From 4ae8ae8a6e1589943623e07b93fc7ebce362d7d4 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Wed, 10 Apr 2024 18:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=EF=BC=9A=E6=8F=90=E8=B4=A7?= =?UTF-8?q?=E7=82=B9=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/store/PointDao.php | 37 ++++++++ app/common/model/store/Point.php | 33 +++++++ app/common/model/system/merchant/Merchant.php | 15 ++-- .../repositories/store/PointRepository.php | 85 +++++++++++++++++++ .../store/order/StoreCartRepository.php | 9 +- .../order/StoreOrderCreateRepository.php | 11 ++- .../store/product/ProductRepository.php | 12 ++- app/controller/admin/store/Point.php | 70 +++++++++++++++ app/controller/admin/store/StoreProduct.php | 5 +- route/admin/product.php | 9 ++ 10 files changed, 266 insertions(+), 20 deletions(-) create mode 100644 app/common/dao/store/PointDao.php create mode 100644 app/common/model/store/Point.php create mode 100644 app/common/repositories/store/PointRepository.php create mode 100644 app/controller/admin/store/Point.php diff --git a/app/common/dao/store/PointDao.php b/app/common/dao/store/PointDao.php new file mode 100644 index 0000000..a83027d --- /dev/null +++ b/app/common/dao/store/PointDao.php @@ -0,0 +1,37 @@ +where('is_del', 0) + ->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){ + $query->where('id', (int)$params['id']); + }) + ->when(isset($params['mer_take_name']) && $params['mer_take_name'] !== '',function($query) use ($params){ + $query->where('mer_take_name', 'like', "%{$params['mer_take_name']}%"); + }) + ->order('create_time DESC,id DESC'); + } + + + + + +} diff --git a/app/common/model/store/Point.php b/app/common/model/store/Point.php new file mode 100644 index 0000000..045521a --- /dev/null +++ b/app/common/model/store/Point.php @@ -0,0 +1,33 @@ +mer_id ?? 0; //0 支持在线聊天 1 支持电话 -1 暂无客服 - $services_type = merchantConfig($this->mer_id,'services_type'); + $services_type = merchantConfig($merId,'services_type'); if ($services_type) { if (!$this->service_phone) $services_type = -1; } else { $services_type = 0; - $where = ['mer_id' => $this->mer_id, 'is_open' => 1,'status' => 1]; + $where = ['mer_id' => $merId, 'is_open' => 1,'status' => 1]; $service = StoreService::where($where)->count(); if (!$service) $services_type = -1; } @@ -236,9 +236,10 @@ class Merchant extends BaseModel return merchantConfig($this->mer_id, 'mer_certificate'); } - public function getIssetCertificateAttr() - { - return count(merchantConfig($this->mer_id, 'mer_certificate') ?: []) > 0; + public function getIssetCertificateAttr(){ + $merId = $this->mer_id ?? 0; + + return count(merchantConfig((int)$merId, 'mer_certificate') ?: []) > 0; } public function getMarginRemindStatusAttr() diff --git a/app/common/repositories/store/PointRepository.php b/app/common/repositories/store/PointRepository.php new file mode 100644 index 0000000..021a90a --- /dev/null +++ b/app/common/repositories/store/PointRepository.php @@ -0,0 +1,85 @@ +dao = $dao; + } + /** + * Common: 公共搜索模型 + * Author: wu-hui + * Time: 2024/04/10 18:15 + * @param $search + * @return \app\common\model\store\Point + */ + public function getSearchModel($search){ + return $this->dao->searchList($search); + } + /** + * Common: 列表获取 + * Author: wu-hui + * Time: 2024/04/10 18:18 + * @param array $params + * @param int $page + * @param int $limit + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getList(array $params,int $page,int $limit):array{ + $query = $this->dao->searchList($params); + $count = $query->count(); + $list = $query->page($page,$limit)->select()->toArray(); + + return compact('count','list'); + } + /** + * Common: 添加 / 编辑 + * Author: wu-hui + * Time: 2024/04/10 18:17 + * @param $params + * @throws \think\db\exception\DbException + */ + public function editInfo($params){ + $data = [ + "mer_id" => $params['mer_id'], + "mer_take_name" => $params['mer_take_name'], + "mer_take_phone" => $params['mer_take_phone'], + "mer_take_location" => implode(',',$params['mer_take_location']), + "mer_take_address" => $params['mer_take_address'], + "mer_take_day" => implode(',',$params['mer_take_day']), + "mer_take_time" => implode(',',$params['mer_take_time']) + ]; + // 判断:是否符合条件 + if(empty($params['mer_take_name'])) throw new ValidateException('请输入提货点名称'); + if(empty($params['mer_take_phone'])) throw new ValidateException('请输入提货点手机号'); + if(empty($params['mer_take_location'])) throw new ValidateException('请选择经纬度'); + if(empty($params['mer_take_address'])) throw new ValidateException('请输入提货点详细地址'); + if(empty($params['mer_take_day'])) throw new ValidateException('请选择营业日期'); + if(empty($params['mer_take_time'])) throw new ValidateException('请选择营业时间'); + // 判断:是否已经存在 + $isHas = $this->getSearchModel([]) + ->where('mer_take_name',$params['mer_take_name']) + ->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){ + $query->where('id','<>',(int)$params['id']); + })->value('id'); + if($isHas > 0) throw new ValidateException('提货点已经存在'); + // 操作 + if((int)$params['id'] > 0) $this->dao->update((int)$params['id'], $data);// 编辑 + else $this->dao->create($data);// 添加 + } + + + + + + + +} diff --git a/app/common/repositories/store/order/StoreCartRepository.php b/app/common/repositories/store/order/StoreCartRepository.php index c128f12..efa5682 100644 --- a/app/common/repositories/store/order/StoreCartRepository.php +++ b/app/common/repositories/store/order/StoreCartRepository.php @@ -62,13 +62,16 @@ class StoreCartRepository extends BaseRepository if ($item['merchant']){ $merchantData = $item['merchant']->append(['openReceipt'])->toArray(); } else { - $merchantData = ['mer_id' => 0]; + $merchantData = [ + 'mer_id' => 0, + 'delivery_way' => [1,2] + ]; } + unset($item['merchant']); $coupon_make = app()->make(StoreCouponRepository::class); if (!isset($arr[$item['mer_id']])) { - if ($hasCoupon) - $merchantData['hasCoupon'] = $coupon_make->validMerCouponExists($item['mer_id'], $hasCoupon); + if ($hasCoupon) $merchantData['hasCoupon'] = $coupon_make->validMerCouponExists($item['mer_id'], $hasCoupon); $arr[$item['mer_id']] = $merchantData; } if ($hasCoupon && !$arr[$item['mer_id']]['hasCoupon']) { diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 404da96..8f5dcf7 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -130,6 +130,12 @@ class StoreOrderCreateRepository extends StoreOrderRepository{ $order_svip_discount = 0; // 循环计算每个店铺的订单数据 foreach($merchantCartList as &$merchantCart){ + // 数据补齐 + if(!in_array('coupon', array_keys($merchantCart))) $merchantCart['coupon'] = []; + if(!in_array('config', array_keys($merchantCart))) $merchantCart['config'] = []; + + + // 其他参数 $postageRule = []; $total_price = 0; $total_num = 0; @@ -957,9 +963,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository{ // $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); $orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key); - if(!$orderInfo){ - throw new ValidateException('订单操作超时,请刷新页面'); - } + if(!$orderInfo) throw new ValidateException('订单操作超时,请刷新页面'); + $order_model = $orderInfo['order_model']; $order_extend = $orderInfo['order_extend']; if(!$orderInfo['order_delivery_status']){ diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index fee3a9a..6581800 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -1296,9 +1296,12 @@ class ProductRepository extends BaseRepository $merchantRepository = app()->make(MerchantRepository::class); $care = false; if ($uid) $care = $merchantRepository->getCareByUser($merId, $uid); - $merchant = $merchantRepository->search(['mer_id' => $merId])->with(['type_name']) - ->field('mer_id,mer_name,real_name,mer_address,mer_keyword,mer_avatar,mer_banner,mini_banner,product_score,service_score,postage_score,service_phone,care_count,type_id')->find() - ->append(['isset_certificate','services_type'])->toArray(); + $merchant = $merchantRepository->search(['mer_id' => $merId]) + ->with(['type_name']) + ->field('mer_id,mer_name,real_name,mer_address,mer_keyword,mer_avatar,mer_banner,mini_banner,product_score,service_score,postage_score,service_phone,care_count,type_id') + ->findOrEmpty() + ->append(['isset_certificate','services_type']) + ->toArray(); $merchant['top_banner'] = merchantConfig($merId, 'mer_pc_top'); $merchant['care'] = $care; $merchant['recommend'] = $this->getRecommend($productId,$merId); @@ -1444,7 +1447,8 @@ class ProductRepository extends BaseRepository } else { $res = json_decode($res, true); } - $res['merchant'] = $this->getMerchant($product['mer_id'],$product['product_id'],$uid); + + $res['merchant'] = $this->getMerchant((int)$product['mer_id'],$product['product_id'],$uid); return $res; } diff --git a/app/controller/admin/store/Point.php b/app/controller/admin/store/Point.php new file mode 100644 index 0000000..886311a --- /dev/null +++ b/app/controller/admin/store/Point.php @@ -0,0 +1,70 @@ +repository = $repository; + } + /** + * Common: 列表获取 + * Author: wu-hui + * Time: 2024/04/10 18:20 + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getList(){ + [$page, $limit] = $this->getPage(); + $params = $this->request->params(['mer_take_name']); + $data = $this->repository->getList((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + /** + * Common: 编辑信息 + * Author: wu-hui + * Time: 2024/04/10 18:19 + * @return mixed + * @throws \think\db\exception\DbException + */ + public function editInfo(){ + $params = $this->request->params([ + ['id', 0], + 'mer_take_name', + 'mer_take_phone', + 'mer_take_location', + 'mer_take_address', + 'mer_take_day', + 'mer_take_time' + ]); + $params['mer_id'] = (int)$this->request->merId(); + $this->repository->editInfo($params); + + return app('json')->success(); + } + /** + * Common: 删除信息 + * Author: wu-hui + * Time: 2024/04/10 18:42 + * @param $id + * @return mixed + */ + public function delInfo($id){ + $id = (int)$this->request->param('id'); + + $this->repository->update($id,['is_del' => 1]); + + return app('json')->success('删除成功'); + } + +} diff --git a/app/controller/admin/store/StoreProduct.php b/app/controller/admin/store/StoreProduct.php index 0d5b369..460fa5b 100644 --- a/app/controller/admin/store/StoreProduct.php +++ b/app/controller/admin/store/StoreProduct.php @@ -299,8 +299,7 @@ class StoreProduct extends BaseController * @author Qinii * @day 2020-06-24 */ - public function config() - { + public function config(){ $data = systemConfig(['extension_status','svip_switch_status','integral_status']); $merData= merchantConfig($this->request->merId(),['mer_integral_status','mer_integral_rate','mer_svip_status','svip_store_rate']); $svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'],100,2) : 0; @@ -310,8 +309,8 @@ class StoreProduct extends BaseController $data['integral_rate'] = $merData['mer_integral_rate'] ?: 0; // $data['delivery_way'] = $this->request->merchant()->delivery_way ? $this->request->merchant()->delivery_way : [2]; // $data['is_audit'] = $this->request->merchant()->is_audit; - $data['delivery_way'] = [2]; $data['is_audit'] = 0; + $data['delivery_way'] = [1,2]; return app('json')->success($data); } diff --git a/route/admin/product.php b/route/admin/product.php index 7acfb9d..fdd5e1f 100644 --- a/route/admin/product.php +++ b/route/admin/product.php @@ -515,6 +515,15 @@ Route::group(function () { '_path' => '/config/guarantee', '_auth' => true, ]); + // 提货点管理 + Route::group('store/point', function () { + Route::get('list','/getList')->name('systemStorePointList'); + Route::post('edit','/editInfo')->name('systemStorePointEditInfo'); + Route::post('del/:id','/delInfo')->name('systemStorePointDelInfo'); + })->prefix('admin.store.Point'); + + + })->middleware(AllowOriginMiddleware::class)