yujian
2019-12-25 a3ead770c30b310b9b1b7e3786d5d847da540e55
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/InviteControllerV2.java
@@ -8,6 +8,7 @@
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -25,11 +26,17 @@
import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
import com.yeshi.fanli.entity.bus.user.WeiXinUser;
import com.yeshi.fanli.entity.system.BusinessSystem;
import com.yeshi.fanli.entity.system.SystemClientParams;
import com.yeshi.fanli.exception.user.UserAccountException;
import com.yeshi.fanli.exception.user.UserInfoExtraException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SpreadImgService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
import com.yeshi.fanli.service.inter.push.PushService;
import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
@@ -80,6 +87,17 @@
   @Resource
   private UserInviteSeparateService userInviteSeparateService;
   @Resource
   private SpreadImgService spreadImgService;
   @Resource
   private SpreadUserImgService spreadUserImgService;
   @Resource
   private SystemClientParamsService systemClientParamsService;
   /**
    * 邀请码验证
    * 
@@ -352,7 +370,7 @@
    */
   @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
   public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
      JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
      JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
      JSONObject resultData = new JSONObject();
      long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
@@ -405,6 +423,23 @@
   }
   /**
    * 获取用户信息
    * @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
@@ -412,7 +447,7 @@
    * @param threeSale
    * @return
    */
   private JSONObject getBossInfo(AcceptData acceptData, long uid, ThreeSale threeSale) {
   private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
      JSONObject bossData = new JSONObject();
      if (threeSale != null && threeSale.getBoss() != null) {
         UserInfo boss = threeSale.getBoss();
@@ -543,4 +578,53 @@
         out.print(JsonUtil.loadFalseResult("提醒失败"));
      }
   }
   @RequestSerializableByKey(key = "'getInviteImgs-'+#uid")
   @RequestMapping(value = "/getInviteImgs", method = RequestMethod.POST)
   public void getInviteImgs(AcceptData acceptData, Long uid, Integer page, PrintWriter out, HttpServletRequest request) {
      if (uid == null || uid <= 0) {
         out.print(JsonUtil.loadFalseResult("用户未登录"));
         return;
      }
      if (page == null || page < 1)
         page = 1;
      try {
         String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
         if (StringUtil.isNullOrEmpty(inviteCode)) {
            out.print(JsonUtil.loadFalseResult("邀请码未激活"));
            return;
         }
         int count = 3;
         if (page > 1)
            count = Integer.MAX_VALUE;
         // 邀请图
         List<String> imgList = spreadUserImgService.getUserSpreadImgToPage(uid, page, count, request);
         // 邀请规则
         BusinessSystem system = new BusinessSystem();
         system.setId(4L);
         system.setPlatform(1);
         system.setCreatetime(java.lang.System.currentTimeMillis());
         SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, "inviteRules");
         JSONObject data = new JSONObject();
         data.put("count", spreadImgService.countAll());
         data.put("inviteCode", inviteCode);
         data.put("helpLink", configService.get("invite_help_link"));
         data.put("inviteRules",  values.getValue().replace("\n", "<br><br>"));
         data.put("imgUrlList", JsonUtil.getSimpleGsonWithDate().toJson(imgList));
         data.put("inviteLink", "http://a.app.qq.com/o/simple.jsp?pkgname=com.yeshi.ec.rebate");
         out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
      } catch (Exception e) {
         LogHelper.errorDetailInfo(e);
         out.print(JsonUtil.loadFalseResult("邀请信息获取失败"));
      }
   }
}