Browse Source

商品下线流程优化

wufeng 2 years ago
parent
commit
61ae74b82a
1 changed files with 44 additions and 31 deletions
  1. 44 31
      app/admin/controller/Goodup.php

+ 44 - 31
app/admin/controller/Goodup.php

@@ -1458,24 +1458,9 @@ class Goodup extends Base
                 $inr=Db::name("good_exam")->insert($data);
                 if($inr){
 
-                    ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
-                        "order_code" => $skuCode,//编号
-                        "status" => $bifore,
-                        "action_remark" => '',//备注
-                        "action_type" => "status"//新建create,编辑edit,更改状态status
-                    ], "SPSX", $exam_status, $platform);
-
-                    ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
-                        "order_type" => 'SPSX',
-                        "order_code" => $skuCode,//咨询单详情编号
-                        "order_id" => $platform['id'],
-                        "order_status" => $exam_status,"before_status"=>$bifore
-                    ]);
-
-
                     //如果是商品下线的话,记入商品下线记录表
                     if ($exam_status == 8) {
-                        Db::name("good_offline_log")->insert([
+                        $offline_id = Db::name("good_offline_log")->insertGetId([
                             'spuCode' => $platform['spuCode'],
                             'skuCodes' => $skuCode,
                             'good_name' => Db::name("good_basic")->where('spuCode', $platform['spuCode'])->value('good_name', ''),
@@ -1485,6 +1470,34 @@ class Goodup extends Base
                             'creater' => $creater,
                             'addtime' => date('Y-m-d H:i:s'),
                         ]);
+
+                        ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
+                            "order_code" => $skuCode,//编号
+                            "status" => $bifore,
+                            "action_remark" => '',//备注
+                            "action_type" => "status"//新建create,编辑edit,更改状态status
+                        ], "GOL", $exam_status, $platform);
+
+                        ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
+                            "order_type" => 'GOL',
+                            "order_code" => $skuCode,//咨询单详情编号
+                            "order_id" => $offline_id,//商品下线记录的ID
+                            "order_status" => $exam_status, "before_status" => $bifore
+                        ]);
+                    } else {
+                        ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
+                            "order_code" => $skuCode,//编号
+                            "status" => $bifore,
+                            "action_remark" => '',//备注
+                            "action_type" => "status"//新建create,编辑edit,更改状态status
+                        ], "SPSX", $exam_status, $platform);
+
+                        ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
+                            "order_type" => 'SPSX',
+                            "order_code" => $skuCode,//咨询单详情编号
+                            "order_id" => $platform['id'],
+                            "order_status" => $exam_status, "before_status" => $bifore
+                        ]);
                     }
 
                     Db::commit();
@@ -2644,7 +2657,7 @@ class Goodup extends Base
     public function offlineGoodBySpuCode()
     {
 
-        $param = $this->request->only(['token', 'spuCode','offline_reason','offline_remark'=>''], 'post', 'trim');
+        $param = $this->request->only(['token', 'spuCode', 'offline_reason', 'offline_remark' => ''], 'post', 'trim');
 
         $val = Validate::rule(['token' => 'require', 'spuCode' => 'require', 'offline_reason|下线原因' => 'require']);
 
@@ -2670,6 +2683,17 @@ class Goodup extends Base
                     'updatetime' => date('Y-m-d H:i:s'),
                 ]);
 
+            $good_offline_log_id = Db::name("good_offline_log")->insertGetId([
+                'spuCode' => $param['spuCode'],
+                'skuCodes' => implode(',', $skuCodeS),
+                'good_name' => Db::name("good_basic")->where('spuCode', $param['spuCode'])->value('good_name', ''),
+                'offline_reason' => $param['offline_reason'],
+                'offline_remark' => $param['offline_remark'],
+                'createrid' => $createrid,
+                'creater' => $creater,
+                'addtime' => date('Y-m-d H:i:s'),
+            ]);
+
             $insert_good_exam_data = [];
             foreach ($skuCodeS as $skuCode) {
                 $insert_good_exam_data[] = [
@@ -2687,29 +2711,18 @@ class Goodup extends Base
                     "status" => 6,
                     "action_remark" => '',//备注
                     "action_type" => "status"//新建create,编辑edit,更改状态status
-                ], "SPSX", 8, $param);
+                ], "GOL", 8, $param);
 
                 ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
-                    "order_type" => 'SPSX',
+                    "order_type" => 'GOL',
                     "order_code" => $skuCode,
-                    "order_id" => 0,
+                    "order_id" => $good_offline_log_id,
                     "order_status" => 8, "before_status" => 6
                 ]);
             }
 
             Db::name("good_exam")->insertAll($insert_good_exam_data);
 
-            Db::name("good_offline_log")->insert([
-                'spuCode'=>$param['spuCode'],
-                'skuCodes'=>implode(',',$skuCodeS),
-                'good_name'=>Db::name("good_basic")->where('spuCode',$param['spuCode'])->value('good_name',''),
-                'offline_reason'=>$param['offline_reason'],
-                'offline_remark'=>$param['offline_remark'],
-                'createrid'=>$createrid,
-                'creater'=>$creater,
-                'addtime'=>date('Y-m-d H:i:s'),
-            ]);
-
             Db::commit();
             return app_show(0, "同一个成本商品编号下的商品下线成功");