| | |
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | |
| | |
|
| | | @Resource
|
| | | private BindRemindService bindRemindService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralDetailService integralDetailService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | /**
|
| | | * 新版登录 V1.5.3
|
| | | *
|
| | |
| | | out.print(JsonUtil.loadTrueResult("记录成功"));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | |
| | | //
|
| | | String inviteCode = "";
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) |
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | inviteCode = userInfoExtra.getInviteCode();
|
| | | |
| | |
|
| | | UserVipRateVO vo = new UserVipRateVO();
|
| | | vo.setId(uid);
|
| | | vo.setInviteCode(inviteCode);
|
| | |
| | | vo.setPortrait(userInfo.getPortrait());
|
| | | vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | vo.setCsdLink(configService.get("customer_service_link"));
|
| | | |
| | | // 省钱 -自购产生返利 |
| | |
|
| | | // 省钱 -自购产生返利
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | // 分享赚
|
| | | BigDecimal rewardShare = hongBaoV2CountService.getRewardMoneyByShare(uid);
|
| | | // 邀请赚
|
| | | BigDecimal rewardInvite = hongBaoV2CountService.getRewardMoneyByInvite(uid); |
| | | |
| | | BigDecimal rewardInvite = hongBaoV2CountService.getRewardMoneyByInvite(uid);
|
| | |
|
| | | UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null |
| | | vo.setVipInfo(userVIPInfo);
|
| | | String leftTime = "";
|
| | | if (userVIPInfo != null && userVIPInfo.getApplyTime() != null) {
|
| | | // TODO 计算时间
|
| | | long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
|
| | | if (s > 3600) {
|
| | | leftTime = s / 3600 + "小时";
|
| | | leftTime = "还剩" + leftTime;
|
| | | } else if (s >= 60) {
|
| | | leftTime = s / 60 + "分钟";
|
| | | leftTime = "还剩" + leftTime;
|
| | | } else if (s > 0) {
|
| | | leftTime = s + "秒";
|
| | | leftTime = "还剩" + leftTime;
|
| | | }
|
| | | }
|
| | | vo.setLeftTime(leftTime);
|
| | |
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null
|
| | | && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) { // VIP
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.mm.dd");
|
| | | vo.setVip(true);
|
| | | vo.setSuccessTime(format.format(userVIPInfo.getSuccessTime()));
|
| | | vo.setConserveMoney(finishMoney.setScale(2));
|
| | | vo.setEarnMoney(MoneyBigDecimalUtil.add(rewardShare, rewardInvite).setScale(2));
|
| | | } else {
|
| | | BigDecimal rate1 = new BigDecimal(5);
|
| | | BigDecimal rate2 = new BigDecimal(12);
|
| | | vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, MoneyBigDecimalUtil.div(rate1, rate2)).setScale(2));
|
| | | vo.setEarnMoney( MoneyBigDecimalUtil.mul2(rewardShare, MoneyBigDecimalUtil.div(rate1, rate2)).setScale(2));
|
| | | vo.setConserveMoney(
|
| | | MoneyBigDecimalUtil.mul2(finishMoney, MoneyBigDecimalUtil.div(rate1, rate2)).setScale(2));
|
| | | vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardShare, MoneyBigDecimalUtil.div(rate1, rate2)).setScale(2));
|
| | | }
|
| | |
|
| | | vo.setFinishMoney(finishMoney.setScale(2));
|
| | | |
| | |
|
| | | // 会员规则执行时间
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | |
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | |
| | |
|
| | | vo.setFinishGoldCoin(integralDetailService.getCumulativeMoney(uid));
|
| | | vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid, executeDate.getTime(), payMoney));
|
| | | vo.setFinishHongBao(banLiShopOrderService.countByUidAndState(uid, list));
|
| | | |
| | |
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra !=null && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | if (extra != null
|
| | | && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
|
| | | } else {
|
| | | vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
|
| | |
| | | vo.setLimitHongBao(Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
|
| | | vo.setLimitMoney(new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
|
| | | vo.setLimitgoldCoin(new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin")));
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(vo)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(vo));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 开通VIP
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "applyVip")
|
| | | public void applyVip(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 省钱 -自购产生返利
|
| | |
|
| | | // 会员规则执行时间
|
| | | 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();
|
| | | }
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | BigDecimal finishGoldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | | long finishTeam = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, executeDate.getTime(), payMoney);
|
| | | long finishHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | |
|
| | | long limitTeam = 0;
|
| | |
|
| | | 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")));
|
| | | BigDecimal limitgoldCoin = (new BigDecimal(userVipConfigService.getValueByKey("require_gold_coin")));
|
| | |
|
| | | if (finishGoldCoin.compareTo(limitgoldCoin) >= 0 && 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.loadFalseResult(e.getMsg())));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|