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 com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
|
|
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, String settleId) {
|
GoldCornConsumeRecord record = new GoldCornConsumeRecord();
|
record.setUid(uid);
|
record.setCornNum(cornNum);
|
record.setMoney(rate.multiply(new BigDecimal(record.getCornNum())).setScale(2, RoundingMode.FLOOR).multiply(new BigDecimal(100)).longValue());
|
record.setType(GoldCornConsumeType.changeMoney);
|
record.setId(uid + "-" + record.getType().name() + "-" + day);
|
//积分兑换少于1分的按照1分计算
|
if (record.getMoney() == 0L && cornNum > 0) {
|
record.setMoney(1L);
|
}
|
record.setEventTime(GoldCornUtil.convertFormatDay(day));
|
record.setEventId(settleId);
|
return record;
|
}
|
|
|
}
|