feat : pay

This commit is contained in:
2025-02-17 16:46:41 +08:00
parent 1fb7bf4ea7
commit 8e6c6f9cb1
13 changed files with 353 additions and 13 deletions

View File

@@ -12,5 +12,5 @@ namespace App\Service\Common\Pay;
interface ThirdPayInterface
{
public function pay(float $money,int $orderId,int $orderType,string $outTradeNo,int $userId);
public function pay(float $money,int $orderId,string $outTradeNo,int $userId);
}

View File

@@ -18,6 +18,11 @@ use function Hyperf\Config\config;
abstract class WxJsRechargeBaseService implements ThirdPayInterface
{
/**
* @var string
*/
public string $openId;
/**
* 回调地址
* @var string
@@ -110,7 +115,7 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
/**
* @return void
*/
private function setConfig(): void
public function setConfig(): void
{
$this->config = config('ysdPay');
}
@@ -118,17 +123,16 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
/**
* @param float $money
* @param int $orderId
* @param int $orderType
* @param string $outTradeNo
* @param int $userId
* @return Collection|Rocket
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function pay(float $money, int $orderId, int $orderType, string $outTradeNo, int $userId): Collection|Rocket
public function pay(float $money, int $orderId, string $outTradeNo, int $userId): Collection|Rocket
{
if (empty($this->config)) throw new ErrException('调起支付失败-微信支付配置项不存在');
$userOpenId = '123';
try {
$wxOrder = [
'out_trade_no' => $outTradeNo,
@@ -138,7 +142,7 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
'currency' => 'CNY'
],
'payer' => [
'openid' => $userOpenId,
'openid' => $this->openId,
]
];

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Service\Common\Pay\Wx;
use function Hyperf\Config\config;
class WxJsRechargeOrderService extends WxJsRechargeBaseService
{
public function callBackHandle()
{
// TODO: Implement callBackHandle() method.
}
public function setNotify()
{
//返回的回调地址
$this->config['wechat']['default']['notify_url'] = config('system.api_url').'/common/wxPay/order/js/callBack';
}
}