wugg пре 2 година
родитељ
комит
bdd4e1ee2e
2 измењених фајлова са 34 додато и 14 уклоњено
  1. 2 1
      app/admin/controller/Purch.php
  2. 32 13
      app/admin/controller/Sale.php

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

@@ -476,6 +476,7 @@ class Purch extends Base
                         $data=[
                             "orderCode"=>$value['orderCode'],
                             "good_code"=>$value['spuCode'],
+                            "cgd_diffid"=>$item,
                             "good_name"=>$value['good_name'],
                             "diff_weight"=>$diff_weight,
                             "diff_price"=>$diff_weight*$value['good_price'],
@@ -609,7 +610,7 @@ class Purch extends Base
         $temp = $dio['status'];
             $dio['status']=$status;
             $dio['updatetime']=date("Y-m-d H:i:s");
-            $item = Db::name("purchease_diff")->update($dio);
+            $item = Db::name("purchease_diff")->save($dio);
          if ($item){
 //             $sto = ["order_code"=>$dio['cgdNo'],"status"=>$temp,"action_remark"=>'',"action_type"=>"status"];
 //             ActionLog::logAdd($this->post['token'],$sto,"CGGCD",$dio['status'],$sto);

+ 32 - 13
app/admin/controller/Sale.php

@@ -2410,25 +2410,44 @@ class Sale extends Base
             return error_show(1004, "参数id不能为空");
         }
         $info = Db::name("sale_diff")->where(["id" => $id])->find();
-        if (empty($info)) {
+        if ($info==false) {
             return error_show(1004, "订单数据未找到");
         }
+        $cgd = Db::name("purchease_diff")->where(['id'=>$info['cgd_diffid']])->find();
+        if($cgd==false){
+            return error_show(1004, "采购工差单数据未找到");
+        }
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "3";
         $remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
         $ite=$info['status'];
-        $info['status'] = $status;
-        $info['remark'] = $remark;
-        $info['updatetime'] = date("Y-m-d H:i:s");
-        $up = Db::name("sale_diff")->save($info);
-        if ($up) {
-            $stx = ["order_code"=>$info["orderCode"],"status"=>$ite,"action_remark"=>'',"action_type"=>"status"];
-            ActionLog::logAdd($this->post['token'],$stx,"QRGCD",$info['status'],$info);
-            $order=["order_type"=>"QRGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],"order_status"=>$info['status']];
-            ProcessOrder::AddProcess($this->post['token'],$order);
-            return app_show(0, "更新成功");
-        } else {
-            return error_show(1003, "更新失败");
+        Db::startTrans();
+        try{
+            $upda=[
+                "status"=>$status,
+                "remark"=>$remark,
+                "updatetime"=> date("Y-m-d H:i:s"),
+            ];
+            $up = Db::name("sale_diff")->where($info)->save($upda);
+            if ($up) {
+                $stx = ["order_code"=>$info["orderCode"],"status"=>$ite,"action_remark"=>'',"action_type"=>"status"];
+                ActionLog::logAdd($this->post['token'],$stx,"QRGCD",$info['status'],$info);
+                $order=["order_type"=>"QRGCD","order_code"=>$info["orderCode"],"order_id"=>$info['id'],"order_status"=>$status];
+                ProcessOrder::AddProcess($this->post['token'],$order);
+                $cgdup =Db::name("purchease_diff")->where(["id"=>$info['cgd_diffid']])->save($upda);
+                if($cgdup){
+                    Db::commit();
+                    return app_show(0, "更新成功");
+                }
+
+            }
+                Db::rollback();
+                return error_show(1003, "更新失败");
+
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1003,$e->getMessage());
         }
+
     }
 
     /**