From 9c2da8289922d4c87a44d10a164e10e848f277de Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 26 Aug 2020 21:40:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E6=A0=A1=E9=AA=8C=20?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E8=AE=A2=E5=8D=95=E4=B8=8D=E8=83=BD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=A4=9A=E4=B8=AA=E7=89=B9=E4=BB=B7=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/PaymentController.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/Controller/PaymentController.php b/app/Controller/PaymentController.php index 9fc92ae..ec7d6d6 100644 --- a/app/Controller/PaymentController.php +++ b/app/Controller/PaymentController.php @@ -3,14 +3,23 @@ namespace App\Controller; use App\Constants\ErrorCode; +use App\Model\Order; +use App\Model\OrderGoods; use App\Model\OrderMain; use App\Request\WxminiPayRequest; +use App\Service\PurchaseLimitServiceInterface; use EasyWeChat\Factory; +use Hyperf\DbConnection\Db; use Hyperf\Guzzle\CoroutineHandler; class PaymentController extends BaseController { + /** + * @Inject + * @var PurchaseLimitServiceInterface + */ + protected $purchaseLimitService; public function wxminiPayOnline(WxminiPayRequest $request){ @@ -30,6 +39,22 @@ class PaymentController extends BaseController return $this->result(ErrorCode::PAY_FAILURE, $data,'订单不存在或已失效'); } + //查询订单商品信息 + $order = Order::query() + ->where('order_main_id',$data['order_id']) + ->select('id') + ->get() + ->toArray(); + $orderGoods = OrderGoods::query() + ->whereIn('order_id',$order) + ->get(); + //判断是否有购买多个特价商品 + $result = $this->purchaseLimitService->PurchaseLimit($orderGoods); + if(!$result){ + Db::rollBack(); + return '同一个订单不能购买多个特价商品'; + } + $result = $app->order->unify([ 'body' => '懒族生活 - 外卖下单', 'out_trade_no' => $orderMain->global_order_id,