shish 2 年之前
父節點
當前提交
b7f35192a0

+ 10 - 2
app-ghs/controllers/PurchaseOrderController.php

@@ -501,7 +501,8 @@ class PurchaseOrderController extends BaseController
                 $noLock = util::lock($key);
                 if ($noLock) {
                     //没有锁定,即没有在分配货位,可以进行货位分配
-                    PurchaseOrderClass::assign($order);
+                    $params = ['staffId'=>$shopAdmin->id,'staffName'=>$shopAdmin->name];
+                    PurchaseOrderClass::assign($order,$shop,$params);
                     util::unlock($key);
                 }
             }
@@ -542,6 +543,10 @@ class PurchaseOrderController extends BaseController
             if ($bookSn != $cgBookSn) {
                 util::success(['assign' => 0, 'hint' => 'shop bookSn != cg bookSn']);
             }
+            $staff = $this->shopAdmin;
+            $staffId = $staff->id??0;
+            $staffName = $staff->name??'';
+            $params = ['staffId'=>$staffId,'staffName'=>$staffName];
         } else {
             if ($cg->salt != $salt) {
                 util::success(['assign' => 0, 'hint' => 'cg salt != post salt']);
@@ -554,11 +559,14 @@ class PurchaseOrderController extends BaseController
             if ($shop->bookSn != $cgBookSn) {
                 util::success(['assign' => 0, 'hint' => 'shop bookSn != cg bookSn o']);
             }
+            $staffId = $cg->shopAdminId??0;
+            $staffName = $cg->shopAdminName??'';
+            $params = ['staffId'=>$staffId,'staffName'=>$staffName];
         }
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            PurchaseOrderClass::assign($cg);
+            PurchaseOrderClass::assign($cg,$shop,$params);
             $transaction->commit();
             util::success(['assign' => 1]);
         } catch (\Exception $e) {

+ 75 - 7
biz-ghs/book/classes/BookCustomClass.php

@@ -113,6 +113,57 @@ class BookCustomClass extends BaseClass
         return $bookCustomRes;
     }
 
+    public static function addRoadNum($bookCustomRes,$addRoadNum,$bill,$shop,$product,$params)
+    {
+        $bookCustomRes->roadNum = bcadd($bookCustomRes->roadNum, $addRoadNum);
+        $bookCustomRes->save();
+        $bookItemCustomResId = $bookCustomRes->id ?? 0;
+
+        $ioRes = $params['ioRes'] ?? null;
+        $relatedId = $ioRes->id ?? 0;
+
+        $itemId = $product->id ?? 0;
+        $ptItemId = $product->itemId ?? 0;
+        $name = $product->name ?? '';
+        $py = $product->py ?? '';
+        $bigUnit = $product->bigUnit ?? '扎';
+        $bookSn = $shop->bookSn ?? '';
+        $mainId = $shop->mainId ?? 0;
+        $staffName = $params['staffName'] ?? '';
+        $staffId = $params['staffId'] ?? 0;
+        $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+        $customId = $bookCustomRes->customId ?? 0;
+        $customName = $bookCustomRes->name ?? '';
+        $customNamePy = $bookCustomRes->py ?? '';
+        $orderSn = $bill->orderSn ?? '';
+        $event = "{$staffName} 新增待入库采购单 {$orderSn},路上增加 {$name}" . $addRoadNum . $bigUnit;
+
+        $changeData = [
+            'mainId' => $mainId,
+            'bookSn' => $bookSn,
+            'name' => $name,
+            'py' => $py,
+            'itemId' => $itemId,
+            'ptItemId' => $ptItemId,
+            'customId' => $customId,
+            'customName' => $customName,
+            'customNamePy' => $customNamePy,
+            'relateId' => $relatedId,
+            'relateSecondId' => $bookItemCustomResId,
+            'ptStyle' => 2,
+            'capitalType' => $currentCapitalType,
+            'io' => 1,
+            'changeNum' => $addRoadNum,
+            'num' => $bookCustomRes->roadNum,
+            'event' => $event,
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'remark' => '',
+        ];
+        BookCustomRoadChangeClass::add($changeData, true);
+        return $bookCustomRes;
+    }
+
     public static function delRoadNum($bookCustomRes, $delRoadNum, $num, $bill, $shop, $product, $params)
     {
         $bookCustomRes->roadNum = bcsub($bookCustomRes->roadNum, $delRoadNum);
@@ -184,7 +235,7 @@ class BookCustomClass extends BaseClass
         return $bookCustomRes;
     }
 
