admin
2020-01-07 6fdcc0c26dd33e87a024a69ed635d9aedb59cad6
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/InviteController.java
@@ -15,6 +15,7 @@
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.user.ThreeSale;
import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
@@ -57,7 +58,7 @@
   private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
   /**
    * 站内信提醒队员添加微信号
    * 专属邀请码条件
    * 
    * @param acceptData
    * @param uid
@@ -65,15 +66,38 @@
    * @param out
    */
   @RequestMapping(value = "tailorCode")
   public void tailorCode(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
   public void tailorCode(WXMPAcceptData acceptData, String callback, Long uid, PrintWriter out) {
      if (uid == null) {
         out.print(JsonUtil.loadFalseResult("用户id缺失"));
         return;
      }
      JSONArray array1 = new JSONArray();
      array1.add("1.邀请码可帮助好友激活邀请功能;");
      array1.add("2.好友通过你的邀请码激活邀请功能后,将成为你的直接粉丝,未来产生的订单你都有奖金;");
      array1.add("3.邀请码具有唯一性。");
      JSONObject desc1 = new JSONObject();
      desc1.put("title", "邀请码的作用");
      desc1.put("content",array1);
      JSONArray array2 = new JSONArray();
      array2.add("1.你可以自由设置4~12位简单易记的邀请码;");
      array2.add("2.专属邀请码是对你和你的团队尊贵身份的彰显。");
      JSONObject desc2 = new JSONObject();
      desc2.put("title", "专属邀请码优势");
      desc2.put("content",array2);
      JSONArray array = new JSONArray();
      array.add(desc1);
      array.add(desc2);
      JSONObject data = new JSONObject();
      data.put("desc", array);
      data.put("num", threeSaleSerivce.countFirstTeam(uid, 1));
      data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT);
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -85,7 +109,7 @@
    * @param out
    */
   @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
   public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
   public void countMyTeam(WXMPAcceptData acceptData, long uid, PrintWriter out) {
      try {
         long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
         long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
@@ -145,7 +169,7 @@
    * @param out
    */
   @RequestMapping(value = "listMyTeam", method = RequestMethod.POST)
   public void listMyTeam(AcceptData acceptData, int page, long uid, int type, PrintWriter out) {
   public void listMyTeam(WXMPAcceptData acceptData, int page, long uid, int type, PrintWriter out) {
      if (type != 1 && type != 2) {
         out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
         return;
@@ -311,4 +335,63 @@
      result.put("list", resultArray);
      return result;
   }
   /**
    * 获取用户信息
    * @param acceptData
    * @param uid
    * @param out
    */
   @RequestMapping(value = "getBossInfo", method = RequestMethod.POST)
   public void getBossInfo(AcceptData acceptData, Long uid, PrintWriter out) {
      if (uid == null || uid <= 0) {
         out.print(JsonUtil.loadFalseResult("用户未登录"));
         return;
      }
      JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
      out.print(JsonUtil.loadTrueResult(bossData));
   }
   /**
    * 上级信息组织
    *
    * @param acceptData
    * @param uid
    * @param threeSale
    * @return
    */
   private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
      JSONObject bossData = new JSONObject();
      if (threeSale != null && threeSale.getBoss() != null) {
         UserInfo boss = threeSale.getBoss();
         bossData.put("hasBoss", true);
         bossData.put("inviteId", threeSale.getId());
         bossData.put("nickName", boss.getNickName());
         bossData.put("portrait", boss.getPortrait());
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
         Long createTime = threeSale.getCreateTime();
         Date inviteTime = new Date(createTime);
         UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
         if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
            bossData.put("weiXin", userInfoExtra.getWeiXin());
            bossData.put("weiXinState", 3);
            bossData.put("weiXinTip", "添加TA的微信,你可向TA学习如何通过板栗快省赚钱。");
         } else {
            if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
               bossData.put("weiXinState", 1);
               bossData.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
            } else {
               bossData.put("weiXinState", 2);
               bossData.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
            }
         }
         bossData.put("inviteTime", "你于 " + sdf.format(inviteTime) + "接受了TA的邀请");
      } else {
         bossData.put("hasBoss", false);
         bossData.put("helpLink", configService.get("invite_code_hlep_link"));
         bossData.put("weiXinTip", "恭喜你,我们的优质用户;\r\n你并没有邀请人,但你的邀请激活功能是被默认开启的;\r\n你拥有独特的无邀请人激活码。");
      }
      return bossData;
   }
}