Browse Source

feat(zhjw): 优化客户标签和地址处理

-将 customer_tags 从字符串改为数组类型
- 添加 full_address_id 字段用于存储地址 ID 数组- 在后端控制器中处理 customer_tags 的字符串与数组转换
- 更新 SalesService 中的信息获取逻辑,处理客户标签和地址 ID
master
liutong 1 year ago
parent
commit
8d8d7c4f85
  1. 3
      admin/src/addon/zhjw/views/sales/sales_edit.vue
  2. 14
      niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php
  3. 31
      niucloud/addon/zhjw/app/service/admin/sales/SalesService.php

3
admin/src/addon/zhjw/views/sales/sales_edit.vue

@ -185,7 +185,7 @@ const initialFormData = {
city_id: '',
district_id: '',
community_name: '',
customer_tags: '',
customer_tags: [],
full_address: '',
full_address_id: [],// =[130000,130300,130304]
@ -240,6 +240,7 @@ const setFormData = async (id: number = 0) => {
Object.keys(formData).forEach((key: string) => {
if (data[key] != undefined) formData[key] = data[key]
})
formData.full_address_id = [Number(formData.province_id), Number(formData.city_id), Number(formData.district_id)]
}
if (id) setFormData(id);

14
niucloud/addon/zhjw/app/adminapi/controller/sales/Sales.php

@ -81,9 +81,14 @@ class Sales extends BaseAdminController
["city_id",0],
["district_id",0],
["community_name",""],
["customer_tags",""],
["customer_tags",[]],
]);
if(!empty($data['customer_tags'])){
$data['customer_tags'] = implode(',',$data['customer_tags']);
}
$this->validate($data, 'addon\zhjw\app\validate\sales\Sales.add');
$id = (new SalesService())->add($data);
return success('ADD_SUCCESS', ['id' => $id]);
@ -112,9 +117,14 @@ class Sales extends BaseAdminController
["city_id",0],
["district_id",0],
["community_name",""],
["customer_tags",""],
["customer_tags",[]],
]);
if(!empty($data['customer_tags'])){
$data['customer_tags'] = implode(',',$data['customer_tags']);
}
$this->validate($data, 'addon\zhjw\app\validate\sales\Sales.edit');
(new SalesService())->edit($id, $data);
return success('EDIT_SUCCESS');

31
niucloud/addon/zhjw/app/service/admin/sales/SalesService.php

@ -41,7 +41,7 @@ class SalesService extends BaseAdminService
$field = 'id,student_phone,student_name,sex,age,school_name,grade,class_name,source_channel,customer_source,add_staff_id,get_staff_id,contact_name,province_id,city_id,district_id,full_address,community_name,customer_tags,create_time,update_time,is_deleted,created_by,created_role,updated_by,updated_role';
$order = 'id desc';
$search_model = $this->model->withSearch(["student_phone","student_name","sex","age","school_name","grade","class_name","source_channel","customer_source","add_staff_id","get_staff_id","contact_name","province_id","city_id","district_id","community_name","customer_tags","create_time"], $where)->with(['staff','staff','sysArea','sysArea','sysArea'])->field($field)->order($order);
$search_model = $this->model->withSearch(["student_phone", "student_name", "sex", "age", "school_name", "grade", "class_name", "source_channel", "customer_source", "add_staff_id", "get_staff_id", "contact_name", "province_id", "city_id", "district_id", "community_name", "customer_tags", "create_time"], $where)->with(['staff', 'staff', 'sysArea', 'sysArea', 'sysArea'])->field($field)->order($order);
$list = $this->pageQuery($search_model);
return $list;
}
@ -55,7 +55,20 @@ class SalesService extends BaseAdminService
{
$field = 'id,student_phone,student_name,sex,age,school_name,grade,class_name,source_channel,customer_source,add_staff_id,get_staff_id,contact_name,province_id,city_id,district_id,full_address,community_name,customer_tags,create_time,update_time,is_deleted,created_by,created_role,updated_by,updated_role';
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff','staff','sysArea','sysArea','sysArea'])->findOrEmpty()->toArray();
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['staff', 'staff', 'sysArea', 'sysArea', 'sysArea'])->findOrEmpty()->toArray();
if(empty($info['customer_tags'])){
$info['customer_tags'] = [];
}else{
$info['customer_tags'] = explode(',',$info['customer_tags']);
}
if(!empty($info['province_id']) && !empty($info['city_id']) && !empty($info['district_id'])){
$info['full_address_id'] = [$info['province_id'],$info['city_id'],$info['district_id']];
}else{
$info['full_address_id'] = [];
}
return $info;
}
@ -97,15 +110,17 @@ class SalesService extends BaseAdminService
}
public function getStaffAll(){
$staffModel = new Staff();
return $staffModel->select()->toArray();
public function getStaffAll()
{
$staffModel = new Staff();
return $staffModel->select()->toArray();
}
public function getSysAreaAll(){
$sysAreaModel = new SysArea();
return $sysAreaModel->select()->toArray();
public function getSysAreaAll()
{
$sysAreaModel = new SysArea();
return $sysAreaModel->select()->toArray();
}

Loading…
Cancel
Save