diff --git a/src/Services/Cron.php b/src/Services/Cron.php
index 1fd2fba79..959c655e2 100755
--- a/src/Services/Cron.php
+++ b/src/Services/Cron.php
@@ -184,13 +184,20 @@ final class Cron
->count(),
];
- $str = "# 付费用户计数";
+ $str = "# 付费用户计数 \n";
+// $str .= "
";
foreach ($aCount as $k => $v) {
$str .= "\n".$k.":".$v;
+// $str .= "";
+// $str .= "| ".$k." | ";
+// $str .= "".$v." | ";
+// $str .= "
";
}
+// $str .= "
";
+// $str .= "\n\n----END--------";
$oTelegramV2 = new TelegramV2("base");
- $oTelegramV2->setMsgType("html");
+// $oTelegramV2->setMsgType("html");
$oTelegramV2->send($str, "str");
}
@@ -955,6 +962,14 @@ final class Cron
$oOrder->update_time = time();
$oOrder->save();
+ $product = Product::where("code", $oOrder->product_code)->first();
+
+ if ($product) {
+ $product->sale_count -= 1;
+ $product->status = 1;
+ $product->save();
+ }
+
if ($invoice->money_use > 0) {
$iUserMoneyOld = $oUser->money;
$oUser->money += $invoice->money_use;
diff --git a/src/Services/Payment.php b/src/Services/Payment.php
index 195b4d7cc..082d7dff8 100755
--- a/src/Services/Payment.php
+++ b/src/Services/Payment.php
@@ -229,10 +229,7 @@ final class Payment
// tomd("redir:".$redir);
// exit;
-
-
////// 先创建订单
-
$product = (new Product())->find($product_id);
if ($product === null || $product->stock === 0) {
@@ -242,6 +239,13 @@ final class Payment
]);
}
+ if ($product->sale_count >= $product->stock) {
+ return $response->withJson([
+ 'ret' => 0,
+ 'msg' => '商品不存在或库存不足',
+ ]);
+ }
+
if ($product->end_time != 0 && $product->end_time < time()) {
return $response->withJson([
'ret' => 0,
@@ -438,12 +442,11 @@ final class Payment
);
}
-
-// if ($product->stock > 0) {
+// if ($product->stock >= 1) { // 大于等于1说明有商品且限购
// $product->stock -= 1;
// }
-// $product->sale_count += 1;
-// $product->save();
+ $product->sale_count += 1;
+ $product->save();
if ($coupon_raw !== '') {
$coupon->use_count += 1;
diff --git a/src/Services/Tg/Hook/Mod/Test.php b/src/Services/Tg/Hook/Mod/Test.php
index 70ec6d42f..1b6fa5092 100644
--- a/src/Services/Tg/Hook/Mod/Test.php
+++ b/src/Services/Tg/Hook/Mod/Test.php
@@ -171,6 +171,7 @@ final class Test extends Base
public function orderCombo()
{
$job = new Cron();
+ $job->productAuto();
$job->orderToPlan(); // 账单激活 | 用户当前class非2就进过期队列
$job->plan_expireToQueue(); // 标记过期队列
$job->planQueue_pendingToActivation(); // 队列排除 1 激活pending