-    public static function delNeedCgNum($bookCustomRes, $delNeedCgNum, $totalBookNum, $order, $shop, $product, $params)
+    public static function delNeedCgNum($bookCustomRes, $delNeedCgNum, $totalBookNum, $bill, $shop, $product, $params)
     {
         $bookCustomRes->needCgNum = bcsub($bookCustomRes->needCgNum, $delNeedCgNum);
         $bookCustomRes->save();
@@ -193,21 +244,38 @@ class BookCustomClass extends BaseClass
         $ioRes = $params['ioRes'] ?? null;
         $relatedId = $ioRes->id ?? 0;
 
-        //待采减少变动记录
         $itemId = $product->id ?? 0;
         $ptItemId = $product->itemId ?? 0;
         $name = $product->name ?? '';
         $py = $product->py ?? '';
         $bigUnit = $product->bigUnit ?? '扎';
         $bookSn = $shop->bookSn ?? '';
-        $mainId = $order->mainId ?? 0;
-        $customId = $order->customId ?? 0;
-        $customName = $order->customName ?? '';
-        $customNamePy = $order->customNamePy ?? '';
+        $mainId = $shop->mainId ?? 0;
         $currentCapitalType = dict::getDict('capitalType', 'delBook');
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        $currentChangeType = $params['currentChangeType']??'delBook';
+        if($currentChangeType == 'addCg'){
+            $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName."增加待入库单 {$orderSn} 减少待采 {$name} ". $delNeedCgNum . $bigUnit;
+        }elseif($currentChangeType == 'delBook'){
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $customId = $bill->customId ?? 0;
+            $customName = $bill->customName ?? '';
+            $customNamePy = $bill->customNamePy ?? '';
+            $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        }else{
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $event = '';
+            util::fail('没有找到的操作');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

+ 76 - 7
biz-ghs/book/classes/BookItemClass.php

@@ -495,6 +495,59 @@ class BookItemClass extends BaseClass
         return $bookItemRes;
     }
 
+
+    public static function addRoadNum($bookItemRes, $addRoadNum, $num, $bill, $shop, $product, $params)
+    {
+        $bookItemRes->roadNum = bcadd($bookItemRes->roadNum, $addRoadNum);
+        $bookItemRes->save();
+        $bookItemResId = $bookItemRes->id ?? 0;
+
+        $ioRes = $params['ioRes'] ?? null;
+        $relatedId = $ioRes->id ?? 0;
+
+        $itemId = $product->id ?? 0;
+        $ptItemId = $product->itemId ?? 0;
+        $name = $product->name ?? '';
+        $py = $product->py ?? '';
+        $bigUnit = $product->bigUnit ?? '扎';
+        $bookSn = $shop->bookSn ?? '';
+        $mainId = $shop->mainId ?? 0;
+        $staffName = $params['staffName'] ?? '';
+        $staffId = $params['staffId'] ?? 0;
+
+        $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+        $customId = 0;
+        $customName = '';
+        $customNamePy = '';
+        $orderSn = $bill->orderSn ?? '';
+        $event = "{$staffName} 新增待入库采购单 {$orderSn},路上增加 {$name}" . $addRoadNum . $bigUnit;
+
+        $changeData = [
+            'mainId' => $mainId,
+            'bookSn' => $bookSn,
+            'name' => $name,
+            'py' => $py,
+            'itemId' => $itemId,
+            'ptItemId' => $ptItemId,
+            'customId' => $customId,
+            'customName' => $customName,
+            'customNamePy' => $customNamePy,
+            'relateId' => $relatedId,
+            'relateSecondId' => $bookItemResId,
+            'ptStyle' => 2,
+            'capitalType' => $currentCapitalType,
+            'io' => 1,
+            'changeNum' => $addRoadNum,
+            'num' => $bookItemRes->roadNum,
+            'event' => $event,
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'remark' => '',
+        ];
+        BookRoadChangeGlobalClass::add($changeData, true);
+        return $bookItemRes;
+    }
+
     public static function delRoadNum($bookItemRes, $delRoadNum, $num, $bill, $shop, $product, $params)
     {
         $bookItemRes->roadNum = bcsub($bookItemRes->roadNum, $delRoadNum);
@@ -567,7 +620,7 @@ class BookItemClass extends BaseClass
         return $bookItemRes;
     }
 
-    public static function delNeedCgNum($bookItemRes, $delNeedCgNum, $totalBookNum, $order, $shop, $product, $params)
+    public static function delNeedCgNum($bookItemRes, $delNeedCgNum, $totalBookNum, $bill, $shop, $product, $params)
     {
         $bookItemRes->needCgNum = bcsub($bookItemRes->needCgNum, $delNeedCgNum);
         $bookItemRes->save();
@@ -576,21 +629,37 @@ class BookItemClass extends BaseClass
         $ioRes = $params['ioRes'] ?? null;
         $relatedId = $ioRes->id ?? 0;
 
-        //预订减少变动记录
         $itemId = $product->id ?? 0;
         $ptItemId = $product->itemId ?? 0;
         $name = $product->name ?? '';
         $py = $product->py ?? '';
         $bigUnit = $product->bigUnit ?? '扎';
         $bookSn = $shop->bookSn ?? '';
-        $mainId = $order->mainId ?? 0;
-        $customId = $order->customId ?? 0;
-        $customName = $order->customName ?? '';
-        $customNamePy = $order->customNamePy ?? '';
+        $mainId = $shop->mainId ?? 0;
         $currentCapitalType = dict::getDict('capitalType', 'addBook');
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        $currentChangeType = $params['currentChangeType']??'delBook';
+        if($currentChangeType == 'addCg'){
+            $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName."增加待入库单 {$orderSn} 减少待采 {$name} ". $delNeedCgNum . $bigUnit;
+        }elseif($currentChangeType == 'delBook'){
+            $customId = $bill->customId ?? 0;
+            $customName = $bill->customName ?? '';
+            $customNamePy = $bill->customNamePy ?? '';
+            $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        }else{
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $event = '';
+            util::fail('没有找到的操作');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

+ 69 - 8
biz-ghs/book/classes/BookItemCustomClass.php

@@ -113,6 +113,56 @@ class BookItemCustomClass extends BaseClass
         return $bookItemCustomRes;
     }
 
+    public static function addRoadNum($bookItemCustomRes, $addRoadNum, $num, $bill, $shop, $product, $params)
+    {
+        $bookItemCustomRes->roadNum = bcadd($bookItemCustomRes->roadNum, $addRoadNum);
+        $bookItemCustomRes->save();
+        $bookItemResId = $bookItemCustomRes->id ?? 0;
+
+        $ioRes = $params['ioRes'] ?? null;
+        $relatedId = $ioRes->id ?? 0;
+        $bigUnit = $product->bigUnit ?? '扎';
+        $itemId = $product->id ?? 0;
+        $ptItemId = $product->itemId ?? 0;
+        $name = $product->name ?? '';
+        $py = $product->py ?? '';
+        $bookSn = $shop->bookSn ?? '';
+        $mainId = $shop->mainId ?? 0;
+        $staffName = $params['staffName'] ?? '';
+        $staffId = $params['staffId'] ?? 0;
+        $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+        $customId = $bookItemCustomRes->customId ?? 0;
+        $customName = $bookItemCustomRes->customName ?? '';
+        $customNamePy = $bookItemCustomRes->customNamePy ?? '';
+        $orderSn = $bill->orderSn ?? '';
+        $event = "{$staffName} 新增待入库采购单 {$orderSn},路上增加 {$name}" . $addRoadNum . $bigUnit;
+
+        $changeData = [
+            'mainId' => $mainId,
+            'bookSn' => $bookSn,
+            'name' => $name,
+            'py' => $py,
+            'itemId' => $itemId,
+            'ptItemId' => $ptItemId,
+            'customId' => $customId,
+            'customName' => $customName,
+            'customNamePy' => $customNamePy,
+            'relateId' => $relatedId,
+            'relateSecondId' => $bookItemResId,
+            'ptStyle' => 2,
+            'capitalType' => $currentCapitalType,
+            'io' => 1,
+            'changeNum' => $addRoadNum,
+            'num' => $bookItemCustomRes->roadNum,
+            'event' => $event,
+            'staffId' => $staffId,
+            'staffName' => $staffName,
+            'remark' => '',
+        ];
+        BookRoadChangeClass::add($changeData, true);
+        return $bookItemCustomRes;
+    }
+
     public static function delRoadNum($bookItemCustomRes, $delRoadNum, $num, $bill, $shop, $product, $params)
     {
         $bookItemCustomRes->roadNum = bcsub($bookItemCustomRes->roadNum, $delRoadNum);
@@ -129,7 +179,7 @@ class BookItemCustomClass extends BaseClass
         $py = $product->py ?? '';
         $bookSn = $shop->bookSn ?? '';
         $mainId = $shop->mainId ?? 0;
-
+        $currentCapitalType = dict::getDict('capitalType', 'delBook');
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
 
@@ -182,7 +232,7 @@ class BookItemCustomClass extends BaseClass
         return $bookItemCustomRes;
     }
 
-    public static function delNeedCgNum($bookItemCustomRes, $delNeedCgNum, $totalBookNum, $order, $shop, $product, $params)
+    public static function delNeedCgNum($bookItemCustomRes, $delNeedCgNum, $totalBookNum, $bill, $shop, $product, $params)
     {
         $bookItemCustomRes->needCgNum = bcsub($bookItemCustomRes->needCgNum, $delNeedCgNum);
         $bookItemCustomRes->save();
@@ -191,21 +241,32 @@ class BookItemCustomClass extends BaseClass
         $ioRes = $params['ioRes'] ?? null;
         $relatedId = $ioRes->id ?? 0;
 
-        //待采减少变动记录
         $itemId = $product->id ?? 0;
         $ptItemId = $product->itemId ?? 0;
         $name = $product->name ?? '';
         $py = $product->py ?? '';
         $bigUnit = $product->bigUnit ?? '扎';
         $bookSn = $shop->bookSn ?? '';
-        $mainId = $order->mainId ?? 0;
-        $customId = $order->customId ?? 0;
-        $customName = $order->customName ?? '';
-        $customNamePy = $order->customNamePy ?? '';
+        $mainId = $shop->mainId ?? 0;
         $currentCapitalType = dict::getDict('capitalType', 'delBook');
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        $customId = $bookItemCustomRes->customId ?? 0;
+        $customName = $bookItemCustomRes->customName ?? '';
+        $customNamePy = $bookItemCustomRes->customNamePy ?? '';
+        $currentChangeType = $params['currentChangeType']??'delBook';
+        $event = '';
+        if($currentChangeType == 'addCg'){
+            $currentCapitalType = dict::getDict('capitalType', 'ghsPurchase');
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName."增加待入库单 {$orderSn} 减少待采 {$name} ". $delNeedCgNum . $bigUnit;
+        }elseif($currentChangeType == 'delBook'){
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $event = $customName . '减少预订' . $name . $totalBookNum . $bigUnit . ',其中减少待采' . $delNeedCgNum . $bigUnit;
+        }else{
+            util::fail('没有找到的操作');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

+ 12 - 12
biz-ghs/order/classes/PurchaseOrderClass.php

@@ -69,7 +69,7 @@ class PurchaseOrderClass extends BaseClass
     const IN_TYPE_LATER = 0;
     const IN_TYPE_NOW = 1;
 
-    public static function assign($cg)
+    public static function assign($cg,$shop,$params)
     {
         $bookSn = $cg->bookSn ?? 0;
         $orderSn = $cg->orderSn ?? '';
@@ -146,17 +146,17 @@ class PurchaseOrderClass extends BaseClass
                     //剩余要分配数量不足则退出本循环
                     break;
                 }
+
                 //待采数量减少
-                $bookItemCustomRes->needCgNum = bcsub($needCgNum, $remainNeedSendNum);
-                $bookCustomRes->needCgNum = bcsub($bookCustomRes->needCgNum, $remainNeedSendNum);
-                $bookItemRes->needCgNum = bcsub($bookItemRes->needCgNum, $remainNeedSendNum);
+                $params['currentChangeType'] = 'addCg';
+                $bookItemCustomRes = BookItemCustomClass::delNeedCgNum($bookItemCustomRes, $remainNeedSendNum, 0, $cg, $shop, $currentItemInfo, $params);
+                $bookCustomRes = BookCustomClass::delNeedCgNum($bookCustomRes, $remainNeedSendNum, 0, $cg, $shop, $currentItemInfo, $params);
+                $bookItemRes = BookItemClass::delNeedCgNum($bookItemRes, $remainNeedSendNum, 0, $cg, $shop, $currentItemInfo, $params);
+
                 //路上数量增加
-                $bookItemCustomRes->roadNum = bcadd($bookItemCustomRes->roadNum, $remainNeedSendNum);
-                $bookCustomRes->roadNum = bcadd($bookCustomRes->roadNum, $remainNeedSendNum);
-                $bookItemRes->roadNum = bcadd($bookItemRes->roadNum, $remainNeedSendNum);
-                $bookItemCustomRes->save();
-                $bookCustomRes->save();
-                $bookItemRes->save();
+                $bookItemCustomRes = BookItemCustomClass::addRoadNum($bookItemCustomRes, $remainNeedSendNum, $cg, $shop, $currentItemInfo, $params);
+                $bookCustomRes = BookCustomClass::addRoadNum($bookCustomRes,$remainNeedSendNum,$cg,$shop,$currentItemInfo,$params);
+                $bookItemRes = BookItemClass::addRoadNum($bookItemRes,$remainNeedSendNum,$cg,$shop,$currentItemInfo,$params);
 
                 //确认已分配数量增加
                 $cgItem->confirmSendNum = bcadd($cgItem->confirmSendNum, $remainNeedSendNum);
@@ -510,10 +510,10 @@ class PurchaseOrderClass extends BaseClass
             $noLock = util::lock($key);
             if ($noLock) {
                 //可以获得锁,没有在分配货位,可以进行货位分配
-                self::assign($cg);
+                $params = ['staffId'=>$staffId,'staffName'=>$staffName];
+                self::assign($cg,$shop,$params);
                 util::unlock($key);
                 //分配货位后上架和入库
-                $params = ['staffId'=>$staffId,'staffName'=>$staffName];
                 $shop = $data['shop']??null;
                 CgOrderItemClass::assignToPutOn($cg,$shop,$params);
             } else {

+ 10 - 1
console/controllers/BookController.php

@@ -2,6 +2,7 @@
 
 namespace console\controllers;
 
+use biz\shop\classes\ShopClass;
 use bizGhs\cg\classes\CgOrderClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\shop\classes\ShopAdminClass;
@@ -43,7 +44,15 @@ class BookController extends Controller
                 $connection = Yii::$app->db;
                 $transaction = $connection->beginTransaction();
                 try {
-                    $respond = PurchaseOrderClass::assign($cg);
+                    $shopId = $cg->shopId??0;
+                    $shop = ShopClass::getById($shopId,true);
+                    if(empty($shop)){
+                        continue;
+                    }
+                    $staffId = $cg->shopAdminId??0;
+                    $staffName = $cg->shopAdminName??'';
+                    $params = ['staffId'=>$staffId,'staffName'=>$staffName];
+                    $respond = PurchaseOrderClass::assign($cg,$shop,$params);
                     $transaction->commit();
                     $hasChange = $respond['hasChange'] ?? 0;
                     if ($hasChange == 1) {