|
@@ -3,14 +3,17 @@
|
|
|
namespace app\controller\api;
|
|
namespace app\controller\api;
|
|
|
|
|
|
|
|
use app\extra\basic\Base;
|
|
use app\extra\basic\Base;
|
|
|
|
|
+use app\extra\dyMini\Pay;
|
|
|
use app\middleware\AuthMiddleware;
|
|
use app\middleware\AuthMiddleware;
|
|
|
use app\model\saas\SaasOrder;
|
|
use app\model\saas\SaasOrder;
|
|
|
|
|
+use app\service\saas\OrderService;
|
|
|
use DI\Attribute\Inject;
|
|
use DI\Attribute\Inject;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
use LinFly\Annotation\Attributes\Route\GetMapping;
|
|
|
use LinFly\Annotation\Attributes\Route\Middleware;
|
|
use LinFly\Annotation\Attributes\Route\Middleware;
|
|
|
use LinFly\Annotation\Attributes\Route\PostMapping;
|
|
use LinFly\Annotation\Attributes\Route\PostMapping;
|
|
|
use support\Request;
|
|
use support\Request;
|
|
|
|
|
+use support\Response;
|
|
|
|
|
|
|
|
|
|
|
|
|
#[Controller("/dy/order"),Middleware(AuthMiddleware::class)]
|
|
#[Controller("/dy/order"),Middleware(AuthMiddleware::class)]
|
|
@@ -20,9 +23,27 @@ class Order extends Base
|
|
|
#[Inject]
|
|
#[Inject]
|
|
|
protected SaasOrder $model;
|
|
protected SaasOrder $model;
|
|
|
|
|
|
|
|
|
|
+ #[Inject]
|
|
|
|
|
+ protected OrderService $service;
|
|
|
|
|
+
|
|
|
|
|
+ #[GetMapping('list')]
|
|
|
|
|
+ public function getDataList(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $request->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")]
|
|
#[GetMapping("confirm")]
|
|
|
- public function confirmOrder(Request $request)
|
|
|
|
|
|
|
+ public function confirmOrder(Request $request): Response
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
$param = $this->_valid([
|
|
$param = $this->_valid([
|
|
@@ -39,16 +60,37 @@ class Order extends Base
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- #[PostMapping("data")]
|
|
|
|
|
- public function confirmOrderSubmit(Request $request)
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发起支付
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return Response
|
|
|
|
|
+ */
|
|
|
|
|
+ #[PostMapping("toPay")]
|
|
|
|
|
+ public function orderPay(Request $request): Response
|
|
|
{
|
|
{
|
|
|
try {
|
|
try {
|
|
|
$param = $this->_valid([
|
|
$param = $this->_valid([
|
|
|
- "order.require" => trans("empty.require")
|
|
|
|
|
|
|
+ "order.require" => trans("empty.require"),
|
|
|
|
|
+ "mobile.default" => ""
|
|
|
],$request->method());
|
|
],$request->method());
|
|
|
if (!is_array($param)) return error($param);
|
|
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) {
|
|
} catch (\Throwable $throwable) {
|
|
|
return error($throwable->getMessage());
|
|
return error($throwable->getMessage());
|
|
|
}
|
|
}
|