admin
2022-05-10 2922e51a7a8e657a8467c818ae16700e41ddac77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
    }
 
 
}