no message

This commit is contained in:
hellcat 2025-04-26 13:53:54 +08:00
parent 1886701603
commit 81cd2e8387
4 changed files with 130 additions and 20 deletions

View File

@ -34,7 +34,8 @@ final class Cmd
'用户报表date到date' => '#',
'用户查找' => 'user#find 1',
'订单从优惠码分组默认0=当天' => 'order#groupBySaleCode 3',
'访客统计' => 'visitor#all'
'访客统计' => 'visitor#all',
'优惠码' => 'list,find byid bycode,like,set date#totime,del,clone'
];
return json_encode($aCmdList, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

View File

@ -0,0 +1,125 @@
<?php
//declare(strict_types=1);
namespace App\Services\Tg\Hook\Mod;
use App\Models\UserCoupon;
final class Coupon extends Base
{
public function List()
{
$aCouponList = UserCoupon::orderBy("name")->get()->toArray();
foreach ($aCouponList as $row) {
$row = $this->ForMat($row);
$this->oTGHttp->sendToTG(json_encode($row, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
}
$this->oHttp::response(200, 'ok');
}
public function FindByCode($aParam)
{
$sCode = $aParam['aArg'][1];
$aCoupon = UserCoupon::where('code', $sCode)->first()->toArray();
$aCoupon = $this->ForMat($aCoupon);
return json_encode($aCoupon, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
public function FindById($aParam)
{
$sId = $aParam['aArg'][1];
$aCoupon = UserCoupon::where('id', $sId)->first()->toArray();
$aCoupon = $this->ForMat($aCoupon);
return json_encode($aCoupon, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
}
public function Like($aParam)
{
$sFiled = $aParam['aOption'][1];
$sLike = $aParam['aArg'][1];
$aCoupon = UserCoupon::where($sFiled, 'like', '%'.$sLike.'%')->get()->toArray();
tomd($aCoupon, 1);
}
public function Set($aParam)
{
$sId = $aParam['aOption'][1];
$sFiled = $aParam['aOption'][2];
$sValue = $aParam['aArg'][1];
@list($sValue, $sType) = explode("#", $sValue, 2);
if ($sType == "totime") {
$sValue = strtotime($sValue);
}
$oCoupon = UserCoupon::find($sId);
if ($oCoupon) {
$oCoupon->$sFiled = $sValue;
return $oCoupon->save();
} else {
return "没有这个";
}
}
public function Clone($aParam)
{
$iId = $aParam['aArg'][1];
$oCoupon = UserCoupon::find($iId);
$oCouponNew = $oCoupon->replicate();
$oCouponNew->code = $oCouponNew->code.'__copy'.time();
return $oCouponNew->save();
}
public function Del($aParam)
{
$iId = $aParam['aArg'][1];
$oCoupon = UserCoupon::find($iId);
if ($oCoupon) {
$r = $oCoupon->delete();
} else {
$r = "没有";
}
return $r;
}
private function ForMat($aCoupon)
{
$aCoupon['content'] = json_decode($aCoupon['content'], 1);
$aCoupon['limit'] = json_decode($aCoupon['limit'], 1);
$aCoupon['limit']['use_time'] = $aCoupon['limit']['use_time'] ? date("Y-m-d H:i:s", $aCoupon['limit']['use_time']) : false;
$aCoupon['limit']['total_use_time'] = $aCoupon['limit']['total_use_time'] ? date("Y-m-d H:i:s", $aCoupon['limit']['total_use_time']) : false;
$aCoupon['create_time'] = date("Y-m-d H:i:s", $aCoupon['create_time']);
$aCoupon['expire_time'] = date("Y-m-d H:i:s", $aCoupon['expire_time']);
return $aCoupon;
}
}

View File

@ -1,19 +0,0 @@
<?php
//declare(strict_types=1);
namespace App\Services\Tg\Hook\Mod;
use App\Models\Coupon;
//use App\Services\DB;
final class SaleCode
{
public function List()
{
}
}

View File

@ -38,6 +38,9 @@ final class User
$aUser['transfer_today'] = Tools::flowToGB($aUser['transfer_today']).'GB';
$aUser['transfer_total'] = Tools::flowToGB($aUser['transfer_total']).'GB';
$aUser['transfer_enable'] = Tools::flowToGB($aUser['transfer_enable']).'GB';
$aUser['u'] = Tools::flowToGB($aUser['u']).'GB';
$aUser['d'] = Tools::flowToGB($aUser['d']).'GB';
$aUser['ud'] = $aUser['u'] + $aUser['d'];
$aUser['last_use_time'] = date('Y-m-d H:i:s', $aUser['last_use_time']);
} else {
$aUser = ["not have id" => $iUserId];