|
|
|
@ -49,6 +49,8 @@ class Payment extends BaseService |
|
|
|
|
// 下单的客户端 |
|
|
|
|
private string $client = ''; |
|
|
|
|
|
|
|
|
|
private int $type; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置当前支付方式 |
|
|
|
|
* @param string $method 支付方式 |
|
|
|
@ -60,6 +62,12 @@ class Payment extends BaseService |
|
|
|
|
return $this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setType($type): Payment |
|
|
|
|
{ |
|
|
|
|
$this->type = $type; |
|
|
|
|
return $this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置下单的客户端 |
|
|
|
|
* @param string $client 客户端 |
|
|
|
@ -83,6 +91,7 @@ class Payment extends BaseService |
|
|
|
|
*/ |
|
|
|
|
public function orderPay(int $identityId, array $extra = []): array |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// 创建订单信息 |
|
|
|
|
$this->orderInfo = $this->createOrder($identityId); |
|
|
|
|
// 订单支付事件 |
|
|
|
@ -109,7 +118,7 @@ class Payment extends BaseService |
|
|
|
|
{ |
|
|
|
|
// 余额支付 |
|
|
|
|
if ($this->method == PaymentMethodEnum::BALANCE) { |
|
|
|
|
$this->orderPaySuccess($this->orderInfo['order_no']); |
|
|
|
|
$this->setType($this->orderInfo['order_type'])->orderPaySuccess($this->orderInfo['order_no']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -126,7 +135,11 @@ class Payment extends BaseService |
|
|
|
|
{ |
|
|
|
|
$service = new IdentityPaySuccessService(); |
|
|
|
|
// 订单支付成功业务处理 |
|
|
|
|
$service->setOrderNo($orderNo)->setMethod($this->method)->setTradeId($tradeId)->setPaymentData($paymentData); |
|
|
|
|
$service->setOrderNo($orderNo) |
|
|
|
|
->setMethod($this->method) |
|
|
|
|
->setTradeId($tradeId) |
|
|
|
|
->setType($this->type) |
|
|
|
|
->setPaymentData($paymentData); |
|
|
|
|
if (!$service->handle()) { |
|
|
|
|
throwError($service->getError() ?: '订单支付失败'); |
|
|
|
|
} |
|
|
|
@ -146,7 +159,7 @@ class Payment extends BaseService |
|
|
|
|
if ($info->isEmpty()) { |
|
|
|
|
throwError('记录不存在'); |
|
|
|
|
} |
|
|
|
|
if (UserService::isDealerMember() && $info['type'] == IdentityEnum::DEALER) { |
|
|
|
|
if (UserService::isDealerMember() && $info['type'] != IdentityEnum::DEALER) { |
|
|
|
|
throwError('非法操作'); |
|
|
|
|
} |
|
|
|
|
if (!$model->createOrder($info->toArray())) { |
|
|
|
@ -225,6 +238,10 @@ class Payment extends BaseService |
|
|
|
|
*/ |
|
|
|
|
private function unifiedorder(array $extra = []): array |
|
|
|
|
{ |
|
|
|
|
// 判断支付方式是否合法 |
|
|
|
|
if (!in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY])) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
// 生成第三方交易订单号 (并非主订单号) |
|
|
|
|
$outTradeNo = OrderService::createOrderNo(); |
|
|
|
|
// 获取支付方式的配置信息 |
|
|
|
|