|
|
|
@@ -23,6 +23,8 @@ class Customers extends Wxapp
|
|
|
|
|
|
|
|
|
|
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
|
|
|
|
$this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model');
|
|
|
|
|
$this->load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag');
|
|
|
|
|
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
|
|
|
|
|
$this->load->model('auto/auto_series_model');
|
|
|
|
|
$this->load->model('auto/auto_brand_model');
|
|
|
|
|
$this->load->model('auto/auto_attr_model');
|
|
|
|
@@ -42,18 +44,18 @@ class Customers extends Wxapp
|
|
|
|
|
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
|
|
|
|
}
|
|
|
|
|
$admin = $this->app_user_model->get(['id' => $row['admin_id']], 'id,uname');
|
|
|
|
|
$brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
|
|
|
|
|
$series = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
|
|
|
|
|
$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
//$brand = $this->auto_brand_model->get(['id' => $row['brand_id']], 'name');
|
|
|
|
|
//$series = $this->auto_series_model->get(['id' => $row['s_id']], 'name');
|
|
|
|
|
//$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
//$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
//$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
$tags = [$row['level'] . '级用户'];
|
|
|
|
|
$status_name = $this->customers_model->get_status();
|
|
|
|
|
$tip = $status_name[$row['status']] ? $status_name[$row['status']] : '';
|
|
|
|
|
|
|
|
|
|
$other_data = [
|
|
|
|
|
'品牌车型' => $brand['name'] . $series['name'],
|
|
|
|
|
'颜色型号' => $color . '-' . $version,
|
|
|
|
|
//'品牌车型' => $brand['name'] . $series['name'],
|
|
|
|
|
//'颜色型号' => $color . '-' . $version,
|
|
|
|
|
'建卡时间' => date('Y-m-d', $row['c_time']),
|
|
|
|
|
'客户来源' => $this->get_cfTitle($row),
|
|
|
|
|
'销售顾问' => isset($admin) ? $admin['uname'] : '',
|
|
|
|
@@ -88,21 +90,45 @@ class Customers extends Wxapp
|
|
|
|
|
if (!$row) {
|
|
|
|
|
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
|
|
|
|
}
|
|
|
|
|
$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
//$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
$of_title = $row['of_id'] ? $this->get_cfTitle($row) : '';
|
|
|
|
|
$data['baseinfo'] = [
|
|
|
|
|
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
|
|
|
|
|
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'cf_title' => $row['cf_title']]), 'cn' => '客户电话'],
|
|
|
|
|
'brand_id' => ['value' => intval($row['brand_id']), 'cn' => '车辆品牌'],
|
|
|
|
|
'car_id' => ['value' => intval($row['s_id']), 'cn' => '车辆车系'],
|
|
|
|
|
'v_id' => ['value' => intval($row['v_id']), 'cn' => '车型级别'],
|
|
|
|
|
'color_id' => ['value' => intval($car_json['c_id']), 'cn' => '车型颜色'],
|
|
|
|
|
//'brand_id' => ['value' => intval($row['brand_id']), 'cn' => '车辆品牌'],
|
|
|
|
|
//'car_id' => ['value' => intval($row['s_id']), 'cn' => '车辆车系'],
|
|
|
|
|
//'v_id' => ['value' => intval($row['v_id']), 'cn' => '车型级别'],
|
|
|
|
|
//'color_id' => ['value' => intval($car_json['c_id']), 'cn' => '车型颜色'],
|
|
|
|
|
'of_id' => ['value' => $of_title, 'of_id' => intval($row['of_id']), 'of2_id' => intval($row['of2_id']), 'cn' => '线索来源'],
|
|
|
|
|
'buy_time' => ['value' => $row['buy_time'], 'cn' => '预计购车时间'],
|
|
|
|
|
];
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function get_tag()
|
|
|
|
|
{
|
|
|
|
|
$id = intval($this->input_param('id'));
|
|
|
|
|
$show = $res_td = [];
|
|
|
|
|
$res = $this->mdCustomerTag->select(['status' => 1, 'pid' => 0], 'sort desc,id desc', 0, 0, 'id,name');
|
|
|
|
|
if ($res) {
|
|
|
|
|
if ($id) {
|
|
|
|
|
$res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');
|
|
|
|
|
}
|
|
|
|
|
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
|
|
|
|
|
foreach ($res as $key => $val) {
|
|
|
|
|
$list = [];
|
|
|
|
|
$res2 = $this->mdCustomerTag->select(['status' => 1, 'pid' => $val['id']], 'sort desc,id desc', 0, 0, 'id,name');
|
|
|
|
|
foreach ($res2 as $key2 => $val2) {
|
|
|
|
|
//检查是否选中标签
|
|
|
|
|
$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'], 'list' => $list];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $show;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改基本信息
|
|
|
|
|
protected function put_data()
|
|
|
|
|
{
|
|
|
|
@@ -111,19 +137,29 @@ class Customers extends Wxapp
|
|
|
|
|
$id = $this->input_param('cus_id');
|
|
|
|
|
$name = $this->input_param('name');
|
|
|
|
|
$mobile = $this->input_param('mobile');
|
|
|
|
|
$car_id = $this->input_param('car_id'); //品牌车型id
|
|
|
|
|
$v_id = $this->input_param('v_id'); //车型id
|
|
|
|
|
$color_id = $this->input_param('color_id'); //颜色id
|
|
|
|
|
$of_id = $this->input_param('of_id'); //线下来源一级
|
|
|
|
|
$of2_id = $this->input_param('of2_id'); //线下来源一级
|
|
|
|
|
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
|
|
|
|
$tag = $this->input_param('tag'); //客户标签
|
|
|
|
|
$row = $this->customers_model->get(['id' => $id]);
|
|
|
|
|
if (!$row) {
|
|
|
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
|
|
|
}
|
|
|
|
|
$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
$update = [];
|
|
|
|
|
if ($row['cf_title'] != '平台分配') {
|
|
|
|
|
if ($tag) {//客户标签检查
|
|
|
|
|
foreach ($tag as $key => $val) {
|
|
|
|
|
$checked = false;//检查是否有选择
|
|
|
|
|
foreach ($val['list'] as $key2 => $val2) {
|
|
|
|
|
if ($val2['checked'] == true) {
|
|
|
|
|
$checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($checked == false) {
|
|
|
|
|
throw new Exception('请选择' . $val['name'], API_CODE_FAIL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($mobile) {
|
|
|
|
|
if (!mobile_valid($mobile)) {
|
|
|
|
|
throw new Exception('手机号格式错误', ERR_PARAMS_ERROR);
|
|
|
|
@@ -134,96 +170,129 @@ class Customers extends Wxapp
|
|
|
|
|
$update['mobile'] = $mobile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$s_row = $this->auto_series_model->get(['id' => $car_id]);
|
|
|
|
|
$ids_arr = [];
|
|
|
|
|
if ($v_id) {
|
|
|
|
|
$car_json['v_id'] = $v_id;
|
|
|
|
|
$ids_arr[] = $v_id;
|
|
|
|
|
}
|
|
|
|
|
if ($color_id) {
|
|
|
|
|
$car_json['c_id'] = $color_id;
|
|
|
|
|
$ids_arr[] = $color_id;
|
|
|
|
|
}
|
|
|
|
|
$attr_row = $this->auto_attr_model->get_map_by_ids($ids_arr);
|
|
|
|
|
if ($attr_row[$color_id]) {
|
|
|
|
|
$color_row = $attr_row[$color_id][0];
|
|
|
|
|
$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
|
|
|
|
isset($color_row) && $car_json['color'] = $color_row;
|
|
|
|
|
}
|
|
|
|
|
if ($attr_row[$v_id]) {
|
|
|
|
|
$version_row = $attr_row[$v_id][0];
|
|
|
|
|
$version_row['jsondata'] = json_decode($version_row['jsondata'], true);
|
|
|
|
|
isset($version_row) && $car_json['version'] = $version_row;
|
|
|
|
|
}
|
|
|
|
|
$update['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
//$car_id = $this->input_param('car_id'); //品牌车型id
|
|
|
|
|
//$v_id = $this->input_param('v_id'); //车型id
|
|
|
|
|
//$color_id = $this->input_param('color_id'); //颜色id
|
|
|
|
|
//$car_json = json_decode($row['car_json'], true);
|
|
|
|
|
//$s_row = $this->auto_series_model->get(['id' => $car_id]);
|
|
|
|
|
//$ids_arr = [];
|
|
|
|
|
//if ($v_id) {
|
|
|
|
|
//$car_json['v_id'] = $v_id;
|
|
|
|
|
//$ids_arr[] = $v_id;
|
|
|
|
|
//}
|
|
|
|
|
//if ($color_id) {
|
|
|
|
|
//$car_json['c_id'] = $color_id;
|
|
|
|
|
//$ids_arr[] = $color_id;
|
|
|
|
|
//}
|
|
|
|
|
//$attr_row = $this->auto_attr_model->get_map_by_ids($ids_arr);
|
|
|
|
|
//if ($attr_row[$color_id]) {
|
|
|
|
|
//$color_row = $attr_row[$color_id][0];
|
|
|
|
|
//$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
|
|
|
|
//isset($color_row) && $car_json['color'] = $color_row;
|
|
|
|
|
//}
|
|
|
|
|
//if ($attr_row[$v_id]) {
|
|
|
|
|
//$version_row = $attr_row[$v_id][0];
|
|
|
|
|
//$version_row['jsondata'] = json_decode($version_row['jsondata'], true);
|
|
|
|
|
//isset($version_row) && $car_json['version'] = $version_row;
|
|
|
|
|
//}
|
|
|
|
|
//$update['car_json'] = json_encode($car_json, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
// $v_id && $update['v_id'] = $v_id;
|
|
|
|
|
//if ($s_row) {
|
|
|
|
|
//$update['s_id'] = $s_row['id'];
|
|
|
|
|
//$update['brand_id'] = $s_row['brand_id'];
|
|
|
|
|
//}
|
|
|
|
|
$name && $update['name'] = $name;
|
|
|
|
|
$of_id && $update['of_id'] = $of_id;
|
|
|
|
|
$of2_id && $update['of2_id'] = $of2_id;
|
|
|
|
|
$v_id && $update['v_id'] = $v_id;
|
|
|
|
|
if ($s_row) {
|
|
|
|
|
$update['s_id'] = $s_row['id'];
|
|
|
|
|
$update['brand_id'] = $s_row['brand_id'];
|
|
|
|
|
}
|
|
|
|
|
if ($buy_time) {
|
|
|
|
|
$this->load->library('receiver/customers_entity');
|
|
|
|
|
$update['level'] = $this->customers_entity->cal_level($buy_time);
|
|
|
|
|
$update['buy_time'] = $buy_time;
|
|
|
|
|
}
|
|
|
|
|
$result = $this->customers_model->update($update, ['id' => $id]);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$uname = $this->session['uname'];
|
|
|
|
|
$this->load->library('receiver/customers_entity');
|
|
|
|
|
$this->customers_entity->add_log($id, $this->session['uid'], $uname, "修改用户基本信息");
|
|
|
|
|
throw new Exception('保存成功', API_CODE_SUCCESS);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception('保存失败', ERR_PARAMS_ERROR);
|
|
|
|
|
$update && $this->customers_model->update($update, ['id' => $id]);
|
|
|
|
|
//客户标签
|
|
|
|
|
if ($tag) {
|
|
|
|
|
$add_tag = [];
|
|
|
|
|
//查找已加入标签
|
|
|
|
|
$res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');
|
|
|
|
|
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
|
|
|
|
|
foreach ($tag as $key => $val) {
|
|
|
|
|
foreach ($val['list'] as $key2 => $val2) {
|
|
|
|
|
if ($val2['checked'] == true) {
|
|
|
|
|
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
|
|
|
|
|
$add_tag[] = ['c_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
|
|
|
|
|
$this->mdCustomerTagdata->delete(['c_id' => $id, 't_id' => $val2['id']]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($add_tag && count($add_tag)) {
|
|
|
|
|
$this->mdCustomerTagdata->add_batch($add_tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$uname = $this->session['uname'];
|
|
|
|
|
$this->load->library('receiver/customers_entity');
|
|
|
|
|
$this->customers_entity->add_log($id, $this->session['uid'], $uname, "修改用户基本信息");
|
|
|
|
|
throw new Exception('保存成功', API_CODE_SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建客户
|
|
|
|
|
protected function post()
|
|
|
|
|
{
|
|
|
|
|
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
|
|
|
|
|
|
|
|
|
$name = $this->input_param('name');
|
|
|
|
|
$mobile = $this->input_param('mobile');
|
|
|
|
|
$car_id = $this->input_param('car_id'); //品牌车型id
|
|
|
|
|
$v_id = $this->input_param('v_id'); //车型id
|
|
|
|
|
$color_id = $this->input_param('color_id'); //颜色id
|
|
|
|
|
$back_s_id = $this->input_param('b_s_id'); //备选车型
|
|
|
|
|
//$car_id = $this->input_param('car_id'); //品牌车型id
|
|
|
|
|
//$v_id = $this->input_param('v_id'); //车型id
|
|
|
|
|
//$color_id = $this->input_param('color_id'); //颜色id
|
|
|
|
|
//$back_s_id = $this->input_param('b_s_id'); //备选车型
|
|
|
|
|
$buy_time = $this->input_param('buy_time'); //预计购车时间
|
|
|
|
|
$of_id = $this->input_param('of_id'); //线下来源一级
|
|
|
|
|
$of2_id = $this->input_param('of2_id'); //线下来源一级
|
|
|
|
|
$status = intval($this->input_param('status')); //状态
|
|
|
|
|
|
|
|
|
|
$tag = $this->input_param('tag'); //客户标签
|
|
|
|
|
if (!mobile_valid($mobile)) throw new Exception('请输入正确的手机号码', ERR_PARAMS_ERROR);
|
|
|
|
|
if (!$name || !$car_id || !$v_id || !$color_id) {
|
|
|
|
|
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
|
|
|
if ($tag) {//客户标签检查
|
|
|
|
|
foreach ($tag as $key => $val) {
|
|
|
|
|
$checked = false;//检查是否有选择
|
|
|
|
|
foreach ($val['list'] as $key2 => $val2) {
|
|
|
|
|
if ($val2['checked'] == true) {
|
|
|
|
|
$checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($checked == false) {
|
|
|
|
|
throw new Exception('请选择' . $val['name'], API_CODE_FAIL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//if (!$name || !$car_id || !$v_id || !$color_id) {
|
|
|
|
|
//throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
|
|
|
|
//}
|
|
|
|
|
if ($this->customers_model->count(['biz_id' => $biz_id, 'mobile' => $mobile])) {
|
|
|
|
|
throw new Exception('客户已存在', API_CODE_FAIL);
|
|
|
|
|
}
|
|
|
|
|
$biz_row = $this->biz_model->get(['id' => $biz_id]);
|
|
|
|
|
$row = $this->auto_series_model->get(['id' => $car_id]);
|
|
|
|
|
$where = [
|
|
|
|
|
"id in ($v_id,$color_id)" => null
|
|
|
|
|
];
|
|
|
|
|
$attr_row = $this->auto_attr_model->map('id', '', $where);
|
|
|
|
|
if ($attr_row[$color_id]) {
|
|
|
|
|
$color_row = $attr_row[$color_id][0];
|
|
|
|
|
$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
|
|
|
|
}
|
|
|
|
|
if ($attr_row[$v_id]) {
|
|
|
|
|
$version_row = $attr_row[$v_id][0];
|
|
|
|
|
$version_row['jsondata'] = json_decode($version_row['jsondata'], true);
|
|
|
|
|
}
|
|
|
|
|
$car_json = [
|
|
|
|
|
'c_id' => $color_id,
|
|
|
|
|
'v_id' => $v_id,
|
|
|
|
|
'back_s_id' => $back_s_id,
|
|
|
|
|
'color' => isset($color_row) ? $color_row : '',
|
|
|
|
|
'version' => isset($version_row) ? $version_row : ''
|
|
|
|
|
];
|
|
|
|
|
//$row = $this->auto_series_model->get(['id' => $car_id]);
|
|
|
|
|
//$where = ["id in ($v_id,$color_id)" => null];
|
|
|
|
|
//$attr_row = $this->auto_attr_model->map('id', '', $where);
|
|
|
|
|
//if ($attr_row[$color_id]) {
|
|
|
|
|
//$color_row = $attr_row[$color_id][0];
|
|
|
|
|
//$color_row['jsondata'] = json_decode($color_row['jsondata'], true);
|
|
|
|
|
//}
|
|
|
|
|
//if ($attr_row[$v_id]) {
|
|
|
|
|
//$version_row = $attr_row[$v_id][0];
|
|
|
|
|
//$version_row['jsondata'] = json_decode($version_row['jsondata'], true);
|
|
|
|
|
//}
|
|
|
|
|
//$car_json = [
|
|
|
|
|
//'c_id' => $color_id,
|
|
|
|
|
//'v_id' => $v_id,
|
|
|
|
|
//'back_s_id' => $back_s_id,
|
|
|
|
|
//'color' => isset($color_row) ? $color_row : '',
|
|
|
|
|
//'version' => isset($version_row) ? $version_row : ''
|
|
|
|
|
//];
|
|
|
|
|
$this->load->library('receiver/customers_entity');
|
|
|
|
|
$level = $this->customers_entity->cal_level($buy_time);
|
|
|
|
|
|
|
|
|
@@ -231,13 +300,13 @@ class Customers extends Wxapp
|
|
|
|
|
'name' => $name,
|
|
|
|
|
'mobile' => $mobile,
|
|
|
|
|
'biz_id' => $biz_id,
|
|
|
|
|
'brand_id' => $row['brand_id'],
|
|
|
|
|
's_id' => $row['id'],
|
|
|
|
|
'v_id' => $v_id,
|
|
|
|
|
//'brand_id' => $row['brand_id'],
|
|
|
|
|
//'s_id' => $row['id'],
|
|
|
|
|
//'v_id' => $v_id,
|
|
|
|
|
'admin_id' => $this->session['uid'],
|
|
|
|
|
'level' => $level,
|
|
|
|
|
'cf_title' => '自有资源',
|
|
|
|
|
'car_json' => json_encode($car_json, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
//'car_json' => json_encode($car_json, JSON_UNESCAPED_UNICODE),
|
|
|
|
|
'cont_time' => date('Y-m-d H:i:s'),
|
|
|
|
|
'status' => $status,
|
|
|
|
|
'c_time' => time()
|
|
|
|
@@ -250,11 +319,30 @@ class Customers extends Wxapp
|
|
|
|
|
$buy_time && $add_data['buy_time'] = $buy_time;
|
|
|
|
|
$of_id && $add_data['of_id'] = $of_id;
|
|
|
|
|
$of2_id && $add_data['of2_id'] = $of2_id;
|
|
|
|
|
$result = $this->customers_model->add($add_data);
|
|
|
|
|
if ($result) {
|
|
|
|
|
$id = $this->customers_model->add($add_data);
|
|
|
|
|
if ($id) {
|
|
|
|
|
//客户标签
|
|
|
|
|
if ($tag) {
|
|
|
|
|
$add_tag = [];
|
|
|
|
|
//查找已加入标签
|
|
|
|
|
$res_td = $this->mdCustomerTagdata->select(['c_id' => $id], 'id desc', 0, 0, 't_id');
|
|
|
|
|
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
|
|
|
|
|
foreach ($tag as $key => $val) {
|
|
|
|
|
foreach ($val['list'] as $key2 => $val2) {
|
|
|
|
|
if ($val2['checked'] == true) {
|
|
|
|
|
if (!$tag_data || !in_array($val2['id'], $tag_data)) {//未加标签,新增
|
|
|
|
|
$add_tag[] = ['c_id' => $id, 't_id' => $val2['id'], 'c_time' => time()];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($add_tag && count($add_tag)) {
|
|
|
|
|
$this->mdCustomerTagdata->add_batch($add_tag);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$uname = $this->session['uname'];
|
|
|
|
|
$this->load->library('receiver/customers_entity');
|
|
|
|
|
$this->customers_entity->add_log($result, $this->session['uid'], $uname, "创建客户");
|
|
|
|
|
$this->customers_entity->add_log($id, $this->session['uid'], $uname, "创建客户");
|
|
|
|
|
throw new Exception('创建成功', API_CODE_SUCCESS);
|
|
|
|
|
} else {
|
|
|
|
|
throw new Exception('创建失败', ERR_PARAMS_ERROR);
|
|
|
|
@@ -411,8 +499,8 @@ class Customers extends Wxapp
|
|
|
|
|
$if_driver = $this->input_param('if_driver');
|
|
|
|
|
$level = $this->input_param('level');
|
|
|
|
|
$brand_id = $this->input_param('brand_id');
|
|
|
|
|
$s_id = $this->input_param('s_id'); //车系id
|
|
|
|
|
$v_id = $this->input_param('v_id'); //车型级别id
|
|
|
|
|
//$s_id = $this->input_param('s_id'); //车系id
|
|
|
|
|
//$v_id = $this->input_param('v_id'); //车型级别id
|
|
|
|
|
$cfrom = $this->input_param('cfrom'); //客户来源id
|
|
|
|
|
$status = $this->input_param('status'); //状态
|
|
|
|
|
$o_type = $this->input_param('o_type'); //排序
|
|
|
|
@@ -507,22 +595,22 @@ class Customers extends Wxapp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//品牌车型
|
|
|
|
|
$brand_arr = array_unique(array_column($rows, 'brand_id'));
|
|
|
|
|
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
|
|
|
|
|
//$brand_arr = array_unique(array_column($rows, 'brand_id'));
|
|
|
|
|
//$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
|
|
|
|
|
//车系车型
|
|
|
|
|
$series_arr = array_unique(array_column($rows, 's_id'));
|
|
|
|
|
$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
|
|
|
|
|
//$series_arr = array_unique(array_column($rows, 's_id'));
|
|
|
|
|
//$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
|
|
|
|
|
|
|
|
|
|
foreach ($rows as $key => $val) {
|
|
|
|
|
$car_json = json_decode($val['car_json'], true);
|
|
|
|
|
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
//$car_json = json_decode($val['car_json'], true);
|
|
|
|
|
//$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
//$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
|
|
|
|
|
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
|
|
|
$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
|
|
|
//$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
|
|
|
//$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
|
|
|
$other_data = [
|
|
|
|
|
'品牌车型' => $brand_name . $serie_name,
|
|
|
|
|
'颜色型号' => $color . '-' . $version,
|
|
|
|
|
//'品牌车型' => $brand_name . $serie_name,
|
|
|
|
|
//'颜色型号' => $color . '-' . $version,
|
|
|
|
|
'建卡时间' => date('Y-m-d', $val['c_time']),
|
|
|
|
|
'客户来源' => $this->get_cfTitle($val),
|
|
|
|
|
'销售顾问' => isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '',
|
|
|
|
@@ -625,14 +713,14 @@ 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');
|
|
|
|
|
foreach ($rows as $key => $val) {
|
|
|
|
|
$car_json = json_decode($val['car_json'], true);
|
|
|
|
|
$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
|
|
|
$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
|
|
|
//$car_json = json_decode($val['car_json'], true);
|
|
|
|
|
//$color = isset($car_json['color']) ? $car_json['color']['title'] : '';
|
|
|
|
|
//$version = isset($car_json['version']) ? $car_json['version']['title'] : '';
|
|
|
|
|
//$brand_name = isset($brands[$val['brand_id']]) ? $brands[$val['brand_id']][0]['name'] : '';
|
|
|
|
|
//$serie_name = isset($series[$val['s_id']]) ? $series[$val['s_id']][0]['name'] : '';
|
|
|
|
|
$other_data = [
|
|
|
|
|
'品牌车型' => $brand_name . $serie_name,
|
|
|
|
|
'颜色型号' => $color . '-' . $version,
|
|
|
|
|
//'品牌车型' => $brand_name . $serie_name,
|
|
|
|
|
//'颜色型号' => $color . '-' . $version,
|
|
|
|
|
'建卡时间' => date('Y-m-d', $val['c_time']),
|
|
|
|
|
'客户来源' => $val['cf_title'],
|
|
|
|
|
'销售顾问' => isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '',
|
|
|
|
|