From 95fe7bd9815fef484426a99940d1be50dfa4bf21 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Mon, 14 Aug 2023 17:51:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E7=AB=AF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/user/BusinessTeam.php | 89 ++++++++++++++++++ server/app/admin/logic/setting/BasicLogic.php | 2 + .../admin/logic/user/BusinessTeamLogic.php | 90 ++++++++++++++++++ server/app/admin/logic/user/UserLogic.php | 12 ++- .../validate/user/BusinessTeamValidate.php | 21 +++++ .../view/setting/basic/website_base.html | 70 +++++++++++++- server/app/api/controller/Demand.php | 92 +++++++++++++++++++ server/app/api/controller/Order.php | 22 +++++ server/app/api/logic/UserLogic.php | 19 +++- server/app/common/model/BusinessTeam.php | 9 ++ server/app/common/model/Demand.php | 9 ++ server/app/common/model/DemandReport.php | 9 ++ server/public/static/admin/js/function.js | 19 ++++ 13 files changed, 460 insertions(+), 3 deletions(-) create mode 100644 server/app/admin/controller/user/BusinessTeam.php create mode 100644 server/app/admin/logic/user/BusinessTeamLogic.php create mode 100644 server/app/admin/validate/user/BusinessTeamValidate.php create mode 100644 server/app/api/controller/Demand.php create mode 100644 server/app/common/model/BusinessTeam.php create mode 100644 server/app/common/model/Demand.php create mode 100644 server/app/common/model/DemandReport.php diff --git a/server/app/admin/controller/user/BusinessTeam.php b/server/app/admin/controller/user/BusinessTeam.php new file mode 100644 index 00000000..5aac9d82 --- /dev/null +++ b/server/app/admin/controller/user/BusinessTeam.php @@ -0,0 +1,89 @@ +request->isAjax()){ + $get = $this->request->get(); + $lists = BusinessTeamLogic::lists($get); + return JsonServer::success('', $lists); + } + return view(); + } + + public function add() + { + if($this->request->isAjax()) { + try{ + $post = $this->request->post(); + validate(BusinessTeamValidate::class)->scene('add')->check($post); + }catch(ValidateException $e) { + return JsonServer::error($e->getError()); + } + $result = BusinessTeamLogic::add($post); + if($result === true) { + return JsonServer::success('添加成功'); + } + return JsonServer::error(BusinessTeamLogic::getError()); + } + return view(); + } + + public function edit(){ + if($this->request->isAjax()){ + try{ + $post = $this->request->post(); + validate(BusinessTeamValidate::class)->scene('edit')->check($post); + }catch(ValidateException $e) { + return JsonServer::error($e->getError()); + } + $result = BusinessTeamLogic::edit($post); + if($result === true) { + return JsonServer::success('编辑成功'); + } + return JsonServer::error(BusinessTeamLogic::getError()); + } + + $id = $this->request->get('id', '', 'intval'); + $detail = BusinessTeamLogic::getBusinessTeam($id); + return view('', [ + 'detail' => $detail + ]); + } + + public function del() + { + $id = $this->request->post('id', '', 'intval'); + $result = BusinessTeamLogic::del($id); + if($result === true) { + return JsonServer::success('删除成功'); + } + return JsonServer::error(BusinessTeamLogic::getError()); + } + +// public function set() +// { +// if($this->request->isAjax()) { +// $post = $this->request->post(); +// ConfigServer::set('user_level', 'intro', $post['intro']); +// return JsonServer::success('设置成功'); +// } +// $intro = ConfigServer::get('user_level', 'intro'); +// $intro_default = config('default.user_level.intro'); +// +// return view('', [ +// 'intro' => $intro, +// 'intro_default' => $intro_default +// ]); +// } +} \ No newline at end of file diff --git a/server/app/admin/logic/setting/BasicLogic.php b/server/app/admin/logic/setting/BasicLogic.php index b3a46711..496750e1 100644 --- a/server/app/admin/logic/setting/BasicLogic.php +++ b/server/app/admin/logic/setting/BasicLogic.php @@ -30,6 +30,7 @@ class BasicLogic extends Logic 'pc_client_login_logo' => ConfigServer::get('website', 'pc_client_login_logo'), 'user_image' => ConfigServer::get('website', 'user_image'), 'goods_image' => ConfigServer::get('website', 'goods_image'), + 'order_contract_template' => ConfigServer::get('website', 'order_contract_template'), 'platform_login_logo' => ConfigServer::get('website_platform', 'platform_login_logo'), 'platform_login_image' => ConfigServer::get('website_platform', 'platform_login_image'), @@ -65,6 +66,7 @@ class BasicLogic extends Logic ConfigServer::set('website', 'pc_client_login_logo', UrlServer::setFileUrl($post['pc_client_login_logo'] ?? '')); ConfigServer::set('website', 'user_image', UrlServer::setFileUrl($post['user_image'] ?? '')); ConfigServer::set('website', 'goods_image', UrlServer::setFileUrl($post['goods_image'] ?? '')); + ConfigServer::set('website', 'order_contract_template', UrlServer::setFileUrl($post['order_contract_template'] ?? '')); } /** diff --git a/server/app/admin/logic/user/BusinessTeamLogic.php b/server/app/admin/logic/user/BusinessTeamLogic.php new file mode 100644 index 00000000..d7b47790 --- /dev/null +++ b/server/app/admin/logic/user/BusinessTeamLogic.php @@ -0,0 +1,90 @@ +page($get['page'], $get['limit'])->select()->toArray(); + + return ['count' => $count, 'lists' => $lists]; + } + + public static function add($post) + { + try{ + $userLevel = BusinessTeam::where(['name'=>trim($post['name'])])->findOrEmpty(); + if(!$userLevel->isEmpty()) { + throw new \think\Exception('名称已被使用,请更换后重试'); + } + $time = time(); + $data = [ + 'name' => trim($post['name']), + 'phone' => trim($post['phone']), + 'create_time' => $time, + ]; + BusinessTeam::create($data); + return true; + }catch(\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + public static function edit($post) + { + try{ + $userLevel = BusinessTeam::where([ + ['name', '=', trim($post['name'])], + ['id', '<>', $post['id']] + ])->findOrEmpty(); + if(!$userLevel->isEmpty()) { + throw new \think\Exception('名称已被使用,请更换后重试'); + } + $data = [ + 'id' => $post['id'], + 'name' => trim($post['name']), + 'phone' => trim($post['phone']), + ]; + BusinessTeam::update($data); + return true; + }catch(\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + public static function del($id) + { + try{ + BusinessTeam::where('id', $id)->delete(); + return true; + }catch(\Exception $e) { + self::$error = $e->getMessage(); + return false; + } + } + + public static function getBusinessTeamList() + { + $levelArr = BusinessTeam::field('id,name,phone') + ->select() + ->toArray(); + $levelArr[0] = ['id'=>0, 'name'=>'暂无团队', 'phone' => '']; + return $levelArr; + } + + public static function getBusinessTeam($id){ + $detail = BusinessTeam::where(['id'=>$id])->findOrEmpty(); + if($detail->isEmpty()) { + return []; + } + $detail = $detail->toArray(); + return $detail; + } +} \ No newline at end of file diff --git a/server/app/admin/logic/user/UserLogic.php b/server/app/admin/logic/user/UserLogic.php index a7a522cf..fde7c850 100644 --- a/server/app/admin/logic/user/UserLogic.php +++ b/server/app/admin/logic/user/UserLogic.php @@ -7,6 +7,7 @@ use app\common\enum\ClientEnum; use app\common\enum\OrderEnum; use app\common\logic\AccountLogLogic; use app\common\model\AccountLog; +use app\common\model\BusinessTeam; use app\common\model\user\User; use app\common\model\user\UserLevel; use app\common\model\user\UserTag; @@ -30,6 +31,11 @@ class UserLogic extends Logic $where[] = ['disable', '=', $get['disable']]; } + //业务团队 + if(isset($get['team_id']) && $get['team_id'] !== ''){ + $where[] = ['team_id','=',$get['team_id']]; + } + //等级查询 if(isset($get['level']) && $get['level'] !== ''){ $where[] = ['level','=',$get['level']]; @@ -64,12 +70,14 @@ class UserLogic extends Logic $user_count = User::where($where)->count(); $user_list = User::where($where) - ->field('id,sn,nickname,avatar,level,total_order_amount,tag_ids,client,login_time,create_time,user_growth,user_money,earnings,first_leader,disable') + ->field('id,sn,nickname,avatar,level,total_order_amount,tag_ids,client,login_time,create_time,user_growth,user_money,earnings,first_leader,disable,team_id') ->page($get['page'],$get['limit']) ->order('id desc') ->select() ->toArray(); + // 业务团队 + $business_team = BusinessTeam::order('id desc')->column('name','id'); //会员等级 $user_level = UserLevel::where(['del'=>0])->column('name','id'); // 会员标签 @@ -82,6 +90,8 @@ class UserLogic extends Logic $item['earnings'] = empty($item['earnings']) ? 0 : $item['earnings']; // 总资产 $item['total_amount'] = $item['user_money'] + $item['earnings']; + // 业务团队 + $item['team_name'] = $business_team[$item['team_id']] ?? '无'; // 会员等级 $item['level_name'] = '暂无等级'; if(isset($user_level[$item['level']])){ diff --git a/server/app/admin/validate/user/BusinessTeamValidate.php b/server/app/admin/validate/user/BusinessTeamValidate.php new file mode 100644 index 00000000..3e35a598 --- /dev/null +++ b/server/app/admin/validate/user/BusinessTeamValidate.php @@ -0,0 +1,21 @@ + 'require', + 'name|名称' => 'require', + 'phone|电话' => 'require', + ]; + + public function sceneAdd() { + return $this->only(['name', 'phone']); + } + + public function sceneEdit() { + return $this->only(['id', 'name', 'phone']); + } +} \ No newline at end of file diff --git a/server/app/admin/view/setting/basic/website_base.html b/server/app/admin/view/setting/basic/website_base.html index b8b65d73..6ad541c1 100644 --- a/server/app/admin/view/setting/basic/website_base.html +++ b/server/app/admin/view/setting/basic/website_base.html @@ -109,7 +109,7 @@
- {if !empty($config.user_image)} + {if !empty($config.goods_image)}
img @@ -127,6 +127,32 @@
+ +
+ +
+
+ + {if !empty($config.order_contract_template)} + +
+ + +
+ {else/} + + {/if} +
+
+ 前置订单的合同模版,建议大小不超过:10M。pdf格式 +
+
+
+
+ diff --git a/server/app/api/controller/Demand.php b/server/app/api/controller/Demand.php new file mode 100644 index 00000000..be5aa56d --- /dev/null +++ b/server/app/api/controller/Demand.php @@ -0,0 +1,92 @@ + 'desc' + ]; + + $count = thisModel::where($where)->count(); + + $list = thisModel::field(['id', 'name', 'create_time']) + ->where($where) + ->order($order) + ->page($page,$limit) + ->select() + ->toArray(); + + $data = [ + 'list' => $list, + 'page_no' => $page, + 'page_size' => $limit, + 'count' => $count, + ]; + return JsonServer::success('获取成功', $data); + } catch (\Exception $e) { + return JsonServer::error('获取失败'); + } + } + + public function detail() + { + $id = input('id/d', 0); + if (!$item = thisModel::where('id', $id)->find()) { + return JsonServer::error('记录不存在'); + } + return JsonServer::success('获取成功', $item->toArray()); + } + + public function report(): Json + { + $input = input('post.'); + + $rule = [ + 'demand_id|需求' => 'require|number', + 'name|姓名' => 'require|min:2|max:50', + 'phone|手机' => 'require|mobile', +// 'company|公司' => '', +// 'price|报价' => '', + ]; + + $validate = Validate::rule($rule); + if (!$validate->check($input)) { + return JsonServer::error($validate->getError()); + } + + DemandReport::create([ + 'demand_id' => $input['demand_id'], + 'name' => $input['name'], + 'phone' => $input['phone'], + 'company' => $input['company'] ?: '', + 'price' => $input['price'] ?: '', + 'create_time' => time(), + ]); + + return JsonServer::success('报名成功'); + } + +} \ No newline at end of file diff --git a/server/app/api/controller/Order.php b/server/app/api/controller/Order.php index 8af88c06..a3b18d47 100644 --- a/server/app/api/controller/Order.php +++ b/server/app/api/controller/Order.php @@ -6,11 +6,33 @@ use app\api\logic\OrderInvoiceLogic; use app\api\logic\OrderLogic; use app\api\validate\OrderValidate; use app\common\basics\Api; +use app\common\server\ConfigServer; use app\common\server\JsonServer; class Order extends Api { + public $like_not_need_login = ['contractDownload']; + + /** + * @notes 合同下载 + * @return \think\response\Json + * @throws \think\Exception + * @author suny + * @date 2021/7/13 6:11 下午 + */ + public function contractDownload() + { + $path = ConfigServer::get('website', 'order_contract_template'); + return JsonServer::success('下单成功!', ['path' => $path, 'domain' => request()->domain()]); + } + + public function contractUpload() + { + + return JsonServer::success('上传成功!'); + } + /** * @notes 下单 * @return \think\response\Json diff --git a/server/app/api/logic/UserLogic.php b/server/app/api/logic/UserLogic.php index a62c8467..3242810c 100644 --- a/server/app/api/logic/UserLogic.php +++ b/server/app/api/logic/UserLogic.php @@ -4,6 +4,7 @@ namespace app\api\logic; use app\api\controller\Account; use app\common\basics\Logic; use app\common\logic\ChatLogic; +use app\common\model\BusinessTeam; use app\common\model\goods\GoodsCollect; use app\common\model\kefu\ChatRecord; use app\common\model\kefu\ChatRelation; @@ -75,12 +76,28 @@ class UserLogic extends Logic if(!$user_level->isEmpty()){ $user['next_level_tips'] = '距离升级还差'.intval($user_level['growth_value'] - $user['user_growth']); } + + $team = [ + 'id' => 0, + 'name' => '', + 'phone' => '', + ]; + + // 团队信息 + $teamInfo = BusinessTeam::where('id', $user['team_id'])->find(); + if (!empty($teamInfo)) { + $team['id'] = $teamInfo['id'] ?? 0; + $team['name'] = $teamInfo['name'] ?: ''; + $team['phone'] = $teamInfo['phone'] ?: ''; + } + // 是否设置支付密码 $user['hasPayPassword'] = $user['pay_password'] ? 1: 0; $user->visible(['id','nickname','sn','avatar', 'mobile', 'hasPayPassword','next_level_tips','user_money','total_order_amount','total_recharge_amount', 'coupon','user_integral','level','wait_pay','wait_take','wait_delivery', - 'wait_comment','after_sale', 'distribution_setting', 'distribution_code', 'notice_num', 'collect','level_name','vip']); + 'wait_comment','after_sale', 'distribution_setting', 'distribution_code', 'notice_num', 'collect','level_name','vip','team_id']); $user = $user->toArray(); + $user['team_info'] = $team; return $user; } diff --git a/server/app/common/model/BusinessTeam.php b/server/app/common/model/BusinessTeam.php new file mode 100644 index 00000000..7f307c68 --- /dev/null +++ b/server/app/common/model/BusinessTeam.php @@ -0,0 +1,9 @@ +\n' + + '' + + '' + + '
'; + $(element).prev().val(res.data[1].uri); + $(element).after(html); + $(element).css('display','none'); + } + }); } };