licheb_428

This commit is contained in:
dengbw
2022-04-28 10:28:24 +08:00
committed by lccsw
parent 60baf5e891
commit fbc931fb15
6 changed files with 248 additions and 103 deletions
+44 -1
View File
@@ -612,7 +612,7 @@ class CusorderV2 extends Wxapp{
}
if($keyword){
$where["(name='{$keyword}' or mobile='{$keyword}')"] = null;
$where["(name='{$keyword}' or owner_name='{$keyword}')"] = null;
}
if($status == 11 ){ //进行中
$where['status'] = 0;
@@ -782,6 +782,49 @@ class CusorderV2 extends Wxapp{
];
return $data;
}
//获取客户订单
protected function get_customer(){
$customer_id = intval($this->input_param('customer_id'));
if (!$customer_id) {
throw new Exception('参数错误', ERR_PARAMS_ERROR);
}
$where = ['status>=' => 0, 'customer_id' => $customer_id];
$total = $this->orders_model->count($where);
$lists = [];
if ($total) {
$rows = $this->orders_model->select($where, 'id desc', 0, 0, 'id,name,mobile,owner_name,owner_mobile,brand_id,s_id,v_id');
//品牌车型
$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');
//获取车辆属性
$version_arr = array_unique(array_column($rows, 'v_id'));
$attrs = $this->auto_attr_model->get_map_by_ids($version_arr, 'id,title');
foreach ($rows as $key => $val) {
$car_name = $name = $mobile = '';
if ($val['brand_id']) { //已选择车型
$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'] : '';
$version = isset($attrs[$val['v_id']]) ? $attrs[$val['v_id']][0]['title'] : '';
$car_name = "{$brand_name}{$serie_name}-{$version}";
}
$lists[] = [
'id' => $val['id'],
'car_name' => $car_name,
'name' => $val['owner_name'] ? $val['owner_name'] : $val['name'],
'mobile' => $val['owner_mobile'] ? $val['owner_mobile'] : $val['mobile']
];
}
}
$data = [
'list' => $lists,
'total' => $total
];
return $data;
}
//订单列表头部
protected function get_tabs(){
$lists = [
+44 -27
View File
@@ -25,10 +25,10 @@ class Customers extends Wxapp
$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('receiver/order/receiver_orders_v2_model', 'mdOrders');
$this->load->model('auto/auto_series_model');
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_attr_model');
$this->load->model("biz/biz_model");
}
@@ -66,6 +66,7 @@ class Customers extends Wxapp
'other_data' => $other_data,
'is_weChat' => $row['unionid'] ? true : false,
'generate_order' => $this->myuid == $row['admin_id'] ? true : false,
'level' => $row['level'],
'tags' => $tags
];
return $data;
@@ -329,6 +330,7 @@ class Customers extends Wxapp
$a_num = $this->input_param('a_num');
$is_top = $this->input_param('is_top');
$defeat_reason = $this->input_param('defeat_reason');//申请战败内容
$level = $this->input_param('level');//客户等级
$content = trim($this->input_param('content'));//小记内容
$content_imgs = $this->input_param('imgs');//小记图片
@@ -345,7 +347,7 @@ class Customers extends Wxapp
if ($row['admin_id'] != $uid) {
throw new Exception('无法操作该客户', ERR_PARAMS_ERROR);
}
$log = $a_log = '';
$log_0 = $log_4 = $log_9 = '';
if ($status == 3) {
if (!$defeat_reason) {
throw new Exception('请输入战败理由', ERR_PARAMS_ERROR);
@@ -355,12 +357,12 @@ class Customers extends Wxapp
$jsondata['defeat']['reason'] = $defeat_reason;
$up_data['if_defeat'] = 1;
$up_data['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
$log = '申请战败:' . $defeat_reason;
$log_0 = '申请战败:' . $defeat_reason;
} else {
if (strlen($status)) { //变更状态
if (strlen($status) && $status != $row['status']) { //变更状态
$up_data['status'] = $status;
$status_name = $this->customers_model->get_status();
$log = '状态变更为' . $status_name[$status];
$log_9 = '状态变更为' . $status_name[$status];
}
}
strlen($is_top) && $up_data['is_top'] = $is_top;
@@ -379,36 +381,43 @@ class Customers extends Wxapp
}
$a_num && $up_data['a_num = a_num+1'] = null;
$t_num && $up_data['t_num = t_num+1'] = null;
$level != $row['level'] && $up_data['level'] = $level;//更改客户等级
$log_4 = '';//到店
if ($status == 1 || $a_num) {
$log_4 = $row['status'] == 1 ? '客户再次到店' : '客户到店';
$up_data['cont_time'] = date('Y-m-d H:i:s'); //修改到店状态修改最后联系时间
if ($row['dt_time'] == '0000-00-00 00:00:00') {//首次到店时间
$up_data['dt_time'] = date('Y-m-d H:i:s');
}
}
$result = true;
$this->load->library('receiver/customers_entity');
if ($content) {//加小记
$result = $this->customers_entity->add_log_visit($id, $uid, $uname, $content, 0, 1, $content_imgs);
}
if ($up_data) {
$a_log = '';//到店
if ($status == 1 || $a_num) {
$a_log = '客户到店';
$up_data['cont_time'] = date('Y-m-d H:i:s'); //修改到店状态修改最后联系时间
if ($row['dt_time'] == '0000-00-00 00:00:00') {//首次到店时间
$up_data['dt_time'] = date('Y-m-d H:i:s');
}
}
$result = $this->customers_model->update($up_data, ['id' => $id]);
if ($result) { //添加日志
if ($a_log) {//到店
$this->customers_entity->add_log($id, $uid, $uname, $a_log, 4);
if ($level != $row['level']) {//更改客户等级
$this->customers_entity->add_log($id, $uid, $uname, '更改客户等级', 9);
}
if ($log_9) {//系统变更
$this->customers_entity->add_log($id, $uid, $uname, $log_9, 9);
}
if ($log_4) {//到店
$this->customers_entity->add_log($id, $uid, $uname, $log_4, 4);
}
if ($t_num) {//试驾
$this->customers_entity->add_log($id, $uid, $uname, '客户试驾', 5);
}
if ($log) {//小记
$this->customers_entity->add_log($id, $uid, $uname, $log, 0);
}
if ($status == 2) {//变成订单客户 更新客户已回访
$this->customers_entity->add_log_visit($id, $uid, $uname, '', 0, 1);
if ($log_0) {//小记
$this->customers_entity->add_log($id, $uid, $uname, $log_0, 0);
}
// if ($status == 2) {//变成订单客户 更新客户已回访
// $this->customers_entity->add_log_visit($id, $uid, $uname, '', 0, 1);
// }
}
}
if ($content) {//加小记
$result = $this->customers_entity->add_log_visit($id, $uid, $uname, $content, 0, 1, $content_imgs);
}
if ($result) {
throw new Exception('操作成功', API_CODE_SUCCESS);
} else {
@@ -596,12 +605,15 @@ class Customers extends Wxapp
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time']));
$other_data['销售顾问'] = isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '';
$tags = [$val['level'] . '级用户'];
$defeat = '';
$defeat = $orders_pay = '';
if ($val['if_defeat'] == 1) {
$defeat = '战败申请中';
} else if ($val['if_defeat'] == 2) {
$defeat = '再战';
}
//查找订单未支付
$orders_count = $this->mdOrders->count(['status' => 0, 'customer_id' => $val['id']]);
$orders_count && $orders_pay = '订单未支付';
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
@@ -611,6 +623,7 @@ class Customers extends Wxapp
'other_data' => $other_data,
'tags' => $tags,
'defeat' => $defeat,
'orders_pay' => $orders_pay,
'group_id' => $group_id,
'is_weChat' => $val['unionid'] ? true : false,
'allot' => $allot
@@ -700,12 +713,15 @@ class Customers extends Wxapp
];
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time']));
$tags = [$val['level'] . '级用户'];
$defeat = '';
$defeat = $orders_pay = '';
if ($val['if_defeat'] == 1) {
$defeat = '战败申请中';
} else if ($val['if_defeat'] == 2) {
$defeat = '再战';
}
//查找订单未支付
$orders_count = $this->mdOrders->count(['status' => 0, 'customer_id' => $val['id']]);
$orders_count && $orders_pay = '订单未支付';
$lists[] = [
'id' => $val['id'],
'name' => $val['name'],
@@ -714,7 +730,8 @@ class Customers extends Wxapp
'is_top' => $val['is_top'],
'other_data' => $other_data,
'tags' => $tags,
'defeat' => $defeat
'defeat' => $defeat,
'orders_pay' => $orders_pay
];
}
}
@@ -810,7 +827,7 @@ class Customers extends Wxapp
$uid = $this->session['uid'];
$uname = $this->session['uname'];
if ($type == 1) {
$this->customers_entity->add_log($id, $uid, $uname, '拒绝战败申请', 0);
$this->customers_entity->add_log($id, $uid, $uname, '拒绝战败申请', 9);
} else {
//战败
$admin_id = $row['admin_id'] ? $row['admin_id'] : $uid;//战败归属顾问的uid
@@ -27,7 +27,7 @@ class Receiver_customer_oplogs_model extends HD_Model
public function typeAry($id = 0)
{
$arr = [0 => '小记', 1 => '发短信', 2 => '拨打号码', 3 => '创建', 4 => '到店', 5 => '试驾', 6 => '订单', 7 => '战败'
, 8 => '企微跟进'];
, 8 => '企微跟进', 9 => '系统'];
if ($id) {
return $arr[$id];
} else {
+155 -29
View File
@@ -201,7 +201,159 @@ class Persona extends CI_Controller
}
/**
* Notes:到店
* Notes:保存用户信息
* Created on: 2022/4/27 0:55
* Created by: dengbw
*/
public function post_user()
{
$params = $this->input->post();
$userInfo = $params['userInfo'];
$mobile = $userInfo['mobile'];
$biz_id = intval($userInfo['biz_id']);
$this->load->library('receiver/customers_entity');
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('receiver/receiver_customer_tagdata_model', 'mdCustomerTagdata');
$c_id = $userInfo['c_id'];
$result = '';
if ($c_id) {//已存在客户,更新资料
$up_data = ['of_id' => $params['of_id'], 'of2_id' => $params['of2_id']];
$result = $this->mdCustomers->update($up_data, ['id' => $c_id]);
$this->customers_entity->add_log($c_id, $userInfo['admin_id'], $userInfo['admin_name'], '修改用户基本信息');
} else {
if ($mobile && $biz_id) {//有手机号查找客户是否已存在
$re_cus = $this->mdCustomers->get(['biz_id' => $biz_id, 'mobile' => $mobile, 'status<>' => -1]);
if ($re_cus) {//已存客户绑定操作,不带入现有标签中
$result = $this->mdCustomers->update(['unionid' => $userInfo['unionid']], ['id' => $re_cus['id']]);
} else {//创建新客户
$this->load->model("biz/biz_model", 'mdBiz');
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
$city_id = intval($re_biz['city_id']);
$county_id = intval($re_biz['county_id']);
$date = date('Y-m-d H:i:s');
$admin_id = $userInfo['admin_id'];
$admin_name = $userInfo['admin_name'];
$add_data = [
'name' => $userInfo['name'],
'mobile' => $mobile,
'biz_id' => $biz_id,
'city_id' => $city_id,
'county_id' => $county_id,
'unionid' => $userInfo['unionid'],
'of_id' => $params['of_id'],
'of2_id' => $params['of2_id'],
'cf_title' => '自有资源',
'admin_id' => $admin_id,
'status' => 0,//未见客户
'p_time' => $date,//分配时间
'c_time' => time()
];
$c_id = $this->mdCustomers->add($add_data);
if ($c_id) {//加日志
$result = true;
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
$res_log = $this->mdWechatqyLog->select(['external_userid' => $userInfo['external_userid']
, 'userid' => $userInfo['userid']], 'c_time asc', 0, 0, 'remark');
if ($res_log) {//企微跟进记录
foreach ($res_log as $key => $val) {
$this->customers_entity->add_log($c_id, $admin_id, $admin_name, $val['remark'], 8);
}
}
$this->customers_entity->add_log($c_id, $admin_id, $admin_name, '创建客户档案', 3);
}
}
}
}
//客户标签操作
if ($c_id && $params['taglList']) {
$add_tag = [];
//查找已加入标签
$res_td = $this->mdCustomerTagdata->select(['c_id' => $c_id], 'id desc', 0, 0, 't_id');
$tag_data = $res_td ? array_unique(array_column($res_td, 't_id')) : '';
foreach ($params['taglList'] 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' => $c_id, 't_id' => $val2['id'], 'c_time' => time()];
}
} else {
if ($tag_data && in_array($val2['id'], $tag_data)) {//删除标签
$this->mdCustomerTagdata->delete(['c_id' => $c_id, 't_id' => $val2['id']]);
}
}
}
}
if ($add_tag && count($add_tag)) {
$this->mdCustomerTagdata->add_batch($add_tag);
}
}
//企微操作
$remark_mobiles = $userInfo['mobile'] ? [$userInfo['mobile']] : '';
$description = $params['of_title'] ? $params['of_title'] : '';
if ($description && $params['of2_title']) {
$description .= '-' . $params['of2_title'];
}
//企微备注操作
$this->wx_qyapi->get_external_contact(['url' => 'remark', 'userid' => $userInfo['userid']
, 'external_userid' => $userInfo['external_userid'], 'remark_mobiles' => $remark_mobiles, 'description' => $description]);
//标签操作
$tags_name = $userInfo['tags_name'];
$add_tag = $remove_tag = '';
if ($params['taglList']) {
foreach ($params['taglList'] as $key => $val) {
foreach ($val['list'] as $key2 => $val2) {
if ($val2['checked'] == 'true') {
if (!$tags_name || !in_array($val2['name'], $tags_name)) {//未加标签,新增
$add_tag[] = $val2['qy_id'];
}
} else {
if ($tags_name && in_array($val2['name'], $tags_name)) {//删除标签
$remove_tag[] = $val2['qy_id'];
}
}
}
}
}
if ($add_tag || $remove_tag) {
$this->wx_qyapi->get_external_contact(['url' => 'mark_tag', 'userid' => $userInfo['userid'],
'external_userid' => $userInfo['external_userid'], 'add_tag' => $add_tag, 'remove_tag' => $remove_tag]);
}
if ($result) {
$this->show_json(200, '保存成功');
} else {
$this->show_json(400, '保存失败');
}
}
/**
* Notes:授权获取企业员工UserId
* Created on: 2022/3/29 17:03
* Created by: dengbw
* @param string $url
* @param array $params
* @return mixed
*/
private function set_auth($url = '', $params = array())
{
$config = $this->wx_qyapi_agent->getConfig();
$code = $params['code'];
if ($code) {//授权码获取微信信息
$this->load->library('mycurl');
$access_token = $this->wx_qyapi_agent->access_token();
$auth_url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={$access_token}&code={$code}";
$res = $this->mycurl->httpGet($auth_url);
return json_decode($res, true);
} else {//静默授权获取用户openid
$this->load->helper('url');
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['corpid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
}
/**
* Notes:到店(废弃22-4-27)
* Created on: 2022/3/27 0:57
* Created by: dengbw
*/
@@ -343,11 +495,11 @@ class Persona extends CI_Controller
}
/**
* Notes:保存用户信息
* Notes:保存用户信息(废弃22-4-27)
* Created on: 2022/3/27 0:55
* Created by: dengbw
*/
public function post_user()
public function post_user_backup()
{
$params = $this->input->post();
$userInfo = $params['userInfo'];
@@ -421,32 +573,6 @@ class Persona extends CI_Controller
}
}
/**
* Notes:授权获取企业员工UserId
* Created on: 2022/3/29 17:03
* Created by: dengbw
* @param string $url
* @param array $params
* @return mixed
*/
private function set_auth($url = '', $params = array())
{
$config = $this->wx_qyapi_agent->getConfig();
$code = $params['code'];
if ($code) {//授权码获取微信信息
$this->load->library('mycurl');
$access_token = $this->wx_qyapi_agent->access_token();
$auth_url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={$access_token}&code={$code}";
$res = $this->mycurl->httpGet($auth_url);
return json_decode($res, true);
} else {//静默授权获取用户openid
$this->load->helper('url');
$redirect_uri = urlencode($url);
$auth_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$config['corpid']}&redirect_uri={$redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
redirect($auth_url);
}
}
private function show_json($code, $msg, $info = [])
{
$data['code'] = $code;
+3 -44
View File
@@ -6,7 +6,7 @@
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?= $_title ?></title>
<link rel="stylesheet" href="/css/h5/persona/h5.css?v=1">
<link rel="stylesheet" href="/css/h5/persona/h5.css?v=2">
<script src="https://qs.haodian.cn/web/javascript/jquery.3.4.1.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/vue.2.6.10.min.js"></script>
<script type="text/javascript" src="https://qs.haodian.cn/web/javascript/qs.js"></script>
@@ -18,7 +18,7 @@
<body class="bg-f7">
<div id="app">
<div class="container">
<div class="inner30">
<div class="inner30 pb220">
<div class="inner30 bg-fff ulib-r10">
<div class="relative">
<img class="block imgsize-90X90 ulib-r5" :src="userInfo.avatar" alt="#"/>
@@ -28,11 +28,7 @@
<i class="text-middle iconfont icon-nvshangjia color-fb3aab" v-if="userInfo.gender==2"></i>
<span class="text-middle color-36b229">{{userInfo.source}}</span>
</div>
<button :class="'absolute right-0 box-middle btn pt15 pb15 pl30 pr30 text-center font-30 color-fff ulib-r10 ' + [submitFlag?'bg-b5':'bg-3f91fd']"
:disabled="submitFlag" @click="postToBiz()">到店
</button>
</div>
<!-- <div class="bg-f7 mt30 pt20 pb20 pl30 pr30 font-30 color-2b78f5 ulib-r10">点击关联企业</div> -->
<div class="mt20 pl140 relative bbs-1-eee last-b-none">
<div class="absolute left-0 box-middle font-28 color-666">手机号</div>
<div v-if="userInfo.c_id" class="pt10 pb10 text-right font-28">{{userInfo.mobile}}</div>
@@ -83,13 +79,11 @@
</vdiv>
</div>
</div>
<div class="pt50 pb50 pl60 pr60">
<div class="fixed left-0 bottom-0 right-0 bg-fff-op80 pt30 pb50 pl30 pr30">
<button :class="'wp100 btn pt30 pb30 text-center font-32 color-fff ulib-r750 ' + [submitFlag?'bg-b5':'bg-3f91fd']"
:disabled="submitFlag" @click="postUser()">确认保存
</button>
</div>
</div>
</div>
</div>
@@ -160,41 +154,6 @@
}
});
},
//到店
postToBiz() {
let that = this;
if (!that.userInfo.mobile) {
mDialog.msg({content: "请输入手机号"});
return
}
var of_title = that.of_id ? $("#id-of_id").find("option:selected").text() : '';
var of2_title = that.of2_id ? $("#id-of2_id").find("option:selected").text() : '';
$.ajax({
url: '/h5/persona/post_to_biz',
type: 'post',
dataType: 'json',
data: {
userInfo: that.userInfo,
taglList: that.taglList,
of_id: that.of_id,
of2_id: that.of2_id,
of_title: of_title,
of2_title: of2_title,
aid: that.aid,
},
beforeSend: function () {
loading = mDialog.load({shade: false, text: "",});
that.submitFlag = true;
},
success: function (re) {
mDialog.msg({content: re.msg});
},
complete: function () {
loading && mDialog.close(loading); //关闭加载
that.submitFlag = false;
}
});
},
//保存
postUser() {
let that = this;
File diff suppressed because one or more lines are too long