From 81cd2e8387ee4221a5a9f4781e673754aeb59ec8 Mon Sep 17 00:00:00 2001 From: hellcat <> Date: Sat, 26 Apr 2025 13:53:54 +0800 Subject: [PATCH] no message --- src/Services/Tg/Hook/Mod/Cmd.php | 3 +- src/Services/Tg/Hook/Mod/Coupon.php | 125 ++++++++++++++++++++++++++ src/Services/Tg/Hook/Mod/SaleCode.php | 19 ---- src/Services/Tg/Hook/Mod/User.php | 3 + 4 files changed, 130 insertions(+), 20 deletions(-) create mode 100644 src/Services/Tg/Hook/Mod/Coupon.php delete mode 100644 src/Services/Tg/Hook/Mod/SaleCode.php diff --git a/src/Services/Tg/Hook/Mod/Cmd.php b/src/Services/Tg/Hook/Mod/Cmd.php index 27f5c792..f1ad29e5 100644 --- a/src/Services/Tg/Hook/Mod/Cmd.php +++ b/src/Services/Tg/Hook/Mod/Cmd.php @@ -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); diff --git a/src/Services/Tg/Hook/Mod/Coupon.php b/src/Services/Tg/Hook/Mod/Coupon.php new file mode 100644 index 00000000..f4175f9c --- /dev/null +++ b/src/Services/Tg/Hook/Mod/Coupon.php @@ -0,0 +1,125 @@ +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; + + } + +} diff --git a/src/Services/Tg/Hook/Mod/SaleCode.php b/src/Services/Tg/Hook/Mod/SaleCode.php deleted file mode 100644 index b13c1455..00000000 --- a/src/Services/Tg/Hook/Mod/SaleCode.php +++ /dev/null @@ -1,19 +0,0 @@ - $iUserId];