| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteSeparateService userInviteSeparateService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | | |
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | | @Resource
|
| | | private PushService pushService;
|
| | | |
| | | @Resource
|
| | | private UserSystemMsgService userSystemMsgService;
|
| | |
|
| | | /**
|
| | | * 专属邀请码条件
|
| | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("desc", array);
|
| | | data.put("num", threeSaleSerivce.countFirstTeam(uid, 1));
|
| | | data.put("num", threeSaleSerivce.countFirstTeam(uid));
|
| | | data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
|
| | | public void countMyTeam(WXMPAcceptData acceptData, long uid, PrintWriter out) {
|
| | | try {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid);
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid);
|
| | | JSONObject bossData = new JSONObject();
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | |
| | | }
|
| | | resultData.put("helpLink", helpLink);
|
| | | resultData.put("firstTeam", firstTeam);
|
| | | resultData.put("firstTeamTotal", firstTeamTotal);
|
| | | resultData.put("firstTeamTotal", firstTeam);
|
| | | resultData.put("secondTeam", secondTeam);
|
| | | resultData.put("secondTeamTotal", secondTeamTotal);
|
| | | resultData.put("secondTeamTotal", secondTeam);
|
| | | resultData.put("boss", bossData);
|
| | |
|
| | | boolean hasCode = false;
|
| | |
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listMyTeam", method = RequestMethod.POST)
|
| | | @RequestMapping(value = "listMyTeam")
|
| | | public void listMyTeam(WXMPAcceptData acceptData, int page, long uid, int type, PrintWriter out) {
|
| | | if (type != 1 && type != 2) {
|
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | |
| | | long count = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
|
| | | count = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countFirstTeam(uid);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
|
| | | count = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countSecondTeam(uid);
|
| | | }
|
| | |
|
| | | boolean needVIPInfo = false;
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | needVIPInfo = true;
|
| | | boolean needVIPInfo = true;
|
| | |
|
| | | // 组织数据
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type, needVIPInfo);
|
| | |
| | | // 添加是否为VIP
|
| | | if (vipMap != null && vipMap.get(worker.getId()) != null) {
|
| | | object.put("vip", vipMap.get(worker.getId()));
|
| | | if (vipMap.get(worker.getId())) {
|
| | | UserInviteSeparate separate = userInviteSeparateService.selectByWorkerIdAndBossId(worker.getId(),
|
| | | uid);
|
| | | if (separate != null && separate.getEndTime() != null) {
|
| | | try {
|
| | |
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", "#888888");
|
| | | contentJson1.put("content", "将于");
|
| | |
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", "#F14242");
|
| | | contentJson2.put("content", DateUtil.dateDiff4(new Date(), separate.getEndTime()));
|
| | |
|
| | | JSONObject contentJson3 = new JSONObject();
|
| | | contentJson3.put("color", "#888888");
|
| | | contentJson3.put("content", "后脱离邀请关系");
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | array.add(contentJson1);
|
| | | array.add(contentJson2);
|
| | | array.add(contentJson3);
|
| | | object.put("vipBreakTime", array);
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | String fontColor1 = "#888888";
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBossInfo", method = RequestMethod.POST)
|
| | | public void getBossInfo(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | public void getBossInfo(WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 站内信提醒队员添加微信号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "remindBossAddWX")
|
| | | public void remindTeam(WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("传递参数缺失"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户信息不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(uid);
|
| | | if (threeSale == null) {
|
| | | out.print(JsonUtil.loadFalseResult("没有邀请人"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Long remindId = null;
|
| | | boolean remindBoss = true;
|
| | | if (uid.longValue() == threeSale.getWorker().getId().longValue()) {
|
| | | remindId = threeSale.getBoss().getId(); // 提醒上级
|
| | | } else if (uid.longValue() == threeSale.getBoss().getId().longValue()) {
|
| | | remindBoss = false;
|
| | | remindId = threeSale.getWorker().getId(); // 提醒下级
|
| | | }
|
| | |
|
| | | if (remindId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("信息验证未通过"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Long bossId = null;
|
| | | Long workerId = null;
|
| | | String title = "粉丝提醒消息";
|
| | | String content = "";
|
| | | if (remindBoss) {
|
| | | // 提示队长
|
| | | bossId = remindId;
|
| | | workerId = uid;
|
| | | content = "你的直接粉丝" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系和学习省钱技巧,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | } else {
|
| | | // 提示队员
|
| | | bossId = uid;
|
| | | workerId = remindId;
|
| | | content = "你的邀请人" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系帮助你更好的省钱,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | }
|
| | |
|
| | | try {
|
| | | List<String> listIOS = new ArrayList<String>();
|
| | | List<String> listAndroid = new ArrayList<String>();
|
| | | pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
|
| | |
|
| | | userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content,
|
| | | UserSystemMsg.TIME_TAG_COMMON, null);
|
| | |
|
| | | ThreeSaleExtraInfo newInfo = new ThreeSaleExtraInfo();
|
| | | if (remindBoss) {
|
| | | newInfo.setRemindBoss(1);
|
| | | } else {
|
| | | newInfo.setRemindWorker(1);
|
| | | }
|
| | |
|
| | | ThreeSaleExtraInfo threeExtra = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(bossId, workerId);
|
| | | if (threeExtra != null) {
|
| | | newInfo.setId(threeExtra.getId());
|
| | | newInfo.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(newInfo);
|
| | | } else {
|
| | | newInfo.setBoss(new UserInfo(bossId));
|
| | | newInfo.setWorker(new UserInfo(workerId));
|
| | | newInfo.setCreateTime(new Date());
|
| | | newInfo.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.insertSelective(newInfo);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("weiXinState", 2);
|
| | | data.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult("提醒失败"));
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 上级信息组织
|
| | | *
|
| | | * @param acceptData
|