|
|
@ -121,6 +121,10 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
Db::beginTransaction(); |
|
|
Db::beginTransaction(); |
|
|
try { |
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
// 获取分布式全局ID
|
|
|
|
|
|
$generator = ApplicationContext::getContainer()->get(IdGeneratorInterface::class); |
|
|
|
|
|
$globalOrderId = $generator->generate(); |
|
|
|
|
|
|
|
|
$mainTable = ApplicationContext::getContainer()->get(OrderMain::class)->getTable(); |
|
|
$mainTable = ApplicationContext::getContainer()->get(OrderMain::class)->getTable(); |
|
|
$childTable = ApplicationContext::getContainer()->get(Order::class)->getTable(); |
|
|
$childTable = ApplicationContext::getContainer()->get(Order::class)->getTable(); |
|
|
|
|
|
|
|
|
@ -240,15 +244,16 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
|
|
|
|
|
|
// 计算红包折扣金额
|
|
|
// 计算红包折扣金额
|
|
|
foreach ($canRealUseCoupons as $key => &$coupon) { |
|
|
foreach ($canRealUseCoupons as $key => &$coupon) { |
|
|
if (!in_array($coupon['id'], $receiveCouponIds)) { |
|
|
|
|
|
unset($coupon); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!in_array($coupon->id, $receiveCouponIds)) { |
|
|
|
|
|
unset($canRealUseCoupons[$key]); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ($coupon['coupon']['discount_type'] == Coupon::DISCOUNT_TYPE_CASH) { |
|
|
|
|
|
$couponMoney = bcadd($couponMoney, $coupon['coupon']['discounts'], 2); |
|
|
|
|
|
} elseif ($coupon['coupon']['discount_type'] == Coupon::DISCOUNT_TYPE_RATE) { |
|
|
|
|
|
$discountRate = bcdiv($coupon['coupon']['discounts'],10); |
|
|
|
|
|
|
|
|
if ($coupon->coupon->discount_type == Coupon::DISCOUNT_TYPE_CASH) { |
|
|
|
|
|
$couponMoney = bcadd($couponMoney, $coupon->coupon->discounts, 2); |
|
|
|
|
|
} elseif ($coupon->coupon->discount_type == Coupon::DISCOUNT_TYPE_RATE) { |
|
|
|
|
|
$discountRate = bcdiv($coupon->coupon->discounts,10); |
|
|
$discountRate = bcsub(1,$discountRate); |
|
|
$discountRate = bcsub(1,$discountRate); |
|
|
$discountMoney = bcmul($orderAmount, $discountRate); |
|
|
$discountMoney = bcmul($orderAmount, $discountRate); |
|
|
$couponMoney = bcadd($couponMoney, $discountMoney, 2); |
|
|
$couponMoney = bcadd($couponMoney, $discountMoney, 2); |
|
|
@ -257,10 +262,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 获取分布式全局ID
|
|
|
|
|
|
$generator = ApplicationContext::getContainer()->get(IdGeneratorInterface::class); |
|
|
|
|
|
$globalOrderId = $generator->generate(); |
|
|
|
|
|
|
|
|
|
|
|
$orderAmount = bcadd((string)$orderAmount, '0', 2); |
|
|
$orderAmount = bcadd((string)$orderAmount, '0', 2); |
|
|
$totalAmount = bcadd((string)$totalAmount, (string)$orderAmount); |
|
|
$totalAmount = bcadd((string)$totalAmount, (string)$orderAmount); |
|
|
$totalAmount = bcadd((string)$totalAmount, (string)$deliveryAmount); |
|
|
$totalAmount = bcadd((string)$totalAmount, (string)$deliveryAmount); |
|
|
@ -333,11 +334,12 @@ class OrderOnlineService implements OrderOnlineServiceInterface |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 优惠券红包使用记录
|
|
|
|
|
|
$this->couponService->orderUseCoupons($globalOrderId, $canRealUseCoupons); |
|
|
|
|
|
|
|
|
|
|
|
Db::commit(); |
|
|
Db::commit(); |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($receiveCouponIds)) { |
|
|
|
|
|
$this->couponService->orderUseCoupons($globalOrderId, $canRealUseCoupons); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 清除购物车
|
|
|
// 清除购物车
|
|
|
$this->shopCartUpdateService->doClear($userId, $marketId); |
|
|
$this->shopCartUpdateService->doClear($userId, $marketId); |
|
|
|
|
|
|
|
|
|