Bladeren bron

会员升级

Kirin 1 jaar geleden
bovenliggende
commit
8fe0eaf52b

+ 15 - 0
app/controller/api/v1/user/UserAwardIntegralController.php

@@ -0,0 +1,15 @@
+<?php
+/**
+ * @Created by PhpStorm
+ * @author: Kirin
+ * @day: 2023/12/1
+ * @time: 15:27
+ */
+
+namespace app\controller\api\v1\user;
+
+
+class UserAwardIntegralController
+{
+
+}

+ 34 - 24
app/services/order/StoreOrderCreateServices.php

@@ -227,6 +227,16 @@ class StoreOrderCreateServices extends BaseServices
             'give_coupon' => implode(',', $promotions_give['give_coupon'] ?? []),
             'store_id' => $storeId
         ];
+        if ($orderInfo['total_price'] > sys_config('max_price', 0) && sys_config('max_price', 0) > 0) {
+            throw new ValidateException('下单金额不超过' . sys_config('max_price'));
+        }
+        if ($orderInfo['total_price'] < sys_config('min_price', 0) && sys_config('min_price', 0) > 0) {
+            throw new ValidateException('下单金额不低于' . sys_config('max_price'));
+        }
+        $orderPre = $this->dao->search(['uid' => $uid])->order('add_time', 'desc')->find();
+        if ($orderPre && $orderPre['add_time'] > (time() - (sys_config('order_time', 0) * 60))) {
+            throw new ValidateException('请等待' . ((sys_config('order_time', 0) * 60) - (time() - $orderPre['add_time'])) . '秒后再下单');
+        }
         if ($userInfo['user_type'] == 'wechat' || $userInfo['user_type'] == 'routine') {
             /** @var WechatUserServices $wechatServices */
             $wechatServices = app()->make(WechatUserServices::class);
@@ -346,10 +356,10 @@ class StoreOrderCreateServices extends BaseServices
                 switch ($type) {
                     case 0://普通
                     case 6://预售
-					case 8://抽奖
-					case 9://拼单
-					case 10://桌码
-						$res5 = $res5 && $services->decProductStock($cart_num, (int)$cart['productInfo']['id'], $unique, $store_id);
+                    case 8://抽奖
+                    case 9://拼单
+                    case 10://桌码
+                        $res5 = $res5 && $services->decProductStock($cart_num, (int)$cart['productInfo']['id'], $unique, $store_id);
                         break;
                     case 1://秒杀
                         $res5 = $res5 && $seckillServices->decSeckillStock($cart_num, $activity_id, $unique, $store_id);
@@ -367,7 +377,7 @@ class StoreOrderCreateServices extends BaseServices
                         $res5 = $res5 && $storeNewcomerServices->decNewcomerStock($cart_num, $activity_id, $unique, $store_id);
                         break;
                     default:
-						$res5 = $res5 && $services->decProductStock($cart_num, (int)$cart['productInfo']['id'], $unique, $store_id);
+                        $res5 = $res5 && $services->decProductStock($cart_num, (int)$cart['productInfo']['id'], $unique, $store_id);
                         break;
                 }
             }
