yujian
2019-09-03 d1dccd08a249b830a95eeeb04af25f87d5c056be
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -27,6 +27,7 @@
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;
@@ -49,6 +50,9 @@
   
   @Resource
   private ThreeSaleSerivce threeSaleSerivce;
   @Resource
   private UserInfoService userInfoService;
   
   @Resource
   private UserInfoExtraService userInfoExtraService;
@@ -348,6 +352,12 @@
         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不存在"));
@@ -355,9 +365,11 @@
      } 
      
      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(); // 提醒下级
      } 
      
@@ -366,22 +378,57 @@
         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 {
         // TODO版本区分
         List<String> listIOS = new ArrayList<String>();
         List<String> listAndroid = new ArrayList<String>();
         pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
         
//         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);
         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;
      }
   }
}