mirror of
https://gitee.com/technical-laohu/mpay_v2_webman.git
synced 2026-05-17 06:20:25 +08:00
feat: 完善支付通道和收款监听链路
新增 ChannelNotifyPayloadInterface 等支付插件通知契约,规范 pay_no 定位和插件返回校验。 新增微信、支付宝、收钱吧、Postar 个人收款插件适配,支持余额识别与备注识别。 新增 receipt-watcher 后端进程、Redis 队列 job 和平台事件监听,覆盖收款流水通知、商户通知、退款派发、转账派发与清算完成。 补齐个人收款监听相关系统配置、仓储、服务费冻结明细、订单后台操作和通道测试能力。 重构支付单创建、回调、费用、风控、结算和通道统计链路,统一状态流转与幂等处理。
This commit is contained in:
32
app/queue/redis/MerchantNotify.php
Normal file
32
app/queue/redis/MerchantNotify.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\MerchantNotifyJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 商户通知队列消费者。
|
||||
*
|
||||
* 只声明队列名和业务 Job,具体消费逻辑统一放在 MerchantNotifyJob 中。
|
||||
*/
|
||||
class MerchantNotify extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::MERCHANT_NOTIFY;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<MerchantNotifyJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return MerchantNotifyJob::class;
|
||||
}
|
||||
}
|
||||
33
app/queue/redis/README.md
Normal file
33
app/queue/redis/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Redis Consumer 目录说明
|
||||
|
||||
本目录只放会被 `webman/redis-queue` 扫描的正式 Redis 队列 Consumer。
|
||||
|
||||
当前配置位于 `config/plugin/webman/redis-queue/process.php`,其中 `consumer_dir` 指向本目录。队列进程启动时会递归扫描本目录下的 PHP 文件,只要类实现了 `Webman\RedisQueue\Consumer`,就会被实例化并订阅队列。
|
||||
|
||||
## Consumer 职责
|
||||
|
||||
Consumer 应保持很薄,只负责:
|
||||
|
||||
- 声明队列名。
|
||||
- 声明对应 Job 类。
|
||||
- 适配 Redis 队列框架。
|
||||
|
||||
队列名统一从 `app\common\constant\PaymentQueueConstant` 引用,避免生产者和消费者各自维护字符串。
|
||||
|
||||
业务处理应放在 `app/queue/job` 下的 Job 类中。
|
||||
|
||||
## 禁止放入
|
||||
|
||||
- 抽象基类。
|
||||
- 示例 Consumer。
|
||||
- 不希望生产环境订阅的临时测试类。
|
||||
- 复杂业务逻辑。
|
||||
|
||||
这些文件可能被队列进程扫描并误订阅。
|
||||
|
||||
## 新增任务约定
|
||||
|
||||
1. 先在 `app/common/constant/PaymentQueueConstant.php` 登记队列名。
|
||||
2. 再在 `app/queue/job` 新增业务 Job。
|
||||
3. 最后在本目录新增 Consumer,继承 `app\queue\support\AbstractRedisConsumer`。
|
||||
4. Consumer 只设置 `$queue`,并通过 `jobClass()` 返回对应 Job 类名。
|
||||
30
app/queue/redis/ReceiptFlowNotify.php
Normal file
30
app/queue/redis/ReceiptFlowNotify.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\ReceiptFlowNotifyJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 网页流水监听通知队列消费者。
|
||||
*/
|
||||
class ReceiptFlowNotify extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::RECEIPT_FLOW_NOTIFY;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<ReceiptFlowNotifyJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return ReceiptFlowNotifyJob::class;
|
||||
}
|
||||
}
|
||||
32
app/queue/redis/RefundDispatch.php
Normal file
32
app/queue/redis/RefundDispatch.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\RefundDispatchJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 退款通道请求队列消费者。
|
||||
*
|
||||
* 只声明队列名和业务 Job,具体消费逻辑统一放在 RefundDispatchJob 中。
|
||||
*/
|
||||
class RefundDispatch extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::REFUND_DISPATCH;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<RefundDispatchJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return RefundDispatchJob::class;
|
||||
}
|
||||
}
|
||||
30
app/queue/redis/SettlementComplete.php
Normal file
30
app/queue/redis/SettlementComplete.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\SettlementCompleteJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 清算自动入账队列消费者。
|
||||
*/
|
||||
class SettlementComplete extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::SETTLEMENT_COMPLETE;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<SettlementCompleteJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return SettlementCompleteJob::class;
|
||||
}
|
||||
}
|
||||
32
app/queue/redis/TransferDispatch.php
Normal file
32
app/queue/redis/TransferDispatch.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\TransferDispatchJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 转账通道派发队列消费者。
|
||||
*
|
||||
* 只声明队列名和业务 Job,具体消费逻辑统一放在 TransferDispatchJob 中。
|
||||
*/
|
||||
class TransferDispatch extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::TRANSFER_DISPATCH;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<TransferDispatchJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return TransferDispatchJob::class;
|
||||
}
|
||||
}
|
||||
32
app/queue/redis/TransferQuery.php
Normal file
32
app/queue/redis/TransferQuery.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\queue\redis;
|
||||
|
||||
use app\common\constant\PaymentQueueConstant;
|
||||
use app\queue\job\TransferQueryJob;
|
||||
use app\queue\support\AbstractRedisConsumer;
|
||||
|
||||
/**
|
||||
* 转账通道查单队列消费者。
|
||||
*
|
||||
* 只声明队列名和业务 Job,具体消费逻辑统一放在 TransferQueryJob 中。
|
||||
*/
|
||||
class TransferQuery extends AbstractRedisConsumer
|
||||
{
|
||||
/**
|
||||
* 队列名称。
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $queue = PaymentQueueConstant::TRANSFER_QUERY;
|
||||
|
||||
/**
|
||||
* 获取任务类名。
|
||||
*
|
||||
* @return class-string<TransferQueryJob> 任务类名
|
||||
*/
|
||||
protected function jobClass(): string
|
||||
{
|
||||
return TransferQueryJob::class;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user