|
|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.pay.paytest;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
@@ -12,7 +13,10 @@ import org.apache.http.client.methods.HttpGet;
|
|
|
import org.jeecg.async.DirectCompletableFutureService;
|
|
|
import org.jeecg.async.ThreadPoolProperties;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.constant.CommonConstant;
|
|
|
import org.jeecg.common.util.SpringContextUtils;
|
|
|
+import org.jeecg.modules.app.form.RefundOrderForm;
|
|
|
+import org.jeecg.modules.app.service.IOrderService;
|
|
|
import org.jeecg.modules.pay.config.WechatConstants;
|
|
|
import org.jeecg.modules.pay.config.WechatPayV3Utils;
|
|
|
import org.jeecg.modules.pay.config.WechatUrlConstants;
|
|
|
@@ -25,7 +29,12 @@ import org.jeecg.modules.pay.serverPay.PayKit;
|
|
|
import org.jeecg.modules.pay.serverPay.RsaKit;
|
|
|
import org.jeecg.modules.rabbitmq.DelayedMessageService;
|
|
|
import org.jeecg.modules.system.app.entity.AppOrder;
|
|
|
+import org.jeecg.modules.system.app.entity.AppOrderProInfo;
|
|
|
+import org.jeecg.modules.system.app.entity.AppSitePlace;
|
|
|
+import org.jeecg.modules.system.app.service.IAppOrderProInfoService;
|
|
|
import org.jeecg.modules.system.app.service.IAppOrderService;
|
|
|
+import org.jeecg.modules.system.app.service.IAppSitePlaceService;
|
|
|
+import org.jeecg.modules.system.app.service.IAppSiteService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
@@ -36,10 +45,10 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.cert.X509Certificate;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
@@ -249,6 +258,57 @@ public class payController {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ private final IAppSitePlaceService appSitePlaceService;
|
|
|
+ private final IAppOrderProInfoService appOrderProInfoService;
|
|
|
+ private final IOrderService orderService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/getTest8")
|
|
|
+ public void test8() throws ParseException {
|
|
|
+ List<AppOrder> list = appOrderService.list(Wrappers.<AppOrder>lambdaQuery()
|
|
|
+ .eq(AppOrder::getPayStatus, CommonConstant.NUMBER_1)
|
|
|
+ .eq(AppOrder::getOrderStatus, CommonConstant.ORDER_STATUS_1)
|
|
|
+ .eq(AppOrder::getOrderType, CommonConstant.ORDER_TYPE_2));
|
|
|
+ for (AppOrder appOrder : list) {
|
|
|
+ //判断订单是否支持过期自动退款
|
|
|
+ String orgCode = appOrder.getOrgCode();
|
|
|
+ AppSitePlace sitePlace = appSitePlaceService.getOne(Wrappers.lambdaQuery(AppSitePlace.class).eq(AppSitePlace::getOrgCode, orgCode).last("limit 1"));
|
|
|
+ if (ObjectUtil.isNotEmpty(sitePlace)){
|
|
|
+ if (sitePlace.getRefundType() != null ){
|
|
|
+ List<AppOrderProInfo> orderProInfoList = appOrderProInfoService.list(Wrappers.lambdaQuery(AppOrderProInfo.class)
|
|
|
+ .eq(AppOrderProInfo::getOrderId, appOrder.getId())
|
|
|
+ .eq(AppOrderProInfo::getType, CommonConstant.ORDER_PRO_INFO_TYPE_2)
|
|
|
+ );
|
|
|
+ List<AppOrderProInfo> refundOrderList = new ArrayList<>();
|
|
|
+ for (AppOrderProInfo appOrderProInfo : orderProInfoList) {
|
|
|
+
|
|
|
+ if (appOrderProInfo.getOrderStatus() == 1) {
|
|
|
+ // 订单未使用,判断是否已过期
|
|
|
+ LocalDateTime expireTime = LocalDateTime.parse(appOrderProInfo.getExpireTime() + " 23:59", DateTimeFormatter.ofPattern(
|
|
|
+ "yyyy-MM" +
|
|
|
+ "-dd HH:mm"));
|
|
|
+ if (expireTime.isBefore(LocalDateTime.now())) {
|
|
|
+ // 订单已过期
|
|
|
+ refundOrderList.add(appOrderProInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //批量退款
|
|
|
+ if (CollUtil.isNotEmpty(refundOrderList)){
|
|
|
+ RefundOrderForm refundOrderForm = new RefundOrderForm();
|
|
|
+ refundOrderForm.setOrderCode(appOrder.getOrderCode());
|
|
|
+
|
|
|
+ StringJoiner sj = new StringJoiner(",");
|
|
|
+ refundOrderList.forEach(appOrderProInfo -> sj.add(appOrderProInfo.getId()));
|
|
|
+
|
|
|
+ refundOrderForm.setOrderProInfoIds(sj.toString());
|
|
|
+ refundOrderForm.setReason("过期自动退款");
|
|
|
+
|
|
|
+ orderService.refundOrder(refundOrderForm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 查询分账回退结果
|