|
|
@@ -8,11 +8,9 @@ import com.izouma.yags.repo.BalanceRecordRepo;
|
|
|
import com.izouma.yags.repo.UserBalanceRepo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
import javax.transaction.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -26,53 +24,6 @@ public class UserBalanceService {
|
|
|
private final SysConfigService sysConfigService;
|
|
|
private final Environment env;
|
|
|
|
|
|
- @PostConstruct
|
|
|
- public void init() {
|
|
|
- balanceRecordRepo.findAll().stream().forEach(b -> {
|
|
|
- if (StringUtils.isEmpty(b.getBalanceDesc())) {
|
|
|
- switch (b.getType()) {
|
|
|
- case WITHDRAW:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.WITHDRAW);
|
|
|
- break;
|
|
|
- case SELL:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.SELL);
|
|
|
- break;
|
|
|
- case AUCTION:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.AUCTION);
|
|
|
- break;
|
|
|
- case AUCTION_RETURN:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.AUCTION_RETURN);
|
|
|
- break;
|
|
|
- case REWARD:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.REWARD);
|
|
|
- break;
|
|
|
- case RETURN:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.RETURN);
|
|
|
- break;
|
|
|
- case PAY:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.PAY);
|
|
|
- break;
|
|
|
- case RECHARGE:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.RECHARGE);
|
|
|
- break;
|
|
|
- case DENY:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.DENY);
|
|
|
- break;
|
|
|
- case BONUS:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.BONUS);
|
|
|
- break;
|
|
|
- case REFUND:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.REFUND);
|
|
|
- break;
|
|
|
- default:
|
|
|
- b.setBalanceDesc(Constants.BalanceDesc.OTHER);
|
|
|
- break;
|
|
|
- }
|
|
|
- balanceRecordRepo.save(b);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
public BalanceRecord balancePay(Long userId, BigDecimal amount, Long orderId, String remark) {
|
|
|
UserBalance userBalance = userBalanceRepo.findById(userId).orElseThrow(new BusinessException("余额不足"));
|
|
|
if (userBalance.getBalance().compareTo(amount) < 0) {
|