Veronique 6 місяців тому
батько
коміт
cad7835c6d

+ 14 - 3
conf/script/1000/init/Time_3_D_0_1_0_0_SavePayRequestRecord.groovy

@@ -6,7 +6,9 @@ import com.yinjie.heating.common.datas.ESKeys
 import com.yinjie.heating.common.entity.heating.PayRequestRecord
 import com.yinjie.heating.common.tool.ERPUtils
 import org.apache.logging.log4j.Logger
+import org.elasticsearch.index.query.BoolQueryBuilder
 import org.elasticsearch.index.query.QueryBuilders
+import org.elasticsearch.index.reindex.DeleteByQueryAction
 
 import java.nio.charset.StandardCharsets
 import java.nio.file.Files
@@ -30,15 +32,16 @@ static def createRunnable(String appHome, ESClient esClient, NoSqlKeysService ke
         Path filePath = Paths.get(fileName)
         Files.createDirectories(filePath.getParent())
 
+        BoolQueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PAY_REQUEST_RECORD_TYPE))
+                .must(QueryBuilders.rangeQuery("createTimeLong").lt(ERPUtils.dayStartTimeMilliseconds))
+
         Ignore_ExecPageFlipper.execute(1000, { PageFlipper p ->
             List<PayRequestRecord> payRequestRecordList = ESList.<PayRequestRecord> getESList()
                     .esClient(esClient)
                     .jsonConvert(jsonConvert)
                     .clazz(PayRequestRecord.class)
                     .queryBuilder({
-                        return QueryBuilders.boolQuery().must(QueryBuilders.typeQuery(ESKeys.ES_ERP_PAY_REQUEST_RECORD_TYPE))
-                                .must(QueryBuilders.rangeQuery("createTimeLong").lt(ERPUtils.dayStartTimeMilliseconds))
-
+                        return qb
                     })
                     .index(keysService.getESKey(ESKeys.ES_ERP_PAY_REQUEST_RECORD_INDEX, supplierCode))
                     .executePage(p)
@@ -57,6 +60,14 @@ static def createRunnable(String appHome, ESClient esClient, NoSqlKeysService ke
                     StandardOpenOption.APPEND)
         })
 
+        //写完之后,将前一天的es清掉
+        DeleteByQueryAction.INSTANCE.newRequestBuilder(esClient.getClient())
+                .refresh(true)
+                .source(keysService.getESKey(ESKeys.ES_ERP_PAY_REQUEST_RECORD_INDEX, supplierCode))
+                .filter(qb)
+                .get()
+
+
         sleep(1000) //无论如何,让脚本执行时间超过1s,防止1s内执行完毕导致多次执行
         logger.info("写入请求销账记录完成")
 

+ 52 - 4
doc/热力服务商接口说明.md

@@ -18,7 +18,7 @@
 
 ## 签名/验签规则
 
-平台将请求参数字段**排序后**序列化为键值对,并使用&链接成字符串
+平台/商户将请求参数字段**排序后**序列化为键值对,并使用&链接成字符串
 
 对字符串进行rsa2048签名
 
