| | |
| | | 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.UserInfoService;
|
| | | 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 ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("nickName", userInfo.getNickName());
|
| | | data.put("portrait", userInfo.getPortrait());
|
| | | data.put("tips", "确认要成为TA的一级队员吗?邀请关系一旦建立不可更改。");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("nickName", userInfo.getNickName());
|
| | | data.put("portrait", userInfo.getPortrait());
|
| | | data.put("tips", "确认要成为TA的一级队员吗?邀请关系一旦建立不可更改。");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | |
|
| | | // 组织数据
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type);
|
| | | resultData.put("helpLink", configService.get("team_help_url"));
|
| | |
|
| | | boolean hasCode = false;
|
| | | boolean bdWeiXin = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
|
| | | bdWeiXin = true;
|
| | | }
|
| | | |
| | | // 未激活邀请码
|
| | | if (!hasCode) {
|
| | | resultData.put("helpLinkActivate", configService.get("team_help_url"));
|
| | | resultData.put("tipCode", "激活邀请功能后才可以邀请队员,一级队员是由你直接邀请,二级队员是由你的一级队员邀请。\r\n邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | | |
| | | // 未添加微信号
|
| | | if (!bdWeiXin) {
|
| | | resultData.put("tipWeiXin", "添加微信号后,你的邀请人和一级队员可通过微信号与你建立联系;\r\n你也可以向邀请人学习或向一级队员教授赚钱技巧。");
|
| | | }
|
| | | resultData.put("bdWeiXin", bdWeiXin);
|
| | |
|
| | | // 安卓返回统计数据
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equalsIgnoreCase(platform)) {
|
| | | JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
|
| | | resultData.put("boss", bossData);
|
| | | resultData.put("firstTeam", threeSaleSerivce.countFirstTeam(uid, 1));
|
| | | resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
|
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | | boolean hasCode = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | | resultData.put("hasTeam", count > 0? true:false);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | |
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
|
| | | JSONObject resultData = new JSONObject();
|
| | | |
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | resultData.put("boss", bossData);
|
| | | resultData.put("helpLink", configService.get("team_help_url"));
|
| | | resultData.put("firstTeam", threeSaleSerivce.countFirstTeam(uid, 1));
|
| | | resultData.put("firstTeam", firstTeam);
|
| | | resultData.put("firstTeamTotal", threeSaleSerivce.countFirstTeam(uid, null));
|
| | | resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
|
| | | resultData.put("secondTeamTotal", threeSaleSerivce.countSecondTeam(uid, null));
|
| | | |
| | | boolean hasTeam = true;
|
| | | if (firstTeam <= 0) {
|
| | | hasTeam = false;
|
| | | resultData.put("invitelink", configService.get("invite_activation_url"));
|
| | | }
|
| | | resultData.put("hasTeam", hasTeam);
|
| | | |
| | | boolean hasCode = false;
|
| | | boolean bdWeiXin = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
|
| | | bdWeiXin = true;
|
| | | }
|
| | | |
| | | // 未激活邀请码
|
| | | resultData.put("hasCode", hasCode);
|
| | | if (!hasCode) {
|
| | | List<String> tipCode = new ArrayList<String>();
|
| | | resultData.put("helpLinkActivate", configService.get("team_help_url"));
|
| | | tipCode.add("激活邀请功能后才可以邀请队员,一级队员是由你直接邀请,二级队员是由你的一级队员邀请。");
|
| | | tipCode.add("邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
|
| | | resultData.put("tipCode", tipCode);
|
| | | }
|
| | | |
| | | // 未添加微信号
|
| | | List<String> tipWeiXin = new ArrayList<String>();
|
| | | if (!bdWeiXin) {
|
| | | tipWeiXin.add("添加微信号后,你的邀请人和一级队员可通过微信号与你建立联系;");
|
| | | tipWeiXin.add("你也可以向邀请人学习或向一级队员教授赚钱技巧。");
|
| | | }
|
| | | resultData.put("tipWeiXin", tipWeiXin);
|
| | | resultData.put("tipWeiXinAdd", "添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。");
|
| | | resultData.put("bdWeiXin", bdWeiXin);
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | bossData.put("inviteTime", "你于 " + sdf.format(inviteTime) + "接受了TA的邀请");
|
| | | |
| | | } else {
|
| | | bossData.put("hasBoss", false);
|
| | | bossData.put("helpLink", configService.get("invite_code_hlep_link"));
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户信息不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | ThreeSale threeSale = threeSaleSerivce.selectByPrimaryKey(inviteId);
|
| | | if (threeSale == null) {
|
| | | out.print(JsonUtil.loadFalseResult("关系id不存在"));
|
| | |
| | | }
|
| | |
|
| | | 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(); // 提醒下级
|
| | | }
|
| | |
|
| | |
| | | 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, "", "", listIOS, listAndroid);
|
| | |
|
| | | userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.question,
|
| | | "", "", UserSystemMsg.TIME_TAG_EMERGENT, null);
|
| | | 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("提醒失败"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|