507 lines
21 KiB
PHP
507 lines
21 KiB
PHP
<?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/receiver_customer_defeat
|
||
* https://api.liche.cn/plan/temp/receiver_customer_defeat
|
||
*/
|
||
public function receiver_customer_defeat()
|
||
{
|
||
$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 = ["status=3 OR defeat_time<>0" => null];
|
||
$res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,jsondata,status,defeat_time');
|
||
if (!$res) {
|
||
echo '<br>本次更新战败客户信息完成了:';
|
||
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
|
||
echo '<br><br><a href="/plan/temp/receiver_customer_defeat">点击将再次更新战败客户信息>>></a>';
|
||
exit;
|
||
}
|
||
$log = array();
|
||
foreach ($res as $key => $value) {
|
||
$upDate = [];
|
||
if ($value['status'] == 3) {
|
||
$jsondata = $value['jsondata'] ? json_decode($value['jsondata'], true) : [];
|
||
if ($jsondata['defeat']['pass_time']) {
|
||
$upDate = ['def_time' => $jsondata['defeat']['pass_time']];//更新战败时间
|
||
}
|
||
} else if ($value['defeat_time'] > 0) {//申请中
|
||
$upDate = ['if_defeat' => 1];
|
||
} else if ($value['defeat_time'] == -1) {//再战
|
||
$upDate = ['if_defeat' => 2];
|
||
}
|
||
if ($upDate) {
|
||
$this->mdCustomers->update($upDate, ['id' => $value['id']]);
|
||
$log[] = ['id' => $value['id'], 'upDate' => $upDate];
|
||
$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_defeat?counts=' . $counts . '&size=' . $param['size'] . '&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';
|
||
}
|
||
}
|
||
}
|