From 6bcdc0f09d9d4dcf5bc60815ab12fdc9bc8b5da1 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 15 Mar 2024 11:15:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/user/User.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index d2f5084d..54f83a89 100644 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -553,9 +553,10 @@ class User extends BaseController public function merchantRecord() { [$page, $limit] = $this->getPage(); - $userIds = UserModel::where('spread_uid', $this->user->uid)->page($page, $limit)->column('uid'); - $query = Merchant::whereIn('uid', $userIds)->where('is_del', 0); - $merchants = $query->page($page, $limit) + $userQuery = UserModel::where('spread_uid', $this->user->uid); + $count = $userQuery->count(); + $userIds = $userQuery->page($page, $limit)->column('uid'); + $merchants = Merchant::whereIn('uid', $userIds)->where('is_del', 0) ->field('mer_id,mer_name,uid,real_name,sale_amount,purchase_amount as buy_amount') ->select()->toArray(); $merchants = reset_index($merchants, 'uid'); @@ -569,7 +570,7 @@ class User extends BaseController $result[] = ['mer_id' => '', 'mer_name' => '', 'uid' => $userId, 'real_name' => '', 'sale_amount' => '0.00', 'buy_amount' => '0.00', 'status' => 0]; } } - return app('json')->success(['count' => count($userIds), 'list' => $result]); + return app('json')->success(['count' => $count, 'list' => $result]); } /** From b1aea23f76bc0af38d48c7a5271d5f3bfd5bc83a Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 15 Mar 2024 11:22:58 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=80=E6=AC=BE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repositories/store/order/StoreRefundOrderRepository.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/common/repositories/store/order/StoreRefundOrderRepository.php b/app/common/repositories/store/order/StoreRefundOrderRepository.php index 7dc9d787..a8f7c5d6 100644 --- a/app/common/repositories/store/order/StoreRefundOrderRepository.php +++ b/app/common/repositories/store/order/StoreRefundOrderRepository.php @@ -406,6 +406,7 @@ class StoreRefundOrderRepository extends BaseRepository $data['order_id'] = $orderId; $data['uid'] = $uid; $data['mer_id'] = $order->mer_id; + $data['sale_type'] = $order['sale_type']; $data['refund_order_sn'] = app()->make(StoreOrderRepository::class)->getNewOrderId(StoreOrderRepository::TYPE_SN_REFUND); $refund_order_id = 0; foreach ($products as $product) { @@ -605,6 +606,7 @@ class StoreRefundOrderRepository extends BaseRepository $data['integral'] = $totalIntegral; $data['platform_refund_price'] = $totalPlatformRefundPrice; $data['refund_postage'] = $totalPostage; + $data['sale_type'] = $order['sale_type']; return Db::transaction(function () use ($refundProduct, $data, $products, $order, &$refund_order_id) { event('refund.creates.before', compact('data')); @@ -707,6 +709,7 @@ class StoreRefundOrderRepository extends BaseRepository $data['refund_num'] = $num; $data['extension_one'] = $total_extension_one; $data['extension_two'] = $total_extension_two; + $data['sale_type'] = $order['sale_type']; return Db::transaction(function () use ($order, $data, $product, $productId, $num) { event('refund.create.before', compact('data')); From 5198b9542863298d3eeb35c53f02dbc2773f2eb9 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 15 Mar 2024 11:52:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=AD=E7=89=A9?= =?UTF-8?q?=E8=BD=A6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/order/StoreCartDao.php | 5 +++-- app/common/dao/store/product/SpuDao.php | 2 +- .../repositories/store/order/StoreCartRepository.php | 7 ++++--- app/controller/api/store/order/StoreCart.php | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/common/dao/store/order/StoreCartDao.php b/app/common/dao/store/order/StoreCartDao.php index 26944a5f..14876644 100644 --- a/app/common/dao/store/order/StoreCartDao.php +++ b/app/common/dao/store/order/StoreCartDao.php @@ -50,11 +50,12 @@ class StoreCartDao extends BaseDao * @Author:Qinii * @Date: 2020/6/1 * @param int $uid + * @param int $saleType * @return mixed */ - public function getAll(int $uid) + public function getAll(int $uid, int $saleType = 1) { - $query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0]) + $query = ($this->getModel())::where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType]) ->with([ 'product' => function ($query) { $query->field('product_id,image,store_name,is_show,status,is_del,unit_name,price,mer_status,is_used,product_type,once_max_count,once_min_count,pay_limit,mer_svip_status,svip_price_type'); diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index 2537a8f6..bbb10706 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -73,7 +73,7 @@ class SpuDao extends BaseDao $query->whereIn('P.mer_id',$where['mer_ids']); }) ->when(isset($where['sale_type']) && $where['sale_type'] !== '',function($query)use($where){ - $saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY]; + $saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY, Enum::RETAIL_WHOLESALE]; $merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id'); $query->whereIn('P.mer_id', $merIds); }) diff --git a/app/common/repositories/store/order/StoreCartRepository.php b/app/common/repositories/store/order/StoreCartRepository.php index 7604c7e1..4455f21d 100644 --- a/app/common/repositories/store/order/StoreCartRepository.php +++ b/app/common/repositories/store/order/StoreCartRepository.php @@ -46,13 +46,14 @@ class StoreCartRepository extends BaseRepository } /** - * @param $uid + * @param $user + * @param int $saleType * @return array * @author Qinii */ - public function getList($user) + public function getList($user, int $saleType = 1) { - $res = $this->dao->getAll($user->uid)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']); + $res = $this->dao->getAll($user->uid, $saleType)->append(['checkCartProduct', 'UserPayCount', 'ActiveSku','spu']); return $this->checkCartList($res, $user->uid, $user); } diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index 799feba3..3ad1f05a 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -56,7 +56,8 @@ class StoreCart extends BaseController */ public function lst() { - $data = $this->repository->getList($this->request->userInfo()); + $saleType = $this->request->get('sale_type', 1); + $data = $this->repository->getList($this->request->userInfo(), intval($saleType)); return app('json')->success($data); } From fab06892d43fe9445506d9748acbdc01b6fddd79 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 15 Mar 2024 13:39:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/order/StoreCartDao.php | 4 ++-- app/common/dao/store/product/SpuDao.php | 11 +++++++++++ .../repositories/store/product/SpuRepository.php | 2 +- app/controller/api/store/order/StoreCart.php | 3 ++- app/controller/api/store/product/StoreSpu.php | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/common/dao/store/order/StoreCartDao.php b/app/common/dao/store/order/StoreCartDao.php index 14876644..ce62d97e 100644 --- a/app/common/dao/store/order/StoreCartDao.php +++ b/app/common/dao/store/order/StoreCartDao.php @@ -134,9 +134,9 @@ class StoreCartDao extends BaseDao * @return mixed * @author Qinii */ - public function getCartCount(int $uid) + public function getCartCount(int $uid, int $saleType) { - $data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0])->field('SUM(cart_num) as count')->select(); + $data = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0, 'sale_type' => $saleType])->field('SUM(cart_num) as count')->select(); $data[0]['count'] = $data[0]['count'] ? $data[0]['count'] : 0; return $data; } diff --git a/app/common/dao/store/product/SpuDao.php b/app/common/dao/store/product/SpuDao.php index bbb10706..c3447373 100644 --- a/app/common/dao/store/product/SpuDao.php +++ b/app/common/dao/store/product/SpuDao.php @@ -76,6 +76,9 @@ class SpuDao extends BaseDao $saleType = $where['sale_type'] == Enum::SALE_TYPE_RETAIL ? [Enum::RETAIL_ONLY, Enum::RETAIL_WHOLESALE] : [Enum::WHOLESALE_ONLY, Enum::RETAIL_WHOLESALE]; $merIds = Merchant::whereIn('wholesale', $saleType)->column('mer_id'); $query->whereIn('P.mer_id', $merIds); + if ($where['sale_type'] == Enum::SALE_TYPE_WHOLESALE) { + $query->join('StoreProductAttrValue PAV','S.product_id = PAV.product_id', 'left')->where('PAV.wholesale_price', '>', 0); + } }) ->when(isset($where['product_ids']) && $where['product_ids'] !== '',function($query)use($where){ $query->whereIn('P.product_id',$where['product_ids']); @@ -112,6 +115,14 @@ class SpuDao extends BaseDao $query->whereIn('P.mer_id',$merId); }) + ->when(isset($where['mer_type']) && $where['mer_type'] !== '',function($query)use($where){ + $merId = Merchant::where('type_id', 22)->value('mer_id'); + if ($where['mer_type'] == 1) { + $query->where('P.mer_id', $merId); + } elseif ($where['mer_type'] == 2) { + $query->where('P.mer_id', '<>', $merId); + } + }) ->when(isset($where['cate_pid']) && $where['cate_pid'], function ($query) use ($where) { $storeCategoryRepository = app()->make(StoreCategoryRepository::class); if (is_array($where['cate_pid'])) { diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index b020df56..25ad3a6a 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -34,7 +34,7 @@ class SpuRepository extends BaseRepository { public $dao; public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id'; - public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,stock,mer_svip_status'; + public $productFiled = 'P.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,P.sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,S.ot_price,svip_price_type,P.stock,mer_svip_status'; public function __construct(SpuDao $dao) { $this->dao = $dao; diff --git a/app/controller/api/store/order/StoreCart.php b/app/controller/api/store/order/StoreCart.php index 3ad1f05a..b15fa47c 100644 --- a/app/controller/api/store/order/StoreCart.php +++ b/app/controller/api/store/order/StoreCart.php @@ -173,7 +173,8 @@ class StoreCart extends BaseController */ public function cartCount() { - return app('json')->success($this->repository->getCartCount($this->request->uid())); + $saleType = $this->request->get('sale_type', 1); + return app('json')->success($this->repository->getCartCount($this->request->uid()), intval($saleType)); } /** diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index e52f3f87..b2787d7a 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -67,6 +67,7 @@ class StoreSpu extends BaseController 'type_code', 'category_id', 'label_name', + 'mer_type', ]); if ($where['type_id'] || $where['type_code']) { $query = Merchant::where(['status' => 1, 'mer_state' => 1, 'is_del' => 0]);