different_629
This commit is contained in:
@@ -12,6 +12,67 @@ 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
|
||||
@@ -106,6 +167,7 @@ class Liche extends HD_Controller
|
||||
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
|
||||
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
|
||||
$this->load->model('app/app_different_qy_model', 'mdDifferentQy');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$t1 = 'lc_receiver_orders_v2';
|
||||
$t2 = 'lc_receiver_order_status';
|
||||
@@ -143,23 +205,30 @@ class Liche extends HD_Controller
|
||||
$data = ['o_id' => $value['id'], 'uid' => $uid, 'name' => $value['owner_name'], 'mobile' => $value['owner_mobile'],
|
||||
'birth_day' => $birth_day, 'sex' => $sex, 'brand_id' => $value['brand_id'], 's_id' => $value['s_id'],
|
||||
'v_id' => $value['v_id'], 'order_time' => $value['order_time'], 'ck_time' => $value['ck_time'], 'car_num' => $car_num];
|
||||
$biz_type = 0;
|
||||
if ($value['biz_id']) {
|
||||
$re_biz = $this->mdBiz->get(['id' => $value['biz_id']]);
|
||||
if ($re_biz) {
|
||||
$biz_type = $re_biz['type'];
|
||||
$data['province_id'] = $re_biz['province_id'];
|
||||
$data['city_id'] = $re_biz['city_id'];
|
||||
$data['county_id'] = $re_biz['county_id'];
|
||||
}
|
||||
}
|
||||
if ($value['owner_mobile']) {//查找企微
|
||||
$re_qy = $this->mdWechatqy->get(['mobile' => $value['owner_mobile']]);
|
||||
if ($re_qy) {
|
||||
$data['wxqy'] = 1;
|
||||
if ($biz_type == 5) {//异业店
|
||||
$re_qy = $this->mdDifferentQy->get(['mobile' => $value['owner_mobile']]);
|
||||
$re_qy && $data['wxqy'] = 1;
|
||||
} else {
|
||||
$re_use = $this->mdUsers->get(['mobile' => $value['owner_mobile'], 'status<>' => -1]);
|
||||
if ($re_use['unionid']) {
|
||||
$re_qy = $this->mdWechatqy->get(['unionid' => $re_use['unionid']]);
|
||||
$re_qy && $data['wxqy'] = 1;
|
||||
$re_qy = $this->mdWechatqy->get(['mobile' => $value['owner_mobile']]);
|
||||
if ($re_qy) {
|
||||
$data['wxqy'] = 1;
|
||||
} else {
|
||||
$re_use = $this->mdUsers->get(['mobile' => $value['owner_mobile'], 'status<>' => -1]);
|
||||
if ($re_use['unionid']) {
|
||||
$re_qy = $this->mdWechatqy->get(['unionid' => $re_use['unionid']]);
|
||||
$re_qy && $data['wxqy'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class Licheb extends HD_Controller
|
||||
$qy_adds = $qy_dels = $customers = 0;
|
||||
if ($value['userid']) {
|
||||
$qy_where = ['userid' => $value['userid'], 'c_time>=' => $s_time, 'c_time<=' => $e_time];
|
||||
if ($type == 5) {
|
||||
if ($type == 5) {//异业店
|
||||
$qy_adds = $this->mdDifferentQyLog->count(array_merge($qy_where, ['change_type' => 'add_external_contact']));
|
||||
$qy_dels = $this->mdDifferentQyLog->count(array_merge($qy_where, ["change_type in('del_external_contact','del_follow_user')" => null]));
|
||||
} else {
|
||||
|
||||
@@ -39,6 +39,7 @@ class Plan extends CI_Controller
|
||||
|
||||
$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', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志
|
||||
|
||||
|
||||
@@ -154,6 +154,41 @@ Class Different extends HD_Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:企业微信接收事件(测试用)
|
||||
* https://liche-api-dev.xiaoyu.com/wechat/different/get_qy?bid=133
|
||||
* https://api.liche.cn/wechat/different/get_qy?bid=133
|
||||
* https://open.work.weixin.qq.com/wwopen/devtool/interface?doc_id=14961 测试回调模式
|
||||
* Created on: 2022/3/23 17:23
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function get_qy()
|
||||
{
|
||||
$param = $this->input->get();
|
||||
require_once(COMMPATH . '/third_party/WXqy/WXBizMsgCrypt.php');
|
||||
$sVerifyMsgSig = $param['msg_signature'];
|
||||
$sVerifyTimeStamp = $param['timestamp'];
|
||||
$sVerifyNonce = $param['nonce'];
|
||||
$sVerifyEchoStr = $param['echostr'];
|
||||
$token = 'y1U8zJBQWsHC';
|
||||
$encodingAesKey = 'sA52I1PPw4ahdWrJjOKRlDtyyKUMBasTGdl5aCqszpi';
|
||||
$corpid = 'ww0fb634daed56031e';
|
||||
// 需要返回的明文
|
||||
$sEchoStr = "";
|
||||
$wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpid);
|
||||
if ($sVerifyEchoStr) {//验证回调URL
|
||||
$errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
|
||||
debug_log('qymsg_errCode:' . $errCode, $this->log_file);
|
||||
if ($errCode == 0) {
|
||||
// 验证URL成功,将sEchoStr返回
|
||||
echo urldecode($sEchoStr);
|
||||
} else {
|
||||
echo $errCode;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:临时更新用户客户id
|
||||
|
||||
@@ -54,10 +54,10 @@ class Wx_qyapi
|
||||
),
|
||||
//异业店_凯利之星
|
||||
'diff_133' => array(
|
||||
'corpid' => 'ww0fb634daed56031e',
|
||||
'corpsecret' => 'ho5SeDUuoZ2TgkzJJt_mEtLaJW_eYXW_drLmibNmbZU',
|
||||
'token' => 'y1U8zJBQWsHC',//接收事件使用
|
||||
'encodingAesKey' => 'sA52I1PPw4ahdWrJjOKRlDtyyKUMBasTGdl5aCqszpi',//接收事件使用
|
||||
'corpid' => 'ww1493c3e4fb56ef29',
|
||||
'corpsecret' => 'wbQ6zvc8vdJmpuWYAHH2yr4_izBQlVTByWIWPoGNyZw',
|
||||
'token' => 'wEa15o5kmUXOutqg',//接收事件使用
|
||||
'encodingAesKey' => 'qeHFP89LQAGK1LzLcsxBZ2nrqpTMWfkQ1WYd4mz5atX',//接收事件使用
|
||||
),
|
||||
);
|
||||
$params['corpid'] && $this->corpid = $params['corpid'];
|
||||
|
||||
@@ -50,10 +50,10 @@ class Wx_qyapi_agent
|
||||
'agentid' => 1000024
|
||||
),
|
||||
//异业店_凯利之星_客户画像
|
||||
'diff_133_1000004' => array(
|
||||
'corpid' => 'ww0fb634daed56031e',
|
||||
'corpsecret' => 'v-OCOKbBBd6FGiazrETTDO03Fz-2XF73aECYfOQpahc',
|
||||
'agentid' => 1000004
|
||||
'diff_133_1000002' => array(
|
||||
'corpid' => 'ww1493c3e4fb56ef29',
|
||||
'corpsecret' => 'W6iKxOYqNLidbN4-7mYUYbiLKaMZmm7UHFF_TfpOk8M',
|
||||
'agentid' => 1000002
|
||||
),
|
||||
);
|
||||
$params['corpid'] && $this->corpid = $params['corpid'];
|
||||
|
||||
@@ -63,7 +63,7 @@ class Biz_model extends HD_Model
|
||||
*/
|
||||
function type_ary($key = null)
|
||||
{
|
||||
$map = array('1' => '品牌店', '2' => '合伙店', '3' => '代理店', '4' => '合作店');
|
||||
$map = array('1' => '品牌店', '2' => '合伙店', '3' => '代理店', '4' => '合作店', '5' => '异业店');
|
||||
if (!is_null($key)) {
|
||||
return $map[$key];
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Different extends CI_Controller
|
||||
$this->bid = intval($bid);
|
||||
if ($this->bid == 133) {
|
||||
$this->config_qyapi = ['app' => "diff_{$this->bid}"];
|
||||
$this->config_qyapi_agent = ['app' => "diff_{$this->bid}_1000004"];
|
||||
$this->config_qyapi_agent = ['app' => "diff_{$this->bid}_1000002"];
|
||||
} else {
|
||||
$this->show_json(400, '参数错误~');
|
||||
}
|
||||
@@ -240,7 +240,7 @@ class Different extends CI_Controller
|
||||
$jsondata['tag_group'] = $tag_group;
|
||||
$up_data['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
||||
$re_cus2['wxqy'] != 1 && $up_data['wxqy'] = 1;
|
||||
if(!$re_cus2['unionid'] && $userInfo['unionid']){
|
||||
if (!$re_cus2['unionid'] && $userInfo['unionid']) {
|
||||
$up_data['unionid'] = $userInfo['unionid'];
|
||||
}
|
||||
$result = $this->mdCustomers->update($up_data, ['id' => $c_id]);
|
||||
@@ -332,7 +332,7 @@ class Different extends CI_Controller
|
||||
$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 ($re_cus) {
|
||||
if ($re_cus && $re_cus['admin_id'] != $uid) {
|
||||
$this->show_json(200, '已有同事在跟进该客户');
|
||||
}
|
||||
if ($result) {
|
||||
|
||||
@@ -350,7 +350,7 @@ class Persona extends CI_Controller
|
||||
$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 ($re_cus) {
|
||||
if ($re_cus && $re_cus['admin_id'] != $uid) {
|
||||
$this->show_json(200, '已有同事在跟进该客户');
|
||||
}
|
||||
if ($result) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
XY1NT1LdcnUTlQZJ
|
||||
Reference in New Issue
Block a user