inventory_302
This commit is contained in:
@@ -18,6 +18,67 @@ class Licheb extends HD_Controller
|
||||
$this->load->model('receiver/receiver_customers_visit_model', 'mdCustomersVisit');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user