From dea0bef60ebeb366f2872e4d6e4f8eaa7f482629 Mon Sep 17 00:00:00 2001 From: yixian Date: Thu, 14 May 2020 22:32:12 +1000 Subject: [PATCH] fix: settlement email issue. documents update --- pom.xml | 2 +- src/document/openapi/cn/document.yml | 12 +- src/document/openapi/en/document.yml | 271 ++++++++++-------- .../clearing/core/CleanService.java | 2 +- .../clearing/core/impl/CleanServiceImpl.java | 31 +- 5 files changed, 177 insertions(+), 141 deletions(-) diff --git a/pom.xml b/pom.xml index bfb3b872f..63a3aaafe 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ au.com.royalpay.payment payment-parent - 2.1.45 + 2.1.47 4.0.0 manage diff --git a/src/document/openapi/cn/document.yml b/src/document/openapi/cn/document.yml index a82272519..b77863011 100644 --- a/src/document/openapi/cn/document.yml +++ b/src/document/openapi/cn/document.yml @@ -540,7 +540,17 @@ paths: domestic_only: type: boolean default: false - description: 是否只允许本国卡。由于境内境外卡支付手续费差异巨大,可在此限制。 + description: | + 是否只允许本国卡。由于境内境外卡支付手续费差异巨大,可在此限制。 + **当商户开启消费者支付手续费功能,而international_only提交了false时,当前参数自动置为true。** + international_only: + type: boolean + default: false + description: | + 是否只允许国际卡。当商户开启消费者支付手续费功能,需要提交当前参数为true才可允许国际卡支付,同时此订单将只允许国际卡支付。 + **因此商户需要在支付页面提供本地卡和国际卡两个支付入口!** + + 另:当domestic_only=true的时候当前参数无效。 disable_credit_card: type: boolean default: false diff --git a/src/document/openapi/en/document.yml b/src/document/openapi/en/document.yml index 3f39a4ed6..716a2b2cc 100644 --- a/src/document/openapi/en/document.yml +++ b/src/document/openapi/en/document.yml @@ -554,7 +554,18 @@ paths: domestic_only: type: boolean default: false - description: whether only domestic cards can pay. due to there is huge difference on surcharge rate between domestic cards and international cards. merchants can add a limit on the order. + description: | + Whether only domestic cards can pay. due to there is huge difference on surcharge rate between domestic cards and international cards. + Merchants can add a limit on the order. + **Note: If merchant enabled auto attach surcharge on orders, and international_only is false, this parameter will automatically set to true** + international_only: + type: boolean + default: false + description: | + If set this parameter to true, this order will refuse domestic cards. It is useful when merchant enabled auto attach surcharge to orders. + Then is required to set this value as true to enable international cards. This also means customers should choose use domestic cards or international cards first on merchants' page + + And if domestic_only param is true, this param will be ignored. disable_credit_card: type: boolean default: false @@ -610,14 +621,16 @@ paths: put: summary: Create Card Order description: | - 商户可在页面引入https://channel.rpayplus.com/channel/v1/view/card_input_frame.js - 并通过回调取得key_id和secret信息,并将其作为卡信息提交给royalpay直接完成下单支付。 + Input https://channel.rpayplus.com/channel/v1/view/card_input_frame.js in merchant's webpage. + After called commit, it will return `key_id` and `secret` parameter asyncronized by callback. + + Post these parameter to royalpay and finish payment directly. - js引用案例: + js Example ``` - let cardInputContainer = document.getElementById('card-input-area');//预先准备放置卡输入界面的container - let cardInput = new CardInputFrame(cardInputContainer);//创建frame对象 - //设置iframe的样式参数 + let cardInputContainer = document.getElementById('card-input-area');//a container prepared to put the card input frame in. + let cardInput = new CardInputFrame(cardInputContainer);//create frame object + //setting iframe style cardInput.frameStyle = { width: '100%', height: '400px', @@ -625,20 +638,22 @@ paths: borderRadius: '10px' }; cardInput.onError = function(msg){ - //卡输入界面返回错误信息时进行展示 + //if the input card message has mistake, will call this method and pass the error detail here }; cardInput.onReady = function(){ - //iframe加载完毕的触发事件 + //iframe loaded event }; cardInput.onSuccess = function(secretData){ - //成功取得加密卡信息回调 + //success get encrypted card informations //secretData: {'key_id':'','secret':''} }; - cardInput.show();//开始加载iframe + cardInput.show();//start loading iframe - //通过外部事件触发卡输入界面提交,注意卡输入界面没有按钮,必须通过外部触发提交事件。并回调到onSuccess回调函数。 + //call commit method when customer clicked pay button so that callbacks will be triggered cardInput.commit(); ``` + + **Note: This API do not allow customers pay for surcharge** tags: - CardPayment parameters: @@ -663,18 +678,20 @@ paths: properties: key_id: type: string - description: 卡输入界面回调得到的key_id + description: card input frame returned key_id card_info: type: string - description: 卡输入界面回调得到的secret + description: card input frame returned secret domestic_only: type: boolean default: false - description: 是否只允许本国卡。由于境内境外卡支付手续费差异巨大,可在此限制。 + description: | + Whether only domestic cards can pay. due to there is huge difference on surcharge rate between domestic cards and international cards. + Merchants can add a limit on the order. disable_credit_card: type: boolean default: false - description: 如果希望禁止消费者使用信用卡支付可传入true + description: Pass true if want to refuse credit cards. customer: $ref: 'components_order.yml#/cardCustomerParam' responses: @@ -686,10 +703,10 @@ paths: $ref: 'components_order.yml#/orderBasicResponse' /micropay/partners/{partner_code}/orders/{partner_order_id}: put: - summary: 付款码下单 + summary: Retail Passive Payment Order description: | - 线下支付订单接口用于带有扫码设备的收银终端进行对接,商户输入金额后要求客户出示支付码,用扫码枪扫码后将扫码内容和金额一并提交并完成支付操作。 - 线下支付订单接口现已兼容微信、支付宝通道。可根据付款码自动识别交易渠道。 + Retail Passive Payment is used for cashier terminals which can scan BarCode or QRCode. Shop staff input the payment amount and ask customers for their payment code, + then system send price and payment code to server and finish the payment. Retail Passive Payment now support both Alipay and WeChat tags: - RetailPay @@ -715,10 +732,10 @@ paths: properties: device_id: type: string - description: 扫码设备id + description: ID of the device which sends the request auth_code: type: string - description: 付款码 + description: The Payment QR Code scanned from customer's WeChat Wallet. responses: 200: description: Result @@ -728,9 +745,11 @@ paths: $ref: 'components_order.yml#/orderStatus' /retail_qrcode/partners/{partner_code}/orders/{partner_order_id}: put: - summary: 线下QRCode支付单 + summary: Retail Active Payment Order description: | - 线下QRCode支付用于对接无扫码设备的收银终端,下单后得到二维码地址,自行生成二维码图片后展示在收银终端屏幕上,并由用户使用对应支付客户端进行扫码支付。 线下QRCode现已同时兼容支付宝、微信客户端进行支付 + Retail Active Payment is used for cashier terminals which cannot scan Barcode or QRCode. Get the Code url after create the order, + convert this url to a QRCode and ask customers use their app to scan this QRCode then finish the payment. + Retail Active Payment now support Alipay, WeChat tags: - RetailPay @@ -755,7 +774,7 @@ paths: properties: device_id: type: string - description: 收银设备id + description: ID of the device which sends the request. responses: 200: description: Order @@ -768,13 +787,13 @@ paths: properties: code_url: type: string - description: 付款码字符串,商户可自行生成二维码 # todo + description: QR Code string. Partners can create the payment QR Code according to this value. /alipay/partners/{partner_code}/orders/{partner_order_id}: put: - summary: 支付宝WEB订单下单 + summary: Alipay WEB Order description: | - 创建订单后跳转到返回的pay_url(需附加签名参数和redirect参数),随后进入支付宝支付页面完成支付 - 该接口现仅支持支付宝。 + Use for Alipay Payment in PC Website. After create order, jump to the pay_url returned and attach sign params and redirect param. Then enter Alipay page to finish payment. + Alipay Channel Only. tags: - AlipayOnline parameters: @@ -803,10 +822,11 @@ paths: properties: pay_url: type: string - description: Payment page URL,加签后传递给前端并跳转至当前URL,让消费者完成支付 + description: Payment page URL. redirect to the url with signature parameters. /cb_bankpay/partners/{partner_code}/orders/{partner_order_id}: put: - summary: 网银快捷支付下单 + summary: CB BankPay Order + description: Use for CB BankPay in PC Website. After create order, jump to the pay_url returned and attach sign params and redirect param. tags: - CB Bank parameters: @@ -831,10 +851,10 @@ paths: properties: product_name: type: string - description: 商品名称 + description: production name gateway_type: type: integer - description: '网关类型,8: H5网关,9:PC网关' + description: 'Gateway Require 8: H5 gateway,9: PC gateway' enum: - 8 - 9 @@ -850,10 +870,13 @@ paths: properties: pay_url: type: string - description: Payment page URL,加签后传递给前端并跳转至当前URL,让消费者完成支付 + description: Payment page URL. redirect to the url with signature parameters. /gateway/partners/{partner_code}/app_orders/{partner_order_id}: put: - summary: SDK下单 + summary: SDK Order + description: | + Used for mobile Apps calling Wechat payment with Wechat SDK. Call this api to create order and get param string for SDK calling. + Call SDK api with the param to start payment and get payment result from Wechat app It is strongly advised to request RoyalPay order query Api to confirm that the order has been paid in order to cancelling order by system at the same time. tags: - SDK Payment parameters: @@ -877,23 +900,23 @@ paths: properties: channel: type: string - description: 支付渠道,大小写敏感 + description: Payment channel, required, case sensitive enum: - Wechat - Alipay system: type: string - description: 客户端操作类型,支付宝选填,微信不需要 + description: OS type of client app, optional for Alipay, not required for Wechat enum: - android - iphone - ipad version: type: string - description: 客户端版本号,支付宝选填,微信不需要 + description: client app version, optional for Alipay, not required for Wechat appid: type: string - description: 微信必填,开发者平台appid + description: wechat appid, required for Wechat, not required for Alipay responses: 200: description: Order @@ -906,11 +929,13 @@ paths: properties: sdk_params: type: string - description: json字符串,可直接传递给SDK端发起支付 + description: param string for calling SDK /gateway/partners/{partner_code}/channel_exchange_rate: get: - summary: 渠道汇率查询 - description: 获取当前各渠道AUD兑CNY汇率值(1AUD=?CNY),该汇率仅做参考,以实际成交汇率为准 + summary: Channel Exchange Rates + description: | + Get current exchange rate from AUD to CNY provided by WeChat and Alipay(AUD 1=CNY ?). + This exchange rate shown is for reference only, please refer to the real time exchange rate when processing the actual transaction. tags: - PublicApi parameters: @@ -928,28 +953,29 @@ paths: properties: return_code: type: string - description: 状态码 + description: Execution result example: SUCCESS wechat_rate: type: number - description: 微信当前汇率 + description: Wechat exchange rate example: 4.41111 alipay_retail_rate: type: number - description: 支付宝线下接口汇率 + description: Alipay retail exchange rate example: 4.411111 alipay_online_rate: type: number - description: 支付宝线上汇率 + description: Alipay online exchange rate example: 4.411111 /gateway/partners/{partner_code}/orders/{partner_order_id}/refunds/{partner_refund_id}: put: - summary: 发起退款 - description: 一笔支付订单可以分多次退款,退款总金额不得超过实际支付金额,退款币种与支付订单一致 + summary: Refund Order + description: | + One payment order can create more than one refund orders. Total amount of all refund orders must be less than or equal to the actual paid amount and the currency of refund order is the same as the payment order. tags: - QRCode - JSAPI @@ -967,11 +993,11 @@ paths: - name: partner_order_id in: path required: true - description: 需要退款订单的单号 + description: Payment order id in merchant's system - name: partner_refund_id in: path required: true - description: 退款单号 + description: Refund id in merchant's system requestBody: content: application/json: @@ -982,10 +1008,10 @@ paths: properties: fee: type: integer - description: 退款金额,单位是货币最小单位,单个订单退款单金额总和不能超过用户支付金额 + description: 退Refund amount. Use base unit of the currency. Total amount of all refund orders must be less than actual paid amount. device_id: type: string - description: 操作设备id + description: ID of the device which sends the request responses: 200: description: Refund @@ -994,7 +1020,7 @@ paths: schema: $ref: 'components_order.yml#/refundStatus' get: - summary: 查询退款 + summary: Check Refund Status tags: - QRCode - JSAPI @@ -1012,11 +1038,11 @@ paths: - name: partner_order_id in: path required: true - description: 订单的单号 + description: Payment order id in merchant's system - name: partner_refund_id in: path required: true - description: 退款单号 + description: Refund id in merchant's system responses: 200: description: Refund Status @@ -1026,10 +1052,13 @@ paths: $ref: 'components_order.yml#/refundStatus' /gateway/partners/{partner_code}/transactions: get: - summary: 查询流水 + summary: Check Transactions description: | - 本接口将列出商户当日所有流水,包括所有接口(含非网关接口)支付通道的付款、RoyalPay优惠补贴、退款、 退款失败补正、系统补正、营销账户转入转出等,不含清算信息 - 注意一笔付款订单或退款订单均可能对应多条流水记录 + This Api will list all transactions for current merchant in the day, containing all payment methods(include no gateway methods) and all payment channels such as payment, + RoyalPay discount cashback, refunds, credit for failure refunds, system pay back, + cashback account income/outcome, etc. Settlement transactions will not be contained. + + **Note: A payment order or refund order can contains several transaction records** tags: - PublicApi parameters: @@ -1043,7 +1072,7 @@ paths: type: string in: query required: true - description: 账单日期,'yyyyMMdd'格式,GMT+10,只能查今天以前的账单 + description: Transaction date. Format as 'yyyyMMdd', GMT+10. Only transaction before today can be query example: 20200315 responses: 200: @@ -1065,13 +1094,13 @@ paths: SUCCESS transaction_count: type: integer - description: 流水条数 + description: transactions number order_count: type: integer - description: 付款条数 + description: credit number refund_count: type: integer - description: 退款条数 + description: debit number transactions: type: array items: @@ -1086,10 +1115,13 @@ paths: description: target settlement date, maybe delay due to holidays and bank issues(yyyy-MM-dd) /gateway/partners/{partner_code}/settlements: get: - summary: 查看清算详情 + summary: Check Settlements description: | - 本接口将列出商户查询日期清算的所有流水,包括所有接口(含非网关接口)支付通道的付款、RoyalPay优惠补贴、退款、 退款失败补正、系统补正、营销账户转入转出等 - 注意一笔付款订单或退款订单均可能对应多条流水记录 + This Api will list all transactions with the settlement this day, containing all payment methods(include no gateway methods) + and all payment channels such as payment, RoyalPay discount cashback, refunds, credit for failure refunds, + system pay back, cashback account income/outcome, etc. + + **Note: A payment order or refund order can contains several transaction records** tags: - PublicApi parameters: @@ -1102,7 +1134,7 @@ paths: format: date pattern: yyyyMMdd type: string - description: 清算日期,'yyyyMMdd'格式,GMT+10,只能查今天以前 + description: Settle date. Format as 'yyyyMMdd' ,GMT+10. Only settlement before today can be query required: true responses: 200: @@ -1119,56 +1151,58 @@ paths: SUCCESS result_code: type: string - description: 业务Execute Result + description: Process Result example: SUCCESS settle_from: type: string format: date - description: 订单起始日期:yyyyMMdd + description: 'Transaction date from, yyyyMMdd' settle_to: type: string format: date - description: 订单截止日期:yyyyMMdd + description: Transaction date to, yyyyMMdd settle_days: type: string - description: 清算周期 + description: Settle delay example: T+2 transaction_count: type: integer - description: 流水条数 + description: transaction record count order_count: type: integer - description: 付款条数 + description: credit count refund_count: type: integer - description: 退款条数 + description: debit count total_credit: type: integer - description: 入账总金额(AUD分) + description: total credit fee(AUD cent) total_debits: type: integer - description: 支出总金额(AUD分) + description: total debit fee(AUD cent) total_surcharge: type: integer - description: 手续费总额(AUD分) + description: Total surcharge(AUD cent) total_transfer: type: integer - description: 打款总额(AUD分) + description: Total transfer amount(AUD cent) transactions: type: array items: $ref: 'components_order.yml#/transactionItem' /notify: post: - summary: 到账通知 + summary: Order Paid Notify description: | - 若订单创建时提供了notify_url,系统会在用户支付成功后向这个地址主动发送支付成功状态推送,请求方式为POST - 与服务器API不同,推送校验参数会包含在json内,商户系统应该验证校验参数,确定来源正确后再次进行订单接口查询确认订单支付状态再进行后续操作。 - 商户系统收到请求后应按要求返回参数,若RoyalPay未收到合法参数,视为商户未接收成功,推送动作首次触发会重试3次,随后24小时内每10分钟推送一次,直到返回200状态码。 - 商户系统应当能够处理收到的重复请求。 - 商户系统收到通知后以防万一应调用主动查询接口确认订单状态。 + If notify_url is provided when order is created. System will post request to this url when the payment succeeds. + Request method is POST. Different from Server APIs, sign parameters will be included in json entity. + Partner system shall valid them to prevent fake requests. Partner system shall response with correct parameters. + If RoyalPay did not receive valid response, system will regard as receiving failed and retry the notification. + System will retry up to3 times. Partner system shall be able to handle the repeated requests. + + **It is recommended to actively call the query API to confirm the payment status after receiving the push, so as to prevent other third parties from forging the push!** tags: - SDK Payment - CB Bank @@ -1188,53 +1222,53 @@ paths: time: type: integer format: int64 - description: UTC时间戳 + description: UTC timestamp in millis nonce_str: type: string - description: 随机字符串 + description: Random string sign: type: string - description: 签名 + description: Sign partner_order_id: type: string - description: 商户单号 + description: Partner order id channel_order_id: type: string - description: 渠道方交易单号 + description: PayChannel(Alipay、Wechat) Transaction Trade No order_id: type: string - description: RoyalPay订单号 + description: RoyalPay order id total_fee: type: integer - description: 订单金额,单位是最小货币单位 + description: Order amount real_fee: type: integer - description: 支付金额,单位是最小货币单位 + description: Actual paid amount rate: type: number - description: 交易时使用的汇率,1AUD=?CNY + description: Exchange Rate used while trading. 1AUD=?CNY currency: type: string - description: 币种,AUD + description: Currency, AUD channel: type: string - description: 交易渠道 + description: Payment Channel Alipay, AlipayOnline, Wechat create_time: type: string format: 'date-time' pattern: yyyy-MM-dd HH:mm:ss - description: 订单创建时间,格式为'yyyy-MM-dd HH:mm:ss',GMT+10 + description: Time when order is created, which is formatted in 'yyyy-MM-dd HH:mm:ss', GMT+10 pay_time: type: string format: 'date-time' pattern: yyyy-MM-dd HH:mm:ss - description: 订单支付时间,格式为'yyyy-MM-dd HH:mm:ss',GMT+10 + description: Time when order is paid, which is formatted in 'yyyy-MM-dd HH:mm:ss', GMT+10. responses: 200: description: OK /customs/partners/{partner_code}/declare/report/{client_report_id}: put: - summary: 创建报关单 + summary: Create Custom Declare tags: - Custom parameters: @@ -1252,37 +1286,37 @@ paths: properties: order_id: type: string - description: 商户支付订单号,要求同一商户唯一 + description: Partner order id custom: type: string - description: 海关编号 * [渠道海关编号](https://www.royalpay.com.au/downloads/CustomsNO.xlsx) + description: Customs No. * [Channel Custom No](https://www.royalpay.com.au/downloads/CustomsNO.xlsx) mch_custom_id: type: string - description: 商户在海关备案的编号 + description: Customs record id of merchant mch_custom_name: type: string - description: 商户海关备案名称 + description: Customs record name of merchant sub_order: type: array - description: 子订单(拆单) + description: Child orders(If split order required) items: type: object properties: sub_order_no: type: string - description: 商户子订单号 + description: Sub order no fee_type: type: string - description: 币种代码 + description: currency default: CNY enum: - CNY order_fee: type: number - description: 子订单金额,单位是元 + description: Sub order price. unit is Yuan transport_fee: type: number - description: 子订单物流金额,单位是元 + description: Sub order transport fee. unit is Yuan responses: 200: description: Custom @@ -1291,7 +1325,7 @@ paths: schema: $ref: 'components_order.yml#/customInfo' get: - summary: 查询报关单 + summary: Query Custom Report tags: - Custom parameters: @@ -1310,8 +1344,8 @@ paths: $ref: 'components_order.yml#/customInfo' /customs/partners/{partner_code}/redeclare/report/{client_report_id}: put: - summary: 重新提交报关单 - description: 用于重新提交未报关成功的报关单 + summary: Redeclare Custom Report + description: Used to resubmit the attachment information of the order required by the merchant. tags: - Custom parameters: @@ -1334,31 +1368,34 @@ components: type: apiKey in: query name: nonce_str - description: 随机字符串 + description: Random String time: type: apiKey in: query name: time - description: 带毫秒的Unix时间戳,务必检查服务器时间和时区配置。计算服务器上的UTC时间是否匹配真实UTC时间即可。允许误差±5分钟 + description: | + Unix Timestamp with millis. It is recommended to check your server time and timezone configuration. + You can calculate the UTC time according your server time & timezone and check if it was correct. sign: type: apiKey in: query name: sign description: | - 商户签约后会分配得到一个partner_code和credential_code用于签名,其中partner_code随请求传递,credential_code务必自行存储不得外泄,仅作为签名参数。 + After merchants signed contract. They will get a `partner_code` and `credential_code` to make signatures. + `partner_code` is passed with requests. `credential_code` must be store safe in merchant side. it only used to make signatures. - 每次请求都必须加入签名信息作为请求校验。校验参数全部以Query Param参数的方式附加在URL后面,顺序不分先后。 + Each requests must add sign parameters as authentication. Sign params will tailed after request url as query param. And no sort is required. - 签名过程: + Signature progress: - 1. 连接生成签名的原始字符串,需要4个参数,使用&连接,无需转码 + 1. Create origin string for validation. required 4 parameters and connect them with &. Translating is not required. > valid_string=partner_code&time&nonce_str&credential_code - 2. 使用SHA256对valid_string进行签名,并转换为小写字符串 + 2. Use SHA256 to sign valid_string and get lowercased hex string > sign=hex(sha256(valid_string)).toLowerCase() - 3. 在请求中将签名使用的time, nonce_str和生成的sign作为query参数发送 + 3. Pass used `time`, `nonce_str` and generated `sign` as query parameter in requests. - > 签名测试地址:https://mpay.royalpay.com.au/sign_test.html + > Signature test address: https://mpay.royalpay.com.au/sign_test.html diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java index f994fa5f5..c25558ab4 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/CleanService.java @@ -46,7 +46,7 @@ public interface CleanService { void settlementXlsx(Date date, HttpServletResponse response) throws IOException; - List getXlsx(Date dt, String bank, List logs) throws IOException; + List getXlsx(Date dt, List logs) throws IOException; List getSettleLogs(Date dt, List clearIds); diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index ed54117d0..ac308ef7b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -435,28 +435,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } @Override - public List getXlsx(Date dt, String bank, List logs) throws IOException { + public List getXlsx(Date dt, List logs) throws IOException { List result = new ArrayList<>(); - int fileIndex = 1; - if (logs.size() > 1) { - for (JSONObject log : logs) { - String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + "_" + fileIndex + ".xlsx"; - JSONObject file = new JSONObject(); - file.put("name", filename); - List details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); - details = mergeBatchSettleClients(details); - file.put("byteArr", generateSettleXlsxFile(dt, details, bank)); - result.add(file); - fileIndex++; - } - } else { - for (JSONObject log : logs) { - String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + ".xlsx"; + for (JSONObject log : logs) { + List details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); + List banks = details.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList()); + for (String bank : banks) { + String filename = String.format("Merchant_Setlement_Info_%s_%s.xlsx", bank, DateFormatUtils.format(log.getDate("operate_time"), "yyyyMMddHHmmss")); JSONObject file = new JSONObject(); file.put("name", filename); - List details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")); - details = mergeBatchSettleClients(details); - file.put("byteArr", generateSettleXlsxFile(dt, details, bank)); + List mergedDetails = mergeBatchSettleClients(details.stream().filter(detail -> bank.equals(detail.getString("settle_bank"))).collect(Collectors.toList())); + file.put("byteArr", generateSettleXlsxFile(dt, mergedDetails, bank)); result.add(file); } } @@ -1373,7 +1362,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider List attachList = new ArrayList<>(); JSONObject attach1 = new JSONObject(); List clearLogs = getSettleLogs(date, clearIds); - List xlsxFileList = getXlsx(date, "CBA", clearLogs); + List xlsxFileList = getXlsx(date, clearLogs); if (xlsxFileList.size() > 1) { fileName1 += ".zip"; attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList))); @@ -1439,7 +1428,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider ExtParamsUtils.getExtParamsValue(log.getString("plan_detail"), detail -> StringUtils.defaultIfEmpty(detail.getString("remark"), detail.getString("plan_id"))))) .collect(Collectors.joining(",")); - sendTaskFinishMessages(ManagerRole.FINANCIAL_STAFF, "清算文件已发送清算方:"+detailDescription, "发送清算通知"); + sendTaskFinishMessages(ManagerRole.FINANCIAL_STAFF, "清算文件已发送清算方:" + detailDescription, "发送清算通知"); if (autoMarkSent) { if (!clearIds.isEmpty()) { clearingLogMapper.lockSettlementsById(clearLogs.stream().map(log -> log.getString("clearing_id")).collect(Collectors.toList()));