feat: 修改交易统计逻辑以支持按日期查询

This commit is contained in:
mkm 2024-06-20 11:27:14 +08:00
parent 283e8f1747
commit 4339cf481e
3 changed files with 8 additions and 12 deletions

View File

@ -359,7 +359,8 @@ class WorkbenchController extends BaseAdminController
//交易趋势
public function bottom_trade()
{
$data=(new TradeStatisticLogic())->getBottomTrade(['data'=>'2024/05/21-2024/06/19']);
$date=$this->request->get('date','');
$data=(new TradeStatisticLogic())->getBottomTrade(['data'=>$this->getDay($date)]);
return $this->data($data);
}

View File

@ -172,7 +172,7 @@ class TradeStatisticLogic extends BaseLogic
$query->group("FROM_UNIXTIME(create_time, '$timeUinx')");
})
->order('create_time ASC')->select()->toArray();
$monthCurveOrderCount = $this->trendYdata((array)$monthCurveOrderCount, $where['timeKey']);
$monthCurveOrderCount = $this->trendYdata((array)$monthCurveOrderCount, $timeKey);
//上月订单数
$lastOrderCountWhere['timeKey'] = $this->TimeConvert("last_month");
$where['timeKey'] = [
@ -228,14 +228,10 @@ class TradeStatisticLogic extends BaseLogic
})
->order('create_time ASC')->select()->toArray();
$monthCurveOrderPeople = $this->trendYdata((array)$monthCurveOrderPeople, $where['timeKey']);
$monthCurveOrderPeople = $this->trendYdata((array)$monthCurveOrderPeople, $timeKey);
//上月支付人数
$timeKey = $this->TimeConvert("last_month");
$where['timeKey'] = [
"start_time" => strtotime($timeKey['start_time']),
"end_time" => strtotime($timeKey['end_time']),
"days" => $timeKey['days']
];
// $timeKey = $this->TimeConvert("last_month");
$lastPayOrderPeople = $storeOrder->where($monthOrderPeopleWhere)->whereMonth('create_time')->group('uid')->count();
//上月支付曲线

View File

@ -135,8 +135,8 @@ class UserStatisticLogic extends BaseLogic
$xAxis = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'];
$timeType = '%H';
} elseif ($num != 0) {
$dt_start = strtotime($time[0]);
$dt_end = strtotime($time[1]);
$dt_start = $time[0];
$dt_end = $time[1];
while ($dt_start <= $dt_end) {
if ($num == 30) {
$xAxis[] = date('Y-m', $dt_start);
@ -149,7 +149,6 @@ class UserStatisticLogic extends BaseLogic
}
}
}
$visitPeople = array_column($userVisit->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');
$newPeople = array_column($user->getTrendData($time, $channelType, $timeType), 'num', 'days');
$paidPeople = array_column($order->getTrendData($time, $channelType, $timeType, 'count(distinct(uid))'), 'num', 'days');