|
@@ -16,13 +16,16 @@ import org.dromara.backstage.domain.vo.card.PtCardVo;
|
|
|
import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
import org.dromara.backstage.payment.domain.bo.PurseInOutBo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtBagVo;
|
|
import org.dromara.backstage.payment.domain.vo.PtBagVo;
|
|
|
import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
import org.dromara.backstage.payment.domain.vo.PtUserAccountVo;
|
|
|
|
|
+import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.domain.R;
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.enums.*;
|
|
import org.dromara.common.core.enums.*;
|
|
|
import org.dromara.common.core.exception.consume.ConsumeException;
|
|
import org.dromara.common.core.exception.consume.ConsumeException;
|
|
|
|
|
+import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -152,7 +155,7 @@ public class PayOrderBusiness {
|
|
|
list.parallelStream().forEach(item -> {
|
|
list.parallelStream().forEach(item -> {
|
|
|
// doSubsidyOrderHandle(item, mapCount, infoList);
|
|
// doSubsidyOrderHandle(item, mapCount, infoList);
|
|
|
// 使用线程池进行补助入账
|
|
// 使用线程池进行补助入账
|
|
|
- threadPoolTaskExecutor.execute(()->doSubsidyOrderHandle(item, mapCount, infoList));
|
|
|
|
|
|
|
+ threadPoolTaskExecutor.execute(() -> doSubsidyOrderHandle(item, mapCount, infoList));
|
|
|
});
|
|
});
|
|
|
java.lang.String message = MessageFormat.format("补助到账完成,成功[{0}]条,失败[{1}]条", mapCount.get("successCount"), mapCount.get("errorCount"));
|
|
java.lang.String message = MessageFormat.format("补助到账完成,成功[{0}]条,失败[{1}]条", mapCount.get("successCount"), mapCount.get("errorCount"));
|
|
|
infoList.forEach(log::error);
|
|
infoList.forEach(log::error);
|
|
@@ -161,7 +164,6 @@ public class PayOrderBusiness {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 资金收支时计算管理费
|
|
* 资金收支时计算管理费
|
|
|
*
|
|
*
|
|
@@ -191,6 +193,8 @@ public class PayOrderBusiness {
|
|
|
}
|
|
}
|
|
|
R<PurseInOutBo> result = createNormalOrder(bo);
|
|
R<PurseInOutBo> result = createNormalOrder(bo);
|
|
|
if (result.getCode() == R.SUCCESS) {
|
|
if (result.getCode() == R.SUCCESS) {
|
|
|
|
|
+ // 如果充值成功,更新缓存中的余额
|
|
|
|
|
+ updateCacheBalanceByUserId(bo.getUserId(), bo.getReceiptMoney());
|
|
|
return R.ok(result.getData());
|
|
return R.ok(result.getData());
|
|
|
} else {
|
|
} else {
|
|
|
return R.fail(result.getMsg());
|
|
return R.fail(result.getMsg());
|
|
@@ -219,6 +223,8 @@ public class PayOrderBusiness {
|
|
|
try {
|
|
try {
|
|
|
R<PurseInOutBo> result = createNormalOrder(boCopy);
|
|
R<PurseInOutBo> result = createNormalOrder(boCopy);
|
|
|
if (result.getCode() == R.SUCCESS) {
|
|
if (result.getCode() == R.SUCCESS) {
|
|
|
|
|
+ // 如果退款成功,更新缓存中的余额
|
|
|
|
|
+ updateCacheBalanceByUserId(bo.getUserId(), boCopy.getReceiptMoney());
|
|
|
return R.ok(result.getData());
|
|
return R.ok(result.getData());
|
|
|
} else {
|
|
} else {
|
|
|
return R.fail(result.getMsg(), boCopy);
|
|
return R.fail(result.getMsg(), boCopy);
|
|
@@ -274,10 +280,21 @@ public class PayOrderBusiness {
|
|
|
errorCount++;
|
|
errorCount++;
|
|
|
mapCount.put("errorCount", errorCount);
|
|
mapCount.put("errorCount", errorCount);
|
|
|
infoList.add(MessageFormat.format("[补助到账失败]-[补助信息:{0}]-[错误信息:{1}]", JSONUtil.toJsonStr(orderBo),
|
|
infoList.add(MessageFormat.format("[补助到账失败]-[补助信息:{0}]-[错误信息:{1}]", JSONUtil.toJsonStr(orderBo),
|
|
|
- result.getData().toString()));
|
|
|
|
|
|
|
+ result.getData().toString()));
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
infoList.add(MessageFormat.format("[补助到账失败]-[补助信息:{0}]-[错误信息:{1}]", JSONUtil.toJsonStr(orderBo), e.getMessage()));
|
|
infoList.add(MessageFormat.format("[补助到账失败]-[补助信息:{0}]-[错误信息:{1}]", JSONUtil.toJsonStr(orderBo), e.getMessage()));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private void updateCacheBalanceByUserId(Long id, BigDecimal dealMoney) {
|
|
|
|
|
+ String userId = String.valueOf(id);
|
|
|
|
|
+ BigDecimal balance = BigDecimal.ZERO;
|
|
|
|
|
+ if (RedisUtils.getCacheMapValue(CacheNames.USER_TOTAL_BALANCE, userId) != null) {
|
|
|
|
|
+ balance = RedisUtils.getCacheMapValue(CacheNames.USER_TOTAL_BALANCE, userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ balance = balance.add(dealMoney);
|
|
|
|
|
+ RedisUtils.delCacheMapValue(CacheNames.USER_TOTAL_BALANCE, userId);
|
|
|
|
|
+ RedisUtils.setCacheMapValue(CacheNames.USER_TOTAL_BALANCE, userId, balance);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|