no message
This commit is contained in:
1 parent
912098c0b6
commit
e59aa4e049
11 files changed
+180
-27
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
Reference in new issue
Block a user