修改红包退还金额的错误
This commit is contained in:
parent
a64abab901
commit
98d65a1cad
@ -40,7 +40,7 @@ class StoreRefundProductDao extends BaseDao
|
|||||||
$lst = $this->getModel()::getDB()->alias('A')->leftJoin('StoreRefundOrder B', 'A.refund_order_id = B.refund_order_id')
|
$lst = $this->getModel()::getDB()->alias('A')->leftJoin('StoreRefundOrder B', 'A.refund_order_id = B.refund_order_id')
|
||||||
->where('B.status', '>', -1)
|
->where('B.status', '>', -1)
|
||||||
->whereIn('A.order_product_id', $ids)->group('A.order_product_id')
|
->whereIn('A.order_product_id', $ids)->group('A.order_product_id')
|
||||||
->field('A.order_product_id, SUM(A.refund_price) as refund_price, SUM(A.platform_refund_price) as platform_refund_price, SUM(A.refund_postage) as refund_postage, SUM(A.refund_integral) as refund_integral')
|
->field('A.order_product_id, SUM(A.refund_price) as refund_price, SUM(A.platform_refund_price) as platform_refund_price, SUM(A.refund_postage) as refund_postage, SUM(A.refund_integral) as refund_integral, SUM(A.refund_consumption) as refund_consumption')
|
||||||
->select()->toArray();
|
->select()->toArray();
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach ($lst as $item) {
|
foreach ($lst as $item) {
|
||||||
|
@ -457,15 +457,18 @@ class StoreRefundOrderRepository extends BaseRepository
|
|||||||
$postagePrice = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
$postagePrice = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
||||||
|
|
||||||
$refundPrice = 0;
|
$refundPrice = 0;
|
||||||
|
$consumptionRefund = 0;
|
||||||
//计算可退金额
|
//计算可退金额
|
||||||
if ($product['product_price'] > 0) {
|
if ($product['product_price'] > 0) {
|
||||||
// 商品实付单价
|
// 商品实付单价
|
||||||
$payPrice = bcdiv($product['pay_price'], $product['product_num'], 2);
|
$payPrice = bcdiv($product['pay_price'], $product['product_num'], 2);
|
||||||
$consumptionPrice = $product['consumption_price'];
|
$consumptionPrice = bcdiv($product['consumption_price'], $product['product_num'], 2);
|
||||||
if ($product['refund_num'] == $num) {
|
if ($product['refund_num'] == $num) {
|
||||||
$refundPrice = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
$refundPrice = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||||
|
$consumptionRefund = bcsub($product['consumption_price'], $productRefundPrice['refund_consumption'] ?? 0, 2);
|
||||||
} else {
|
} else {
|
||||||
$refundPrice = bcmul($payPrice, $num, 2);
|
$refundPrice = bcmul($payPrice, $num, 2);
|
||||||
|
$consumptionRefund = bcmul($consumptionPrice, $num, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$totalRefundPrice = bcadd($refundPrice, $postagePrice, 2);
|
$totalRefundPrice = bcadd($refundPrice, $postagePrice, 2);
|
||||||
@ -516,12 +519,12 @@ class StoreRefundOrderRepository extends BaseRepository
|
|||||||
$data['refund_num'] = $num;
|
$data['refund_num'] = $num;
|
||||||
$data['extension_one'] = $total_extension_one;
|
$data['extension_one'] = $total_extension_one;
|
||||||
$data['extension_two'] = $total_extension_two;
|
$data['extension_two'] = $total_extension_two;
|
||||||
$data['refund_consumption'] = $consumptionPrice ?? 0;
|
$data['refund_consumption'] = $consumptionRefund;
|
||||||
if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
$data['refund_price'] = 0;
|
$data['refund_price'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Db::transaction(function () use ($order, $data, $product, $productId, $num) {
|
return Db::transaction(function () use ($order, $data, $product, $productId, $num, $consumptionRefund) {
|
||||||
event('refund.create.before', compact('data'));
|
event('refund.create.before', compact('data'));
|
||||||
$refund = $this->dao->create($data);
|
$refund = $this->dao->create($data);
|
||||||
app()->make(StoreRefundProductRepository::class)->create([
|
app()->make(StoreRefundProductRepository::class)->create([
|
||||||
@ -532,6 +535,7 @@ class StoreRefundOrderRepository extends BaseRepository
|
|||||||
'refund_price' => $data['refund_price'],
|
'refund_price' => $data['refund_price'],
|
||||||
'refund_integral' => $data['integral'],
|
'refund_integral' => $data['integral'],
|
||||||
'refund_postage' => $data['refund_postage'],
|
'refund_postage' => $data['refund_postage'],
|
||||||
|
'refund_consumption' => $consumptionRefund,
|
||||||
]);
|
]);
|
||||||
$product->refund_num -= $num;
|
$product->refund_num -= $num;
|
||||||
$product->is_refund = 1;
|
$product->is_refund = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user