@@ -41,7 +41,9 @@ RAS密钥可以使用支付宝提供的工具计算 [密钥生成工具](http://
 
 # 接口说明
 
-平台发起调用,商户收到调用信息并验证签名后返回对应的业务信息,商户在进件时需要提供对应接口的访问地址
+==平台发起调用==
+
+商户收到调用信息并验证签名后返回对应的业务信息
 
 # 查询缴费单
 
@@ -83,12 +85,12 @@ RAS密钥可以使用支付宝提供的工具计算 [密钥生成工具](http://
 | DEF0012 | 该用户不支持网上缴费,请联系公共事业单位 |
 | DEF0006 | 其他异常                 |
 
-
-
 # 缴费单销账
 
 ## 应用场景
 
+==平台发起调用==
+
 用户在平台完成缴费,需要调用商户的系统进行销账。
 
 ## 请求参数
@@ -125,3 +127,49 @@ RAS密钥可以使用支付宝提供的工具计算 [密钥生成工具](http://
 | DEF0013 | 金额不符合规则              |
 | DEF0006 | 其他异常                 |
 
+# 下载对账单
+
+## 应用场景
+
+==商户发起调用==
+
+商户可在交易次日向平台发起交易日账单下载请求
+
+## 请求Header
+
+| 参数    | 类型     | 必填 | 描述           |
+| :---- | :----- | :- | :----------- |
+| appId | String | 是  | 商户号,由平台提供,唯一 |
+
+## 请求参数
+
+| 参数        | 类型     | 必填 | 描述            |
+| :-------- | :----- | :- | :------------ |
+| payDate   | String | 是  | 账单日期 yyyyMMdd |
+| nonceStr  | String | 是  | 随机字符串         |
+| timeStamp | String | 是  | 请求发起的时间戳      |
+| sign      | String | 是  | 签名            |
+
+## 返回结果
+
+| 变量名         | 类型      | 描述                                                                               | 示例值        |
+| :---------- | :------ | :------------------------------------------------------------------------------- | :--------- |
+| appId       | String  | 商户号,由平台提供,唯一,原样回传即可                                                              | 1234567    |
+| respCode    | String  | 调用结果,详见错误码                                                                       | 00000      |
+| respMsg     | String  | 错误描述                                                                             | success    |
+| fileKey     | byte\[] | 使用==商户方提供的公钥==加密后的文件aes密钥.商户须自行使用私钥解密出文件aes密钥之后,再使用aes密钥对fileContent进行解密得到原始文件内容 |            |
+| fileContent | byte\[] | 使用文件aes密钥加密后的文件内容                                                                |            |
+| timeStamp   | String  | 请求返回的时间戳                                                                         | 1745393406 |
+
+
+
+## 错误码
+
+| 错误码     | 描述          |
+| :------ | :---------- |
+| 00000   | 成功          |
+| DEF0020 | 该日期账单文件暂未生成 |
+| DEF0030 | 验签失败        |
+| DEF0010 | 用户不存在       |
+| DEF0006 | 其他异常        |
+

+ 5 - 4
yjWebCore/src/main/java/com/yinjie/heating/webcore/rest/TestRest.java

@@ -67,7 +67,7 @@ public class TestRest extends BaseService {
                 () -> {
                     HeatingApp app = heatingDocService.getRedisHeatingApp("TEST000000", Long.parseLong(supplierCode));
 
-                    RetResult<QueryFeeResponse> result = callThirdAppService.callQueryFee("testUserBillKey", app, dataSourceId, Long.parseLong(supplierCode));
+                    RetResult<QueryFeeResponse> result = callThirdAppService.callQueryFee("700003035", app, dataSourceId, Long.parseLong(supplierCode));
                     if (result.isSuccess()) {
                         return RMapUtils.successV2(result.getResult(), null, null);
                     } else {
@@ -87,7 +87,7 @@ public class TestRest extends BaseService {
                 () -> {
                     HeatingApp app = heatingDocService.getRedisHeatingApp("TEST000000", Long.parseLong(supplierCode));
 
-                    RetResult<BaseResponse> result = callThirdAppService.callRequestPay("testUserBillKey", "20250425", "bankNo000000000000000",
+                    RetResult<BaseResponse> result = callThirdAppService.callRequestPay("700003035", "20250425", "bankNo000000000000000",
                             "100", app, dataSourceId, Long.parseLong(supplierCode));
                     if (result.isSuccess()) {
                         return RMapUtils.successV2(result.getResult(), null, null);
@@ -107,13 +107,12 @@ public class TestRest extends BaseService {
             @RestHeader(name = ERPHeader.HTTPHEADER_SUPPLIER) String supplierCode) {
         return CompletableFuture.supplyAsync(
                 () -> {
-
                     Map<String, String> header = new HashMap<>();
                     header.put("Content-Type", "application/json");
                     header.put("appId", "TEST000000");
 
                     Map<String, String> body = new HashMap<>();
-                    body.put("payDate", "20250901");
+                    body.put("payDate", "20250729");
                     body.put("nonceStr", UUID.randomUUID().toString().replace("-", ""));
                     body.put("timeStamp", String.valueOf((new Date()).getTime()));
 
@@ -154,6 +153,8 @@ public class TestRest extends BaseService {
 
                             String fileContent = new String(orgFileContent, StandardCharsets.UTF_8);
 
+                            logger.info(fileContent);
+
                             return RMapUtils.successV2(fileContent, null, null);
                         } else {
                             return RMapUtils.error(HttpCode.BAD_REQUEST.value(), response.getRespMsg());

+ 1 - 1
yjWebCore/src/main/java/com/yinjie/heating/webcore/servlet/ThirdInvokeServlet.java

@@ -214,7 +214,7 @@ public class ThirdInvokeServlet extends ERPAdminHttpServlet {
         String billKey = reqBody.get("billKey").toString();
         String payDate = reqBody.get("payDate").toString();  //yyyyMMdd
         String bankBillNo = reqBody.get("bankBillNo").toString();
-        String payAmount = reqBody.get("payAmount").toString();
+        String payAmount = reqBody.get("payAmount").toString(); //元
 
         BigDecimal chargeMoney = new BigDecimal(payAmount);
         if (chargeMoney.compareTo(BigDecimal.ZERO) < 1) {