diff --git a/api/controllers/plan/Licheb.php b/api/controllers/plan/Licheb.php
index b0ea01f5..a4c66414 100644
--- a/api/controllers/plan/Licheb.php
+++ b/api/controllers/plan/Licheb.php
@@ -17,6 +17,66 @@ class Licheb extends HD_Controller
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
}
+ /**
+ * Notes:更新盘点状态
+ * Created on: 2022/05/24 17:15
+ * Created by: dengbw
+ * https://liche-api-dev.xiaoyu.com/plan/licheb/inventory_log?sd=1
+ * https://api.liche.cn/plan/licheb/inventory_log
+ */
+ public function inventory_log()
+ {
+ $params = $this->input->get();
+ $hour = date('H.i');
+ if (($hour > 05.00 && $hour < 06.00) || $params['sd']) {
+ if ($params['sd']) {
+ echo "开始执行盘点[{$hour}]
";
+ }
+ } else {
+ echo '[05.00-06.00]执行盘点[' . $hour . ']
';
+ return;
+ }
+ $this->load->model('items/Items_inventory_log_model', 'mdInventoryLog');
+ $this->load->model('items/items_model', 'mdItems');
+ $time = strtotime("-1 day");//昨天此时的时间戳
+ $size = 200;//每次最多处理多少条
+ $rds = intval($this->input->get('rds'));
+ $redis = &load_cache('redis');
+ $t_day = date('Y-m-d', $time);
+ $redisKey = 'app_licheb_inventory_log_id_' . $t_day;
+ if ($rds) {
+ $redis->delete($redisKey);
+ }
+ $id = $redis->get($redisKey);
+ !$id && $id = 0;
+ $log = [];
+ $where = ['id >' => $id, 'status<>' => 1];
+ $res = $this->mdInventoryLog->select($where, 'id asc', 1, $size, 'id,item_id');
+ if (!$res) {
+ echo '执行到当前盘点id:' . $id . '暂无数据';
+ return;
+ }
+ foreach ($res as $k => $v) {
+ $re = $this->mdItems->get(['id' => $v['item_id']]);
+ if (!$re || $re['bill_time'] != '0000-00-00 00:00:00') {
+ $this->mdInventoryLog->update(['status' => 1], ['id' => $v['id']]);
+ $log = ['id' => $v['id'], 'item_id' => $v['item_id']];
+ }
+ }
+ $redis->save($redisKey, $id, 24 * 3600);//保存最后id
+ if ($params['sd']) {
+ echo '
执行到当前盘点id:' . $redis->get($redisKey);
+ echo ' 日期:' . $t_day;
+ echo '
成功更新:
';
+ if ($log) {
+ echo json_encode($log, JSON_UNESCAPED_UNICODE);
+ echo '
';
+ }
+ echo '数据库获取:
';
+ echo json_encode($res, JSON_UNESCAPED_UNICODE);
+ }
+ }
+
/**
* Notes:顾问日志
* Created on: 2021/10/19 17:15
diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php
index bd0efafd..e0fba881 100644
--- a/api/controllers/plan/Plan.php
+++ b/api/controllers/plan/Plan.php
@@ -37,6 +37,7 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 2);//给店长发送待分配短信
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
$plan[] = array('url' => base_url(array('plan', 'licheb', 'bizs_log')), 'interval' => 2);//门店日志
+ $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);//更新车主企业微信