owners_906

This commit is contained in:
dengbw
2022-09-06 17:18:19 +08:00
committed by lccsw
parent 215d40d38f
commit 9ac612d62a
5 changed files with 66 additions and 104 deletions
+8
View File
@@ -263,13 +263,21 @@ class Customer extends HD_Controller
} else {
$tag = $this->get_tag($row['id']);
}
$to_send = '';
if ($row['cs_biz_id'] == -1) {
$to_send = '已改派';
} else if ($row['cs_biz_id'] > 0) {
$to_send = '接收线索';
}
$info = array(
'id' => $row['id'],
'name' => $row['name'],
'level' => $row['level'],
'mobile' => $mobile_sub,
'of_title' => $of_title,
'wxqy_name' => $this->customers_model->wxqyAry($row['wxqy']),
'cf_user' => $cf_user,
'to_send' => $to_send,
'c_time' => date('Y-m-d H:i:s', $row['c_time']),
'status' => $row['status'],
'tag' => $tag,
+7 -3
View File
@@ -60,9 +60,13 @@
<tr>
<td class="table-td"><span class="mr5">客户来源:</span>{{info.of_title}}</td>
<td class="table-td"><span class="mr5">企微好友:</span>{{info.wxqy_name}}</td>
<td class="table-td">
<template v-if="info.cf_user"><span class="mr5">分销来源:</span>{{info.cf_user}}</template>
</td>
<td class="table-td"><span class="mr5">客户等级:</span>{{info.level}}</td>
</tr>
<tr v-if="info.to_send || info.cf_user">
<td class="table-td" v-if="info.to_send"><span class="mr5">改派:</span>{{info.to_send}}</td>
<td class="table-td" v-if="info.cf_user"><span class="mr5">分销来源:</span>{{info.cf_user}}</td>
<td class="table-td" v-if="info.to_send && info.cf_user"></td>
<td class="table-td" v-else colspan="2"></td>
</tr>
<tr>
<td>
+48 -98
View File
@@ -12,126 +12,76 @@ class Liche extends HD_Controller
parent::__construct();
}
/**
* Notes:更新异业店车主企业微信
* Created on: 2022/6/21 16:00
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/liche/owners_wxqy_different?rds=1
* https://api.liche.cn/plan/liche/owners_wxqy_different
*/
public function owners_wxqy_different()
{
$params = $this->input->get();
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'update_owners_different_wxqy_c_time';
if ($rds) {
$redis->delete($redisKey);
}
$c_time = $redis->get($redisKey);
!$c_time && $c_time = strtotime(date('Y-m-d') . ' 00:00:00');
$log = [];
$this->load->model('app/app_different_qy_log_model', 'mdWechatqyLog');
$this->load->model('app/app_different_qy_model', 'mdWechatqy');
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
$res = $this->mdWechatqyLog->select(["c_time>=" => $c_time, "change_type in('add_external_contact','edit_external_contact')" => null]
, 'c_time asc', 1, $size, 'change_type,external_userid,c_time');
if (!$res) {
if ($params['rds']) {
echo '1执行到当前c_time' . date('Y-m-d H:i:s', $c_time) . '暂无数据';
}
return;
}
foreach ($res as $key => $value) {
$c_time = $value['c_time'];
if ($value['external_userid']) {
$re_qy = $this->mdWechatqy->get(['external_userid' => $value['external_userid']]);
$mobile = $re_qy['mobile'];
if ($mobile) {
$re_own = $this->mdOwners->get(['mobile' => $mobile]);
if ($re_own) {
$this->mdOwners->update(['wxqy' => 1], ['id' => $re_own['id']]);
if ($params['rds']) {
$log[] = ['mobile' => $mobile];
}
}
}
}
}
$redis->save($redisKey, $c_time);
if ($params['rds']) {
echo '<br>2执行到当前c_time' . date('Y-m-d H:i:s', $c_time);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
}
}
/**
* Notes:更新车主企业微信
* Created on: 2022/6/21 16:00
* Created on: 2022/9/06 16:00
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/liche/owners_wxqy?rds=1
* https://liche-api-dev.xiaoyu.com/plan/liche/owners_wxqy?sd=1
* https://api.liche.cn/plan/liche/owners_wxqy
*/
public function owners_wxqy()
{
$params = $this->input->get();
$size = 100;//每次最多处理多少条
$hour = date('H.i');
if (($hour > 22.00 && $hour < 23.55) || $params['sd']) {
if ($params['sd']) {
echo "开始执行车主[{$hour}]";
}
} else {
echo '[22.00-23.55]执行车主[' . $hour . ']';
return;
}
$size = 200;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'update_owners_wxqy_c_time';
$log_date = date('Y-m-d');
$redisKey = 'lc_receiver_owners_id_' . $log_date;
if ($rds) {
$redis->delete($redisKey);
}
$c_time = $redis->get($redisKey);
!$c_time && $c_time = strtotime(date('Y-m-d') . ' 00:00:00');
$id = $redis->get($redisKey);
!$id && $id = 0;
$log = [];
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
$res = $this->mdWechatqyLog->select(["c_time>=" => $c_time, "change_type in('add_external_contact','edit_external_contact')" => null]
, 'c_time asc', 1, $size, 'change_type,external_userid,c_time');
$where = ['a.id>' => $id, 'a.wxqy' => 0];
$res = $this->db->select('a.id,a.mobile,a.u_time,b.admin_id,b.biz_id')
->from('lc_receiver_owners as a')
->join('lc_receiver_orders_v2 as b', "b.id=a.o_id", 'left')
->where($where)
->order_by('a.id asc')
->limit($size, 0)
->get()->result_array();
if (!$res) {
if ($params['rds']) {
echo '1执行到当前c_time' . date('Y-m-d H:i:s', $c_time) . '暂无数据';
}
echo '执行到车主id' . $id . '暂无数据';
return;
}
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
$this->load->model('app/app_different_qy_model', 'mdDifferentQy');
$str_biz_ids = implode(',', array_unique(array_column($res, 'biz_id')));
$map_biz = $this->mdBiz->map('id', 'city_id,type,status', ["id in({$str_biz_ids})" => null]);
$str_user_ids = implode(',', array_unique(array_column($res, 'admin_id')));
$map_user = $this->mdUsers->map('id', 'userid', ["id in({$str_user_ids})" => null]);
foreach ($res as $key => $value) {
$c_time = $value['c_time'];
if ($value['external_userid']) {
$re_qy = $this->mdWechatqy->get(['external_userid' => $value['external_userid']]);
$mobile = $re_qy['mobile'];
$type = 1;
if (!$mobile && $re_qy['unionid']) {
$re_use = $this->mdUsers->get(['unionid' => $re_qy['unionid']]);
if ($re_use['mobile']) {
$type = 2;
$mobile = $re_use['mobile'];
}
$id = $value['id'];
$biz_type = intval($map_biz[$value['biz_id']]['type']);
$userid = $map_user[$value['admin_id']];
if ($userid) {
if ($biz_type == 5) {//异业店
$re = $this->mdDifferentQy->get(['userid' => $userid, 'mobile' => $value['mobile']]);
} else {
$re = $this->mdWechatqy->get(['userid' => $userid, 'mobile' => $value['mobile']]);
}
if ($mobile) {
$re_own = $this->mdOwners->get(['mobile' => $mobile]);
if ($re_own) {
$this->mdOwners->update(['wxqy' => 1], ['id' => $re_own['id']]);
if ($params['rds']) {
$log[] = ['mobile' => $mobile, 'type' => $type];
}
}
if ($re) {//更新企微好友
$this->mdOwners->update(['wxqy' => 1, 'u_time' => $value['u_time']], ['id' => $id]);
$params['sd'] && $log[] = ['id' => $id, 'mobile' => $value['mobile']];
}
}
}
$redis->save($redisKey, $c_time);
if ($params['rds']) {
echo '<br>2执行到当前c_time' . date('Y-m-d H:i:s', $c_time);
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
if ($params['sd']) {
echo '<br>执行到当前车主id' . $redis->get($redisKey);
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
+1 -2
View File
@@ -40,8 +40,7 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'licheb', 'inventory_log')), 'interval' => 5);//更新盘点状态
$plan[] = array('url' => base_url(array('plan', 'liche', 'add_owners')), 'interval' => 5);//新增车主
$plan[] = array('url' => base_url(array('plan', 'liche', 'owners_wxqy')), 'interval' => 60);//更新车主企业微信
$plan[] = array('url' => base_url(array('plan', 'liche', 'owners_wxqy_different')), 'interval' => 60);//更新异业店车主企业微信
$plan[] = array('url' => base_url(array('plan', 'liche', 'owners_wxqy')), 'interval' => 10);//更新车主企业微信
$plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志
+2 -1
View File
@@ -781,7 +781,8 @@ class Customers extends Wxapp
}
$this->customer_oplogs_model->add_batch($add_oplogs);
}
$this->customers_entity->add_log($customer_id, $uid, $uname, "客户改派");
$this->customers_entity->add_log($id, $uid, $uname, "客户改派");//改派的客户日志
$this->customers_entity->add_log($customer_id, $uid, $uname, "客户改派");//改派后的客户日志
}
}
throw new Exception('分配成功', API_CODE_SUCCESS);