|
@@ -497,6 +497,7 @@ class OrderService
|
|
->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
->where('join_goods_coupon_id', $couponId)
|
|
->where('join_goods_coupon_id', $couponId)
|
|
->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
|
|
+ ->where('coupon_detail.coupon_detail_status', 'ACTIVED')
|
|
->first();
|
|
->first();
|
|
if (!$couponDetail) {
|
|
if (!$couponDetail) {
|
|
continue;
|
|
continue;
|
|
@@ -508,45 +509,30 @@ class OrderService
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (in_array($couponDetail->coupon_classify, ['立减券', '满减券'])) {
|
|
if (in_array($couponDetail->coupon_classify, ['立减券', '满减券'])) {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
- if (!Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
- Redis::sAdd($cacheKey, $couponId);
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- $cutBalance = $couponDetail->coupon_value;
|
|
|
|
- }
|
|
|
|
- if ($cutBalance - $money >= 0) {
|
|
|
|
- $payAmount = $payAmount - $money;
|
|
|
|
- $cutBalance = $cutBalance - $money;
|
|
|
|
- } elseif ($cutBalance != 0 && $cutBalance - $money < 0) {
|
|
|
|
- $payAmount = $payAmount - $cutBalance;
|
|
|
|
- $cutBalance = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ $payAmount = $payAmount - $couponDetail->coupon_value;
|
|
// json记录
|
|
// json记录
|
|
$discountData[$couponId] = [
|
|
$discountData[$couponId] = [
|
|
'coupon_id' => $couponId,
|
|
'coupon_id' => $couponId,
|
|
- 'coupon_value' => $cutBalance == 0 ? $couponDetail->coupon_value : $money,
|
|
|
|
|
|
+ 'coupon_value' => $couponDetail->coupon_value,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
];
|
|
];
|
|
- Redis::set($cacheDiscountKey, json_encode($discountData,JSON_UNESCAPED_UNICODE));
|
|
|
|
-
|
|
|
|
|
|
+ Redis::set($cacheDiscountKey, json_encode($discountData, JSON_UNESCAPED_UNICODE));
|
|
CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
}
|
|
}
|
|
} elseif ($couponDetail->coupon_classify == '折扣券') {
|
|
} elseif ($couponDetail->coupon_classify == '折扣券') {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
- $payAmount = $payAmount - ($money * (100 - $couponDetail->coupon_value) / 100);
|
|
|
|
- if (!empty($discountData[$couponId]['coupon_value'])) {
|
|
|
|
- $zhekouAmount = $discountData[$couponId]['coupon_value'] + ($money * (100 - $couponDetail->coupon_value) / 100);
|
|
|
|
- } else {
|
|
|
|
- $zhekouAmount = $money * (100 - $couponDetail->coupon_value) / 100;
|
|
|
|
- }
|
|
|
|
|
|
+ $zhekouAmount = round($countAndAmount['amount'] * (100 - $couponDetail->coupon_value) / 100, 2);
|
|
|
|
+ $payAmount = $payAmount - $zhekouAmount;
|
|
// json记录
|
|
// json记录
|
|
$discountData[$couponId] = [
|
|
$discountData[$couponId] = [
|
|
'coupon_id' => $couponId,
|
|
'coupon_id' => $couponId,
|
|
@@ -554,97 +540,56 @@ class OrderService
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
];
|
|
];
|
|
- Redis::set($cacheDiscountKey, json_encode($discountData,JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
+ Redis::set($cacheDiscountKey, json_encode($discountData, JSON_UNESCAPED_UNICODE));
|
|
CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
}
|
|
}
|
|
} elseif (in_array($couponDetail->coupon_classify, ['抵用券', '赠品券'])) {
|
|
} elseif (in_array($couponDetail->coupon_classify, ['抵用券', '赠品券'])) {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
- if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
|
|
- $diyongCouponDetailIds = CouponDetail::leftJoin('coupon_goods', 'coupon_goods.join_goods_coupon_id', '=', 'coupon_detail.join_detail_coupon_id')
|
|
|
|
- ->where('join_detail_coupon_id', $couponId)
|
|
|
|
- ->where('coupon_goods.join_coupon_goods_id', $goodsId)
|
|
|
|
- ->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
|
|
- ->where('coupon_detail_status', 'ACTIVED')
|
|
|
|
- ->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
|
|
- ->pluck('coupon_detail_id')
|
|
|
|
- ->toArray();
|
|
|
|
- $couponDetailsIds = Redis::sMembers($cacheKey);
|
|
|
|
- foreach ($diyongCouponDetailIds as $key => $detailId) {
|
|
|
|
- if (in_array($detailId, $couponDetailsIds)) {
|
|
|
|
- unset($diyongCouponDetailIds[$key]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (count($diyongCouponDetailIds) > $good['nbr']) {
|
|
|
|
- $diyongCouponDetailIds = array_slice($diyongCouponDetailIds, 0, ceil($good['nbr']));
|
|
|
|
- }
|
|
|
|
- $useDetailIds = [];
|
|
|
|
- if (!empty($discountData[$couponId]['coupon_detail_id'])) {
|
|
|
|
- $useDetailIds = $discountData[$couponId]['coupon_detail_id'];
|
|
|
|
- }
|
|
|
|
- $diyongAmount = 0;
|
|
|
|
- if (!empty($discountData[$couponId]['coupon_value'])) {
|
|
|
|
- $diyongAmount = $discountData[$couponId]['coupon_value'];
|
|
|
|
- }
|
|
|
|
- foreach ($diyongCouponDetailIds as $detailId) {
|
|
|
|
- // 是否计算过了
|
|
|
|
- if (!Redis::sIsMember($cacheKey, $detailId)) {
|
|
|
|
- $useDetailIds[] = $detailId;
|
|
|
|
- Redis::sAdd($cacheKey, $detailId);
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- CouponDetail::where('coupon_detail_id', $detailId)->update(['coupon_detail_status' => 'USED']);
|
|
|
|
- if ($good['nbr'] > 1) {
|
|
|
|
- $payAmount = $payAmount - $good['goods_sales_price'];
|
|
|
|
- $diyongAmount += $good['goods_sales_price'];
|
|
|
|
- $good['nbr'] = $good['nbr'] - 1;
|
|
|
|
- } elseif (ceil($good['nbr']) == 1) {
|
|
|
|
- $payAmount = $payAmount - ($good['goods_sales_price'] * $good['nbr']);
|
|
|
|
- $diyongAmount = $diyongAmount + ($good['goods_sales_price'] * $good['nbr']);
|
|
|
|
- $good['nbr'] = 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // json记录
|
|
|
|
- $discountData[$couponId] = [
|
|
|
|
- 'coupon_id' => $couponId,
|
|
|
|
- 'coupon_value' => $diyongAmount,
|
|
|
|
- 'coupon_classify' => $couponDetail->coupon_classify,
|
|
|
|
- 'coupon_detail_id' => array_unique($useDetailIds)
|
|
|
|
- ];
|
|
|
|
- Redis::set($cacheDiscountKey, json_encode($discountData,JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
|
|
+ CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
|
|
+ if ($good['nbr'] > 1) {
|
|
|
|
+ $diyongAmount = $good['goods_sales_price'];
|
|
|
|
+ $payAmount = $payAmount - $diyongAmount;
|
|
|
|
+ } elseif (ceil($good['nbr']) == 1) {
|
|
|
|
+ $diyongAmount = round($good['goods_sales_price'] * $good['nbr'], 2);
|
|
|
|
+ $payAmount = $payAmount - $diyongAmount;
|
|
|
|
+ }
|
|
|
|
+ // json记录
|
|
|
|
+ $discountData[$couponId] = [
|
|
|
|
+ 'coupon_id' => $couponId,
|
|
|
|
+ 'coupon_value' => $diyongAmount,
|
|
|
|
+ 'coupon_classify' => $couponDetail->coupon_classify,
|
|
|
|
+ 'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
|
|
+ ];
|
|
|
|
+ Redis::set($cacheDiscountKey, json_encode($discountData, JSON_UNESCAPED_UNICODE));
|
|
} elseif ($couponDetail->coupon_classify == '福利券') {
|
|
} elseif ($couponDetail->coupon_classify == '福利券') {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
- if (!Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- Redis::sAdd($cacheKey, $couponId);
|
|
|
|
- CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
|
|
- $welfareBalance = $couponDetail->coupon_value;
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
|
|
+ CouponDetail::where('coupon_detail_id', $couponDetail->coupon_detail_id)->update(['coupon_detail_status' => 'USED']);
|
|
$fuliAmount = 0;
|
|
$fuliAmount = 0;
|
|
- if (!empty($discountData[$couponId]['coupon_value'])) {
|
|
|
|
- $fuliAmount = $discountData[$couponId]['coupon_value'];
|
|
|
|
|
|
+ if (!empty($couponDetail->coupon_value)) {
|
|
|
|
+ $fuliAmount = $couponDetail->coupon_value;
|
|
}
|
|
}
|
|
- if ($welfareBalance >= $money) {
|
|
|
|
- $payAmount = $payAmount - $money;
|
|
|
|
- $welfareBalance = $welfareBalance - $money;
|
|
|
|
- $fuliAmount += $money;
|
|
|
|
- } else {
|
|
|
|
- $fuliAmount += $welfareBalance;
|
|
|
|
- $payAmount = $payAmount - $welfareBalance;
|
|
|
|
- $welfareBalance = 0;
|
|
|
|
|
|
+
|
|
|
|
+ if ($fuliAmount >= $countAndAmount['amount']) {
|
|
|
|
+ $preferentialAmount = $countAndAmount['amount'];
|
|
|
|
+ }else{
|
|
|
|
+ $preferentialAmount = $fuliAmount;
|
|
}
|
|
}
|
|
|
|
+ $payAmount = $payAmount - $preferentialAmount;
|
|
|
|
+
|
|
// json记录
|
|
// json记录
|
|
$discountData[$couponId] = [
|
|
$discountData[$couponId] = [
|
|
'coupon_id' => $couponId,
|
|
'coupon_id' => $couponId,
|
|
- 'coupon_value' => $fuliAmount,
|
|
|
|
|
|
+ 'coupon_value' => $preferentialAmount,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
];
|
|
];
|
|
- Redis::set($cacheDiscountKey, json_encode($discountData,JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
+ Redis::set($cacheDiscountKey, json_encode($discountData, JSON_UNESCAPED_UNICODE));
|
|
} elseif (in_array($couponDetail->coupon_classify, ['年卡', '季卡', '月卡'])) {
|
|
} elseif (in_array($couponDetail->coupon_classify, ['年卡', '季卡', '月卡'])) {
|
|
if (Redis::sIsMember($cacheKey, $couponId) || Redis::sIsMember($cacheKey, $goodsId)) {
|
|
if (Redis::sIsMember($cacheKey, $couponId) || Redis::sIsMember($cacheKey, $goodsId)) {
|
|
continue;
|
|
continue;
|
|
@@ -670,7 +615,7 @@ class OrderService
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_classify' => $couponDetail->coupon_classify,
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
'coupon_detail_id' => [$couponDetail->coupon_detail_id]
|
|
];
|
|
];
|
|
- Redis::set($cacheDiscountKey, json_encode($discountData,JSON_UNESCAPED_UNICODE));
|
|
|
|
|
|
+ Redis::set($cacheDiscountKey, json_encode($discountData, JSON_UNESCAPED_UNICODE));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -679,11 +624,13 @@ class OrderService
|
|
}
|
|
}
|
|
$amountBalance = [
|
|
$amountBalance = [
|
|
'pay_amount' => round($payAmount, 2),
|
|
'pay_amount' => round($payAmount, 2),
|
|
- 'welfare_balance' => $welfareBalance,
|
|
|
|
- 'cut_balance' => $cutBalance
|
|
|
|
|
|
+ 'welfare_balance' => 0,
|
|
|
|
+ 'cut_balance' => 0
|
|
];
|
|
];
|
|
return $amountBalance;
|
|
return $amountBalance;
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
|
+ Redis::del("ORDER:USE:COUPON:" . $memberId);
|
|
|
|
+ Redis::del("ORDER:USE:COUPON:DISCOUNT:" . $memberId);
|
|
dump($e->getTrace());
|
|
dump($e->getTrace());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -717,6 +664,7 @@ class OrderService
|
|
->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
->where('join_goods_coupon_id', $couponId)
|
|
->where('join_goods_coupon_id', $couponId)
|
|
->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
|
|
+ ->where('coupon_detail.coupon_detail_status', 'ACTIVED')
|
|
->first();
|
|
->first();
|
|
if (!$couponDetail) {
|
|
if (!$couponDetail) {
|
|
continue;
|
|
continue;
|
|
@@ -728,84 +676,49 @@ class OrderService
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if (in_array($couponDetail->coupon_classify, ['立减券', '满减券'])) {
|
|
if (in_array($couponDetail->coupon_classify, ['立减券', '满减券'])) {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
- if (!Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
- Redis::sAdd($cacheKey, $couponId);
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- $cutBalance = $couponDetail->coupon_value;
|
|
|
|
- }
|
|
|
|
- if ($cutBalance - $money >= 0) {
|
|
|
|
- $payAmount = $payAmount - $money;
|
|
|
|
- $cutBalance = $cutBalance - $money;
|
|
|
|
- } elseif ($cutBalance != 0 && $cutBalance - $money < 0) {
|
|
|
|
- $payAmount = $payAmount - $cutBalance;
|
|
|
|
- $cutBalance = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ $payAmount = $payAmount - $couponDetail->coupon_value;
|
|
}
|
|
}
|
|
} elseif ($couponDetail->coupon_classify == '折扣券') {
|
|
} elseif ($couponDetail->coupon_classify == '折扣券') {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
- $payAmount = $payAmount - ($money * (100 - $couponDetail->coupon_value) / 100);
|
|
|
|
|
|
+ $zhekouAmount = round($countAndAmount['amount'] * (100 - $couponDetail->coupon_value) / 100, 2);
|
|
|
|
+ $payAmount = $payAmount - $zhekouAmount;
|
|
}
|
|
}
|
|
} elseif (in_array($couponDetail->coupon_classify, ['抵用券', '赠品券'])) {
|
|
} elseif (in_array($couponDetail->coupon_classify, ['抵用券', '赠品券'])) {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
- if ($couponDetail->coupon_category == 'PIECE' || ($couponDetail->coupon_category == 'NORMAL' && $countAndAmount['amount'] >= $couponDetail->coupon_minimum_limit)) {
|
|
|
|
- $diyongCouponDetailIds = CouponDetail::leftJoin('coupon_goods', 'coupon_goods.join_goods_coupon_id', '=', 'coupon_detail.join_detail_coupon_id')
|
|
|
|
- ->where('join_detail_coupon_id', $couponId)
|
|
|
|
- ->where('coupon_goods.join_coupon_goods_id', $goodsId)
|
|
|
|
- ->where('coupon_goods.join_coupon_goods_sku_id', $good['sku_id'])
|
|
|
|
- ->where('coupon_detail_status', 'ACTIVED')
|
|
|
|
- ->where('coupon_detail.join_coupon_detail_member_id', $memberId)
|
|
|
|
- ->pluck('coupon_detail_id')
|
|
|
|
- ->toArray();
|
|
|
|
- $couponDetailsIds = Redis::sMembers($cacheKey);
|
|
|
|
- foreach ($diyongCouponDetailIds as $key => $detailId) {
|
|
|
|
- if (in_array($detailId, $couponDetailsIds)) {
|
|
|
|
- unset($diyongCouponDetailIds[$key]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (count($diyongCouponDetailIds) > $good['nbr']) {
|
|
|
|
- $diyongCouponDetailIds = array_slice($diyongCouponDetailIds, 0, ceil($good['nbr']));
|
|
|
|
- }
|
|
|
|
- foreach ($diyongCouponDetailIds as $detailId) {
|
|
|
|
- // 是否计算过了
|
|
|
|
- if (!Redis::sIsMember($cacheKey, $detailId)) {
|
|
|
|
- Redis::sAdd($cacheKey, $detailId);
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- if ($good['nbr'] > 1) {
|
|
|
|
- $payAmount = $payAmount - $good['goods_sales_price'];
|
|
|
|
- $good['nbr'] = $good['nbr'] - 1;
|
|
|
|
- } elseif (ceil($good['nbr']) == 1) {
|
|
|
|
- $payAmount = $payAmount - ($good['goods_sales_price'] * $good['nbr']);
|
|
|
|
- $good['nbr'] = 0;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
|
|
+ if ($good['nbr'] > 1) {
|
|
|
|
+ $diyongAmount = $good['goods_sales_price'];
|
|
|
|
+ $payAmount = $payAmount - $diyongAmount;
|
|
|
|
+ } elseif (ceil($good['nbr']) == 1) {
|
|
|
|
+ $diyongAmount = round($good['goods_sales_price'] * $good['nbr'], 2);
|
|
|
|
+ $payAmount = $payAmount - $diyongAmount;
|
|
}
|
|
}
|
|
} elseif ($couponDetail->coupon_classify == '福利券') {
|
|
} elseif ($couponDetail->coupon_classify == '福利券') {
|
|
-// if (Redis::sIsMember($cacheKey, $goodsId)) {
|
|
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
- if (!Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
- Redis::sAdd($cacheKey, $couponId);
|
|
|
|
-// Redis::sAdd($cacheKey, $goodsId);
|
|
|
|
- $welfareBalance = $couponDetail->coupon_value;
|
|
|
|
|
|
+ if (Redis::sIsMember($cacheKey, $couponId)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
- if ($welfareBalance >= $money) {
|
|
|
|
- $payAmount = $payAmount - $money;
|
|
|
|
- $welfareBalance = $welfareBalance - $money;
|
|
|
|
- } else {
|
|
|
|
- $payAmount = $payAmount - $welfareBalance;
|
|
|
|
- $welfareBalance = 0;
|
|
|
|
|
|
+ Redis::sAdd($cacheKey, $couponId);
|
|
|
|
+ $fuliAmount = 0;
|
|
|
|
+ if (!empty($couponDetail->coupon_value)) {
|
|
|
|
+ $fuliAmount = $couponDetail->coupon_value;
|
|
|
|
+ }
|
|
|
|
+ if ($fuliAmount >= $countAndAmount['amount']) {
|
|
|
|
+ $preferentialAmount = $countAndAmount['amount'];
|
|
|
|
+ }else{
|
|
|
|
+ $preferentialAmount = $fuliAmount;
|
|
}
|
|
}
|
|
|
|
+ $payAmount = $payAmount - $preferentialAmount;
|
|
} elseif (in_array($couponDetail->coupon_classify, ['年卡', '季卡', '月卡'])) {
|
|
} elseif (in_array($couponDetail->coupon_classify, ['年卡', '季卡', '月卡'])) {
|
|
if (Redis::sIsMember($cacheKey, $couponId) || Redis::sIsMember($cacheKey, $goodsId)) {
|
|
if (Redis::sIsMember($cacheKey, $couponId) || Redis::sIsMember($cacheKey, $goodsId)) {
|
|
continue;
|
|
continue;
|
|
@@ -831,6 +744,8 @@ class OrderService
|
|
];
|
|
];
|
|
return $amountBalance;
|
|
return $amountBalance;
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
|
+ Redis::del("ORDER:USE:COUPON:" . $memberId);
|
|
|
|
+ Redis::del("ORDER:USE:COUPON:DISCOUNT:" . $memberId);
|
|
dump($e->getTrace());
|
|
dump($e->getTrace());
|
|
}
|
|
}
|
|
}
|
|
}
|