shish 1 rok temu
rodzic
commit
da84d96dd6

+ 1 - 1
app-ghs/controllers/CgRefundController.php

@@ -40,7 +40,7 @@ class CgRefundController extends BaseController
         $where['mainId'] = $this->mainId;
         $relateOrderSn = $get['relateOrderSn'] ?? '';
         if (!empty($relateOrderSn)) {
-            $where['relateOrderSn'] = $relateOrderSn;
+            $where['relateOrderSn'] = $relateOrderSnf;
         }
         $list = CgRefundClass::getRefundList($where);
         util::success($list);

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

@@ -776,6 +776,13 @@ class BookItemClass extends BaseClass
             $customNamePy = $bookCustomRes->py ?? '';
             $orderSn = $bill->orderSn ?? '';
             $event = "采购单 {$orderSn} 取消,{$name} 增加待采" . $addNeedCgNum . $bigUnit;
+        } elseif ($currentChangeType == 'refund') {
+            $currentCapitalType = dict::getDict('capitalType', 'ghsCgRefund');
+            $customId = $bookCustomRes->customId ?? 0;
+            $customName = $bookCustomRes->name ?? '';
+            $customNamePy = $bookCustomRes->py ?? '';
+            $orderSn = $bill->orderSn ?? '';
+            $event = "采购单 {$orderSn} 售后,{$name} 增加待采" . $addNeedCgNum . $bigUnit;
         } elseif ($currentChangeType == 'addBook') {
             $currentCapitalType = dict::getDict('capitalType', 'addBook');
             $customId = $bill->customId ?? 0;

+ 1 - 1
biz-ghs/book/classes/BookItemCustomClass.php

@@ -83,7 +83,7 @@ class BookItemCustomClass extends BaseClass
             $needOnNum = bcsub($bookNum, $onNum);
         }
         if ($needOnNum > $couldOnNum) {
-            util::fail('可上' . $couldOnNum . '份');
+            util::fail('可上' . $couldOnNum . '份,需上:'.$needOnNum.',只能上:'.$couldOnNum);
         }
         $params['currentChangeType'] = 'stockOn';
         $bookItemRes = BookItemClass::addOnNum($bookItemRes, $needOnNum, null, $shop, $product, $params);

+ 12 - 0
biz-ghs/cg/classes/CgOrderItemClass.php

@@ -38,6 +38,18 @@ class CgOrderItemClass extends BaseClass
             }
             $cgItemName = $cgItem->name ?? '';
             $parentId = $cgItem->id ?? 0;
