<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[汇付支付Dougong Lightning SDK（dg-lightning-sdk-java）]]></title><description><![CDATA[<h1><span style="color:rgb(31, 35, 40)">Dougong Lightning SDK（Java）项目说明</span></h1><h2>Repository：<a href="https://github.com/huifurepo/dg-lightning-sdk-java" rel="noopener noreferrer" target="_blank">https://github.com/huifurepo/dg-lightning-sdk-java</a></h2><h2><span style="color:rgb(31, 35, 40)">概述</span></h2><p><span style="color:rgb(31, 35, 40)">Dougong Lightning SDK 以 V4 插件的形式提供极简聚合支付能力，遵循“化繁为简、必参极简 + 可选灵活扩展”的设计风格，通过统一的调用入口与对象化入参模型降低集成成本。</span></p><h2><span style="color:rgb(31, 35, 40)">主要特性</span></h2><ul><li><span style="color:rgb(31, 35, 40)">统一入口：通过 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">Factory</code><span style="color:rgb(31, 35, 40)"> 创建客户端，所有能力从一个入口发起。</span></li><li><span style="color:rgb(31, 35, 40)">必参极简：主交易字段最小化，低频参数走扩展注入。</span></li><li><span style="color:rgb(31, 35, 40)">可插拔扩展：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">optional(key, value)</code><span style="color:rgb(31, 35, 40)"> 注入场景参数，保持模型稳定。</span></li><li><span style="color:rgb(31, 35, 40)">统一管道：入参归一、扩展合并、序列化、路由与调用一体化。</span></li><li><span style="color:rgb(31, 35, 40)">多场景覆盖：下单、查询、关单、退款、退款查询。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">包结构简述</span></h2><ul><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">factory</code><span style="color:rgb(31, 35, 40)">：统一入口与客户端创建（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">Factory</code><span style="color:rgb(31, 35, 40)">）。</span></li><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">biz.client</code><span style="color:rgb(31, 35, 40)">：业务客户端与链式扩展（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePayClient</code><span style="color:rgb(31, 35, 40)">）。</span></li><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">biz.net</code><span style="color:rgb(31, 35, 40)">：网关请求、签名与路由（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePayRequest</code><span style="color:rgb(31, 35, 40)">）。</span></li><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">models</code><span style="color:rgb(31, 35, 40)">：对象化入参/响应与领域对象（如 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">TradePaymentCreateRequest</code><span style="color:rgb(31, 35, 40)">、分账对象）。</span></li><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">utils</code><span style="color:rgb(31, 35, 40)">：基础工具与配置（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePay</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">DateTools</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">SequenceTools</code><span style="color:rgb(31, 35, 40)"> 等）。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">安装与引入</span></h2><p><span style="color:rgb(31, 35, 40)">在上层业务模块的 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">pom.xml</code><span style="color:rgb(31, 35, 40)"> 中引入：</span></p><pre data-language="plain">&lt;dependency&gt;
  &lt;groupId&gt;com.huifu.dg.lightning.sdk&lt;/groupId&gt;
  &lt;artifactId&gt;dg-lightning-sdk&lt;/artifactId&gt;
  &lt;version&gt;1.0.3&lt;/version&gt;
&lt;/dependency&gt;
</pre><h2><span style="color:rgb(31, 35, 40)">场景快速冒烟</span></h2><ul><li><span style="color:rgb(31, 35, 40)">目标：零门槛验证“统一入口 + 极简扩展”是否接通。</span></li><li><span style="color:rgb(31, 35, 40)">示例目录：查看 dougong-java-sdk项目的bspay-java-sdk-sample 项目</span></li><li><span style="color:rgb(31, 35, 40)">操作步骤：</span><ul><li><span style="color:rgb(31, 35, 40)">在示例目录选择一个交易类型示例类（如 JSAPI/正扫/付款码）。</span></li><li><span style="color:rgb(31, 35, 40)">设置主交易字段：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">req_date</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">req_seq_id</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">huifu_id</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">goods_desc</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">trans_amt</code><span style="color:rgb(31, 35, 40)">、</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">trade_type</code><span style="color:rgb(31, 35, 40)">。</span></li><li><span style="color:rgb(31, 35, 40)">注入通道扩展：将场景参数对象序列化为 JSON，使用 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">optional("method_expand", json)</code><span style="color:rgb(31, 35, 40)"> 注入；</span></li><li><span style="color:rgb(31, 35, 40)">叠加收单能力：如需贴息/增值等，序列化为 JSON，使用 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">optional("tx_metadata", json)</code><span style="color:rgb(31, 35, 40)"> 注入。</span></li><li><span style="color:rgb(31, 35, 40)">运行示例类的 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">main</code><span style="color:rgb(31, 35, 40)"> 或测试方法，观察返回的交易号/二维码/支付参数等核心结果。</span></li></ul></li></ul><h2><span style="color:rgb(31, 35, 40)">快速开始</span></h2><pre data-language="plain">// 1. 初始化商户配置（建议从配置中心加载 MerConfig 后调用 BasePay.initWithMerConfig）
BasePay.initWithMerConfig(merConfig);

// 2. 组装必填入参（以聚合下单为例）
TradePaymentCreateRequest req = new TradePaymentCreateRequest();
req.setReqDate(DateTools.getCurrentDateYYYYMMDD());
req.setReqSeqId(SequenceTools.getReqSeqId32());
req.setHuifuId("6666xxxxxxxxxxx");
req.setGoodsDesc("商品描述");
req.setTransAmt("0.01");
req.setTradeType("A_JSAPI");

// 3. 通过工厂获取客户端并发起调用
Map&lt;String, Object&gt; resp = Factory.Payment.Common()
        .optional("notify_url", "https://your.notify/url")
        .create(req);
</pre><h2><span style="color:rgb(31, 35, 40)">可选参数扩展</span></h2><ul><li><span style="color:rgb(31, 35, 40)">使用链式的 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">optional(key, value)</code><span style="color:rgb(31, 35, 40)"> 在客户端注入低频参数，这些参数将与请求体合并并覆盖同名字段。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">下单统一入口与扩展模型</span></h2><ul><li><span style="color:rgb(31, 35, 40)">单一入口：所有支付下单统一通过 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#create</code><span style="color:rgb(31, 35, 40)"> 发起</span></li><li><span style="color:rgb(31, 35, 40)">交易抽象：用 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">trade_type</code><span style="color:rgb(31, 35, 40)"> 标识具体支付场景；用 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">method_expand</code><span style="color:rgb(31, 35, 40)"> 承载该场景的专有参数，二者组合即为“交易对象”的扩展模型。</span></li><li><span style="color:rgb(31, 35, 40)">收敛策略：新增或变更任意交易场景时，仅需定义场景参数对象 → 序列化为 JSON → 注入 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">method_expand</code><span style="color:rgb(31, 35, 40)">，无需新增接口或客户端方法。</span></li><li><span style="color:rgb(31, 35, 40)">推荐用法：保持必参极简，扩展参数一律通过 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">optional("method_expand", json)</code><span style="color:rgb(31, 35, 40)"> 注入；若无扩展，传 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">"{}"</code><span style="color:rgb(31, 35, 40)"> 即可。</span></li><li><span style="color:rgb(31, 35, 40)">调用示例：</span></li></ul><pre data-language="plain">req.setTradeType("T_JSAPI");
String json = JSON.toJSONString(wxData);
Map&lt;String, Object&gt; resp = Factory.Payment.Common()
    .optional("method_expand", json)
    .create(req);
</pre><h2><span style="color:rgb(31, 35, 40)">交易设计理念</span></h2><ul><li><span style="color:rgb(31, 35, 40)">意向订单（主交易字段）：用统一的主字段表达订单意向与基础要素，如日期、流水号、商户、金额、商品等，保持稳定不随渠道变化。</span></li><li><span style="color:rgb(31, 35, 40)">通道信息（trade_type + method_expand）：以 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">trade_type</code><span style="color:rgb(31, 35, 40)"> 选择支付通道/场景，以 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">method_expand</code><span style="color:rgb(31, 35, 40)"> 承载该通道的专有参数，二者组合定义“如何支付”。新增渠道能力只需新增专有参数对象并通过 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">method_expand</code><span style="color:rgb(31, 35, 40)"> 注入，无需改动统一入口。</span></li><li><span style="color:rgb(31, 35, 40)">收单附加能力（tx_metadata）：用于承载收单侧扩展能力，如贴息、分期、优惠分账、增值等，以 JSON 字符串注入即可。</span></li><li><span style="color:rgb(31, 35, 40)">三层划分：将一次交易抽象为“意向订单（主字段）+ 通道（trade_type+method_expand）+ 收单附加能力（tx_metadata）”。该划分确保主交易模型稳定、通道能力可插拔、收单扩展可累加，统一入口下自然演进。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">统一请求管道（简述）</span></h2><ul><li><span style="color:rgb(31, 35, 40)">入参归一：将请求对象规范化为键值对。</span></li><li><span style="color:rgb(31, 35, 40)">扩展合并：合并扩展参数，客户端注入覆盖同名字段。</span></li><li><span style="color:rgb(31, 35, 40)">特殊序列化：对象型特殊字段统一序列化为 JSON 字符串。</span></li><li><span style="color:rgb(31, 35, 40)">路径解析与调用：将功能码解析为网关路径，完成 HTTP 调用并返回统一结果。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">常用接口示例</span></h2><ul><li><span style="color:rgb(31, 35, 40)">支付下单：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#create</code><span style="color:rgb(31, 35, 40)">（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">TradePaymentCreateRequest</code><span style="color:rgb(31, 35, 40)">）</span></li><li><span style="color:rgb(31, 35, 40)">支付查询：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#query</code></li><li><span style="color:rgb(31, 35, 40)">关单：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#close</code></li><li><span style="color:rgb(31, 35, 40)">退款：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#refund</code></li><li><span style="color:rgb(31, 35, 40)">退款查询：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">CommonPayClient#refundQuery</code></li></ul><h2><span style="color:rgb(31, 35, 40)">开箱即用与场景示例</span></h2><ul><li><span style="color:rgb(31, 35, 40)">项目定位：本包为 V4 极简插件，示例与运行入口位于主 SDK 项目。</span></li><li><span style="color:rgb(31, 35, 40)">示例目录：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">bspay-java-sdk-parent/bspay-java-sdk-sample/src/main/java/com/huifu/bspay/sdk/demo/v4</code></li><li><span style="color:rgb(31, 35, 40)">使用方式：在主 SDK 示例目录中选择对应交易类型的示例类，按需修改基础入参与扩展参数（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">trade_type + method_expand</code><span style="color:rgb(31, 35, 40)"> / </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">tx_metadata</code><span style="color:rgb(31, 35, 40)">），直接运行。</span></li><li><span style="color:rgb(31, 35, 40)">配置说明：主 SDK 通过配置中心加载环境与密钥信息；如运行异常，请在主 SDK 项目中调整环境与商户配置。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">配置说明</span></h2><ul><li><span style="color:rgb(31, 35, 40)">通过 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePay.initWithMerConfig(MerConfig)</code><span style="color:rgb(31, 35, 40)"> 或 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePay.initWithMerConfigs(Map&lt;String, MerConfig&gt;)</code><span style="color:rgb(31, 35, 40)"> 完成多商户配置加载（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">dg-lightning-sdk/src/main/java/com/huifu/dg/lightning/utils/BasePay.java:57-71</code><span style="color:rgb(31, 35, 40)">）。</span></li><li><span style="color:rgb(31, 35, 40)">调用时使用默认商户配置，或在请求方法中指定 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">merchantKey</code><span style="color:rgb(31, 35, 40)"> 选择商户配置（</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePayRequest</code><span style="color:rgb(31, 35, 40)"> 的对应重载）。</span></li><li><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePay.prodMode</code><span style="color:rgb(31, 35, 40)"> 控制目标环境域名（生产/联测/内部），统一封装于 </span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">BasePayRequest</code><span style="color:rgb(31, 35, 40)"> 调用路径解析。</span></li></ul><h2><span style="color:rgb(31, 35, 40)">异常与错误</span></h2><h2><span style="color:rgb(31, 35, 40)">许可与版本</span></h2><ul><li><span style="color:rgb(31, 35, 40)">版本：</span><code style="color:rgb(31, 35, 40);background-color:rgba(175, 184, 193, 0.2)">1.0.3</code></li><li><span style="color:rgb(31, 35, 40)">许可证：Apache-2.0（详见根 POM）</span></li></ul><p></p><p></p>]]></description><link>https://paas.huifu.com/bbs/topic/23/汇付支付dougong-lightning-sdk-dg-lightning-sdk-java</link><generator>RSS for Node</generator><lastBuildDate>Sun, 20 Sep 2026 16:00:18 GMT</lastBuildDate><atom:link href="https://paas.huifu.com/bbs/topic/23.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 May 2026 08:33:17 GMT</pubDate><ttl>60</ttl></channel></rss>