inventory_303

This commit is contained in:
dengbw
2022-03-03 10:38:50 +08:00
parent 44c3fda88e
commit af903d1e64
+14 -7
View File
@@ -391,25 +391,32 @@ class User extends Wxapp
];
$brands = $this->auto_brand_model->select($where, '', 0, 0, 'id,name');
foreach ($brands as $key2 => $val2) {
// $count_items = $this->mdItems->count(['brand_id' => $val2['id'], 'status<>' => 0, 'biz_id' => $val['id']
// , 'bill_time' => '0000-00-00 00:00:00']);
$res_items = $this->mdItems->select(['brand_id' => $val2['id'], 'status<>' => 0, 'biz_id' => $val['id']
, 'bill_time' => '0000-00-00 00:00:00'], 'in_time asc', 0, 0, 'id,in_time,c_time');
$str_ids = $res_items ? implode(',', array_column($res_items, 'id')) : '';
$bg_color = '#999';
$name = $val2['name'];
$name2 = '';
if ($str_ids) {
$bg_color = '#fff';
$in_time = $res_items[0]['in_time'] != '0000-00-00 00:00:00' ? strtotime($res_items[0]['in_time']) : $res_items[0]['c_time'];
$re_logs = $this->mdItemsOplogs->select(["item_id in({$str_ids})" => null, 'type' => 2, 'biz_id_to' => $val['id']
], 'com_time asc', 1, 1, 'com_time');//找出调拨最早
$re_logs && $in_time = strtotime($re_logs[0]['com_time']);
], 'com_time asc', 1, 1, 'item_id,com_time');//找出调拨最早
if ($re_logs && $re_logs[0]['item_id']) {
$this->load->model('items/items_transfer_model', 'mdTransfer');
$re_tran = $this->mdTransfer->get(['item_id' => $re_logs[0]['item_id'], 'status' => 1]);
if ($re_tran) {
$in_time = '';
$name2 = '(在途)';
} else {
$in_time = strtotime($re_logs[0]['com_time']);
}
}
if ($in_time) {//计算库存天数
$days = round((time() - $in_time) / 3600 / 24);
$days > 0 && $name = $val2['name'] . '(' . $days . '天)';
$days > 0 && $name2 = '(' . $days . '天)';
}
}
$auto_brands[] = ['name' => $name, 'bg_color' => $bg_color];
$auto_brands[] = ['name' => $val2['name'] . $name2, 'bg_color' => $bg_color];
}
}
$lists[] = [