客户回访调整

This commit is contained in:
meimei
2025-04-16 10:08:13 +08:00
parent 7891a254a1
commit 478e257bce
10 changed files with 435 additions and 26 deletions

View File

@@ -3,6 +3,7 @@
namespace app\admin\controller;
use app\common\controller\Backend;
use think\Db;
/**
* 客户回访记录
@@ -49,10 +50,9 @@ class Firmcustomerfollowuprecord extends Backend
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$list = $this->model
->where($where)
->where('firmcustomer_id','=',input('ids'))
->order($sort, $order)
->paginate($limit);
@@ -68,4 +68,70 @@ class Firmcustomerfollowuprecord extends Backend
return $this->view->fetch();
}
public function newadd()
{
if (false === $this->request->isPost()) {
$customer_id = input('ids');
$customer = Db::table('fa_firmcustomer')->where('id',$customer_id)->find();
$this->view->assign('customer',$customer);
return $this->view->fetch();
}
$params = $this->request->post();
if (empty($params)) {
$this->error(__('Parameter %s can not be empty', ''));
}
$params = $this->preExcludeFields($params);
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
$params[$this->dataLimitField] = $this->auth->id;
}
$customerData = Db::table('fa_firmcustomer')->where('id',$params['firmcustomer_id'])->find();
$dataList = [];
foreach ($params['visit_info'] as $value){
$data = $params;
unset($data['visit_info']);
$data['rel_wx'] = $customerData['rel_wx'];
$data['rel_group'] = $customerData['rel_group'];
$data['visit_msg'] = $value['visit_msg'];
$data['day'] = $value['day'];
$data['followup_time'] = $value['times'];
$dataList[] = $data;
}
$result = false;
Db::startTrans();
try {
//是否采用模型验证
if ($this->modelValidate) {
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
$this->model->validateFailException()->validate($validate);
}
$fields = Db::table('fa_firmcustomerfollowuprecord')->getTableFields();
foreach ($dataList as $value){
$validData = array_intersect_key($value, array_flip($fields));
$result = Db::table('fa_firmcustomerfollowuprecord')->insertGetId($validData);
if ($result){
$firmcustomerfollowuptimelist = [];
$firmcustomerfollowuptimelist['firmcustomerfollowuprecord_id']=$result;
$firmcustomerfollowuptimelist['day']=$value['day'];
$firmcustomerfollowuptimelist['followup_time']=$value['followup_time'];
Db::table('fa_firmcustomerfollowuptimelist')->insert($firmcustomerfollowuptimelist);
}else{
Db::rollback();
$this->error('添加失败,请重新操作');
}
}
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
if ($result === false) {
$this->error(__('No rows were inserted'));
}
$this->success();
}
}

View File

@@ -53,6 +53,7 @@ class Firmcustomerfollowuptimelist extends Backend
$list = $this->model
->with(['firmcustomerfollowuprecord'])
->where($where)
->where('firmcustomerfollowuprecord_id','=',input('ids'))
->order($sort, $order)
->paginate($limit);

View File

@@ -77,14 +77,18 @@ class Mattertemplatecategorization extends Backend
$firmstoreprojectsone_id = input('firmstoreprojectsone_id');
$firmstoreprojectstwo_id = input('firmstoreprojectstwo_id');
$model = $this->model->where('mattertemplate_id',1);
$visitmodel = Db::table('fa_mattertemplatecategorization')->where('mattertemplate_id',2);
if (!empty($firmstoreprojectsone_id)){
$model = $model->where('firmstoreprojectsone_id',$firmstoreprojectsone_id);
$visitmodel = $visitmodel->where('firmstoreprojectsone_id',$firmstoreprojectsone_id);
}
if (!empty($firmstoreprojectstwo_id)){
$model = $model->where('firmstoreprojectstwo_id',$firmstoreprojectstwo_id);
$visitmodel = $visitmodel->where('firmstoreprojectstwo_id',$firmstoreprojectstwo_id);
}
$data = $model->select();
return json(['total'=>count($data),'data'=>$data]);
$visitdata = $visitmodel->select();
return json(['data'=>$data,'visit_data'=>$visitdata]);
}
}

View File

@@ -171,4 +171,16 @@ class Mattertemplatecategorizedcontent extends Backend
}
$this->success();
}
public function getAllContent(){
$mattertemplatecategorization_id = $this->request->post('id');
$type = $this->request->post('type');
$data = $this->model->where('mattertemplatecategorization_id',$mattertemplatecategorization_id)
->order('id desc');
if ($type==1){
$data = $data->find();
}else{
$data = $data->select();
}
return json(['data'=>$data]);
}
}