| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.entity.wx.WXMPSessionInfo;
|
| | | import org.yeshi.utils.wx.WXXCXUtil;
|
| | |
|
| | | import com.google.gson.GsonBuilder;
|
| | | 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.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.exception.user.UserInfoException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.MaskKeyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.annotation.UserActive;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private MaskKeyService maskKeyService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | |
|
| | | /**
|
| | | * 获取openId
|
| | |
| | | out.print(JsonUtil.loadFalseResult("openId获取失败"));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "saveInfo")
|
| | | public void saveInfo(AcceptData acceptData, String nickName, String weiXin, Integer sex, Long uid,
|
| | | String inviteCode, MultipartFile qrCodeFile, HttpServletRequest request, PrintWriter out) {
|
| | |
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 二维码
|
| | | if (qrCodeFile != null) {
|
| | | userInfoExtraService.uploadERCode(qrCodeFile, uid);
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (UserInfoException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private void outUserInfoHandle(UserInfo user) {
|
| | |
|
| | | // 红包处理
|
| | | user.setTotalHongBao(new BigDecimal(0));
|
| | | user.setNoOpenHongBao(new BigDecimal(0));
|
| | | user.setCanOpenHongBao(new BigDecimal(0));
|
| | |
|
| | | // 电话号码处理
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) {
|
| | | if (user.getPhone().length() > 5) {
|
| | | String phone = user.getPhone().substring(0, 3);
|
| | | phone += "******";
|
| | | phone += user.getPhone().substring(user.getPhone().length() - 2, user.getPhone().length());
|
| | | user.setPhone(phone);
|
| | | }
|
| | | }
|
| | |
|
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
|
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
|
| | | String picture = userInfoExtra.getUserRank().getPicture();
|
| | | String icon = userInfoExtra.getUserRank().getIcon();
|
| | | user.setRankNamePicture(picture);
|
| | | user.setRankIcon(icon);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param form
|
| | | * @param requst
|
| | | * @param out
|
| | | */
|
| | | @UserActive(uid = "#uid")
|
| | | @RequestMapping(value = "getUserInfo")
|
| | | public void getuserinfoNew(WXMPAcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) {
|
| | | try {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getAppId());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("请求参数为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.getUserInfo(uid);
|
| | |
|
| | | // 添加用户活跃记录
|
| | | UserActiveLog userActiveLog = new UserActiveLog();
|
| | | userActiveLog.setChannel("wxmp");
|
| | | userActiveLog.setIp(requst.getRemoteHost());
|
| | | userActiveLog.setUid(userInfo.getId());
|
| | | userActiveLog.setVersionCode(acceptData.getVersion());
|
| | | userActiveLog.setOsVersion(acceptData.getWxVersion());
|
| | | userActiveLog.setDeviceType("wxmp");
|
| | | userActiveLog.setDevice(acceptData.getDevice());
|
| | | userActiveLogService.addUserActiveLog(userActiveLog);
|
| | | |
| | |
|
| | | // 处理用户信息
|
| | | outUserInfoHandle(userInfo);
|
| | | userInfo.setVip(userVIPInfoService.isVIP(uid));
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | boolean tailor = false;
|
| | | int welfareCenterNews = 0;
|
| | | String invitCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (userInfoExtra.getCouponNews() != null) {
|
| | | welfareCenterNews = userInfoExtra.getCouponNews();
|
| | | }
|
| | | // vip邀请码优先
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) {
|
| | | invitCode = userInfoExtra.getInviteCodeVip();
|
| | | } else if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | tailor = true;
|
| | | invitCode = userInfoExtra.getInviteCode();
|
| | | }
|
| | |
|
| | | if (userInfoExtra.getUserRank() != null) {
|
| | | String picture = userInfoExtra.getUserRank().getPicture();
|
| | | String icon = userInfoExtra.getUserRank().getIcon();
|
| | | userInfo.setRankNamePicture(picture);
|
| | | userInfo.setRankIcon(icon);
|
| | | } else {
|
| | | userInfo.setRankNamePicture(null);
|
| | | userInfo.setRankIcon(null);
|
| | | }
|
| | |
|
| | | if (userInfoExtra.getSex() != null)
|
| | | userInfo.setSex(userInfoExtra.getSex());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
|
| | | userInfo.setWeiXin(userInfoExtra.getWeiXin());
|
| | |
|
| | | // 二维码
|
| | | userInfo.setErCode(userInfoExtra.getErCode());
|
| | | }
|
| | | // 显示邀请码特制入口
|
| | | data.put("tailor", tailor);
|
| | |
|
| | | userInfo.setWeiXinTip("添加微信号后,你的邀请人和直接粉丝可以通过微信与你建立联系。");
|
| | |
|
| | | data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
|
| | | data.put("invitCode", invitCode); // 邀请码
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip()))
|
| | | data.put("invitCodeUpdated", true);// 邀请码是否已经修改过
|
| | | else
|
| | | data.put("invitCodeUpdated", false);
|
| | | data.put("vipLink", userVipConfigService.getValueByKey("vip_link"));// 超级会员升级链接
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(invitCode)) {
|
| | | String bossName = "";
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null && threeSale.getBoss() != null) {
|
| | | bossName = threeSale.getBoss().getNickName();
|
| | | }
|
| | | data.put("bossName", bossName);
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final UserInfo uuser = userInfo;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 获取邀请码:若无邀请码且存在有效的队员关系 则自动生成邀请码
|
| | | userInfoExtraService.getInviteCodeByUid(uuser.getId());
|
| | |
|
| | | // 更新用户附加信息,老用户不存在的需要添加
|
| | | try {
|
| | | userInfoExtraService.updateUserRankByUid(uuser.getId());
|
| | | } catch (UserInfoExtraException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | } catch (UserInfoException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|