shish 2 лет назад
Родитель
Сommit
545ce92b2d

+ 27 - 8
biz-ghs/book/classes/BookCustomClass.php

@@ -63,7 +63,7 @@ class BookCustomClass extends BaseClass
         return $bookCustomRes;
     }
 
-    public static function delOnNum($bookCustomRes, $delOnNum, $num, $order, $shop, $product, $params)
+    public static function delOnNum($bookCustomRes, $delOnNum, $num, $bill, $shop, $product, $params)
     {
         $bookCustomRes->onNum = bcsub($bookCustomRes->onNum, $delOnNum);
         $bookCustomRes->save();
@@ -72,21 +72,40 @@ 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 ?? '';
-        $currentCapitalType = dict::getDict('capitalType', 'delBook');
+        $mainId = $shop->mainId ?? 0;
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+
+        $currentChangeType = $params['currentChangeType'] ?? 'delBook';
+        if($currentChangeType == 'ghsCgRefund'){
+            //供货商采购单售后
+            $customId = $bookCustomRes->customId ?? 0;
+            $customName = $bookCustomRes->name ?? '';
+            $customNamePy = $bookCustomRes->py ?? '';
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName.'采购单'. $orderSn. '售后,下架' .$name. $delOnNum . $bigUnit;
+            $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund');
+        }elseif($currentChangeType == 'delBook'){
+            $customId = $bill->customId ?? 0;
+            $customName = $bill->customName ?? '';
+            $customNamePy = $bill->customNamePy ?? '';
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+        }else{
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $event = '';
+            util::fail('不存在的运作哈。。。');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

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

@@ -445,7 +445,7 @@ class BookItemClass extends BaseClass
         return $bookItemRes;
     }
 
-    public static function delOnNum($bookItemRes, $delOnNum, $num, $order, $shop, $product, $params)
+    public static function delOnNum($bookItemRes, $delOnNum, $num, $bill, $shop, $product, $params)
     {
         $bookItemRes->onNum = bcsub($bookItemRes->onNum, $delOnNum);
         $bookItemRes->save();
@@ -461,14 +461,35 @@ class BookItemClass extends BaseClass
         $py = $product->py ?? '';
         $bigUnit = $product->bigUnit ?? '扎';
         $bookSn = $shop->bookSn ?? '';
-        $mainId = $order->mainId ?? 0;
-        $customId = $order->customId ?? 0;
-        $customName = $order->customName ?? '';
-        $customNamePy = $order->customNamePy ?? '';
-        $currentCapitalType = dict::getDict('capitalType', 'delBook');
+        $mainId = $shop->mainId ?? 0;
+
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+
+        $currentChangeType = $params['currentChangeType'] ?? 'delBook';
+        if($currentChangeType == 'ghsCgRefund'){
+            //供货商采购单售后
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName.'采购单'. $orderSn. '售后,下架' .$name. $delOnNum . $bigUnit;
+            $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund');
+        }elseif($currentChangeType == 'delBook'){
+            $customId = $bill->customId ?? 0;
+            $customName = $bill->customName ?? '';
+            $customNamePy = $bill->customNamePy ?? '';
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+        }else{
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $event = '';
+            util::fail('不存在的运作哈。。。');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

+ 28 - 7
biz-ghs/book/classes/BookItemCustomClass.php

@@ -12,7 +12,7 @@ class BookItemCustomClass extends BaseClass
 
     public static $baseFile = '\bizGhs\book\models\BookItemCustom';
 
-    public static function delOnNum($bookItemCustomRes, $delOnNum, $num, $order, $shop, $product, $params)
+    public static function delOnNum($bookItemCustomRes, $delOnNum, $num, $bill, $shop, $product, $params)
     {
         $bookItemCustomRes->onNum = bcsub($bookItemCustomRes->onNum, $delOnNum);
         $bookItemCustomRes->save();
@@ -28,14 +28,35 @@ class BookItemCustomClass extends BaseClass
         $py = $product->py ?? '';
         $bigUnit = $product->bigUnit ?? '扎';
         $bookSn = $shop->bookSn ?? '';
-        $mainId = $order->mainId ?? 0;
-        $customId = $order->customId ?? 0;
-        $customName = $order->customName ?? '';
-        $customNamePy = $order->customNamePy ?? '';
-        $currentCapitalType = dict::getDict('capitalType', 'delBook');
+        $mainId = $shop->mainId ?? 0;
+
         $staffName = $params['staffName'] ?? '';
         $staffId = $params['staffId'] ?? 0;
-        $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+
+        $currentChangeType = $params['currentChangeType'] ?? 'delBook';
+        if($currentChangeType == 'ghsCgRefund'){
+            //供货商采购单售后
+            $customId = $bookItemCustomRes->customId ?? 0;
+            $customName = $bookItemCustomRes->customName ?? '';
+            $customNamePy = $bookItemCustomRes->customNamePy ?? '';
+            $orderSn = $bill->orderSn??'';
+            $event = $staffName.'采购单'. $orderSn. '售后,下架' .$name. $delOnNum . $bigUnit;
+            $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund');
+        }elseif($currentChangeType == 'delBook'){
+            $customId = $bill->customId ?? 0;
+            $customName = $bill->customName ?? '';
+            $customNamePy = $bill->customNamePy ?? '';
+            $event = $customName . '减少预订' . $name . $num . $bigUnit . ',其中下架' . $delOnNum . $bigUnit;
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+        }else{
+            $currentCapitalType = dict::getDict('capitalType', 'delBook');
+            $customId = 0;
+            $customName = '';
+            $customNamePy = '';
+            $event = '';
+            util::fail('不存在的运作哦!!!');
+        }
+
         $changeData = [
             'mainId' => $mainId,
             'bookSn' => $bookSn,

+ 17 - 7
biz-ghs/cg/services/CgRefundService.php

@@ -68,6 +68,12 @@ class CgRefundService extends BaseService
             $shop = $post['shop'] ?? [];
 
             $cgItemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $order->orderSn], null, '*', 'productId', true);
+            $productIds = [];
+            foreach($cgItemList as $cgItem){
+                $productIds[] = $cgItem->productId??0;
+            }
+            $productInfoList = ProductClass::getAllByCondition(['id'=>['in',$productIds]],null,'*','id',true);
+
             foreach ($productData as $currentProduct) {
                 $num = $currentProduct['num'] ?? 0;
                 $productId = $currentProduct['productId'] ?? 0;
@@ -75,6 +81,10 @@ class CgRefundService extends BaseService
                     util::fail('发现无效花材');
                 }
                 $currentCgItem = $cgItemList[$productId] ?? null;
+                $productInfo = $productInfoList[$productId]??null;
+                if(empty($productInfo)){
+                    util::fail('花材信息没有找到呢。');
+                }
                 $hasRefundNum = $currentCgItem->refundNum ?? 0;
                 $totalNum = $currentCgItem->itemNum ?? 0;
                 $unitPrice = $currentCgItem->bigPrice ?? 0;
@@ -150,8 +160,11 @@ class CgRefundService extends BaseService
                         if ($sendRefundNum > $onNum) {
                             util::fail('售后时,bookItemCustom上架数量不够扣');
                         }
-                        $bookItemCustomRes->onNum = bcsub($bookItemCustomRes->onNum, $sendRefundNum);
-                        $bookItemCustomRes->save();
+
+                        $staffId = $post['shopAdminId']??0;
+                        $staffName = $post['shopAdminName']??'';
+                        $params = ['staffId'=>$staffId,'staffName'=>$staffName,'currentChangeType'=>'ghsCgRefund'];
+                        $bookItemCustomRes = BookItemCustomClass::delOnNum($bookItemCustomRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
 
                         $customId = $bookItemCustomRes->customId ?? 0;
                         $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
@@ -162,8 +175,7 @@ class CgRefundService extends BaseService
                         if ($sendRefundNum > $onNum2) {
                             util::fail('售后时,bookCustom上架数量不够扣');
                         }
-                        $bookCustomRes->onNum = bcsub($bookCustomRes->onNum, $sendRefundNum);
-                        $bookCustomRes->save();
+                        $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes,$sendRefundNum, $num, $order, $shop, $productInfo, $params);
 
                         $itemId = $bookItemCustomRes->itemId ?? 0;
                         $bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
@@ -174,9 +186,7 @@ class CgRefundService extends BaseService
                         if ($sendRefundNum > $onNum3) {
                             util::fail('售后时,bookItem上架数量不够扣');
                         }
-                        $bookItemRes->onNum = bcsub($bookItemRes->onNum, $sendRefundNum);
-                        $bookItemRes->save();
-
+                        $bookItemRes = BookItemClass::delOnNum($bookItemRes,$sendRefundNum, $num, $order, $shop, $productInfo, $params);
                     }
                     if (floatval($num) != floatval($totalSendRefundNum)) {
                         util::fail("{$name} 退货数量必须和货位退货数和一致");

+ 2 - 0
common/components/dict.php

@@ -353,6 +353,7 @@ class dict
             'addBook' => ['id' => 67, 'name' => 'addBook'],
             //减少预订
             'delBook' => ['id' => 68, 'name' => 'delBook'],
+            'ghsCgRefund' => ['id' => 69, 'name' => 'ghsCgRefund'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
@@ -394,6 +395,7 @@ class dict
             66 => ['link' => '', 'name' => '充值', 'id' => 66,],
             67 => ['link' => '', 'name' => '新增预订', 'id' => 67,],
             68 => ['link' => '', 'name' => '减少预订', 'id' => 68,],
+            69 => ['link' => '', 'name' => '采购售后', 'id' => 69,],
         ],
 
         //用户来源