wugg 2 жил өмнө
parent
commit
ac956201e4

+ 4 - 6
app/admin/controller/GoodOfflineLog.php

@@ -36,18 +36,16 @@ class GoodOfflineLog extends Base
     public function getDetail()
     {
 
-        $code = $this->request->post('code', null, 'trim');
+        $id = $this->request->post('id', null, 'trim');
 
-        $val = Validate::rule(['code' => 'require']);
+        $val = Validate::rule(['id' => 'require|number|gt:0']);
 
-        if (!$val->check(['code' => $code])) return error_show(1004, $val->getError());
+        if (!$val->check(['id' => $id])) return error_show(1004, $val->getError());
         else {
             $res = Db::name('good_offline_log')
                 ->alias('gol')
                 ->field('gol.*,ri.result')
-                ->where(function ($query) use ($code) {
-                    return $query->whereFindInSet('gol.skuCodes', $code)->whereOr('gol.spuCode', $code);
-                })
+                ->where('gol.id', $id)
                 ->leftJoin('result_info ri', 'ri.result_code=gol.offline_reason')
                 ->find();
 

+ 12 - 10
app/admin/controller/Goodup.php

@@ -1504,8 +1504,9 @@ class Goodup extends Base
                                 'orderCode' => $skuCode,
                                 'order_type' => 'GOL',
                                 'order_status' => 8,
-                                'action_id' => $createrid,
-                                'action_name' => $creater,
+                                'order_id' => $offline_id,
+                                'apply_id' => $createrid,
+                                'apply_name' => $creater,
                                 'uid' => $itemitem['uid'],
                                 'uname' => empty($itemitem['nickName']) ? '' : $itemitem['nickName'],
                                 'is_read' => 0,
@@ -2707,7 +2708,7 @@ class Goodup extends Base
             $skuCodeS = Db::name("good_platform")
                 ->where(['spuCode' => $param['spuCode'], 'is_del' => 0])//exam_status 7审核失败,8已下线
                 ->column('exam_status,skuCode', 'skuCode');
-            if (empty($skuCodeS)) throw new \Exception('记录不存在');
+            if (empty($skuCodeS)) throw new \Exception('该商品未在任何平台申请上线');
 
             //商品平台
             Db::name("good_platform")
@@ -2731,14 +2732,14 @@ class Goodup extends Base
 
             //根据权限查询应该接收商品下线通知的人员
             $all_uid_name = Db::name('role_action')
-                ->whereFindInSet('action_conllect','877')//数据写死的,要注意各个环境数据是否一致
+                ->whereFindInSet('action_conllect', '877')//数据写死的,要注意各个环境数据是否一致
                 ->field('role_id')
                 ->buildSql();
 
             $all_user = Db::name('user_role')
                 ->alias('ur')
-                ->where('ur.roleid IN '.$all_uid_name)
-                ->leftJoin('depart_user du','du.uid = ur.uid AND du.is_del=0')
+                ->where('ur.roleid IN ' . $all_uid_name)
+                ->leftJoin('depart_user du', 'du.uid = ur.uid AND du.is_del=0')
                 ->column('ur.uid,du.nickName');
 
             $insert_good_exam_data = $insert_order_msg_data = [];
@@ -2773,10 +2774,11 @@ class Goodup extends Base
                         'orderCode' => $skuCode,
                         'order_type' => 'GOL',
                         'order_status' => 8,
+                        'order_id' => $good_offline_log_id,
                         'uid' => $itemitem['uid'],
                         'uname' => empty($itemitem['nickName']) ? '' : $itemitem['nickName'],
-                        'action_id' => $createrid,
-                        'action_name' => $creater,
+                        'apply_id' => $createrid,
+                        'apply_name' => $creater,
                         'is_read' => 0,
                         'addtime' => date('Y-m-d H:i:s'),
                         'updatetime' => date('Y-m-d H:i:s'),
@@ -2791,11 +2793,11 @@ class Goodup extends Base
             Db::name('order_msg')->insertAll($insert_order_msg_data);
 
             Db::commit();
-            return app_show(0, "同一个成本商品编号下的商品下线成功");
+            return app_show(0, "下线成功");
 
         } catch (\Exception $e) {
             Db::rollback();
-            return error_show(1004, '同一个成本商品编号下的商品下线失败,' . $e->getMessage() . '|' . $e->getFile() . '|' . $e->getLine());
+            return error_show(1004, '操作失败,' . $e->getMessage());
         }
     }
 

+ 2 - 2
app/admin/controller/OrderImport.php

@@ -101,7 +101,7 @@ class OrderImport extends Base
         if ($param['company_name']) $where[] = ['c.createrid', 'in', get_company_item_user_by_name($param['company_name'])];
 
         $total = OIFCModel::alias('c')
-            ->leftJoin('good_platform gp', 'gp.plat_code=c.plat_code AND gp.platform_code=c.platform_id AND gp.is_del=0')
+            ->leftJoin('good_platform gp', 'gp.plat_code=c.plat_code AND gp.platform_code=c.platform_id AND gp.is_del=0 AND gp.exam_status=6')
             ->leftJoin('good g', 'g.spuCode=gp.spuCode AND g.is_del=0')
             ->leftJoin('platform p', 'p.id=c.platform_id AND p.is_del=0')
             ->leftJoin("depart_user u", "u.uid=c.createrid AND u.is_del=0")
@@ -110,7 +110,7 @@ class OrderImport extends Base
 
         $list = OIFCModel::alias('c')
             ->field('c.*,g.good_name,p.platform_name platform_title,u.itemid')
-            ->leftJoin('good_platform gp', 'gp.plat_code=c.plat_code AND gp.platform_code=c.platform_id AND gp.is_del=0')
+            ->leftJoin('good_platform gp', 'gp.plat_code=c.plat_code AND gp.platform_code=c.platform_id AND gp.is_del=0 AND gp.exam_status=6')
             ->leftJoin('good g', 'g.spuCode=gp.spuCode AND g.is_del=0')
             ->leftJoin('platform p', 'p.id=c.platform_id AND p.is_del=0')
             ->leftJoin("depart_user u", "u.uid=c.createrid AND u.is_del=0")

+ 69 - 20
app/admin/controller/SaleReport.php

@@ -952,7 +952,7 @@ class SaleReport extends Base
 
         $data = Db::name('purchease_diff')
             ->alias('pd')
-            ->field('pd.addtime,sd.diffCode,sd.orderCode,pd.apply_name,pd.apply_id,po.addtime poaddtime,pd.good_name,ci.companyName,pd.good_num,pd.sale_price,pd.good_weight,pd.diff_weight,pd.diff_price,sd.status,po.order_type,po.spuCode')
+            ->field('pd.addtime,sd.diffCode,sd.orderCode,pd.apply_name,pd.apply_id,po.addtime poaddtime,pd.good_name,ci.companyName,pd.good_num,pd.sale_price,pd.good_weight,pd.diff_weight,pd.diff_price,sd.status,po.order_type,po.spuCode,s.apply_name sale_apply_name,s.apply_id sale_apply_id')
             ->leftJoin('sale_diff sd', 'sd.cgd_diffid=pd.id')
             ->leftJoin('purchease_order po', 'po.cgdNo=pd.cgdNo')
             ->leftJoin('order_num on', 'on.cgdNo=pd.cgdNo')
@@ -972,6 +972,7 @@ class SaleReport extends Base
 
 
             $value['apply_company'] = get_company_name_by_uid($value['apply_id']);
+            $value['sale_apply_company'] = get_company_name_by_uid($value['sale_apply_id']);
             $value['noble_metal'] = isset($this->noble_metal[$noble_metal]) ? $this->noble_metal[$noble_metal] : '';
             $value['total_price'] = round($value['sale_price'], $value['good_num'], 2);
             $value['is_update_sale'] = isset($this->sale_diff_status[$value['status']]) ? $this->sale_diff_status[$value['status']] : '';
@@ -993,7 +994,7 @@ class SaleReport extends Base
 
         $data = Db::name('purchease_diff')
             ->alias('pd')
-            ->field('pd.addtime 发起时间,sd.diffCode 工差单号,sd.orderCode 关联确认单,pd.apply_name 创建人,"" 部门,pd.apply_id,po.addtime 确认单下单日期,pd.good_name 产品名称,ci.companyName 客户名称,"" 贵金属种类,pd.good_num 下单数量,pd.sale_price 单价,"" 总额,pd.good_weight 商品总重量,pd.diff_weight 工差重量,pd.diff_price 销售工差总费用,sd.status 是否修改销售额,po.order_type,po.spuCode')
+            ->field('pd.addtime 发起时间,sd.diffCode 工差单号,sd.orderCode 关联确认单,pd.apply_name 创建人,"" 部门,pd.apply_id,po.addtime 确认单下单日期,pd.good_name 产品名称,ci.companyName 客户名称,"" 贵金属种类,pd.good_num 下单数量,pd.sale_price 单价,"" 总额,pd.good_weight 商品总重量,pd.diff_weight 工差重量,pd.diff_price 销售工差总费用,sd.status 是否修改销售额,s.apply_name 销售人员,s.apply_id sale_apply_id,"" 销售部门,po.order_type,po.spuCode')
             ->leftJoin('sale_diff sd', 'sd.cgd_diffid=pd.id')
             ->leftJoin('purchease_order po', 'po.cgdNo=pd.cgdNo')
             ->leftJoin('order_num on', 'on.cgdNo=pd.cgdNo')
@@ -1011,6 +1012,7 @@ class SaleReport extends Base
             else $noble_metal = Db::name('good_basic')->where(['spuCode' => $value['spuCode']])->value('noble_metal');
 
             $value['部门'] = get_company_name_by_uid($value['apply_id']);
+            $value['销售部门'] = get_company_name_by_uid($value['sale_apply_id']);
             $value['贵金属种类'] = isset($this->noble_metal[$noble_metal]) ? $this->noble_metal[$noble_metal] : '';
             $value['总额'] = round($value['单价'], $value['下单数量'], 2);
             $value['是否修改销售额'] = isset($this->sale_diff_status[$value['是否修改销售额']]) ? $this->sale_diff_status[$value['是否修改销售额']] : '';
@@ -1018,6 +1020,7 @@ class SaleReport extends Base
             unset($value['apply_id']);
             unset($value['order_type']);
             unset($value['spuCode']);
+            unset($value['sale_apply_id']);
 
             $list[] = $value;
         }
@@ -1030,45 +1033,91 @@ class SaleReport extends Base
     //【五、退货明细表】
     public function thData()
     {
-        $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
+        $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
 
-        $where = [['thd.is_del', '=', 0]];
+        $where = [['thd.is_del', '=', 0], ['thd.th_type', 'in', [2, 3]]];
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];
-        if ($param['status'] != '') $where[] = ['or.status', '=', $param['status']];
 
         $count = Db::name('th_data')
             ->alias('thd')
-            ->leftJoin('order_out oo', 'oo.orderCode=thd.orderCode')
-            ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
-            ->leftJoin('order_return or', 'or.returnCode=thd.thCode')
             ->leftJoin('sale s', 's.orderCode=thd.orderCode')
             ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
-            ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
             ->where($where)
+            ->order('thd.addtime', 'desc')
             ->count('thd.id');
 
         $data = Db::name('th_data')
             ->alias('thd')
-            ->field('thd.addtime return_time,thd.thCode,oo.outCode,or.status,thd.apply_name,thd.apply_id,thd.orderCode,s.addtime,c.companyName,s.good_name,s.sale_price,s.wsend_num,s.th_num,s.th_fee,oa.contactor,oa.mobile,oa.addr,oa.addr_code,ri.result result_desc')
-            ->leftJoin('order_out oo', 'oo.orderCode=thd.orderCode')
-            ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
-            ->leftJoin('order_return or', 'or.returnCode=thd.thCode')
+            ->field('thd.id,thd.th_type,thd.addtime return_time,thd.thCode,"" outCode,"" status,"" apply_name,"" apply_company,thd.orderCode,s.addtime,c.companyName,s.good_name,s.sale_price,s.wsend_num,s.th_num,s.th_fee,"" contactor,"" mobile,"" addr,"" result')
             ->leftJoin('sale s', 's.orderCode=thd.orderCode')
             ->leftJoin('customer_info c', 'c.companyNo=s.customer_code')
-            ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
             ->where($where)
-            ->page($param['page'], $param['size'])
             ->order('thd.addtime', 'desc')
-            ->cursor();
+            ->select()
+            ->toArray();
+
+        $th_types = [];
+        foreach ($data as $value) {
+            $th_types[$value['th_type']][] = $value['thCode'];
+        }
+
+        $all_order_return = Db::name('order_return')
+            ->alias('or')
+            ->withAttr('status', function ($val) {
+                return isset($this->all_order_return_status[$val]) ? $this->all_order_return_status[$val] : '';
+            })
+            ->withAttr('apply_company', function ($val, $da) {
+                return get_company_name_by_uid($da['apply_id']);
+            })
+            ->leftJoin('order_out oo', 'oo.outCode=or.outCode')
+            ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
+            ->leftJoin('result_info ri', 'ri.result_code=or.error_code')
+            ->where('or.is_del', 0)
+            ->whereIn('or.returnCode', $th_types[2])
+            ->column('or.id,or.outCode,or.status,or.apply_id,or.apply_name,"" apply_company,oa.contactor,oa.mobile,oa.addr,ri.result,oa.addr_code', 'or.returnCode');
+
+
+        $all_order_back = Db::name('order_back')
+            ->alias('ob')
+            ->where('ob.is_del', 0)
+            ->whereIn('ob.thNo', $th_types[3])
+            ->withAttr('status', function ($val) {
+                return isset($this->order_back_status[$val]) ? $this->order_back_status[$val] : '';
+            })
+            ->withAttr('apply_company', function ($val, $da) {
+                return get_company_name_by_uid($da['apply_id']);
+            })
+            ->leftJoin('order_out oo', 'oo.outCode=ob.outCode')
+            ->leftJoin('order_addr oa', 'oa.id=oo.addrid')
+            ->leftJoin('result_info ri', 'ri.result_code=ob.return_code')
+            ->column('ob.id,ob.outCode,ob.status,ob.apply_id,ob.apply_name,"" apply_company,oa.contactor,oa.mobile,oa.addr,ri.result,oa.addr_code', 'thNo');
 
         $list = [];
 
         foreach ($data as $value) {
-            $value['status'] = isset($this->all_order_return_status[$value['status']]) ? $this->all_order_return_status[$value['status']] : '';
-            $value['apply_company'] = get_company_name_by_uid($value['apply_id']);
+            if ($value['th_type'] == 2) {
+                $value['outCode'] = isset($all_order_return[$value['thCode']]['outCode']) ? $all_order_return[$value['thCode']]['outCode'] : '';
+                $value['status'] = isset($all_order_return[$value['thCode']]['status']) ? $all_order_return[$value['thCode']]['status'] : '';
+                $value['apply_name'] = isset($all_order_return[$value['thCode']]['apply_name']) ? $all_order_return[$value['thCode']]['apply_name'] : '';
+                $value['apply_company'] = isset($all_order_return[$value['thCode']]['apply_company']) ? $all_order_return[$value['thCode']]['apply_company'] : '';
+                $value['contactor'] = isset($all_order_return[$value['thCode']]['contactor']) ? $all_order_return[$value['thCode']]['contactor'] : '';
+                $value['mobile'] = isset($all_order_return[$value['thCode']]['mobile']) ? $all_order_return[$value['thCode']]['mobile'] : '';
+                $value['addr'] = isset($all_order_return[$value['thCode']]['addr']) ? $all_order_return[$value['thCode']]['addr'] : '';
+                $value['result'] = isset($all_order_return[$value['thCode']]['result']) ? $all_order_return[$value['thCode']]['result'] : '';
+            } elseif ($value['th_type'] == 3) {
+                $value['outCode'] = isset($all_order_back[$value['thCode']]['outCode']) ? $all_order_back[$value['thCode']]['outCode'] : '';
+                $value['status'] = isset($all_order_back[$value['thCode']]['status']) ? $all_order_back[$value['thCode']]['status'] : '';
+                $value['apply_name'] = isset($all_order_back[$value['thCode']]['apply_name']) ? $all_order_back[$value['thCode']]['apply_name'] : '';
+                $value['apply_company'] = isset($all_order_back[$value['thCode']]['apply_company']) ? $all_order_back[$value['thCode']]['apply_company'] : '';
+                $value['contactor'] = isset($all_order_back[$value['thCode']]['contactor']) ? $all_order_back[$value['thCode']]['contactor'] : '';
+                $value['mobile'] = isset($all_order_back[$value['thCode']]['mobile']) ? $all_order_back[$value['thCode']]['mobile'] : '';
+                $value['addr'] = isset($all_order_back[$value['thCode']]['addr']) ? $all_order_back[$value['thCode']]['addr'] : '';
+                $value['result'] = isset($all_order_back[$value['thCode']]['result']) ? $all_order_back[$value['thCode']]['result'] : '';
+            }
+
             $list[] = $value;
         }
-
+        
         return app_show(0, '请求成功', ['list' => $list, 'count' => $count]);
 
     }
@@ -1076,7 +1125,7 @@ class SaleReport extends Base
     //【五、退货明细表】
     public function thDataExport()
     {
-        $param = $this->request->only(['token', 'start_date' => '', 'end_date' => '', 'status' => ''], 'post', 'trim');
+        $param = $this->request->only(['token', 'start_date' => '', 'end_date' => ''], 'post', 'trim');
 
         $where = [['thd.is_del', '=', 0], ['thd.th_type', 'in', [2, 3]]];
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['thd.addtime', 'between', [$param['start_date'] . ' 00:00:00', $param['end_date'] . ' 23:59:59']];

+ 3 - 1
app/admin/model/OrderMsg.php

@@ -29,7 +29,9 @@ class OrderMsg extends Model
                 $temp['content']=$content;
                 $temp['orderCode']=$msg['order_code'];
                 $temp['order_type']=$msg['order_type'];
-                $temp['uid']=$value['action_uid'];
+                $temp['order_status']=$msg['order_status'];
+                $temp['order_id']=$msg['order_id'];
+                $temp['uid']=$value['action_uid'];//所有人,缺申请人和操作人
                 $temp['uname']=$value['action_name'];
                 $temp['is_read']=0;
                 $temp['addtime']=date("Y-m-d H:i:s");