all(); if (!empty($param['size'])) { $param['pageSize'] = $param['size']; } $param['openid'] = $request->user['openid']; $data = $this->service->setModel()->getList($param); return successTrans("success.data",pageFormat($data)); } catch (\Throwable $th) { return error($th->getMessage()); } } #[GetMapping("confirm")] public function confirmOrder(Request $request): Response { try { $param = $this->_valid([ "order.require" => trans("empty.require") ],$request->method()); if (!is_array($param)) return error($param); $order = $this->model->where("order_sn",$param['order'])->with(['product','poi'])->findOrEmpty(); if ($order->isEmpty()) return errorTrans("empty.data"); if ($order['status'] <> 0) return errorTrans("empty.data"); return $this->encode("ok",$order->toArray()); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 发起支付 * @param Request $request * @return Response */ #[PostMapping("toPay")] public function orderPay(Request $request): Response { try { $param = $this->_valid([ "order.require" => trans("empty.require"), "mobile.default" => "" ],$request->method()); if (!is_array($param)) return error($param); $order = $this->model->where("order_sn",$param['order'])->with(['product','poi'])->findOrEmpty(); $payParam = [ "order_sn" => $order['order_sn'], "total" => $order['price'], "name" => $order['product']['product_name'], "notify_url" => "" ]; $byteAuthorization = (new Pay)->config([ "appid" => sConf("wechat.mini_appid"), "secret" => sConf("wechat.mini_secret"), "salt" => sConf("wechat.mch_salt"), ])->createOrder($payParam); if (!empty($param['mobile'])) { $order->mobile = $param['mobile']; $order->save(); } return success("ok",['pay' => $byteAuthorization]); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }