| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | 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.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | /**
|
| | | * 邀请码验证
|
| | |
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null)
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | |
| | |
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | | if (wxUnionId == null || wxUnionId.trim().length() == 0)
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | |
| | |
|
| | | String activeWX = StringUtil.Md5("activeWX:" + weiXinUser.getUnionid());
|
| | | redisManager.cacheCommonString(activeWX, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
|
| | | |
| | |
|
| | | // 邀请关系用户信息
|
| | | UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, wxUnionId);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("nickName", userInfo.getNickName());
|
| | | data.put("portrait", userInfo.getPortrait());
|
| | |
| | |
|
| | | /**
|
| | | * 微信激活
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param key 验证返回的key
|
| | | * @param key
|
| | | * 验证返回的key
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "'activeInviteWX-'+#uid")
|
| | |
| | | String value = redisManager.getCommonString(key);
|
| | | if (StringUtil.isNullOrEmpty(value))
|
| | | throw new UserAccountException(1, "微信授权失效");
|
| | | |
| | |
|
| | | WeiXinUser weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class);
|
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(1, "微信授权失效");
|
| | | |
| | |
|
| | | userInfoExtraService.activeInviteWX(uid, weiXinUser);
|
| | | // 删除缓存
|
| | | redisManager.removeCommonString(key);
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult("邀请码激活成功"));
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 用户队员列表查询 1.5.3查询有效队员
|
| | | *
|
| | |
| | | count = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | }
|
| | |
|
| | | boolean needVIPInfo = false;
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | needVIPInfo = true;
|
| | |
|
| | | // 组织数据
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type);
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type,needVIPInfo);
|
| | |
|
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | |
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type) {
|
| | | private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
|
| | | JSONObject result = new JSONObject();
|
| | | JSONArray resultArray = new JSONArray();
|
| | |
|
| | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
|
| | |
|
| | | List<Long> workerIdList = new ArrayList<>();
|
| | | Map<Long, Boolean> vipMap = null;
|
| | | if (needVipInfo) {
|
| | | for (ThreeSale threeSale : list)
|
| | | workerIdList.add(threeSale.getWorker().getId());
|
| | | if (workerIdList.size() > 0)
|
| | | vipMap = userVIPInfoService.listByUids(workerIdList);
|
| | | }
|
| | | for (ThreeSale threeSale : list) {
|
| | | UserInfo worker = threeSale.getWorker();
|
| | | if (worker == null) {
|
| | |
| | |
|
| | | Date inviteTime = new Date(threeSale.getCreateTime());
|
| | | object.put("inviteTime", format.format(inviteTime) + " 加入");
|
| | | // 添加是否为VIP
|
| | | if (vipMap != null && vipMap.get(worker.getId()) != null)
|
| | | object.put("vip", vipMap.get(worker.getId()));
|
| | |
|
| | | String fontColor1 = "#888888";
|
| | | JSONArray array = new JSONArray();
|