Browse Source

feat(ResourceSharing): 增加客户资源共享筛选功能

- 在 ResourceSharing 控制器中添加了 name 和 phone_number 参数
- 在 CustomerResources 模型中添加了 member_id 字段
- 在 ResourceSharingService 服务中实现了根据客户姓名和手机号筛选资源共享记录的功能
master
liutong 10 months ago
parent
commit
3b91a6f78b
  1. 7
      niucloud/app/api/controller/apiController/ResourceSharing.php
  2. 3
      niucloud/app/model/customer_resources/CustomerResources.php
  3. 18
      niucloud/app/service/api/apiService/ResourceSharingService.php

7
niucloud/app/api/controller/apiController/ResourceSharing.php

@ -28,9 +28,10 @@ class ResourceSharing extends BaseApiService
{ {
$user_id = $this->member_id;//当前登陆的用户id $user_id = $this->member_id;//当前登陆的用户id
$page = $request->param('page','1');//
$limit = $request->param('limit','10');//
$shared_by = $request->param('shared_by','');//共享人ID $shared_by = $request->param('shared_by','');//共享人ID
$name = $request->param('name','');////客户资源表-姓名
$phone_number = $request->param('phone_number','');//客户资源表-手机号
$shared_at_str = $request->param('shared_at_str','');//共享时间|[开始时间(Y-m-d),结束时间(Y-m-d)] $shared_at_str = $request->param('shared_at_str','');//共享时间|[开始时间(Y-m-d),结束时间(Y-m-d)]
$shared_at_arr = []; $shared_at_arr = [];
if(!empty($shared_at_str)){ if(!empty($shared_at_str)){
@ -42,6 +43,8 @@ class ResourceSharing extends BaseApiService
$where = [ $where = [
'shared_by'=>$shared_by, 'shared_by'=>$shared_by,
'shared_at_arr'=>$shared_at_arr, 'shared_at_arr'=>$shared_at_arr,
'name'=>$name,
'phone_number'=>$phone_number,
]; ];
$res= (new ResourceSharingService())->getList($where); $res= (new ResourceSharingService())->getList($where);
return success($res); return success($res);

3
niucloud/app/model/customer_resources/CustomerResources.php

@ -89,7 +89,8 @@ class CustomerResources extends BaseModel
'updated_at' => '更新时间', 'updated_at' => '更新时间',
'deleted_at' => '逻辑删除时间', 'deleted_at' => '逻辑删除时间',
'status' => '客户状态', 'status' => '客户状态',
'member_label' => '资源标签' 'member_label' => '资源标签',
'member_id' => '客户登录标识'
]; ];
public function orderTable() public function orderTable()

18
niucloud/app/service/api/apiService/ResourceSharingService.php

@ -12,6 +12,7 @@
namespace app\service\api\apiService; namespace app\service\api\apiService;
use app\model\campus_person_role\CampusPersonRole; use app\model\campus_person_role\CampusPersonRole;
use app\model\customer_resources\CustomerResources;
use app\model\order_table\OrderTable; use app\model\order_table\OrderTable;
use app\model\resource_sharing\ResourceSharing; use app\model\resource_sharing\ResourceSharing;
use core\base\BaseApiService; use core\base\BaseApiService;
@ -47,8 +48,25 @@ class ResourceSharingService extends BaseApiService
->distinct(true) ->distinct(true)
->column('person_id'); ->column('person_id');
$resource_id_arr = [];//客户资源表id
//客户资源表名字
if(!empty($where['name'])){
$resource_id = (new CustomerResources())->where('name', 'like', "%{$where['name']}%")->column('id');
$resource_id_arr = array_merge($resource_id_arr,$resource_id);
}
//客户资源表手机号
if(!empty($where['phone_number'])){
$resource_id = (new CustomerResources())->where('phone_number', 'like', "%{$where['phone_number']}%")->column('id');
$resource_id_arr = array_merge($resource_id_arr,$resource_id);
}
//去重
$resource_id_arr = array_unique($resource_id_arr);
$model = $this->model; $model = $this->model;
if($resource_id_arr){
$model = $model->whereIn('resource_id',$resource_id_arr);
}
if ((!empty($where['shared_by']) || isset($where['shared_by'])) && $where['shared_by'] !== '') { if ((!empty($where['shared_by']) || isset($where['shared_by'])) && $where['shared_by'] !== '') {
$model = $model->where('shared_by', $where['shared_by']); $model = $model->where('shared_by', $where['shared_by']);

Loading…
Cancel
Save