|
|
@@ -80,26 +80,17 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
$goodsPrice = $unitPrice * $goodsNum;
|
|
|
$prePrice = stringUtil::calcAdd($sendCost, $goodsPrice);
|
|
|
- $actPrice = $prePrice;
|
|
|
$showPrice = $prePrice;
|
|
|
-
|
|
|
- //计算优惠金额
|
|
|
- $couponId = isset($post['couponId']) && !empty($post['couponId']) ? $post['couponId'] : 0;
|
|
|
- //没有使用优惠券,默认使用会员优惠
|
|
|
- if (empty($couponId)) {
|
|
|
- $discountInfo = UserAssetService::getDiscount($this->userId);
|
|
|
- if (isset($discountInfo['member'])) {
|
|
|
- $discount = $discountInfo['member']['discount'];
|
|
|
- $actPrice = ($actPrice * ($discount * 10000)) / 10000;
|
|
|
- $showPrice = $actPrice;
|
|
|
- }
|
|
|
- } else {
|
|
|
- //验证优惠券有效性
|
|
|
- $discountAmount = CouponService::valid($couponId, $actPrice, $this->userId);
|
|
|
- //优惠券在支付成功后变更状态
|
|
|
- $showPrice = stringUtil::calcSub($actPrice, $discountAmount);
|
|
|
+ $sourceType = $this->isWx ? 0 : 1;
|
|
|
+ if (httpUtil::isMiniProgram()) {
|
|
|
+ $sourceType = 2;
|
|
|
}
|
|
|
-
|
|
|
+ $couponId = isset($post['couponId']) && !empty($post['couponId']) ? $post['couponId'] : 0;
|
|
|
+ $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => $sourceType, 'couponId' => $couponId, 'userId' => $this->userId]);
|
|
|
+ $actPrice = $discountData['price'];
|
|
|
+ $post['discountType'] = $discountData['discountType'];
|
|
|
+ $post['discountAmount'] = $discountData['discountAmount'];
|
|
|
+
|
|
|
$now = time();
|
|
|
$expireTime = $now + 1800;//订单30分钟后过期
|
|
|
$post['deadline'] = $expireTime;
|
|
|
@@ -243,7 +234,12 @@ class OrderController extends BaseController
|
|
|
$shopInfo = ShopService::getById($shopId);
|
|
|
ShopService::valid($shopInfo, $this->merchantId);
|
|
|
//来源 0微信 1支付宝 2小程序 3朋友圈 4美团
|
|
|
- $sourceType = 3;
|
|
|
+ $sourceType = $this->isWx ? 0 : 1;
|
|
|
+ if (httpUtil::isMiniProgram()) {
|
|
|
+ $sourceType = 2;
|
|
|
+ }
|
|
|
+ $sourceType = isset($post['sourceType']) ? $post['source'] : 0;
|
|
|
+
|
|
|
$post['userId'] = $this->userId;
|
|
|
$prePrice = round($post['prePrice'], 2);
|
|
|
$couponId = isset($post['couponId']) ? $post['couponId'] : 0;
|