wugg 3 years ago
parent
commit
cd16267834
2 changed files with 19 additions and 7 deletions
  1. 18 6
      app/admin/controller/Resign.php
  2. 1 1
      app/common.php

+ 18 - 6
app/admin/controller/Resign.php

@@ -768,14 +768,26 @@ class Resign extends BaseController
         try{
             $up =Db::name("purchease_order")->insert($cg);
             if($up){
-
-                return app_show(0,"采购单新建成功");
-            }else{
-                return error_show(1004,"采购单新建失败");
+                $data=[
+                    "cgdNo"=>$cgdCode,
+                    "spuCode"=>$info['spuCode'],
+                    "total_num"=>$info['good_num'],
+                    "merge_num"=>0,
+                    "balance_num"=>$info['good_num'],
+                    "addtime"=>date("Y-m-d H:i:s"),
+                    "updatetime"=>date("Y-m-d H:i:s")
+                ];
+                $in =Db::name("order_bk")->insert($data);
+                if($in){
+                    Db::commit();
+                    return app_show(0,"采购单新建成功");
+                }
             }
+                Db::rollback();
+                return error_show(1004,"采购单新建失败");
         }catch (\Exception $e){
-
+            Db::rollback();
+            return error_show(1004,$e->getMessage());
         }
-
     }
 }

+ 1 - 1
app/common.php

@@ -168,7 +168,7 @@ function makeNo($str){
 
     $date=date("mdHis");
     $year = date("Y")-2000;
-    $msec=randomkeys(4);
+    $msec=rand(1000,9999);
     return $str.$year.$date.$msec;
 }
 function randomkeys($length) {