修改交易统计
This commit is contained in:
parent
d238d6b238
commit
695a47e8c5
@ -77,12 +77,43 @@ class WorkbenchLogic extends BaseLogic
|
||||
$timeRange = [1, (int)date('n')];
|
||||
$field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(pay_price) as pay_price';
|
||||
}
|
||||
$data['order_list'] = StoreOrder::field($field)
|
||||
$orderList = StoreOrder::field($field)
|
||||
->where('store_id', $params['store_id'])
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('pay_time', $startTime, $endTime)
|
||||
->group($group)
|
||||
->select();
|
||||
->select()
|
||||
->toArray();
|
||||
$userList = StoreOrder::field($field . ',count(uid) as user_num')
|
||||
->where('store_id', $params['store_id'])
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('pay_time', $startTime, $endTime)
|
||||
->group($group . ',uid')
|
||||
->select()
|
||||
->toArray();
|
||||
$orderList = reset_index($orderList, 'pay_time');
|
||||
$userList = reset_index($userList, 'pay_time');
|
||||
$orderListTmp = [];
|
||||
$userListTmp = [];
|
||||
for ($i = $timeRange[0]; $i <= $timeRange[1]; $i++) {
|
||||
if (!isset($orderList[$i])) {
|
||||
$orderListTmp[$i] = ['pay_time' => $i, 'pay_price' => 0];
|
||||
} else {
|
||||
$orderListTmp[$i] = ['pay_time' => $i, 'pay_price' => $orderList[$i]['pay_price']];
|
||||
}
|
||||
if (!isset($userList[$i])) {
|
||||
$userListTmp[$i] = ['pay_time' => $i, 'user_num' => 0];
|
||||
} else {
|
||||
$userListTmp[$i] = ['pay_time' => $i, 'user_num' => $userList[$i]['user_num']];
|
||||
}
|
||||
}
|
||||
$data['statistics'] = [
|
||||
'range' => array_column($orderListTmp, 'pay_time'),
|
||||
'data' => [
|
||||
array_values($orderListTmp),
|
||||
array_values($userListTmp)
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user