no message
This commit is contained in:
parent
912098c0b6
commit
e59aa4e049
@ -16,7 +16,8 @@ return static function (Slim\App $app): void {
|
||||
// test
|
||||
$app->get('/my', App\Controllers\MyController::class . ':index');
|
||||
|
||||
|
||||
// tom通用api
|
||||
$app->get('/api/huodong/findbydate/{date}', App\Controllers\TomApi\HuodongController::class . ':findByDate');
|
||||
|
||||
// gembox 日后分离出去
|
||||
$app->group('/gembox', static function (RouteCollectorProxy $group): void {
|
||||
|
||||
@ -73,6 +73,25 @@ $oHttp->aData['message']['text'] = '\/tk#ry__1 aasd';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/tk#list';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/user#report__day__300';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#list';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#Like__name v';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#set__3__name ss1v';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#set__3__expire_time 2025-01-03 22:22:22#totime';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#clone 3';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/coupon#del 11';
|
||||
|
||||
$oHttp->aData['message']['text'] = '\/user#limit 10';
|
||||
|
||||
//$oHttp->aData['message']['text'] = '\/coupon#findById 3';
|
||||
|
||||
|
||||
//{
|
||||
// "update_id": 761180998,
|
||||
// "message": {
|
||||
|
||||
@ -503,8 +503,7 @@
|
||||
</div>
|
||||
<p class="my-3">
|
||||
{if $user->class === 0}
|
||||
未购买套餐,
|
||||
<a href="/user/product">购买一个套餐</a>
|
||||
未购买套餐,请先<a href="/user/product">购买一个套餐</a>
|
||||
{else}
|
||||
您的【{$class}】订阅会在 {$class_expire_days} 天后到期({$user->class_expire})
|
||||
{/if}
|
||||
|
||||
@ -148,6 +148,13 @@
|
||||
$('#coupon-code').text($('#coupon').val());
|
||||
$('#product-buy-discount').text(data.discount);
|
||||
$('#product-buy-total').text(data.buy_price);
|
||||
} else if (data.ret === 2) {
|
||||
$('#coupon-code').text($('#coupon').val());
|
||||
$('#product-buy-discount').text(data.discount);
|
||||
$('#product-buy-total').text(data.buy_price);
|
||||
|
||||
$('#success-message').text(data.msg);
|
||||
$('#success-dialog').modal('show');
|
||||
} else {
|
||||
$('#fail-message').text(data.msg);
|
||||
$('#fail-dialog').modal('show');
|
||||
|
||||
@ -33,14 +33,14 @@ EOL;
|
||||
$jobs = new CronService();
|
||||
|
||||
// Run new shop related jobs
|
||||
$jobs->processPendingOrder();
|
||||
$jobs->processTabpOrderActivation();
|
||||
$jobs->processBandwidthOrderActivation();
|
||||
$jobs->processTimeOrderActivation();
|
||||
$jobs->processPendingOrder(); // 标记订单 - 待激活,超时
|
||||
$jobs->processTabpOrderActivation(); // 激活订单,过期订单(不重置用户流量)
|
||||
$jobs->processBandwidthOrderActivation(); // 流量包处理,没用
|
||||
$jobs->processTimeOrderActivation(); // 时间包处理,没用
|
||||
|
||||
// Run user related jobs
|
||||
$jobs->expirePaidUserAccount();
|
||||
$jobs->sendPaidUserUsageLimitNotification();
|
||||
$jobs->expirePaidUserAccount(); // 重置套餐用户流量
|
||||
$jobs->sendPaidUserUsageLimitNotification(); // 流量预警
|
||||
|
||||
// Run node related jobs
|
||||
$jobs->updateNodeIp();
|
||||
|
||||
@ -19,7 +19,7 @@ use App\Services\Reward;
|
||||
use App\Services\TomTool\Http;
|
||||
use App\Services\TomTool\VisitorCount;
|
||||
|
||||
|
||||
use App\Command\Cron;
|
||||
session_start();
|
||||
|
||||
final class TestController extends BaseController
|
||||
@ -82,10 +82,9 @@ final class TestController extends BaseController
|
||||
public function test2()
|
||||
{
|
||||
|
||||
$_SESSION['test'] = 333;
|
||||
var_dump($_SESSION);
|
||||
$oCron = new Cron();
|
||||
$oCron->boot();
|
||||
|
||||
http_response_code(200);exit;
|
||||
}
|
||||
|
||||
public function test3()
|
||||
|
||||
32
src/Controllers/TomApi/HuodongController.php
Normal file
32
src/Controllers/TomApi/HuodongController.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controllers\TomApi;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Slim\Http\Response;
|
||||
use Slim\Http\ServerRequest;
|
||||
|
||||
use App\Models\Huodong;
|
||||
//use App\Models\TgStep;
|
||||
|
||||
final class HuodongController
|
||||
{
|
||||
|
||||
public function findByDate(ServerRequest $request, Response $response, array $args)
|
||||
{
|
||||
|
||||
$sFindDate = $args['date'];
|
||||
|
||||
$oHuodong = Huodong::where("start_date", "<=", $sFindDate)->where("end_date", ">=", $sFindDate)->first();
|
||||
|
||||
if ($oHuodong) {
|
||||
echo json_encode($oHuodong);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Controllers\User;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Huodong;
|
||||
use App\Models\Order;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserCoupon;
|
||||
@ -88,6 +89,25 @@ final class CouponController extends BaseController
|
||||
}
|
||||
|
||||
$content = json_decode($coupon->content);
|
||||
|
||||
$iRet = 1;
|
||||
$sMsg = "优惠码可用";
|
||||
|
||||
$sDateNow = date("Y-m-d");
|
||||
// $sDateNow = "2025-05-02";
|
||||
$oHuodong = Huodong::where("start_date", "<=", $sDateNow)->where("end_date", ">=", $sDateNow)->first();
|
||||
|
||||
if ($oHuodong) {
|
||||
if ($oHuodong->class == "A") {
|
||||
if ($content->type === 'percentage') {
|
||||
|
||||
$content->value = $oHuodong->coupon_global;
|
||||
$iRet = 2;
|
||||
$sMsg = '该优惠码可用,在【'.$oHuodong->title.'】期间视为-'.$oHuodong->coupon_global.'%优惠。';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($content->type === 'percentage') {
|
||||
$discount = $product->price * $content->value / 100;
|
||||
@ -98,8 +118,8 @@ final class CouponController extends BaseController
|
||||
$buy_price = $product->price - $discount;
|
||||
|
||||
return $response->withJson([
|
||||
'ret' => 1,
|
||||
'msg' => '优惠码可用',
|
||||
'ret' => $iRet,
|
||||
'msg' => $sMsg,
|
||||
'discount' => $discount,
|
||||
'buy_price' => $buy_price,
|
||||
]);
|
||||
|
||||
@ -9,6 +9,7 @@ use App\Models\Invoice;
|
||||
use App\Models\Order;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserCoupon;
|
||||
use App\Models\Huodong;
|
||||
use App\Utils\Cookie;
|
||||
use App\Utils\Tools;
|
||||
use Exception;
|
||||
@ -138,6 +139,20 @@ final class OrderController extends BaseController
|
||||
|
||||
if ($coupon_raw !== '') {
|
||||
$coupon = (new UserCoupon())->where('code', $coupon_raw)->first();
|
||||
|
||||
//// start 特别活动禁用优惠码 || 不禁用了,变为调整
|
||||
// if ($oHuodong) {
|
||||
// if ($oHuodong->class == "A") {
|
||||
// // 月套餐以上禁用优惠码
|
||||
// if ($product->type_by_time > 32) {
|
||||
// return $response->withJson([
|
||||
// 'ret' => 0,
|
||||
// 'msg' => '该商品在【'.$oHuodong->title.'】期间不能使用优惠码',
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//// end
|
||||
|
||||
if ($coupon === null || ($coupon->expire_time !== 0 && $coupon->expire_time < time())) {
|
||||
return $response->withJson([
|
||||
@ -188,6 +203,21 @@ final class OrderController extends BaseController
|
||||
}
|
||||
|
||||
$content = json_decode($coupon->content);
|
||||
|
||||
//// start 特别活动期间限制优惠码额度
|
||||
$sDateNow = date("Y-m-d");
|
||||
// $sDateNow = "2025-05-02";
|
||||
|
||||
$oHuodong = Huodong::where("start_date", "<=", $sDateNow)->where("end_date", ">=", $sDateNow)->first();
|
||||
|
||||
if ($oHuodong !== null) {
|
||||
if ($oHuodong->class == "A") {
|
||||
if ($content->type === 'percentage') {
|
||||
$content->value = $oHuodong->coupon_global;
|
||||
}
|
||||
}
|
||||
}
|
||||
//// end
|
||||
|
||||
if ($content->type === 'percentage') {
|
||||
$discount = $product->price * $content->value / 100;
|
||||
@ -236,6 +266,9 @@ final class OrderController extends BaseController
|
||||
$order->status = 'pending_payment';
|
||||
$order->create_time = time();
|
||||
$order->update_time = time();
|
||||
if (isset($oHuodong) && $oHuodong !== null && $oHuodong->class) {
|
||||
$order->huodong_class = $oHuodong->class;
|
||||
}
|
||||
$order->save();
|
||||
|
||||
$invoice_content = [];
|
||||
|
||||
35
src/Models/Huodong.php
Executable file
35
src/Models/Huodong.php
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
/**
|
||||
* @property int $id 工单ID
|
||||
* @property string $title 工单标题
|
||||
* @property string $content 工单内容
|
||||
* @property int $userid 用户ID
|
||||
* @property int $datetime 创建时间
|
||||
* @property string $status 工单状态
|
||||
* @property string $type 工单类型
|
||||
*
|
||||
* @mixin Builder
|
||||
*/
|
||||
final class Huodong extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'huodong';
|
||||
|
||||
// public function type(): string
|
||||
// {
|
||||
// return match ($this->type) {
|
||||
// 'howto' => '使用',
|
||||
// 'billing' => '财务',
|
||||
// 'account' => '账户',
|
||||
// default => '其他',
|
||||
// };
|
||||
// }
|
||||
|
||||
}
|
||||
@ -579,18 +579,26 @@ final class Cron
|
||||
//// end
|
||||
|
||||
//// * 特别活动追加,季套餐赠月套餐,年套餐赠季套餐
|
||||
// if ($order->huodong_class && $order->huodong_class == "A") {
|
||||
//
|
||||
// $oProduct = Product::where("name", $order->product_name)
|
||||
// ->where("type_by_time", "<", $content->class_time)
|
||||
// ->orderBy("type_by_time", "desc")
|
||||
// ->first();
|
||||
// $oProductContent = json_decode($oProduct->content);
|
||||
//
|
||||
// $content->class_time += $oProductContent->class_time;
|
||||
// $content->bandwidth += $oProductContent->bandwidth;
|
||||
//
|
||||
// }
|
||||
if ($order->huodong_class && $order->huodong_class == "A") {
|
||||
|
||||
// 按理是大于30天,做个冗余
|
||||
if ($content->class_time > 32) {
|
||||
|
||||
$oProduct = Product::where("name", $order->product_name)
|
||||
->where("type_by_time", "<", $content->class_time)
|
||||
->orderBy("type_by_time", "desc")
|
||||
->first();
|
||||
|
||||
if ($oProduct) {
|
||||
$oProductContent = json_decode($oProduct->content);
|
||||
|
||||
$content->class_time += $oProductContent->class_time;
|
||||
$content->bandwidth += $oProductContent->bandwidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//// end
|
||||
|
||||
// 激活TABP
|
||||
|
||||
Loading…
Reference in New Issue
Block a user