feat : pay callback
This commit is contained in:
@@ -11,6 +11,7 @@ use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Yansongda\Artful\Exception\InvalidParamsException;
|
||||
use Yansongda\Artful\Rocket;
|
||||
use Yansongda\HyperfPay\Pay;
|
||||
use Yansongda\Supports\Collection;
|
||||
@@ -76,30 +77,30 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
// abstract public function setMchId();
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取返回数据
|
||||
// * @return void
|
||||
// * @throws ContainerExceptionInterface
|
||||
// * @throws NotFoundExceptionInterface
|
||||
// * @throws ContainerException
|
||||
// * @throws InvalidParamsException
|
||||
// */
|
||||
// public function getWechatData(): void
|
||||
// {
|
||||
// $params = $this->request->all();
|
||||
// $this->log->callbackLog(__CLASS__.'微信支付回调'.json_encode($params));
|
||||
//
|
||||
// $this->setConfig();
|
||||
// $result = $this->pay->wechat($this->config)->callback($params);
|
||||
// $this->callbackData = $result['resource']['ciphertext'];
|
||||
//
|
||||
// if (empty($this->callbackData)) {
|
||||
// $this->log->error(__CLASS__.'获取回调失败'.json_encode($params));
|
||||
// throw new ErrException('获取回调失败');
|
||||
// }
|
||||
//
|
||||
// $this->log->info(__CLASS__.'微信支付完成回调'.json_encode($this->callbackData));
|
||||
// }
|
||||
/**
|
||||
* 获取返回数据
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface|InvalidParamsException
|
||||
*/
|
||||
public function getWechatData(): void
|
||||
{
|
||||
$this->setConfig();
|
||||
|
||||
try {
|
||||
$this->callbackData = $this->ysdPay->wechat($this->config)->callback($this->request)->toArray()['resource']['ciphertext'];
|
||||
}catch (Exception $e) {
|
||||
$this->log->debug(__CLASS__.'微信支付回调解密失败'.json_encode($e->getMessage()));
|
||||
throw new ErrException('微信支付回调解密失败');
|
||||
}
|
||||
|
||||
if (!empty($this->callbackData)) {
|
||||
$this->log->debug(__CLASS__.'获取回调失败'.json_encode($this->request));
|
||||
throw new ErrException('获取回调失败');
|
||||
}
|
||||
|
||||
$this->log->info(__CLASS__.'微信支付完成回调'.json_encode($this->callbackData));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,14 +2,57 @@
|
||||
|
||||
namespace App\Service\Common\Pay\Wx;
|
||||
|
||||
use App\Service\ServiceTrait\Api\CheckOrderCallBackTrait;
|
||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use function Hyperf\Config\config;
|
||||
|
||||
class WxJsRechargeOrderService extends WxJsRechargeBaseService
|
||||
{
|
||||
use CheckOrderCallBackTrait,
|
||||
OrderTrait;
|
||||
|
||||
/**
|
||||
* 订单 id
|
||||
* @var int
|
||||
*/
|
||||
protected int $orderId;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected string $orderNo;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected mixed $orderInfo;
|
||||
|
||||
|
||||
public function callBackHandle()
|
||||
{
|
||||
// TODO: Implement callBackHandle() method.
|
||||
$this-> getWechatData();
|
||||
|
||||
$this->checkWxCallBackOrder();
|
||||
|
||||
$this->checkGoodOrder();
|
||||
|
||||
Db::transaction(function (){
|
||||
$this->manageGoodOrder();
|
||||
|
||||
$this->manageWxOrder();
|
||||
});
|
||||
|
||||
//todo 发送订阅通知
|
||||
// $this->sendGainCoinMsg();
|
||||
|
||||
//发送mq通知报表结算
|
||||
// $this->sendShareExMq($this->orderInfo->mid,ShareExCode::RECHARGE_COIN, [
|
||||
// 'order_id' => $this->orderInfo->id,
|
||||
// 'count' => $this->rechargeCoin,
|
||||
// ]);
|
||||
|
||||
return $this->returnSuccess();
|
||||
}
|
||||
|
||||
public function setNotify()
|
||||
|
||||
Reference in New Issue
Block a user