|
@@ -1792,10 +1792,7 @@ class GoodsController extends Curd
|
|
|
$discountJson = [];
|
|
|
if (!empty($params['order_discount_json'])) {
|
|
|
$discountJson = json_decode($params['order_discount_json'], true);
|
|
|
- foreach ($discountJson as $item) {
|
|
|
-// if (!empty($item['coupon_value'])) {
|
|
|
-// $item['coupon_value'] = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $item['coupon_value'], 2);
|
|
|
-// }
|
|
|
+ foreach ($discountJson as &$item) {
|
|
|
if (!empty($item['coupon_id'])) {
|
|
|
$orderAmount = OrderService::countAndAmount($params['goodsContentList'], $item['coupon_id']);
|
|
|
$payAmountUseCoupon = $params['order_amount_pay'] - ($params['order_amount_total'] - $orderAmount['amount']);
|
|
@@ -1803,9 +1800,12 @@ class GoodsController extends Curd
|
|
|
$amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $payAmountUseCoupon, 2);
|
|
|
}
|
|
|
} else {
|
|
|
- $orderAmount['amount'] = $params['order_amount_pay'];
|
|
|
+ $orderAmount['amount'] = $params['order_amount_total'];
|
|
|
$amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
|
|
|
}
|
|
|
+ if (!empty($item['coupon_value'])) {
|
|
|
+ $item['coupon_value'] = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $item['coupon_value'], 2);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$orderId = 'OD' . date('ymdHi') . random_string(4, 'up');
|