|
|
@@ -0,0 +1,67 @@
|
|
|
+package com.sckw.payment.task;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.sckw.payment.model.dto.wallet.PatchPay;
|
|
|
+import com.sckw.payment.dao.KwpWalletRefundMapper;
|
|
|
+import com.sckw.payment.model.KwpWalletRefund;
|
|
|
+import com.sckw.payment.model.constant.RefundEnum;
|
|
|
+import com.sckw.payment.service.PayCenterService;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author xucaiqin
|
|
|
+ * @date 2023-09-05 19:37:00
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Component
|
|
|
+@EnableScheduling
|
|
|
+public class RefundTask {
|
|
|
+ @Resource
|
|
|
+ private PayCenterService payCenterService;
|
|
|
+ @Resource
|
|
|
+ private KwpWalletRefundMapper kwpWalletRefundMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0/1 * * * ? ")
|
|
|
+ public void task() {
|
|
|
+ LambdaQueryWrapper<KwpWalletRefund> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwpWalletRefund::getStatus, RefundEnum.REFUNDING.getStatus());
|
|
|
+ List<KwpWalletRefund> kwpWalletRefunds = kwpWalletRefundMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(kwpWalletRefunds)) {
|
|
|
+ log.warn("无数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<PatchPay> list;
|
|
|
+ try {
|
|
|
+ for (KwpWalletRefund kwpWalletRefund : kwpWalletRefunds) {
|
|
|
+ list = new ArrayList<>();
|
|
|
+ PatchPay patchPay = new PatchPay();
|
|
|
+ patchPay.setUid(kwpWalletRefund.getFilter());
|
|
|
+ patchPay.setMoney(bigMoney(kwpWalletRefund.getActualMoney()));
|
|
|
+ patchPay.setRemark(kwpWalletRefund.getRemark());
|
|
|
+ list.add(patchPay);
|
|
|
+ //查询清分状态,修改退款单状态 todo-xcq
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error("定时任务异常:{}", ex, ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long bigMoney(BigDecimal big) {
|
|
|
+ if (Objects.isNull(big)) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ BigDecimal divide = big.multiply(new BigDecimal("100"));
|
|
|
+ return divide.longValueExact();
|
|
|
+ }
|
|
|
+}
|