财务、报表、MQ、OA 与同步任务
模块职责
这个模块负责资金单据、在线支付回调、账户流水、授信白条、报表查询、OA 审批回调、MQ 生产消费和跨系统同步。它不是一个单独业务,而是贯穿采购、销售、活动、渠道、移动商城的基础设施。
财务入口
- PC 收付款:
application/controllers/scm/Payment.php - 财务控制器:
application/controllers/financial - 资金账户:
application/controllers/saleAccount/Account.php - 支付中心 MQ:
application/controllers/tasks/PayCenterNotify.php - 结算中心 MQ:
application/controllers/tasks/QPayCenterNotify.php
财务关键 Service 和模型
application/Services/Payment/PaymentSer.php:收付款业务。application/Services/Payment/RepaymentSer.php:还款业务。application/Services/BaseData/AccountSer.php:账户基础能力。application/models/payment/PaymentModel.php:收付款主表。application/models/payment/PaymentInfoModel.php:收付款明细。application/models/payment/RepaymentOrderModel.php:还款单。application/models/orders/PoOrderPayInfoModel.php:采购在线支付信息。
支付中心回调流程
application/controllers/tasks/PayCenterNotify.php 是核心消费者。
支付中心 MQ
-> PayCenterNotify::consume
-> 注册 paycenter_pay_result / paycenter_pay_exception / refund 等事件
-> paycenterPayResult 校验 payStatus
-> 生成 PaymentModel 主单
-> 生成 PaymentInfoModel 明细
-> 写 PoOrderPayInfoModel
-> 更新采购/预订单/授信相关状态
-> 特殊来源触发活动或秒杀状态推进
支付成功判断:
payStatus == 02才认为支付成功。- 支付明细按
payAccountTypeCode分组,可能包含个人付款、白条、待退款账户、返利、专属返利、服务费等。 - 在线采购支付会写
paymentType = PoOrderEnums::PAYMENT_TYPE_ONLINE。
支付异常:
paycenter_pay_exception会尝试关闭待支付采购单。- 秒杀待支付采购单关闭后需要释放秒杀码。
报表入口
- 报表控制器:
application/controllers/reports - 老报表入口:
application/controllers/Report.php - 报表 Service:
application/Services/Report
主要报表 Service:
PurchaseReportSer.php:采购明细、采购退货、采购入库、供应商维度、活动订单报表。SaleReportSer.php:销售对账、历史销售、商品销售。InventoryReportSer.php:库存报表。ProfitReportSer.php:利润报表。CustomerReportSer.php:客户报表。AccountPaySer.php、AccountReceiveSer.php:应付应收。
报表查询特点:
- 部分查询不直接查业务库,而是请求
CENTER_API.'/devcenter/report/hologres/query'。 PurchaseReportSer使用 DWD 表,如dwd_bbyh_dgj_scm_po_order、dwd_bbyh_dgj_scm_po_order_return、dwd_bbyh_dgj_scm_pu_invoice。- 报表口径可能和实时业务库有延迟,排查时要同时确认业务表和 DWD 表。
MQ 生产者
统一封装在 application/Services/Mq/MqSer.php。
常见消息:
- 库存事件:
sendInventoryEvent - 采购入库:
sendInStorageEvent - 采购关闭确认:
sendPoCloseOrderConfirm - 暂停取消:
sendPauseCancel - 销售出库通知 APP:
sendSaOrderOutToMq - 销售状态通知 APP:
sendSaOrderStatusToMq - 活动开始/结束通知 SAAS:
sendActivityStartToSaas、sendActivityEndToSaas - OA 结果:
sendOAResult - 渠道订单:
sendChannelOrderManualCreate、sendChannelOrderDelivery、sendChannelOrderApprove - 对账单:
sendStatementStrategySync、sendStatementBillCreate、sendStatementSend
MQ 事件常量在 application/KzData/Enums/MqEventEnums.php。
MQ 消费者和任务
消费者入口集中在 application/controllers/tasks:
OrderCenterNotify.php:订单中心正向、售后、取消、关闭、自制订单。PayCenterNotify.php:支付中心。OaNotify.php、OaResultNotify.php:OA 审批。DispatchCenterNotify.php:调拨/配送中心。ItemCenterNotify.php:商品中心。SaasOrderNotify.php:SAAS 订单通知。ChannelOrderNotify.php:渠道订单。StatementNotify.php、StatementTasks.php:对账单。FlashSaleTask.php:秒杀超时和补偿。
OA 审批
OA 相关枚举在 application/KzData/Enums/OaEnums.php:
2审批成功。3审批失败。
秒杀活动使用 FlashActivityEnums::OA_TEMPLATE_CODE = callback_20260526。OPS 提交活动后会进入 OA,OA 回调再更新活动申请状态和启用状态。
销售/出库同步下游
application/Services/SyncOrder/SyncOrderSer.php 负责把 DGJ 销售和出库同步到 dgj_notify:
garage_repair_order_createdgarage_repair_order_updatedgarage_repair_order_cancelledgarage_repair_order_stoppedgarage_repair_outbound_createdgarage_repair_outbound_updatedgarage_repair_outbound_cancelled
SyncOrderBuilder.php 会把 DGJ 单据转换成下游字段:
- 订单:服务站、订单类型、客户、总数量、总金额、支付方式、商品明细。
- 出库:出库数量、出库金额、仓库、货位、销售单号、出库单号。
- 取消/结单:取消原因、结单原因、时间。
常见跨系统流程
采购在线支付
-> 支付中心 MQ
-> PayCenterNotify
-> 付款单/明细/采购支付信息
-> 采购状态推进
-> 活动或秒杀状态联动
销售出库
-> InventorySer 写库存
-> MqSer::sendInventoryEvent
-> SyncOrderSer::syncOutboundCreate
-> APP/SAAS/下游收到出库事件
OPS 秒杀审批
-> FlashActivitySer::submitFlashActivity
-> OA
-> OaNotify / OaResultNotify
-> 活动申请状态更新
渠道发货
-> BaseOrder::delivery
-> 创建出库
-> MqSer::sendChannelOrderDelivery
-> 渠道方收到发货通知
排查建议
- MQ 没消费:先看对应
tasks/*Notify.php是否注册了事件,再看MqEventEnums的 destination 和 routing key。 - 回调重复:查业务表是否有幂等字段,如订单号、来源单号、唯一签收 ID。
- 支付成功但财务单没有:查
PaymentModel、PaymentInfoModel、PoOrderPayInfoModel和支付回调日志。 - 报表不一致:业务库和 Hologres DWD 表都要查,确认同步时间。
- OA 状态不一致:查活动表的
apply_status、oa_status、oa_no,再查 OA 回调任务。