admin
2018-12-22 93c629bfb624e1e88875adb8866e0552b0f36c31
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
package com.yeshi.fanli.controller.client;
 
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.JsonUtil;
 
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.admin.InviteGetMoney;
import com.yeshi.fanli.entity.system.System;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.exception.NotExistObjectException;
import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.user.QrCodeService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.UserRankingsService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
/**
 * 
 * 类说明: 前端客户端所需接口
 * 
 * @author mawurui
 * @createTime 2018年4月2日 上午9:39:30
 * @version /test/invite
 */
@Controller
@RequestMapping("api/v1/invite")
public class InviteGetMoneyController {
 
    @Resource
    private InviteGetMoneyService inviteGetMoneyService;
 
    @Resource
    private SystemClientParamsService systemClientParamsService;
 
    @Resource
    private QrCodeService qrCodeService;
 
    @Resource
    private SpreadUserImgService spreadUserImgService;
 
    @Resource
    private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
 
    @Resource
    private UserRankingsService userRankingsService;
 
    @RequestMapping(value = "/inviteGetMoney", method = RequestMethod.POST)
    public void everyDayTaskList(AcceptData acceptData, int pageIndex, PrintWriter out, String uid)
            throws NotExistObjectException {
        // 查询商品总数
        Integer totalCount = 0;
        int totalPage = totalCount % Constant.PAGE_SIZE == 0 ? totalCount / Constant.PAGE_SIZE
                : totalCount / Constant.PAGE_SIZE + 1;
        PageEntity pageEntity = new PageEntity(pageIndex, Constant.PAGE_SIZE, totalCount, totalPage);
 
        /*
         * // 分页查询邀请提成榜 List<InviteGetMoney> inviteGetMoneyList =
         * inviteGetMoneyService.inviteGetMoneyList(pageIndex - 1, "");
         * 
         * // 名字*处理 for (InviteGetMoney inviteGetMoney : inviteGetMoneyList) {
         * 
         * String name = inviteGetMoney.getName(); if (name != null) { if
         * (name.length() > 2) { name = Utils.getStarString(name, 1,
         * name.length() - 1); } else { name = name.substring(0, 1) + "**" +
         * name.substring(name.length() - 1); } } inviteGetMoney.setName(name);
         * inviteGetMoney.setRankIcon(UserUtil.getRankIcon(3)); }
         */
 
        List<InviteGetMoney> inviteGetMoneyList = userRankingsService.getRank(0, 5);
 
        JSONObject data = new JSONObject();
        data.put("pageEntity", JsonUtil.getSimpleGsonWithDate().toJson(pageEntity));
        data.put("everyDayTaskList", new JSONArray());
        data.put("inviteGetMoneyList", JsonUtil.getSimpleGsonWithDate().toJson(inviteGetMoneyList));
        if (uid.equals("0") || uid == null) {
            data.put("myTeam", "---");
            data.put("moneyToday", "---");
            data.put("moneyMonth", "---");
            data.put("moneyLastMonth", "---");
        } else {
            // 我的队员
            int myFirstTeamCount = inviteGetMoneyService.myFirstTeamCount(uid);
            int mySecondTeamCount = inviteGetMoneyService.mySecondTeamCount(uid);
            int myTeamCount = myFirstTeamCount + mySecondTeamCount;
            data.put("myTeam", myTeamCount);
            // 今日 本月预估收益
            BigDecimal moneyToday = inviteGetMoneyService.getMoneyToday(uid + "");
            if (moneyToday == null) {
                moneyToday = new BigDecimal(0);
            }
            BigDecimal moneyMonth = inviteGetMoneyService.getMoneyMonth(uid + "");
            if (moneyMonth == null) {
                moneyMonth = new BigDecimal(0);
            }
 
            BigDecimal moneyLastMonth = inviteGetMoneyService.getMoneyLastMonth(uid + "");
 
            data.put("moneyToday", moneyToday.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyMonth", moneyMonth.setScale(2, BigDecimal.ROUND_DOWN).toString());
            data.put("moneyLastMonth", moneyLastMonth.toString());
        }
 
        // 活动规则
        String key = "activityRules"; // key值
        com.yeshi.fanli.entity.system.System system = new System();
        system.setCreatetime(java.lang.System.currentTimeMillis());
        system.setPlatform(1);
        system.setId(4L);
        SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key);
        // 转换换行符 给前端
        String valueN = values.getValue();
        String valueBr = valueN.replace("\n", "<br><br>");
 
        data.put("activityRules", valueBr);
        data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
                Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
        out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
    }
 
    /**
     * 
     * 方法说明: 分享好友邀请图片
     * 
     * @author mawurui createTime 2018年4月3日 下午3:49:05
     * @param pageIndex
     * @param out
     * @param uid
     * @throws NotExistObjectException
     * @throws IOException
     */
    @RequestMapping(value = "/listInviteFriendImg", method = RequestMethod.POST)
    public void listInviteFriendImg(AcceptData acceptData, PrintWriter out, Long uid)
            throws NotExistObjectException, IOException {
        JSONObject data = new JSONObject();
        if (uid != null && !uid.equals("0")) {
            List<String> imgList = spreadUserImgService.getUserSpreadImg(uid);
            data.put("imgUrlList", JsonUtil.getSimpleGsonWithDate().toJson(imgList));
        }
 
        // 邀请规则
        String key = "inviteRules"; // key值
        com.yeshi.fanli.entity.system.System system = new System();
        system.setCreatetime(java.lang.System.currentTimeMillis());
        system.setPlatform(1);
        system.setId(4L);
        SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, key);
        // 转换换行符 给前端
        String valueN = values.getValue();
        String valueBr = valueN.replace("\n", "<br><br>");
 
        data.put("inviteRules", valueBr);
        out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
    }
}