|
|
@@ -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} 退货数量必须和货位退货数和一致");
|