Bläddra i källkod

fix:定时任务同步前一天的支付状态

ct 5 dagar sedan
förälder
incheckning
afc87bbbf8

+ 3 - 1
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -174,8 +174,10 @@ public class IndexStatisticsController {
         if(ObjectUtils.isNull(redPacketCompanyMoney)){
             redPacketCompanyMoney = BigDecimal.ZERO;
         }
-        consumptionBalanceDataDTO.setRunTianBalance(redPacketCompanyMoney);
+        if (consumptionBalanceDataDTO != null){
+            consumptionBalanceDataDTO.setRunTianBalance(redPacketCompanyMoney);
 
+        }
         return R.ok().put("data", consumptionBalanceDataDTO);
     }
 

+ 7 - 0
fs-admin/src/main/java/com/fs/his/task/Task.java

@@ -197,6 +197,8 @@ public class Task {
     private FsUserOperationLogMapper fsUserOperationLogMapper;
 
     public static final String SOP_TEMP_VOICE_KEY = "sop:tempVoice";
+    @Autowired
+    private IFsStorePaymentService fsStorePaymentService;
 
     /**
      * sop任务token消耗统计
@@ -1531,5 +1533,10 @@ public class Task {
         log.info("定时删除行为轨迹记录 {} 条", deleteCount);
     }
 
+    //同步支付状态
+    public void synchronizePayStatus(){
+        fsStorePaymentService.synchronizePayStatus();
+    }
+
 
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/service/IFsStorePaymentService.java

@@ -126,4 +126,6 @@ public interface IFsStorePaymentService
     R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param);
 
     String payConfirm(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo);
+
+    void synchronizePayStatus();
 }

+ 2 - 2
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -388,7 +388,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         return 1;
     }
 
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public int refundMoney(FsStoreAfterSales fsStoreAfterSales) {
         FsStoreAfterSales order = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(fsStoreAfterSales.getId());
@@ -473,7 +473,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         if (payments != null && payments.size() > 0) {
             FsStorePayment payment = payments.get(0);
             if (reMoney.compareTo(payment.getPayMoney()) > 0) {
-                return 0; //退款金额不能大于实际支付金额
+                throw new CustomException("退款金额不能大于实际支付金额"); //退款金额不能大于实际支付金额
             }
             String json = configService.selectConfigByKey("his.pay");
             if (payment.getPayMode().equals("wx")) {

+ 24 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStorePaymentServiceImpl.java

@@ -7,6 +7,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
@@ -1536,6 +1537,29 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
         return "SUCCESS";
     }
 
+    @Override
+    public void synchronizePayStatus() {
+        FsStorePayment queryParam = new FsStorePayment();
+        queryParam.setStatus(0);//未支付
+        queryParam.setBeginTime(DateUtils.addDateDays(-1));
+        queryParam.setEndTime(DateUtils.getNowDate().toString());
+        List<FsStorePayment> list = selectFsStorePaymentList(queryParam);
+        if (list != null && !list.isEmpty()) {
+            List<CompletableFuture<Void>> futures = new ArrayList<>();
+            for (FsStorePayment fsStorePayment : list) {
+                if (fsStorePayment.getPayCode().equals("1974233163920048128")){
+                    System.out.println(fsStorePayment.getPayCode());
+                }
+                CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
+                    updateFsStorePaymentByDecryptForm(fsStorePayment.getPaymentId());
+                    logger.info("定时任务:同步支付状态,payment_id:{}",fsStorePayment.getPaymentId());
+                });
+                futures.add(future);
+            }
+            CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+        }
+    }
+
     @Override
     public R paymentByWxaCode(FsStorePaymentPayParam param) {
         FsUser user = userMapper.selectFsUserById(param.getUserId());

+ 2 - 0
fs-service/src/main/resources/mapper/his/FsStorePaymentMapper.xml

@@ -58,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="storeId != null "> and store_id = #{storeId}</if>
             <if test="businessCode != null "> and business_code = #{businessCode}</if>
             <if test="appId != null and appId !=''"> and app_id = #{appId}</if>
+            <if test="beginTime != null and beginTime !=''"> and create_time >= #{beginTime}</if>
+            <if test="endTime != null and endTime !=''"> and create_time &lt;= #{endTime}</if>
         </where>
     </select>