wuggemail@foxmail.com před 3 měsíci
rodič
revize
172a58dc47
2 změnil soubory, kde provedl 19 přidání a 15 odebrání
  1. 1 1
      app/cxinv/model/ProductCheck.php
  2. 18 14
      app/cxinv/model/TzProduct.php

+ 1 - 1
app/cxinv/model/ProductCheck.php

@@ -66,7 +66,7 @@ class ProductCheck extends Base
                     'checkCode'=>makeNo('CWTZ'),
                     'code'=>$model->checkCode,
                     'itemid'=>$id,
-                    "type"=>1,
+                    "type"=>2,
                     'goodNo'=>$product->skuCode,
                     'goodType'=>$product->good_type,
                     'goodName'=>$product->goodName,

+ 18 - 14
app/cxinv/model/TzProduct.php

@@ -29,20 +29,24 @@ class TzProduct extends Base
     public static function onAfterInsert(Model $model): void
     {
         if($model['type']==2){
-            $adjust=$model->Adjust;
-            ProductStock::OutStock($model['product_id'],$model['num']);
-            $log = [
-                "type" => 1,
-                'order_item_id' => $adjust->manager_id,
-                'product_id' => $model['product_id'],
-                'num' => $model['num'],
-                "fz_date" => $adjust->Manager->fz_date,
-                'unit_price' =>$model['unit_price'],
-                'rate' => $model->Product->cat_tax,
-                'apply_id' => $model->checkUid,
-                'apply_name' => $model->checkUname,
-            ];
-            (new ProductOnlog)->save($log);
+            try{
+                $adjust=$model->Adjust;
+                ProductStock::OutStock($model['product_id'],$model['num']);
+                $log = [
+                    "type" => 1,
+                    'order_item_id' => $adjust->manager_id,
+                    'product_id' => $model['product_id'],
+                    'num' => $model['num'],
+                    "fz_date" => $adjust->Manager->fz_date,
+                    'unit_price' =>$model['unit_price'],
+                    'rate' => $model->Product->cat_tax,
+                    'apply_id' => $model->checkUid,
+                    'apply_name' => $model->checkUname,
+                ];
+                (new ProductOnlog)->save($log);
+            }catch (\Exception $e){
+                throw new \Exception($e->getMessage());
+            }
         }
     }
 }