| | |
| | | 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.Date;
|
| | | import java.util.List;
|
| | |
|
| | | 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.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.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.SMSHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | 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.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.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | 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.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.BindRemindService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | 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.vip.UserVIPInfoService;
|
| | | 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.vo.user.UserVipRateVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 账户系统
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v2/user")
|
| | | public class UserAccountControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountService userAccountService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenHWService deviceTokenHWService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenOPPOService deviceTokenOPPOService;
|
| | |
|
| | | @Resource
|
| | | private DeviceTokenVIVOService deviceTokenVIVOService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountBindingHistoryService userAccountBindingHistoryService;
|
| | |
|
| | | @Resource
|
| | | private HomeNavbarUserService homeNavbarUserService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoDeleteRecordService userInfoDeleteRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | |
|
| | | @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
|
| | | * |
| | | * @param acceptData
|
| | | * @param vcode
|
| | | * @param phone
|
| | | * @param code
|
| | | * @param loginType
|
| | | * 登录方式: 1-手机登录 2-微信登录
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "login", method = RequestMethod.POST)
|
| | | public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | try {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = null;
|
| | | // 手机登录
|
| | | if (loginType == 1) {
|
| | | userInfo = userAccountService.loginPhone(request, loginType, vcode, phone, system.getAppid());
|
| | | }
|
| | |
|
| | | // 微信登录
|
| | | if (loginType == 2) {
|
| | | userInfo = userAccountService.loginWeiXinNew(request, acceptData, loginType, code, system.getAppid());
|
| | | }
|
| | |
|
| | | if (userInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | } else {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final UserInfo uuser = userInfo;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | String device = acceptData.getDevice();
|
| | | try {
|
| | | // 同步自定义导航
|
| | | homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | // 绑定oppo,VIVO推送
|
| | | DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice());
|
| | | if (active != null) {
|
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId());
|
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId());
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | } catch (UserAccountException e) {
|
| | | int errorCode = e.getCode();
|
| | | if (errorCode == 101) { // 需要绑定手机号
|
| | | 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());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 绑定电话号码 V2.0.1 微信登录
|
| | | * |
| | | * @param acceptData
|
| | | * @param vcode
|
| | | * @param phone
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "'bindPhoneLogin-'+#phone")
|
| | | @RequestMapping(value = "bindPhoneLogin")
|
| | | public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, 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(vcode)) {
|
| | | out.print(JsonUtil.loadFalseResult("验证码不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult("key值不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | phone = phone.replaceAll(" ", "");
|
| | |
|
| | | String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
|
| | | if (Constant.IS_OUTNET) {
|
| | | if (!vcode.equalsIgnoreCase(oldVCode)) {
|
| | | out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
|
| | | return;
|
| | | }
|
| | | redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
|
| | | }
|
| | |
|
| | | try {
|
| | | UserInfo userInfo = userAccountService.bindPhoneToLogin(phone, key, system.getAppid(), request);
|
| | |
|
| | | 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()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 绑定电话号码 V2.0.1 微信登录
|
| | | * |
| | | * @param acceptData
|
| | | * @param vcode
|
| | | * @param phone
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "recordBind")
|
| | | public void recordBind(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户id为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | bindRemindService.addBindPhone(uid);
|
| | | out.print(JsonUtil.loadTrueResult("记录成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVIPInfo")
|
| | | public void getVIPInfo(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 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("customer_service_link"));
|
| | |
|
| | | // 省钱 -自购产生返利
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | | // 分享赚
|
| | | BigDecimal rewardShare = hongBaoV2CountService.getRewardMoneyByShare(uid);
|
| | | // 邀请赚
|
| | | BigDecimal rewardInvite = hongBaoV2CountService.getRewardMoneyByInvite(uid);
|
| | |
|
| | | 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(MoneyBigDecimalUtil.add(rewardShare, rewardInvite));
|
| | | } else {
|
| | | BigDecimal rate1 = new BigDecimal(5);
|
| | | BigDecimal rate2 = new BigDecimal(12);
|
| | | vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, MoneyBigDecimalUtil.div(rate1, rate2)));
|
| | | vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardShare, MoneyBigDecimalUtil.div(rate1, rate2)));
|
| | | }
|
| | | vo.setFinishMoney(finishMoney);
|
| | |
|
| | | // 会员规则执行时间
|
| | | 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"));
|
| | |
|
| | | 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())) {
|
| | | 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")));
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | 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;
|
| | | }
|
| | |
|
| | | 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(""));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | 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 javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.ks.push.service.BDeviceTokenService; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.vo.taobao.TaoBaoUser; |
| | | import com.yeshi.fanli.vo.user.QQUserInfoVO; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | 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.order.CommonOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | | import com.yeshi.fanli.service.inter.order.OrderMoneyDailyCountService; |
| | | import com.yeshi.fanli.service.inter.push.DeviceActiveService; |
| | | 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.user.BindRemindService; |
| | | 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.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.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; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import org.yeshi.utils.entity.ProxyIP; |
| | | |
| | | /** |
| | | * 账户系统 |
| | | * |
| | | * @author Administrator |
| | | */ |
| | | @Controller |
| | | @RequestMapping("api/v2/user") |
| | | public class UserAccountControllerV2 { |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | @Resource |
| | | private UserAccountService userAccountService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | |
| | | @Resource |
| | | private DeviceTokenOPPOService deviceTokenOPPOService; |
| | | |
| | | @Resource |
| | | private DeviceTokenXMService deviceTokenXMService; |
| | | |
| | | @Resource |
| | | private DeviceTokenVIVOService deviceTokenVIVOService; |
| | | |
| | | @Resource |
| | | private HomeNavbarUserService homeNavbarUserService; |
| | | |
| | | |
| | | @Resource |
| | | private DeviceActiveService deviceActiveService; |
| | | |
| | | @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; |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private BDeviceTokenService bDeviceTokenService; |
| | | |
| | | |
| | | /** |
| | | * 新版登录 V1.5.3 |
| | | * |
| | | * @param acceptData |
| | | * @param loginType 登录方式: 1-手机登录 2-微信登录 3-手机 4-qq |
| | | * @param vcode |
| | | * @param phone |
| | | * @param code |
| | | * @param aliAccessToken |
| | | * @param qqUser |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "login", method = RequestMethod.POST) |
| | | public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code, String aliAccessToken, String qqUser, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo userInfo = null; |
| | | |
| | | |
| | | switch (loginType) { |
| | | //电话号码登录 |
| | | case 1: { |
| | | if (!StringUtil.isNullOrEmpty(aliAccessToken)) { |
| | | long now = System.currentTimeMillis(); |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.oneKeyLoginCount, StringUtil.Md5(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid())); |
| | | ; |
| | | redisManager.increase(key); |
| | | int expire = (int) ((TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now + 1000 * 60 * 60 * 24L, "yyyyMMdd"), "yyyyMMdd") - now) / 1000); |
| | | redisManager.expire(key, expire); |
| | | } |
| | | userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, aliAccessToken, system); |
| | | } |
| | | break; |
| | | //微信登录 |
| | | case 2: { |
| | | //需要绑定电话号码 |
| | | if (SystemInfoUtil.hasFunctions(system.getSystem(), SystemFunction.bindPhone)) |
| | | userInfo = userAccountService.loginWeiXinNew(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | //不需要绑定电话号码 |
| | | else |
| | | userInfo = userAccountService.loginWeiXin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | } |
| | | break; |
| | | case 4: { |
| | | QQUserInfoVO qqUserInfo = UserUtil.parseQQUser(qqUser); |
| | | userInfo = userAccountService.loginQQ(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, qqUserInfo, system); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | |
| | | if (userInfo == null) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | } else { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo)); |
| | | if (SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.inviteCode)) { |
| | | data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId())); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | final UserInfo uuser = userInfo; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | String device = acceptData.getDevice(); |
| | | try { |
| | | // 同步自定义导航 |
| | | homeNavbarUserService.synchroDeviceToUser(uuser.getId(), device); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | if (acceptData.getSystem().isNewPush()) { |
| | | bDeviceTokenService.bindUid(acceptData.getSystem().name(), StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid(), uuser.getId() + ""); |
| | | } else { |
| | | // 绑定oppo,VIVO推送 |
| | | DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice()); |
| | | if (active != null) { |
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } catch (UserAccountException e) { |
| | | int errorCode = e.getCode(); |
| | | if (errorCode == UserAccountException.CODE_NEED_BIND_PHONE) { // 需要绑定手机号 |
| | | 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 if (errorCode == UserAccountException.CODE_NEED_BIND_WX) { // 需要绑定微信号 |
| | | 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.error("登录出错:" + e.getCode() + "-" + e.getMessage()); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 淘宝登录(子APP) |
| | | * |
| | | * @param acceptData |
| | | * @param userData |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "loginTB", method = RequestMethod.POST) |
| | | public void loginTB(AcceptData acceptData, String userData, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | if (acceptData.getSystem() == SystemEnum.blks) { |
| | | out.print(JsonUtil.loadFalseResult("暂不支持此种登录方式")); |
| | | return; |
| | | } |
| | | TaoBaoUser taoBaoUser = new Gson().fromJson(userData, TaoBaoUser.class); |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo userInfo = null; |
| | | try { |
| | | userInfo = userAccountService.loginTB(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), taoBaoUser, system); |
| | | } catch (UserAccountException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | } |
| | | |
| | | if (userInfo == null) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | } else { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo)); |
| | | data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 绑定电话号码 V2.0.1 三方登录 |
| | | * |
| | | * @param acceptData |
| | | * @param vcode |
| | | * @param phone |
| | | * @param out |
| | | */ |
| | | @RequestSerializableByKey(key = "'bindPhoneLogin-'+#phone") |
| | | @RequestMapping(value = "bindPhoneLogin") |
| | | public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, String key, String aliAccessToken, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult("key值不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(aliAccessToken)) { |
| | | long now = System.currentTimeMillis(); |
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.oneKeyLoginCount, StringUtil.Md5(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid())); |
| | | ; |
| | | redisManager.increase(redisKey); |
| | | int expire = (int) ((TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now + 1000 * 60 * 60 * 24L, "yyyyMMdd"), "yyyyMMdd") - now) / 1000); |
| | | redisManager.expire(redisKey, expire); |
| | | } |
| | | |
| | | String mobile = null; |
| | | try { |
| | | mobile = userAccountService.getMobile(vcode, phone, aliAccessToken, acceptData.getSystem(), SMSHistory.TYPE_BIND); |
| | | } catch (UserAccountException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | UserInfo userInfo = userAccountService.bindPhoneToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, mobile, 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())); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "绑定失败")); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 绑定微信V2.1.3 电话号码 登录 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param code |
| | | * @param key |
| | | * @param request |
| | | * @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(), acceptData.getSystem()); |
| | | 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(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), 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 微信登录 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "recordBind") |
| | | public void recordBind(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null || uid <= 0) { |
| | | out.print(JsonUtil.loadFalseResult("用户id为空")); |
| | | return; |
| | | } |
| | | bindRemindService.addBindPhone(uid); |
| | | out.print(JsonUtil.loadTrueResult("记录成功")); |
| | | } |
| | | |
| | | /** |
| | | * 获取vip信息 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getVIPInfo") |
| | | public void getVIPInfo(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 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.getValue(ConfigKeyEnum.customerServiceLink.getKey(), acceptData.getSystem())); |
| | | |
| | | 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 { |
| | | userVIPPreInfoService.upgradeVipByMyOrder(uid); |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | userVIPPreInfoService.upgradeVipByTeamNum(uid); |
| | | } catch (Exception e) { |
| | | } |
| | | 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.getValue(ConfigKeyEnum.newerGonglue.getKey(), acceptData.getSystem())); |
| | | |
| | | // 已完成 |
| | | 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.getValue(ConfigKeyEnum.customerServiceLink.getKey(), acceptData.getSystem())); |
| | | |
| | | 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) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | |
| | | userAccountService.unRegisterUser(uid, "用户主动注销账户"); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("注销成功")); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 注销账户数据 |
| | | * |
| | | * @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; |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | Date minDate = null; |
| | | Date maxDate = null; |
| | | long timeStamp = System.currentTimeMillis(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTimeInMillis(timeStamp); |
| | | |
| | | // 全部未到账 |
| | | 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()); |
| | | |
| | | // 本月预估 |
| | | 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.getValue(ConfigKeyEnum.accountLogoutProtocolLink.getKey(), acceptData.getSystem())); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | @RequestMapping("getTaoBaoShareParams") |
| | | public void getTaoBaoShareParams(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | String relationId = userExtraTaoBaoInfoService.getRelationIdByUid(uid); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("relationId", relationId); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |