Jelajahi Sumber

Merge branch 'version1.5' into wugg-dev

wugg 2 tahun lalu
induk
melakukan
6cf49bab89

+ 4 - 2
app/abutment/controller/Consult.php

@@ -960,7 +960,8 @@ class Consult extends HomeBaseController
                                             "order_id" => $projetc['id'],
                                             "order_status" => 2,
                                             "before_status" => 1,
-                                            'holder_id'=>$projetc['createrid']
+                                            'holder_id'=>$projetc['createrid'],
+                                            'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                                         ]);
                                     }
                                 }
@@ -1209,7 +1210,8 @@ class Consult extends HomeBaseController
                                                     "order_id" => $project_id['id'],
                                                     "order_status" => 2,
                                                     "before_status" => 1,
-                                                    'holder_id'=>$project_id['createrid']
+                                                    'holder_id'=>$project_id['createrid'],
+                                                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                                                 ]
                                             );
                                         }

+ 5 - 0
app/abutment/controller/Good.php

@@ -533,6 +533,7 @@ class Good extends HomeBaseController
                     "order_status" => 0,
                     "before_status" => 0,
                     'holder_id' => $data['createrid'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
                 Db::commit();
                 return json_show(0, "创建成功", ["spuCode" => $spucode]);
@@ -801,6 +802,7 @@ class Good extends HomeBaseController
                     "order_status" => $temp['status'],
                     "before_status" => $data['status'],
                     'holder_id' => $data['createrid'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
                 Db::commit();
                 return json_show(0, "更新成功");
@@ -907,6 +909,7 @@ class Good extends HomeBaseController
                     "order_status" => $data['status'],
                     "before_status" => $datas['status'],
                     'holder_id' => $datas['createrid'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
 //                $online =  Db::name("good_platform")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
 //                if($online){
@@ -1266,6 +1269,7 @@ class Good extends HomeBaseController
                     "order_status" => 0,
                     "before_status" => 0,
                     'holder_id' => $data['createrid'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
                 if ($speclist !== "" && !empty($speclist)) {
                     foreach ($speclist as $value) {
@@ -1706,6 +1710,7 @@ class Good extends HomeBaseController
                     "order_status" => 7,
                     "before_status" => 0,
                     'holder_id' => $data['createrid'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
                 if (!empty($ladd)) {
                     $na = Db::name("good_nake")->insertAll($ladd);

+ 5 - 2
app/abutment/controller/Sale.php

@@ -301,7 +301,8 @@ class Sale extends HomeBaseController
                     "order_id" => $einfo['id'],
                     "order_status" => $einfo['status'],
                     "before_status" => $orderstatus,
-                    'holder_id' => $einfo['apply_id']
+                    'holder_id' => $einfo['apply_id'],
+                    'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                 ]);
 
                 $stokc = Db::name("good_stock")->where(['spuCode' => $einfo['good_code'], "wsm_code" => $outinfo['wsm_code'], "is_del" => 0])->find();
@@ -464,6 +465,7 @@ class Sale extends HomeBaseController
                         'wait_id' => $order_out_infos[$value['outCode']]['apply_id'],
                         'wait_name' => $order_out_infos[$value['outCode']]['apply_name'],
                         'holder_id' => $order_out_infos[$value['outCode']]['apply_id'],
+                        'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                     ]);
 
 
@@ -494,7 +496,8 @@ class Sale extends HomeBaseController
                         "order_id" => $sale_infos[$order_out_infos[$value['outCode']]['orderCode']]['id'],
                         "order_status" => $einfo['status'],
                         "before_status" => $sale_infos[$order_out_infos[$value['outCode']]['orderCode']]['status'],
-                        'holder_id' => $sale_infos[$order_out_infos[$value['outCode']]['orderCode']]['apply_id']
+                        'holder_id' => $sale_infos[$order_out_infos[$value['outCode']]['orderCode']]['apply_id'],
+                        'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
                     ]);
 
                     //【库存】

+ 1 - 2
app/admin/controller/Consult.php

@@ -1614,8 +1614,7 @@ class Consult extends Base
                     "action_remark" => '',//备注
                     "action_type" => "status"//新建create,编辑edit,更改状态status
                 ], "YJD", $info['status'], $info);
-                $process=["order_code"=>$bargainNo,"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'YJD',"before_status"=>$ra_status,'holder_id'=>$info['createrid']
-                ];
+                $process=["order_code"=>$bargainNo,"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'YJD',"before_status"=>$ra_status,'holder_id'=>$info['createrid']];
                 ProcessOrder::AddProcess($token,$process);
                 if($info['status']==1||$info['status']==3||$info['status']==8||$info['status']==6||$info['status']==9||$info['status']==10||$info['status']==11){
                     $bidstatus=$bids['status'];

+ 10 - 4
app/admin/controller/Good.php

@@ -64,7 +64,11 @@ class Good extends Base
         $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !=="" ? trim($this->post['supplierNo'])
             :"";
         if($supplierNo!==""){
-            $where[]=['a.supplierNo',"=",$supplierNo];
+            $where[]=['a.supplierNo',"like","%$supplierNo%"];
+        }
+         $supplier_name = isset($this->post['supplier_name']) && $this->post['supplier_name'] !=="" ? trim($this->post['supplier_name']):"";
+        if($supplier_name!==""){
+            $where[]=['s.name',"like","%$supplier_name%"];
         }
         $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) :"";
         if($companyNo!==""){
@@ -118,6 +122,7 @@ class Good extends Base
         $count = Db::name('good')
             ->alias("a")
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+            ->leftJoin("supplier s","a.supplierNo=s.code")
             ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
             ->leftJoin("platform p","p.id=b.platform_code")
             ->where('p.platform_type',0)//只筛选非对接平台的商品
@@ -129,9 +134,10 @@ class Good extends Base
             ->alias("a")
             ->field("b.skuCode,b.platform_code,b.plat_code,b.id as good_id,a.cat_id,a.good_name,a.good_img,a.good_info_img,a.good_thumb_img,
             b.createrid,a.is_exclusive,a.brand_id,a.supplierNo,a.good_unit,a.noble_metal,a.companyNo,a.spuCode,a.good_type,b.creater,b.addtime,
-            b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid,a.is_stock")
+            b.updatetime,b.exam_status,a.createrid purchase_id,a.creater purchase,u.itemid,a.is_stock,s.name as supplier_name")
             //成本表里的创建人,也是线上商品的采购人,为了防止混淆,给creater取个别名
             ->leftJoin("good_platform b","a.spuCode=b.spuCode")
+            ->leftJoin("supplier s","a.supplierNo=s.code")
 //            ->leftJoin("good_basic gb","gb.spuCode=a.spuCode")
             ->leftJoin("depart_user u", "u.uid=b.createrid AND u.is_del=0")
             ->leftJoin("platform p","p.id=b.platform_code")
@@ -146,8 +152,8 @@ class Good extends Base
             $platform = Db::name("platform")->where(["id"=>$value['platform_code']])->find();
             $value['platform_name'] = isset($platform['platform_name']) ? $platform['platform_name']:"";
             $value['platform_code_en'] = isset($platform['platform_code_en']) ? $platform['platform_code_en']:"";
-            $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
-            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name']:"";
+//            $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
+//            $value['supplier_name'] = isset($supplier['name']) ? $supplier['name']:"";
             $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
             $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
             $unit = Db::name("unit")->where(["id"=>$value['good_unit']])->find();

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

@@ -12,14 +12,15 @@ class GoodOfflineLog extends Base
     public function getList()
     {
 
-        $param = $this->request->only(['start_date' => '', 'end_date' => '', 'creater' => '', 'page' => 1, 'size' => 15], 'post', 'trim');
+        $param = $this->request->only(['start_date' => '', "spuCode"=>'',"good_name"=>'','end_date' => '', 'creater' => '',
+         'page' => 1,'size' => 15], 'post', 'trim');
 
         $where = [];
         if ($param['start_date'] != '' && $param['end_date'] != '') $where[] = ['addtime', 'between', [$param['start_date'], $param['end_date']]];
         if ($param['creater'] != '') $where[] = ['creater', 'like', '%' . $param['creater'] . '%'];
-
+        if ($param['spuCode'] != '') $where[] = ['spuCode', 'like', '%' . $param['spuCode'] . '%'];
+        if ($param['good_name'] != '') $where[] = ['good_name', 'like', '%' . $param['good_name'] . '%'];
         $count = Db::name('good_offline_log')->where($where)->count('id');
-
         $list = Db::name('good_offline_log')
             ->field('id,spuCode,good_name,creater,addtime')
             ->where($where)

+ 42 - 13
app/admin/controller/Proorder.php

@@ -67,13 +67,39 @@ class Proorder extends Base
             if ($param['order_code'] != '') $db->whereLike("a.order_code", '%' . $param['order_code'] . '%');
             if ($param['action_uid'] != '') $db->where('a.action_uid', $param['action_uid']);
 
-            $count = $db->count();
+            $count = $db
+//                ->field("ANY_VALUE(`a`.`id`) id,`a`.order_type,`a`.order_id,GROUP_CONCAT(`a`.`id` ORDER BY `a`.`id` DESC) ids")
+                ->group('a.order_type,a.order_id')
+//                ->order(['a.id'=>'desc'])
+//                ->fetchSql()
+//                ->withAttr('ids', function ($val) {
+//                    $temp = explode(',', $val);
+//                    return $temp[0];
+//                })
+//                ->page($page, $param['size'])
+                ->count('a.id');
 
             $total = ceil($count / $param['size']);
             $page = $param['page'] > $total ? $total : $param['page'];
-            $list = $db
-                ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id")
+
+            //筛选符合条件的order_type,排除重复数据
+            $order_types = $db
+                ->field("ANY_VALUE(`a`.`id`) id,`a`.order_type,`a`.order_id,GROUP_CONCAT(`a`.`id` ORDER BY `a`.`id` DESC) ids")
+                ->group('a.order_type,a.order_id')
+                ->order(['id' => 'desc'])
+                ->withAttr('ids', function ($val) {
+                    $temp = explode(',', $val);
+                    return $temp[0];
+                })
                 ->page($page, $param['size'])
+                ->select()
+                ->toArray();
+
+            $list = ProcessWait::alias("a")
+                ->field("b.apply_id,b.apply_name,a.addtime,a.action_uid,a.action_name,a.order_status,a.order_type,a.order_process,a.order_code,a.order_id,a.id,a.order_process_finally")
+                ->whereIn('a.id', array_column($order_types, 'ids'))
+                ->leftJoin("workflow b", "a.order_type=b.order_type and a.order_code=b.order_code")
+//                ->page($page, $param['size'])
                 ->order("a.addtime desc")
                 ->select()
                 ->toArray();
@@ -86,15 +112,18 @@ class Proorder extends Base
             $data = [];
             foreach ($list as $value) {
                 $var = Db::name("action_process")
-                    ->where(['order_type' => $value['order_type'], 'order_process' => $value['order_process']])
-                    ->field("status_name,order_process,order_name,roleid")
-                    ->find();
+                    ->where(['order_type' => $value['order_type']])
+                    ->whereIn('order_process', [$value['order_process'], $value['order_process_finally']])
+//                    ->field("status_name,order_process,order_name,roleid")
+                    ->column('status_name,order_process,order_name,roleid', 'order_process');
+//                    ->find();
                 $value['process_name'] = isset($all_process[$value['order_type']]) ? $all_process[$value['order_type']] : '';
-                $value['order_name'] = $var['order_name'];
-                $value['status_name'] = $var['status_name'];
+                $value['order_name'] = $var[$value['order_process']]['order_name'];
+                $value['status_name'] = $var[$value['order_process']]['status_name'];
+                $value['order_process_finally_status_name'] = $var[$value['order_process_finally']]['status_name'] ?? '';
                 $data[] = $value;
             }
-            return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
+            return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);
         }
 
 
@@ -109,12 +138,13 @@ class Proorder extends Base
         $db = ProcessWait::alias("a")
             ->leftJoin('workflow b', 'a.order_type=b.order_type and a.order_code=b.order_code')
 //            ->leftJoin('process p', 'p.process_type=a.order_type AND p.is_del=0 AND p.status=1')
-            ->where(['a.status' => ProcessWait::$status_wait])
-            ->whereFindInSet('handle_user_list', $this->uid);
+            ->where(['a.status' => ProcessWait::$status_wait]);
+
 
 //        $db->where(function ($query) use ($param) {
         //所属角色
-//            $role = $this->checkRole();
+        $role = $this->checkRole();
+        if ($role['roleid'] != 1) $db->whereFindInSet('handle_user_list', $this->uid);
 
 //            if (!empty($role['write']) || $role['roleid'] == 33) $query->whereFindInSet('roleid', $role['roleid']);
 //            $query->whereFindInSet('roleid', $role['roleid']);
@@ -323,5 +353,4 @@ class Proorder extends Base
     }
 
 
-
 }

+ 4 - 4
app/admin/controller/Purch.php

@@ -86,22 +86,22 @@ class Purch extends Base
         $start = isset($this->post['start']) && $this->post['start']!="" ?$this->post['start']:"";
         if($start!=""){
             // $where['addtime'] = Db::raw(" >= '{$start}'");
-            $where[]=['po.addtime',">=", $start];
+            $where[]=['po.addtime',">=", $start." 00:00:00"];
         }
         $end = isset($this->post['end']) && $this->post['end']!="" ?$this->post['end']:"";
         if($end!=""){
-            $where[]=['po.addtime',"<=", $end];
+            $where[]=['po.addtime',"<=", $end." 23:59:59"];
         }
         $last_start = isset($this->post['last_start']) && $this->post['last_start']!="" ?$this->post['last_start']:"";
         if($last_start!=""){
             //$where['lasttime'] = Db::raw(" >= '{$last_start}'");
-            $where[]=['po.lasttime',">=", $last_start];
+            $where[]=['po.lasttime',">=", $last_start." 00:00:00"];
 
         }
         $last_end = isset($this->post['last_end']) && $this->post['last_end']!="" ?$this->post['last_end']:"";
         if($last_end!=""){
             //$where['lasttime'] = Db::raw(" <= '{$last_end}'");
-            $where[]=['po.lasttime',"<=", $last_end];
+            $where[]=['po.lasttime',"<=", $last_end." 23:59:59"];
         }
         $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ?$this->post['orderCode']:"";
         if($orderCode!=""){

+ 23 - 6
app/admin/controller/Reorder.php

@@ -878,6 +878,16 @@ class Reorder extends Base
                         "order_status" =>$orderinfo['status'],"before_status"=>$lor
                     ]);
 
+                    //对应采购单也要处理
+                    ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], [
+                        "order_type" => 'CGD',
+                        "order_code" => $cgd['cgdNo'],
+                        "order_id" => $cgd["id"],
+                        "order_status" => $cgd['status'],
+                        "before_status" => $lor,
+                        'holder_id' => Db::name('supplier')->where(['code' => $cgd['supplierNo'], 'is_del' => 0])->value('personid', 0)
+                    ]);
+
                     if($orderinfo['is_stock'] == 1 || $info['is_th'] == 0){
                         $wsmcode = $orderinfo['is_stock'] == 1 ? $cgd['wsm_code'] : $info['return_wsm'];
                         if ($wsmcode == "") {
@@ -1091,8 +1101,7 @@ class Reorder extends Base
         if($order['wsend_num']!=$order['good_num']){
         	  return error_show(1005,"订单未发货数量与总数不等,无法全退");
         }
-        $retrun =Db::name("sale_return")->where([["orderCode","=",$orderCode],["is_del","=",0],["status","<",4]])
-            ->count();
+        $retrun =Db::name("sale_return")->where([["orderCode","=",$orderCode],["is_del","=",0],["status","<",4]])->count();
         if($retrun>0){
             return error_show(1005,"存在退货订单数据");
         }
@@ -1200,6 +1209,16 @@ class Reorder extends Base
                                         Db::rollback();
                                         return error_show(1004, "地址发货单更新失败");
                                     }
+
+                            //处理发货申请单流程
+                            ProcessOrder::AddProcess(["id" => $this->uid, "nickname" => $this->uname], [
+                                "order_type" => 'CKD',
+                                "order_code" => $send["outCode"],//出库单号
+                                "order_id" => $send["id"],
+                                "order_status" => 4,//全部退货
+                                "before_status" => $send['status'],
+                                'holder_id=' => $send['apply_id']
+                            ]);
 //                                    $ordersend = Db::name("order_send")->where(["outCode" => $send['outCode']])->find();
 //                                    if($ordersend==false){
 //                                    	Db::rollback();
@@ -1262,8 +1281,7 @@ class Reorder extends Base
                         'holder_id=' => $order['apply_id']
                     ]);
 
-                  	$saleinfo=Db::name("sale_info")->where([["orderCode","=",$orderCode],["num",">",0]])->select()
-					->toArray();
+                  	$saleinfo=Db::name("sale_info")->where([["orderCode","=",$orderCode],["num",">",0]])->select()->toArray();
 					if(empty($saleinfo)) {
 						Db::rollback();
 						return error_show(1005, '商品批次数据未找到');
@@ -1271,8 +1289,7 @@ class Reorder extends Base
 					$tempnum =$thnum;
 					foreach ( $saleinfo as $va){
 					if($tempnum ==0) break;
-					$stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'id' => $va['stockid']])
-                        ->find();
+					$stock = Db::name("good_stock")->where(["spuCode" => $order['good_code'], 'id' => $va['stockid']])->find();
 					if($stock==false) {
 						Db::rollback();
 						return error_show(1005, '商品库存数据未找到');

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

@@ -204,7 +204,7 @@ class Resign extends Base
         ];
         $in = Db::name("purchease")->insert($info,true);
         if($in>0){
-            $order=["order_type"=>'BHD',"order_code"=>$bk_code,"order_id"=>$in,"order_status"=>1,"before_status"=>1, 'holder_id' => $info['apply_id']];
+            $order=["order_type"=>'BHD',"order_code"=>$bk_code,"order_id"=>$in,"order_status"=>1,"before_status"=>1, 'holder_id' => $info['cgderid']];
             ProcessOrder::AddProcess($token,$order);
             $ste = ["order_code"=>$bk_code,"status"=>0,"action_remark"=>'',"action_type"=>"create"];
             ActionLog::logAdd($token,$ste,"BHD",1,$info);

+ 3 - 3
app/admin/controller/Resigninfo.php

@@ -111,10 +111,10 @@ class Resigninfo extends Base
         ];
         $in = Db::name('resign_info')->insertGetId($data);
         $stn = ["order_code"=>'',"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
-        ActionLog::logAdd(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$stn,"LZJJ",$status,$stn);
+        ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname],$stn,"LZJJ",$status,$stn);
 
-        $process=["order_code"=>'',"order_id"=>$in,"order_status"=>$status,"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $data['hand_uid']];
-        ProcessOrder::AddProcess(['id'=>isset($resign_uid["data"]['id'])?$resign_uid["data"]['id']:0,'nickname'=>$ri],$process);
+        $process=["order_code"=>'',"order_id"=>$in,"order_status"=>$status,"order_type"=>'LZJJ',"before_status"=>0, 'holder_id' => $this->uid];
+        ProcessOrder::AddProcess(['id'=>$this->uid,'nickname'=>$this->uname],$process);
         return $in ? error_show(0,"添加成功") : error_show(1002,"添加失败");
     }
     public function selec(){

+ 30 - 3
app/admin/controller/Sale.php

@@ -3272,6 +3272,10 @@ class Sale extends Base
         if ($good_name !== "") {
             $where[] = ['b.good_name', "like", "%$good_name%"];
         }
+        $supplier_name = isset($this->post['supplier_name']) && $this->post['supplier_name'] !== "" ? trim($this->post['supplier_name']) : "";
+        if ($supplier_name !== "") {
+            $where[] = ['wpo.supplier_name', "like", "%$supplier_name%"];
+        }
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
         if ($status !== "") {
             $where[] = ['a.status', "=", $status];
@@ -4402,9 +4406,7 @@ class Sale extends Base
         Db::startTrans();
         try {
 
-            $good_data = [];
-
-            $temp_out_codes = [];
+            $good_data =  $temp_out_codes = $yz_data = [];
 
             foreach ($param['list'] as $value) {
 
@@ -4553,12 +4555,37 @@ class Sale extends Base
 
                 } else throw new Exception($value['outCode'] . '发货失败');
                 Cache::store("redis")->handler()->lPush("SENDOUT",$value['outCode']);
+
+
+                //如果是有赞订单的话,将发货信息推到有赞
+                if($sale_infos[$order_out_infos[$value['outCode']]['orderCode']]['order_source']==5){
+                    $yz_data[]=[
+                        'orderCode'=>$sale_infos[$order_out_infos[$value['outCode']]['orderCode']],
+                        'out_stype'=>isset($value['post_name']) ? $value['post_name'] : '',
+                        'post_code'=>$value['post_code'],
+                        'uid'=>$createrid,
+                        'uname'=>$creater,
+                        'order_out'=>$value['outCode'],
+                    ];
+                }
             }
 
             if (!empty($good_data)) GoodLog::LogAdd(['id' => $createrid, 'nickname' => $creater], $good_data, "CKD");
 
             Db::commit();
 
+            //如果是有赞订单的话,将发货信息推到有赞
+            //有赞信息有可能推送失败(比如超过72小时,不允许多次修改等),所以不应该和这里的事务放到一起
+            if ($yz_data) {
+                foreach ($yz_data as $yz) {
+//                    $res = curl_request(config('app.yz_domain') . 'api/yz_out_send', ['orderCode' => $einfo['orderCode'], 'out_stype' => $post_name, 'post_code' => $post_code, 'uid' => $uid, 'uname' => $uname, 'order_out' => $outCode]);
+                    curl_request(config('app.yz_domain') . 'api/yz_out_send', $yz);
+                }
+
+//                $res = json_decode($res, true);
+//                if ($res['code'] != 0) return app_show(0, '发货成功,' . $res['message']);
+            }
+
             return app_show(0, '发货成功');
 
         } catch (Exception $exception) {

+ 1 - 1
app/admin/model/ProcessOrder.php

@@ -42,7 +42,7 @@ class ProcessOrder extends \think\Model
 
         //手动排除竞价单ZXD
         if($order['order_type']!='ZXD') {
-            ProcessWait::add(array_merge($data, ['holder_id' => $order['holder_id'] ?? 0]), isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '');
+            ProcessWait::add(array_merge($data, ['holder_id' => $order['holder_id'] ?? 0,'person_id' => $order['person_id'] ?? 0]), isset($order['wait_id']) ? $order['wait_id'] : 0, isset($order['wait_name']) ? $order['wait_name'] : '');
         }
 
         $insert = $data;

+ 12 - 3
app/admin/model/ProcessWait.php

@@ -35,6 +35,11 @@ class ProcessWait extends Model
 //            "addtime"=>'',
 //        ];
 
+        //修改各个节点的最终节点
+        Db::name('process_wait')
+            ->where(['order_type' => $data['order_type'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id']])
+            ->update(['order_process_finally' => $data['action_process']]);
+
         //把上一个节点改成已完成
         Db::name('process_wait')
             ->where(['order_type' => $data['order_type'], 'order_process' => $data['action_status'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id'], 'status' => self::$status_wait])
@@ -50,9 +55,9 @@ class ProcessWait extends Model
 
         if ($info) {
 
-            //如果下一个节点是中断节点,则将相关记录删除,不再新增
+            //如果下一个节点是中断节点,则将相关记录删除,不再新增(只删除待办数据,221010145800@戴确认)
             if ($info['action_type'] == ActionProcess::$action_type_interrupt) {
-                self::where(['order_type' => $data['order_type'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id']])
+                self::where(['order_type' => $data['order_type'], 'order_code' => $data['order_code'], 'order_id' => $data['order_id'], 'status' => self::$status_wait])
                     ->update(['status' => self::$status_interrupt, 'updatetime' => date('Y-m-d H:i:s')]);
                 return true;
             }
@@ -130,6 +135,7 @@ class ProcessWait extends Model
                 'action_name' => $data['action_name'],
                 'status' => self::$status_wait,
                 'order_process' => $data['action_process'],
+                'order_process_finally' => $data['action_process'],
                 'addtime' => date('Y-m-d H:i:s'),
                 'updatetime' => date('Y-m-d H:i:s'),
             ];
@@ -145,7 +151,10 @@ class ProcessWait extends Model
                     ->where('is_del', 0)
                     ->column('role_id');
                 $insert_data['roleid'] = implode(',', $roleid);
-                $insert_data['handle_user_list'] = get_handle_user_list($info['id'], $data['holder_id'] ?? 0, $info['api_url']);//handle_user_list当前待处理人的uid集合
+
+                //针对议价单流程,待boss审核节点,做特殊处理
+                if ($data['order_type'] == 'YJD' && $data['action_process'] == 7) $insert_data['handle_user_list'] = implode(',', Db::name('user_role')->whereIn('roleid', $roleid)->where(['is_del' => 0, 'status' => 1])->where('roleid','<>',1)->column('uid'));
+                else $insert_data['handle_user_list'] = implode(',', get_handle_user_list($info['id'], $data['holder_id'] ?? 0, $info['api_url'], $data['person_id'] ?? 0));//handle_user_list当前待处理人的uid集合
             }
 
             //增加新的节点

+ 158 - 0
app/command/UpdateProcessWaitFinallyData.php

@@ -0,0 +1,158 @@
+<?php
+declare (strict_types=1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+use think\Exception;
+use think\facade\Db;
+
+class UpdateProcessWaitFinallyData extends Command
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('UpdateProcessWaitFinallyData')
+            ->setDescription('更新待办数据表中的字段:最终状态值');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+        Db::startTrans();
+        try {
+
+            $data = Db::name('process_wait')
+                ->field('order_code,order_type,order_id')
+                ->group('order_code,order_type,order_id')
+                ->whereIn('status', [1, 2])
+                ->cursor();
+
+            foreach ($data as $value) {
+
+                $order_process_finally = 0;
+
+                switch ($value['order_type']) {
+                    //1.采购单流程
+                    case 'CGD':
+                        $order_process_finally = Db::name('purchease_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //2.采购单入库流程
+                    case 'RKD':
+                        $order_process_finally = Db::name('purchease_in')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //3.备货申请单流程
+                    case 'BHD':
+                        $order_process_finally = Db::name('purchease')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //4.销售订单流程
+                    case 'XSQRD':
+                        $order_process_finally = Db::name('sale')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //5.发货申请单流程
+                    case 'CKD':
+                        $order_process_finally = Db::name('order_out')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //6.售后申请单流程
+                    case 'SHD':
+                        $order_process_finally = Db::name('order_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //7.售后退货单流程
+                    case 'CKTHD':
+                        $order_process_finally = Db::name('order_back')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //8.销售退货单流程
+                    case 'XSTHD':
+                        $order_process_finally = Db::name('sale_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //9.采购工差单流程
+                    case 'CGGCD':
+                        $order_process_finally = Db::name('purchease_diff')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //10.销售工差单流程
+                    case 'XSGCD':
+                        $order_process_finally = Db::name('sale_diff')
+                            ->where(['id' => $value['order_id']])
+                            ->value('status', 0);
+                        break;
+                    //11.调拨单流程
+                    case 'DBD':
+                        $order_process_finally = Db::name('allot_stock')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //12.盘点单流程
+                    case 'PDD':
+                        $order_process_finally = Db::name('good_check')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //13.议价单流程
+                    case 'YJD':
+                        $order_process_finally = Db::name('bargain_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //14.项目单流程
+                    case 'PRO':
+                        $order_process_finally = Db::name('project')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //15.商品成本流程
+                    case 'SPCB':
+                        $order_process_finally = Db::name('good_basic')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //16.商品上线流程
+                    case 'SPSX':
+                        $order_process_finally = Db::name('good_platform')
+                            ->where(['id' => $value['order_id']])
+                            ->value('exam_status', 0);
+                        break;
+                    //17.活动流程
+                    case 'HD':
+                        $order_process_finally = Db::name('good_activity')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //19.有赞商品上架流程
+                    case 'YZSX':
+                        $order_process_finally = Db::name('platform_youzan')
+                            ->where(['id' => $value['order_id']])
+                            ->value('exam_status', 0);
+                        break;
+                    //20.有赞订单审核流程
+//                case 'YZQRD':
+//                    $order_process_finally = Db::name('')->where(['id' => $value['order_id'], 'is_del' => 0])->value('', 0);
+//                    break;
+                    //22.离职交接流程
+                    case 'LZJJ':
+                        $order_process_finally = Db::name('resign_info')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //23.采购单退货流程
+                    case 'CGTHD':
+                        $order_process_finally = Db::name('purchease_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //24.竞价单流程
+                    case 'ZXD':
+                        $order_process_finally = Db::name('consult_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+                        break;
+                    //25.商品下线流程
+//                    case 'GOL':
+//                        $order_process_finally = Db::name('good_offline_log')->where(['id' => $value['order_id'], 'is_del' => 0])->value('status', 0);
+//                        break;
+                }
+
+                if ($order_process_finally) Db::name('process_wait')
+                    ->where('order_code', $value['order_code'])
+                    ->where('order_type', $value['order_type'])
+                    ->update(['order_process_finally' => $order_process_finally]);
+            }
+
+            Db::commit();
+
+            $output->writeln('update success');
+
+        } catch (Exception $exception) {
+            Db::rollback();
+            $output->writeln('update fail,' . $exception->getMessage());
+        }
+
+
+    }
+
+
+}

+ 59 - 0
app/command/UpdateYzHistoryData.php

@@ -0,0 +1,59 @@
+<?php
+declare (strict_types=1);
+
+namespace app\command;
+
+use think\console\Command;
+use think\console\Input;
+use think\console\input\Argument;
+use think\console\input\Option;
+use think\console\Output;
+use think\Exception;
+use think\facade\Db;
+
+class UpdateYzHistoryData extends Command
+{
+    protected function configure()
+    {
+        // 指令配置
+        $this->setName('UpdateYzHistoryData')
+            ->setDescription('更新有赞的历史数据');
+    }
+
+    protected function execute(Input $input, Output $output)
+    {
+
+        $data = Db::name('order_out')
+            ->alias('a')
+            ->field('a.orderCode,a.outCode,a.post_name,a.post_code')
+            ->leftJoin('sale b', 'b.orderCode=a.orderCode')
+            ->where('a.addtime', '>=', date('Y-m-d H:i:s', time() - 72 * 3600))
+            ->where([
+                'a.is_del' => 0,
+                'a.status' => 2,
+                'b.order_source' => 5
+            ])
+            ->limit(1)->select()->toArray();
+//            ->cursor();
+
+        $url = config('app.yz_domain') . 'api/yz_out_send';
+
+        foreach ($data as $value) {
+            $res = curl_request($url, [
+                'orderCode' => $value['orderCode'],
+                'out_stype' => $value['post_name'],
+                'post_code' => $value['post_code'],
+                'uid' => 96,
+                'uname' => '武锋(历史数据处理)',
+                'order_out' => $value['outCode'],
+            ]);
+
+            $res = json_decode($res, true);
+            if ($res['code'] != 0) $output->writeln('handle fail,' . json_encode($value, JSON_UNESCAPED_UNICODE) . ':' . $res['message']);
+        }
+
+
+    }
+
+
+}

+ 17 - 6
app/common.php

@@ -1219,7 +1219,11 @@ if (!function_exists('checkHasAccountBySupplierNos')) {
 
 //获取当前操作人(待办列表)
 if (!function_exists('get_handle_user_list')) {
-    function get_handle_user_list(int $action_process_id = 0, int $holder_id = 0, string $api_url = '')
+    //$action_process_id 节点id
+    //$holder_id 所有人uid
+    //$api_url 接口路径,匹配菜单使用
+    //$person_id 供应商负责人(供应商端)
+    function get_handle_user_list(int $action_process_id = 0, int $holder_id = 0, string $api_url = '',int $person_id=0)
     {
 
         //筛选符合流程权限的角色id集合
@@ -1243,6 +1247,7 @@ if (!function_exists('get_handle_user_list')) {
             ->where(['is_del' => 0, 'menu_api' => $api_url])
             ->value('id', 0);
 
+        $tmp = [];
         if ($menu_id) {
             //共享规则
             $share = Db::name('role_share')
@@ -1256,7 +1261,7 @@ if (!function_exists('get_handle_user_list')) {
                 ->cursor();
 
             foreach ($share as $s) {
-                if ($s['to_user']) $data[] = $s['to_user'];
+                if ($s['to_user']) $tmp[] = $s['to_user'];
                 elseif ($s['to_group']) {
                     $group_user = Db::name('role_group')
                         ->where([
@@ -1264,15 +1269,21 @@ if (!function_exists('get_handle_user_list')) {
                             'is_del' => 0,
                             'status' => 1,
                         ])->value('group_user');
-                    $data = array_merge($data, explode(',', $group_user));
+                    $tmp = array_merge($tmp, explode(',', $group_user));
                 }
             }
         }
 
-        sort($data);
-        $data = array_unique($data);
+        $res = array_intersect($tmp, $data);//流程权限和数据权限取交集
 
-        return $data;
+        //如果本人有流程权限的话,加入到数组中
+        if (in_array($holder_id, $data)) $res[] = $holder_id;
+        if ($person_id) $res[] = $person_id;
+
+        sort($res);
+        $res = array_unique($res);
+
+        return $res;
 
     }
 }

+ 1 - 1
app/youzan/logic/Goodup.php

@@ -170,7 +170,7 @@ class Goodup
                         "order_id" => $create,
                         "order_status" => $tmp['exam_status'],
                         "before_status" => $tmp['exam_status'],
-                        'holder_id'=>$god['chargerid'],
+                        'holder_id' => Db::name('good_basic')->where(["spuCode" => $value['spuCode'], "is_del" => 0])->value('chargerid', 0),
                     ]);
                     $iso = Db::name("good")->where(["spuCode" => $value['spuCode'], "is_del" => 0])->find();
                     if ($iso == false) {

+ 2 - 2
public/index.php

@@ -15,9 +15,9 @@ namespace think;
 require __DIR__ . '/../vendor/autoload.php';
 header('Access-Control-Allow-Origin:*');
 header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE');
-header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
+header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization,sign,appid,noce,timestamp");
 // 执行HTTP应用并响应
-if($_SERVER['REQUEST_METHOD']=="OPTIONS"){
+if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
     echo '';
     exit();
 }