Files
liche/api/controllers/plan/Temp.php
T
2022-05-10 17:03:14 +08:00

734 lines
35 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Notes:临时数据操作
* Created on: 2021/9/18 17:15
* Created by: dengbw
*/
class Temp extends HD_Controller
{
private $log_file;
public function __construct()
{
parent::__construct();
$this->log_file = 'temp.log';
}
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/material_template
* https://api.liche.cn/plan/temp/material_template
*/
public function material_template()
{
$this->load->model('app/material/Material_template_model', 'mdTemplate');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 100;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = ["id>" => 0];
$res = $this->mdTemplate->select($where, 'id ASC', $param['page'], $param['size'], 'id,brand_ids');
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/material_template">点击将再次更新>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$brand_ids = $value['brand_ids'];
if ($brand_ids) {
if (!strstr($brand_ids, '0,')) {
$brand_ids = '0,'.$brand_ids;
$ret = $this->mdTemplate->update(['brand_ids' => $brand_ids], ['id' => $value['id']]);
if ($ret == 1) {
$log[] = ['id' => $value['id'], 'brand_ids' => $brand_ids];
$counts++;
}
}
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/material_template?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customers_wxqy
* https://api.liche.cn/plan/temp/receiver_customers_wxqy
*/
public function receiver_customers_wxqy()
{
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
$this->load->library('wx_qyapi', ['app' => 'lichene']);
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 2;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = ["change_type<>" => 'edit_external_contact'];
$res = $this->mdWechatqyLog->select($where, 'c_time ASC', $param['page'], $param['size']);
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customers_wxqy">点击将再次更新>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
if ($value['userid'] && $value['external_userid']) {
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'user_get', 'userid' => $value['userid']));
if ($re_wx['errcode'] == 0 && $re_wx['mobile']) {//获取企业成员手机
$re_use = $this->mdUsers->get(array('mobile' => $re_wx['mobile']));
$biz_id = intval($re_use['biz_id']);
if ($biz_id) {
$re_wx = $this->wx_qyapi->get_external_contact(array('url' => 'get', 'external_userid' => $value['external_userid']));
if ($re_wx['errcode'] == 0) {
$follow_user = [];
foreach ($re_wx['follow_user'] as $key => $val) {
if ($val['userid'] == $value['userid']) {//找出当前企业员工
$follow_user = $val;
break;
}
}
$remark_mobiles = $follow_user['remark_mobiles'];//用户手机
if ($remark_mobiles && $remark_mobiles != '[]' && is_array($remark_mobiles)) {
$mobile = $remark_mobiles[0];//取第一个手机号
if ($mobile) {
if ($value['change_type'] == 'add_external_contact') {//新增
$wxqy = 1;
} else {//删除
$wxqy = -1;
}
$ret = $this->mdCustomers->update(['wxqy' => $wxqy], ['mobile' => $mobile, 'biz_id' => $biz_id]);
if ($ret == 1) {
$log[] = ['mobile' => $mobile, 'biz_id' => $biz_id, 'wxqy' => $wxqy];
$counts++;
}
}
}
}
}
}
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_customers_wxqy?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/users_log_t_num
* https://api.liche.cn/plan/temp/users_log_t_num
*/
public function users_log_t_num()
{
$this->load->model('receiver/receiver_customer_oplogs_model', 'mdCustomerOplogs');
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 200;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$where = ["log_date>=" => '2022-04-15', 'a_num>0 OR follows>0' => null];
$res = $this->mdUsersLog->select($where, 'id ASC', $param['page'], $param['size'], 'id,sale_id,biz_id,log_date');
if (!$res) {
echo '<br>本次更新完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/users_log_t_num">点击将再次更新>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$sale_id = $value['sale_id'];
$biz_id = $value['biz_id'];
$s_time = strtotime($value['log_date'] . ' 00:00:00');
$e_time = strtotime($value['log_date'] . ' 23:59:59');
$t_num = $this->mdCustomerOplogs->count(['uid' => $sale_id, 'type' => 5, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
"customer_id in(select id from lc_receiver_customers where admin_id={$sale_id} and biz_id={$biz_id})" => null]);
if ($t_num) {
$this->mdUsersLog->update(['t_num' => $t_num], ['id' => $value['id']]);
$log[] = ['id' => $value['id'], 't_num' => $t_num];
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/users_log_t_num?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新顾问新增企微/删除企微
* Created on: 2022/3/09 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_users_log
* https://api.liche.cn/plan/temp/receiver_users_log
*/
public function receiver_users_log()
{
$param = $this->input->get();
$page = intval($param['page']);
!$page && $page = 0;
ob_start(); //打开缓冲区
$user = [
0 => ['mobile' => '17346260816', 'userid' => 'LiLiXiang'], 1 => ['mobile' => '18150195895', 'userid' => 'ChenZongHui'],
2 => ['mobile' => '18950116819', 'userid' => 'JiangYaLi'], 3 => ['mobile' => '18965122277', 'userid' => 'DianCheDaRen'],
4 => ['mobile' => '13860199646', 'userid' => 'LinFan'], 5 => ['mobile' => '18659595528', 'userid' => 'ChenHuiCan01'],
6 => ['mobile' => '13507568055', 'userid' => '13507568055'], 7 => ['mobile' => '17606013180', 'userid' => 'LiuXinXin_2'],
8 => ['mobile' => '13380307317', 'userid' => 'caohui'], 9 => ['mobile' => '17359594819', 'userid' => 'HuJianPing'],
10 => ['mobile' => '15959209469', 'userid' => 'LiuChaHua'], 11 => ['mobile' => '18659197547', 'userid' => 'YuWei'],
12 => ['mobile' => '18559377877', 'userid' => 'ChenYuYou'], 13 => ['mobile' => '13599837805', 'userid' => 'ZengJiaMin'],
14 => ['mobile' => '18649670973', 'userid' => 'ZengLingYan'], 15 => ['mobile' => '15859720661', 'userid' => '15859720661'],
16 => ['mobile' => '13950003857', 'userid' => 'LiHuaiSong'], 17 => ['mobile' => '18950000118', 'userid' => 'LaiDaoAi'],
18 => ['mobile' => '18605086929', 'userid' => '18605086929'], 19 => ['mobile' => '13850083832', 'userid' => 'DuXiaoXia'],
20 => ['mobile' => '18559676954', 'userid' => 'ChenHuiMin'], 21 => ['mobile' => '13850726991', 'userid' => 'WuHaiLin'],
22 => ['mobile' => '15080308865', 'userid' => 'LinGuoPu'], 23 => ['mobile' => '17350035353', 'userid' => 'WeiJiaXing'],
24 => ['mobile' => '18018028742', 'userid' => 'WangZhiJie'], 25 => ['mobile' => '13074881868', 'userid' => 'ZhaoZhenRong'],
26 => ['mobile' => '13806009429', 'userid' => 'SuYaQin'], 27 => ['mobile' => '13860137801', 'userid' => 'LiTingTing'],
28 => ['mobile' => '18759985717', 'userid' => 'LiFengCan'], 29 => ['mobile' => '15980755194', 'userid' => 'ChenYingMing'],
30 => ['mobile' => '18876491999', 'userid' => 'huanghong'], 31 => ['mobile' => '18505912588', 'userid' => 'wangwenbin'],
32 => ['mobile' => '18906027570', 'userid' => 'LiJiaQunGongYongShouJi'], 33 => ['mobile' => '13559551217', 'userid' => 'LiMeiJin'],
34 => ['mobile' => '13313999284', 'userid' => 'lanpeifang'], 35 => ['mobile' => '13559080373', 'userid' => 'linxiaolong'],
36 => ['mobile' => '15859529108', 'userid' => 'hekaihong'], 37 => ['mobile' => '13559062229', 'userid' => 'ZhangQingYuan'],
38 => ['mobile' => '15259197710', 'userid' => 'LiJiaQun'], 39 => ['mobile' => '15880277181', 'userid' => 'ZhangShanBang'],
40 => ['mobile' => '13365014916', 'userid' => 'WuHuanZheng'], 41 => ['mobile' => '18650598580', 'userid' => 'XuHang'],
42 => ['mobile' => '13305996879', 'userid' => 'HuangJian'], 43 => ['mobile' => '13067246341', 'userid' => 'YuZhen'],
44 => ['mobile' => '18750080006', 'userid' => '18750080006'], 45 => ['mobile' => '15695928565', 'userid' => 'YouYongHuang'],
46 => ['mobile' => '18259235613', 'userid' => 'ShaoYunFei'], 47 => ['mobile' => '18650557687', 'userid' => 'ChenYingQin'],
48 => ['mobile' => '13599531683', 'userid' => 'LuoHuaiJie'], 49 => ['mobile' => '15960721797', 'userid' => 'ChenLingLing'],
50 => ['mobile' => '18506016272', 'userid' => 'WengQiZhang'], 51 => ['mobile' => '13616021231', 'userid' => 'LiuShengHua'],
52 => ['mobile' => '18250809990', 'userid' => 'LiuHaiQuan'], 53 => ['mobile' => '13860164563', 'userid' => 'DengBingWen'],
54 => ['mobile' => '18005933510', 'userid' => 'DongKaiJie'], 55 => ['mobile' => '18659299345', 'userid' => 'jimmy'],
56 => ['mobile' => '15659169988', 'userid' => 'HuangJunQiang'], 57 => ['mobile' => '13615020855', 'userid' => 'LaiLianYing'],
58 => ['mobile' => '13666060496', 'userid' => 'ZhangWei'], 59 => ['mobile' => '15106060016', 'userid' => 'WuDianZi'],
60 => ['mobile' => '15160770985', 'userid' => 'XuGuangYi'], 61 => ['mobile' => '13400600144', 'userid' => 'ZhouJinBin'],
62 => ['mobile' => '13950175671', 'userid' => 'ShaoBinHua'], 63 => ['mobile' => '18850511969', 'userid' => 'FuYangYi'],
64 => ['mobile' => '18106088956', 'userid' => 'LiZhengHui'], 65 => ['mobile' => '13275023326', 'userid' => 'YeJiaChen'],
66 => ['mobile' => '15659286291', 'userid' => 'YangYaQi'], 67 => ['mobile' => '13515074395', 'userid' => 'ChenMei'],
68 => ['mobile' => '18559672677', 'userid' => 'DianCheLiKe'], 69 => ['mobile' => '13665921959', 'userid' => 'ChenCuiYun'],
70 => ['mobile' => '15959013922', 'userid' => 'YuTing'], 71 => ['mobile' => '13906050306', 'userid' => 'ZhengYun']];
if (!$user[$page]) {
echo '<br>本次更新顾问客户数完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $param['page'] . '</span> 人';
echo '<br><br><a href="/plan/temp/receiver_users_log">点击将再次更新顾问客户数>>></a>';
exit;
}
$userid = $user[$page]['userid'];
$mobile = $user[$page]['mobile'];
$date = ['user' => $user[$page]];
if ($mobile) {
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$this->load->model("biz/biz_model", 'mdBiz');
$re_use = $this->mdUsers->get(['mobile' => $mobile, 'group_id < 4' => null, 'status' => 1], 'id,biz_id,userid,mobile,uname');
$date['re_use'] = $re_use;
if ($re_use) {//找到狸车宝用户
if (!$re_use['userid']) {//userid与手机绑定关连
$this->mdUsers->update(['userid' => $userid], ['id' => $re_use['id']]);
}
$sale_id = $id = $re_use['id'];
$biz_id = intval($re_use['biz_id']);
$re_biz = $this->mdBiz->get(['id' => $biz_id]);
$city_id = intval($re_biz['city_id']);
$type = intval($re_biz['type']);
$this->load->library('wx_qyapi', ['app' => 'lichene']);
$param_qy = ['url' => 'get_user_behavior_data'];
$param_qy['userid'] = $userid;
$param_qy['start_time'] = 1648742400;//2022-04-01 00:00:00
$param_qy['end_time'] = 1650643199;//2022-04-22 00:00:00
$re_wx = $this->wx_qyapi->get_external_contact($param_qy);
$adds = $updates = 0;
if ($re_wx['errcode'] == 0) {
foreach ($re_wx['behavior_data'] as $key => $value) {
$log_date = date('Y-m-d', $value['stat_time']);
$qy_adds = intval($value['new_contact_cnt']);
$qy_dels = intval($value['negative_feedback_cnt']);
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
if ($re_log) {
$ret = $this->mdUsersLog->update(['qy_adds' => $qy_adds, 'qy_dels' => $qy_dels], ['id' => $re_log['id']]);
$ret && $updates++;
} else {
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id,
'log_date' => $log_date, 'qy_adds' => $qy_adds, 'qy_dels' => $qy_dels, 'c_time' => $value['stat_time']];
$add_id = $this->mdUsersLog->add($add_item);
$add_id && $adds++;
}
}
}
$date['re_wx'] = $re_wx;
$date['adds'] = $adds;
$date['updates'] = $updates;
}
}
echo json_encode($date, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/receiver_users_log?page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新车辆调拨状态
* Created on: 2022/2/28 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/inventory_log
* https://api.liche.cn/plan/licheb/inventory_log
*/
public function inventory_log()
{
$params = $this->input->get();
$size = 100;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'inventory_log_id';
$id = $redis->get($redisKey);
!$id && $id = 0;
if ($rds) {//手动清除缓存
$id = 0;
$redis->delete($redisKey);
}
$log = array();
$this->load->model('items/Items_inventory_log_model', 'mdInventoryLog');
$this->load->model('items/items_model', 'mdItems');
$where = array('id >' => $id, 'status' => 0);
$res_log = $this->mdInventoryLog->select($where, 'id asc', 1, $size, 'id,item_id,biz_id,addr_id');
if (!$res_log) {
echo '执行到当前id' . $id . '暂无数据';
$redis->delete($redisKey);
return;
}
foreach ($res_log as $key => $value) {
$id = $value['id'];
$res_item = $this->mdItems->get(['id' => $value['item_id']]);
if ($res_item) {
$status = '';
if ($res_item['bill_time'] != '0000-00-00 00:00:00') {//已售
$status = -2;
} else if ($res_item['biz_id'] != $value['biz_id'] || $res_item['addr_id'] != $value['addr_id']) {//已调拨
$status = -1;
}
if ($status) {
$ret = $this->mdInventoryLog->update(['status' => $status], ['id' => $id]);
if ($ret) {
$log[] = array('id' => $id, 'status' => $status);
}
}
}
}
$redis->save($redisKey, $id);//保存最后id
if ($params['sd']) {
echo '<br>执行到当前id' . $id;
echo '<br>成功更新:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
echo '<br>';
}
echo '数据库获取:<br>';
echo json_encode($res_log, JSON_UNESCAPED_UNICODE);
}
}
/**
* Notes:更新车辆调拨异常
* Created on: 2022/1/4 13:53
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/transfer_abnormal
* https://api.liche.cn/plan/licheb/transfer_abnormal
*/
public function transfer_abnormal()
{
$this->load->model('items/items_transfer_model', 'mdTransfer');
$params = $this->input->get();
$ret = '';
if ($params['id']) {
$abnormal = intval($params['abnormal']);
$ret = $this->mdTransfer->update(['abnormal' => $abnormal], ['id' => $params['id']]);
}
if ($ret) {
echo "更新异常成功_{$params['id']}_$abnormal";
} else {
echo "更新异常失败";
}
}
/**
* 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
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customer_of
* https://api.liche.cn/plan/temp/receiver_customer_of
*/
public function receiver_customer_of()
{
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$param = $this->input->get();
if ($param['up_id']) {
$ret = $this->mdCustomers->update(['of_id' => 3, 'of2_id' => 37], ['id' => $param['up_id']]);
echo $ret ? '<br>更新成功:' : '<br>更新失败:';
exit;
}
$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("cf_id" => 29);
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,of_id');
if (!$res) {
echo '<br>本次更新客户线下来源完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/receiver_customer_of">点击将再次更新客户线下来源>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
if (!$value['of_id']) {
$this->mdCustomers->update(['of_id' => 5, 'of2_id' => 53], ['id' => $value['id']]);
$log[] = array('id' => $value['id'], 'of_id' => 5);
$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_of?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:新增街道
* Created on: 2021/12/14 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/add_street
* https://api.liche.cn/plan/temp/add_street
*/
public function add_street()
{
$this->load->model('sys/Sys_area_model', 'mdSysArea');
$this->load->model('sys/Sys_street_model', 'mdSysStreet');
$this->load->model('sys/Bs_street_model', 'mdBsStreet');//表已经删除
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 5;
!$param['page'] && $param['page'] = 1;
$counts = intval($param['counts']);
ob_start(); //打开缓冲区
$res = $this->mdSysArea->select(['status' => 1], 'id ASC', $param['page'], $param['size'], 'county_id');
if (!$res) {
echo '<br>本次新增街道完成了:';
echo '<br><br>成功新增街道 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/add_street">点击将再次新增街道>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$res_bs = $this->mdBsStreet->select(['AREA_CODE' => $value['county_id']], 'STREET_ID ASC', 0, 0, 'STREET_CODE,STREET_NAME');
$add = [];
foreach ($res_bs as $key2 => $value2) {
$add[] = ['county_id' => $value['county_id'], 'street_id' => $value2['STREET_CODE'], 'street_name' => $value2['STREET_NAME']];
$log[] = array('street_name' => $value2['STREET_NAME'], 'street_id' => $value2['STREET_CODE']);
$counts++;
}
if ($add) {
$this->mdSysStreet->add_batch($add);
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/add_street?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新狸车宝渠道门店
* Created on: 2021/9/18 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/channel_biz
* https://api.liche.cn/plan/temp/channel_biz
*/
public function channel_biz()
{
$this->load->model('app/licheb/App_licheb_users_model', 'mdUsers');
$this->load->model('app/licheb/App_licheb_channel_biz_model', 'mdChannelBiz');
$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('status ' => 1, 'group_id' => 4);
$res = $this->mdUsers->select($where, 'id ASC', $param['page'], $param['size'], 'id,biz_id,uname');
if (!$res) {
echo '<br>本次更新狸车宝渠道门店完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/channel_biz">点击将再次更新狸车宝渠道门店>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
if ($value['biz_id']) {
$biz_id_arr = explode(',', $value['biz_id']);
foreach ($biz_id_arr as $key2 => $value2) {
$where = ["uid" => $value['id'], 'biz_id' => $value2];
$re_cb = $this->mdChannelBiz->get($where);
if (!$re_cb) {
$where['c_time'] = time();
$this->mdChannelBiz->add($where);
}
}
$log[] = array('uname' => $value['uname'], 'biz_id' => $value['biz_id']);
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/channel_biz?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新商品操作日志
* Created on: 2021/9/18 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/items_oplogs
* https://api.liche.cn/plan/temp/items_oplogs
*/
public function items_oplogs()
{
$this->load->model('items/items_model', 'mdItems');
$this->load->model('items/items_oplogs_model', 'mdItemsOplogs');
$this->load->library('entity/items_entity');
$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('status >' => 0, 'in_time <>' => '0000-00-00 00:00:00');
$res = $this->mdItems->select($where, 'id ASC', $param['page'], $param['size'], 'id,biz_id,addr_id,in_time');
if (!$res) {
echo '<br>本次更新商品操作日志完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/temp/items_oplogs">点击将再次更新商品操作日志>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$re_c = $this->mdItemsOplogs->get(array('item_id' => $value['id'], 'biz_id' => $value['biz_id'], 'type' => 1));
if (!$re_c['id']) {
if ($value['biz_id'] == -1 && !$value['addr_id']) {
continue;
}
$params = array('item_id' => $value['id'], 'type' => 1, 'uid' => 0, 'uname' => '系统'
, 'com_time' => $value['in_time'], 'biz_id' => $value['biz_id'], 'addr_id' => $value['addr_id']);
$this->items_entity->add_log($params);
$log[] = array('id' => $value['id']);
$counts++;
}
}
echo '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
echo json_encode($res, JSON_UNESCAPED_UNICODE);
header('refresh:3;url=/plan/temp/items_oplogs?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
/**
* Notes:更新客户表来源id
* Created on: 2021/9/18 11:58
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customer
* https://api.liche.cn/plan/temp/receiver_customer
*/
public function receiver_customer()
{
$this->load->model('receiver/receiver_clues_model', 'mdClues');
$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('rid >' => 0);
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,rid,cf_id');
if (!$res) {
echo '<br>本次更新客户来源id完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/xmcard/tem_wxqy">点击将再次更新客户来源id>>></a>';
exit;
}
$log = array();
foreach ($res as $key => $value) {
$re_c = $this->mdClues->get(array('id' => $value['rid']));
if ($re_c['cf_id']) {
$this->mdCustomers->update(array('cf_id' => $re_c['cf_id']), array('id' => $value['id']));
$log[] = array('id' => $value['id'], 'cf_id' => $re_c['cf_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?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
ob_end_flush();//输出全部内容到浏览器
}
//更新下定时间
public function order_time()
{
$this->load->model('receiver/order/receiver_orders_model');
$this->load->model('app/liche/app_liche_orders_model');
$param = $this->input->get();
$param['page'] = intval($param['page']);
$param['size'] = intval($param['size']);
!$param['size'] && $param['size'] = 50;
!$param['page'] && $param['page'] = 1;
$where = [
'status>' => 0,
'order_time' => '0000-00-00 00:00:00',
];
$rows = $this->receiver_orders_model->select($where, 'id ASC', $param['page'], $param['size'], 'id');
if ($rows) {
foreach ($rows as $key => $val) {
$pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 1]);
if (!$pay_row) {
$pay_row = $this->app_liche_orders_model->get(['o_id' => $val['id'], 'status' => 1, 'type' => 4]);
}
if ($pay_row) {
$this->receiver_orders_model->update(['order_time' => $pay_row['pay_time']], ['id' => $val['id']]);
}
}
$ids = implode(',', array_column($rows, 'id'));
echo "do:{$ids} ";
} else {
echo 'finish';
}
}
//创建支付订单
public function c_payorder()
{
$this->load->model('receiver/order/receiver_orders_model');
$this->load->model('app/liche/app_liche_users_model');
$this->load->model('app/liche/app_liche_orders_model');
$this->load->library('receiver/orders_entity');
$params = $this->input->get();
$params['page'] = intval($params['page']);
$params['size'] = intval($params['size']);
!$params['size'] && $params['size'] = 10;
!$params['page'] && $params['page'] = 1;
if ($params['id']) {
$where = [
'id' => $params['id']
];
} else {
$where = [
'status>' => 0,
'status<' => 3,
'biz_id !=' => 1
];
}
$rows = $this->receiver_orders_model->select($where, 'id asc', $params['page'], $params['size']);
if ($rows) {
$data = [];
foreach ($rows as $key => $val) {
$userinfo = $this->app_liche_users_model->get(['mobile' => $val['mobile']]);
$result = $this->orders_entity->check_finish_v2($val['id'], $userinfo);
$data[] = [
'id' => $val['id'],
'result' => $result,
];
}
echo json_encode($data, JSON_UNESCAPED_UNICODE);
} else {
echo 'finish';
}
}
}