admin
2022-10-28 0e9b6603d4ae9d11c1fbc90257ce816c5807b8ff
app/src/main/java/com/yeshi/makemoney/app/utils/factory/UserMoneyRecordFactory.java
@@ -1,12 +1,15 @@
package com.yeshi.makemoney.app.utils.factory;
import com.ks.lib.common.exception.ParamsException;
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeRecord;
import com.yeshi.makemoney.app.entity.money.Extract;
import com.yeshi.makemoney.app.entity.money.UserMoneyRecord;
import com.yeshi.makemoney.app.entity.money.UserMoneyType;
import com.yeshi.makemoney.app.entity.user.UserInfo;
import org.yeshi.utils.StringUtil;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
/**
@@ -71,4 +74,30 @@
    }
    public static UserMoneyRecord createGoldCornExchange(GoldCornConsumeRecord record) throws ParamsException {
        if (record == null) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "金币兑换记录不能为空");
        }
        if (record.getId() == null) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "金币兑换记录主键不能为空");
        }
        if (record.getMoney() == null) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "兑换金额不能为空");
        }
        if (record.getUid() == null) {
            throw new ParamsException(ParamsException.CODE_PARAMS_NOT_ENOUGH, "兑换用户不能为空");
        }
        UserMoneyRecord detail = new UserMoneyRecord();
        detail.setCreateTime(new Date());
        detail.setSerialNo(UserMoneyType.goldCorn.name().toLowerCase() + "_" + record.getId());
        detail.setMoney(new BigDecimal(record.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.FLOOR));
        detail.setType(UserMoneyType.goldCorn);
        detail.setUpdateTime(new Date());
        detail.setUser(new UserInfo(record.getUid()));
        detail.setShow(true);
        detail.setAdd(true);
        return detail;
    }
}