admin
2019-07-18 8579b9ea8205a2bcea72d2c9a843fdad1ed2e665
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package com.yeshi.fanli.util.factory.msg;
 
import java.util.Date;
 
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail.MsgTypeAccountTypeEnum;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.util.StringUtil;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
public class MsgAccountDetailFactory {
    public final static int TYPE_WX = 1;// 微信
    public final static int TYPE_TB = 2;// 淘宝
    public final static int TYPE_PHONE = 3;// 电话
 
    /**
     * 账号绑定成功
     * 
     * @param uid
     * @param type
     * @return
     */
    public static MsgAccountDetail createBindingAccount(Long uid, int type) {
        String msg = "";
        if (type == TYPE_PHONE) {
            msg = "<highlight>恭喜你手机号绑定成功</highlight>";
        } else if (type == TYPE_TB) {
            msg = "<highlight>恭喜你淘宝绑定成功</highlight>";
        } else if (type == TYPE_WX) {
            msg = "<highlight>恭喜你微信绑定成功</highlight>";
        }
        if (StringUtil.isNullOrEmpty(msg))
            return null;
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg);
        detail.setTitle("绑定账号");
        detail.setType(MsgTypeAccountTypeEnum.bingding);
        detail.setUser(new UserInfo(uid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
    /**
     * 账号解绑成功
     * 
     * @param uid
     * @param type
     * @return
     */
    public static MsgAccountDetail createUnBindingAccount(Long uid, int type) {
        String msg = "";
        if (type == TYPE_PHONE) {
            msg = "<highlight>手机号解绑成功</highlight>";
        } else if (type == TYPE_TB) {
            msg = "<highlight>淘宝解绑成功</highlight>";
        } else if (type == TYPE_WX) {
            msg = "<highlight>微信解绑成功</highlight>";
        }
        if (StringUtil.isNullOrEmpty(msg))
            return null;
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg);
        detail.setTitle("解绑账号");
        detail.setType(MsgTypeAccountTypeEnum.cancelBinding);
        detail.setUser(new UserInfo(uid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
    /**
     * 账号更换成功
     * 
     * @param uid
     * @param type
     * @return
     */
    public static MsgAccountDetail createChangeBindingAccount(Long uid, int type) {
        String msg = "";
        if (type == TYPE_PHONE) {
            msg = "<highlight>手机号更换绑定成功</highlight>";
        } else if (type == TYPE_TB) {
            msg = "<highlight>淘宝更换绑定成功</highlight>";
        } else if (type == TYPE_WX) {
            msg = "<highlight>微信更换绑定成功</highlight>";
        }
        if (StringUtil.isNullOrEmpty(msg))
            return null;
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg);
        detail.setTitle("更换绑定账号");
        detail.setType(MsgTypeAccountTypeEnum.bingdingChange);
        detail.setUser(new UserInfo(uid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
    /**
     * 账号打通
     * 
     * @param mainUid
     * @param lessUid
     * @return
     */
    public static MsgAccountDetail createConnectAccount(Long mainUid, Long lessUid) {
        if (mainUid == null || lessUid == null)
            return null;
        String msg = String.format("恭喜你账号合并成功,由“<highlight>%s</highlight>”合并到“<highlight>%s</highlight>”", lessUid + "",
                mainUid + "");
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg);
        detail.setTitle("账号合并");
        detail.setType(MsgTypeAccountTypeEnum.connect);
        detail.setUser(new UserInfo(mainUid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
    // 账号等级
    public static MsgAccountDetail createUserRank(Long uid, String orderType, int orderCount, String rankName) {
        if (uid == null || rankName == null)
            return null;
 
        String msg = String.format(
                "恭喜你,上月<highlight>%s</highlight>订单达到<highlight>%s</highlight>单,已为你升级为<highlight>%s</highlight>用户,将会获得对应的福利和特权。",
                orderType, orderCount + "", rankName);
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg);
        detail.setTitle("账号等级");
        detail.setType(MsgTypeAccountTypeEnum.level);
        detail.setUser(new UserInfo(uid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
    // 淘宝授权失败
    public static MsgAccountDetail createTaoBaoAuthFail(Long uid, String taoBaoNickName, String reason) {
        if (uid == null || reason == null)
            return null;
 
        JSONArray msg = new JSONArray();
        JSONObject item = new JSONObject();
        item.put("name", "账号");
        item.put("content", String.format("淘宝昵称[%s]", taoBaoNickName));
        msg.add(item);
 
        item = new JSONObject();
        item.put("name", "原因");
        item.put("content", reason);
        msg.add(item);
 
        MsgAccountDetail detail = new MsgAccountDetail();
        detail.setBeiZhu("无");
        detail.setContent(msg.toString());
        detail.setTitle("淘宝账号授权失败");
        detail.setType(MsgTypeAccountTypeEnum.taoBaoAuthFail);
        detail.setUser(new UserInfo(uid));
        detail.setCreateTime(new Date());
        detail.setRead(false);
        return detail;
    }
 
}