|
@@ -1,16 +1,27 @@
|
|
|
package com.izouma.nineth.service;
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
|
+import com.alibaba.excel.annotation.ExcelProperty;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
|
import com.huifu.adapay.model.AdapayCommon;
|
|
import com.huifu.adapay.model.AdapayCommon;
|
|
|
import com.huifu.adapay.model.Payment;
|
|
import com.huifu.adapay.model.Payment;
|
|
|
|
|
+import com.huifu.adapay.model.Refund;
|
|
|
import com.izouma.nineth.ApplicationTests;
|
|
import com.izouma.nineth.ApplicationTests;
|
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
|
|
|
+import com.izouma.nineth.utils.SnowflakeIdWorker;
|
|
|
|
|
+import com.izouma.nineth.utils.excel.BigIntegerConverter;
|
|
|
|
|
+import com.izouma.nineth.utils.excel.LocalDateConverter;
|
|
|
|
|
+import com.izouma.nineth.utils.excel.LocalDateTimeConverter;
|
|
|
|
|
+import lombok.Data;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -89,4 +100,93 @@ public class AdapayServiceTest extends ApplicationTests {
|
|
|
public void queryBalance() throws BaseAdaPayException {
|
|
public void queryBalance() throws BaseAdaPayException {
|
|
|
adapayService.queryBalance("1110", "0288514678171392");
|
|
adapayService.queryBalance("1110", "0288514678171392");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Data
|
|
|
|
|
+ public static class RefundOrder {
|
|
|
|
|
+ @ExcelProperty("交易时间")
|
|
|
|
|
+ private LocalDateTime time;
|
|
|
|
|
+
|
|
|
|
|
+ @ExcelProperty("订单号")
|
|
|
|
|
+ private String id;
|
|
|
|
|
+
|
|
|
|
|
+ @ExcelProperty("支付流水号")
|
|
|
|
|
+ private String serial;
|
|
|
|
|
+
|
|
|
|
|
+ @ExcelProperty("第三方订单号")
|
|
|
|
|
+ private String thirdId;
|
|
|
|
|
+
|
|
|
|
|
+ @ExcelProperty("支付宝/微信订单号")
|
|
|
|
|
+ private String txId;
|
|
|
|
|
+
|
|
|
|
|
+ @ExcelProperty("交易金额")
|
|
|
|
|
+ private String amount;
|
|
|
|
|
+
|
|
|
|
|
+ private String refundId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void refund() throws BaseAdaPayException {
|
|
|
|
|
+ List<RefundOrder> orders = EasyExcel.read("/Users/drew/Downloads/merTransDetail_0284905900625472_20211201_20211215_1639557451.xlsx")
|
|
|
|
|
+ .head(RefundOrder.class)
|
|
|
|
|
+ .registerConverter(new LocalDateConverter())
|
|
|
|
|
+ .registerConverter(new LocalDateTimeConverter())
|
|
|
|
|
+ .registerConverter(new BigIntegerConverter())
|
|
|
|
|
+ .sheet().doReadSync();
|
|
|
|
|
+ System.out.println(orders.size());
|
|
|
|
|
+ for (RefundOrder order : orders) {
|
|
|
|
|
+ String refundId = new SnowflakeIdWorker(0, 0).nextId() + "";
|
|
|
|
|
+ Map<String, Object> refundParams = new HashMap<>();
|
|
|
|
|
+ refundParams.put("refund_amt", order.getAmount());
|
|
|
|
|
+ refundParams.put("refund_order_no", new SnowflakeIdWorker(0, 0).nextId() + "");
|
|
|
|
|
+ Map<String, Object> response = Refund.create(order.getId(), refundParams);
|
|
|
|
|
+ order.setRefundId(refundId);
|
|
|
|
|
+ }
|
|
|
|
|
+ EasyExcel.write("/Users/drew/Desktop/refund.xlsx", RefundOrder.class).sheet("sheet")
|
|
|
|
|
+ .registerConverter(new LocalDateConverter())
|
|
|
|
|
+ .registerConverter(new LocalDateTimeConverter())
|
|
|
|
|
+ .registerConverter(new BigIntegerConverter())
|
|
|
|
|
+ .doWrite(orders);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void queryrefund() throws BaseAdaPayException {
|
|
|
|
|
+ List<RefundOrder> orders = EasyExcel.read("/Users/drew/Desktop/refund.xlsx")
|
|
|
|
|
+ .head(RefundOrder.class)
|
|
|
|
|
+ .registerConverter(new LocalDateConverter())
|
|
|
|
|
+ .registerConverter(new LocalDateTimeConverter())
|
|
|
|
|
+ .registerConverter(new BigIntegerConverter())
|
|
|
|
|
+ .sheet().doReadSync();
|
|
|
|
|
+ System.out.println(orders.size());
|
|
|
|
|
+ List<String> success = new ArrayList<>();
|
|
|
|
|
+ List<String> fail = new ArrayList<>();
|
|
|
|
|
+ for (RefundOrder order : orders) {
|
|
|
|
|
+ Map<String, Object> refundParams = new HashMap<>();
|
|
|
|
|
+ refundParams.put("refund_order_no", order.getRefundId());
|
|
|
|
|
+ Map<String, Object> refund = Refund.query(refundParams);
|
|
|
|
|
+ System.out.println(refund.get("refunds"));
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (((JSONArray) refund.get("refunds")).getJSONObject(0).getString("trans_status").equals("S")) {
|
|
|
|
|
+ success.add(order.getId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fail.add(order.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ fail.add(order.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println("success:" + success.size());
|
|
|
|
|
+ System.out.println("fail:" + fail.size());
|
|
|
|
|
+ System.out.println(StringUtils.join(fail, ","));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void rrr() throws BaseAdaPayException {
|
|
|
|
|
+ Map<String, Object> response1 = Payment.query("002112021120816060510314566462621900800");
|
|
|
|
|
+ String refundId = new SnowflakeIdWorker(0, 0).nextId() + "";
|
|
|
|
|
+ Map<String, Object> refundParams = new HashMap<>();
|
|
|
|
|
+ refundParams.put("refund_amt", "10.80");
|
|
|
|
|
+ refundParams.put("refund_order_no", new SnowflakeIdWorker(0, 0).nextId() + "");
|
|
|
|
|
+ Map<String, Object> response = Refund.create("002112021120816060510314566462621900800", refundParams);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|