+            $assignSeat = $cgItem->assignSeat;
+            if ($assignSeat == 0) {
+                $params['currentChangeType'] = 'cgCancel';
+                $params['customName'] = '';
+                $params['customId'] = '';
+                $params['customNamePy'] = '';
+                $remainNeedSendNum = $cgItem->itemNum ?? 0;
+                $currentItemInfo = ProductClass::getById($productId, true);
+                $bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $productId], true);
+                $bookItemRes = BookItemClass::addNeedCgNum($bookItemRes, $remainNeedSendNum, 0, $cg, $shop, $currentItemInfo, $params);
+                continue;
+            }
             $sendList = CgOrderItemSendClass::getAllByCondition(['parentId' => $parentId], null, '*', null, true);
             if (!empty($sendList)) {
                 foreach ($sendList as $send) {

+ 80 - 69
biz-ghs/cg/services/CgRefundService.php

@@ -122,82 +122,93 @@ class CgRefundService extends BaseService
 
                 $sendRefundData = $currentProduct['sendRefund'] ?? [];
                 if ($shop->bookSn == $bookSn && !empty($bookSn)) {
-                    if (!empty($sendRefundData)) {
-                        $sendIds = array_column($sendRefundData, 'id');
-                        $sendRes = CgOrderItemSendClass::getAllByCondition(['id' => ['in', $sendIds]], null, '*', 'id', true);
-                        $totalSendRefundNum = 0;
-                        foreach ($sendRefundData as $sendKey => $send) {
-                            $sendRefundNum = $send['refundNum'] ?? 0;
-                            $totalSendRefundNum = bcadd($totalSendRefundNum, $sendRefundNum);
-                            $sendId = $send['id'] ?? 0;
-                            $currentSend = $sendRes[$sendId] ?? null;
-                            if (empty($currentSend)) {
-                                util::fail('没有找到采购单花材的配送信息呢');
-                            }
-                            $totalOnNum = $currentSend->num ?? 0;
-                            $hasOutNum = $currentSend->outNum ?? 0;
-                            $remainNum = bcsub($totalOnNum, $hasOutNum);
-                            $customName = $currentSend->customName ?? '';
-                            if ($sendRefundNum > $remainNum) {
-                                util::fail($customName . '货位不够退了');
-                            }
-                            $currentSend->outNum = bcadd($currentSend->outNum, $sendRefundNum);
-                            $currentSend->save();
+                    $assignSeat = $currentCgItem->assignSeat;
+                    if ($assignSeat == 0) {
+                        $params['currentChangeType'] = 'refund';
+                        $params['customName'] = '';
+                        $params['customId'] = '';
+                        $params['customNamePy'] = '';
+                        $currentItemInfo = ProductClass::getById($productId, true);
+                        $bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $productId], true);
+                        $bookItemRes = BookItemClass::addNeedCgNum($bookItemRes, $num, 0, $order, $shop, $currentItemInfo, $params);
+                    } else {
+                        if (!empty($sendRefundData)) {
+                            $sendIds = array_column($sendRefundData, 'id');
+                            $sendRes = CgOrderItemSendClass::getAllByCondition(['id' => ['in', $sendIds]], null, '*', 'id', true);
+                            $totalSendRefundNum = 0;
+                            foreach ($sendRefundData as $sendKey => $send) {
+                                $sendRefundNum = $send['refundNum'] ?? 0;
+                                $totalSendRefundNum = bcadd($totalSendRefundNum, $sendRefundNum);
+                                $sendId = $send['id'] ?? 0;
+                                $currentSend = $sendRes[$sendId] ?? null;
+                                if (empty($currentSend)) {
+                                    util::fail('没有找到采购单花材的配送信息呢');
+                                }
+                                $totalOnNum = $currentSend->num ?? 0;
+                                $hasOutNum = $currentSend->outNum ?? 0;
+                                $remainNum = bcsub($totalOnNum, $hasOutNum);
+                                $customName = $currentSend->customName ?? '';
+                                if ($sendRefundNum > $remainNum) {
+                                    util::fail($customName . '货位不够退了');
+                                }
+                                $currentSend->outNum = bcadd($currentSend->outNum, $sendRefundNum);
+                                $currentSend->save();
 
-                            $bookGhsGiveId = $currentSend->bookGhsGiveId ?? 0;
-                            $give = BookItemGhsClass::getById($bookGhsGiveId, true);
-                            if (empty($give)) {
-                                util::fail('售后时,货位配送相关信息缺失哦');
-                            }
-                            $give->outNum = bcadd($give->outNum, $sendRefundNum);
-                            $give->save();
+                                $bookGhsGiveId = $currentSend->bookGhsGiveId ?? 0;
+                                $give = BookItemGhsClass::getById($bookGhsGiveId, true);
+                                if (empty($give)) {
+                                    util::fail('售后时,货位配送相关信息缺失哦');
+                                }
+                                $give->outNum = bcadd($give->outNum, $sendRefundNum);
+                                $give->save();
 
-                            $bookItemCustomId = $currentSend->bookItemCustomId ?? 0;
-                            $bookItemCustomRes = BookItemCustomClass::getById($bookItemCustomId, true);
-                            if (empty($bookItemCustomRes)) {
-                                util::fail('售后时,bookItemCustom信息缺失');
-                            }
-                            $onNum = $bookItemCustomRes->onNum ?? 0;
-                            if ($sendRefundNum > $onNum) {
-                                util::fail('售后时,bookItemCustom上架数量不够扣');
-                            }
+                                $bookItemCustomId = $currentSend->bookItemCustomId ?? 0;
+                                $bookItemCustomRes = BookItemCustomClass::getById($bookItemCustomId, true);
+                                if (empty($bookItemCustomRes)) {
+                                    util::fail('售后时,bookItemCustom信息缺失');
+                                }
+                                $onNum = $bookItemCustomRes->onNum ?? 0;
+                                if ($sendRefundNum > $onNum) {
+                                    util::fail('售后时,bookItemCustom上架数量不够扣');
+                                }
 
-                            $staffId = $post['shopAdminId'] ?? 0;
-                            $staffName = $post['shopAdminName'] ?? '';
-                            $params = ['staffId' => $staffId, 'staffName' => $staffName, 'currentChangeType' => 'ghsCgRefund'];
-                            $bookItemCustomRes = BookItemCustomClass::delOnNum($bookItemCustomRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
+                                $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);
-                            if (empty($bookCustomRes)) {
-                                util::fail('售后时,bookCustom信息缺失');
-                            }
-                            $onNum2 = $bookCustomRes->onNum ?? 0;
-                            if ($sendRefundNum > $onNum2) {
-                                util::fail('售后时,bookCustom上架数量不够扣');
-                            }
-                            $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
+                                $customId = $bookItemCustomRes->customId ?? 0;
+                                $bookCustomRes = BookCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId], true);
+                                if (empty($bookCustomRes)) {
+                                    util::fail('售后时,bookCustom信息缺失');
+                                }
+                                $onNum2 = $bookCustomRes->onNum ?? 0;
+                                if ($sendRefundNum > $onNum2) {
+                                    util::fail('售后时,bookCustom上架数量不够扣');
+                                }
+                                $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
 
-                            $itemId = $bookItemCustomRes->itemId ?? 0;
-                            $bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
-                            if (empty($bookItemRes)) {
-                                util::fail('售后时,bookItem信息缺失');
+                                $itemId = $bookItemCustomRes->itemId ?? 0;
+                                $bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
+                                if (empty($bookItemRes)) {
+                                    util::fail('售后时,bookItem信息缺失');
+                                }
+                                $onNum3 = $bookItemRes->onNum ?? 0;
+                                if ($sendRefundNum > $onNum3) {
+                                    util::fail('售后时,bookItem上架数量不够扣');
+                                }
+                                $bookItemRes = BookItemClass::delOnNum($bookItemRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
                             }
-                            $onNum3 = $bookItemRes->onNum ?? 0;
-                            if ($sendRefundNum > $onNum3) {
-                                util::fail('售后时,bookItem上架数量不够扣');
+                            if (floatval($num) != floatval($totalSendRefundNum)) {
+                                util::fail("{$name} 退货数量必须和货位退货数和一致");
                             }
-                            $bookItemRes = BookItemClass::delOnNum($bookItemRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
-                        }
-                        if (floatval($num) != floatval($totalSendRefundNum)) {
-                            util::fail("{$name} 退货数量必须和货位退货数和一致");
-                        }
-                    }else{
-                        $sendList = CgOrderItemSendClass::getAllByCondition(['parentId'=>$currentCgItem->id],null,'*',null,true);
-                        if(!empty($sendList)){
-                            foreach($sendList as $sendInfo){
-                                if($sendInfo->status != 2){
-                                    util::fail('请填写货位要退的数量');
+                        } else {
+                            $sendList = CgOrderItemSendClass::getAllByCondition(['parentId' => $currentCgItem->id], null, '*', null, true);
+                            if (!empty($sendList)) {
+                                foreach ($sendList as $sendInfo) {
+                                    if ($sendInfo->status != 2) {
+                                        util::fail('请填写货位要退的数量');
+                                    }
                                 }
                             }
                         }