From 710b7e31a25d7aaaa54af13a1c5687eaac5d94c3 Mon Sep 17 00:00:00 2001 From: manghe Date: Thu, 3 Apr 2025 16:34:49 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Goods.php | 31 +++++++++++++++++++++++++++++++ app/api/controller/Notify.php | 10 +++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 616c9dd..aba9191 100755 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -807,6 +807,21 @@ class Goods extends Base } } } + + if ($goods['quanju_xiangou'] > 0) { + // <= $user_xiangou_count + // return $this->renderError('当前活动限购' . $goods['quanju_xiangou'] . '次'); + //限购 + $user_xiangou_count = OrderList::field('id')->where('goods_id', '=', $goods_id) + ->where('user_id', '=', $user['id']) + ->where('num', '=', $num) + ->count(); + if ($user_xiangou_count >= $goods['quanju_xiangou']) { + return $this->renderError('当前活动限购' . $goods['quanju_xiangou'] . '次'); + } + + } + if ($goods['type'] != 15) { #奖品信息 $is_goodslist = GoodsList::field('id') @@ -1168,6 +1183,22 @@ class Goods extends Base } else { $attach = 'order_qts'; } + + if ($goods['quanju_xiangou'] > 0) { + + // 查看一天内有没有未支付的订单,未支付的订单要先作废 + $order_info = Order::where('goods_id', '=', $goods_id) + ->where('user_id', '=', $user['id']) + ->where('num', '=', $num) + ->where('status', '=', 0) + ->where('addtime', '>=', time() - 86400) + ->find(); + if ($order_info) { + $order_info->status = 2; + $order_info->save(); + } + } + $payRes = (new Pay())->wxCreateOrder($order_num, $price, $user['openid'], $body, $attach); if ($payRes['status'] == 1) { #结果集 diff --git a/app/api/controller/Notify.php b/app/api/controller/Notify.php index f1a2600..35a354e 100755 --- a/app/api/controller/Notify.php +++ b/app/api/controller/Notify.php @@ -240,7 +240,7 @@ class Notify extends Base Db::rollback(); } } - } elseif ($table == 'order_yfs' || $table == 'order_lts' || $table == 'order_zzs' || $table == 'order_flw'|| $table == 'order_scs') {#抽赏一番赏 擂台赏 + } elseif ($table == 'order_yfs' || $table == 'order_lts' || $table == 'order_zzs' || $table == 'order_flw' || $table == 'order_scs') {#抽赏一番赏 擂台赏 $orderInfo = Order::where('order_num', '=', $out_trade_no) ->where('status', '=', 0) ->find(); @@ -286,6 +286,14 @@ class Notify extends Base } else { Db::rollback(); } + } else { + $tempOrder = Order::where('order_num', '=', $out_trade_no) + ->find(); + if ($tempOrder) { + // 作废订单支付 + $tempOrder->status = 3; + $tempOrder->save(); + } } } elseif ($table == 'order_wxs') {#抽赏无限赏 $orderInfo = Order::where('order_num', '=', $out_trade_no)