admin
2022-05-19 a44f2c3b5db92069ea2813ecf8cb12a6ab3b2203
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.yeshi.makemoney.app.utils.factory.msg;
 
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeRecord;
import com.yeshi.makemoney.app.entity.msg.UserMsg;
import com.yeshi.makemoney.app.entity.msg.UserMsgType;
import org.yeshi.utils.StringUtil;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
 
/**
 * @author hxh
 * @title: UserMsgFactory
 * @description: 用户消息工厂
 * @date 2022/4/7 15:51
 */
public class UserMsgFactory {
 
    /**
     * @return com.yeshi.makemoney.app.entity.msg.UserMsg
     * @author hxh
     * @description 金币兑换
     * @date 16:02 2022/4/7
     * @param: record
     * @param: balance
     **/
    public static UserMsg createGoldCornExchange(GoldCornConsumeRecord record, BigDecimal balance) {
        UserMsg userMsg = new UserMsg();
        userMsg.setType(UserMsgType.goldcornexchange);
        userMsg.setUid(record.getUid());
        List<UserMsg.UserMsgItem> contentList = new ArrayList<>();
        contentList.add(new UserMsg.UserMsgItem("折算金币", record.getCornNum() + ""));
        contentList.add(new UserMsg.UserMsgItem("折算金额", new BigDecimal(record.getMoney()).divide(new BigDecimal(100), 2, RoundingMode.FLOOR).toString() + "元"));
        contentList.add(new UserMsg.UserMsgItem("账户余额", balance.toString() + "元"));
        userMsg.setContentList(contentList);
        return userMsg;
    }
 
 
    /**
     * @return com.yeshi.makemoney.app.entity.msg.UserMsg
     * @author hxh
     * @description 提现成功
     * @date 16:02 2022/4/7
     * @param: uid
     * @param: money
     **/
    public static UserMsg createExtractSuccess(Long uid, BigDecimal money) {
        UserMsg userMsg = new UserMsg();
        userMsg.setType(UserMsgType.extract);
        userMsg.setUid(uid);
        List<UserMsg.UserMsgItem> contentList = new ArrayList<>();
        contentList.add(new UserMsg.UserMsgItem("提现金额", money.toString() + "元"));
        contentList.add(new UserMsg.UserMsgItem("提现状态", "提现成功"));
        userMsg.setContentList(contentList);
        return userMsg;
    }
 
    /**
     * @return com.yeshi.makemoney.app.entity.msg.UserMsg
     * @author hxh
     * @description 提现失败
     * @date 16:02 2022/4/7
     * @param: uid
     * @param: money
     **/
 
    public static UserMsg createExtractFail(Long uid, BigDecimal money, String beizhu) {
        UserMsg userMsg = new UserMsg();
        userMsg.setType(UserMsgType.extract);
        userMsg.setUid(uid);
        List<UserMsg.UserMsgItem> contentList = new ArrayList<>();
        contentList.add(new UserMsg.UserMsgItem("提现金额", money.toString() + "元"));
        contentList.add(new UserMsg.UserMsgItem("提现状态", "提现失败"));
        if (!StringUtil.isNullOrEmpty(beizhu)) {
            contentList.add(new UserMsg.UserMsgItem("备注", beizhu));
        }
        userMsg.setContentList(contentList);
        return userMsg;
    }
 
 
    /**
     * @return com.yeshi.makemoney.app.entity.msg.UserMsg
     * @author hxh
     * @description 创建系统消息
     * @date 16:02 2022/4/7
     * @param: uid
     * @param: reason
     * @param: operate
     **/
    public static UserMsg createSystem(Long uid, String reason, String operate) {
        UserMsg userMsg = new UserMsg();
        userMsg.setType(UserMsgType.system);
        userMsg.setUid(uid);
        List<UserMsg.UserMsgItem> contentList = new ArrayList<>();
        contentList.add(new UserMsg.UserMsgItem("事        由", reason));
        contentList.add(new UserMsg.UserMsgItem("处        理", operate));
        userMsg.setContentList(contentList);
        return userMsg;
    }
 
 
}