Customers_610

This commit is contained in:
dengbw
2022-06-10 15:04:39 +08:00
parent 14fb995468
commit 98be1d1d2b
+22 -4
View File
@@ -438,9 +438,11 @@ class Customers extends Wxapp
$follow_channel && $content = "跟进渠道($follow_channel)" . $content;
if ($visit_time) {
$content .= '。计划回访时间:' . $visit_time;
$where_vis = ['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $uid, 't_day' => $visit_time, 'level' => $level];
$sales_id = $row['admin_id'] ? $row['admin_id'] : $uid;//有销售id,回访归属销售
$where_vis = ['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $sales_id, 't_day' => $visit_time];
$re_vis = $this->mdCustomerVisitData->get($where_vis);
if (!$re_vis) {
$where_vis['level'] = $level;
$where_vis['c_time'] = time();
$this->mdCustomerVisitData->add($where_vis);
}
@@ -678,6 +680,7 @@ class Customers extends Wxapp
'is_weChat' => $val['unionid'] ? true : false,
'allot' => $allot,
'tip' => $tip,
'level' => $val['level'],
];
}
}
@@ -695,10 +698,14 @@ class Customers extends Wxapp
$uid = $this->session['uid'];
$id_arr = $this->input_param('ids');
$admin_id = $this->input_param('admin_id');
$visit_time = $this->input_param('visit_time');
$allot = $this->get_allot();
if ($allot == 0) {
throw new Hd_exception('无权限分配', API_CODE_INVILD_PARAM);
}
if (!$visit_time) {
throw new Hd_exception('请选择回访时间', API_CODE_INVILD_PARAM);
}
$admin = $this->app_user_model->get(['id' => $admin_id, 'status' => 1]);
if (!$id_arr || !$admin) {
throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM);
@@ -710,13 +717,24 @@ class Customers extends Wxapp
if ($re['admin_id'] == $admin_id) {//同个销售跳出循环
continue;
}
$upDate = ['admin_id' => $admin_id];
$upDate = ['admin_id' => $admin_id, 'visit_time' => $visit_time];
!$re['sales_id'] && $upDate['sales_id'] = $admin_id;//初始销售id
$ret = $this->customers_model->update($upDate, ["id" => $id]);
if ($ret) {
//写日志
$log = "分配客户";
$this->customers_entity->add_log($id, $uid, $uname, $log);
$this->customers_entity->add_log($id, $uid, $uname, "分配客户");
$biz_id = $re['biz_id'];
$level = $re['level'];
$where_vis = ['c_id' => $id, 'biz_id' => $biz_id, 'sales_id' => $admin_id, 't_day' => $visit_time];
$re_vis = $this->mdCustomerVisitData->get($where_vis);
if (!$re_vis) {
//删除未回访计划
$this->mdCustomerVisitData->delete(['c_id' => $id, 'biz_id' => $biz_id, 'status<>' => 2, 't_day >=' => $visit_time]);
$where_vis['level'] = $level;
$where_vis['c_time'] = time();
$this->mdCustomerVisitData->add($where_vis);
$this->customers_entity->add_log_visit($id, $uid, $uname, '计划回访时间:' . $visit_time, 0, 1);
}
//发送短信
$num = $re['mobile'] ? substr($re['mobile'], -4) : 0;
send_alisms(array('mobile' => $admin['mobile'], 'template' => 'SMS_226945702', 'param' => ['num' => $num]));