wugg 3 년 전
부모
커밋
a3a5fd41a4
1개의 변경된 파일52개의 추가작업 그리고 40개의 파일을 삭제
  1. 52 40
      app/admin/controller/Reorder.php

+ 52 - 40
app/admin/controller/Reorder.php

@@ -348,53 +348,65 @@ class Reorder extends \app\BaseController
         }
         $rid= isset($apply_id["data"]['id']) ?  $apply_id["data"]['id'] : "";
         $rname= isset($apply_id["data"]['nickname']) ?  $apply_id["data"]['nickname'] : "";
-        $info['status'] =$status;
-        $info['remark'] =$remark;
-        $info["updatetime"]=date("Y-m-d H:i:s");
-        $up = Db::name("sale_return")->save($info);
-        if($up){
-            if($info['order_type']==2&&$status==4){
-                $returnCode=makeNo("TH");
-                $data = [
-                    "returnCode"=>$returnCode,
-                    "cgdNo"=>$cgd['cgdNo'],
-                    "good_code"=>$cgd['good_type_code'],
-                    "return_num"=>$cgd['wsend_num'],
-                    "good_name"=>$cgd['good_name'],
-                    "good_price"=>$cgd['good_price'],
-                    "good_catid"=>$gd['cat_id'],
-                    "apply_name"=>$rname,
-                    "apply_id"=>$rid,
-                    "good_total"=>$cgd['good_num'],
-                    "post_company"=>"",
-                    "post_code"=>"",
-                    "post_fee"=>"",
-                    "status"=>1,
-                    "remark"=>'',
-                    "is_del"=>0,
-                    "addtime"=>date("Y-m-d H:i:s"),
-                    "updatetime"=>date("Y-m-d H:i:s")
-                ];
-                $pd = Db::name('purchease_back')->insert($data);
-                if($pd){
-                    $cgd['wsend_num']=0;
-                    $cgd['status']=3;
-                    $cgd['send_status']=3;
-                    $cgd['updatetime']=date("Y-m-d H:i:s");
-                    $up=Db::name('purchease_order')->save($cgd);
-                    if($up){
-                        return app_show(0,"更新成功");
+        Db::startTrans();
+        try{
+            $info['status'] =$status;
+            $info['remark'] =$remark;
+            $info["updatetime"]=date("Y-m-d H:i:s");
+            $up = Db::name("sale_return")->save($info);
+            if($up){
+                if($info['order_type']==2&&$status==4){
+                    $returnCode=makeNo("TH");
+                    $data = [
+                        "returnCode"=>$returnCode,
+                        "cgdNo"=>$cgd['cgdNo'],
+                        "good_code"=>$cgd['good_type_code'],
+                        "return_num"=>$cgd['wsend_num'],
+                        "good_name"=>$cgd['good_name'],
+                        "good_price"=>$cgd['good_price'],
+                        "good_catid"=>$gd['cat_id'],
+                        "apply_name"=>$rname,
+                        "apply_id"=>$rid,
+                        "good_total"=>$cgd['good_num'],
+                        "post_company"=>"",
+                        "post_code"=>"",
+                        "post_fee"=>"",
+                        "status"=>1,
+                        "remark"=>'',
+                        "is_del"=>0,
+                        "addtime"=>date("Y-m-d H:i:s"),
+                        "updatetime"=>date("Y-m-d H:i:s")
+                    ];
+                    $pd = Db::name('purchease_back')->insert($data);
+                    if($pd){
+                        $cgd['wsend_num']=0;
+                        $cgd['status']=3;
+                        $cgd['send_status']=3;
+                        $cgd['updatetime']=date("Y-m-d H:i:s");
+                        $up=Db::name('purchease_order')->save($cgd);
+                        if($up){
+                            Db::commit();
+                            return app_show(0,"更新成功");
+                        }else{
+                            Db::rollback();
+                            return error_show(1004,"更新失败");
+                        }
                     }else{
+                        Db::rollback();
                         return error_show(1004,"更新失败");
                     }
-                }else{
-                    return error_show(1004,"更新失败");
                 }
+                Db::commit();
+                return app_show(0,"更新成功");
+            }else{
+                Db::rollback();
+                return error_show(1004,"更新失败");
             }
-            return app_show(0,"更新成功");
-        }else{
+        }catch (\Exception $e){
+            Db::rollback();
             return error_show(1004,"更新失败");
         }
+
     }
 
     public function zxcreate(){