From 275211cb834fe24fef08e6c4c8130f5d1094e4d0 Mon Sep 17 00:00:00 2001 From: "1213317725@qq.com" <1213317725@qq.com> Date: Sun, 18 May 2025 17:38:53 +0800 Subject: [PATCH] 1 --- admin/components.d.ts | 4 - admin/src/app/api/customer_resources.ts | 30 +- admin/src/app/api/six_speed.ts | 27 +- admin/src/app/api/sys.ts | 12 + ...customer_resources.customer_resources.json | 74 +- .../app/lang/zh-cn/six_speed.six_speed.json | 62 +- .../components/customer-resources-edit.vue | 1111 +++++++++-------- .../customer_resources/customer_resources.vue | 542 ++++---- .../six_speed/components/six-speed-edit.vue | 681 +++++----- admin/src/app/views/six_speed/six_speed.vue | 586 ++++----- .../customer_resources/CustomerResources.php | 46 +- .../controller/six_speed/SixSpeed.php | 34 +- .../app/adminapi/route/customer_resources.php | 4 + niucloud/app/adminapi/route/six_speed.php | 5 + niucloud/app/common.php | 28 + .../customer_resources/CustomerResources.php | 6 + niucloud/app/model/six_speed/SixSpeed.php | 184 +-- .../CustomerResourcesService.php | 151 ++- .../admin/six_speed/SixSpeedService.php | 16 +- niucloud/app/validate/six_speed/SixSpeed.php | 8 +- 20 files changed, 1703 insertions(+), 1908 deletions(-) diff --git a/admin/components.d.ts b/admin/components.d.ts index e5b7f07b..266a85b9 100644 --- a/admin/components.d.ts +++ b/admin/components.d.ts @@ -10,7 +10,6 @@ declare module '@vue/runtime-core' { Attachment: typeof import('./src/components/upload-attachment/attachment.vue')['default'] DiyLink: typeof import('./src/components/diy-link/index.vue')['default'] Editor: typeof import('./src/components/editor/index.vue')['default'] - ElAlert: typeof import('element-plus/es')['ElAlert'] ElAside: typeof import('element-plus/es')['ElAside'] ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] @@ -45,7 +44,6 @@ declare module '@vue/runtime-core' { ElPopover: typeof import('element-plus/es')['ElPopover'] ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] - ElResult: typeof import('element-plus/es')['ElResult'] ElRow: typeof import('element-plus/es')['ElRow'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] @@ -58,8 +56,6 @@ declare module '@vue/runtime-core' { ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] ElTag: typeof import('element-plus/es')['ElTag'] - ElTimeline: typeof import('element-plus/es')['ElTimeline'] - ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] ElTree: typeof import('element-plus/es')['ElTree'] ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect'] diff --git a/admin/src/app/api/customer_resources.ts b/admin/src/app/api/customer_resources.ts index da9d8f53..54b50473 100644 --- a/admin/src/app/api/customer_resources.ts +++ b/admin/src/app/api/customer_resources.ts @@ -1,5 +1,9 @@ import request from '@/utils/request' + + + + // USER_CODE_BEGIN -- customer_resources /** * 获取客户资源列表 @@ -7,7 +11,7 @@ import request from '@/utils/request' * @returns */ export function getCustomerResourcesList(params: Record) { - return request.get(`customer_resources/customer_resources`, { params }) + return request.get(`customer_resources/customer_resources`, {params}) } /** @@ -16,7 +20,7 @@ export function getCustomerResourcesList(params: Record) { * @returns */ export function getCustomerResourcesInfo(id: number) { - return request.get(`customer_resources/customer_resources/${id}`) + return request.get(`customer_resources/customer_resources/${id}`); } /** @@ -25,10 +29,7 @@ export function getCustomerResourcesInfo(id: number) { * @returns */ export function addCustomerResources(params: Record) { - return request.post('customer_resources/customer_resources', params, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.post('customer_resources/customer_resources', params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -38,11 +39,7 @@ export function addCustomerResources(params: Record) { * @returns */ export function editCustomerResources(params: Record) { - return request.put( - `customer_resources/customer_resources/${params.id}`, - params, - { showErrorMessage: true, showSuccessMessage: true } - ) + return request.put(`customer_resources/customer_resources/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -51,14 +48,13 @@ export function editCustomerResources(params: Record) { * @returns */ export function deleteCustomerResources(id: number) { - return request.delete(`customer_resources/customer_resources/${id}`, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.delete(`customer_resources/customer_resources/${id}`, { showErrorMessage: true, showSuccessMessage: true }) } -export function getWithCampusList(params: Record) { - return request.get('customer_resources/campus_all', { params }) +export function getWithPersonnelList(params: Record){ + return request.get('customer_resources/personnel_all', {params}) +}export function getWithCampusList(params: Record){ + return request.get('customer_resources/campus_all', {params}) } // USER_CODE_END -- customer_resources diff --git a/admin/src/app/api/six_speed.ts b/admin/src/app/api/six_speed.ts index 46a63f72..05791561 100644 --- a/admin/src/app/api/six_speed.ts +++ b/admin/src/app/api/six_speed.ts @@ -1,5 +1,7 @@ import request from '@/utils/request' + + // USER_CODE_BEGIN -- six_speed /** * 获取六一速列表 @@ -7,7 +9,7 @@ import request from '@/utils/request' * @returns */ export function getSixSpeedList(params: Record) { - return request.get(`six_speed/six_speed`, { params }) + return request.get(`six_speed/six_speed`, {params}) } /** @@ -16,7 +18,7 @@ export function getSixSpeedList(params: Record) { * @returns */ export function getSixSpeedInfo(id: number) { - return request.get(`six_speed/six_speed/${id}`) + return request.get(`six_speed/six_speed/${id}`); } /** @@ -25,10 +27,7 @@ export function getSixSpeedInfo(id: number) { * @returns */ export function addSixSpeed(params: Record) { - return request.post('six_speed/six_speed', params, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.post('six_speed/six_speed', params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -38,10 +37,7 @@ export function addSixSpeed(params: Record) { * @returns */ export function editSixSpeed(params: Record) { - return request.put(`six_speed/six_speed/${params.id}`, params, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.put(`six_speed/six_speed/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) } /** @@ -50,10 +46,13 @@ export function editSixSpeed(params: Record) { * @returns */ export function deleteSixSpeed(id: number) { - return request.delete(`six_speed/six_speed/${id}`, { - showErrorMessage: true, - showSuccessMessage: true, - }) + return request.delete(`six_speed/six_speed/${id}`, { showErrorMessage: true, showSuccessMessage: true }) +} + +export function getWithPersonnelList(params: Record){ + return request.get('six_speed/personnel_all', {params}) +}export function getWithCustomerResourcesList(params: Record){ + return request.get('six_speed/customer_resources_all', {params}) } // USER_CODE_END -- six_speed diff --git a/admin/src/app/api/sys.ts b/admin/src/app/api/sys.ts index 285cc133..2ae8b5b0 100644 --- a/admin/src/app/api/sys.ts +++ b/admin/src/app/api/sys.ts @@ -720,3 +720,15 @@ export function deleteExport(id: number) { export function getInstallConfig() { return request.get('sys/install/config') } + + + +//业绩配置 + +export function getYjpzConfig() { + return request.get('sys/get_yjpz_config') +} + +export function yjpzConfig(params: Record) { + return request.post(`sys/yjpz_config`, params) +} diff --git a/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json b/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json index 1a539222..57befe1e 100644 --- a/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json +++ b/admin/src/app/lang/zh-cn/customer_resources.customer_resources.json @@ -1,38 +1,38 @@ { - "source": "来源", - "sourcePlaceholder": "请输入来源", - "sourceChannel": "来源渠道", - "sourceChannelPlaceholder": "请输入来源渠道", - "consultant": "顾问", - "name": "姓名", - "namePlaceholder": "请输入姓名", - "age": "年龄", - "agePlaceholder": "请输入年龄", - "gender": "性别", - "genderPlaceholder": "请输入性别", - "phoneNumber": "联系电话", - "phoneNumberPlaceholder": "请输入联系电话", - "demand": "需求", - "demandPlaceholder": "请输入需求", - "purchasingPower": "购买力", - "purchasingPowerPlaceholder": "请输入购买力", - "cognitiveIdea": "认知理念", - "cognitiveIdeaPlaceholder": "请输入认知理念", - "optionalClassTime": "可选上课时间", - "optionalClassTimePlaceholder": "请输入可选上课时间", - "distance": "距离", - "distancePlaceholder": "请输入距离", - "decisionMaker": "决策人", - "decisionMakerPlaceholder": "请输入决策人", - "initialIntent": "客户初步意向度", - "initialIntentPlaceholder": "请输入客户初步意向度", - "campus": "所属校区", - "campusPlaceholder": "请输入所属校区", - "status": "客户状态", - "statusPlaceholder": "请输入客户状态", - "addCustomerResources": "添加客户资源", - "updateCustomerResources": "编辑客户资源", - "customerResourcesDeleteTips": "确定要删除该数据吗?", - "startDate": "请选择开始时间", - "endDate": "请选择结束时间" -} + "source":"来源", + "sourcePlaceholder":"请输入来源", + "sourceChannel":"来源渠道", + "sourceChannelPlaceholder":"请输入来源渠道", + "consultant":"顾问", + "name":"姓名", + "namePlaceholder":"请输入姓名", + "age":"年龄", + "agePlaceholder":"请输入年龄", + "gender":"性别", + "genderPlaceholder":"请输入性别", + "phoneNumber":"联系电话", + "phoneNumberPlaceholder":"请输入联系电话", + "demand":"需求", + "demandPlaceholder":"请输入需求", + "purchasingPower":"购买力", + "purchasingPowerPlaceholder":"请输入购买力", + "cognitiveIdea":"认知理念", + "cognitiveIdeaPlaceholder":"请输入认知理念", + "optionalClassTime":"可选上课时间", + "optionalClassTimePlaceholder":"请输入可选上课时间", + "distance":"距离", + "distancePlaceholder":"请输入距离", + "decisionMaker":"决策人", + "decisionMakerPlaceholder":"请输入决策人", + "initialIntent":"客户初步意向度", + "initialIntentPlaceholder":"请输入客户初步意向度", + "campus":"所属校区", + "campusPlaceholder":"请输入所属校区", + "status":"客户状态", + "statusPlaceholder":"请输入客户状态", + "addCustomerResources":"添加客户资源", + "updateCustomerResources":"编辑客户资源", + "customerResourcesDeleteTips":"确定要删除该数据吗?", + "startDate":"请选择开始时间", + "endDate":"请选择结束时间" +} \ No newline at end of file diff --git a/admin/src/app/lang/zh-cn/six_speed.six_speed.json b/admin/src/app/lang/zh-cn/six_speed.six_speed.json index ad597a10..07515f52 100644 --- a/admin/src/app/lang/zh-cn/six_speed.six_speed.json +++ b/admin/src/app/lang/zh-cn/six_speed.six_speed.json @@ -1,35 +1,29 @@ { - "id": "编号", - "idPlaceholder": "请输入编号", - "purchasePower": "需求购买力", - "purchasePowerPlaceholder": "请输入需求购买力", - "conceptAwareness": "认知理念", - "conceptAwarenessPlaceholder": "请输入认知理念", - "preferredClassTime": "可选上课时间", - "preferredClassTimePlaceholder": "请输入可选上课时间", - "distance": "距离", - "distancePlaceholder": "请输入距离", - "communication": "沟通备注", - "communicationPlaceholder": "请输入沟通备注", - "promisedVisitTime": "承诺到访时间", - "promisedVisitTimePlaceholder": "请输入承诺到访时间", - "actualVisitTime": "实际到访时间", - "actualVisitTimePlaceholder": "请输入实际到访时间", - "callIntent": "电话后的意向程度: low-低, medium-中, high-高", - "callIntentPlaceholder": "请输入电话后的意向程度: low-低, medium-中, high-高", - "firstVisitStatus": "一访情况", - "firstVisitStatusPlaceholder": "请输入一访情况", - "secondVisitStatus": "二访情况", - "secondVisitStatusPlaceholder": "请输入二访情况", - "isClosed": "是否关单: 1-是, 0-否", - "isClosedPlaceholder": "请输入是否关单: 1-是, 0-否", - "staffId": "人员ID", - "staffIdPlaceholder": "请输入人员ID", - "resourceId": "资源ID", - "resourceIdPlaceholder": "请输入资源ID", - "addSixSpeed": "添加六一速", - "updateSixSpeed": "编辑六一速", - "sixSpeedDeleteTips": "确定要删除该数据吗?", - "startDate": "请选择开始时间", - "endDate": "请选择结束时间" -} + "purchasePower":"需求购买力", + "purchasePowerPlaceholder":"请输入需求购买力", + "conceptAwareness":"认知理念", + "conceptAwarenessPlaceholder":"请输入认知理念", + "preferredClassTime":"可选上课时间", + "preferredClassTimePlaceholder":"请输入可选上课时间", + "distance":"距离", + "distancePlaceholder":"请输入距离", + "communication":"沟通备注", + "communicationPlaceholder":"请输入沟通备注", + "promisedVisitTime":"承诺到访时间", + "promisedVisitTimePlaceholder":"请输入承诺到访时间", + "actualVisitTime":"实际到访时间", + "actualVisitTimePlaceholder":"请输入实际到访时间", + "callIntent":"电话后的意向程度", + "callIntentPlaceholder":"请输入电话后的意向程度", + "firstVisitStatus":"一访情况", + "firstVisitStatusPlaceholder":"请输入一访情况", + "secondVisitStatus":"二访情况", + "secondVisitStatusPlaceholder":"请输入二访情况", + "isClosed":"是否关单", + "isClosedPlaceholder":"请输入是否关单", + "addSixSpeed":"添加六一速", + "updateSixSpeed":"编辑六一速", + "sixSpeedDeleteTips":"确定要删除该数据吗?", + "startDate":"请选择开始时间", + "endDate":"请选择结束时间" +} \ No newline at end of file diff --git a/admin/src/app/views/customer_resources/components/customer-resources-edit.vue b/admin/src/app/views/customer_resources/components/customer-resources-edit.vue index 8ba98fce..2b9beb29 100644 --- a/admin/src/app/views/customer_resources/components/customer-resources-edit.vue +++ b/admin/src/app/views/customer_resources/components/customer-resources-edit.vue @@ -1,553 +1,574 @@ + .diy-dialog-wrap .el-form-item__label { + height: auto !important; + } + \ No newline at end of file diff --git a/admin/src/app/views/customer_resources/customer_resources.vue b/admin/src/app/views/customer_resources/customer_resources.vue index 834d68a9..047a83c0 100644 --- a/admin/src/app/views/customer_resources/customer_resources.vue +++ b/admin/src/app/views/customer_resources/customer_resources.vue @@ -1,311 +1,231 @@ - - - - - + + + + + diff --git a/admin/src/app/views/six_speed/components/six-speed-edit.vue b/admin/src/app/views/six_speed/components/six-speed-edit.vue index 6981866c..85cd6e1a 100644 --- a/admin/src/app/views/six_speed/components/six-speed-edit.vue +++ b/admin/src/app/views/six_speed/components/six-speed-edit.vue @@ -1,358 +1,323 @@ - - - - - - + + + + + + diff --git a/admin/src/app/views/six_speed/six_speed.vue b/admin/src/app/views/six_speed/six_speed.vue index a1401496..1ac9bf8c 100644 --- a/admin/src/app/views/six_speed/six_speed.vue +++ b/admin/src/app/views/six_speed/six_speed.vue @@ -1,372 +1,214 @@ - - - - - + + + + + diff --git a/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php b/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php index 9ec70666..f9152768 100644 --- a/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php +++ b/niucloud/app/adminapi/controller/customer_resources/CustomerResources.php @@ -64,13 +64,23 @@ class CustomerResources extends BaseAdminController ["initial_intent",""], ["campus",""], ["status",""], - ["create_year_month",date("Y-m")], - ["create_date",date("Y-m-d")] - ]); + ["create_year_month",date("Y-m")], + ["create_date",date("Y-m-d")], + ["purchase_power",""], + ["concept_awareness",""], + ["preferred_class_time",""], + ["distance_tow",""], + ["communication",""], + ["promised_visit_time",""], + ["actual_visit_time",""], + ["call_intent",""], + ["first_visit_status",""], + ["second_visit_status",""], + ["is_closed",""] + ]); $this->validate($data, 'app\validate\customer_resources\CustomerResources.add'); - $id = (new CustomerResourcesService())->add($data); - return success('ADD_SUCCESS', ['id' => $id]); + return (new CustomerResourcesService())->add($data); } /** @@ -94,11 +104,27 @@ class CustomerResources extends BaseAdminController ["decision_maker",""], ["initial_intent",""], ["campus",""], - ["status",""] + ["status",""], + ["create_year_month",date("Y-m")], + ["create_date",date("Y-m-d")], + + ["purchase_power",""], + ["concept_awareness",""], + ["preferred_class_time",""], + ["distance_tow",""], + ["communication",""], + ["promised_visit_time",""], + ["actual_visit_time",""], + ["call_intent",""], + ["first_visit_status",""], + ["second_visit_status",""], + ["is_closed",""] + + ]); $this->validate($data, 'app\validate\customer_resources\CustomerResources.edit'); - (new CustomerResourcesService())->edit($id, $data); - return success('EDIT_SUCCESS'); + + return (new CustomerResourcesService())->edit($id, $data); } /** @@ -112,6 +138,10 @@ class CustomerResources extends BaseAdminController } + public function getPersonnelAll(){ + return success(( new CustomerResourcesService())->getPersonnelAll()); + } + public function getCampusAll(){ return success(( new CustomerResourcesService())->getCampusAll()); } diff --git a/niucloud/app/adminapi/controller/six_speed/SixSpeed.php b/niucloud/app/adminapi/controller/six_speed/SixSpeed.php index c034d5b7..6a3164b3 100644 --- a/niucloud/app/adminapi/controller/six_speed/SixSpeed.php +++ b/niucloud/app/adminapi/controller/six_speed/SixSpeed.php @@ -28,19 +28,7 @@ class SixSpeed extends BaseAdminController */ public function lists(){ $data = $this->request->params([ - ["purchase_power",""], - ["concept_awareness",""], - ["preferred_class_time",""], - ["distance",""], - ["communication",""], - ["promised_visit_time",""], - ["actual_visit_time",""], - ["call_intent",""], - ["first_visit_status",""], - ["second_visit_status",""], - ["is_closed",""], - ["staff_id",""], - ["resource_id",""] + ]); return success((new SixSpeedService())->getPage($data)); } @@ -65,14 +53,12 @@ class SixSpeed extends BaseAdminController ["preferred_class_time",""], ["distance",""], ["communication",""], - ["promised_visit_time","2025-05-16 17:57:14"], - ["actual_visit_time","2025-05-16 17:57:14"], + ["promised_visit_time","2025-05-18 16:21:59"], + ["actual_visit_time","2025-05-18 16:21:59"], ["call_intent",""], ["first_visit_status",""], ["second_visit_status",""], ["is_closed",0], - ["staff_id",0], - ["resource_id",0], ]); $this->validate($data, 'app\validate\six_speed\SixSpeed.add'); @@ -92,14 +78,12 @@ class SixSpeed extends BaseAdminController ["preferred_class_time",""], ["distance",""], ["communication",""], - ["promised_visit_time","2025-05-16 17:57:14"], - ["actual_visit_time","2025-05-16 17:57:14"], + ["promised_visit_time","2025-05-18 16:21:59"], + ["actual_visit_time","2025-05-18 16:21:59"], ["call_intent",""], ["first_visit_status",""], ["second_visit_status",""], ["is_closed",0], - ["staff_id",0], - ["resource_id",0], ]); $this->validate($data, 'app\validate\six_speed\SixSpeed.edit'); @@ -118,4 +102,12 @@ class SixSpeed extends BaseAdminController } + public function getPersonnelAll(){ + return success(( new SixSpeedService())->getPersonnelAll()); + } + + public function getCustomerResourcesAll(){ + return success(( new SixSpeedService())->getCustomerResourcesAll()); + } + } diff --git a/niucloud/app/adminapi/route/customer_resources.php b/niucloud/app/adminapi/route/customer_resources.php index b612a5b3..7dc8c08a 100644 --- a/niucloud/app/adminapi/route/customer_resources.php +++ b/niucloud/app/adminapi/route/customer_resources.php @@ -18,6 +18,8 @@ use app\adminapi\middleware\AdminLog; + + // USER_CODE_BEGIN -- customer_resources Route::group('customer_resources', function () { @@ -33,6 +35,8 @@ Route::group('customer_resources', function () { //删除客户资源 Route::delete('customer_resources/:id', 'customer_resources.CustomerResources/del'); + Route::get('personnel_all','customer_resources.CustomerResources/getPersonnelAll'); + Route::get('campus_all','customer_resources.CustomerResources/getCampusAll'); })->middleware([ diff --git a/niucloud/app/adminapi/route/six_speed.php b/niucloud/app/adminapi/route/six_speed.php index 6d721f88..d84effe4 100644 --- a/niucloud/app/adminapi/route/six_speed.php +++ b/niucloud/app/adminapi/route/six_speed.php @@ -14,6 +14,7 @@ use think\facade\Route; use app\adminapi\middleware\AdminCheckRole; use app\adminapi\middleware\AdminCheckToken; use app\adminapi\middleware\AdminLog; + // USER_CODE_BEGIN -- six_speed Route::group('six_speed', function () { @@ -29,6 +30,10 @@ Route::group('six_speed', function () { //删除六一速 Route::delete('six_speed/:id', 'six_speed.SixSpeed/del'); + Route::get('personnel_all','six_speed.SixSpeed/getPersonnelAll'); + + Route::get('customer_resources_all','six_speed.SixSpeed/getCustomerResourcesAll'); + })->middleware([ AdminCheckToken::class, AdminCheckRole::class, diff --git a/niucloud/app/common.php b/niucloud/app/common.php index 9abd2ef5..dbcc248f 100644 --- a/niucloud/app/common.php +++ b/niucloud/app/common.php @@ -1046,3 +1046,31 @@ function get_campus_where($user_id){ return $where; } + + +function getModifiedFields(array $oldData, array $newData): array +{ + $modifiedFields = []; + $oldValues = []; + $newValues = []; + + foreach ($newData as $key => $newValue) { + + if (!array_key_exists($key, $oldData)) { + continue; + } + + if ($oldData[$key] != $newValue) { + $modifiedFields[] = $key; + $oldValues[$key] = $oldData[$key]; + $newValues[$key] = $newValue; + } + } + + return [ + 'is_save' => !empty($modifiedFields), + 'modified_fields' => json_encode($modifiedFields, JSON_UNESCAPED_UNICODE), + 'old_values' => json_encode($oldValues, JSON_UNESCAPED_UNICODE), + 'new_values' => json_encode($newValues, JSON_UNESCAPED_UNICODE), + ]; +} diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index b173fe90..c9e00e87 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/niucloud/app/model/customer_resources/CustomerResources.php @@ -16,6 +16,8 @@ use think\model\concern\SoftDelete; use think\model\relation\HasMany; use think\model\relation\HasOne; +use app\model\personnel\Personnel; + use app\model\campus\Campus; /** @@ -81,6 +83,10 @@ class CustomerResources extends BaseModel + public function personnel(){ + return $this->hasOne(Personnel::class, 'id', 'consultant')->joinType('left')->withField('name,id')->bind(['consultant_name'=>'name']); + } + public function campus(){ return $this->hasOne(Campus::class, 'id', 'campus')->joinType('left')->withField('campus_name,id')->bind(['campus_name'=>'campus_name']); } diff --git a/niucloud/app/model/six_speed/SixSpeed.php b/niucloud/app/model/six_speed/SixSpeed.php index d6d35c34..8a5c83fe 100644 --- a/niucloud/app/model/six_speed/SixSpeed.php +++ b/niucloud/app/model/six_speed/SixSpeed.php @@ -16,6 +16,10 @@ use think\model\concern\SoftDelete; use think\model\relation\HasMany; use think\model\relation\HasOne; +use app\model\personnel\Personnel; + +use app\model\customer_resources\CustomerResources; + /** * 六一速模型 * Class SixSpeed @@ -50,177 +54,17 @@ class SixSpeed extends BaseModel */ protected $defaultSoftDelete = 0; - /** - * 搜索器:六一速编号 - * @param $value - * @param $data - */ - public function searchIdAttr($query, $value, $data) - { - if ($value) { - $query->where("id", $value); - } - } - - /** - * 搜索器:六一速需求购买力 - * @param $value - * @param $data - */ - public function searchPurchasePowerAttr($query, $value, $data) - { - if ($value) { - $query->where("purchase_power", $value); - } - } - - /** - * 搜索器:六一速认知理念 - * @param $value - * @param $data - */ - public function searchConceptAwarenessAttr($query, $value, $data) - { - if ($value) { - $query->where("concept_awareness", $value); - } - } - - /** - * 搜索器:六一速可选上课时间 - * @param $value - * @param $data - */ - public function searchPreferredClassTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("preferred_class_time", $value); - } - } - - /** - * 搜索器:六一速距离 - * @param $value - * @param $data - */ - public function searchDistanceAttr($query, $value, $data) - { - if ($value) { - $query->where("distance", $value); - } - } - - /** - * 搜索器:六一速沟通备注 - * @param $value - * @param $data - */ - public function searchCommunicationAttr($query, $value, $data) - { - if ($value) { - $query->where("communication", $value); - } - } - - /** - * 搜索器:六一速承诺到访时间 - * @param $value - * @param $data - */ - public function searchPromisedVisitTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("promised_visit_time", $value); - } - } - - /** - * 搜索器:六一速实际到访时间 - * @param $value - * @param $data - */ - public function searchActualVisitTimeAttr($query, $value, $data) - { - if ($value) { - $query->where("actual_visit_time", $value); - } - } - - /** - * 搜索器:六一速电话后的意向程度: low-低, medium-中, high-高 - * @param $value - * @param $data - */ - public function searchCallIntentAttr($query, $value, $data) - { - if ($value) { - $query->where("call_intent", $value); - } - } - - /** - * 搜索器:六一速一访情况 - * @param $value - * @param $data - */ - public function searchFirstVisitStatusAttr($query, $value, $data) - { - if ($value) { - $query->where("first_visit_status", $value); - } - } - - /** - * 搜索器:六一速二访情况 - * @param $value - * @param $data - */ - public function searchSecondVisitStatusAttr($query, $value, $data) - { - if ($value) { - $query->where("second_visit_status", $value); - } - } - - /** - * 搜索器:六一速是否关单: 1-是, 0-否 - * @param $value - * @param $data - */ - public function searchIsClosedAttr($query, $value, $data) - { - if ($value) { - $query->where("is_closed", $value); - } - } - - /** - * 搜索器:六一速人员ID - * @param $value - * @param $data - */ - public function searchStaffIdAttr($query, $value, $data) - { - if ($value) { - $query->where("staff_id", $value); - } - } - - /** - * 搜索器:六一速资源ID - * @param $value - * @param $data - */ - public function searchResourceIdAttr($query, $value, $data) - { - if ($value) { - $query->where("resource_id", $value); - } + + + + + + public function personnel(){ + return $this->hasOne(Personnel::class, 'id', 'staff_id')->joinType('left')->withField('name,id')->bind(['staff_id_name'=>'name']); } - - - + public function customerResources(){ + return $this->hasOne(CustomerResources::class, 'id', 'resource_id')->joinType('left')->withField('name,id')->bind(['resource_id_name'=>'name']); + } - } diff --git a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php index d66b5c8a..7d82ed54 100644 --- a/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php +++ b/niucloud/app/service/admin/customer_resources/CustomerResourcesService.php @@ -11,9 +11,13 @@ namespace app\service\admin\customer_resources; +use app\model\customer_resource_changes\CustomerResourceChanges; use app\model\customer_resources\CustomerResources; +use app\model\personnel\Personnel; use app\model\campus\Campus; +use app\model\six_speed\SixSpeed; +use app\model\six_speed_modification_log\SixSpeedModificationLog; use core\base\BaseAdminService; @@ -40,7 +44,7 @@ class CustomerResourcesService extends BaseAdminService $field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status'; $order = 'id desc'; - $search_model = $this->model->where(get_campus_where($this->uid))->withSearch(["name","phone_number"], $where)->with(['campus'])->field($field)->order($order); + $search_model = $this->model->withSearch(["name","phone_number"], $where)->with(['personnel'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } @@ -54,7 +58,12 @@ class CustomerResourcesService extends BaseAdminService { $field = 'id,create_year_month,create_date,source,source_channel,consultant,name,age,gender,phone_number,demand,purchasing_power,cognitive_idea,optional_class_time,distance,decision_maker,initial_intent,campus,created_at,updated_at,deleted_at,status'; - $info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray(); + $info = $this->model->field($field)->where([['id', "=", $id]])->with(['personnel'])->findOrEmpty()->toArray(); + + $sixSpeed = new SixSpeed(); + $data = $sixSpeed->where(['resource_id' => $id])->field("*,distance as distance_tow")->findOrEmpty()->toArray(); + $info = $info+$data; + return $info; } @@ -65,9 +74,41 @@ class CustomerResourcesService extends BaseAdminService */ public function add(array $data) { - $data['consultant'] = $this->username; + $personnel = new Personnel(); + $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); + if(!$data['consultant']){ + return fail("操作失败"); + } + $sixSpeed = new SixSpeed(); + $res = $this->model->create($data); - return $res->id; + + if($data['purchase_power']){ + $six_id = $sixSpeed->where(['resource_id' => $res->id])->value("id"); + $data['staff_id'] = $data['consultant']; + + $field = [ + 'purchase_power' => $data['purchase_power'], + 'concept_awareness' => $data['concept_awareness'], + 'preferred_class_time' => $data['preferred_class_time'], + 'distance' => $data['distance_tow'], + 'communication' => $data['communication'], + 'promised_visit_time' => $data['promised_visit_time'], + 'actual_visit_time' => $data['actual_visit_time'], + 'call_intent' => $data['call_intent'], + 'first_visit_status' => $data['first_visit_status'], + 'second_visit_status' => $data['second_visit_status'], + 'is_closed' => $data['is_closed'], + 'staff_id' => $data['staff_id'], + 'resource_id' => $res->id + ]; + if($six_id){ + $sixSpeed->where(['resource_id' => $res->id])->update($field); + }else{ + $sixSpeed->insert($field); + } + } + return success("操作成功"); } @@ -75,14 +116,101 @@ class CustomerResourcesService extends BaseAdminService * 客户资源编辑 * @param int $id * @param array $data - * @return bool */ public function edit(int $id, array $data) { - - $data['consultant'] = $this->username; - $this->model->where([['id', '=', $id]])->update($data); - return true; + $personnel = new Personnel(); +// $data['consultant'] = $personnel->where(['sys_user_id' => $this->uid])->value("id"); +// if(!$data['consultant']){ +// return fail("操作失败"); +// } + + $data['consultant'] = 1; + $res = $this->model->where([['id', '=', $id]])->findOrEmpty()->toArray(); + + + $this->model->where([['id', '=', $id]])->update([ + 'source' => $data['source'], + 'source_channel' => $data['source_channel'], + 'consultant' => $data['consultant'], + 'name' => $data['name'], + 'age' => $data['age'], + 'gender' => $data['gender'], + 'phone_number' => $data['phone_number'], + 'demand' => $data['demand'], + 'purchasing_power' => $data['purchasing_power'], + 'cognitive_idea' => $data['cognitive_idea'], + 'optional_class_time' => $data['optional_class_time'], + 'distance' => $data['distance'], + 'decision_maker' => $data['decision_maker'], + 'initial_intent' => $data['initial_intent'], + 'campus' => $data['campus'], + 'status' => $data['status'], + 'create_year_month' => $data['create_year_month'], + 'create_date' => $data['create_date'] + ]); + + $resources_save = getModifiedFields($res,$data); + + $customerResourceChanges = new CustomerResourceChanges(); + if($resources_save['is_save']){ + $customerResourceChanges->insert([ + 'customer_resource_id' => $id, + 'operator_id' => $data['consultant'], + 'campus_id' => $data['campus'], + 'modified_fields' => $resources_save['modified_fields'], + 'old_values' => $resources_save['old_values'], + 'new_values' => $resources_save['new_values'] + ]); + } + + + $sixSpeed = new SixSpeed(); + if($data['purchase_power']){ + $sixSpeedModificationLog = new SixSpeedModificationLog(); + $six_id = $sixSpeed->where(['resource_id' => $id])->value("id"); + $data['staff_id'] = $data['consultant']; + + + + $field = [ + 'purchase_power' => $data['purchase_power'], + 'concept_awareness' => $data['concept_awareness'], + 'preferred_class_time' => $data['preferred_class_time'], + 'distance' => $data['distance_tow'], + 'communication' => $data['communication'], + 'promised_visit_time' => $data['promised_visit_time'], + 'actual_visit_time' => $data['actual_visit_time'], + 'call_intent' => $data['call_intent'], + 'first_visit_status' => $data['first_visit_status'], + 'second_visit_status' => $data['second_visit_status'], + 'is_closed' => $data['is_closed'], + 'staff_id' => $data['staff_id'], + 'resource_id' => $id + ]; + if($six_id){ + $six_log = $sixSpeed->where(['resource_id' => $id])->findOrEmpty()->toArray(); + $six_save = getModifiedFields($six_log,$field); + + if($six_save['is_save']){ + + $sixSpeedModificationLog->insert([ + 'customer_resource_id' => $id, + 'operator_id' => $data['consultant'], + 'campus_id' => $data['campus'], + 'modified_field' => $six_save['modified_fields'], + 'old_value' => $six_save['old_values'], + 'new_value' => $six_save['new_values'] + ]); + } + + $sixSpeed->where(['resource_id' => $id])->update($field); + }else{ + $sixSpeed->insert($field); + } + } + + return success("操作成功"); } /** @@ -98,6 +226,11 @@ class CustomerResourcesService extends BaseAdminService } + public function getPersonnelAll(){ + $personnelModel = new Personnel(); + return $personnelModel->select()->toArray(); + } + public function getCampusAll(){ $campusModel = new Campus(); return $campusModel->select()->toArray(); diff --git a/niucloud/app/service/admin/six_speed/SixSpeedService.php b/niucloud/app/service/admin/six_speed/SixSpeedService.php index 3797b679..8e6c224f 100644 --- a/niucloud/app/service/admin/six_speed/SixSpeedService.php +++ b/niucloud/app/service/admin/six_speed/SixSpeedService.php @@ -12,6 +12,8 @@ namespace app\service\admin\six_speed; use app\model\six_speed\SixSpeed; +use app\model\personnel\Personnel; +use app\model\customer_resources\CustomerResources; use core\base\BaseAdminService; @@ -39,7 +41,7 @@ class SixSpeedService extends BaseAdminService $field = 'id,purchase_power,concept_awareness,preferred_class_time,distance,communication,promised_visit_time,actual_visit_time,call_intent,first_visit_status,second_visit_status,is_closed,staff_id,resource_id,created_at,updated_at,deleted_at'; $order = 'id desc'; - $search_model = $this->model->withSearch(["id","purchase_power","concept_awareness","preferred_class_time","distance","communication","promised_visit_time","actual_visit_time","call_intent","first_visit_status","second_visit_status","is_closed","staff_id","resource_id"], $where)->field($field)->order($order); + $search_model = $this->model->withSearch([], $where)->with(['personnel','customerResources'])->field($field)->order($order); $list = $this->pageQuery($search_model); return $list; } @@ -53,7 +55,7 @@ class SixSpeedService extends BaseAdminService { $field = 'id,purchase_power,concept_awareness,preferred_class_time,distance,communication,promised_visit_time,actual_visit_time,call_intent,first_visit_status,second_visit_status,is_closed,staff_id,resource_id,created_at,updated_at,deleted_at'; - $info = $this->model->field($field)->where([['id', "=", $id]])->findOrEmpty()->toArray(); + $info = $this->model->field($field)->where([['id', "=", $id]])->with(['personnel','customerResources'])->findOrEmpty()->toArray(); return $info; } @@ -95,5 +97,15 @@ class SixSpeedService extends BaseAdminService } + public function getPersonnelAll(){ + $personnelModel = new Personnel(); + return $personnelModel->select()->toArray(); + } + + public function getCustomerResourcesAll(){ + $customerResourcesModel = new CustomerResources(); + return $customerResourcesModel->select()->toArray(); + } + } diff --git a/niucloud/app/validate/six_speed/SixSpeed.php b/niucloud/app/validate/six_speed/SixSpeed.php index 73ae076f..3f636e9b 100644 --- a/niucloud/app/validate/six_speed/SixSpeed.php +++ b/niucloud/app/validate/six_speed/SixSpeed.php @@ -28,8 +28,6 @@ class SixSpeed extends BaseValidate 'promised_visit_time' => 'require', 'call_intent' => 'require', 'is_closed' => 'require', - 'staff_id' => 'require', - 'resource_id' => 'require', ]; protected $message = [ @@ -41,13 +39,11 @@ class SixSpeed extends BaseValidate 'promised_visit_time.require' => ['common_validate.require', ['promised_visit_time']], 'call_intent.require' => ['common_validate.require', ['call_intent']], 'is_closed.require' => ['common_validate.require', ['is_closed']], - 'staff_id.require' => ['common_validate.require', ['staff_id']], - 'resource_id.require' => ['common_validate.require', ['resource_id']], ]; protected $scene = [ - "add" => ['purchase_power', 'concept_awareness', 'preferred_class_time', 'distance', 'communication', 'promised_visit_time', 'actual_visit_time', 'call_intent', 'first_visit_status', 'second_visit_status', 'is_closed', 'staff_id', 'resource_id'], - "edit" => ['purchase_power', 'concept_awareness', 'preferred_class_time', 'distance', 'communication', 'promised_visit_time', 'actual_visit_time', 'call_intent', 'first_visit_status', 'second_visit_status', 'is_closed', 'staff_id', 'resource_id'] + "add" => ['purchase_power', 'concept_awareness', 'preferred_class_time', 'distance', 'communication', 'promised_visit_time', 'actual_visit_time', 'call_intent', 'first_visit_status', 'second_visit_status', 'is_closed'], + "edit" => ['purchase_power', 'concept_awareness', 'preferred_class_time', 'distance', 'communication', 'promised_visit_time', 'actual_visit_time', 'call_intent', 'first_visit_status', 'second_visit_status', 'is_closed'] ]; }