customer_317

This commit is contained in:
dengbw
2022-03-17 16:52:21 +08:00
committed by lccsw
parent 1a0640bfca
commit d1f81342b9
3 changed files with 77 additions and 21 deletions
+13 -1
View File
@@ -16,9 +16,10 @@
</div>
<div class="coms-table-wrap mt10">
<form class="form-search coms-table-hd clearfix no-border" onsubmit="return false"
<form id="vue-app" class="form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="/receiver/customer">
<input name="status" value="<?= $params['status'] ?>" type="hidden">
<input type="hidden" id="id_tag" name="tag" value="<?= $params['tag'] ?>">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">客户搜索:</label>
@@ -163,6 +164,9 @@
<div class="am-form-group fl ml10">
<input type="button" @click="btnTimes" value="选择筛选时间" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10" style="display: none">
<input type="button" @click="searchTag" value="客户画像" class="am-btn am-btn-success am-btn-sm">
</div>
<div class="am-form-group fl ml10">
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
</div>
@@ -349,6 +353,14 @@
saveEdit: function () {
$("form").submit();
},
searchTag: function () {
var tag = [];
tag.push('1_1');
tag.push('1_3');
tag.push('2_5');
$('#id_tag').val(tag);
$('#vue-app').submit();
},
init_citys: function () {
var vm = this;
$.ajax({
+41 -1
View File
@@ -16,6 +16,47 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
/**
* Notes:更新客户初始销售
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customer_sales
* https://api.liche.cn/plan/temp/receiver_customer_sales
*/
public function receiver_customer_sales()
{
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 50;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = array("admin_id>" => 0);
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,admin_id,sales_id');
if (!$res) {
echo '<br>本次更新客户初始销售完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customer_sales">点击将再次更新客户初始销售>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
if (!$value['sales_id']) {
$this->mdCustomers->update(['sales_id' => $value['admin_id']], ['id' => $value['id']]);
$log[] = array('id' => $value['id'], 'sales_id' => $value['admin_id']);
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_customer_sales?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新客户线下来源
* Created on: 2022/3/09 11:58
@@ -39,7 +80,6 @@ class Temp extends HD_Controller
echo '<br>本次更新客户线下来源完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customer_of">点击将再次更新客户线下来源>>></a>';
$this->mdCustomers->update(['cf_title' => '自有资源', 'of_id' => 5, 'of2_id' => 53], ['id' => 2873]);
exit;
}
$log = array();
+23 -19
View File
@@ -123,7 +123,7 @@ class Customers extends Wxapp
$checked = $tag_data && in_array($val2['id'], $tag_data) ? true : false;
$list[] = ['id' => $val2['id'], 'name' => $val2['name'], 'checked' => $checked];
}
$show[] = ['id' => $val['id'], 'name' => $val['name'],'type' => $val['type'], 'list' => $list];
$show[] = ['id' => $val['id'], 'name' => $val['name'], 'type' => $val['type'], 'list' => $list];
}
}
return $show;
@@ -574,7 +574,10 @@ class Customers extends Wxapp
//车系车型
//$series_arr = array_unique(array_column($rows, 's_id'));
//$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
$allot = 0;
if ($group_id == 2 || $group_id = 3) {//店长和老板可再分配用户
$allot = 1;
}
foreach ($rows as $key => $val) {
//$car_json = json_decode($val['car_json'], true);
//$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
@@ -605,7 +608,8 @@ class Customers extends Wxapp
'is_top' => $val['is_top'],
'other_data' => $other_data,
'tags' => $tags,
'defeat' => $defeat
'defeat' => $defeat,
'allot' => $allot
];
}
}
@@ -623,28 +627,28 @@ class Customers extends Wxapp
$uid = $this->session['uid'];
$id_arr = $this->input_param('ids');
$admin_id = $this->input_param('admin_id');
$admin = $this->app_user_model->get(['id' => $admin_id, 'status' => 1]);
if (!$id_arr || !$admin) {
throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM);
}
$ids = implode(',', $id_arr);
$ret = $this->customers_model->update(['admin_id' => $admin_id], ["id in ({$ids})" => null]);
if (is_bool($ret)) {
debug_log("[error]# " . $this->customers_model->db->last_query(), __FUNCTION__, $this->log_dir);
throw new Exception('分派失败', API_CODE_FAIL);
}
//写日志
$this->load->library('receiver/customers_entity');
//$customers = $this->customers_model->get_map_by_ids($id_arr, 'id,rid');
foreach ($id_arr as $val) {
$log = "分配客户";
$this->customers_entity->add_log($val, $uid, $uname, $log);
//发送短信
$re = $this->customers_model->get(['id' => $val]);
$num = $re['mobile'] ? substr($re['mobile'], -4) : 0;
send_alisms(array('mobile' => $admin['mobile'], 'template' => 'SMS_226945702', 'param' => ['num' => $num]));
$id = $val;
$re = $this->customers_model->get(['id' => $id]);
if ($re['admin_id'] == $admin_id) {//同个销售跳出循环
continue;
}
$upDate = ['admin_id' => $admin_id];
!$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);
//发送短信
$num = $re['mobile'] ? substr($re['mobile'], -4) : 0;
send_alisms(array('mobile' => $admin['mobile'], 'template' => 'SMS_226945702', 'param' => ['num' => $num]));
}
}
throw new Exception('分配成功', API_CODE_SUCCESS);
}