update 校验支付单

This commit is contained in:
2023-10-24 14:49:49 +08:00
parent 238784d987
commit a4352ebc64
4 changed files with 49 additions and 37 deletions

View File

@@ -2,12 +2,14 @@ package com.jsowell.adapay.service;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.TypeReference;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.*;
import com.jsowell.adapay.common.AdaPayment;
import com.jsowell.adapay.common.CreateAdaPaymentParam;
import com.jsowell.adapay.common.DivMember;
import com.jsowell.adapay.config.AbstractAdapayConfig;
@@ -1088,27 +1090,40 @@ public class AdapayService {
/**
* 查询支付列表
*/
public void queryPaymentList(String startTime, String endTime) {
public List<AdaPayment> queryPaymentList(String startTime, String endTime) throws BaseAdaPayException {
List<AdaPayment> resultList = Lists.newArrayList();
String wechatAppId = "wxbb3e0d474569481d";
String appId = "app_d0c80cb1-ffc8-48cb-a030-fe9bec823aaa";
long begin = DateUtils.dateStrToTimestamp(startTime); // 13位时间戳
long end = DateUtils.dateStrToTimestamp(endTime); // 13位时间戳
// 根据时间段查询支付对象列表
Map<String, Object> queryListParam = Maps.newHashMap();
queryListParam.put("app_id", appId);
queryListParam.put("page_index", "1");
queryListParam.put("page_size", "20");
queryListParam.put("created_gte", begin);
queryListParam.put("created_lte", end);
int pageNum = 0; // 页面容量,取值范围 1~20默认值为 10
int pageSize = 20; // 页面容量,取值范围 1~20默认值为 10
System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam));
Map<String, Object> paymentListResult = null;
try {
paymentListResult = Payment.queryList(queryListParam, wechatAppId);
} catch (BaseAdaPayException e) {
throw new RuntimeException(e);
}
System.out.println("查询支付对象列表result" + JSON.toJSONString(paymentListResult));
boolean hasMore;
do {
pageNum += 1;
// 根据时间段查询支付对象列表
Map<String, Object> queryListParam = Maps.newHashMap();
queryListParam.put("app_id", appId);
queryListParam.put("page_index", pageNum);
queryListParam.put("page_size", pageSize);
queryListParam.put("created_gte", begin);
queryListParam.put("created_lte", end);
System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(queryListParam));
Map<String, Object> paymentListResult = Payment.queryList(queryListParam, wechatAppId);
if (paymentListResult == null) {
break;
}
String jsonString = JSON.toJSONString(paymentListResult);
System.out.println("查询支付对象列表result" + jsonString);
JSONObject jsonObject = JSON.parseObject(jsonString);
List<AdaPayment> list = jsonObject.getList("payments", AdaPayment.class, JSONReader.Feature.FieldBased);
resultList.addAll(list);
hasMore = jsonObject.getBoolean("has_more");
} while (hasMore);
return resultList;
}
}