|
@@ -69,27 +69,38 @@ class stat_anoticeControl extends SystemControl
|
|
|
|
|
|
public function fcodeOp()
|
|
|
{
|
|
|
+ $mod_goods = Model('goods');
|
|
|
$mod_fcode = Model('goods_fcode');
|
|
|
- $result = $mod_fcode->field('goods_commonid,fc_state,batch_code,fc_code,count(*) as nc_count')->group('batch_code,fc_state')->select();
|
|
|
- foreach ($result as $item=>$value)
|
|
|
+ $items = $mod_fcode->field('goods_commonid,batch_code,count(*) as nc_count')->group('goods_commonid,batch_code')->select();
|
|
|
+
|
|
|
+ $result = [];
|
|
|
+ foreach ($items as $item)
|
|
|
{
|
|
|
+ $val = [];
|
|
|
|
|
|
- $data[$value['batch_code']]['batch_code']= $value['batch_code'];
|
|
|
- $data[$value['batch_code']]['fc_sum'] += $value['nc_count'];
|
|
|
- if ($value['fc_state'] == '0') {
|
|
|
- $data[$value['batch_code']]['unused_quantity']= $value['nc_count'];
|
|
|
- } else if ($value['fc_state'] == '1') {
|
|
|
- $data[$value['batch_code']]['used_quantity']= $value['nc_count'];
|
|
|
- }
|
|
|
- $data[$value['batch_code']]['goods_commonid']= $value['goods_commonid'];
|
|
|
- if (empty($data[$value['batch_code']]['fc_link']))
|
|
|
- {
|
|
|
- $url = BASE_SITE_URL . '/mobile/index.php?act=fcode&op=open' . "&common_id={$value['goods_commonid']}&batch_code={$value['batch_code']}";
|
|
|
- $data[$value['batch_code']]['fc_link'] = $url;
|
|
|
+ $val['goods_commonid'] = $item['goods_commonid'];
|
|
|
+ $val['batch_code'] = $item['batch_code'];
|
|
|
+ $val['count'] = $item['nc_count'];
|
|
|
+
|
|
|
+ $unused = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'fc_state' => 0))->count();
|
|
|
+ $binded = $mod_fcode->where(array('goods_commonid' => $item['goods_commonid'],'batch_code' => $item['batch_code'],'grab_state' => 2))->count();
|
|
|
+
|
|
|
+ $val['used'] = $item['nc_count'] - $unused;
|
|
|
+ $val['binded'] = $binded;
|
|
|
+
|
|
|
+ $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$item['goods_commonid']}&batch_code={$item['batch_code']}";
|
|
|
+ $val['fc_link'] = $url;
|
|
|
+ $goods = $mod_goods->where(array('goods_commonid' => $item['goods_commonid']))->limit(1)->select();
|
|
|
+ if(empty($goods)) {
|
|
|
+ $val['goods_name'] = "不存在了!";
|
|
|
+ } else {
|
|
|
+ $val['goods_name'] = $goods[0]['goods_name'];
|
|
|
}
|
|
|
+
|
|
|
+ $result[] = $val;
|
|
|
}
|
|
|
|
|
|
- Tpl::output('list', $data);
|
|
|
+ Tpl::output('list', $result);
|
|
|
Tpl::showpage('stat.anotice.fcode.list');
|
|
|
}
|
|
|
}
|