6
0
Fork 0

调整换货补货调整数量,导致金额对不上

release
vine_liutk 2022-03-23 15:25:26 +08:00
parent 7ac3de3449
commit 214fa33aaf
2 changed files with 11 additions and 1 deletions

View File

@ -64,7 +64,15 @@ class AfterSaleVerify extends Form implements LazyRenderable
if ($num > $afterSale->orderProduct->quantity) {
throw new BizException('调整数量不能大于下单数量');
}
$afterSaleService->verify($afterSale, $input['remarks3'], (int) Arr::get($input, 'amount', 0), $num);
//调整换货补货时amount问题
$amount = (int) Arr::get($input, 'amount', 0) ?: $afterSale->amount;
if (in_array($afterSale->type, [Aftersale::TYPE_CHANGE, Aftersale::TYPE_FILL])) {
//如果调整数量, 则同时调整价格
if ($num != $afterSale->num) {
$amount = bcmul(bcdiv($afterSale->amount, $afterSale->num), $num);
}
}
$afterSaleService->verify($afterSale, $input['remarks3'], $amount, $num);
} elseif ($input['state'] == 1) {//需要补充资料
$afterSaleService->backApply($afterSale, $input['remarks1']);
}

View File

@ -183,6 +183,7 @@ class AfterSaleService
case AfterSale::TYPE_CHANGE:
$afterSale->update([
'num' => $num,
'amount' => $amount,
'state' => $afterSale::STATE_AGREE,
'remarks' => $remarks,
]);
@ -195,6 +196,7 @@ class AfterSaleService
case AfterSale::TYPE_FILL:
$afterSale->update([
'num' => $num,
'amount' => $amount,
'state' => $afterSale::STATE_AGREE,
'remarks' => $remarks,
]);