|
|
@@ -68,14 +68,14 @@ class CgRefundService extends BaseService
|
|
|
}
|
|
|
|
|
|
$shop = $post['shop'] ?? [];
|
|
|
- $originalPrice = 0;
|
|
|
+ $originalPrice = 0;
|
|
|
$cgItemList = PurchaseOrderItemClass::getAllByCondition(['orderSn' => $order->orderSn], null, '*', 'productId', true);
|
|
|
|
|
|
$productIds = [];
|
|
|
- foreach($cgItemList as $cgItem){
|
|
|
- $productIds[] = $cgItem->productId??0;
|
|
|
+ foreach ($cgItemList as $cgItem) {
|
|
|
+ $productIds[] = $cgItem->productId ?? 0;
|
|
|
}
|
|
|
- $productInfoList = ProductClass::getAllByCondition(['id'=>['in',$productIds]],null,'*','id',true);
|
|
|
+ $productInfoList = ProductClass::getAllByCondition(['id' => ['in', $productIds]], null, '*', 'id', true);
|
|
|
foreach ($productData as $currentProduct) {
|
|
|
$num = $currentProduct['num'] ?? 0;
|
|
|
$productId = $currentProduct['productId'] ?? 0;
|
|
|
@@ -83,8 +83,8 @@ class CgRefundService extends BaseService
|
|
|
util::fail('发现无效花材');
|
|
|
}
|
|
|
$currentCgItem = $cgItemList[$productId] ?? null;
|
|
|
- $productInfo = $productInfoList[$productId]??null;
|
|
|
- if(empty($productInfo)){
|
|
|
+ $productInfo = $productInfoList[$productId] ?? null;
|
|
|
+ if (empty($productInfo)) {
|
|
|
util::fail('花材信息没有找到呢。');
|
|
|
}
|
|
|
$hasRefundNum = $currentCgItem->refundNum ?? 0;
|
|
|
@@ -102,6 +102,7 @@ class CgRefundService extends BaseService
|
|
|
if ($couldRefundNum < $num) {
|
|
|
util::fail('超过可退数量');
|
|
|
}
|
|
|
+ $originalPrice = bcadd($originalPrice, $totalPrice, 2);
|
|
|
$name = $currentCgItem->name ?? '';
|
|
|
$cover = $currentCgItem->cover ?? '';
|
|
|
$ptItemId = $currentCgItem->itemId ?? 0;
|
|
|
@@ -135,14 +136,14 @@ class CgRefundService extends BaseService
|
|
|
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.'货位不够退了');
|
|
|
+ $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->outNum = bcadd($currentSend->outNum, $sendRefundNum);
|
|
|
$currentSend->save();
|
|
|
|
|
|
$bookGhsGiveId = $currentSend->bookGhsGiveId ?? 0;
|
|
|
@@ -163,9 +164,9 @@ class CgRefundService extends BaseService
|
|
|
util::fail('售后时,bookItemCustom上架数量不够扣');
|
|
|
}
|
|
|
|
|
|
- $staffId = $post['shopAdminId']??0;
|
|
|
- $staffName = $post['shopAdminName']??'';
|
|
|
- $params = ['staffId'=>$staffId,'staffName'=>$staffName,'currentChangeType'=>'ghsCgRefund'];
|
|
|
+ $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;
|
|
|
@@ -177,7 +178,7 @@ class CgRefundService extends BaseService
|
|
|
if ($sendRefundNum > $onNum2) {
|
|
|
util::fail('售后时,bookCustom上架数量不够扣');
|
|
|
}
|
|
|
- $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes,$sendRefundNum, $num, $order, $shop, $productInfo, $params);
|
|
|
+ $bookCustomRes = BookCustomClass::delOnNum($bookCustomRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
|
|
|
|
|
|
$itemId = $bookItemCustomRes->itemId ?? 0;
|
|
|
$bookItemRes = BookItemClass::getByCondition(['bookSn' => $bookSn, 'itemId' => $itemId], true);
|
|
|
@@ -188,14 +189,14 @@ class CgRefundService extends BaseService
|
|
|
if ($sendRefundNum > $onNum3) {
|
|
|
util::fail('售后时,bookItem上架数量不够扣');
|
|
|
}
|
|
|
- $bookItemRes = BookItemClass::delOnNum($bookItemRes,$sendRefundNum, $num, $order, $shop, $productInfo, $params);
|
|
|
+ $bookItemRes = BookItemClass::delOnNum($bookItemRes, $sendRefundNum, $num, $order, $shop, $productInfo, $params);
|
|
|
}
|
|
|
if (floatval($num) != floatval($totalSendRefundNum)) {
|
|
|
util::fail("{$name} 退货数量必须和货位退货数和一致");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if($refundPrice<$originalPrice){
|
|
|
+ if ($refundPrice < $originalPrice) {
|
|
|
util::fail('退款金额需要等于或大于花材总和');
|
|
|
}
|
|
|
}
|
|
|
@@ -206,7 +207,7 @@ class CgRefundService extends BaseService
|
|
|
$refund = CgRefundClass::add($data, true);
|
|
|
|
|
|
//锁定当前增加资产的运作,有多处,请搜索关键词 ghsAddDebtAction
|
|
|
- $ghsId = $order->ghsId??0;
|
|
|
+ $ghsId = $order->ghsId ?? 0;
|
|
|
$ghs = GhsClass::getLockById($ghsId);
|
|
|
if (empty($ghs)) {
|
|
|
util::fail('没有找到供货商');
|
|
|
@@ -229,9 +230,9 @@ class CgRefundService extends BaseService
|
|
|
'amount' => $refundPrice,
|
|
|
'balance' => $ghs->debtAmount,
|
|
|
'io' => 0,
|
|
|
- 'staffId'=>$refund->shopAdminId,
|
|
|
- 'staffName'=>$refund->shopAdminName,
|
|
|
- 'event' => '采购单 '.$order->orderSn.' 申请售后 ' .$orderSn ,
|
|
|
+ 'staffId' => $refund->shopAdminId,
|
|
|
+ 'staffName' => $refund->shopAdminName,
|
|
|
+ 'event' => '采购单 ' . $order->orderSn . ' 申请售后 ' . $orderSn,
|
|
|
'sjId' => $sjId,
|
|
|
'shopId' => $shopId,
|
|
|
];
|