no message
This commit is contained in:
parent
c33f1a83b7
commit
59b02ed935
@ -35,7 +35,7 @@ $oHttp->aData = [
|
||||
'type' => 'private'
|
||||
],
|
||||
'date' => 1610000000,
|
||||
"text" => "\/nodeLike#name#type1 m1",
|
||||
"text" => "\/reportCoupon#3",
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
@ -315,6 +315,48 @@ final class HookController
|
||||
|
||||
}
|
||||
|
||||
// 优惠卷报表
|
||||
// /reportCoupon#7
|
||||
if (strpos($sText, '/reportCoupon') === 0 || strpos($sText, '\/reportCoupon') === 0) {
|
||||
try {
|
||||
@list($sCmd, $iDay) = explode("#", $sText, 2);
|
||||
|
||||
// 确保 $iDay 是一个有效的数字
|
||||
if (!is_numeric($iDay) || $iDay < 0) {
|
||||
throw new Exception('无效的天数参数');
|
||||
}
|
||||
|
||||
$sStartTime = strtotime("-$iDay days");
|
||||
|
||||
$aOrderList = Order::where('update_time', '>=', $sStartTime)
|
||||
->select('coupon',
|
||||
\App\Services\DB::raw('count(*) as total'),
|
||||
\App\Services\DB::raw('SUM(price) as total_price'))
|
||||
->groupBy('coupon')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
$sMsg = '';
|
||||
foreach ($aOrderList as $row) {
|
||||
$sMsg .= "\n\n";
|
||||
$sMsg .= $row['coupon'] . ':' . $row['total_price'] . ':' . $row['total'];
|
||||
}
|
||||
|
||||
$this->sendMessage($sMsg);
|
||||
|
||||
Http::response(200, 'ok');
|
||||
} catch (Exception $e) {
|
||||
// 处理异常
|
||||
$errorMsg = '发生错误: ' . $e->getMessage();
|
||||
$this->sendMessage($errorMsg);
|
||||
|
||||
// 返回错误响应
|
||||
Http::response(200, '内部服务器错误');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 节点列表(简洁)
|
||||
// /nodeList
|
||||
if (strpos($sText, '/nodeList') === 0 || strpos($sText, '\/nodeList') === 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user