admin
2021-01-15 5405154d6979f1b50ce2d881bb164b1acca80b6d
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
package com.ks.daylucky.util.factory.vo;
 
import com.ks.daylucky.pojo.DO.UserMsg;
import com.ks.daylucky.pojo.DTO.msg.LuckyMsgContent;
import com.ks.daylucky.pojo.VO.UserMsgContentVO;
import com.ks.daylucky.pojo.VO.UserMsgVO;
import com.ks.daylucky.pojo.VO.common.JumpDetailVO;
import net.sf.json.JSONObject;
 
import java.util.ArrayList;
import java.util.List;
 
public class UserMsgVOFactory {
 
    public static UserMsgVO create(UserMsg msg) {
        UserMsgVO vo = new UserMsgVO();
        vo.setId(msg.getId());
        vo.setIcon(msg.getMsgType().getIcon());
        vo.setName(msg.getMsgType().getName());
        vo.setTime(msg.getCreateTime());
        if (msg.getMsgType() == UserMsg.UserMsgType.lucky) {
            vo.setContentList(create(msg.getLuckyMsgContent()));
        }
        return vo;
    }
 
    private static String getDateNumber(String dateNumber) {
        StringBuilder builder = new StringBuilder();
        builder.append("<div style=\"display: flex;justify-content: space-between;\">");
        builder.append("<span>" + dateNumber + "</span>");
        builder.append("<a style='color:#theme'>查看详情</a>");
        builder.append("</div>");
        return builder.toString();
    }
 
    private static List<UserMsgContentVO> create(LuckyMsgContent luckyMsgContent) {
        LuckyMsgContent.LuckyMsgType luckyMsgType = luckyMsgContent.getLuckyMsgType();
        List<UserMsgContentVO> voList = new ArrayList<>();
        JSONObject params = new JSONObject();
        params.put("url", "/pages/activity-detail/activity-detail?id=" + luckyMsgContent.getActivityId());
        voList.add(new UserMsgContentVO("活动期号", getDateNumber(luckyMsgContent.getDateNumber()), new JumpDetailVO(JumpDetailVO.JumpType.page, null, params)));
 
        if (luckyMsgType == LuckyMsgContent.LuckyMsgType.joinSuccess) {
            voList.add(new UserMsgContentVO("状态", "参与成功"));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.receiveOutDate) {
            voList.add(new UserMsgContentVO("领取状态", luckyMsgContent.getReceiveState()));
            voList.add(new UserMsgContentVO("奖品权益", luckyMsgContent.getOutDateAwardState()));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.assistAndJoin) {
            voList.add(new UserMsgContentVO("助力状态", "<div style='display:flex; align-items: center;'>助力好友<img style='width: 48rpx;height: 48rpx;border-radius: 50%;' src='" + luckyMsgContent.getAssistUser().getPortrait() + "' />成功参与了抽奖</div>"));
            voList.add(new UserMsgContentVO("幸运券数", String.format("+%s张", luckyMsgContent.getWeight())));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.assist) {
            voList.add(new UserMsgContentVO("助力状态", "<div style='display:flex; align-items: center;'>好友<img style='width: 48rpx;height: 48rpx;border-radius: 50%;' src='" + luckyMsgContent.getAssistUser().getPortrait() + "' />助力成功</div>"));
            voList.add(new UserMsgContentVO("幸运券数", String.format("+%s张", luckyMsgContent.getWeight())));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.openFail) {
            voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState()));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.notDrawn) {
            voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState()));
            voList.add(new UserMsgContentVO("中奖状态", luckyMsgContent.getDrawnState()));
        } else if (luckyMsgType == LuckyMsgContent.LuckyMsgType.drawn) {
            voList.add(new UserMsgContentVO("开奖状态", luckyMsgContent.getOpenState()));
            voList.add(new UserMsgContentVO("中奖状态", luckyMsgContent.getDrawnState()));
            voList.add(new UserMsgContentVO("奖    品", luckyMsgContent.getAwardName()));
        }
 
        voList.add(new UserMsgContentVO("备注", luckyMsgContent.getRemarks()));
        return voList;
    }
 
 
}