Browse Source

Merge branch 'master-new-dev-wf' of wugg/phpstock into master-new

wufeng 1 year ago
parent
commit
bda08e0c5b

+ 1 - 1
app/admin/controller/After.php

@@ -1811,7 +1811,7 @@ class After extends Base
                 ])->findOrEmpty();
 
             if (empty($rs)) throw new Exception('该售后单记录不存在');
-            if (in_array($rs['status'], [4, 12, 5, 8])) throw new Exception('不允许取消');
+            if (in_array($rs['status'], [5,6,8,11,12])) throw new Exception('不允许取消');
 
             //修改记录
             $res = Db::name('order_return')

+ 25 - 8
app/admin/controller/ReportByRelaComNo.php

@@ -367,6 +367,8 @@ class ReportByRelaComNo extends Base
                     'wait_confirm_total_num' => '0',//待与供应商确认-总单数
                     'wait_in_total_fee' => '0',//待入库-总金额
                     'wait_in_total_num' => '0',//待入库-总单数
+                    'relaComNo' => $this->relaComNo,
+                    'relaComName' => $this->relaComName,
                 ];
             }
 
@@ -386,8 +388,6 @@ class ReportByRelaComNo extends Base
                     break;
             }
 
-            $value['业务公司编码'] = $this->relaComNo;
-            $value['业务公司名称'] = $this->relaComName;
 
 //            if ($value['status'] == 0) {
 //                $data[$value['addtime']][$value['itemid']]['wait_total_fee'] += $value['total_fee'];
@@ -431,7 +431,6 @@ class ReportByRelaComNo extends Base
         if (!$val_params->check($param)) return error_show(1004, $val_params->getError());
 
         //@todo  此处无法添加业务公司筛选
