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' => '删除', ]);