From 0afaadb797907f918dfbd1ab1edb42b3e4c98d03 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 27 Feb 2024 09:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=A7=E7=A4=BC=E5=8C=85?= =?UTF-8?q?=E9=99=90=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderCreateRepository.php | 26 ++++++++++++++++++- .../system/merchant/MerchantIntention.php | 2 +- .../api/store/product/StoreProductPresell.php | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 2868acdc..2e8e6662 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -3,6 +3,9 @@ namespace app\common\repositories\store\order; use app\common\dao\store\coupon\StoreCouponUserDao; +use app\common\model\store\order\StoreOrder; +use app\common\model\store\product\ProductCate; +use app\common\model\system\merchant\Merchant; use app\common\repositories\system\form\FormRepository; use app\common\repositories\system\RecordRepository; use crmeb\jobs\SendSmsJob; @@ -100,6 +103,27 @@ class StoreOrderCreateRepository extends StoreOrderRepository } $product_cart = []; + //大礼包限购 + $isPlatformCard = $merchantCart['list'][0]['product']->isPlatformCard(); + if ($isPlatformCard) { + $merchantTypeId = Merchant::where('uid', $uid)->value('type_id'); + if (empty($merchantTypeId) || $merchantTypeId != 21) { + throw new ValidateException('大礼包仅限种养殖户购买'); + } + //平台购物卡仅能购买一次 + $productIds = ProductCate::where('mer_cate_id', env('PLATFORM_CARD_CATE_ID'))->column('product_id'); + $orderRecord = StoreOrder::alias('t1') + ->leftJoin('store_order_product t2', 't1.order_id = t2.order_id') + ->whereIn('product_id', $productIds) + ->where('t1.uid', $uid) + ->where('paid', 1) + ->where('is_refund', 0) + ->count(); + if ($orderRecord > 0) { + throw new ValidateException('大礼包仅能购买一次'); + } + } + foreach ($merchantCart['list'] as $k => $cart) { //获取订单商品支持的配送类型 if ($cart['product']['delivery_way']) { @@ -144,7 +168,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository if ($presellType == 2) $down_price = bcadd($down_price, bcmul($cart['cart_num'], $cart['productPresellAttr']['down_price'], 2), 2); } - if ($cart['product']['type'] == 1 && !$cart['product']->isPlatformCard()) { + if ($cart['product']['type'] == 1 && $isPlatformCard) { $enabledPlatformCoupon = false; $enabledCoupon = false; } diff --git a/app/controller/admin/system/merchant/MerchantIntention.php b/app/controller/admin/system/merchant/MerchantIntention.php index c7312c9a..9b2109ac 100644 --- a/app/controller/admin/system/merchant/MerchantIntention.php +++ b/app/controller/admin/system/merchant/MerchantIntention.php @@ -38,7 +38,7 @@ class MerchantIntention extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']); + $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id', 'type']); return app('json')->success($this->repository->getList($where, $page, $limit)); } diff --git a/app/controller/api/store/product/StoreProductPresell.php b/app/controller/api/store/product/StoreProductPresell.php index 291cdc18..77465157 100644 --- a/app/controller/api/store/product/StoreProductPresell.php +++ b/app/controller/api/store/product/StoreProductPresell.php @@ -37,7 +37,7 @@ class StoreProductPresell extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $where = $this->request->params([['type',4],'star','mer_id']); + $where = $this->request->params([['type',4],'star','mer_id', 'keyword']); return app('json')->success($this->repository->getApiList($where,$page, $limit)); }