diff --git a/public/.DS_Store b/public/.DS_Store index 0cb7846e..9c8c5350 100755 Binary files a/public/.DS_Store and b/public/.DS_Store differ diff --git a/resources/.DS_Store b/resources/.DS_Store index 803fbbf4..4178d24d 100755 Binary files a/resources/.DS_Store and b/resources/.DS_Store differ diff --git a/resources/views/.DS_Store b/resources/views/.DS_Store index d4da398a..f674d57a 100755 Binary files a/resources/views/.DS_Store and b/resources/views/.DS_Store differ diff --git a/resources/views/tabler/.DS_Store b/resources/views/tabler/.DS_Store index 2cb7ff6d..3710dd90 100755 Binary files a/resources/views/tabler/.DS_Store and b/resources/views/tabler/.DS_Store differ diff --git a/resources/views/tabler/user/header.tpl b/resources/views/tabler/user/header.tpl index 9741d30c..788ebde0 100755 --- a/resources/views/tabler/user/header.tpl +++ b/resources/views/tabler/user/header.tpl @@ -135,12 +135,10 @@ 账单 - 资料 diff --git a/src/Controllers/Admin/ProductController.php b/src/Controllers/Admin/ProductController.php index 7f2edc02..55e9e959 100755 --- a/src/Controllers/Admin/ProductController.php +++ b/src/Controllers/Admin/ProductController.php @@ -21,7 +21,7 @@ final class ProductController extends BaseController 'field' => [ 'op' => '操作', 'id' => '商品ID', - 'type_by_time' => '套餐时长', + 'class_time' => '套餐时长', 'name' => '名称', 'price' => '售价', 'status' => '销售状态', @@ -194,7 +194,7 @@ final class ProductController extends BaseController ]; $product->type = $type; - $product->type_by_time = $class_time; + $product->class_time = $class_time; $product->name = $name; $product->price = $price; $product->content = json_encode($content); @@ -304,7 +304,7 @@ final class ProductController extends BaseController ]; $product->type = $type; - $product->type_by_time = $class_time; + $product->class_time = $class_time; $product->name = $name; $product->price = $price; $product->content = json_encode($content); @@ -355,7 +355,7 @@ final class ProductController extends BaseController public function ajax(ServerRequest $request, Response $response, array $args): ResponseInterface { - $products = (new Product())->orderBy('type_by_time', 'desc')->orderBy('price', 'asc')->get(); + $products = (new Product())->orderBy('class_time', 'desc')->orderBy('price', 'asc')->get(); foreach ($products as $product) { $product->op = 'where('status', '1') - ->where('type_by_time', '30') + ->where('class_time', '30') ->orderBy('price') ->get(); diff --git a/src/Controllers/TestController.php b/src/Controllers/TestController.php index ba003097..3ef875d0 100755 --- a/src/Controllers/TestController.php +++ b/src/Controllers/TestController.php @@ -180,7 +180,7 @@ final class TestController extends BaseController $user = AuthService::getUser(); $taocan = (new Product())->where('status', '1') - ->where('type_by_time', '30') + ->where('class_time', '30') ->orderBy('price') ->get(); diff --git a/src/Controllers/User/CouponController.php b/src/Controllers/User/CouponController.php index 290f4f42..018a1fc1 100755 --- a/src/Controllers/User/CouponController.php +++ b/src/Controllers/User/CouponController.php @@ -88,6 +88,120 @@ 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; +// } else { +// $discount = $content->value; +// } +// +// $buy_price = $product->price - $discount; + +// return $response->withJson([ +// 'ret' => $iRet, +// 'msg' => $sMsg, +// 'discount' => $discount, +// 'buy_price' => $buy_price, +// ]); + + return $response->withJson([ + 'code' => 111, + 'shop' => 222, + 'credit' => 333, + 'total' => 444, + 'total' => 555, + ]); + } + + public function check_old(ServerRequest $request, Response $response, array $args): ResponseInterface + { + $coupon_raw = $this->antiXss->xss_clean($request->getParam('coupon')); + $product_id = $this->antiXss->xss_clean($request->getParam('product_id')); + $invalid_coupon_msg = '优惠码无效'; + + if ($coupon_raw === '') { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + + $coupon = (new UserCoupon())->where('code', $coupon_raw)->first(); + + if ($coupon === null || ($coupon->expire_time !== 0 && $coupon->expire_time < time())) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + + $product = (new Product())->where('id', $product_id)->first(); + + if ($product === null) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + + $limit = json_decode($coupon->limit); + + if ($limit->disabled) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + + if ($limit->product_id !== '' && ! in_array($product_id, explode(',', $limit->product_id))) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + + $user = $this->user; + $use_limit = $limit->use_time; + + if ($use_limit > 0) { + $user_use_count = (new Order())->where('user_id', $user->id)->where('coupon', $coupon->code)->count(); + if ($user_use_count >= $use_limit) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + } + + $total_use_limit = $limit->total_use_time; + + if ($total_use_limit > 0 && $coupon->use_count >= $total_use_limit) { + return $response->withJson([ + 'ret' => 0, + 'msg' => $invalid_coupon_msg, + ]); + } + $content = json_decode($coupon->content); $iRet = 1; diff --git a/src/Controllers/User/OrderController.php b/src/Controllers/User/OrderController.php index 091cae69..ed64e13d 100755 --- a/src/Controllers/User/OrderController.php +++ b/src/Controllers/User/OrderController.php @@ -148,7 +148,7 @@ final class OrderController extends BaseController // if ($oHuodong) { // if ($oHuodong->class == "A") { // // 月套餐以上禁用优惠码 -// if ($product->type_by_time > 32) { +// if ($product->class_time > 32) { // return $response->withJson([ // 'ret' => 0, // 'msg' => '该商品在【'.$oHuodong->title.'】期间不能使用优惠码', diff --git a/src/Controllers/User/ProductController.php b/src/Controllers/User/ProductController.php index 74acd4b1..cb2191cf 100755 --- a/src/Controllers/User/ProductController.php +++ b/src/Controllers/User/ProductController.php @@ -20,17 +20,17 @@ final class ProductController extends BaseController public function index(ServerRequest $request, Response $response, array $args): ResponseInterface { $tabps = (new Product())->where('status', '1') - ->where('type_by_time', '30') + ->where('class_time', '30') ->orderBy('price') ->get(); $bandwidths = (new Product())->where('status', '1') - ->where('type_by_time', '90') + ->where('class_time', '90') ->orderBy('price') ->get(); $times = (new Product())->where('status', '1') - ->where('type_by_time', '365') + ->where('class_time', '365') ->orderBy('price') ->get(); // echo '';var_dump($tabps); diff --git a/src/Services/Cron.php b/src/Services/Cron.php index 9c2b30c9..41f32b29 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -703,8 +703,8 @@ final class Cron if ($content->class_time > 32) { $oProduct = Product::where("name", $order->product_name) - ->where("type_by_time", "<", $content->class_time) - ->orderBy("type_by_time", "desc") + ->where("class_time", "<", $content->class_time) + ->orderBy("class_time", "desc") ->first(); if ($oProduct) { diff --git a/src/Services/Gateway/Epay.php b/src/Services/Gateway/Epay.php index 7c8eb7b2..fce7c83d 100755 --- a/src/Services/Gateway/Epay.php +++ b/src/Services/Gateway/Epay.php @@ -68,6 +68,10 @@ final class Epay extends Base $type = $this->antiXss->xss_clean($request->getParam('type')); $redir = $this->antiXss->xss_clean($request->getParam('redir')); + //// 修改,先创建账单 + ////////end////// + + if ($price <= 0) { return $response->withJson([ 'ret' => 0, @@ -111,6 +115,14 @@ final class Epay extends Base $data['sign_type'] = $this->epay['sign_type']; $client = new Client(); + //// 本地直接成功 + if ($_ENV['is_loc'] == true) { + $this->postPayment($pl->tradeno); + + return $response->withJson(['state' => 'success', 'msg' => 'Payment success']); + } + //// end + try { $res = $client->request('POST', $this->epay['apiurl'] . 'mapi.php', ['form_params' => $data]); diff --git a/src/Services/Tg/Hook/Mod/Test.php b/src/Services/Tg/Hook/Mod/Test.php index 30c812f1..2c87914c 100644 --- a/src/Services/Tg/Hook/Mod/Test.php +++ b/src/Services/Tg/Hook/Mod/Test.php @@ -9,10 +9,20 @@ use App\Models\User as ModelUser; use App\Utils\Tools; //use App\Services\DB; use App\Services\Cron; +use App\Command\Cron as CommandCron; final class Test extends Base { // id:1778 测试员test1,可着它嚯嚯 + + + + public function cron($aParam) + { + $sFunc = $aParam["aArg"][1]; + $job = new Cron(); + return $job->$sFunc(); + } public function smtpClearDayCount() { diff --git a/storage/GeoLite2-City/GeoLite2-City.mmdb b/storage/GeoLite2-City/GeoLite2-City.mmdb new file mode 100644 index 00000000..eee9de52 Binary files /dev/null and b/storage/GeoLite2-City/GeoLite2-City.mmdb differ diff --git a/storage/GeoLite2-Country/GeoLite2-Country.mmdb b/storage/GeoLite2-Country/GeoLite2-Country.mmdb new file mode 100644 index 00000000..819c3440 Binary files /dev/null and b/storage/GeoLite2-Country/GeoLite2-Country.mmdb differ diff --git a/手动部分.md b/手动部分.md index afb7668e..9e18191c 100755 --- a/手动部分.md +++ b/手动部分.md @@ -6,7 +6,7 @@ ALTER TABLE user_invite_code ADD COLUMN `is_admin` tinyint(1) DEFAULT 0; ALTER TABLE product -ADD COLUMN `type_by_time` int(11) DEFAULT 0; +ADD COLUMN `class_time` int(11) DEFAULT 0; ALTER TABLE node ADD COLUMN `online_user_date_last` datetime DEFAULT NULL; @@ -52,7 +52,7 @@ node加字段 =================================================== -ALTER TABLE product ADD type_by_time INT DEFAULT 0; +ALTER TABLE product ADD class_time INT DEFAULT 0; ALTER TABLE user_coupon ADD name VARCHAR(255) NOT NULL AFTER id; .config添加$_ENV['geoUrl']
';var_dump($tabps); diff --git a/src/Services/Cron.php b/src/Services/Cron.php index 9c2b30c9..41f32b29 100755 --- a/src/Services/Cron.php +++ b/src/Services/Cron.php @@ -703,8 +703,8 @@ final class Cron if ($content->class_time > 32) { $oProduct = Product::where("name", $order->product_name) - ->where("type_by_time", "<", $content->class_time) - ->orderBy("type_by_time", "desc") + ->where("class_time", "<", $content->class_time) + ->orderBy("class_time", "desc") ->first(); if ($oProduct) { diff --git a/src/Services/Gateway/Epay.php b/src/Services/Gateway/Epay.php index 7c8eb7b2..fce7c83d 100755 --- a/src/Services/Gateway/Epay.php +++ b/src/Services/Gateway/Epay.php @@ -68,6 +68,10 @@ final class Epay extends Base $type = $this->antiXss->xss_clean($request->getParam('type')); $redir = $this->antiXss->xss_clean($request->getParam('redir')); + //// 修改,先创建账单 + ////////end////// + + if ($price <= 0) { return $response->withJson([ 'ret' => 0, @@ -111,6 +115,14 @@ final class Epay extends Base $data['sign_type'] = $this->epay['sign_type']; $client = new Client(); + //// 本地直接成功 + if ($_ENV['is_loc'] == true) { + $this->postPayment($pl->tradeno); + + return $response->withJson(['state' => 'success', 'msg' => 'Payment success']); + } + //// end + try { $res = $client->request('POST', $this->epay['apiurl'] . 'mapi.php', ['form_params' => $data]); diff --git a/src/Services/Tg/Hook/Mod/Test.php b/src/Services/Tg/Hook/Mod/Test.php index 30c812f1..2c87914c 100644 --- a/src/Services/Tg/Hook/Mod/Test.php +++ b/src/Services/Tg/Hook/Mod/Test.php @@ -9,10 +9,20 @@ use App\Models\User as ModelUser; use App\Utils\Tools; //use App\Services\DB; use App\Services\Cron; +use App\Command\Cron as CommandCron; final class Test extends Base { // id:1778 测试员test1,可着它嚯嚯 + + + + public function cron($aParam) + { + $sFunc = $aParam["aArg"][1]; + $job = new Cron(); + return $job->$sFunc(); + } public function smtpClearDayCount() { diff --git a/storage/GeoLite2-City/GeoLite2-City.mmdb b/storage/GeoLite2-City/GeoLite2-City.mmdb new file mode 100644 index 00000000..eee9de52 Binary files /dev/null and b/storage/GeoLite2-City/GeoLite2-City.mmdb differ diff --git a/storage/GeoLite2-Country/GeoLite2-Country.mmdb b/storage/GeoLite2-Country/GeoLite2-Country.mmdb new file mode 100644 index 00000000..819c3440 Binary files /dev/null and b/storage/GeoLite2-Country/GeoLite2-Country.mmdb differ diff --git a/手动部分.md b/手动部分.md index afb7668e..9e18191c 100755 --- a/手动部分.md +++ b/手动部分.md @@ -6,7 +6,7 @@ ALTER TABLE user_invite_code ADD COLUMN `is_admin` tinyint(1) DEFAULT 0; ALTER TABLE product -ADD COLUMN `type_by_time` int(11) DEFAULT 0; +ADD COLUMN `class_time` int(11) DEFAULT 0; ALTER TABLE node ADD COLUMN `online_user_date_last` datetime DEFAULT NULL; @@ -52,7 +52,7 @@ node加字段 =================================================== -ALTER TABLE product ADD type_by_time INT DEFAULT 0; +ALTER TABLE product ADD class_time INT DEFAULT 0; ALTER TABLE user_coupon ADD name VARCHAR(255) NOT NULL AFTER id; .config添加$_ENV['geoUrl']