| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.IPUtil;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.SMSHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | 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.service.inter.user.wx.WXMPUserLoginService;
|
| | |
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.user.UserVipRateVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller("WXMPUserAccountController")
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 通过邀请码获取用户信息
|
| | | *
|
| | |
| | | }
|
| | |
|
| | | String sessionKey = null;
|
| | | WXMPSessionInfo sessionInfo = (WXMPSessionInfo) session.getAttribute(UserController.WXMP_SESSION_INFO_KEY);
|
| | | WXMPSessionInfo sessionInfo = WXXCXUtil.getSessionInfo(Constant.WXMP_APP_INFO, code);
|
| | | if (sessionInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult(90000, "请重新登录"));
|
| | | return;
|
| | | } else {
|
| | | session.setAttribute(UserController.WXMP_SESSION_INFO_KEY, sessionInfo);
|
| | | }
|
| | |
|
| | | sessionKey = sessionInfo.getSessionKey();
|
| | |
| | | return;
|
| | | }
|
| | | String phoneNumber = WXXCXUtil.getPhoneNumber(sessionKey, phoneEncryptedData, phoneIv);
|
| | | LogHelper.test("小程序获取到的电话号码为:"+phoneNumber);
|
| | | |
| | | if (StringUtil.isNullOrEmpty(phoneNumber)) {
|
| | | out.print(JsonUtil.loadFalseResult("获取电话号码失败"));
|
| | | return;
|
| | |
| | |
|
| | | UserInfo lastUserInfo = null;
|
| | | if (!StringUtil.isNullOrEmpty(userData)) {
|
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.wxmpUserLogin, StringUtil.Md5(acceptData.getAppId() + "-" + acceptData.getOpenId()));
|
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.wxmpUserLogin,
|
| | | StringUtil.Md5(acceptData.getAppId() + "-" + acceptData.getOpenId()));
|
| | | String data = redisManager.getCommonString(redisKey);
|
| | | if (!StringUtil.isNullOrEmpty(data)) {
|
| | | lastUserInfo = new Gson().fromJson(data, UserInfo.class);
|
| | |
| | | }
|
| | |
|
| | | @RequestMapping("wxLogin")
|
| | | public void wxLogin(WXMPAcceptData acceptData, String wxEncryptedData, String wxIv, String inviteCode,
|
| | | public void wxLogin(WXMPAcceptData acceptData, String wxEncryptedData, String wxIv, String inviteCode, String code,
|
| | | HttpServletRequest request, HttpSession session, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(acceptData.getOpenId())) {
|
| | | out.print(JsonUtil.loadFalseResult("openId为空"));
|
| | |
| | | out.print(JsonUtil.loadFalseResult("微信用户加密数据为空"));
|
| | | return;
|
| | | }
|
| | | WXMPSessionInfo sessionInfo = (WXMPSessionInfo) session.getAttribute(UserController.WXMP_SESSION_INFO_KEY);
|
| | | if (sessionInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult(90000, "请重新登录"));
|
| | | return;
|
| | | }
|
| | | WXMPSessionInfo sessionInfo = WXXCXUtil.getSessionInfo(Constant.WXMP_APP_INFO, code);
|
| | |
|
| | | String sessionKey = sessionInfo.getSessionKey();
|
| | | if (StringUtil.isNullOrEmpty(sessionKey)) {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.wxmpUserLogin, StringUtil.Md5(acceptData.getAppId() + "-" + acceptData.getOpenId()));
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.wxmpUserLogin,
|
| | | StringUtil.Md5(acceptData.getAppId() + "-" + acceptData.getOpenId()));
|
| | |
|
| | | UserInfo user = new Gson().fromJson(redisManager.getCommonString(key), UserInfo.class);
|
| | | if (user == null) {
|
| | |
| | | userAccountService.updateUserSelective(update);
|
| | | }
|
| | | });
|
| | | break;
|
| | | return;
|
| | | case WXMPLoginResult.CODE_BIND_PHONE:
|
| | | // 需要绑定电话号码
|
| | | redisManager.saveObj(result.getUser(), key, 60 * 5);// 只缓存5分钟
|
| | |
| | | out.print(JsonUtil.loadFalseResult("openId为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | if(uid==null){
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("uid为空"));
|
| | | return;
|
| | | }
|
| | |
| | | out.print(JsonUtil.loadFalseResult("微信信息为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | WXMPSessionInfo sessionInfo = (WXMPSessionInfo) session.getAttribute(UserController.WXMP_SESSION_INFO_KEY);
|
| | | if (sessionInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult(90000, "请重新登录"));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 绑定电话号码 V1.5.3
|
| | | *
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 获取vip信息
|
| | | *
|
| | |
| | | vo.setNickName(userInfo.getNickName());
|
| | | vo.setPortrait(userInfo.getPortrait());
|
| | | vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | vo.setCsdLink(configService.get("customer_service_link"));
|
| | | vo.setCsdLink(configService.get(ConfigKeyEnum.customerServiceLink.getKey()));
|
| | |
|
| | | Date now = new Date();
|
| | | Date start = new Date(0);
|
| | |
| | | }
|
| | | vo.setFinishMoney(hongBaoV2CountService.getRewardMoneyBySelf(uid));
|
| | |
|
| | | |
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid, TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney));
|
| | | // vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney));
|
| | | |
| | | int finishTeam = 0;
|
| | | long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
|
| | | if (listThreeSale != null && listThreeSale.size() > 0) {
|
| | | for (ThreeSale three: listThreeSale) {
|
| | | UserInfo worker = three.getWorker();
|
| | | if (worker == null || worker.getId() == null) {
|
| | | continue;
|
| | | }
|
| | | // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
|
| | | long countValid = commonOrderService.countOrderByUidAndSettled(worker.getId(), payMoney);
|
| | | if (countValid > 0) {
|
| | | finishTeam ++;
|
| | | }
|
| | | }
|
| | | }
|
| | | vo.setFinishTeam(finishTeam);
|
| | | |
| | | vo.setFinishHongBao(banLiShopOrderService.countByUidAndState(uid, list));
|
| | |
|
| | | |
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("info", gson.toJson(vo));
|
| | | data.put("welfare", userVipConfigService.getValueByKey("vip_welfare"));
|
| | | data.put("welfare", JSONArray.fromObject(userVipConfigService.getValueByKey("vip_welfare")));
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(vo)));
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(data)));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 省钱 -自购产生返利
|
| | |
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | long finishTeam = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | long finishHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | |
|
| | | long limitTeam = 0;
|
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra != null
|
| | | && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
|
| | | } else {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
|
| | | }
|
| | | long limitHongBao = (Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
|
| | | BigDecimal limitMoney = (new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
|
| | |
|
| | | if (finishTeam >= limitTeam && finishHongBao >= limitHongBao && finishMoney.compareTo(limitMoney) >= 0) {
|
| | | // 条件符合
|
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未达到开通条件")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult("未达到开通条件"));
|
| | | }
|
| | | return;
|
| | | }
|
| | | // 开通
|
| | | |
| | | try {
|
| | | userVIPInfoService.applyVIP(uid);
|
| | | } catch (UserVIPInfoException e) {
|
| | |
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("已申请")));
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("申请成功,正在受理中")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult("已申请"));
|
| | | out.print(JsonUtil.loadTrueResult("申请成功,正在受理中"));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping("logout")
|
| | | public void logout(WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("uid为空"));
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | }
|