From 2c2b9f0a87eca6813fc8d2b333fb7d5c33823a67 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Sun, 18 May 2025 21:50:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=96=B0=E5=A2=9E=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=B5=84=E6=BA=90=E6=B7=BB=E5=8A=A0=E5=92=8C=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E8=8E=B7=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增客户资源添加接口和字典获取接口 - 实现客户资源数据和六速数据的添加功能 - 实现字典数据的获取功能 - 添加相关路由和控制器 --- .../api/controller/apiController/Common.php | 16 ++-- .../apiController/CustomerResources.php | 81 +++++++++++++++++++ niucloud/app/api/route/route.php | 5 ++ .../service/api/apiService/CommonService.php | 46 +++++++++++ .../apiService/CustomerResourcesService.php | 68 ++++++++++++++++ 5 files changed, 205 insertions(+), 11 deletions(-) create mode 100644 niucloud/app/api/controller/apiController/CustomerResources.php create mode 100644 niucloud/app/service/api/apiService/CommonService.php create mode 100644 niucloud/app/service/api/apiService/CustomerResourcesService.php diff --git a/niucloud/app/api/controller/apiController/Common.php b/niucloud/app/api/controller/apiController/Common.php index 8133b8db..27a570ee 100644 --- a/niucloud/app/api/controller/apiController/Common.php +++ b/niucloud/app/api/controller/apiController/Common.php @@ -11,15 +11,9 @@ namespace app\api\controller\apiController; -use app\dict\member\MemberLoginTypeDict; use app\Request; -use app\service\api\apiService\PersonnelService; -use app\service\api\captcha\CaptchaService; -use app\service\api\login\ConfigService; -use app\service\api\login\LoginService; +use app\service\api\apiService\CommonService; use core\base\BaseApiService; -use Exception; -use think\Response; /** * 公共控制器相关接口 @@ -29,13 +23,13 @@ use think\Response; class Common extends BaseApiService { - //员工详情 - public function info(Request $request){ + //获取字典 + public function getDictionary(Request $request){ //获取员工信息 $where = [ - 'id'=>$this->member_id, + 'key'=>$request->param('key','') ]; - $res = (new PersonnelService())->info($where); + $res = (new CommonService())->getDictionary($where); if(!$res){ return fail('账户信息有误'); } diff --git a/niucloud/app/api/controller/apiController/CustomerResources.php b/niucloud/app/api/controller/apiController/CustomerResources.php new file mode 100644 index 00000000..da7311b4 --- /dev/null +++ b/niucloud/app/api/controller/apiController/CustomerResources.php @@ -0,0 +1,81 @@ +date('Y-m'), + "create_date"=>date('Y-m-d'), + "source_channel" => $request->param('source_channel', ''), + "source" => $request->param('source', ''), + "consultant" => $request->param('consultant', ''), + "name" => $request->param('name', ''), + "age" => $request->param('age', ''), + "gender" => $request->param('gender', ''), + "phone_number" => $request->param('phone_number', ''), + "demand" => $request->param('demand', ''), + "decision_maker" => $request->param('decision_maker', ''), + "initial_intent" => $request->param('initial_intent', ''), + "status" => $request->param('status', ''), + "purchasing_power" => $request->param('purchasing_power', ''), + "cognitive_idea" => $request->param('cognitive_idea', ''), + "optional_class_time" => $request->param('optional_class_time', ''), + "distance" => $request->param('distance', ''), + ]; + + $six_speed_data = [ + "purchase_power" => $request->param('purchasing_power', ''), + "concept_awareness" => $request->param('cognitive_idea', ''), + "promised_visit_time" => $request->param('promised_visit_time', ''),//承诺到访时间 + "preferred_class_time" => $request->param('optional_class_time', ''),//可选上课时间 + "distance" => $request->param('distance', ''),//距离 + "communication" => $request->param('communication', ''),//沟通备注 + "staff_id" => $request->param('staff_id', ''),//人员ID + ]; + + foreach($customer_resources_data as $k=>$v){ + if(empty($v)){ + return fail("缺少必填项{$k}"); + } + } + foreach($six_speed_data as $k=>$v){ + if(empty($v)){ + return fail("缺少必填项{$k}"); + } + } + + + $res = (new CustomerResourcesService())->addData($customer_resources_data,$six_speed_data); + if(!$res['code']){ + return fail($res['msg']); + } + return success([]); + } + + +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index b6013152..d22776a7 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -174,6 +174,8 @@ Route::group(function() { Route::group(function() { //员工登录 Route::post('personnelLogin', 'login.Login/personnelLogin'); + //获取字典 + Route::get('common/getDictionary', 'apiController.Common/getDictionary'); @@ -202,6 +204,9 @@ Route::group(function() { //员工端-修改 Route::post('personnel/edit', 'apiController.Personnel/edit'); + //客户资源-添加 + Route::post('customerResources/add', 'apiController.CustomerResources/add'); + diff --git a/niucloud/app/service/api/apiService/CommonService.php b/niucloud/app/service/api/apiService/CommonService.php new file mode 100644 index 00000000..55e2cc3c --- /dev/null +++ b/niucloud/app/service/api/apiService/CommonService.php @@ -0,0 +1,46 @@ +where('key',$where['key']); + } + $res = $model->field($field)->find();//员工信息 + + if($res){ + $res = $res->toArray(); + }else{ + $res = []; + } + return $res; + + } + +} diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php new file mode 100644 index 00000000..11e99b79 --- /dev/null +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -0,0 +1,68 @@ +0, + 'msg'=>'操作失败' + ]; + //开启事物 + Db::startTrans(); + try { + $resource_id = CustomerResources::insertGetId($customer_resources_data);//客户资源表 + if(!$resource_id){ + Db::rollback(); + return $res; + } + $six_speed_data['resource_id'] = $resource_id; + $sixSpeedAdd = SixSpeed::create($six_speed_data); + if(!$sixSpeedAdd){ + Db::rollback(); + return $res; + } + Db::commit(); + $res = [ + 'code'=>1, + 'msg'=>'操作成功' + ]; + //@todo 缺少一个事件 应补上去查询config事件 + return $res; + }catch (\Exception $exception){ + Db::rollback(); + return $res; + } + } + +}