customer_415_2

This commit is contained in:
dengbw
2022-04-15 16:38:01 +08:00
parent 5a6ca3f952
commit 48436bae74
2 changed files with 19 additions and 23 deletions
+17 -22
View File
@@ -19,7 +19,7 @@ class Licheb extends HD_Controller
}
/**
* Notes:顾问_日志
* Notes:顾问日志
* Created on: 2021/10/19 17:15
* Created by: dengbw
* https://liche-api-dev.xiaoyu.com/plan/licheb/users_log?sd=1
@@ -40,7 +40,7 @@ class Licheb extends HD_Controller
}
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
$size = 2;//每次最多处理多少条
$size = 200;//每次最多处理多少条
$rds = intval($this->input->get('rds'));
$redis = &load_cache('redis');
$redisKey = 'app_licheb_users_log_id';
@@ -50,7 +50,6 @@ class Licheb extends HD_Controller
$redis->delete($redisKey);
}
$id = $redis->get($redisKey);
$id = 19;
!$id && $id = 0;
$log = [];
$where = ['id >' => $id, 'group_id < 4' => null, 'status' => 1];
@@ -63,30 +62,30 @@ class Licheb extends HD_Controller
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrdersV2');
$this->load->model("biz/biz_model", 'mdBiz');
$offlineSources = $this->mdCustomers->offlineSources();
$addDate = [];
$str_biz_ids = implode(',', array_unique(array_column($res, 'biz_id')));
$map_biz = $this->mdBiz->map('id', 'city_id', ["id in({$str_biz_ids})" => null]);
$map_biz = $this->mdBiz->map('id', 'city_id,type', ["id in({$str_biz_ids})" => null]);
foreach ($res as $key => $value) {
$sale_id = $value['id'];
$biz_id = intval($value['biz_id']);
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id]);
$re_log = $this->mdUsersLog->get(['log_date' => $log_date, 'sale_id' => $sale_id, 'biz_id' => $biz_id]);
if (!$re_log) {//判断当天是否已加入
$s_time = strtotime($log_date . ' 00:00:00');
$e_time = strtotime($log_date . ' 23:59:59');
$city_id = intval($map_biz[$value['biz_id']]);
$a_num = $this->mdCustomerOpLogs->count(['type' => 4, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
$city_id = intval($map_biz[$biz_id]['city_id']);
$type = intval($map_biz[$biz_id]['type']);
$a_num = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type' => 4, '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]
);
$follows = $this->mdCustomerOpLogs->count(['type<>' => 3, 'c_time>=' => $s_time, 'c_time<=' => $e_time,
$follows = $this->mdCustomerOpLogs->count(['uid' => $sale_id, 'type<>' => 3, '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], 'distinct(customer_id)'
);
$orders = $this->mdOrdersV2->count(['order_time<>' => '0000-00-00 00:00:00', 'status>=' => 0,
'c_time>=' => $s_time, 'c_time<=' => $e_time]
$orders = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
'order_time>=' => "{$log_date} 00:00:00", 'order_time<=' => "{$log_date} 23:59:59"]
);
$bills = $this->mdOrdersV2->count(['bill_time<>' => '0000-00-00 00:00:00', 'status>=' => 0,
'c_time>=' => $s_time, 'c_time<=' => $e_time]
$bills = $this->mdOrdersV2->count(['sale_id' => $sale_id, 'biz_id' => $biz_id, 'status>=' => 0,
'bill_time>=' => "{$log_date} 00:00:00", 'bill_time<=' => "{$log_date} 23:59:59"]
);
$add_item = ['sale_id' => $sale_id, 'biz_id' => $value['biz_id'], 'city_id' => $city_id, 'a_num' => $a_num
$add_item = ['sale_id' => $sale_id, 'biz_id' => $biz_id, 'type' => $type, 'city_id' => $city_id, 'a_num' => $a_num
, 'orders' => $orders, 'bills' => $bills, 'follows' => $follows, 'log_date' => $log_date, 'c_time' => time()];
$customer_json = '';
foreach ($offlineSources as $key1 => $value1) {
@@ -105,19 +104,15 @@ class Licheb extends HD_Controller
$customer_json[$key1] = ['name' => $value1['name'], 'num' => $customer_num1, 'list' => $list];
}
}
$customer_json && $add_item['customer_json'] = $customer_json;
//$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
$addDate[] = $add_item;
$log[] = array('id' => $sale_id, 'addDate' => $add_item);
$customer_json && $add_item['customer_json'] = json_encode($customer_json, JSON_UNESCAPED_UNICODE);
$add_id = $this->mdUsersLog->add($add_item);
$add_id && $log[] = array('id' => $sale_id, 'addDate' => $add_item);
}
}
if ($addDate && count($addDate)) {
//$this->mdUsersLog->add_batch($addDate);
}
$redis->save($redisKey, $id, 24 * 3600);//保存最后id
if ($params['sd']) {
echo '<br>执行到当前顾问id' . $redis->get($redisKey);
echo '日期:' . json_encode(array('log_date' => $log_date), JSON_UNESCAPED_UNICODE);
echo ' 日期:' . $log_date;
echo '<br>成功新增:<br>';
if ($log) {
echo json_encode($log, JSON_UNESCAPED_UNICODE);
+2 -1
View File
@@ -34,7 +34,8 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 1);//给销售发送待回访短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 1);//给店长发送待分配短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 1);//给店长发送待分配短信
$plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 10);//库存车辆日志
$plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
$plan[] = array('url' => base_url(array('plan', 'biz', 'settle')), 'interval' => 1);
$plan[] = array('url' => base_url(array('plan', 'order', 'up_old_status')), 'interval' => 30); //更新旧订单状态