1
This commit is contained in:
1 parent
83e1517c93
commit
0be377dcfc
5 files changed
+136
-3
No files matched your search
@@ -21,6 +21,7 @@ use App\Models\Zhuanfas;
|
||||
use App\Models\Ducks;
|
||||
use App\Models\Visitor;
|
||||
use App\Models\CountVisitor;
|
||||
use App\Models\CountUser;
|
||||
use App\Services\TomTool\TgSendFormat;
|
||||
use App\Services\IM\Telegram;
|
||||
use App\Utils\Tools;
|
||||
@@ -64,6 +65,118 @@ final class Cron
|
||||
TgStep::where("date", "<=", date('Y-m-d', strtotime('-1 day')))->delete();
|
||||
}
|
||||
|
||||
public static function userCount(): void
|
||||
{
|
||||
$sPrevDate = date("Y-m-d", strtotime("-2 day"));
|
||||
$sPrevDateStart = date("Y-m-d 00:00:00", strtotime("-2 day"));
|
||||
$sPrevDateEnd = date("Y-m-d 23:59:59", strtotime("-2 day"));
|
||||
$sPrevTimeStart = strtotime($sPrevDateStart);
|
||||
$sPrevTimeEnd = strtotime($sPrevDateEnd);
|
||||
$sPrevDate30 = date("Y-m-d", strtotime("-30 day"));
|
||||
echo "<pre>";
|
||||
|
||||
//// 访客统计 start
|
||||
$aVisitorCount = Visitor::select('from', DB::raw('count(*) as count'))
|
||||
->groupBy('from')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$aVisitorMix = [];
|
||||
foreach ($aVisitorCount as $row) {
|
||||
$aVisitorMix[$row['from']]['count'] = $row['count'];
|
||||
}
|
||||
//// 访客统计 end
|
||||
|
||||
// 注册数量
|
||||
$aRegCount = User::select('from', DB::raw('count(*) as count'))
|
||||
->whereDate('reg_date', $sPrevDate)
|
||||
->groupBy('from')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$aRegMix = [];
|
||||
foreach ($aRegCount as $row) {
|
||||
|
||||
if (isset($row['from'])) {
|
||||
$sFrom = $row['from'];
|
||||
} else {
|
||||
$sFrom = '无';
|
||||
}
|
||||
|
||||
$aRegMix[$sFrom]['count'] = $row['count'];
|
||||
}
|
||||
|
||||
//// 付款 start
|
||||
$aOrder = Order::whereBetween("update_time", [$sPrevTimeStart, $sPrevTimeEnd])->where("status", "activated")->get()->toArray();
|
||||
|
||||
// 标记是否是新用户
|
||||
$oUserModel = new User();
|
||||
$iPayCount = 0;
|
||||
$iMoneyCount = 0;
|
||||
$iPayCountNew = 0;
|
||||
$iPayCountOld = 0;
|
||||
$iMoneyCountNew = 0;
|
||||
$iMoneyCountOld = 0;
|
||||
$sFrom = '';
|
||||
$aUserMix = [];
|
||||
foreach ($aOrder as $row) {
|
||||
|
||||
$iPayCount ++;
|
||||
$iMoneyCount += $row["price"];
|
||||
|
||||
$oUser = $oUserModel->where("id", $row["id"])->first();
|
||||
|
||||
if (isset($oUser['from'])) {
|
||||
$sFrom = $oUser['from'];
|
||||
} else {
|
||||
$sFrom = "无";
|
||||
}
|
||||
|
||||
if ( ($row['update_time'] - strtotime($oUser->reg_date)) < (86400 * 30) ) {
|
||||
$iPayCountNew ++;
|
||||
$iMoneyCountNew += $row["price"];
|
||||
} else {
|
||||
$iPayCountOld ++;
|
||||
$iMoneyCountOld += $row["price"];
|
||||
// var_dump($row);
|
||||
}
|
||||
|
||||
$aUserMix[$sFrom]['pay_count'] = $iPayCount;
|
||||
$aUserMix[$sFrom]['money_count'] = $iMoneyCount;
|
||||
$aUserMix[$sFrom]['pay_count_new'] = $iPayCountNew;
|
||||
$aUserMix[$sFrom]['pay_count_old'] = $iPayCountOld;
|
||||
$aUserMix[$sFrom]['money_count_new'] = $iMoneyCountNew;
|
||||
$aUserMix[$sFrom]['money_count_old'] = $iMoneyCountOld;
|
||||
|
||||
}
|
||||
|
||||
$aAllMix = array_merge($aVisitorMix, $aRegMix, $aUserMix);
|
||||
|
||||
|
||||
foreach ($aAllMix as $k => $v) {
|
||||
|
||||
$oCountUserModel = new CountUser();
|
||||
$oCountUserModel->from = $k;
|
||||
$oCountUserModel->count_from = $aVisitorMix[$k]['count'] ?? 0;
|
||||
$oCountUserModel->count_reg = $aRegMix[$k]['count'] ?? 0;
|
||||
$oCountUserModel->count_pay = $UserMix[$k]['pay_count'] ?? 0;
|
||||
$oCountUserModel->count_pay_new = $UserMix[$k]['pay_count_new'] ?? 0;
|
||||
$oCountUserModel->count_pay_old = $UserMix[$k]['pay_count_old'] ?? 0;
|
||||
$oCountUserModel->count_money = $UserMix[$k]['money_count'] ?? 0;
|
||||
$oCountUserModel->count_money_new = $UserMix[$k]['money_count_new'] ?? 0;
|
||||
$oCountUserModel->count_money_old = $UserMix[$k]['money_count_old'] ?? 0;
|
||||
$oCountUserModel->date = $sPrevDate;
|
||||
$r = $oCountUserModel->save();
|
||||
|
||||
}
|
||||
|
||||
|
||||
var_dump($r);
|
||||
exit;
|
||||
|
||||
Visitor::truncate();
|
||||
}
|
||||
|
||||
public static function visitorCount(): void
|
||||
{
|
||||
$oVisitor = Visitor::select('from', DB::raw('count(*) as count'))
|
||||
|
||||
Reference in new issue
Block a user