-        //@todo 关联表 depart_user、company_item和supplier都需要更换
         $where = [['cb.is_del', '=', 0]];
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['cb.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
 //        if ($param['supplier'] != '') $where[] = ['s.name', 'like', '%' . $param['supplier'] . '%'];
@@ -450,20 +449,38 @@ class ReportByRelaComNo extends Base
 
         $list = Db::name('consult_bids')
             ->alias('cb')
-            ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,du.itemid,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,IF(ISNULL(`du`.`nickname`),`s`.`name`,`du`.`nickname`) nickname,IF(ISNULL(`ci`.`name`),"供应商",`ci`.`name`) name,s.name supplierName')
+//            ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,du.itemid,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,IF(ISNULL(`du`.`nickname`),`s`.`name`,`du`.`nickname`) nickname,IF(ISNULL(`ci`.`name`),"供应商",`ci`.`name`) name,cb.supplierName')
+            ->field('DATE_FORMAT(cb.addtime,"%Y-%m-%d") addtime,cb.createrid,SUM(c.num) num,COUNT(cb.id) total,"" nickname,"" name,cb.supplierName')
             ->leftJoin('consult_info c', 'c.infoNo=cb.infoNo')
-            ->leftJoin('depart_user du', 'du.uid=cb.createrid AND du.is_del=0')
-            ->leftJoin('company_item ci', 'ci.id=du.itemid')
-            ->leftJoin('supplier s', 's.code=cb.supplierNo')
+//            ->leftJoin('depart_user du', 'du.uid=cb.createrid AND du.is_del=0')
+//            ->leftJoin('company_item ci', 'ci.id=du.itemid')
+//            ->leftJoin('supplier s', 's.code=cb.supplierNo')
             ->where($where)
-            ->group('addtime,du.itemid,ci.name ,cb.createrid,du.nickname,s.name')
+//            ->group('addtime,du.itemid,ci.name ,cb.createrid,du.nickname,cb.supplierName')
+            ->group('addtime,cb.createrid,cb.supplierNo')
             ->order('addtime desc,du.itemid,ci.name ,cb.createrid,du.nickname')
 //            ->page($param['page'], $param['size'])
             ->cursor();
 
+        //所有账号
+        $user=Db::connect('mysql_sys')
+            ->name('user')
+            ->alias('a')
+            ->leftJoin('account_item b','b.account_id=a.account_id')
+            ->leftJoin('company_item c','c.id=b.itemid')
+            ->column('a.nickname,c.name','a.account_id');
+
         $data = [];
         foreach ($list as $value) {
 
+            if(isset($user[$value['createrid']])){
+                $value['nickname']=$user[$value['createrid']]['nickname'];
+                $value['name']=$user[$value['createrid']]['name'];
+            }else{
+                $value['nickname']=$value['supplierName'];
+                $value['name']='供应商';
+            }
+
             if ($value['name'] == '供应商') {
                 $data[] = $value;
                 continue;

+ 21 - 16
app/admin/controller/SaleReportByRelaComNo.php

@@ -2582,30 +2582,33 @@ class SaleReportByRelaComNo extends Base
 
         $data = Db::name('sale')
             ->alias('a')
-            ->field('a.id,a.order_type,u.itemid,"" name,a.apply_id')
+            ->field('a.id,a.order_type,a.apply_id')
 //            ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
 //            ->leftJoin("company_item ci", "ci.id=u.itemid")
             ->where($where)
             ->cursor();
-        $list = [];
+        $list = $tmp = [];
         $total = ['name' => '总计', 'tag_1' => 0, 'tag_2' => 0, 'tag_3' => 0, 'tag_total' => 0];
         foreach ($data as $val) {
-            if (!isset($list[$val['itemid']])) $list[$val['itemid']] = [
-                'name' => get_company_name_by_uid($val['apply_id']),
+            if (!isset($tmp[$val['apply_id']])) $tmp[$val['apply_id']] = get_company_name_by_uid($val['apply_id']);
+            $val['company_name'] = $tmp[$val['apply_id']];
+
+            if (!isset($list[$val['company_name']])) $list[$val['company_name']] = [
+                'name' => $val['company_name'],
                 'tag_1' => 0,
                 'tag_2' => 0,
                 'tag_3' => 0,
                 'tag_total' => 0,
-                $value['relaComNo'] = $this->relaComNo,
-                $value['relaComName'] = $this->relaComName,
+                'relaComNo' => $this->relaComNo,
+                'relaComName' => $this->relaComName,
             ];
-            $list[$val['itemid']]['tag_' . $val['order_type']]++;
-            $list[$val['itemid']]['tag_total']++;
+            $list[$val['company_name']]['tag_' . $val['order_type']]++;
+            $list[$val['company_name']]['tag_total']++;
             $total['tag_' . $val['order_type']]++;
             $total['tag_total']++;
 
         }
-        $list = array_merge($list);//重置下标
+        $list = array_values($list);//重置下标
         $list[] = $total;
         return app_show(0, '请求成功', $list);
 
@@ -2623,7 +2626,7 @@ class SaleReportByRelaComNo extends Base
 
         $data = Db::name('sale')
             ->alias('a')
-            ->field('a.id,a.order_type,u.itemid,"" name,a.apply_id ')
+            ->field('a.id,a.order_type,a.apply_id ')
 //            ->leftJoin("depart_user u", "u.uid=a.apply_id AND u.is_del=0")
 //            ->leftJoin("company_item ci", "ci.id=u.itemid")
             ->where($where)
@@ -2631,28 +2634,30 @@ class SaleReportByRelaComNo extends Base
         $list = [];
         $total = ['部门' => '总计', '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0];
         foreach ($data as $k => $val) {
-            if (!isset($list[$val['itemid']])) $list[$val['itemid']] = ['部门' => get_company_name_by_uid($val['apply_id']), '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0, $value['业务公司编码'] = $this->relaComNo, $value['业务公司名称'] = $this->relaComName];
+            if (!isset($tmp[$val['apply_id']])) $tmp[$val['apply_id']] = get_company_name_by_uid($val['apply_id']);
+            $val['company_name'] = $tmp[$val['apply_id']];
+            if (!isset($list[$val['company_name']])) $list[$val['company_name']] = ['部门' => $val['company_name'], '库存品' => 0, '非库存品' => 0, '咨询采反' => 0, '总计' => 0, '业务公司编码' => $this->relaComNo, '业务公司名称' => $this->relaComName];
 
             switch ($val['order_type']) {
                 case 1:
-                    $list[$val['itemid']]['库存品']++;
+                    $list[$val['company_name']]['库存品']++;
                     $total['库存品']++;
                     break;
                 case 2:
-                    $list[$val['itemid']]['非库存品']++;
+                    $list[$val['company_name']]['非库存品']++;
                     $total['非库存品']++;
                     break;
                 case 3:
-                    $list[$val['itemid']]['咨询采反']++;
+                    $list[$val['company_name']]['咨询采反']++;
                     $total['咨询采反']++;
                     break;
             }
 
-            $list[$val['itemid']]['总计']++;
+            $list[$val['company_name']]['总计']++;
             $total['总计']++;
 
         }
-        $list = array_merge($list);//重置下标
+        $list = array_values($list);//重置下标
         $list[] = $total;
 
         if (empty($list)) $list[] = ['没有相关可导出的数据'];