stock get_month debug params
This commit is contained in:
@@ -155,6 +155,87 @@ class Stock extends HD_Controller
|
||||
}
|
||||
|
||||
private function monthSelect($params)
|
||||
{
|
||||
var_dump($params);
|
||||
$type_ary = $this->mdBiz->type_ary();
|
||||
$params['type'] = $params['type'] ? $params['type'] : '';
|
||||
$typeStr = '1,2,3';//品牌 合伙 代理
|
||||
$typeAry = [];
|
||||
foreach ($type_ary as $k => $v) {
|
||||
if (strstr($typeStr . ',', $k . ',')) {
|
||||
$typeAry[$k] = $v;
|
||||
}
|
||||
}
|
||||
$biz = $res_biz = $date_months = $dateMonths = [];
|
||||
if ($params['type'] || $params['biz_id'] || $params['city_id']) {
|
||||
$start_date = date('Y-m', strtotime("-11 month"));//取最近12个月
|
||||
$end_date = date('Y-m');
|
||||
$date_months = $this->dateMonths($start_date, $end_date);
|
||||
rsort($date_months);
|
||||
foreach ($date_months as $v) {
|
||||
$firstDay = $v . '-01' . ' 00:00:00';
|
||||
$lastDay = date('Y-m-d', strtotime("$firstDay +1 month -1 day"));
|
||||
$dateMonths[] = ['name' => $v, 'firstDay' => $v . '-01', 'lastDay' => $lastDay];
|
||||
}
|
||||
$type = $params['type'] ? $params['type'] : $typeStr;
|
||||
$where_biz['status'] = 1;
|
||||
$where_biz["type in({$type})"] = null;
|
||||
if ($params['biz_id']) {
|
||||
$where_biz['id'] = $params['biz_id'];
|
||||
} else {
|
||||
$params['city_id'] && $where_biz['city_id'] = $params['city_id'];
|
||||
$params['county_id'] && $where_biz['county_id'] = $params['county_id'];
|
||||
}
|
||||
$res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id,biz_name');
|
||||
foreach ($res_biz as $v) {
|
||||
$months = [];
|
||||
if ($params['export'] == 1) {
|
||||
$months['biz_name'] = $v['biz_name'];
|
||||
}
|
||||
foreach ($dateMonths as $v2) {
|
||||
$where2 = $where3 = ['biz_id' => $v['id'], 'log_date>=' => $v2['firstDay'], 'log_date<=' => $v2['lastDay']];
|
||||
$res_log = $this->mdStockLog->select_groupby('s_id', $where2, 'id desc', 0, 0, 'brand_id,s_id');
|
||||
$data = '';
|
||||
if ($res_log) {
|
||||
$str_ids = implode(',', array_unique(array_column($res_log, 'brand_id')));
|
||||
$map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]);
|
||||
$str_ids = implode(',', array_unique(array_column($res_log, 's_id')));
|
||||
$map_sery = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]);
|
||||
foreach ($res_log as $v3) {
|
||||
$where3['s_id'] = $v3['s_id'];
|
||||
$res_log2 = $this->mdStockLog->select_groupby('item_id', $where3, "total desc,id desc", 1, 1
|
||||
, "count(id) as total");
|
||||
$count = $res_log2 ? $res_log2[0]['total'] : 0;
|
||||
$title = "{$map_brand[$v3['brand_id']]}-{$map_sery[$v3['s_id']]} {$count}天";
|
||||
$data = $data ? $data . ',' . $title : $title;
|
||||
}
|
||||
}
|
||||
if ($params['export'] == 1) {
|
||||
$months[$v2['name']] = $data;
|
||||
} else {
|
||||
$months[] = ['name' => $v2['name'], 'data' => $data];
|
||||
}
|
||||
}
|
||||
if ($params['export'] == 1) {
|
||||
$biz[] = $months;
|
||||
} else {
|
||||
$biz[] = ['biz_name' => $v['biz_name'], 'months' => $months];
|
||||
}
|
||||
}
|
||||
}
|
||||
!$params['city_id'] && $params['city_id'] = '';
|
||||
!$params['county_id'] && $params['county_id'] = '';
|
||||
!$params['biz_id'] && $params['biz_id'] = '';
|
||||
$showData['typeAry'] = $typeAry;
|
||||
$showData['typeStr'] = $typeStr;var_dump($showData);var_dump($params);
|
||||
$data['showData'] = $showData;
|
||||
$data['biz'] = $biz;
|
||||
$data['date_months'] = $date_months;
|
||||
$data['params'] = $params;
|
||||
$data['_title'] = '库存统计';
|
||||
return $data;
|
||||
}
|
||||
private function monthSelect_($params)
|
||||
{
|
||||
$type_ary = $this->mdBiz->type_ary();
|
||||
$params['type'] = $params['type'] ? $params['type'] : '';
|
||||
|
||||
Reference in New Issue
Block a user