admin
2022-04-07 e1cc0d03fadc2d251d36c0dc3650f75e830d5363
app/src/main/java/com/yeshi/makemoney/app/utils/factory/UserMoneyRecordFactory.java
@@ -1,9 +1,11 @@
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;
@@ -71,4 +73,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(record.getMoney());
        detail.setType(UserMoneyType.goldCorn);
        detail.setUpdateTime(new Date());
        detail.setUser(new UserInfo(record.getUid()));
        detail.setShow(true);
        detail.setAdd(true);
        return detail;
    }
}