|
|
@@ -15,6 +15,7 @@ use app\services\BaseServices;
|
|
|
use app\dao\order\StoreOrderDao;
|
|
|
use app\services\pay\PayServices;
|
|
|
use app\services\product\product\StoreCategoryServices;
|
|
|
+use app\services\product\product\StoreProductServices;
|
|
|
use app\services\user\member\MemberCardServices;
|
|
|
use app\services\user\UserBillServices;
|
|
|
use app\services\user\UserServices;
|
|
|
@@ -111,6 +112,29 @@ class StoreOrderComputedServices extends BaseServices
|
|
|
$bargainId = $this->paramData['bargainId'] ?? 0;
|
|
|
$isActivity = $combinationId || $seckillId || $bargainId;
|
|
|
if (!$isActivity) {
|
|
|
+ // 当使用了优惠券时,检查购物车中是否存在复购商品(is_repeat=1)
|
|
|
+ // 若存在,则取消会员折扣(优惠券与会员折扣互斥),重新按原价计算总价
|
|
|
+ if ($couponId > 0) {
|
|
|
+ $productIds = array_unique(array_column($cartInfo, 'product_id'));
|
|
|
+ /** @var StoreProductServices $productServices */
|
|
|
+ $productServices = app()->make(StoreProductServices::class);
|
|
|
+ $hasRepeat = $productServices->getCount([['id', 'in', $productIds], ['is_repeat', '=', 1]]) > 0;
|
|
|
+ if ($hasRepeat) {
|
|
|
+ // 将所有有会员折扣的商品还原为原价,重新汇总总价
|
|
|
+ $newTotalPrice = '0';
|
|
|
+ foreach ($cartInfo as &$cartItem) {
|
|
|
+ if (isset($cartItem['price_type']) && in_array($cartItem['price_type'], ['level', 'member'])) {
|
|
|
+ $cartItem['truePrice'] = $cartItem['sum_price'];
|
|
|
+ $cartItem['vip_truePrice'] = 0;
|
|
|
+ $cartItem['price_type'] = 'normal';
|
|
|
+ }
|
|
|
+ $newTotalPrice = bcadd($newTotalPrice, bcmul((string)$cartItem['truePrice'], (string)$cartItem['cart_num'], 4), 2);
|
|
|
+ }
|
|
|
+ unset($cartItem);
|
|
|
+ $payPrice = (float)$newTotalPrice;
|
|
|
+ $priceGroup['totalPrice'] = $newTotalPrice;
|
|
|
+ }
|
|
|
+ }
|
|
|
//使用优惠劵
|
|
|
[$payPrice, $couponPrice] = $this->useCouponId($couponId, $uid, $cartInfo, $payPrice, $isCreate);
|
|
|
//使用积分
|