| | |
| | | import java.io.PrintWriter;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.dto.user.ThreeSaleFocusDTO;
|
| | | import com.yeshi.fanli.dto.vip.UserVIPLevel;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsgTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.TeamFansInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidNum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInviteValidRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.bus.user.invite.TeamDailyRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TeamUserLevelStatistic;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | |
| | | 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.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInviteSeparateService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.TeamDailyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService;
|
| | | 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.invite.UserInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidNumService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteValidRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.TearcherService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.order.OrderRankingVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | | @Resource
|
| | | private UserInviteSeparateService userInviteSeparateService;
|
| | |
|
| | | @Resource
|
| | | private SpreadImgService spreadImgService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteService userInviteService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInviteValidRecordService userInviteValidRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderCountService commonOrderCountService;
|
| | |
|
| | | @Resource
|
| | | private TeamFansInfoService teamFansInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | |
|
| | | @Resource
|
| | | private TearcherService tearcherService;
|
| | |
|
| | | @Resource
|
| | | private TeamUserLevelStatisticService teamUserLevelStatisticService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | |
|
| | | @Resource
|
| | | private TeamDailyRecordService teamDailyRecordService;
|
| | |
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 邀请码验证
|
| | | *
|
| | |
| | | if (wxUnionId == null || wxUnionId.trim().length() == 0)
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | |
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("activeWX:" + weiXinUser.getUnionid()));
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
|
| | | StringUtil.Md5("activeWX:" + weiXinUser.getUnionid()));
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
|
| | |
|
| | | // 邀请关系用户信息
|
| | |
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param key
|
| | | * 验证返回的key
|
| | | * @param key 验证返回的key
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "'activeInviteWX-'+#uid")
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员列表查询 1.5.3查询有效队员
|
| | | * 用户队员列表查询
|
| | | *
|
| | | * @param acceptData
|
| | | * @param id
|
| | |
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | getMyTeamNew(acceptData, page, uid, type, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
|
| | | count = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countFirstTeam(uid);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
|
| | | count = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countSecondTeam(uid);
|
| | | }
|
| | |
|
| | | boolean needVIPInfo = false;
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | needVIPInfo = true;
|
| | | // 数据加工
|
| | | JSONArray array = null;
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | array = organizeTeamNew(acceptData, listTeam, uid, type, true);
|
| | | } else {
|
| | | boolean needVIPInfo = false;
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | needVIPInfo = true;
|
| | | array = organizeTeam(listTeam, uid, type, needVIPInfo);
|
| | | }
|
| | |
|
| | | // 组织数据
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type,needVIPInfo);
|
| | | JSONObject result = new JSONObject();
|
| | | result.put("count", count);
|
| | | result.put("list", array);
|
| | |
|
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | | boolean hasCode = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | | resultData.put("hasTeam", count > 0 ? true : false);
|
| | | result.put("hasCode", hasCode);
|
| | | result.put("hasTeam", count > 0 ? true : false);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @param type
|
| | | * @return
|
| | | */
|
| | | private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
|
| | | JSONObject result = new JSONObject();
|
| | | private JSONArray organizeTeam(List<ThreeSale> list, Long uid, int type, boolean needVipInfo) {
|
| | | JSONArray resultArray = new JSONArray();
|
| | |
|
| | | Date todayTime = new Date();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | |
| | | // 添加是否为VIP
|
| | | if (vipMap != null && vipMap.get(worker.getId()) != null) {
|
| | | object.put("vip", vipMap.get(worker.getId()));
|
| | | if (vipMap.get(worker.getId())) {
|
| | | UserInviteSeparate separate = userInviteSeparateService.selectByWorkerIdAndBossId(worker.getId(), uid);
|
| | | if (separate != null && separate.getEndTime() != null) {
|
| | | try {
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", "#888888");
|
| | | contentJson1.put("content", "将于");
|
| | |
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", "#F14242");
|
| | | contentJson2.put("content", DateUtil.dateDiff4(new Date(), separate.getEndTime()));
|
| | |
|
| | | JSONObject contentJson3 = new JSONObject();
|
| | | contentJson3.put("color", "#888888");
|
| | | contentJson3.put("content", "后脱离邀请关系");
|
| | | |
| | | JSONArray array = new JSONArray();
|
| | | array.add(contentJson1);
|
| | | array.add(contentJson2);
|
| | | array.add(contentJson3);
|
| | | object.put("vipBreakTime",array);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | String fontColor1 = "#888888";
|
| | | JSONArray array = new JSONArray();
|
| | |
| | | } else {
|
| | | if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
|
| | | object.put("weiXinState", 1);
|
| | | object.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
|
| | | object.put("weiXinTip", "点击提醒,系统会发送一封站内信,提醒其添加微信号。");
|
| | | } else {
|
| | | object.put("weiXinState", 2);
|
| | | object.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | |
| | | object.put("recentMsg", array);
|
| | | resultArray.add(object);
|
| | | }
|
| | |
|
| | | result.put("count", count);
|
| | | result.put("list", resultArray);
|
| | | return result;
|
| | | return resultArray;
|
| | | }
|
| | |
|
| | | |
| | | private void getMyTeamNew(AcceptData acceptData, long page, long uid, int type, PrintWriter out) {
|
| | | if (type != 1 && type != 2) {
|
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeamByUndeleted((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countFirstTeamByUndeleted(uid);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeamByUndeleted((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | count = threeSaleSerivce.countSecondTeamByUndeleted(uid);
|
| | | }
|
| | |
|
| | | JSONObject result = new JSONObject();
|
| | | result.put("count", count);
|
| | | result.put("list", organizeTeamNew(count, listTeam, uid, type, true));
|
| | | |
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | | boolean hasCode = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | }
|
| | | result.put("hasCode", hasCode);
|
| | | result.put("hasTeam", count > 0 ? true : false);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | | |
| | | /**
|
| | | * 加工数据
|
| | | * 加工数据
|
| | | * |
| | | * @param count
|
| | | * @param list
|
| | | * @param uid
|
| | | * @param type 查询粉丝类型 1直接 2间接
|
| | | * @param type 查询粉丝类型 1直接 2间接
|
| | | * @param wxtip 是需要微信提示
|
| | | * @return
|
| | | */
|
| | | private JSONArray organizeTeamNew(long count, List<ThreeSale> list, Long uid, int type, boolean wxtip) {
|
| | | private JSONArray organizeTeamNew(AcceptData acceptData, List<ThreeSale> list, Long uid, int type, boolean wxtip) {
|
| | | JSONArray resultArray = new JSONArray();
|
| | | if (list == null || list.size() == 0) {
|
| | | return resultArray;
|
| | |
| | | for (ThreeSale threeSale : list) {
|
| | | listWid.add(threeSale.getWorker().getId());
|
| | | }
|
| | | |
| | |
|
| | | // 查询有效粉丝id
|
| | | int validType = UserInviteValidRecord.TYPE_TWO;
|
| | | if (type == 1) {
|
| | | validType = UserInviteValidRecord.TYPE_ONE;
|
| | | }
|
| | |
|
| | | List<Long> listVid = userInviteValidRecordService.getValidWorkerIdsByUid(uid, listWid, validType);
|
| | | |
| | |
|
| | | for (ThreeSale threeSale : list) {
|
| | | UserInfo worker = threeSale.getWorker();
|
| | | Long workerId = worker.getId();
|
| | |
|
| | | // 邀请状态
|
| | | Boolean state = threeSale.getState();
|
| | | if (type == 2) {
|
| | | if (state && threeSale.getStateSuper()) {
|
| | | state = true;
|
| | | } else {
|
| | | state = false;
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | // 邀请成功时间
|
| | | Long succeedTime = threeSale.getSucceedTime(); |
| | | Long succeedTime = threeSale.getSucceedTime();
|
| | | if (succeedTime == null) {
|
| | | succeedTime = threeSale.getCreateTime();
|
| | | }
|
| | | |
| | |
|
| | | // 有效粉丝
|
| | | boolean validFans = false; |
| | | if (state && listVid != null && listVid.size() > 0 && listVid.contains(workerId)) {
|
| | | boolean validFans = false;
|
| | | if (listVid != null && listVid.size() > 0 && listVid.contains(workerId)) {
|
| | | validFans = true;
|
| | | }
|
| | | |
| | |
|
| | | // 最近粉丝登录时间
|
| | | Date lastLoginTime = new Date(threeSale.getCreateTime());
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
|
| | | if (userInfoExtra != null && userInfoExtra.getActiveTime() != null) {
|
| | | lastLoginTime = userInfoExtra.getActiveTime();
|
| | | } |
| | | }
|
| | | JSONObject loginJson = new JSONObject();
|
| | | if (formatYears.format(todayTime).equals(formatYears.format(lastLoginTime))) {
|
| | | loginJson.put("content", "最近登录 " + sdf.format(lastLoginTime)); // 本年
|
| | |
| | | loginJson.put("content", "最近登录 " + format.format(lastLoginTime)); // 往年
|
| | | }
|
| | | loginJson.put("color", "#888888");
|
| | | |
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | array.add(loginJson);
|
| | |
|
| | | // 查询粉丝等级
|
| | | UserInviteLevelEnum level = null;
|
| | | UserLevelEnum level = null;
|
| | | UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(workerId);
|
| | | if (vipLevel != null) {
|
| | | if (vipLevel.getLevel() == UserVIPLevel.LEVEL_3) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | } else if (vipLevel.getLevel() == UserVIPLevel.LEVEL_7) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | } else if (vipLevel.getLevel() == UserVIPLevel.LEVEL_10) {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | }
|
| | | if (vipLevel != null && vipLevel.getLevel() != null) {
|
| | | level = UserLevelUtil.getByLevel(vipLevel.getLevel());
|
| | | }
|
| | | |
| | | if(level == null) {
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | level = UserInviteLevelEnum.noActive;
|
| | | } else {
|
| | | level = UserInviteLevelEnum.actived;
|
| | | }
|
| | | if (level == null) {
|
| | | level = UserLevelEnum.daRen;
|
| | | }
|
| | | |
| | | |
| | | level = UserLevelUtil.getShowLevel(level);
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("workerId", workerId);
|
| | | object.put("nickName", worker.getNickName());
|
| | | object.put("portrait", worker.getPortrait());
|
| | | object.put("inviteId", threeSale.getId());
|
| | | object.put("inviteTime", format.format(new Date(succeedTime)) + " 加入");
|
| | | object.put("state", state? 1 : 2);
|
| | | object.put("state", 1);
|
| | | object.put("recentMsg", array);
|
| | | object.put("level", level.name());
|
| | | object.put("validFans", validFans);
|
| | | |
| | | |
| | | // 判断是否存在脱离关系队员
|
| | | if (vipLevel != null && state) {
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserInviteSeparate separate = userInviteSeparateService.selectByWorkerIdAndBossId(workerId, bossId);
|
| | | if (separate != null && separate.getEndTime() != null) {
|
| | | try {
|
| | | JSONObject contentJson1 = new JSONObject();
|
| | | contentJson1.put("color", "#888888");
|
| | | contentJson1.put("content", "将于");
|
| | |
|
| | | String dateDiff = DateUtil.dateDiff4(new Date(), separate.getEndTime());
|
| | | JSONObject contentJson2 = new JSONObject();
|
| | | contentJson2.put("color", "#F14242");
|
| | | contentJson2.put("content", dateDiff);
|
| | |
|
| | | JSONObject contentJson3 = new JSONObject();
|
| | | contentJson3.put("color", "#888888");
|
| | | contentJson3.put("content", "后脱离邀请关系");
|
| | | |
| | | JSONArray vipBreak = new JSONArray();
|
| | | vipBreak.add(contentJson1);
|
| | | vipBreak.add(contentJson2);
|
| | | vipBreak.add(contentJson3);
|
| | | object.put("vipBreakTime",vipBreak);
|
| | | |
| | | List<String> tips = new ArrayList<String>();
|
| | | tips.add("于"+ TimeUtil.formatDateDot(vipLevel.getSuccessTime()) + "升级为" + level.getName());
|
| | | if (type == 1) {
|
| | | tips.add("你需要在"+ dateDiff +"内升级为会员,否则按照邀请规则TA将与你脱离邀请关系。");
|
| | | tips.add("赶快加油升级为会员吧!");
|
| | | } else {
|
| | | tips.add("你需要辅助TA的邀请人"+ threeSale.getBoss().getNickName()+ "在"+dateDiff+"内升级为会员,否则这位间接粉丝" +worker.getNickName()+"将与你脱离邀请关系。");
|
| | | tips.add("赶快帮助TA升级为会员吧!");
|
| | | }
|
| | | object.put("vipBreakTip",tips);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | if (wxtip && type == 1 && threeSale.getState() != null && threeSale.getState()) {
|
| | | if (wxtip) {
|
| | | // 一级队员 查询昵称备注
|
| | | String memoName = null;
|
| | | ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
|
| | |
| | | }
|
| | | }
|
| | | object.put("memoName", memoName);
|
| | | |
| | | // 添加微信信息
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | object.put("weiXin", userInfoExtra.getWeiXin());
|
| | | object.put("weiXinState", 3);
|
| | | object.put("weiXinTip", "添加TA的微信,你可教授TA如何通过板栗快省赚钱技巧。");
|
| | | } else {
|
| | | if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
|
| | | object.put("weiXinState", 1);
|
| | | object.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
|
| | |
|
| | | if (type == 1 && !VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | // 添加微信信息
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | object.put("weiXin", userInfoExtra.getWeiXin());
|
| | | object.put("weiXinState", 3);
|
| | | object.put("weiXinTip", "添加TA的微信,你可教授TA如何通过板栗快省赚钱技巧。");
|
| | | } else {
|
| | | object.put("weiXinState", 2);
|
| | | object.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | | if (!threeSaleExtraInfoSerivce.isRemindWorker(uid, workerId)) {
|
| | | object.put("weiXinState", 1);
|
| | | object.put("weiXinTip", "点击提醒,系统会发送一封站内信,提醒其添加微信号。");
|
| | | } else {
|
| | | object.put("weiXinState", 2);
|
| | | object.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | resultArray.add(object);
|
| | | }
|
| | | return resultArray;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 查看下级的直接粉丝
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid 当前UId
|
| | | * @param tid 下级UId
|
| | | * @param uid 当前UId
|
| | | * @param tid 下级UId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOthersTeam", method = RequestMethod.POST)
|
| | | public void getOthersTeam(AcceptData acceptData, long page, Long uid, Long tid, PrintWriter out) {
|
| | | public void getOthersTeam(AcceptData acceptData, long page, Long uid, Long tid, PrintWriter out) {
|
| | | if (tid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("传递参数不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<ThreeSale> listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, tid, 1);
|
| | | long count = threeSaleSerivce.countFirstTeam(tid, 1);
|
| | |
|
| | | List<ThreeSale> listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE,
|
| | | tid);
|
| | | long count = threeSaleSerivce.countFirstTeam(tid);
|
| | |
|
| | | JSONObject result = new JSONObject();
|
| | | result.put("count", count);
|
| | | result.put("list", organizeTeamNew(count, listTeam, tid, 1, false));
|
| | | result.put("list", organizeTeamNew(acceptData, listTeam, tid, 1, false));
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 用户队员统计- IOS
|
| | | *
|
| | |
| | | JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
|
| | | JSONObject resultData = new JSONObject();
|
| | |
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid);
|
| | | long countSecond = threeSaleSerivce.countSecondTeam(uid);
|
| | | resultData.put("boss", bossData);
|
| | | resultData.put("helpLink", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
|
| | | 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));
|
| | | resultData.put("firstTeamTotal", firstTeam);
|
| | | resultData.put("secondTeam", countSecond);
|
| | | resultData.put("secondTeamTotal", countSecond);
|
| | | resultData.put("helpLink", configService.get(ConfigKeyEnum.teamHelpUrl.getKey()));
|
| | |
|
| | | boolean hasTeam = true;
|
| | | if (firstTeam <= 0) {
|
| | |
| | |
|
| | | /**
|
| | | * 获取用户信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | |
| | | JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
|
| | | out.print(JsonUtil.loadTrueResult(bossData));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 上级信息组织
|
| | | *
|
| | |
| | | } else {
|
| | | if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
|
| | | bossData.put("weiXinState", 1);
|
| | | bossData.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
|
| | | bossData.put("weiXinTip", "点击提醒,系统会发送一封站内信,提醒其添加微信号。");
|
| | | } else {
|
| | | bossData.put("weiXinState", 2);
|
| | | bossData.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | |
| | | 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) {
|
| | | 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) |
| | | 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");
|
| | | |
| | | SystemClientParams values = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
|
| | | "inviteRules");
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", spreadImgService.countAll());
|
| | | data.put("inviteCode", inviteCode);
|
| | | data.put("helpLink", configService.get(ConfigKeyEnum.inviteHelpLink.getKey()));
|
| | | data.put("inviteRules", values.getValue().replace("\n", "<br><br>"));
|
| | | data.put("inviteRules", values.getValue().replace("\n", "<br><br>"));
|
| | | data.put("imgUrlList", JsonUtil.getSimpleGsonWithDate().toJson(imgList));
|
| | | data.put("inviteLink", Constant.YINGYONGBAO_LINK);
|
| | | out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
|
| | |
| | | out.print(JsonUtil.loadFalseResult("邀请信息获取失败"));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 站内信提醒队员添加微信号
|
| | | *
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("num", threeSaleSerivce.countFirstTeam(uid, 1));
|
| | | data.put("num", doneFirst);
|
| | | data.put("limit", Constant.INVITE_CODRE_TAILOR_LIMIT);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "remvoeBreak")
|
| | | public void remvoeBreak(String callback, AcceptData acceptData,Long inviteId, Long uid, Long tid, PrintWriter out) {
|
| | | if (uid == null || inviteId == null || tid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传输参数不完整"));
|
| | |
|
| | | /**
|
| | | * 用户队员列表查询
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMyTeamV2", method = RequestMethod.POST)
|
| | | public void getMyTeamV2(AcceptData acceptData, int page, long uid, int type, ThreeSaleFocusDTO focus,
|
| | | PrintWriter out) {
|
| | | if (type != 1 && type != 2) {
|
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | | }
|
| | | threeSaleSerivce.remvoeBreak(inviteId, uid, tid);
|
| | |
|
| | | long firstTeam = 0;
|
| | | long countSecond = 0;
|
| | | List<ThreeSale> listTeam = null;
|
| | | if (!existScreen(focus)) { // 普通查询
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | }
|
| | | firstTeam = threeSaleSerivce.countFirstTeam(uid);
|
| | | countSecond = threeSaleSerivce.countSecondTeam(uid);
|
| | | } else { // 筛选条件
|
| | | List<Long> listId = null;
|
| | | List<TeamFansInfo> listfocus = teamFansInfoService.query((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, type, uid, focus);
|
| | | if (listfocus != null && listfocus.size() > 0) {
|
| | | listId = new ArrayList<Long>();
|
| | | for (TeamFansInfo focusInfo : listfocus) {
|
| | | listId.add(focusInfo.getWorkerId());
|
| | | }
|
| | | }
|
| | | |
| | | if (listId != null && listId.size() > 0) {
|
| | | if (type == 1) {
|
| | | listTeam = threeSaleSerivce.listFirstTeam(0, Constant.PAGE_SIZE, uid, listId);
|
| | | } else if (type == 2) {
|
| | | listTeam = threeSaleSerivce.listSecondTeam(0, Constant.PAGE_SIZE, uid, listId);
|
| | | }
|
| | | }
|
| | | firstTeam = teamFansInfoService.count(1, uid, focus);
|
| | | countSecond = teamFansInfoService.count(2, uid, focus);
|
| | | }
|
| | | JSONArray array = organizeTeamNew(acceptData, listTeam, uid, type, true);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | long count = (type == 1) ? firstTeam : countSecond;
|
| | | |
| | | JSONObject result = new JSONObject();
|
| | | result.put("firstTeam", firstTeam);
|
| | | result.put("secondTeam", countSecond);
|
| | | result.put("count", count);
|
| | | result.put("list", array);
|
| | | |
| | | // 统计H5链接
|
| | | if (page == 1) {
|
| | | result.put("link", configService.get(ConfigKeyEnum.teamStatisticsLink.getKey()));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(result));
|
| | | }
|
| | | |
| | | /**
|
| | | * 验证是否存在筛选条件
|
| | | * @param focus
|
| | | * @return
|
| | | */
|
| | | private boolean existScreen(ThreeSaleFocusDTO focus) {
|
| | | if (focus.getStateValid() != null || focus.getTaobaoBind() != null || focus.getWeixinBind() != null
|
| | | || focus.getMinFansNum() != null || focus.getMinFansNum() != null
|
| | | || focus.getMinActiveTime() != null || focus.getMaxActiveTime() != null
|
| | | || focus.getMinIncome() != null || focus.getMaxIncome() != null |
| | | || focus.getMinJoinTime() != null || focus.getMaxJoinTime() != null |
| | | || !StringUtil.isNullOrEmpty(focus.getKey()) || !StringUtil.isNullOrEmpty(focus.getLevel()))
|
| | | return true;
|
| | | |
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员统计
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countMyTeamV2")
|
| | | public void countMyTeamV2(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | try {
|
| | | JSONObject bossObject = new JSONObject();
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(uid);
|
| | | if (threeSale == null) {
|
| | | bossObject.put("exist", false);
|
| | | bossObject.put("desc", "恭喜你!板栗快省优质用户;\r\n\r\n你并没有邀请人,但你的邀请能力默认是开启的;\r\n你拥有独特的无邀请人激活码。");
|
| | | } else {
|
| | | // 上级基本信息
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserInfo userInfo = userInfoService.selectByPKey(bossId);
|
| | | boolean phoneCopy = true;
|
| | | String phone = userInfo.getPhone();
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | phone = "";
|
| | | } else {
|
| | | if (!userCustomSettingsService.validateDisplayPhoneByUid(bossId)) {
|
| | | phoneCopy = false;
|
| | | phone = phone.substring(0, 7) + "****";
|
| | | }
|
| | | }
|
| | |
|
| | | // 微信号
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(bossId);
|
| | | if (extra != null) {
|
| | | bossObject.put("weixin", StringUtil.isNullOrEmpty(extra.getWeiXin()) ? "" : extra.getWeiXin());
|
| | | }
|
| | |
|
| | | // 当前等级
|
| | | UserLevelEnum level = null;
|
| | | UserVIPLevel vipLevel = userInviteService.getVIPLevelByUid(bossId);
|
| | | if (vipLevel != null && vipLevel.getLevel() != null) {
|
| | | level = UserLevelUtil.getByLevel(vipLevel.getLevel());
|
| | | }
|
| | | if (level == null) {
|
| | | level = UserLevelEnum.daRen;
|
| | | }
|
| | | level = UserLevelUtil.getShowLevel(level);
|
| | |
|
| | | bossObject.put("exist", true);
|
| | | bossObject.put("nickName", userInfo.getNickName());
|
| | | bossObject.put("portrait", userInfo.getPortrait());
|
| | | bossObject.put("phone", phone);
|
| | | bossObject.put("phoneCopy", phoneCopy);
|
| | | bossObject.put("level", level.name());
|
| | | }
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("boss", bossObject);
|
| | |
|
| | | TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
|
| | | if (tearcherInfo != null) {
|
| | | JSONObject tearcherObject = new JSONObject();
|
| | | tearcherObject.put("nickName", tearcherInfo.getNickName());
|
| | | tearcherObject.put("portrait", tearcherInfo.getPortrait());
|
| | | tearcherObject.put("phone", tearcherInfo.getPhone());
|
| | | tearcherObject.put("weixin", tearcherInfo.getWxID());
|
| | | tearcherObject.put("level", UserLevelEnum.tearcher);
|
| | | json.put("tearcher", tearcherObject);
|
| | | }
|
| | |
|
| | | JSONObject daren = new JSONObject();
|
| | | JSONObject highVIP = new JSONObject();
|
| | | JSONObject superVIP = new JSONObject();
|
| | |
|
| | | TeamUserLevelStatistic statistic = teamUserLevelStatisticService.selectByUid(uid);
|
| | | if (statistic == null) {
|
| | | daren.put("total", 0);
|
| | | highVIP.put("total", 0);
|
| | | superVIP.put("total", 0);
|
| | | } else {
|
| | | int totalDaren = statistic.getDaRenFirstCount() + statistic.getDaRenSecondCount()
|
| | | + statistic.getNormalFirstCount() + statistic.getNormalSecondCount();
|
| | | daren.put("total", totalDaren);
|
| | | highVIP.put("total", statistic.getHighFirstCount() + statistic.getHighSecondCount());
|
| | | superVIP.put("total", statistic.getSuperFirstCount() + statistic.getSuperSecondCount());
|
| | | }
|
| | | |
| | |
|
| | | int darenToday = 0;
|
| | | int highVIPToday = 0;
|
| | | int superVIPToday = 0;
|
| | | String createId = teamDailyRecordService.createId(uid, new Date());
|
| | | TeamDailyRecord record = teamDailyRecordService.getById(createId);
|
| | | if (record != null) {
|
| | | if (record.getFirstDaRen() != null) |
| | | darenToday += record.getFirstDaRen();
|
| | | if (record.getSecondDaRen() != null)
|
| | | darenToday += record.getSecondDaRen(); |
| | | if (record.getFirstHighVIP() != null)
|
| | | highVIPToday += record.getFirstHighVIP();
|
| | | if (record.getSecondHighVIP() != null)
|
| | | highVIPToday += record.getSecondHighVIP();
|
| | | if (record.getFirstSuperVIP() != null)
|
| | | superVIPToday += record.getFirstSuperVIP();
|
| | | if (record.getSecondSuperVIP() != null)
|
| | | superVIPToday += record.getSecondSuperVIP();
|
| | | }
|
| | | |
| | | |
| | | // 获取当月第一天和最后一天 |
| | | Calendar cale = Calendar.getInstance();
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String firstday, lastday; |
| | | // 获取前月的第一天 |
| | | cale = Calendar.getInstance(); |
| | | cale.add(Calendar.MONTH, 0); |
| | | cale.set(Calendar.DAY_OF_MONTH, 1); |
| | | firstday = format.format(cale.getTime()); |
| | | // 获取前月的最后一天 |
| | | cale = Calendar.getInstance(); |
| | | cale.add(Calendar.MONTH, 1); |
| | | cale.set(Calendar.DAY_OF_MONTH, 0); |
| | | lastday = format.format(cale.getTime()); |
| | | |
| | | int darenMonth = 0;
|
| | | int highVIPMonth = 0;
|
| | | int superVIPMonth = 0;
|
| | | Date date = new Date();
|
| | | Date minTime = TimeUtil.parseYYYYMMDD(firstday);
|
| | | Date maxTime = TimeUtil.parseYYYYMMDD_HHMMSS(lastday + " 23:59:59");
|
| | | List<TeamDailyRecord> listMonth = teamDailyRecordService.sumGroupByYearMonth(uid, minTime, maxTime);
|
| | | if (listMonth != null && listMonth.size() > 0) {
|
| | | TeamDailyRecord teamRecord = listMonth.get(0);
|
| | | if (teamRecord.getFirstDaRen() != null) |
| | | darenMonth += teamRecord.getFirstDaRen();
|
| | | if (teamRecord.getSecondDaRen() != null)
|
| | | darenMonth += teamRecord.getSecondDaRen(); |
| | | if (teamRecord.getFirstHighVIP() != null)
|
| | | highVIPMonth += teamRecord.getFirstHighVIP();
|
| | | if (teamRecord.getSecondHighVIP() != null)
|
| | | highVIPMonth += teamRecord.getSecondHighVIP();
|
| | | if (teamRecord.getFirstSuperVIP() != null)
|
| | | superVIPMonth += teamRecord.getFirstSuperVIP();
|
| | | if (teamRecord.getSecondSuperVIP() != null)
|
| | | superVIPMonth += teamRecord.getSecondSuperVIP();
|
| | | }
|
| | | // 达人
|
| | | daren.put("today", darenToday);
|
| | | daren.put("month", darenMonth);
|
| | | // 高级会会员
|
| | | highVIP.put("today", highVIPToday);
|
| | | highVIP.put("month", highVIPMonth);
|
| | | // 统计超级会员数量
|
| | | superVIP.put("today", superVIPToday);
|
| | | superVIP.put("month", superVIPMonth);
|
| | | |
| | | json.put("daren", daren);
|
| | | json.put("highVIP", highVIP);
|
| | | json.put("superVIP", superVIP);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取粉丝信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param workerId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getFansInfo")
|
| | | public void getFansInfo(AcceptData acceptData, Long uid, Long workerId, PrintWriter out) {
|
| | | if (uid == null || workerId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户id缺失"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(workerId);
|
| | | if (threeSale == null) {
|
| | | out.print(JsonUtil.loadFalseResult("邀请关系不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.selectByPKey(workerId);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 非直接邀请关系
|
| | | String bossNickName = null;
|
| | | if (uid.longValue() != threeSale.getBoss().getId().longValue()) {
|
| | | UserInfo boss = userInfoService.selectByPKey(threeSale.getBoss().getId());
|
| | | if (boss != null) {
|
| | | bossNickName = boss.getNickName();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | JSONArray tagArray = new JSONArray();
|
| | | String memoName = user.getNickName();
|
| | | Long succeedTime = threeSale.getSucceedTime();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | String phone = user.getPhone();
|
| | | boolean phoneCopy = true;
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | phone = "";
|
| | | } else {
|
| | | if (!userCustomSettingsService.validateDisplayPhoneByUid(workerId)) {
|
| | | phoneCopy = false;
|
| | | phone = phone.substring(0, 7) + "****";
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("bossNickName", bossNickName);
|
| | | data.put("nickName", user.getNickName());
|
| | | data.put("phone", phone);
|
| | | data.put("phoneCopy", phoneCopy);
|
| | | data.put("joinTime", TimeUtil.formatDate(succeedTime == null ? threeSale.getCreateTime() : succeedTime));
|
| | |
|
| | | ThreeSaleExtraInfo saleExtraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, workerId);
|
| | | if (saleExtraInfo != null) {
|
| | | if (!StringUtil.isNullOrEmpty(saleExtraInfo.getNickname())) {
|
| | | memoName = saleExtraInfo.getNickname();
|
| | | }
|
| | | String tags = saleExtraInfo.getTags();
|
| | | if (!StringUtil.isNullOrEmpty(tags)) {
|
| | | tagArray = JSONArray.fromObject(tags);
|
| | | }
|
| | | }
|
| | | data.put("memoName", memoName);
|
| | | data.put("tags", tagArray);
|
| | |
|
| | | Date activeTime = null;
|
| | | String weixin = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
|
| | | if (userInfoExtra != null) {
|
| | | weixin = userInfoExtra.getWeiXin();
|
| | | activeTime = userInfoExtra.getActiveTime();
|
| | | }
|
| | | |
| | | if (activeTime == null) {
|
| | | activeTime = new Date(user.getCreatetime());
|
| | | }
|
| | | |
| | | data.put("weixin", StringUtil.isNullOrEmpty(weixin) ? "" : weixin);
|
| | | data.put("loginTime", TimeUtil.formatDate(activeTime));
|
| | |
|
| | | UserExtraTaoBaoInfo userExtraTaoBaoInfo = userExtraTaoBaoInfoService.getByUid(workerId);
|
| | | if (userExtraTaoBaoInfo != null && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getRelationId())
|
| | | && !StringUtil.isNullOrEmpty(userExtraTaoBaoInfo.getSpecialId())) {
|
| | | data.put("taobao", true);
|
| | | } else {
|
| | | data.put("taobao", false);
|
| | | }
|
| | |
|
| | | UserVIPPreInfo userVIPPreInfo = userVIPPreInfoService.getLatestProcessInfo(workerId);
|
| | | if (userVIPPreInfo != null) {
|
| | | String levelName = null;
|
| | | Integer process = userVIPPreInfo.getProcess();
|
| | | if (process == UserVIPPreInfo.PROCESS_2) {
|
| | | levelName = "高级会员";
|
| | | } else if (process == UserVIPPreInfo.PROCESS_3) {
|
| | | levelName = "超级会员";
|
| | | } else if (process == UserVIPPreInfo.PROCESS_4) {
|
| | | levelName = "资深导师";
|
| | | }
|
| | |
|
| | | Integer sourceType = userVIPPreInfo.getSourceType();
|
| | | if (sourceType != null && levelName != null) {
|
| | | if (sourceType == UserVIPPreInfo.SOURCE_TYPE_ORDER) {
|
| | | data.put("level", levelName += "(自购分享型)");
|
| | | } else if (sourceType == UserVIPPreInfo.SOURCE_TYPE_TEAM) {
|
| | | data.put("level", levelName += "(邀请团队型)");
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 粉丝统计
|
| | | long indirectNum = 0;
|
| | | long directNum = threeSaleSerivce.countFirstTeam(workerId);
|
| | | if (directNum > 0) {
|
| | | indirectNum = threeSaleSerivce.countSecondTeam(workerId);
|
| | | }
|
| | | |
| | | // 订单统计
|
| | | long countTB = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_TAOBAO, 60);
|
| | | long countJD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_JD, 60);
|
| | | long countPDD = commonOrderCountService.countOrderBySourceAndNearDay(workerId, Constant.SOURCE_TYPE_PDD, 60);
|
| | | |
| | | data.put("fansNum", "直接粉丝: "+directNum+"人\n" + "间接粉丝: "+indirectNum+"人");
|
| | | data.put("orderInfo", "淘宝 ("+countTB+"笔)\n" + "京东 ("+countJD+"笔)\n" + "拼多多 ("+countPDD+"笔)");
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取粉丝信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param workerId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveTags")
|
| | | public void saveTags(AcceptData acceptData, Long uid, Long workerId, String tags, PrintWriter out) {
|
| | | if (uid == null || workerId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户id缺失"));
|
| | | return;
|
| | | }
|
| | |
|
| | | int type = 1;
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerId(workerId);
|
| | | if (threeSale != null && threeSale.getBoss().getId() != uid) {
|
| | | type = 2;
|
| | | }
|
| | |
|
| | | ThreeSaleExtraInfo saleExtraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, workerId);
|
| | | if (saleExtraInfo != null) {
|
| | | ThreeSaleExtraInfo upObject = new ThreeSaleExtraInfo();
|
| | | upObject.setTags(tags);
|
| | | upObject.setId(saleExtraInfo.getId());
|
| | | upObject.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(upObject);
|
| | | } else {
|
| | | saleExtraInfo = new ThreeSaleExtraInfo();
|
| | | saleExtraInfo.setBoss(new UserInfo(uid));
|
| | | saleExtraInfo.setWorker(new UserInfo(workerId));
|
| | | saleExtraInfo.setTags(tags);
|
| | | saleExtraInfo.setType(type);
|
| | | saleExtraInfo.setCreateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.insertSelective(saleExtraInfo);
|
| | | }
|
| | |
|
| | | // 更新粉丝记录信息
|
| | | teamFansInfoService.updateTags(workerId, type, tags);
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 队员数量统计
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countTeamNum")
|
| | | public void countTeamNum(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | try {
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | |
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | | |
| | | // 今日预估
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | TeamDailyRecord todayRecord = createVO(teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, null));
|
| | |
|
| | | // 昨日预估
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | minDate = DateUtil.reduceDay(1, maxDate);
|
| | | TeamDailyRecord yesterdayRecord = createVO(teamDailyRecordService.sumTeamNumGroupByCountDay(uid, minDate, maxDate));
|
| | |
|
| | | // 本月预估
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | TeamDailyRecord monthRecord = createVO(teamDailyRecordService.sumTeamNumGroupByYearMonth(uid, minDate, maxDate));
|
| | | |
| | | // 累计
|
| | | TeamDailyRecord totalityRecord = createVO(teamDailyRecordService.sumTeamNumGroupByUid(uid, null, null));
|
| | | |
| | | JSONObject today = new JSONObject();
|
| | | today.put("direct", todayRecord.getFirstNum());
|
| | | today.put("indirect", todayRecord.getSecondNum());
|
| | | today.put("beyond", todayRecord.getBeyondNum());
|
| | | |
| | | JSONObject yesterday = new JSONObject();
|
| | | yesterday.put("direct", yesterdayRecord.getFirstNum());
|
| | | yesterday.put("indirect", yesterdayRecord.getSecondNum());
|
| | | yesterday.put("beyond", yesterdayRecord.getBeyondNum());
|
| | | |
| | | JSONObject month = new JSONObject();
|
| | | month.put("direct", monthRecord.getFirstNum());
|
| | | month.put("indirect", monthRecord.getSecondNum());
|
| | | month.put("beyond", monthRecord.getBeyondNum());
|
| | | |
| | | JSONObject totality = new JSONObject();
|
| | | totality.put("direct", totalityRecord.getFirstNum());
|
| | | totality.put("indirect", totalityRecord.getSecondNum());
|
| | | totality.put("beyond", totalityRecord.getBeyondNum());
|
| | | |
| | | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("today", today);
|
| | | json.put("yesterday", yesterday);
|
| | | json.put("month", month);
|
| | | json.put("totality", totality);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | private TeamDailyRecord createVO(List<TeamDailyRecord> list) {
|
| | | TeamDailyRecord totalityRecord = new TeamDailyRecord(0,0,0);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (TeamDailyRecord record: list) {
|
| | | totalityRecord.setFirstNum(totalityRecord.getFirstNum() + record.getFirstNum());
|
| | | totalityRecord.setSecondNum(totalityRecord.getSecondNum() + record.getSecondNum());
|
| | | totalityRecord.setBeyondNum(totalityRecord.getBeyondNum() + record.getBeyondNum());
|
| | | }
|
| | | } |
| | | return totalityRecord;
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 邀请排行榜
|
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param dateType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRanking")
|
| | | public void getRanking(String callback, AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
|
| | | if (uid == null || dateType == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("参数缺失"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | | |
| | | if (dateType == 1) {
|
| | | // 今日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | minDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | } else if (dateType == 2) {
|
| | | // 昨日
|
| | | calendar.add(Calendar.DAY_OF_YEAR, -1);
|
| | | maxDate = new Date(TimeUtil.convertDateToTemp(TimeUtil.getGernalTime(timeStamp)));
|
| | | minDate = DateUtil.reduceDay(1, maxDate);
|
| | | } else {
|
| | | // 本月
|
| | | maxDate = new Date(timeStamp);
|
| | | calendar = Calendar.getInstance();
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | }
|
| | | |
| | | |
| | | List<OrderRankingVO> list = teamDailyRecordService.getRankingByFirstNum(uid, minDate, maxDate);
|
| | | if (list.size() > 0) {
|
| | | for (OrderRankingVO vo: list) {
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(vo.getUid());
|
| | | vo.setNickName(user.getNickName());
|
| | | vo.setPortrait(user.getPortrait());
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject json = new JSONObject();
|
| | | json.put("list", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|