34 lines
1.7 KiB
PHP

<?php
namespace app\statistics\logic;
use app\common\logic\BaseLogic;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_visit\StoreVisit;
use app\common\model\user_recharge\UserRecharge;
class UserLogic extends BaseLogic
{
public static function userCount($store_id,$dates)
{
$data = [];
foreach ($dates as $k=>$date) {
$data[$k]['newUserCount']=UserRecharge::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
$data[$k]['viewUserCount']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->group('uid')->count();
$data[$k]['totalUserCount']=UserRecharge::where('create_time','<',strtotime($date) )->where('store_id',$store_id)->where('paid',1)->where('recharge_type','INDUSTRYMEMBERS')->count();
}
return $data;
}
public static function TradeCount($store_id,$dates)
{
$data = [];
foreach ($dates as $k=>$date) {
$data[$k]['date']=$date;
$data[$k]['visitUser']=StoreVisit::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_visit_count_' . $date, 300)->group('uid')->count();
$data[$k]['orderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->cache('statistics_store_order_count_' . $date, 300)->group('uid')->count();
$data[$k]['payOrderUser']=StoreOrder::whereDay('create_time', $date)->where('store_id',$store_id)->where('paid',1)->cache('statistics_store_order_pay_count_' . $date, 300)->group('uid')->count();
}
return $data;
}
}