package com.yeshi.makemoney.app.utils.factory.goldcorn;
|
|
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeRecord;
|
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeType;
|
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
|
/**
|
* @author hxh
|
* @title: GoldCornConsumeRecordFactory
|
* @description: 金币消费记录工厂
|
* @date 2022/4/21 11:28
|
*/
|
public class GoldCornConsumeRecordFactory {
|
|
public static GoldCornConsumeRecord createExchange(Long uid, String day, int cornNum, BigDecimal rate) {
|
GoldCornConsumeRecord record = new GoldCornConsumeRecord();
|
record.setUid(uid);
|
record.setCornNum(cornNum);
|
record.setMoney(rate.multiply(new BigDecimal(record.getCornNum())).setScale(2, RoundingMode.FLOOR));
|
record.setType(GoldCornConsumeType.changeMoney);
|
record.setId(uid + "-" + record.getType().name() + "-" + day);
|
//积分兑换少于1分的按照1分计算
|
if (record.getMoney().compareTo(new BigDecimal(0)) == 0 && cornNum > 0) {
|
record.setMoney(new BigDecimal("0.01"));
|
}
|
return record;
|
}
|
|
|
}
|