You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Controller\v3;
|
|
|
|
use App\Controller\BaseController;
|
|
use App\Model\v3\OrderMain;
|
|
use App\Service\v3\Interfaces\PaymentServiceInterface;
|
|
use Hyperf\Di\Annotation\Inject;
|
|
use Hyperf\Validation\ValidationException;
|
|
|
|
class PaymentController extends BaseController
|
|
{
|
|
|
|
/**
|
|
* @Inject
|
|
* @var PaymentServiceInterface
|
|
*/
|
|
protected $paymentService;
|
|
|
|
/**
|
|
* 微信线上订单支付
|
|
* 主要用户待付款订单中的付款操作
|
|
*/
|
|
public function wechatpayOnline()
|
|
{
|
|
$validator = $this->validationFactory->make(
|
|
$this->request->all(),
|
|
[
|
|
'global_order_id' => 'required|nonempty',
|
|
'user_id' => 'required|nonempty',
|
|
],
|
|
[
|
|
'global_order_id.*' => '订单号错误'
|
|
]
|
|
);
|
|
|
|
if ($validator->fails()) {
|
|
throw new ValidationException($validator);
|
|
}
|
|
|
|
$params = $validator->validated();
|
|
$orderMain = OrderMain::query()->select('global_order_id', 'money', 'user_id')
|
|
->where(['global_order_id' => $params['global_order_id']])->first();
|
|
$parameters = $this->paymentService->do($orderMain->global_order_id, $orderMain->money, $orderMain->user_id);
|
|
|
|
return $this->success(['parameters' => $parameters]);
|
|
}
|
|
}
|