| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | 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.UserInviteValidNum;
|
| | | 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.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.order.OrderMoneyDailyCount;
|
| | | import com.yeshi.fanli.entity.push.DeviceActive;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | 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;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarUserService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneyDailyCountService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceActiveService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenOPPOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenVIVOService;
|
| | | import com.yeshi.fanli.service.inter.push.DeviceTokenXMService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoDeleteRecordService;
|
| | | 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.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralDetailService;
|
| | | 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.vip.TearcherService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | | import com.yeshi.fanli.vo.user.UserVipRateVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | private DeviceTokenOPPOService deviceTokenOPPOService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenXMService deviceTokenXMService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenVIVOService deviceTokenVIVOService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @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;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteService userInviteService;
|
| | |
|
| | | @Resource
|
| | | private UserInviteValidNumService userInviteValidNumService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private TearcherService tearcherService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | |
|
| | | |
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | | |
| | | @Resource
|
| | | private OrderMoneyDailyCountService orderMoneyDailyCountService;
|
| | |
|
| | |
|
| | | /**
|
| | | * 新版登录 V1.5.3
|
| | |
| | | } else {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo));
|
| | | data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId()));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final UserInfo uuser = userInfo;
|
| | |
| | | if (active != null) {
|
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId());
|
| | | }
|
| | | }
|
| | | });
|
| | |
| | | object.put("code", errorCode);
|
| | | object.put("data", data);
|
| | | out.print(object.toString());
|
| | | } else if (errorCode == 102) { // 需要绑定微信号
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("key", e.getMsg());
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("code", errorCode);
|
| | | object.put("data", data);
|
| | | out.print(object.toString());
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | try {
|
| | | LogHelper.cookieLog("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | LogHelper.error("登录出错:" + e.getCode() + "-" + e.getMessage());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 绑定微信V2.1.3 电话号码 登录
|
| | | * |
| | | * @param acceptData
|
| | | * @param vcode
|
| | | * @param phone
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "'bindWXLogin-'+#code")
|
| | | @RequestMapping(value = "bindWXLogin")
|
| | | public void bindWXLogin(AcceptData acceptData, Long uid, String code, String key, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(code)) {
|
| | | out.print(JsonUtil.loadFalseResult("请上传code"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult("key值不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | UserInfo userInfo = userAccountService.bindWXToLogin(request, acceptData, code, system.getAppid(), key);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserAccountException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 绑定电话号码 V2.0.1 微信登录
|
| | | *
|
| | |
| | | out.print(JsonUtil.loadTrueResult("记录成功"));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVIPInfo")
|
| | | public void getVIPInfo(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | public void getVIPInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户id为空"));
|
| | | 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 inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | UserVipRateVO vo = new UserVipRateVO();
|
| | | vo.setId(uid);
|
| | | vo.setInviteCode(inviteCode);
|
| | | vo.setNickName(userInfo.getNickName());
|
| | | vo.setPortrait(userInfo.getPortrait());
|
| | | vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | vo.setCsdLink(configService.get(ConfigKeyEnum.customerServiceLink.getKey()));
|
| | |
|
| | | Date now = new Date();
|
| | | Date start = new Date(0);
|
| | |
|
| | | // 返利订单、奖励券提成
|
| | | List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.fanli);
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
|
| | | BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now)
|
| | | .abs();
|
| | |
|
| | | // 邀请订单、分享订单、补贴
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.share);
|
| | | typeList.add(UserMoneyDetailTypeEnum.invite);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
|
| | | typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
|
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy);
|
| | | BigDecimal rewardMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
|
| | |
|
| | | UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
|
| | | 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
|
| | | vo.setSuccessTime(TimeUtil.getGernalTime(userVIPInfo.getSuccessTime().getTime(), "yyyy.MM.dd"));
|
| | | vo.setConserveMoney(finishMoney);
|
| | | vo.setEarnMoney(rewardMoney);
|
| | | } else {
|
| | | BigDecimal rate = new BigDecimal("0.409");
|
| | | vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, rate));
|
| | | vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardMoney, rate));
|
| | | }
|
| | | 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.setFinishGoldCoin(Long.parseLong(integralDetailService.getCumulativeMoney(uid).setScale(0).toString()));
|
| | |
|
| | | // vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // , 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;
|
| | | 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())) {
|
| | | 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(Long.parseLong(userVipConfigService.getValueByKey("require_gold_coin")));
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | });
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(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;
|
| | | }
|
| | |
|
| | | 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("申请成功,正在受理中"));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVIPInfoV2")
|
| | | public void getVIPInfoV2(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;
|
| | | }
|
| | | // 获取等级
|
| | | UserInviteLevelEnum level = userInviteService.getUserInviteLevelNew(uid);
|
| | |
|
| | | // 达人
|
| | | long limitOrder = 0;
|
| | | long limitFirst = 0;
|
| | | long limitSecond = 0;
|
| | | if (level == UserInviteLevelEnum.actived || level == UserInviteLevelEnum.noActive) {
|
| | | String orderCount = userVipConfigService.getValueByKey("vip_pre_7_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(orderCount)) {
|
| | | limitOrder = Long.parseLong(orderCount);
|
| | | }
|
| | | String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(first)) {
|
| | | limitFirst = Long.parseLong(first);
|
| | | }
|
| | | String second = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second)) {
|
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | } else if (level == UserInviteLevelEnum.highVIP || level == UserInviteLevelEnum.vipApply) {
|
| | | String orderCount = userVipConfigService.getValueByKey("vip_pre_10_order_count");
|
| | | if (!StringUtil.isNullOrEmpty(orderCount)) {
|
| | | limitOrder = Long.parseLong(orderCount);
|
| | | }
|
| | | String first = userVipConfigService.getValueByKey("vip_pre_10_first_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(first)) {
|
| | | limitFirst = Long.parseLong(first);
|
| | | }
|
| | | String second = userVipConfigService.getValueByKey("vip_pre_10_second_level_team_count");
|
| | | if (!StringUtil.isNullOrEmpty(second)) {
|
| | | limitSecond = Long.parseLong(second);
|
| | | }
|
| | | } else if (level == UserInviteLevelEnum.vip || level == UserInviteLevelEnum.tearcherApply) {
|
| | | // TODO 比例
|
| | |
|
| | | } else if (level == UserInviteLevelEnum.tearcher) {
|
| | | // TODO
|
| | | }
|
| | |
|
| | | // 自购订单
|
| | | long doneOrder = hongBaoV2CountService.countMyDirectOrderByCashArrival(uid, Constant.VIP_ORDER_PAY);
|
| | | // 有效粉丝
|
| | | int doneFirst = 0;
|
| | | int doneSecond = 0;
|
| | | UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
|
| | | if (userInviteValidNum != null) {
|
| | | doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
|
| | | doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
|
| | | }
|
| | |
|
| | | Date now = new Date();
|
| | | Date start = new Date(0);
|
| | | // 省钱: ---返利订单、奖励券提成
|
| | | List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.fanli);
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
|
| | | BigDecimal saveMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now).abs();
|
| | |
|
| | | // 赚钱: 邀请订单、分享订单、补贴
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.share);
|
| | | typeList.add(UserMoneyDetailTypeEnum.invite);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
|
| | | typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
|
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy);
|
| | | BigDecimal earnMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
|
| | | if (level != UserInviteLevelEnum.vip) {
|
| | | BigDecimal rate = new BigDecimal("0.409");
|
| | | saveMoney = MoneyBigDecimalUtil.mul2(saveMoney, rate);
|
| | | earnMoney = MoneyBigDecimalUtil.mul2(earnMoney, rate);
|
| | | }
|
| | |
|
| | | String shareRate = "可享佣金的<label style=\"color:#E5005C;\">%s</label>";
|
| | | String teamRate = "最高佣金的<label style=\"color:#E5005C;\">%s</label>";
|
| | | // 达人版
|
| | | JSONObject jsonrRed1 = new JSONObject();
|
| | | jsonrRed1.put("enjoyRate", String.format(shareRate, "145%"));
|
| | | jsonrRed1.put("teamRate", String.format(teamRate, "25%"));
|
| | | jsonrRed1.put("teamIncome", "高级会员以上专属");
|
| | |
|
| | | // 高级会员
|
| | | JSONObject jsonrRed2 = new JSONObject();
|
| | | jsonrRed2.put("enjoyRate", String.format(shareRate, "195%"));
|
| | | jsonrRed2.put("teamRate", String.format(teamRate, "50%"));
|
| | | jsonrRed2.put("teamIncome", "享高级团队收益");
|
| | |
|
| | | // 超级会员
|
| | | JSONObject jsonrRed3 = new JSONObject();
|
| | | jsonrRed3.put("enjoyRate", String.format(shareRate, "210%"));
|
| | | jsonrRed3.put("teamRate", String.format(teamRate, "110%"));
|
| | | jsonrRed3.put("teamIncome", "享超级团队收益");
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("level", level.name());
|
| | | json.put("nickName", userInfo.getNickName());
|
| | | json.put("portrait", userInfo.getPortrait());
|
| | | json.put("ruleLink", userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | json.put("saveMoney", saveMoney);
|
| | | json.put("earnMoney", earnMoney);
|
| | |
|
| | | String tearcherWX = "";
|
| | | TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
|
| | | if (tearcherInfo != null && !StringUtil.isNullOrEmpty(tearcherInfo.getWxID())) {
|
| | | tearcherWX = tearcherInfo.getWxID();
|
| | | }
|
| | | json.put("tearcherWX", tearcherWX);
|
| | | json.put("tearcherTip", "我是你的导师,为你在省赚过程中解难答疑,对你一对一辅导,倾听你的需求总结并反馈给板栗快省官方运营团队,快来添加我吧。");
|
| | | json.put("newerGongLue", configService.get(ConfigKeyEnum.newerGonglue.getKey()));
|
| | |
|
| | | // 已完成
|
| | | json.put("doneOrder", doneOrder);
|
| | | json.put("doneFirst", doneFirst);
|
| | | json.put("doneSecond", doneSecond);
|
| | |
|
| | | // 标准
|
| | | json.put("limitOrder", limitOrder);
|
| | | json.put("limitFirst", limitFirst);
|
| | | json.put("limitSecond", limitSecond);
|
| | |
|
| | | // 已完成
|
| | | json.put("daRen", jsonrRed1);
|
| | | json.put("highVIP", jsonrRed2);
|
| | | json.put("superVIP", jsonrRed3);
|
| | |
|
| | | // 人工客服链接
|
| | | json.put("csdLink", configService.get(ConfigKeyEnum.customerServiceLink.getKey()));
|
| | |
|
| | | UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
|
| | | String leftTime = "";
|
| | | if (userVIPInfo != null && userVIPInfo.getState() == UserVIPInfo.STATE_VERIFING
|
| | | && userVIPInfo.getApplyTime() != null) {
|
| | | 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;
|
| | | } else {
|
| | | leftTime = "还剩0秒";
|
| | | }
|
| | | }
|
| | | json.put("leftTime", leftTime);
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(json)));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(json));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVIPSuccessInfo")
|
| | | public void getVIPSuccessInfo(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserVIPPreInfo vipInfo = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | if (vipInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "还未升级成为会员"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserLevelEnum level = UserLevelUtil.getByLevel(vipInfo.getProcess());
|
| | | if (level == null) {
|
| | | level = UserLevelEnum.daRen;
|
| | | }
|
| | | UserLevelEnum showLevel = UserLevelUtil.getShowLevel(level);
|
| | |
|
| | | String desc = "你于" + TimeUtil.formatDateDot(vipInfo.getCreateTime()) + "升级为" + showLevel.getName();
|
| | |
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("desc", desc);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(json));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getTearcherWX")
|
| | | public void getTearcherWX(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | TearcherInfo tearcher = tearcherService.selectByUid(uid);
|
| | | if (tearcher == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("无导师"));
|
| | | return;
|
| | | } else {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("wx", tearcher.getWxID());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | //获取电话号码
|
| | | @RequestMapping(value = "getPhone")
|
| | | public void getPhone(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if(user==null){
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "用户不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | | JSONObject data=new JSONObject();
|
| | | data.put("phone", user.getPhone());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 账户注销
|
| | | * @param acceptData
|
| | | * @param callback
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("accountRemove")
|
| | | public void accountRemove(AcceptData acceptData, String callback, Long uid, String vcode, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(vcode)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请输入验证码"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该用户不存在"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("id", uid);
|
| | | data.put("nickName", userInfo.getNickName());
|
| | | data.put("portrait", userInfo.getPortrait());
|
| | | if (userInfo.getState() == UserInfo.STATE_FORBIDDEN) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, "帐户已被注销,请重新登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | String phone = userInfo.getPhone();
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未绑定有效电话号码"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (!Constant.IS_TEST) {
|
| | | String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_REMVOE);
|
| | | if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("验证码错误,重新输入"));
|
| | | return;
|
| | | } |
| | | redisManager.clearSMSVCode(phone, SMSHistory.TYPE_REMVOE);
|
| | | }
|
| | | |
| | | UserInfo user = new UserInfo(uid);
|
| | | user.setState(UserInfo.STATE_DELETE);
|
| | | user.setStateDesc("用户主动注销账户");
|
| | | userInfoService.updateByPrimaryKeySelective(user);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("注销成功"));
|
| | | }
|
| | |
|
| | | UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
|
| | | boolean vip = false;
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null |
| | | && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) {
|
| | | vip = true;
|
| | | data.put("applyTime", userVIPInfo.getSuccessTime());
|
| | | } |
| | | data.put("vip", vip);
|
| | | |
| | | // 省钱 -自购产生返利 |
| | | BigDecimal rewardPurchase = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | data.put("rurchaseReward", rewardPurchase.setScale(2));
|
| | | |
| | | BigDecimal conserveMoney = rewardPurchase;
|
| | | if (!vip) { // 少省钱: 自购产生返利 * 5/12
|
| | | BigDecimal rate1 = new BigDecimal(5);
|
| | | BigDecimal rate2 = new BigDecimal(12);
|
| | | conserveMoney = MoneyBigDecimalUtil.mul2(rewardPurchase, MoneyBigDecimalUtil.div(rate1, rate2));
|
| | | |
| | | /**
|
| | | * 注销账户数据
|
| | | * @param acceptData
|
| | | * @param callback
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getAccountData")
|
| | | public void getAccountData(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | data.put("conserveMoney", conserveMoney.setScale(2));
|
| | |
|
| | | // 分享赚
|
| | | BigDecimal rewardShare = hongBaoV2CountService.getRewardMoneyByShare(uid);
|
| | | // 邀请赚
|
| | | BigDecimal rewardInvite = hongBaoV2CountService.getRewardMoneyByInvite(uid); |
| | | |
| | | BigDecimal earnMoney = rewardShare;
|
| | | if (vip) { // 赚钱=分享+邀请 |
| | | earnMoney = MoneyBigDecimalUtil.add(rewardShare, rewardInvite );
|
| | | } else { // 少赚钱: 分享赚* 5/12
|
| | | BigDecimal rate1 = new BigDecimal(5);
|
| | | BigDecimal rate2 = new BigDecimal(12);
|
| | | earnMoney = MoneyBigDecimalUtil.mul2(rewardShare, MoneyBigDecimalUtil.div(rate1, rate2));
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | data.put("earnMoney", earnMoney.setScale(2));
|
| | |
|
| | | // 注:1.有效一级队员定义:2019年1月1日起,自购或分享1笔且付款总金额不小于1元(退款为失效);
|
| | | long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, "2019-01-01", new BigDecimal(1));
|
| | | data.put("teamNum", teamNum);
|
| | | Date minDate = null;
|
| | | Date maxDate = null;
|
| | | long timeStamp = System.currentTimeMillis();
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTimeInMillis(timeStamp);
|
| | |
|
| | | // 累计金币
|
| | | BigDecimal goldCoin = integralDetailService.getCumulativeMoney(uid);
|
| | | data.put("goldCoin", goldCoin.setScale(0));
|
| | | // 帮助链接
|
| | | data.put("helpLink", configService.get("help_link_vip_info"));
|
| | | // 全部未到账
|
| | | minDate = new Date(0);
|
| | | maxDate = new Date(timeStamp);
|
| | | BigDecimal totalMoney = hongBaoV2Service.getUnRecievedMoneyWithCreateTime(uid, minDate, maxDate);
|
| | | if (totalMoney == null) |
| | | totalMoney = BigDecimal.ZERO;
|
| | | totalMoney = totalMoney.add(user.getMyHongBao());
|
| | |
|
| | | // 使用红包次数
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | data.put("shopNum", banLiShopOrderService.countByUidAndState(uid, list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | // 本月预估
|
| | | 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);
|
| | | BigDecimal monthMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
|
| | | |
| | | // 上月预估
|
| | | maxDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | calendar.add(Calendar.MONTH, -1);
|
| | | minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | BigDecimal lastMoney = getMoney(orderMoneyDailyCountService.query(uid, minDate, maxDate));
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("totalMoney", totalMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | data.put("monthMoney", monthMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | data.put("lastMoney", lastMoney.setScale(2, BigDecimal.ROUND_DOWN));
|
| | | data.put("link", configService.get(ConfigKeyEnum.accountLogoutProtocolLink.getKey()));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | private BigDecimal getMoney(List<OrderMoneyDailyCount> list) {
|
| | | BigDecimal money = BigDecimal.ZERO;
|
| | | BigDecimal hundred = BigDecimal.valueOf(100);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (OrderMoneyDailyCount dailyCount : list) {
|
| | | if (dailyCount.getIncome() != null)
|
| | | money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncome()), hundred));
|
| | | if (dailyCount.getIncomeTeam() != null)
|
| | | money = money.add(MoneyBigDecimalUtil.div(BigDecimal.valueOf(dailyCount.getIncomeTeam()), hundred));
|
| | | }
|
| | | }
|
| | | return money;
|
| | | }
|
| | | }
|