From 0c664395bcbd6fe4623d75a6caba5607dadb3666 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 14:03:15 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=AE=A1=E6=A0=B8?= =?UTF-8?q?=E5=95=86=E6=88=B7=E6=9B=B4=E6=96=B0=E8=BA=AB=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantIntentionDao.php | 2 ++ .../merchant/MerchantIntentionRepository.php | 34 +++++++++++++++++++ .../system/merchant/MerchantIntention.php | 29 +++++++++++++++- route/admin/merchant.php | 6 ++++ 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/app/common/dao/system/merchant/MerchantIntentionDao.php b/app/common/dao/system/merchant/MerchantIntentionDao.php index 67a4a579..b9b18c08 100644 --- a/app/common/dao/system/merchant/MerchantIntentionDao.php +++ b/app/common/dao/system/merchant/MerchantIntentionDao.php @@ -41,6 +41,8 @@ class MerchantIntentionDao extends BaseDao $query->where('mer_name|phone|mark', 'like', '%' . $where['keyword'] . '%'); })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { getModelTime($query, $where['date']); + })->when(isset($where['is_change']) && $where['is_change'] !== '', function ($query) use ($where) { + $query->where('is_change', $where['is_change']); })->where('is_del', 0); return $query; diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index f5cfb06f..43219a89 100644 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -102,6 +102,40 @@ class MerchantIntentionRepository extends BaseRepository return $form->setTitle('修改审核状态'); } + + + + /** + * 更新身份 + * @param $id + * @param $data + * @return void + * @throws \think\db\exception\DbException + */ + public function updateIdent($id, $data) + { + $wholesale = $data['wholesale']; + $uid = $data['uid']; + unset($data['mer_type_id']); + unset($data['wholesale']); + unset($data['uid']); + + if($wholesale){ + $check = Merchant::getDB()->where('uid', $uid)->value('mer_id');//商户 + if($check){ + Merchant::getDB()->where('mer_id',$check)->update(['wholesale'=>$wholesale]); + }else{ + throw new ValidateException('先成为商户'); + } + + } + + $intention = $this->search(['mer_intention_id' => $id])->find(); + if (!$intention) + throw new ValidateException('信息不存在'); + $intention->save($data); + } + public function updateStatus($id, $data) { $data['create_mer'] = !empty($data['create_mer']) ? $data['create_mer'] : 2; diff --git a/app/controller/admin/system/merchant/MerchantIntention.php b/app/controller/admin/system/merchant/MerchantIntention.php index 9b2109ac..ca6c2b84 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', 'type']); + $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id', 'type','is_change']); return app('json')->success($this->repository->getList($where, $page, $limit)); } @@ -75,6 +75,33 @@ class MerchantIntention extends BaseController return app('json')->success('修改成功'); } + + + public function switchIdentity($id) + { + if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) + return app('json')->fail('数据不存在'); + + $data = $this->request->params(['status','mer_type_id','uid']); + if(empty($data['status']) || empty($data['mer_type_id']) || empty($data['uid']) ) return app('json')->fail('缺失参数'); + $data['wholesale'] = 0; + if($data['status'] == 1){ + if($data['mer_type_id'] == 23){ + //批发 + $data['wholesale'] =1; + }else{ + $data['wholesale'] =2;//零售 + } + } + $this->repository->updateIdent($id, $data); + return app('json')->success('修改身份成功'); + } + + + + + + public function delete($id) { if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) diff --git a/route/admin/merchant.php b/route/admin/merchant.php index 5f04e85f..5f70b5d3 100644 --- a/route/admin/merchant.php +++ b/route/admin/merchant.php @@ -62,6 +62,12 @@ Route::group(function () { Route::post('status/:id', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ '_alias' => '审核', ]); + + Route::post('change/:id', '/switchIdentity')->name('systemMerchantIntentionIdent')->option([ + '_alias' => '更改身份', + ]); + + Route::delete('delete/:id', '/delete')->name('systemMerchantIntentionDelete')->option([ '_alias' => '删除', ]); From 10f2dbc871d9cc210f3928000a53f0b321bbf6c4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 14:37:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=95=86=E6=88=B7=20=E6=89=B9=E5=8F=91?= =?UTF-8?q?=E5=95=86=E6=88=B7=E6=88=96=E6=89=B9=E5=8F=91=E9=9B=B6=E5=94=AE?= =?UTF-8?q?=E5=95=86=E6=88=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/system/merchant/MerchantIntentionDao.php | 4 ++-- .../merchant/MerchantIntentionRepository.php | 12 ++++++++++++ .../admin/system/merchant/MerchantIntention.php | 14 ++++++++++++-- route/admin/merchant.php | 4 ++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/common/dao/system/merchant/MerchantIntentionDao.php b/app/common/dao/system/merchant/MerchantIntentionDao.php index b9b18c08..70745666 100644 --- a/app/common/dao/system/merchant/MerchantIntentionDao.php +++ b/app/common/dao/system/merchant/MerchantIntentionDao.php @@ -41,8 +41,8 @@ class MerchantIntentionDao extends BaseDao $query->where('mer_name|phone|mark', 'like', '%' . $where['keyword'] . '%'); })->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) { getModelTime($query, $where['date']); - })->when(isset($where['is_change']) && $where['is_change'] !== '', function ($query) use ($where) { - $query->where('is_change', $where['is_change']); + })->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where) { + $query->whereIn('type', $where['type']); })->where('is_del', 0); return $query; diff --git a/app/common/repositories/system/merchant/MerchantIntentionRepository.php b/app/common/repositories/system/merchant/MerchantIntentionRepository.php index 43219a89..321e7144 100644 --- a/app/common/repositories/system/merchant/MerchantIntentionRepository.php +++ b/app/common/repositories/system/merchant/MerchantIntentionRepository.php @@ -45,6 +45,18 @@ class MerchantIntentionRepository extends BaseRepository return compact('count', 'list'); } + public function getMoreList(array $where, $page, $limit) + { + $query = $this->dao->search($where); + $count = $query->count(); + $list = $query->page($page, $limit) + ->order('create_time DESC , status ASC')->with(['merchantCategory', 'merchantType']) + ->select(); + return compact('count', 'list'); + } + + + public function detail($id, ?int $uid) { $where = ['mer_intention_id' => $id]; diff --git a/app/controller/admin/system/merchant/MerchantIntention.php b/app/controller/admin/system/merchant/MerchantIntention.php index ca6c2b84..9624f2b8 100644 --- a/app/controller/admin/system/merchant/MerchantIntention.php +++ b/app/controller/admin/system/merchant/MerchantIntention.php @@ -38,10 +38,21 @@ 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', 'type','is_change']); + $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)); } + //批发零售列表 + public function list() + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id', 'type']); + $where['type'] = [3,4];//批发零售 + return app('json')->success($this->repository->getMoreList($where, $page, $limit)); + } + + + public function form($id) { if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) @@ -81,7 +92,6 @@ class MerchantIntention extends BaseController { if (!$this->repository->getWhereCount(['mer_intention_id' => $id, 'is_del' => 0])) return app('json')->fail('数据不存在'); - $data = $this->request->params(['status','mer_type_id','uid']); if(empty($data['status']) || empty($data['mer_type_id']) || empty($data['uid']) ) return app('json')->fail('缺失参数'); $data['wholesale'] = 0; diff --git a/route/admin/merchant.php b/route/admin/merchant.php index 5f70b5d3..91e9ca35 100644 --- a/route/admin/merchant.php +++ b/route/admin/merchant.php @@ -59,6 +59,10 @@ Route::group(function () { Route::get('lst', '/lst')->name('systemMerchantIntentionLst')->option([ '_alias' => '列表', ]); + Route::get('list', '/list')->name('systemMerchantIntentionList')->option([ + '_alias' => '批发和零售申请列表', + ]); + Route::post('status/:id', '/switchStatus')->name('systemMerchantIntentionStatus')->option([ '_alias' => '审核', ]); From 865762e767ded4111417e59ae4bd4f55ebeb6dec Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Fri, 15 Mar 2024 15:10:36 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=95=86=E6=88=B7=20=E6=89=B9=E5=8F=91?= =?UTF-8?q?=E5=95=86=E6=88=B7=E6=88=96=E6=89=B9=E5=8F=91=E9=9B=B6=E5=94=AE?= =?UTF-8?q?=E5=95=86=E6=88=B7=E6=8F=90=E4=BA=A4=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/merchant/MerchantIntention.php | 27 +++++++++++++++++++ route/api.php | 2 ++ 2 files changed, 29 insertions(+) diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 3d80d359..244e7b71 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -308,6 +308,33 @@ class MerchantIntention extends BaseController return app('json')->success($data); } + public function changeIdentity() + { + $data = $this->request->params([ + 'phone', + 'mer_name', + 'mer_type_id', + 'merchant_category_id', + 'type', + 'name' + ]); + + if(empty($data['phone'])||empty($data['mer_name'])||empty($data['mer_type_id'])||empty($data['merchant_category_id'])||empty($data['type'])||empty($data['name'])){ + return app('json')->fail('参数缺失请检查'); + } + + if ($this->userInfo) $data['uid'] = $this->userInfo->uid; + $data['status'] = 0; + $intention = $this->repository->create($data); + if ($intention) { + return app('json')->success('申请更改商户身份成功'); + } else { + return app('json')->fail('申请更改商户身份失败'); + } + } + + + protected function checkParams() { $data = $this->request->params([ diff --git a/route/api.php b/route/api.php index 786564ec..3c34e37f 100644 --- a/route/api.php +++ b/route/api.php @@ -558,6 +558,8 @@ Route::group('api/', function () { Route::post('intention/create', 'api.store.merchant.MerchantIntention/create'); Route::get('intention/cate', 'api.store.merchant.MerchantIntention/cateLst'); Route::get('intention/type', 'api.store.merchant.MerchantIntention/typeLst'); + + Route::post('intention/change', 'api.store.merchant.MerchantIntention/changeIdentity');//更新身份 //浏览 Route::post('common/visit', 'api.Common/visit'); Route::get('store/product/assist/count', 'api.store.product.StoreProductAssist/userCount');