123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\api\controller;
- use app\api\model\order\Context;
- use app\api\service\User as UserService;
- use app\common\enum\OrderType AS OrderTypeEnum;
- class Pay extends Controller
- {
-
- //准备支付
- public function prePay(){
- $user = UserService::getCurrentLoginUser(true);
- $args = $this->baseValidate([
- // "order_type"=>"require" //业务类型
- ],[
- // "order_type.require"=>"业务类型不能为空"
- ]);
- $order_type = $args['order_type']??OrderTypeEnum::RCORDER;
- $user_id = $user->user_id;
-
- $args = array_merge(["user_id"=>$user_id,"user_mobile"=>$user->mobile],$args);
- //dd($args);
- $c = new Context($order_type,$args);
- $res = $c->prePay();
- if(!$res){
- return $this->renderError($c->getInstance()->getError());
- }
- return $this->renderSuccess($res);
- }
- //重新支付
- public function rePay(){
- $user = UserService::getCurrentLoginUser(true);
- $args = $this->baseValidate([
- // "order_type"=>"require" //业务类型
- ],[
- // "order_type.require"=>"业务类型不能为空"
- ]);
- $order_type = $args['order_type']??OrderTypeEnum::RCORDER;
- $user_id = $user->user_id;
-
- $args = array_merge(["user_id"=>$user_id,"user_mobile"=>$user->mobile],$args);
- $c = new Context($order_type,$args);
- $res = $c->rePay();
- if(!$res){
- return $this->renderError($c->getInstance()->getError());
- }
- return $this->renderSuccess($res);
- }
-
- }
-
|