diff --git a/app/admin/controller/user/UserFeedbackController.php b/app/admin/controller/user/UserFeedbackController.php new file mode 100644 index 0000000..ba31797 --- /dev/null +++ b/app/admin/controller/user/UserFeedbackController.php @@ -0,0 +1,95 @@ +dataLists(new UserFeedbackLists()); + } + + + /** + * @notes 添加用户反馈表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function add() + { + $params = (new UserFeedbackValidate())->post()->goCheck('add'); + $result = UserFeedbackLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserFeedbackLogic::getError()); + } + + + /** + * @notes 编辑用户反馈表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function edit() + { + $params = (new UserFeedbackValidate())->post()->goCheck('edit'); + $result = UserFeedbackLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(UserFeedbackLogic::getError()); + } + + + /** + * @notes 删除用户反馈表 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function delete() + { + $params = (new UserFeedbackValidate())->post()->goCheck('delete'); + UserFeedbackLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取用户反馈表详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function detail() + { + $params = (new UserFeedbackValidate())->goCheck('detail'); + $result = UserFeedbackLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/merchant/MerchantBankLists.php b/app/admin/lists/merchant/MerchantBankLists.php index 95b420e..ff5e89b 100644 --- a/app/admin/lists/merchant/MerchantBankLists.php +++ b/app/admin/lists/merchant/MerchantBankLists.php @@ -7,7 +7,9 @@ use app\admin\lists\BaseAdminDataLists; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; use app\common\model\bank\Bank; +use app\common\model\merchant\Merchant; use app\common\model\merchant\MerchantBank; +use app\common\model\supplier\Supplier; /** @@ -46,7 +48,6 @@ class MerchantBankLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return MerchantBank::where($this->searchWhere) - ->field(['id', 'mer_id', 'bank_id', 'bank_code', 'bank_branch', 'name', 'id_card', 'phone', 'financial_img', 'is_own', 'is_check', 'fail_msg', 'admin_id']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($data){ @@ -56,6 +57,13 @@ class MerchantBankLists extends BaseAdminDataLists implements ListsSearchInterfa $data['bank_info'] = $bank; $data['is_own_text'] = $data['is_own'] == 0 ? '个人账户' : '对公账户'; $data['is_check_text'] = $data->is_check_text; + if($data['user_type'] == 1){ + $merchant = Merchant::field('mer_name')->where('mer_id',$data['mer_id'])->findOrEmpty(); + $data['mer_name'] = $merchant['mer_name']; + }else{ + $supplier = Supplier::field('mer_name')->where('id',$data['supplier_id'])->findOrEmpty(); + $data['mer_name'] = $supplier['mer_name']; + } }) ->toArray(); } diff --git a/app/admin/lists/user/UserFeedbackLists.php b/app/admin/lists/user/UserFeedbackLists.php new file mode 100644 index 0000000..57a6382 --- /dev/null +++ b/app/admin/lists/user/UserFeedbackLists.php @@ -0,0 +1,66 @@ + ['uid'], + '%like%' => ['name', 'contact'], + ]; + } + + + /** + * @notes 获取用户反馈表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function lists(): array + { + return UserFeedback::where($this->searchWhere) + ->field(['id', 'uid', 'content', 'images', 'name', 'contact']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户反馈表数量 + * @return int + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function count(): int + { + return UserFeedback::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/user/UserFeedbackLogic.php b/app/admin/logic/user/UserFeedbackLogic.php new file mode 100644 index 0000000..4f291eb --- /dev/null +++ b/app/admin/logic/user/UserFeedbackLogic.php @@ -0,0 +1,102 @@ + $params['uid'], + 'content' => $params['content'], + 'images' => $params['images'], + 'name' => $params['name'], + 'contact' => $params['contact'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑用户反馈表 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + UserFeedback::where('id', $params['id'])->update([ + 'uid' => $params['uid'], + 'content' => $params['content'], + 'images' => $params['images'], + 'name' => $params['name'], + 'contact' => $params['contact'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除用户反馈表 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public static function delete(array $params): bool + { + return UserFeedback::destroy($params['id']); + } + + + /** + * @notes 获取用户反馈表详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public static function detail($params): array + { + return UserFeedback::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/user/UserFeedbackValidate.php b/app/admin/validate/user/UserFeedbackValidate.php new file mode 100644 index 0000000..c396685 --- /dev/null +++ b/app/admin/validate/user/UserFeedbackValidate.php @@ -0,0 +1,86 @@ + 'require', + 'uid' => 'require', + 'content' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'uid' => '用户id', + 'content' => '反馈内容', + ]; + + + /** + * @notes 添加场景 + * @return UserFeedbackValidate + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function sceneAdd() + { + return $this->only(['uid','content','images','name','contact']); + } + + + /** + * @notes 编辑场景 + * @return UserFeedbackValidate + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function sceneEdit() + { + return $this->only(['id','uid','content','images','name','contact']); + } + + + /** + * @notes 删除场景 + * @return UserFeedbackValidate + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return UserFeedbackValidate + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php new file mode 100644 index 0000000..77c71f6 --- /dev/null +++ b/app/api/controller/UploadController.php @@ -0,0 +1,41 @@ +request->post('cid', 0); + $result = UploadService::image($cid); + return $this->success('上传成功', $result); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + + /** + * @notes 上传视频 + * @author 乔峰 + * @date 2021/12/29 16:27 + */ + public function video() + { + try { + $cid = $this->request->post('cid', 0); + $result = UploadService::video($cid); + return $this->success('上传成功', $result); + } catch (Exception $e) { + return $this->fail($e->getMessage()); + } + } + } \ No newline at end of file diff --git a/app/api/controller/merchant/MerchantController.php b/app/api/controller/merchant/MerchantController.php index 66d1ebd..2dc556a 100644 --- a/app/api/controller/merchant/MerchantController.php +++ b/app/api/controller/merchant/MerchantController.php @@ -17,15 +17,20 @@ class MerchantController extends BaseApiController return $this->dataLists(new MerchantLists()); } - public function add_bank(){ + public function add_bank() + { $params = (new MerchantBankValidate())->post()->goCheck('add'); - $has = Db::name('merchant_bank')->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty(); + if($params['user_type'] == 1){ + $has = Db::name('merchant_bank')->where('mer_id',$params['mer_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty(); + }else{ + $has = Db::name('merchant_bank')->where('supplier_id',$params['supplier_id'])->where('is_own',$params['is_own'])->where('is_check','<>',2)->findOrEmpty(); + } if(!empty($has)){ return $this->fail('已提交审核请勿重复提交'); } $expireAt = strtotime(date('Y-m-d 23:59:59')); // 当天结束时间戳 - $totalKey = $params['mer_id'].$params['bank_code']; - $checkKey = $params['mer_id'].'check'; + $totalKey = $params['user_type'] == 1 ? $params['mer_id'].$params['bank_code'] : $params['supplier_id'].$params['bank_code']; + $checkKey = $params['user_type'] == 1 ? $params['mer_id'].'check' : $params['supplier_id'].'check'; $check = Cache::get($totalKey) ?? 0; if ($check && $check > 9) { return $this->fail('超出绑定限制请明日再绑定'); @@ -58,7 +63,9 @@ class MerchantController extends BaseApiController } } $save_data = [ - 'mer_id' => $params['mer_id'], + 'user_type' => $params['user_type'], + 'mer_id' => $params['mer_id'] ?? 0, + 'supplier_id' => $params['supplier_id'] ?? 0, 'name' => $params['name'], 'bank_id' => $params['bank_id'], 'bank_code' => $params['bank_code'], diff --git a/app/api/controller/user/UserFeedbackController.php b/app/api/controller/user/UserFeedbackController.php new file mode 100644 index 0000000..1bdc86c --- /dev/null +++ b/app/api/controller/user/UserFeedbackController.php @@ -0,0 +1,34 @@ +dataLists(new UserFeedbackLists()); + } + + + public function add() + { + $params = (new UserFeedbackValidate())->post()->goCheck('add'); + $result = UserFeedbackLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(UserFeedbackLogic::getError()); + } + } \ No newline at end of file diff --git a/app/api/lists/operation/OpurchaseGoodsOfferList.php b/app/api/lists/operation/OpurchaseGoodsOfferList.php index 283c164..4ba5d7d 100644 --- a/app/api/lists/operation/OpurchaseGoodsOfferList.php +++ b/app/api/lists/operation/OpurchaseGoodsOfferList.php @@ -69,7 +69,7 @@ class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchI */ public function count(): int { - $supplier_id=$this->request->userInfo['supplier']['id'] ?? 1; + $supplier_id=$this->request->userInfo['supplier']['id'] ?? 0; $params = $this->request->get(); if(isset($params['type']) && $params['type'] == 2){ $where[] = ['price','<>','']; diff --git a/app/api/lists/user/UserFeedbackLists.php b/app/api/lists/user/UserFeedbackLists.php new file mode 100644 index 0000000..d5eddd9 --- /dev/null +++ b/app/api/lists/user/UserFeedbackLists.php @@ -0,0 +1,60 @@ + ['uid'], + '%like%' => ['name', 'contact'], + ]; + } + + + /** + * @notes 获取用户反馈表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function lists(): array + { + $uid = $this->request->userInfo['user_id']; + return UserFeedback::where($this->searchWhere)->where('uid',$uid) + ->field(['id', 'uid', 'content', 'images', 'name', 'contact']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取用户反馈表数量 + * @return int + * @author likeadmin + * @date 2024/05/13 16:56 + */ + public function count(): int + { + return UserFeedback::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/api/logic/user/UserFeedbackLogic.php b/app/api/logic/user/UserFeedbackLogic.php new file mode 100644 index 0000000..e74f5fb --- /dev/null +++ b/app/api/logic/user/UserFeedbackLogic.php @@ -0,0 +1,38 @@ + $params['uid'], + 'content' => $params['content'], + 'images' => $params['images'] ? json_encode($params['images']) : null, + 'name' => $params['name'], + 'contact' => $params['contact'], + 'create_time' => time(), + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + } \ No newline at end of file diff --git a/app/api/validate/MerchantBankValidate.php b/app/api/validate/MerchantBankValidate.php index cbeac7e..4ab5607 100644 --- a/app/api/validate/MerchantBankValidate.php +++ b/app/api/validate/MerchantBankValidate.php @@ -8,11 +8,13 @@ class MerchantBankValidate extends BaseValidate { protected $rule = [ + 'user_type|用户类型' => 'require|in:1,2', + 'mer_id|商户id' => 'requireIf:user_type,1|checkMerchant', + 'supplier_id|供应商id' => 'requireIf:user_type,2|checkSupplier', 'is_own|账号类型' => 'require|in:0,1', - 'mer_id|商户id' => 'require|checkMerchant', 'name|姓名' => 'require', 'bank_id|开户银行' => 'require|checkBank', - 'bank_code|银行账号' => 'require|integer', + 'bank_code|银行账号' => 'require', 'bank_branch|开户网点' => 'require|max:32', 'id_card|身份证' => 'requireIf:is_own,0|idCard', 'phone|手机号' => 'requireIf:is_own,0|mobile', @@ -22,7 +24,7 @@ public function sceneAdd() { - return $this->only(['mer_id','is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']); + return $this->only(['user_type','mer_id','supplier_id','is_own','bank_id','name','bank_code','bank_branch','id_card','phone','financial_img']); } public function checkBank($value){ @@ -40,4 +42,12 @@ } return true; } + + public function checkSupplier($value){ + $data = Db::name('supplier')->where('id',$value)->findOrEmpty(); + if(empty($data)){ + return '供应商不存在'; + } + return true; + } } \ No newline at end of file diff --git a/app/common/model/user/UserFeedback.php b/app/common/model/user/UserFeedback.php new file mode 100644 index 0000000..14e24f4 --- /dev/null +++ b/app/common/model/user/UserFeedback.php @@ -0,0 +1,24 @@ +