@@ -427,9 +437,9 @@ class StoreOrderCreateServices extends BaseServices
         foreach ($cartInfo as &$cart) {
             $cart['use_integral'] = 0;
             $cart['integral_price'] = 0.00;
-			if (!isset($cart['coupon_price'])) {
-				$cart['coupon_price'] = 0.00;
-			}
+            if (!isset($cart['coupon_price'])) {
+                $cart['coupon_price'] = 0.00;
+            }
             $cart['first_order_price'] = 0.00;
             $cart['one_brokerage'] = 0.00;
             $cart['two_brokerage'] = 0.00;
@@ -663,14 +673,14 @@ class StoreOrderCreateServices extends BaseServices
             $couponServices = app()->make(StoreCouponUserServices::class);
             $couponInfo = $couponServices->getOne(['id' => $priceData['coupon_id']], '*', ['issue']);
             if ($couponInfo) {
-				//验证是否适用门店
-				if ($store_id && isset($couponInfo['applicable_type']) && isset($couponInfo['applicable_store_id'])) {
-					$applicable_store_id = is_array($couponInfo['applicable_store_id']) ? $couponInfo['applicable_store_id'] : explode(',', $couponInfo['applicable_store_id']);
-					//活动不适用该门店
-					if ($couponInfo['applicable_type'] == 0 || ($couponInfo['applicable_type'] == 2 && !in_array($store_id, $applicable_store_id))) {
-						return [[], 0];
-					}
-				}
+                //验证是否适用门店
+                if ($store_id && isset($couponInfo['applicable_type']) && isset($couponInfo['applicable_store_id'])) {
+                    $applicable_store_id = is_array($couponInfo['applicable_store_id']) ? $couponInfo['applicable_store_id'] : explode(',', $couponInfo['applicable_store_id']);
+                    //活动不适用该门店
+                    if ($couponInfo['applicable_type'] == 0 || ($couponInfo['applicable_type'] == 2 && !in_array($store_id, $applicable_store_id))) {
+                        return [[], 0];
+                    }
+                }
                 $promotionsList = [];
                 if ($promotions) {
                     $promotionsList = array_combine(array_column($promotions, 'id'), $promotions);
@@ -708,8 +718,8 @@ class StoreOrderCreateServices extends BaseServices
                             $count++;
                         }
                         foreach ($cartInfo as &$cart) {
-							$cart['coupon_id'] = 0;
-							$cart['coupon_price'] = 0;
+                            $cart['coupon_id'] = 0;
+                            $cart['coupon_price'] = 0;
                             if (!$isOverlay($cart) || (isset($cart['is_gift']) && $cart['is_gift'] == 1)) continue;
                             if ($count > 1) {
                                 $coupon_price = bcmul((string)bcdiv((string)bcmul((string)$cart['cart_num'], (string)$cart['truePrice'], 4), (string)$total_price, 4), (string)$priceData['coupon_price'], 2);
@@ -736,8 +746,8 @@ class StoreOrderCreateServices extends BaseServices
                                 }
                             }
                             foreach ($cartInfo as &$cart) {
-								$cart['coupon_id'] = 0;
-								$cart['coupon_price'] = 0;
+                                $cart['coupon_id'] = 0;
+                                $cart['coupon_price'] = 0;
                                 if (!$isOverlay($cart) || (isset($cart['is_gift']) && $cart['is_gift'] == 1)) continue;
                                 if (isset($cart['productInfo']['cate_id']) && array_intersect(explode(',', $cart['productInfo']['cate_id']), $cateIds)) {
                                     if ($count > 1) {
@@ -764,8 +774,8 @@ class StoreOrderCreateServices extends BaseServices
 
                         }
                         foreach ($cartInfo as &$cart) {
-							$cart['coupon_id'] = 0;
-							$cart['coupon_price'] = 0;
+                            $cart['coupon_id'] = 0;
+                            $cart['coupon_price'] = 0;
                             if (!$isOverlay($cart) || (isset($cart['is_gift']) && $cart['is_gift'] == 1)) continue;
                             $product_id = isset($cart['productInfo']['pid']) && $cart['productInfo']['pid'] ? $cart['productInfo']['pid'] : ($cart['product_id'] ?? 0);
                             if ($product_id && in_array($product_id, explode(',', $couponInfo['product_id']))) {
@@ -795,8 +805,8 @@ class StoreOrderCreateServices extends BaseServices
                                 }
                             }
                             foreach ($cartInfo as &$cart) {
-								$cart['coupon_id'] = 0;
-								$cart['coupon_price'] = 0;
+                                $cart['coupon_id'] = 0;
+                                $cart['coupon_price'] = 0;
                                 if (!$isOverlay($cart) || (isset($cart['is_gift']) && $cart['is_gift'] == 1)) continue;
                                 if (isset($cart['productInfo']['brand_id']) && in_array($cart['productInfo']['brand_id'], $brandIds)) {
                                     if ($count > 1) {