|
@@ -1918,18 +1918,30 @@ class ServicesController extends Curd
|
|
|
}
|
|
|
// 推荐人
|
|
|
$params['order_extend_json']['referee'] = $params['referee'] ?? '';
|
|
|
+ $orderAmount = [];
|
|
|
foreach ($params['goodsContentList'] as $goods) {
|
|
|
+ $amountPay = floatval($goods['goods_sales_price']) * $goods['nbr'];
|
|
|
$discountJson = [];
|
|
|
if (!empty($params['order_discount_json'])) {
|
|
|
$discountJson = json_decode($params['order_discount_json'], true);
|
|
|
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']);
|
|
|
+ if (in_array($goods['goods_id'], $orderAmount['goodsIds'])) {
|
|
|
+ $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $orderAmount['amount']) * $payAmountUseCoupon, 2);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $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'] / $params['order_amount_total']) * $item['coupon_value'], 2);
|
|
|
+ $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');
|
|
|
- $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
|
|
|
+// $amountPay = round((floatval($goods['goods_sales_price']) * $goods['nbr'] / $params['order_amount_total']) * $params['order_amount_pay'], 2);
|
|
|
// $amountPay = round(floatval($goods['goods_sales_price']) * $goods['nbr'] * $params['order_ratio'], 2);
|
|
|
$data = [
|
|
|
'order_id' => $orderId,
|
|
@@ -1946,7 +1958,7 @@ class ServicesController extends Curd
|
|
|
'order_status_storage' => $params['order_status_storage'],
|
|
|
'order_platform' => $params['order_platform'],
|
|
|
'order_remark' => $params['order_remark'] ?? '',
|
|
|
- 'order_discount_json' => json_encode($discountJson),
|
|
|
+ 'order_discount_json' => (!empty($orderAmount['goodsIds']) && in_array($goods['goods_id'], $orderAmount['goodsIds'])) || (empty($orderAmount['goodsIds']) && !empty($orderAmount['amount'])) ? json_encode($discountJson) : '[]',
|
|
|
'order_config_json' => $params['order_config_json'] ?? '[]',
|
|
|
'order_express_json' => $params['order_express_json'] ?? '[]',
|
|
|
'order_extend_json' => $params['order_extend_json'] ? json_encode($params['order_extend_json']) : '[]',
|