| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.PrintWriter;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.lang.reflect.InvocationTargetException;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.IPUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | 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.HongBao;
|
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.dto.money.AccountDetails;
|
| | | import com.yeshi.fanli.dto.order.OrderItem;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | | import com.yeshi.fanli.entity.bus.user.BindRemind;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.Extract;
|
| | | import com.yeshi.fanli.entity.bus.user.ExtractRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.LostOrder;
|
| | | import com.yeshi.fanli.entity.bus.user.SMSHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.common.Config;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | import com.yeshi.fanli.exception.goods.CollectionGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.user.BindingAccountException;
|
| | | import com.yeshi.fanli.exception.user.UserCustomSettingsException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | 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.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractRecordService;
|
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService;
|
| | | import com.yeshi.fanli.service.inter.user.BindRemindService;
|
| | | import com.yeshi.fanli.service.inter.user.MaskKeyService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import com.yeshi.fanli.util.HongBaoUtil;
|
| | | 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.Utils;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.annotation.UserActive;
|
| | | import com.yeshi.fanli.util.email.MailSenderUtil;
|
| | | import com.yeshi.fanli.util.factory.AccountDetailsFactory;
|
| | | import com.yeshi.fanli.util.factory.HongBaoFactory;
|
| | | import com.yeshi.fanli.util.factory.OrderItemFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v1/customer")
|
| | | public class UserInfoController {
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Resource
|
| | | private BindingAccountService bindingAccountService;
|
| | |
|
| | | @Resource
|
| | | private ExtractService extractService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | |
|
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private UserAccountService loginService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ExtractRecordService extractRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderService hongBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private SpreadUserImgService spreadUserImgService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserCustomSettingsService userCustomSettingsService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageService accountMessageService;
|
| | |
|
| | | @Resource
|
| | | private MaskKeyService maskKeyService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinDetailService userTaoLiJinDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Resource
|
| | | private BindRemindService bindRemindService;
|
| | |
|
| | | @Resource
|
| | | private RedPackBalanceService redPackBalanceService;
|
| | |
|
| | | @Resource
|
| | | private UserRankService userRankService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | |
|
| | | private static final String PASSWORD_MAX_ERROR = "password_max_error";
|
| | | private static final String EXTRACT_MIN_MONEY = "extract_min_money";
|
| | | private static final String EXTRACT_MAX_MONEY = "extract_max_money";
|
| | |
|
| | | /**
|
| | | * 获取用户信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param form
|
| | | * @param requst
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getuserinfo", method = RequestMethod.POST)
|
| | | public void getUserInfo(AcceptData acceptData, UserInfo form, String code, String create, boolean first,
|
| | | HttpServletRequest requst, PrintWriter out) {
|
| | | String remotIP = IPUtil.getRemotIP(requst);
|
| | | long id = form.getId();
|
| | | // 判断是不是用ID登陆的,如果是用ID登陆的其他都不要管了
|
| | | if (id != 0) {
|
| | | UserInfo find = userInfoService.getUserByIdWithMybatis(id);
|
| | | // ThreadUtil.run(new Runnable() {
|
| | | // @Override
|
| | | // public void run() {
|
| | | // threeSaleSerivce.effective(find);
|
| | | // }
|
| | | // });
|
| | | if (find != null) {
|
| | | if (find.getState() != UserInfo.STATE_NORMAL) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER,
|
| | | Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 邀请关系生效
|
| | | threeSaleSerivce.effective(find);
|
| | |
|
| | | // 添加用户活跃记录
|
| | | UserActiveLog userActiveLog = new UserActiveLog();
|
| | | userActiveLog.setChannel(acceptData.getChannel());
|
| | | userActiveLog.setIp(requst.getRemoteHost());
|
| | | userActiveLog.setUid(find.getId());
|
| | | userActiveLog.setVersionCode(acceptData.getVersion());
|
| | | userActiveLog.setOsVersion(acceptData.getOsVersion());
|
| | | userActiveLog.setDeviceType(acceptData.getDeviceType());
|
| | | userActiveLog.setDevice(acceptData.getDevice());
|
| | |
|
| | | userActiveLogService.addUserActiveLog(userActiveLog);
|
| | |
|
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice());
|
| | | return;
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult("不存在该账户!"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | // 不是用ID的登陆的事就多了
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | | String appid = system.getAppid();
|
| | |
|
| | | // 判断是否是第一次正常登陆
|
| | | /*
|
| | | * String platform = acceptData.getPlatform(); if(platform == "ios") {
|
| | | * // 1: 安卓 2:ios if(firstIos == "1") { //第一次登陆 first = true; } else {
|
| | | * first = false; } }
|
| | | */
|
| | | if (first) {
|
| | | int loginType = form.getLoginType();
|
| | | // WeiXinUserParam wxParam = null;
|
| | | // 如果是微信登陆,那需要先获取到微信的unionid
|
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(),
|
| | | account.getAppSecret());
|
| | | if (loginType == Constant.WEIXIN && StringUtil.isNullOrEmpty(form.getWxUnionId())) {
|
| | | // wxParam = WXinUtil.getWxParam(code);
|
| | | if (weiXinUser == null) {
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | return;
|
| | | }
|
| | | form.setWxOpenId(weiXinUser.getOpenid());
|
| | | form.setWxUnionId(weiXinUser.getUnionid());
|
| | | }
|
| | | String openid = loginType == 1 ? form.getOpenid() : form.getWxUnionId();
|
| | | LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(requst) + "]" + (loginType == 1 ? "淘宝登陆" : "微信登陆")
|
| | | + "[openid:" + openid + "]");
|
| | | if (openid == null || openid.equals("")) {
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | return;
|
| | | }
|
| | | // 获取用户信息
|
| | | UserInfo user = userInfoService.getUserByLoginTypeAndOpenId(loginType, openid, appid);
|
| | | // 判断获取的用户信息是否为空,如果不为空就做的事就又多了
|
| | | if (user != null) {// 数据库中已经存在该用户
|
| | | outUserInfo(acceptData, out, remotIP, user, acceptData.getDevice());
|
| | | UserInfo temp = user;
|
| | | long lastLoginTime = temp.getLastLoginTime() == null ? 0 : temp.getLastLoginTime().longValue();
|
| | | if (lastLoginTime == 0) {// 等于0则是第一次登陆,那么需要判断用户是不是被传销来的,如果是的话,那需要修改相关三级分销的状态
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | threeSaleSerivce.effective(temp);
|
| | | }
|
| | |
|
| | | });
|
| | | }
|
| | | return;
|
| | | }
|
| | | // 查询到的用户信息为空,那么需要填充一些用户信息
|
| | | if (loginType == Constant.WEIXIN) {
|
| | | form.setPortrait(weiXinUser.getHeadimgurl());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | form.setWxPic(wxHeadImg);
|
| | | form.setNickName(weiXinUser.getNickname());
|
| | | form.setWxName(weiXinUser.getNickname());
|
| | | } else if (loginType == Constant.TAOBAO) {
|
| | | form.setTbName(form.getNickName());
|
| | | form.setTbPic(form.getPortrait());
|
| | | }
|
| | | form.setLastLoginIp(remotIP);
|
| | | form.setLastLoginTime(java.lang.System.currentTimeMillis());
|
| | | form.setSystem(system);
|
| | | requst.getSession().setAttribute("newUser", form);
|
| | | out.append(JsonUtil.loadTrueResult(2, form));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (create == null || "0".equals(create)) {
|
| | | out.append(JsonUtil.loadFalseResult("参数create不能为空!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo newUser = (UserInfo) requst.getSession().getAttribute("newUser");
|
| | | UserInfo mainUser = (UserInfo) requst.getSession().getAttribute("mainUser");
|
| | | if (Constant.NEWUSER.equals(create)) { // 创建
|
| | | UserInfo user;
|
| | | synchronized (UserInfo.class) {
|
| | | user = userInfoService.addUser(newUser, appid);
|
| | | }
|
| | | if (user != null) {
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", GsonUtil.toJsonExpose(user));
|
| | | data.put("first", 1);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | LogHelper.userInfo(GsonUtil.toJsonExpose(user));
|
| | | } else {
|
| | | LogHelper.userInfo("不存在用户:" + GsonUtil.toJsonExpose(form));
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | }
|
| | | requst.getSession().removeAttribute("newUser");
|
| | | return;
|
| | | } else if (Constant.BINDUSER.equals(create) && mainUser == null) { // 绑定
|
| | | int formLoginType = form.getLoginType();
|
| | | int newUserLoginType = newUser.getLoginType();
|
| | | if (newUserLoginType == formLoginType) { // 相同类型不能绑定
|
| | | out.print(JsonUtil.loadFalseResult("相同类型的账号不能绑定!"));
|
| | | return;
|
| | | }
|
| | | // 判断是不是微信。如果是微信就要填充微信相关信息
|
| | | if (formLoginType == Constant.WEIXIN/*
|
| | | * &&
|
| | | * StringUtil.isNullOrEmpty(form
|
| | | * .getWxOpenId())
|
| | | */) {
|
| | |
|
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | |
|
| | | WeiXinUser xinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(),
|
| | | account.getAppSecret());
|
| | | if (xinUser == null) {
|
| | | out.print(JsonUtil.loadFalseResult("登录失败"));
|
| | | return;
|
| | | }
|
| | | form.setWxOpenId(xinUser.getOpenid());
|
| | | form.setWxUnionId(xinUser.getUnionid());
|
| | | form.setPortrait(xinUser.getHeadimgurl());
|
| | | form.setNickName(xinUser.getNickname());
|
| | | form.setWxName(xinUser.getNickname());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(xinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | form.setWxPic(wxHeadImg);
|
| | | } else if (formLoginType == Constant.TAOBAO) {
|
| | | form.setTbName(form.getNickName());
|
| | | form.setTbPic(form.getPortrait());
|
| | | }
|
| | | form.setSystem(system);
|
| | | requst.getSession().setAttribute("mainUser", form);
|
| | | String openid = formLoginType == 1 ? form.getOpenid() : form.getWxUnionId();
|
| | | // 获取主账户用户信息
|
| | | UserInfo find = userInfoService.getUserByLoginTypeAndOpenId(formLoginType, openid, appid);
|
| | | if (find != null) {
|
| | | // 主账户不为空就进行绑定操作
|
| | | bind(find, newUser);
|
| | | userInfoService.update(find);
|
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice());
|
| | | requst.getSession().removeAttribute("newUser");
|
| | | requst.getSession().removeAttribute("mainUser");
|
| | | } else {
|
| | | // 为空的话就返回用户信息
|
| | | out.print(JsonUtil.loadTrueResult(3, form));
|
| | | return;
|
| | | }
|
| | | } else {// create=2 ,mainUser != null 创建并绑定!
|
| | | bind(mainUser, newUser);
|
| | | mainUser = userInfoService.addUser(mainUser, appid);
|
| | | outUserInfo(acceptData, out, remotIP, mainUser, acceptData.getDevice());
|
| | | requst.getSession().removeAttribute("newUser");
|
| | | requst.getSession().removeAttribute("mainUser");
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘特价登录
|
| | | * |
| | | * @param acceptData
|
| | | * @param form
|
| | | * @param code
|
| | | * @param create
|
| | | * @param first
|
| | | * @param requst
|
| | | * @param out
|
| | | */
|
| | |
|
| | | @RequestMapping(value = "getuserinfo_ttj", method = RequestMethod.POST)
|
| | | public void getUserInfoTTJ(AcceptData acceptData, UserInfo form, String code, String create, boolean first,
|
| | | HttpServletRequest requst, PrintWriter out) {
|
| | | String remotIP = IPUtil.getRemotIP(requst);
|
| | | long id = form.getId();
|
| | | // 判断是不是用ID登陆的,如果是用ID登陆的其他都不要管了
|
| | | if (id != 0) {
|
| | | UserInfo find = userInfoService.getUserById(id);
|
| | | if (find != null) {
|
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice());
|
| | | return;
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult("不存在该账户!"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | // 不是用ID的登陆的事就多了
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | | form.setSystem(system);
|
| | | String appid = system.getAppid();
|
| | | UserInfo user = userInfoService.getUserByLoginTypeAndOpenId(1, form.getOpenid(), appid);
|
| | | if (user == null) {
|
| | | // 创建用户
|
| | | userInfoService.addUser(form, appid);
|
| | | user = userInfoService.getUserByLoginTypeAndOpenId(1, form.getOpenid(), appid);
|
| | | }
|
| | |
|
| | | // 返回用户信息
|
| | | outUserInfo(acceptData, out, remotIP, user, acceptData.getDevice());
|
| | | }
|
| | |
|
| | | /**
|
| | | * 将副账户绑定到主账户上
|
| | | * |
| | | * @param mainUser
|
| | | * @param viceUser
|
| | | */
|
| | | private void bind(UserInfo mainUser, UserInfo viceUser) {
|
| | | int loginType = viceUser.getLoginType();
|
| | | if (loginType == Constant.TAOBAO) {
|
| | | mainUser.setOpenid(viceUser.getOpenid());
|
| | | mainUser.setTbName(viceUser.getNickName());
|
| | | mainUser.setTbPic(viceUser.getTbPic());
|
| | | } else if (loginType == Constant.WEIXIN) {
|
| | | mainUser.setWxName(viceUser.getWxName());
|
| | | mainUser.setWxOpenId(viceUser.getWxOpenId());
|
| | | mainUser.setWxUnionId(viceUser.getWxUnionId());
|
| | | mainUser.setWxPic(viceUser.getWxPic());
|
| | | }
|
| | | }
|
| | |
|
| | | private void outUserInfo(AcceptData acceptData, PrintWriter out, String remotIP, UserInfo user, String device) {
|
| | | user.setTotalHongBao(new BigDecimal(0));
|
| | | BigDecimal unOpenmoney = new BigDecimal(0);
|
| | | BigDecimal canOpenMoney = new BigDecimal(0);
|
| | | user.setNoOpenHongBao(unOpenmoney);
|
| | | user.setCanOpenHongBao(canOpenMoney);
|
| | |
|
| | | /**
|
| | | * 查询改用户返利红包
|
| | | */
|
| | | BigDecimal fanliHB = user.getTotalHongBao();
|
| | | user.setTotalHongBao(fanliHB);
|
| | |
|
| | | UserInfo filterForClientUser = UserUtil.filterForClientUser(user);
|
| | |
|
| | | // 1.5.0 版本之后返回新的等级
|
| | | String version = acceptData.getVersion();
|
| | | if (version != null && version.trim().length() > 0) {
|
| | | int versionCode = Integer.parseInt(version);
|
| | | String platform = acceptData.getPlatform();
|
| | |
|
| | | AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, "1.5.0");
|
| | | if (versionInfo != null) {
|
| | | int versionCode150 = versionInfo.getVersionCode();
|
| | | if (versionCode >= versionCode150) {
|
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
|
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
|
| | | String picture = userInfoExtra.getUserRank().getPicture();
|
| | | String icon = userInfoExtra.getUserRank().getIcon();
|
| | | filterForClientUser.setRankNamePicture(picture);
|
| | | filterForClientUser.setRankIcon(icon);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user",
|
| | | JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(filterForClientUser));
|
| | | data.put("first", 0);
|
| | | int spreadImgCount = spreadUserImgService.countUserSpreadImg(user.getId());
|
| | | long shareCount = userShareGoodsRecordService.countShareRecordByUid(user.getId());
|
| | |
|
| | | int showTiCheng = 1; // 不显示
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | data.put("showTiCheng", false);
|
| | | else {
|
| | | data.put("showTiCheng", spreadImgCount + shareCount > 0);
|
| | | if (spreadImgCount + shareCount > 0) {
|
| | | showTiCheng = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html",
|
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | else
|
| | | data.put("inviteList", configService.get("team_list"));
|
| | |
|
| | | // 界面状态
|
| | | UserSettingsVO mySettings = null;
|
| | | try {
|
| | | mySettings = userCustomSettingsService.getMySettings(user.getId());
|
| | | } catch (UserCustomSettingsException e) {
|
| | | mySettings = new UserSettingsVO();
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (mySettings.getCancelNotice() == null) {
|
| | | mySettings.setCancelNotice(0);
|
| | | }
|
| | | if (mySettings.getNoBonusCount() == null) {
|
| | | mySettings.setNoBonusCount(showTiCheng); // 根据showTiCheng来判断
|
| | | }
|
| | | if (mySettings.getNoNewsRedDot() == null) {
|
| | | mySettings.setNoNewsRedDot(0);
|
| | | }
|
| | | if (mySettings.getNoShareRecordAndStorage() == null) {
|
| | | mySettings.setNoShareRecordAndStorage(showTiCheng); // 根据showTiCheng来判断
|
| | | }
|
| | | if (mySettings.getNoInvitationBonus() == null) {
|
| | | mySettings.setNoInvitationBonus(0);
|
| | | }
|
| | | if (mySettings.getOpenSpreadHongBao() == null) {
|
| | | mySettings.setOpenSpreadHongBao(0);
|
| | | }
|
| | | data.put("moduleState", mySettings);
|
| | |
|
| | | int welfareCenterNews = 0;
|
| | | String invitCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(user.getId());
|
| | | if (userInfoExtra != null) {
|
| | | if (userInfoExtra.getCouponNews() != null) {
|
| | | welfareCenterNews = userInfoExtra.getCouponNews();
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) {
|
| | | invitCode = userInfoExtra.getInviteCodeVip();
|
| | | } else {
|
| | | invitCode = userInfoExtra.getInviteCode();
|
| | | }
|
| | | }
|
| | | // 邀请码
|
| | | data.put("invitCode", invitCode);
|
| | | // 福利中心消息
|
| | | data.put("welfareCenterNews", welfareCenterNews);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final UserInfo uuser = user;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 获取邀请码:若无邀请码且存在有效的队员关系 则自动生成邀请码
|
| | | userInfoExtraService.getInviteCodeByUid(uuser.getId());
|
| | |
|
| | | LogHelper.userInfo(GsonUtil.toJsonExpose(uuser));
|
| | | uuser.setLastLoginIp(remotIP);
|
| | | uuser.setLastLoginTime(java.lang.System.currentTimeMillis());
|
| | | userInfoService.updateLoginInfo(uuser);
|
| | | // 用户等级更新
|
| | | try {
|
| | | userInfoExtraService.updateUserRankByUid(uuser.getId());
|
| | | } catch (UserInfoExtraException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @RequestMapping("bindUserInfo")
|
| | | public void bindUserInfo(AcceptData acceptData, UserInfo form, String code, PrintWriter out) {
|
| | | UserInfo find = userInfoService.getUserById(form.getId());
|
| | | if (find == null) {
|
| | | out.print(JsonUtil.loadFalseResult("绑定失败,不存在该用户!"));
|
| | | return;
|
| | | }
|
| | | int loginType = form.getLoginType();
|
| | | if (loginType == Constant.WEIXIN) {
|
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(),
|
| | | account.getAppSecret());
|
| | |
|
| | | if (weiXinUser == null) {
|
| | | out.print(JsonUtil.loadFalseResult("绑定失败,用户异常请重试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | LogHelper.test(
|
| | | String.format("绑定微信:头像为 %s \n 昵称为 %s", weiXinUser.getHeadimgurl(), weiXinUser.getNickname()));
|
| | |
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | | UserInfo userInfo = userInfoService.getUserByLoginTypeAndOpenId(loginType, wxUnionId, Constant.APPID);
|
| | | if (userInfo != null) {
|
| | | out.print(JsonUtil.loadFalseResult("绑定失败,该微信账户已存在!"));
|
| | | return;
|
| | | }
|
| | | find.setWxName(weiXinUser.getNickname());
|
| | | find.setWxOpenId(weiXinUser.getOpenid());
|
| | | find.setWxUnionId(weiXinUser.getUnionid());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | find.setWxPic(wxHeadImg);
|
| | | } else { // 绑定淘宝
|
| | | LogHelper.test(String.format("绑定淘宝:头像为 %s \n 昵称为 %s", form.getPortrait(), form.getTbName()));
|
| | | UserInfo userInfo = userInfoService.getUserByLoginTypeAndOpenId(loginType, form.getOpenid(),
|
| | | Constant.APPID);
|
| | | if (userInfo != null) {
|
| | | out.print(JsonUtil.loadFalseResult("绑定失败,该淘宝账户已存在!"));
|
| | | return;
|
| | | }
|
| | | find.setOpenid(form.getOpenid());
|
| | | find.setTbName(form.getTbName());
|
| | | find.setTbPic(form.getPortrait());
|
| | | }
|
| | | userInfoService.update(find);
|
| | | out.print(JsonUtil.loadTrueResult(GsonUtil.toJsonExpose(UserUtil.filterForClientUser(find))));
|
| | | }
|
| | |
|
| | | /**
|
| | | * |
| | | * @param data
|
| | | * @param uid
|
| | | * 用户ID
|
| | | * @param type
|
| | | * 需要解绑的账户类型
|
| | | */
|
| | | @RequestMapping("unBindUserInfo")
|
| | | public void unBindUserInfo(AcceptData data, long uid, int type, PrintWriter out) {
|
| | | UserInfo find = userInfoService.getUserById(uid);
|
| | | if (find == null) {
|
| | | out.print(JsonUtil.loadFalseResult("不存在该用户!"));
|
| | | return;
|
| | | }
|
| | | String openid = find.getOpenid();
|
| | | String wxUnionId = find.getWxUnionId();
|
| | | if (Constant.TAOBAO == type) {
|
| | | if (StringUtil.isNullOrEmpty(openid)) {
|
| | | out.print(JsonUtil.loadFalseResult("当前用户未绑定该类型账户!"));
|
| | | return;
|
| | | }
|
| | | } else if (Constant.WEIXIN == type) {
|
| | | if (StringUtil.isNullOrEmpty(wxUnionId)) {
|
| | | out.print(JsonUtil.loadFalseResult("当前用户未绑定该类型账户!"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | int count = 0;
|
| | | if (StringUtil.isNullOrEmpty(openid)) {
|
| | | count++;
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(wxUnionId)) {
|
| | | count++;
|
| | | }
|
| | | if (count == 1) {
|
| | | out.print(JsonUtil.loadFalseResult("当前只绑定了一个账户,不能解绑!"));
|
| | | return;
|
| | | }
|
| | | userInfoService.unBindUserInfo(find, type);
|
| | | out.print(JsonUtil.loadTrueResult("解绑成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户提现账号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getuseraccount", method = RequestMethod.POST)
|
| | | public void getUserAccount(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<BindingAccount> bindingAccountList = bindingAccountService.getBindingAccountByUid(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", user);
|
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
| | |
|
| | | data.put("error", "0");
|
| | | data.put("maxError", 1);
|
| | | String minMoney = configService.get(EXTRACT_MIN_MONEY); // 单笔提现的最小金额
|
| | | String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 单笔提现的最小金额
|
| | | String maxDayMoney = configService.get("extract_money_day"); // 每日最大提现金额
|
| | | int maxDayCount = Integer.parseInt(configService.get("extract_count_day"));
|
| | | ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid);
|
| | | boolean canExtract = true;
|
| | | String errorMsg = "";
|
| | | if (extractRecord != null && extractRecord.getCount() >= maxDayCount) {
|
| | | canExtract = false;
|
| | | errorMsg = String.format("每日最多提现%s次", maxDayCount + "");
|
| | | } else if (extractRecord != null
|
| | | && extractRecord.getMoney().add(new BigDecimal(minMoney)).compareTo(new BigDecimal(maxDayMoney)) > 0) {
|
| | | canExtract = false;
|
| | | errorMsg = String.format("每日最多提现%s元", maxDayMoney);
|
| | | }
|
| | | data.put("canExtract", canExtract);
|
| | | data.put("extractErrorMsg", errorMsg);
|
| | |
|
| | | data.put("minMoney", minMoney);// 单笔最低
|
| | | data.put("maxMoney", maxMoney);// 单笔最高
|
| | | data.put("maxDayCount", maxDayCount);
|
| | | data.put("bindingAccountList", gson.toJson(filterBindingAccount(bindingAccountList)));
|
| | |
|
| | | JSONObject alipayVerify = new JSONObject();
|
| | | try {
|
| | | bindingAccountService.canVerifyAlipayAccount(uid);
|
| | | alipayVerify.put("state", 0);
|
| | | alipayVerify.put("msg", "可绑定");
|
| | | } catch (BindingAccountException e) {
|
| | | alipayVerify.put("state", e.getCode());
|
| | | alipayVerify.put("msg", e.getMsg());
|
| | | }
|
| | |
|
| | | data.put("alipayBindState", alipayVerify);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否能够提现
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "canextract", method = RequestMethod.POST)
|
| | | public void canExtract(AcceptData acceptData, Long uid, BigDecimal money, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (money == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传金额"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String minMoney = configService.get(EXTRACT_MIN_MONEY); // 单笔提现的最小金额
|
| | | String maxDayMoney = configService.get("extract_money_day"); // 每日最大提现金额
|
| | | int maxDayCount = Integer.parseInt(configService.get("extract_count_day"));
|
| | | ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid);
|
| | | boolean canExtract = true;
|
| | | String errorMsg = "";
|
| | | if (extractRecord != null && extractRecord.getCount() + 1 > maxDayCount) {
|
| | | canExtract = false;
|
| | | errorMsg = String.format("每日最多提现%s次", maxDayCount + "");
|
| | | } else if (extractRecord != null
|
| | | && extractRecord.getMoney().add(money).compareTo(new BigDecimal(maxDayMoney)) > 0) {
|
| | | canExtract = false;
|
| | | errorMsg = String.format("每日最多提现%s元", maxDayMoney);
|
| | | } else if (new BigDecimal(minMoney).compareTo(money) > 0) {
|
| | | canExtract = false;
|
| | | errorMsg = String.format("每次最低提现%s元", minMoney);
|
| | | }
|
| | |
|
| | | if (canExtract) {
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(errorMsg));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getalipayaccount", method = RequestMethod.POST)
|
| | | public void getAlipayAccount(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<BindingAccount> bindingAccountList = bindingAccountService.getBindingAccountByUid(uid);
|
| | |
|
| | | if (bindingAccountList == null || bindingAccountList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "尚未绑定支付宝"));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGsonWithDate().toJson(bindingAccountList.get(0))));
|
| | | }
|
| | |
|
| | | public static List<BindingAccount> filterBindingAccount(List<BindingAccount> bindingAccountList) {
|
| | | List<BindingAccount> accountList = new ArrayList<>();
|
| | |
|
| | | if (bindingAccountList != null)
|
| | | for (BindingAccount bindingAccount : bindingAccountList) {
|
| | | BindingAccount dest = new BindingAccount();
|
| | | try {
|
| | | PropertyUtils.copyProperties(dest, bindingAccount);
|
| | | if (!StringUtil.isNullOrEmpty(dest.getAccount()) && !StringUtil.isNullOrEmpty(dest.getName())) {
|
| | | String name = "";
|
| | | if ((dest.getName() + "").length() > 2)
|
| | | for (int i = 0; i < (dest.getName() + "").length(); i++) {
|
| | | if (i == 0)
|
| | | name += dest.getName().charAt(i);
|
| | | else
|
| | | name += "*";
|
| | | }
|
| | | else
|
| | | name = dest.getName().charAt(0) + "*";
|
| | | dest.setName(name);
|
| | |
|
| | | String account = "";
|
| | | if (dest.getAccount().indexOf("@") > -1) {// 邮箱
|
| | | int index = dest.getAccount().indexOf("@");
|
| | |
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 3 || i >= index)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | } else if (StringUtil.isMobile(dest.getAccount())) {// 电话
|
| | | account = dest.getAccount().substring(0, 3) + "*****" + dest.getAccount()
|
| | | .substring(dest.getAccount().length() - 2, dest.getAccount().length());
|
| | |
|
| | | } else {// 其他
|
| | | if (dest.getAccount().length() >= 6) {
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 3 || i >= dest.getAccount().length() - 2)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | } else {
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 1 || i >= dest.getAccount().length() - 1)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | dest.setAccount(account);
|
| | |
|
| | | }
|
| | | accountList.add(dest);
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvocationTargetException e) {
|
| | | e.printStackTrace();
|
| | | } catch (NoSuchMethodException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | return accountList;
|
| | | }
|
| | |
|
| | | public static BindingAccount filterBindingAccount(BindingAccount bindingAccount) {
|
| | | BindingAccount dest = new BindingAccount();
|
| | | try {
|
| | | PropertyUtils.copyProperties(dest, bindingAccount);
|
| | | if (!StringUtil.isNullOrEmpty(dest.getAccount()) && !StringUtil.isNullOrEmpty(dest.getName())) {
|
| | | String name = "";
|
| | | if ((dest.getName() + "").length() > 2)
|
| | | for (int i = 0; i < (dest.getName() + "").length(); i++) {
|
| | | if (i == 0)
|
| | | name += dest.getName().charAt(i);
|
| | | else
|
| | | name += "*";
|
| | | }
|
| | | else
|
| | | name = dest.getName().charAt(0) + "*";
|
| | | dest.setName(name);
|
| | |
|
| | | String account = "";
|
| | | if (dest.getAccount().indexOf("@") > -1) {// 邮箱
|
| | | int index = dest.getAccount().indexOf("@");
|
| | |
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 3 || i >= index)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | } else if (StringUtil.isMobile(dest.getAccount())) {// 电话
|
| | | account = dest.getAccount().substring(0, 3) + "*****"
|
| | | + dest.getAccount().substring(dest.getAccount().length() - 2, dest.getAccount().length());
|
| | |
|
| | | } else {// 其他
|
| | | if (dest.getAccount().length() >= 6) {
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 3 || i >= dest.getAccount().length() - 2)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | } else {
|
| | | for (int i = 0; i < dest.getAccount().length(); i++) {
|
| | | if (i < 1 || i >= dest.getAccount().length() - 1)
|
| | | account += dest.getAccount().charAt(i);
|
| | | else
|
| | | account += "*";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | dest.setAccount(account);
|
| | |
|
| | | }
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvocationTargetException e) {
|
| | | e.printStackTrace();
|
| | | } catch (NoSuchMethodException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return dest;
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 添加用户提现账号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * @param account
|
| | | * 账号
|
| | | * @param name
|
| | | * 真实名字
|
| | | * @param type
|
| | | * 账号类型:1.支付宝 2.微信
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "addbindingaccount", method = RequestMethod.POST)
|
| | | public void addBindingAccount(AcceptData acceptData, long uid, String account, String name, int type,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (Constant.ZHIFUBAO != type && Constant.WEIXIN != type) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE));
|
| | | return;
|
| | | }
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | BindingAccount addAccount = new BindingAccount();
|
| | | addAccount.setAccount(account);
|
| | | addAccount.setType(type);
|
| | | addAccount.setUserInfo(user);
|
| | | addAccount.setName(name);
|
| | | try {
|
| | | bindingAccountService.addBindingAccount(addAccount);
|
| | | } catch (BindingAccountException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMessage()));
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(Constant.BA_SUCCESS));
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除用户提现账号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * @param type
|
| | | * 账号类型
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deletebindingaccount", method = RequestMethod.POST)
|
| | | public void deleteBindingAccount(AcceptData acceptData, long uid, int type, PrintWriter out) {
|
| | |
|
| | | if (type != Constant.ZHIFUBAO && type != Constant.WEIXIN) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | | BindingAccount account = new BindingAccount();
|
| | | account.setType(type);
|
| | | account.setUserInfo(user);
|
| | | Integer deletecount = bindingAccountService.deleteBindingAccount(account);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", deletecount);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新版提现
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param money
|
| | | * @param vcode
|
| | | * 手机验证码
|
| | | * @param request
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "#uid")
|
| | | @RequestMapping(value = "extractmoneynew", method = RequestMethod.POST)
|
| | | public void extractMoneyNew(AcceptData acceptData, long uid, BigDecimal money, String vcode,
|
| | | HttpServletRequest request, int type, PrintWriter out) {
|
| | | UserInfo user = userInfoService.getUserById(uid);
|
| | | if (user == null) {
|
| | | user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | |
|
| | | out.print(JsonUtil.loadFalseResult("用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (money == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传提现金额"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 判断手机验证码的正确性
|
| | | String oldCode = redisManager.getSMSVCode(user.getPhone(), SMSHistory.TYPE_LOGIN);
|
| | | if (StringUtil.isNullOrEmpty(oldCode) || !oldCode.equalsIgnoreCase(vcode)) {
|
| | | out.print(JsonUtil.loadFalseResult(90001, "验证码错误"));
|
| | | return;
|
| | | }
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | LogHelper.userInfo("提现时,不存在该系统");
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String minMoney = configService.get(EXTRACT_MIN_MONEY); // 单笔提现最小金额
|
| | |
|
| | | if (money.compareTo(new BigDecimal("0.1")) < 0) { // 转帐到支付宝的最小金额
|
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额需要大于:" + 0.1 + "元"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (money.compareTo(new BigDecimal(minMoney)) < 0) { // 后台设置的单笔转账的最小金额
|
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额需要大于:" + minMoney + "元"));
|
| | | return;
|
| | | }
|
| | | String maxMoney = configService.get(EXTRACT_MAX_MONEY); // 单笔提现最大金额
|
| | | if (new BigDecimal(maxMoney).compareTo(money) < 0) { // 后台设置的单笔转账的最大金额
|
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额多为:" + maxMoney + "元"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (type != Constant.ZHIFUBAO && type != Constant.WEIXIN) { // 提现类型必须是支付宝类型或者微信类型,目前(20170506)仅支持支付宝
|
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE));
|
| | | return;
|
| | | }
|
| | |
|
| | | BindingAccount bindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid, type);
|
| | | if (bindingAccount == null) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.NOACCOUNT));
|
| | | return;
|
| | | }
|
| | |
|
| | | Extract extract = new Extract();
|
| | | extract.setIp(IPUtil.getRemotIP(request));
|
| | | extract.setAccount(bindingAccount.getAccount());
|
| | | extract.setName(bindingAccount.getName());
|
| | | extract.setMoney(new BigDecimal(String.valueOf(money)));
|
| | | extract.setUserInfo(user);
|
| | | extract.setExtractTime(java.lang.System.currentTimeMillis());
|
| | | extract.setType(type);
|
| | | extract.setState(0);
|
| | | extract.setSystem(system);
|
| | | Integer etype = extractService.addExtract(extract);
|
| | | if (etype == null) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("id", extract.getId());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | JSONObject json = new JSONObject();
|
| | | json.put("timeStamp", java.lang.System.currentTimeMillis());
|
| | | json.put("adminId", 4L);
|
| | | String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY);
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("%s?from=emailh5&sign=%s",
|
| | | Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | long[] targetUids = new long[] { 3L, 4L };
|
| | | Config config = configService.getConfig("extract_code_email_from");
|
| | | String[] sts = config.getValue().split(",");
|
| | | String account = sts[0];
|
| | | String pwd = sts[1];
|
| | | for (long adminId : targetUids) {
|
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId);
|
| | | String msg = "提现审核链接:" + url;
|
| | | boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的提现审核", msg);
|
| | | }
|
| | | }
|
| | | });
|
| | | return;
|
| | | } else if (etype == 1) {
|
| | | out.print(JsonUtil.loadFalseResult("已超过当日提现次数"));
|
| | | } else if (etype == 2) {
|
| | | out.print(JsonUtil.loadFalseResult("已超过当日提现金额"));
|
| | | } else if (etype == 3) {
|
| | | out.print(JsonUtil.loadFalseResult("提现金额大于我的红包"));
|
| | | } else if (etype == 111) {
|
| | | out.print(JsonUtil.loadFalseResult("修改手机号后,7天内无法提现"));
|
| | | } else if (etype == 110) {
|
| | | out.print(JsonUtil.loadFalseResult("有售后订单尚未扣款"));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取提现进度
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getextractprocess", method = RequestMethod.POST)
|
| | | public void getExtractProcess(AcceptData acceptData, long id, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("请上传用户ID"));
|
| | | return;
|
| | | }
|
| | | Extract extract = extractService.getExtractById(id);
|
| | | if (extract == null) {
|
| | | out.print(JsonUtil.loadFalseResult("提现记录不存在"));
|
| | | return;
|
| | | }
|
| | | if (extract.getUserInfo().getId().longValue() != uid) {
|
| | | out.print(JsonUtil.loadFalseResult("不属于当前用户的提现记录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | BindingAccount account = new BindingAccount();
|
| | | account.setAccount(extract.getAccount());
|
| | | account.setName(extract.getName());
|
| | | List<BindingAccount> bindingAccountList = new ArrayList<>();
|
| | | bindingAccountList.add(account);
|
| | | bindingAccountList = filterBindingAccount(bindingAccountList);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("id", extract.getId());
|
| | | data.put("money", "¥" + extract.getMoney().toString());
|
| | | data.put("account", bindingAccountList.get(0).getAccount());
|
| | | data.put("expireTime",
|
| | | TimeUtil.getGernalTime(extract.getExtractTime() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd HH:mm"));// 24小时后到账
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("findLostOrder")
|
| | | public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, PrintWriter out) {
|
| | | boolean orderNum = true;
|
| | |
|
| | | if (!NumberUtil.isNumeric(lostOrder.getOrderId())) {
|
| | | orderNum = false;
|
| | | } else if (lostOrder.getOrderId().length() < 12 || lostOrder.getOrderId().length() > 20) {
|
| | | orderNum = false;
|
| | | } else
|
| | | orderNum = Utils.isOrderNum(lostOrder.getOrderId());
|
| | |
|
| | | int state;
|
| | | String stateInfo = "提交成功,请等待审核结果。";
|
| | | if (!orderNum) {
|
| | | state = -4;
|
| | | stateInfo = "请提交标准的订单号";
|
| | | } else {
|
| | | state = lostOrderService.addLostOrder(lostOrder);
|
| | | if (state == -3) {
|
| | | stateInfo = "该订单已是返利订单。";
|
| | | } else if (state == -2) {
|
| | | stateInfo = "请勿重复提交,该订单已在审核中。";
|
| | | } else if (state == -1) {
|
| | | stateInfo = "该订单申诉已通过,请稍后查看。";
|
| | | } else if (state == -5) {
|
| | | stateInfo = "该订单为分享奖金订单";
|
| | | }
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("state", state);
|
| | | data.put("info", stateInfo);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("findOrderItemList")
|
| | | public void findOrderItemList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | | List<HongBaoOrder> list = hongBaoOrderService.listFanLiOrder(uid, page, Constant.PAGE_SIZE);
|
| | |
|
| | | List<OrderItem> orderList = new ArrayList<>();
|
| | | for (HongBaoOrder oi : list) {
|
| | | OrderItem orderItem = OrderItemFactory.create(oi);
|
| | | orderItem.setDesc();
|
| | | orderItem.setPicture(TbImgUtil.getTBSize220Img(orderItem.getPicture()));
|
| | | orderList.add(orderItem);
|
| | | }
|
| | | long count = hongBaoOrderService.countFanLiOrder(uid);
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().create();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", gson.toJson(orderList));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取提成订单列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getTiChengOrderList")
|
| | | public void getTiChengOrderList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | | List<HongBaoDTO> hongBaoDTOList = hongBaoV2Service.listJiangJinByUid(uid, page, Constant.PAGE_SIZE);
|
| | | List<HongBao> list = new ArrayList<>();
|
| | | if (hongBaoDTOList != null)
|
| | | for (HongBaoDTO dto : hongBaoDTOList) {
|
| | | list.add(HongBaoFactory.createHongBao(dto));
|
| | | }
|
| | | long count = hongBaoV2Service.countJiangJinByUid(uid);
|
| | | List<OrderItem> orderItemList = HongBaoUtil.convertToTiChengOrder(list);
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", gson.toJson(orderItemList));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("findAccountMessageList")
|
| | | public void findAccountMessageList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | | accountMessageService.syncSystemZnx(uid);
|
| | | List<AccountMessage> list = accountMessageService.findAccountMessageList(uid, page);
|
| | | int count = accountMessageService.getCount(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", GsonUtil.toJsonExpose(list));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("openAccountMessage")
|
| | | public void openAccountMessage(AcceptData acceptData, long id, PrintWriter out) {
|
| | | accountMessageService.open(id);
|
| | | out.print(JsonUtil.loadTrueResult("打开成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping("findCanOpenMessage")
|
| | | public void findCanOpenMessage(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | accountMessageService.syncSystemZnx(uid);
|
| | | // count>0 有消息
|
| | | int count = accountMessageService.getCanOpenCount(uid);
|
| | | out.print(JsonUtil.loadTrueResult(count));
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 用户等级更新
|
| | | try {
|
| | | userInfoExtraService.updateUserRankByUid(uid);
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | @RequestMapping("collectionGoods")
|
| | | public void collectionGoods(AcceptData acceptData, long uid, long auctionId, int type, PrintWriter out) {
|
| | | try {
|
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId,
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | if (type == 1) {
|
| | | if (find != null) {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief);
|
| | | out.print(JsonUtil.loadTrueResult("收藏成功"));
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架"));
|
| | | }
|
| | | } else {
|
| | | if (find == null) {
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | return;
|
| | | } else {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | }
|
| | | }
|
| | | } catch (CollectionGoodsException e1) {
|
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * h5收藏
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("collectionGoodsJp")
|
| | | public void collectionGoodsJp(String callback, AcceptData acceptData, Long uid, Long auctionId, Integer goodsType,
|
| | | PrintWriter out) {
|
| | |
|
| | | if (uid == null || auctionId == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == null) {
|
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | }
|
| | |
|
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId, goodsType);
|
| | |
|
| | | if (find == null) {
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | |
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | |
|
| | | } else {
|
| | | try {
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1));
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | JsonUtil.printMode(out, callback, (JsonUtil.loadFalseResult(1, "商品已下架")));
|
| | | } catch (CollectionGoodsException e1) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg()));
|
| | | }
|
| | | }
|
| | | } else {
|
| | | // 取消收藏
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId, goodsType);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | } catch (CollectionGoodsException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping("collectionGoodsList")
|
| | | public void collectionGoodsList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | |
|
| | | List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1,
|
| | | Constant.PAGE_SIZE, Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>();
|
| | |
|
| | | long count = collectionGoodsV2Service.getCollectionGoodsCount(uid, Constant.SOURCE_TYPE_TAOBAO);
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = new ArrayList<TaoBaoGoodsBrief>();
|
| | | if (collectionGoodsList != null && collectionGoodsList.size() > 0) {
|
| | |
|
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate();
|
| | |
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
|
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(commonGoods.getGoodsId());
|
| | | }
|
| | |
|
| | | try {
|
| | | // API网络接口验证是否在售
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
|
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
|
| | | int state = 1; // 默认停售
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | state = 0; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | | commonGoods.setState(state);
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day()));
|
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief,
|
| | | proportion.toString(), "");
|
| | | taoBaoGoodsBriefExtra.setCreatetime(collectionGoodsV2.getCreateTime());
|
| | |
|
| | | list.add(taoBaoGoodsBriefExtra);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(value.getTime() + "");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(builder).excludeFieldsWithoutExposeAnnotation()
|
| | | .create();
|
| | | data.put("list", gson.toJson(list));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("deleteCollectionGoods")
|
| | | public void deleteCollectionGoods(AcceptData acceptData, String ids, Integer type, long uid, Integer goodsType,
|
| | | PrintWriter out) {
|
| | | if (type != null && type == 1) {
|
| | | clearConllectionGoods(acceptData, uid, out);
|
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(ids)) {
|
| | | Arrays.asList(ids.split(",")).parallelStream().forEach(auctionIdStr -> {
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, Long.parseLong(auctionIdStr),
|
| | | goodsType);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping("clearConllectionGoods")
|
| | | public void clearConllectionGoods(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByUid(uid);
|
| | | } catch (CollectionGoodsException e) {
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | | @RequestMapping("ruleMessage")
|
| | | public void ruleMessage(AcceptData acceptData, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("rank3", String.format("成功邀请50个好友完成注册安装%sAPP(包括一度好友和二度好友之和)",
|
| | | Constant.systemCommonConfig.getProjectChineseName()));
|
| | | data.put("rank2", String.format("成功邀请5个好友完成注册安装%sAPP(包括一度好友和二度好友之和)",
|
| | | Constant.systemCommonConfig.getProjectChineseName()));
|
| | | data.put("rank1", String.format("成功邀请1个好友完成注册安装%sAPP(包括一度好友和二度好友之和)",
|
| | | Constant.systemCommonConfig.getProjectChineseName()));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("findAccountDetailsList")
|
| | | public void findAccountDetailsList(AcceptData acceptData, long uid, int page, PrintWriter out) {
|
| | | List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE);
|
| | | List<AccountDetails> list = new ArrayList<>();
|
| | | for (UserMoneyDetail detail : detailList)
|
| | | list.add(AccountDetailsFactory.create(detail));
|
| | | long count = userMoneyDetailService.countByUidWithState(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", GsonUtil.toJsonExpose(list));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping("findAccountDetailsListV2")
|
| | | public void findAccountDetailsListNew(AcceptData acceptData, Long uid, int page, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "UID为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE);
|
| | |
|
| | | List<AccountDetails> list = new ArrayList<>();
|
| | | for (UserMoneyDetail detail : detailList)
|
| | | list.add(AccountDetailsFactory.create(detail));
|
| | |
|
| | | long count = userMoneyDetailService.countByUidWithState(uid);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | for (AccountDetails ad : list) {
|
| | | JSONObject item = JSONObject.fromObject(GsonUtil.toJsonExpose(ad));
|
| | | if (ad.getState() != null && ad.getState() != -1)
|
| | | item.put("stateIcon",
|
| | | "http://hcj-1255749512.file.myqcloud.com/resource/app/extract_state_" + ad.getState() + ".png");
|
| | | array.add(item);
|
| | | }
|
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | // 获取商品分享链接
|
| | | @RequestMapping(value = "getGoodsShareUrl")
|
| | | public void getGoodsShareUrl(AcceptData acceptData, long id, PrintWriter out) {
|
| | | out.print(JsonUtil
|
| | | .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl())));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员列表查询 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMyTeam", method = RequestMethod.POST)
|
| | | public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | | if (type == 1) {
|
| | | resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid, null);
|
| | | } else if (type == 2) {
|
| | | resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid, null);
|
| | | }
|
| | |
|
| | | // 安卓系统返回所有数据
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equalsIgnoreCase(platform)) {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | |
|
| | | JSONObject bossData = null;
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | bossData = new JSONObject();
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | }
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
|
| | | }
|
| | |
|
| | | String helpLink = configService.get("team_help_url");
|
| | | if (helpLink == null) {
|
| | | helpLink = "";
|
| | | }
|
| | |
|
| | | boolean hasCode = false;
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (inviteCode != null && inviteCode.trim().length() > 0) {
|
| | | hasCode = true; // 已有邀请码
|
| | | } else {
|
| | | // 邀请激活链接
|
| | | resultData.put("activationlink", configService.get("invite_activation_url"));
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | |
|
| | | resultData.put("helpLink", helpLink);
|
| | | resultData.put("firstTeam", firstTeam);
|
| | | resultData.put("firstTeamTotal", firstTeamTotal);
|
| | | resultData.put("secondTeam", secondTeam);
|
| | | resultData.put("secondTeamTotal", secondTeamTotal);
|
| | | resultData.put("boss", bossData);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员列表查询 1.5.3查询有效队员
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getMyTeamNew", method = RequestMethod.POST)
|
| | | public void getMyTeamNew(AcceptData acceptData, long page, long uid, long type, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | | if (type == 1) {
|
| | | resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid, 1);
|
| | | } else if (type == 2) {
|
| | | resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid, 1);
|
| | | }
|
| | |
|
| | | // 安卓系统返回所有数据
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equalsIgnoreCase(platform)) {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | |
|
| | | JSONObject bossData = null;
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | bossData = new JSONObject();
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | }
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
|
| | | }
|
| | |
|
| | | String helpLink = configService.get("team_help_url");
|
| | | if (helpLink == null) {
|
| | | helpLink = "";
|
| | | }
|
| | |
|
| | | boolean hasCode = false;
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (inviteCode != null && inviteCode.trim().length() > 0) {
|
| | | hasCode = true; // 已有邀请码
|
| | | } else {
|
| | | // 邀请激活链接
|
| | | resultData.put("activationlink", configService.get("invite_activation_url"));
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | |
|
| | | resultData.put("helpLink", helpLink);
|
| | | resultData.put("firstTeam", firstTeam);
|
| | | resultData.put("secondTeam", secondTeam);
|
| | | resultData.put("boss", bossData);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员统计 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
|
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | try {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | |
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | long secondTeamTotal = threeSaleSerivce.countSecondTeam(uid, null);
|
| | | JSONObject bossData = new JSONObject();
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null) {
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | if (boss != null) {
|
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | }
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime));
|
| | | }
|
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | |
|
| | | String helpLink = configService.get("team_help_url");
|
| | | if (helpLink == null) {
|
| | | helpLink = "";
|
| | | }
|
| | | resultData.put("helpLink", helpLink);
|
| | | resultData.put("firstTeam", firstTeam);
|
| | | resultData.put("firstTeamTotal", firstTeamTotal);
|
| | | resultData.put("secondTeam", secondTeam);
|
| | | resultData.put("secondTeamTotal", secondTeamTotal);
|
| | | resultData.put("boss", bossData);
|
| | |
|
| | | boolean hasCode = false;
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (inviteCode != null && inviteCode.trim().length() > 0) {
|
| | | hasCode = true; // 已有邀请码
|
| | | } else {
|
| | | // 邀请激活链接
|
| | | resultData.put("activationlink", configService.get("invite_activation_url"));
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户队员信息保存 1.4.1
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId
|
| | | * 邀请id
|
| | | * @param nickname
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setextrainfo", method = RequestMethod.POST)
|
| | | public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String memoName, PrintWriter out) {
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, null);
|
| | | if (listThreeSale == null || listThreeSale.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("该记录不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo worker = listThreeSale.get(0).getWorker();
|
| | | if (worker == null) {
|
| | | out.print(JsonUtil.loadFalseResult("该记录不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, worker.getId());
|
| | | if (extraInfo == null) {
|
| | | extraInfo = new ThreeSaleExtraInfo();
|
| | | extraInfo.setWorker(worker);
|
| | | extraInfo.setNickname(memoName);
|
| | | extraInfo.setCreateTime(new Date());
|
| | | extraInfo.setUpdateTime(new Date());
|
| | | extraInfo.setBoss(new UserInfo(uid));
|
| | | threeSaleExtraInfoSerivce.insertSelective(extraInfo);
|
| | | } else {
|
| | | ThreeSaleExtraInfo updateInfo = new ThreeSaleExtraInfo();
|
| | | updateInfo.setId(extraInfo.getId());
|
| | | updateInfo.setNickname(memoName);
|
| | | updateInfo.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(updateInfo);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除队员关系
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId
|
| | | * 邀请id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "removethreesale", method = RequestMethod.POST)
|
| | | public void removethreesale(AcceptData acceptData, long uid, long inviteId, PrintWriter out) {
|
| | | try {
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.listbyIdAndBossId(inviteId, uid, 1);
|
| | | if (listThreeSale == null || listThreeSale.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("操作数据无效"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo worker = listThreeSale.get(0).getWorker();
|
| | | if (worker == null) {
|
| | | out.print(JsonUtil.loadFalseResult("操作数据无效"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 删除关系
|
| | | threeSaleSerivce.deleteByPrimaryKey(inviteId);
|
| | | // 删除备注
|
| | | threeSaleExtraInfoSerivce.deleteByBossIdAndWorkerId(uid, worker.getId());
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置界面开关状态
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param params
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setModuleState", method = RequestMethod.POST)
|
| | | public void setModuleState(AcceptData acceptData, Long uid, String params, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | if (params == null || params.trim().length() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("传递参数为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject json = JSONObject.fromObject(params);
|
| | | Iterator<String> iterator = json.keys();
|
| | | while (iterator.hasNext()) {
|
| | | String type = (String) iterator.next();
|
| | | int state = json.getInt(type);
|
| | | userCustomSettingsService.saveModuleState(uid, type, state);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("设置成功"));
|
| | |
|
| | | } catch (UserCustomSettingsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("设置失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取等级信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRankInfo", method = RequestMethod.POST)
|
| | | public void getRankInfo(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | UserInfoExtraVO rankInfo = userInfoExtraService.getRankInfo(uid);
|
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
|
| | | gsonBuilder.excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy.MM.dd").create();
|
| | |
|
| | | JSONObject resultData = new JSONObject();
|
| | | resultData.put("rankInfo", gson.toJson(rankInfo));
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | |
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取等级信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getUserConfig", method = RequestMethod.POST)
|
| | | public void getUserConfig(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | JSONObject inviteData = new JSONObject();
|
| | | if (inviteCode == null || inviteCode.trim().length() == 0) {
|
| | | // 无邀请码
|
| | | inviteData.put("content", "邀请激活");
|
| | | inviteData.put("link", configService.get("invite_activation_url"));
|
| | | } else {
|
| | | // 已有邀请码
|
| | | inviteData.put("content", "邀请码");
|
| | | inviteData.put("link", configService.get("invite_activation_success_url"));
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("invite", inviteData);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取用户信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param form
|
| | | * @param requst
|
| | | * @param out
|
| | | */
|
| | | @UserActive(uid = "#uid")
|
| | | @RequestMapping(value = "getuserinfoNew", method = RequestMethod.POST)
|
| | | public void getuserinfoNew(AcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) {
|
| | | try {
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult("系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("请求参数为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.getUserInfo(uid);
|
| | |
|
| | | // 添加用户活跃记录
|
| | | UserActiveLog userActiveLog = new UserActiveLog();
|
| | | userActiveLog.setChannel(acceptData.getChannel());
|
| | | userActiveLog.setIp(requst.getRemoteHost());
|
| | | userActiveLog.setUid(userInfo.getId());
|
| | | userActiveLog.setVersionCode(acceptData.getVersion());
|
| | | userActiveLog.setOsVersion(acceptData.getOsVersion());
|
| | | userActiveLog.setDeviceType(acceptData.getDeviceType());
|
| | | userActiveLog.setDevice(acceptData.getDevice());
|
| | | userActiveLogService.addUserActiveLog(userActiveLog);
|
| | |
|
| | | // 处理用户信息
|
| | | outUserInfoHandle(userInfo);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | JSONObject data = new JSONObject();
|
| | | // 界面状态
|
| | | UserSettingsVO mySettings = null;
|
| | | try {
|
| | | mySettings = userCustomSettingsService.getMySettings(uid);
|
| | | } catch (UserCustomSettingsException e) {
|
| | | mySettings = new UserSettingsVO();
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (mySettings.getCancelNotice() == null) {
|
| | | mySettings.setCancelNotice(0);
|
| | | }
|
| | | if (mySettings.getNoBonusCount() == null) {
|
| | | mySettings.setNoBonusCount(0);
|
| | | }
|
| | | if (mySettings.getNoNewsRedDot() == null) {
|
| | | mySettings.setNoNewsRedDot(0);
|
| | | }
|
| | | if (mySettings.getNoShareRecordAndStorage() == null) {
|
| | | mySettings.setNoShareRecordAndStorage(0);
|
| | | }
|
| | | if (mySettings.getNoInvitationBonus() == null) {
|
| | | mySettings.setNoInvitationBonus(0);
|
| | | }
|
| | |
|
| | | if (mySettings.getOpenSpreadHongBao() == null) {
|
| | | if (userTaoLiJinDetailService.countDetail(uid) > 0) {
|
| | | mySettings.setOpenSpreadHongBao(1);
|
| | | } else {
|
| | | mySettings.setOpenSpreadHongBao(0);
|
| | | }
|
| | | }
|
| | | data.put("moduleState", mySettings);
|
| | |
|
| | | int tailor = 0;
|
| | | int welfareCenterNews = 0;
|
| | | String invitCode = null;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (userInfoExtra.getCouponNews() != null) {
|
| | | welfareCenterNews = userInfoExtra.getCouponNews();
|
| | | }
|
| | | // vip邀请码优先
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) {
|
| | | tailor = 1;
|
| | | invitCode = userInfoExtra.getInviteCodeVip();
|
| | | } else if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | tailor = 2;
|
| | | invitCode = userInfoExtra.getInviteCode();
|
| | | }
|
| | | |
| | | if (userInfoExtra.getUserRank() != null) {
|
| | | String picture = userInfoExtra.getUserRank().getPicture();
|
| | | String icon = userInfoExtra.getUserRank().getIcon();
|
| | | userInfo.setRankNamePicture(picture);
|
| | | userInfo.setRankIcon(icon);
|
| | | } else {
|
| | | userInfo.setRankNamePicture(null);
|
| | | userInfo.setRankIcon(null);
|
| | | }
|
| | |
|
| | | // 1.6.5 之后返回性别、微信号
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | if (userInfoExtra.getSex() != null)
|
| | | userInfo.setSex(userInfoExtra.getSex());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
|
| | | userInfo.setWeiXin(userInfoExtra.getWeiXin());
|
| | | }
|
| | | |
| | | data.put("erCode", userInfoExtra.getErCode());
|
| | | }
|
| | | // 1.6.5 之后返回 微信号提示
|
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | userInfo.setWeiXinTip("添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。");
|
| | |
|
| | | // 查询是否为VIP
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | userInfo.setVip(userVIPInfoService.isVIP(uid));
|
| | | }
|
| | |
|
| | | data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo));
|
| | | data.put("invitCode", invitCode); // 邀请码
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip()))
|
| | | data.put("invitCodeUpdated", true);// 邀请码是否已经修改过
|
| | | else
|
| | | data.put("invitCodeUpdated", false);
|
| | | data.put("welfareCenterNews", welfareCenterNews);// 福利中心消息
|
| | | data.put("vipLink", configService.get("vip_link"));// 超级会员升级链接
|
| | |
|
| | | // 2.0.1之后绑定手机号
|
| | | if (VersionUtil.greaterThan_2_0_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | boolean bindPhone = false;
|
| | | if (StringUtil.isNullOrEmpty(userInfo.getPhone()))
|
| | | bindPhone = bindRemindService.bindRemind(uid, BindRemind.TYPE_PHONE);
|
| | | data.put("bindPhone", bindPhone);
|
| | | }
|
| | |
|
| | | // 2.0.2 版本
|
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | boolean verifyForbid = redPackForbidService.verifyForbid(uid);
|
| | | data.put("redPackLock", verifyForbid);
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(invitCode)) {
|
| | | // 2.0.6 返回邀请人
|
| | | if (VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | String bossName = "";
|
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid);
|
| | | if (threeSale != null && threeSale.getBoss() != null) {
|
| | | bossName = threeSale.getBoss().getNickName();
|
| | | }
|
| | | data.put("bossName", bossName);
|
| | | |
| | | if(tailor == 2) {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | if (firstTeam >= 2) {
|
| | | data.put("tailor", true);
|
| | | }
|
| | | } else {
|
| | | data.put("tailor", false);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | final UserInfo uuser = userInfo;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 获取邀请码:若无邀请码且存在有效的队员关系 则自动生成邀请码
|
| | | userInfoExtraService.getInviteCodeByUid(uuser.getId());
|
| | |
|
| | | // 更新用户附加信息,老用户不存在的需要添加
|
| | | try {
|
| | | userInfoExtraService.updateUserRankByUid(uuser.getId());
|
| | | } catch (UserInfoExtraException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | } catch (UserInfoException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | private void outUserInfoHandle(UserInfo user) {
|
| | |
|
| | | // 红包处理
|
| | | user.setTotalHongBao(new BigDecimal(0));
|
| | | user.setNoOpenHongBao(new BigDecimal(0));
|
| | | user.setCanOpenHongBao(new BigDecimal(0));
|
| | |
|
| | | // 电话号码处理
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) {
|
| | | if (user.getPhone().length() > 5) {
|
| | | String phone = user.getPhone().substring(0, 3);
|
| | | phone += "******";
|
| | | phone += user.getPhone().substring(user.getPhone().length() - 2, user.getPhone().length());
|
| | | user.setPhone(phone);
|
| | | }
|
| | | }
|
| | |
|
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
|
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
|
| | | String picture = userInfoExtra.getUserRank().getPicture();
|
| | | String icon = userInfoExtra.getUserRank().getIcon();
|
| | | user.setRankNamePicture(picture);
|
| | | user.setRankIcon(icon);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 用户更换头像
|
| | | * |
| | | * @param acceptData
|
| | | * @param fileList
|
| | | * @param uid
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "uploadPortrait")
|
| | | public void uploadPortrait(AcceptData acceptData, MultipartFile file, Long uid, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | userInfoService.uploadPortrait(file, uid);
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | |
|
| | | } catch (UserInfoException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("图片上传失败失败"));
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("保存失败"));
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更换基础信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param nickName
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveInfo")
|
| | | public void saveInfo(AcceptData acceptData, String nickName, String weiXin, Integer sex, Long uid,
|
| | | String inviteCode, MultipartFile qrCodeFile, PrintWriter out) {
|
| | | try {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 修改昵称
|
| | | if (!StringUtil.isNullOrEmpty(nickName)) {
|
| | | if (nickName.length() > 200) {
|
| | | out.print(JsonUtil.loadFalseResult("昵称过长"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (maskKeyService.examineContent(nickName)) {
|
| | | out.print(JsonUtil.loadFalseResult("不能包含敏感词汇"));
|
| | | return;
|
| | | }
|
| | | userInfoService.saveUserInfo(nickName, uid);
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.nickName, nickName);
|
| | | }
|
| | |
|
| | | // 修改微信号
|
| | | if (!StringUtil.isNullOrEmpty(weiXin)) {
|
| | | if (weiXin.length() > 32) {
|
| | | out.print(JsonUtil.loadFalseResult("微信号过长"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | UserInfoExtra extra = new UserInfoExtra();
|
| | | extra.setId(userInfoExtra.getId());
|
| | | extra.setWeiXin(weiXin);
|
| | | userInfoExtraService.saveUserInfoExtra(extra);
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.setWeiXinNum, weiXin);
|
| | | }
|
| | | }
|
| | |
|
| | | // 修改性别
|
| | | if (sex != null && sex > 0 && sex < 3) {
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | UserInfoExtra extra = new UserInfoExtra();
|
| | | extra.setId(userInfoExtra.getId());
|
| | | extra.setSex(sex);
|
| | | userInfoExtraService.saveUserInfoExtra(extra);
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.gender, sex + "");
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {// 邀请码不为空
|
| | | inviteCode = inviteCode.trim();
|
| | | if (inviteCode.length() >= 4 && inviteCode.length() <= 12) {
|
| | |
|
| | | if (!userVIPInfoService.isVIP(uid)) {
|
| | | out.print(JsonUtil.loadFalseResult(20, "只有超级会员才能修改"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | userInfoExtraService.updateInviteCodeVip(inviteCode, uid);
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | return;
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(1, "邀请码必须为4到12位"));
|
| | | return;
|
| | | }
|
| | | }
|
| | | |
| | | // 二维码
|
| | | if (qrCodeFile != null) {
|
| | | userInfoExtraService.uploadERCode(qrCodeFile, uid);
|
| | | }
|
| | | |
| | | |
| | | |
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (UserInfoException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("保存失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v1; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Type; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.entity.bus.user.*; |
| | | import com.yeshi.fanli.exception.user.*; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.GsonUtil; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import org.apache.commons.beanutils.PropertyUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.yeshi.utils.*; |
| | | import org.yeshi.utils.entity.wx.WeiXinUser; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | | |
| | | 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.HongBao; |
| | | import com.yeshi.fanli.dto.HongBaoDTO; |
| | | import com.yeshi.fanli.dto.money.AccountDetails; |
| | | import com.yeshi.fanli.dto.order.OrderItem; |
| | | import com.yeshi.fanli.dto.user.UserInviteLevelEnum; |
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO; |
| | | import com.yeshi.fanli.entity.AppVersionInfo; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.PreviewInfo.PreviewEnum; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; |
| | | import com.yeshi.fanli.entity.bus.user.vip.GiveVIPApplyInfo; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.common.AdminUser; |
| | | import com.yeshi.fanli.entity.common.Config; |
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra; |
| | | import com.yeshi.fanli.exception.goods.CollectionGoodsException; |
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.log.LogHelper; |
| | | import com.yeshi.fanli.service.AdminUserService; |
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service; |
| | | import com.yeshi.fanli.service.inter.config.AppVersionService; |
| | | 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.goods.CollectionGoodsV2Service; |
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService; |
| | | import com.yeshi.fanli.service.inter.money.extract.BindingAccountService; |
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractRecordService; |
| | | import com.yeshi.fanli.service.inter.money.extract.ExtractService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service; |
| | | import com.yeshi.fanli.service.inter.order.LostOrderService; |
| | | import com.yeshi.fanli.service.inter.order.OrderService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService; |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackForbidService; |
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinDetailService; |
| | | import com.yeshi.fanli.service.inter.user.AccountMessageService; |
| | | import com.yeshi.fanli.service.inter.user.BindRemindService; |
| | | import com.yeshi.fanli.service.inter.user.MaskKeyService; |
| | | import com.yeshi.fanli.service.inter.user.PreviewInfoService; |
| | | import com.yeshi.fanli.service.inter.user.ShamUserService; |
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService; |
| | | import com.yeshi.fanli.service.inter.user.UserAccountService; |
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService; |
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.inter.user.UserRankService; |
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService; |
| | | import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService; |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleExtraInfoSerivce; |
| | | 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.vip.GiveVIPApplyInfoService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService; |
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager; |
| | | import com.yeshi.fanli.util.account.UserUtil; |
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey; |
| | | import com.yeshi.fanli.util.annotation.UserActive; |
| | | import com.yeshi.fanli.util.email.MailSenderUtil; |
| | | import com.yeshi.fanli.util.factory.AccountDetailsFactory; |
| | | import com.yeshi.fanli.util.factory.HongBaoFactory; |
| | | import com.yeshi.fanli.util.factory.OrderItemFactory; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.util.wx.MyWXLoginUtil; |
| | | import com.yeshi.fanli.vo.user.MineInfoVO; |
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO; |
| | | import com.yeshi.fanli.vo.user.UserSettingsVO; |
| | | |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v1/customer") |
| | | public class UserInfoController { |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private BindingAccountService bindingAccountService; |
| | | |
| | | @Resource |
| | | private ExtractService extractService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | |
| | | @Resource |
| | | private ThreeSaleSerivce threeSaleSerivce; |
| | | |
| | | @Resource |
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce; |
| | | |
| | | @Resource |
| | | private LostOrderService lostOrderService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | @Resource |
| | | private ExtractRecordService extractRecordService; |
| | | |
| | | @Resource |
| | | private UserActiveLogService userActiveLogService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private AdminUserService adminUserService; |
| | | |
| | | @Resource |
| | | private UserMoneyDetailService userMoneyDetailService; |
| | | |
| | | @Resource |
| | | private HongBaoOrderService hongBaoOrderService; |
| | | |
| | | @Resource |
| | | private HongBaoV2Service hongBaoV2Service; |
| | | |
| | | @Resource |
| | | private SpreadUserImgService spreadUserImgService; |
| | | |
| | | @Resource |
| | | private UserShareGoodsRecordService userShareGoodsRecordService; |
| | | |
| | | @Resource |
| | | private UserCustomSettingsService userCustomSettingsService; |
| | | |
| | | @Resource |
| | | private UserInfoExtraService userInfoExtraService; |
| | | |
| | | @Resource |
| | | private AppVersionService appVersionService; |
| | | |
| | | |
| | | @Resource |
| | | private AccountMessageService accountMessageService; |
| | | |
| | | @Resource |
| | | private MaskKeyService maskKeyService; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinDetailService userTaoLiJinDetailService; |
| | | |
| | | @Resource |
| | | private UserInfoModifyRecordService userInfoModifyRecordService; |
| | | |
| | | @Resource |
| | | private BindRemindService bindRemindService; |
| | | |
| | | @Resource |
| | | private UserVIPInfoService userVIPInfoService; |
| | | |
| | | @Resource |
| | | private UserVipConfigService userVipConfigService; |
| | | |
| | | @Resource |
| | | private RedPackForbidService redPackForbidService; |
| | | |
| | | @Resource |
| | | private UserInviteService userInviteService; |
| | | |
| | | @Resource |
| | | private TeamFansInfoService teamFansInfoService; |
| | | |
| | | @Resource |
| | | private UserLevelManager userLevelManager; |
| | | |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | |
| | | @Resource |
| | | private GiveVIPApplyInfoService giveVIPApplyInfoService; |
| | | |
| | | @Resource |
| | | private PreviewInfoService previewInfoService; |
| | | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | private static final String EXTRACT_MIN_MONEY = ConfigKeyEnum.extractMoneyMin.getKey(); |
| | | private static final String EXTRACT_MAX_MONEY = ConfigKeyEnum.extractMoneyMAX.getKey(); |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @param acceptData |
| | | * @param form |
| | | * @param requst |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getuserinfo", method = RequestMethod.POST) |
| | | public void getUserInfo(AcceptData acceptData, UserInfo form, String code, String create, boolean first, |
| | | HttpServletRequest requst, PrintWriter out) { |
| | | String remotIP = IPUtil.getRemotIP(requst); |
| | | long id = form.getId(); |
| | | // 判断是不是用ID登陆的,如果是用ID登陆的其他都不要管了 |
| | | if (id != 0) { |
| | | UserInfo find = userInfoService.getUserByIdWithMybatis(id); |
| | | // ThreadUtil.run(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // threeSaleSerivce.effective(find); |
| | | // } |
| | | // }); |
| | | if (find != null) { |
| | | if (find.getState() != UserInfo.STATE_NORMAL) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, |
| | | Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | |
| | | // 邀请关系生效 |
| | | threeSaleSerivce.effective(find); |
| | | |
| | | // 添加用户活跃记录 |
| | | UserActiveLog userActiveLog = new UserActiveLog(); |
| | | userActiveLog.setChannel(acceptData.getChannel()); |
| | | userActiveLog.setIp(requst.getRemoteHost()); |
| | | userActiveLog.setUid(find.getId()); |
| | | userActiveLog.setVersionCode(acceptData.getVersion()); |
| | | userActiveLog.setOsVersion(acceptData.getOsVersion()); |
| | | userActiveLog.setDeviceType(acceptData.getDeviceType()); |
| | | userActiveLog.setDevice(acceptData.getDevice()); |
| | | |
| | | userActiveLogService.addUserActiveLog(userActiveLog); |
| | | |
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice()); |
| | | return; |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult("不存在该账户!")); |
| | | return; |
| | | } |
| | | } |
| | | // 不是用ID的登陆的事就多了 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | String appid = system.getAppid(); |
| | | |
| | | // 判断是否是第一次正常登陆 |
| | | /* |
| | | * String platform = acceptData.getPlatform(); if(platform == "ios") { |
| | | * // 1: 安卓 2:ios if(firstIos == "1") { //第一次登陆 first = true; } else { |
| | | * first = false; } } |
| | | */ |
| | | if (first) { |
| | | int loginType = form.getLoginType(); |
| | | // WeiXinUserParam wxParam = null; |
| | | // 如果是微信登陆,那需要先获取到微信的unionid |
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); |
| | | WeiXinUser weiXinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(), |
| | | account.getAppSecret()); |
| | | if (loginType == Constant.WEIXIN && StringUtil.isNullOrEmpty(form.getWxUnionId())) { |
| | | // wxParam = WXinUtil.getWxParam(code); |
| | | if (weiXinUser == null) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | return; |
| | | } |
| | | form.setWxOpenId(weiXinUser.getOpenid()); |
| | | form.setWxUnionId(weiXinUser.getUnionid()); |
| | | } |
| | | String openid = loginType == 1 ? form.getOpenid() : form.getWxUnionId(); |
| | | LogHelper.userInfo("[ip:" + IPUtil.getRemotIP(requst) + "]" + (loginType == 1 ? "淘宝登陆" : "微信登陆") |
| | | + "[openid:" + openid + "]"); |
| | | if (openid == null || openid.equals("")) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | return; |
| | | } |
| | | // 获取用户信息 |
| | | UserInfo user = userInfoService.getUserByLoginTypeAndOpenId(loginType, openid, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | // 判断获取的用户信息是否为空,如果不为空就做的事就又多了 |
| | | if (user != null) {// 数据库中已经存在该用户 |
| | | outUserInfo(acceptData, out, remotIP, user, acceptData.getDevice()); |
| | | UserInfo temp = user; |
| | | long lastLoginTime = temp.getLastLoginTime() == null ? 0 : temp.getLastLoginTime().longValue(); |
| | | if (lastLoginTime == 0) {// 等于0则是第一次登陆,那么需要判断用户是不是被传销来的,如果是的话,那需要修改相关三级分销的状态 |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | threeSaleSerivce.effective(temp); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | return; |
| | | } |
| | | // 查询到的用户信息为空,那么需要填充一些用户信息 |
| | | if (loginType == Constant.WEIXIN) { |
| | | form.setPortrait(weiXinUser.getHeadimgurl()); |
| | | String wxHeadImg = COSManager.getInstance() |
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()), |
| | | FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString()) |
| | | .getUrl(); |
| | | form.setWxPic(wxHeadImg); |
| | | form.setNickName(weiXinUser.getNickname()); |
| | | form.setWxName(weiXinUser.getNickname()); |
| | | } else if (loginType == Constant.TAOBAO) { |
| | | form.setTbName(form.getNickName()); |
| | | form.setTbPic(form.getPortrait()); |
| | | } |
| | | form.setLastLoginIp(remotIP); |
| | | form.setLastLoginTime(java.lang.System.currentTimeMillis()); |
| | | requst.getSession().setAttribute("newUser", form); |
| | | out.append(JsonUtil.loadTrueResult(2, form)); |
| | | return; |
| | | } |
| | | |
| | | if (create == null || "0".equals(create)) { |
| | | out.append(JsonUtil.loadFalseResult("参数create不能为空!")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo newUser = (UserInfo) requst.getSession().getAttribute("newUser"); |
| | | UserInfo mainUser = (UserInfo) requst.getSession().getAttribute("mainUser"); |
| | | if (Constant.NEWUSER.equals(create)) { // 创建 |
| | | UserInfo user; |
| | | synchronized (UserInfo.class) { |
| | | user = userInfoService.addUser(newUser, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | } |
| | | if (user != null) { |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", GsonUtil.toJsonExpose(user)); |
| | | data.put("first", 1); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | LogHelper.userInfo(GsonUtil.toJsonExpose(user)); |
| | | } else { |
| | | LogHelper.userInfo("不存在用户:" + GsonUtil.toJsonExpose(form)); |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | } |
| | | requst.getSession().removeAttribute("newUser"); |
| | | return; |
| | | } else if (Constant.BINDUSER.equals(create) && mainUser == null) { // 绑定 |
| | | int formLoginType = form.getLoginType(); |
| | | int newUserLoginType = newUser.getLoginType(); |
| | | if (newUserLoginType == formLoginType) { // 相同类型不能绑定 |
| | | out.print(JsonUtil.loadFalseResult("相同类型的账号不能绑定!")); |
| | | return; |
| | | } |
| | | // 判断是不是微信。如果是微信就要填充微信相关信息 |
| | | if (formLoginType == Constant.WEIXIN/* |
| | | * && |
| | | * StringUtil.isNullOrEmpty(form |
| | | * .getWxOpenId()) |
| | | */) { |
| | | |
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); |
| | | |
| | | WeiXinUser xinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(), |
| | | account.getAppSecret()); |
| | | if (xinUser == null) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | return; |
| | | } |
| | | form.setWxOpenId(xinUser.getOpenid()); |
| | | form.setWxUnionId(xinUser.getUnionid()); |
| | | form.setPortrait(xinUser.getHeadimgurl()); |
| | | form.setNickName(xinUser.getNickname()); |
| | | form.setWxName(xinUser.getNickname()); |
| | | String wxHeadImg = COSManager.getInstance() |
| | | .uploadFile(HttpUtil.getAsInputStream(xinUser.getHeadimgurl()), |
| | | FilePathEnum.userPortrait + UUID.randomUUID().toString()) |
| | | .getUrl(); |
| | | form.setWxPic(wxHeadImg); |
| | | } else if (formLoginType == Constant.TAOBAO) { |
| | | form.setTbName(form.getNickName()); |
| | | form.setTbPic(form.getPortrait()); |
| | | } |
| | | requst.getSession().setAttribute("mainUser", form); |
| | | String openid = formLoginType == 1 ? form.getOpenid() : form.getWxUnionId(); |
| | | // 获取主账户用户信息 |
| | | UserInfo find = userInfoService.getUserByLoginTypeAndOpenId(formLoginType, openid, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | if (find != null) { |
| | | // 主账户不为空就进行绑定操作 |
| | | bind(find, newUser); |
| | | userInfoService.update(find); |
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice()); |
| | | requst.getSession().removeAttribute("newUser"); |
| | | requst.getSession().removeAttribute("mainUser"); |
| | | } else { |
| | | // 为空的话就返回用户信息 |
| | | out.print(JsonUtil.loadTrueResult(3, form)); |
| | | return; |
| | | } |
| | | } else {// create=2 ,mainUser != null 创建并绑定! |
| | | bind(mainUser, newUser); |
| | | mainUser = userInfoService.addUser(mainUser, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | outUserInfo(acceptData, out, remotIP, mainUser, acceptData.getDevice()); |
| | | requst.getSession().removeAttribute("newUser"); |
| | | requst.getSession().removeAttribute("mainUser"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 淘特价登录 |
| | | * |
| | | * @param acceptData |
| | | * @param form |
| | | * @param code |
| | | * @param create |
| | | * @param first |
| | | * @param requst |
| | | * @param out |
| | | */ |
| | | |
| | | @RequestMapping(value = "getuserinfo_ttj", method = RequestMethod.POST) |
| | | public void getUserInfoTTJ(AcceptData acceptData, UserInfo form, String code, String create, boolean first, |
| | | HttpServletRequest requst, PrintWriter out) { |
| | | String remotIP = IPUtil.getRemotIP(requst); |
| | | long id = form.getId(); |
| | | // 判断是不是用ID登陆的,如果是用ID登陆的其他都不要管了 |
| | | if (id != 0) { |
| | | UserInfo find = userInfoService.getUserById(id); |
| | | if (find != null) { |
| | | outUserInfo(acceptData, out, remotIP, find, acceptData.getDevice()); |
| | | return; |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult("不存在该账户!")); |
| | | return; |
| | | } |
| | | } |
| | | // 不是用ID的登陆的事就多了 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | String appid = system.getAppid(); |
| | | UserInfo user = userInfoService.getUserByLoginTypeAndOpenId(1, form.getOpenid(), SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | if (user == null) { |
| | | // 创建用户 |
| | | userInfoService.addUser(form, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | user = userInfoService.getUserByLoginTypeAndOpenId(1, form.getOpenid(), SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | } |
| | | |
| | | // 返回用户信息 |
| | | outUserInfo(acceptData, out, remotIP, user, acceptData.getDevice()); |
| | | } |
| | | |
| | | /** |
| | | * 将副账户绑定到主账户上 |
| | | * |
| | | * @param mainUser |
| | | * @param viceUser |
| | | */ |
| | | private void bind(UserInfo mainUser, UserInfo viceUser) { |
| | | int loginType = viceUser.getLoginType(); |
| | | if (loginType == Constant.TAOBAO) { |
| | | mainUser.setOpenid(viceUser.getOpenid()); |
| | | mainUser.setTbName(viceUser.getNickName()); |
| | | mainUser.setTbPic(viceUser.getTbPic()); |
| | | } else if (loginType == Constant.WEIXIN) { |
| | | mainUser.setWxName(viceUser.getWxName()); |
| | | mainUser.setWxOpenId(viceUser.getWxOpenId()); |
| | | mainUser.setWxUnionId(viceUser.getWxUnionId()); |
| | | mainUser.setWxPic(viceUser.getWxPic()); |
| | | } |
| | | } |
| | | |
| | | private void outUserInfo(AcceptData acceptData, PrintWriter out, String remotIP, UserInfo user, String device) { |
| | | user.setTotalHongBao(new BigDecimal(0)); |
| | | BigDecimal unOpenmoney = new BigDecimal(0); |
| | | BigDecimal canOpenMoney = new BigDecimal(0); |
| | | user.setNoOpenHongBao(unOpenmoney); |
| | | user.setCanOpenHongBao(canOpenMoney); |
| | | |
| | | /** |
| | | * 查询改用户返利红包 |
| | | */ |
| | | BigDecimal fanliHB = user.getTotalHongBao(); |
| | | user.setTotalHongBao(fanliHB); |
| | | |
| | | UserInfo filterForClientUser = UserUtil.filterForClientUser(user); |
| | | |
| | | // 1.5.0 版本之后返回新的等级 |
| | | String version = acceptData.getVersion(); |
| | | if (version != null && version.trim().length() > 0) { |
| | | int versionCode = Integer.parseInt(version); |
| | | String platform = acceptData.getPlatform(); |
| | | |
| | | AppVersionInfo versionInfo = appVersionService.getByPlatformAndVersion(platform, "1.5.0", acceptData.getSystem()); |
| | | if (versionInfo != null) { |
| | | int versionCode150 = versionInfo.getVersionCode(); |
| | | if (versionCode >= versionCode150) { |
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); |
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { |
| | | String picture = userInfoExtra.getUserRank().getPicture(); |
| | | String icon = userInfoExtra.getUserRank().getIcon(); |
| | | filterForClientUser.setRankNamePicture(picture); |
| | | filterForClientUser.setRankIcon(icon); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", |
| | | JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(filterForClientUser)); |
| | | data.put("first", 0); |
| | | int spreadImgCount = spreadUserImgService.countUserSpreadImg(user.getId()); |
| | | long shareCount = userShareGoodsRecordService.countShareRecordByUid(user.getId()); |
| | | |
| | | int showTiCheng = 1; // 不显示 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | data.put("showTiCheng", false); |
| | | else { |
| | | data.put("showTiCheng", spreadImgCount + shareCount > 0); |
| | | if (spreadImgCount + shareCount > 0) { |
| | | showTiCheng = 0; |
| | | } |
| | | } |
| | | |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new_online.html", |
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName())); |
| | | else |
| | | data.put("inviteList", configService.getValue(ConfigKeyEnum.teamList.getKey(), acceptData.getSystem())); |
| | | |
| | | // 界面状态 |
| | | UserSettingsVO mySettings = null; |
| | | try { |
| | | mySettings = userCustomSettingsService.getMySettings(user.getId()); |
| | | } catch (UserCustomSettingsException e) { |
| | | mySettings = new UserSettingsVO(); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (mySettings.getCancelNotice() == null) { |
| | | mySettings.setCancelNotice(0); |
| | | } |
| | | if (mySettings.getNoBonusCount() == null) { |
| | | mySettings.setNoBonusCount(showTiCheng); // 根据showTiCheng来判断 |
| | | } |
| | | if (mySettings.getNoNewsRedDot() == null) { |
| | | mySettings.setNoNewsRedDot(0); |
| | | } |
| | | if (mySettings.getNoShareRecordAndStorage() == null) { |
| | | mySettings.setNoShareRecordAndStorage(showTiCheng); // 根据showTiCheng来判断 |
| | | } |
| | | if (mySettings.getNoInvitationBonus() == null) { |
| | | mySettings.setNoInvitationBonus(0); |
| | | } |
| | | if (mySettings.getOpenSpreadHongBao() == null) { |
| | | mySettings.setOpenSpreadHongBao(0); |
| | | } |
| | | data.put("moduleState", mySettings); |
| | | |
| | | int welfareCenterNews = 0; |
| | | String invitCode = null; |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(user.getId()); |
| | | if (userInfoExtra != null) { |
| | | if (userInfoExtra.getCouponNews() != null) { |
| | | welfareCenterNews = userInfoExtra.getCouponNews(); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) { |
| | | invitCode = userInfoExtra.getInviteCodeVip(); |
| | | } else { |
| | | invitCode = userInfoExtra.getInviteCode(); |
| | | } |
| | | } |
| | | // 邀请码 |
| | | data.put("invitCode", invitCode); |
| | | // 福利中心消息 |
| | | data.put("welfareCenterNews", welfareCenterNews); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | final UserInfo uuser = user; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 获取邀请码:若无邀请码且存在有效的队员关系 则自动生成邀请码 |
| | | userInfoExtraService.getInviteCodeByUid(uuser.getId()); |
| | | |
| | | LogHelper.userInfo(GsonUtil.toJsonExpose(uuser)); |
| | | uuser.setLastLoginIp(remotIP); |
| | | uuser.setLastLoginTime(java.lang.System.currentTimeMillis()); |
| | | userInfoService.updateLoginInfo(uuser); |
| | | // 用户等级更新 |
| | | try { |
| | | userInfoExtraService.updateUserRankByUid(uuser.getId()); |
| | | } catch (UserInfoExtraException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @RequestMapping("bindUserInfo") |
| | | public void bindUserInfo(AcceptData acceptData, UserInfo form, String code, PrintWriter out) { |
| | | UserInfo find = userInfoService.getUserById(form.getId()); |
| | | if (find == null) { |
| | | out.print(JsonUtil.loadFalseResult("绑定失败,不存在该用户!")); |
| | | return; |
| | | } |
| | | int loginType = form.getLoginType(); |
| | | if (loginType == Constant.WEIXIN) { |
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); |
| | | WeiXinUser weiXinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(), |
| | | account.getAppSecret()); |
| | | |
| | | if (weiXinUser == null) { |
| | | out.print(JsonUtil.loadFalseResult("绑定失败,用户异常请重试!")); |
| | | return; |
| | | } |
| | | |
| | | LogHelper.test( |
| | | String.format("绑定微信:头像为 %s \n 昵称为 %s", weiXinUser.getHeadimgurl(), weiXinUser.getNickname())); |
| | | |
| | | String wxUnionId = weiXinUser.getUnionid(); |
| | | UserInfo userInfo = userInfoService.getUserByLoginTypeAndOpenId(loginType, wxUnionId, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | if (userInfo != null) { |
| | | out.print(JsonUtil.loadFalseResult("绑定失败,该微信账户已存在!")); |
| | | return; |
| | | } |
| | | find.setWxName(weiXinUser.getNickname()); |
| | | find.setWxOpenId(weiXinUser.getOpenid()); |
| | | find.setWxUnionId(weiXinUser.getUnionid()); |
| | | String wxHeadImg = COSManager.getInstance() |
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()), |
| | | FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString()) |
| | | .getUrl(); |
| | | find.setWxPic(wxHeadImg); |
| | | } else { // 绑定淘宝 |
| | | LogHelper.test(String.format("绑定淘宝:头像为 %s \n 昵称为 %s", form.getPortrait(), form.getTbName())); |
| | | UserInfo userInfo = userInfoService.getUserByLoginTypeAndOpenId(loginType, form.getOpenid(), |
| | | SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages())); |
| | | if (userInfo != null) { |
| | | out.print(JsonUtil.loadFalseResult("绑定失败,该淘宝账户已存在!")); |
| | | return; |
| | | } |
| | | find.setOpenid(form.getOpenid()); |
| | | find.setTbName(form.getTbName()); |
| | | find.setTbPic(form.getPortrait()); |
| | | } |
| | | userInfoService.update(find); |
| | | out.print(JsonUtil.loadTrueResult(GsonUtil.toJsonExpose(UserUtil.filterForClientUser(find)))); |
| | | } |
| | | |
| | | /** |
| | | * @param data |
| | | * @param uid 用户ID |
| | | * @param type 需要解绑的账户类型 |
| | | */ |
| | | @RequestMapping("unBindUserInfo") |
| | | public void unBindUserInfo(AcceptData data, long uid, int type, PrintWriter out) { |
| | | UserInfo find = userInfoService.getUserById(uid); |
| | | if (find == null) { |
| | | out.print(JsonUtil.loadFalseResult("不存在该用户!")); |
| | | return; |
| | | } |
| | | String openid = find.getOpenid(); |
| | | String wxUnionId = find.getWxUnionId(); |
| | | if (Constant.TAOBAO == type) { |
| | | if (StringUtil.isNullOrEmpty(openid)) { |
| | | out.print(JsonUtil.loadFalseResult("当前用户未绑定该类型账户!")); |
| | | return; |
| | | } |
| | | } else if (Constant.WEIXIN == type) { |
| | | if (StringUtil.isNullOrEmpty(wxUnionId)) { |
| | | out.print(JsonUtil.loadFalseResult("当前用户未绑定该类型账户!")); |
| | | return; |
| | | } |
| | | } |
| | | int count = 0; |
| | | if (StringUtil.isNullOrEmpty(openid)) { |
| | | count++; |
| | | } |
| | | if (StringUtil.isNullOrEmpty(wxUnionId)) { |
| | | count++; |
| | | } |
| | | if (count == 1) { |
| | | out.print(JsonUtil.loadFalseResult("当前只绑定了一个账户,不能解绑!")); |
| | | return; |
| | | } |
| | | userInfoService.unBindUserInfo(find, type); |
| | | out.print(JsonUtil.loadTrueResult("解绑成功")); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户提现账号 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getuseraccount", method = RequestMethod.POST) |
| | | public void getUserAccount(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请登录")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | List<BindingAccount> bindingAccountList = bindingAccountService.getBindingAccountByUid(uid); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("user", user); |
| | | Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); |
| | | |
| | | data.put("error", "0"); |
| | | data.put("maxError", 1); |
| | | String minMoney = configService.getValue(EXTRACT_MIN_MONEY, acceptData.getSystem()); // 单笔提现的最小金额 |
| | | String maxMoney = configService.getValue(EXTRACT_MAX_MONEY, acceptData.getSystem()); // 单笔提现的最小金额 |
| | | String maxDayMoney = configService.getValue(ConfigKeyEnum.extractMoneyDay.getKey(), acceptData.getSystem()); // 每日最大提现金额 |
| | | int maxDayCount = Integer.parseInt(configService.getValue(ConfigKeyEnum.extractDayCount.getKey(), acceptData.getSystem())); |
| | | ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid); |
| | | boolean canExtract = true; |
| | | String errorMsg = ""; |
| | | if (extractRecord != null && extractRecord.getCount() >= maxDayCount) { |
| | | canExtract = false; |
| | | errorMsg = String.format("每日最多提现%s次", maxDayCount + ""); |
| | | } else if (extractRecord != null |
| | | && extractRecord.getMoney().add(new BigDecimal(minMoney)).compareTo(new BigDecimal(maxDayMoney)) > 0) { |
| | | canExtract = false; |
| | | errorMsg = String.format("每日最多提现%s元", maxDayMoney); |
| | | } |
| | | data.put("canExtract", canExtract); |
| | | data.put("extractErrorMsg", errorMsg); |
| | | |
| | | data.put("minMoney", minMoney);// 单笔最低 |
| | | data.put("maxMoney", maxMoney);// 单笔最高 |
| | | data.put("maxDayCount", maxDayCount); |
| | | data.put("bindingAccountList", gson.toJson(filterBindingAccount(bindingAccountList))); |
| | | |
| | | JSONObject alipayVerify = new JSONObject(); |
| | | try { |
| | | bindingAccountService.canVerifyAlipayAccount(uid); |
| | | alipayVerify.put("state", 0); |
| | | alipayVerify.put("msg", "可绑定"); |
| | | } catch (BindingAccountException e) { |
| | | alipayVerify.put("state", e.getCode()); |
| | | alipayVerify.put("msg", e.getMsg()); |
| | | } |
| | | |
| | | data.put("alipayBindState", alipayVerify); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 是否能够提现 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "canextract", method = RequestMethod.POST) |
| | | public void canExtract(AcceptData acceptData, Long uid, BigDecimal money, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请登录")); |
| | | return; |
| | | } |
| | | |
| | | if (money == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传金额")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | String minMoney = configService.getValue(EXTRACT_MIN_MONEY, acceptData.getSystem()); // 单笔提现的最小金额 |
| | | String maxDayMoney = configService.getValue(ConfigKeyEnum.extractMoneyDay.getKey(), acceptData.getSystem()); // 每日最大提现金额 |
| | | int maxDayCount = Integer.parseInt(configService.getValue(ConfigKeyEnum.extractDayCount.getKey(), acceptData.getSystem())); |
| | | ExtractRecord extractRecord = extractRecordService.getExtractRecordByUid(uid); |
| | | boolean canExtract = true; |
| | | String errorMsg = ""; |
| | | if (extractRecord != null && extractRecord.getCount() + 1 > maxDayCount) { |
| | | canExtract = false; |
| | | errorMsg = String.format("每日最多提现%s次", maxDayCount + ""); |
| | | } else if (extractRecord != null |
| | | && extractRecord.getMoney().add(money).compareTo(new BigDecimal(maxDayMoney)) > 0) { |
| | | canExtract = false; |
| | | errorMsg = String.format("每日最多提现%s元", maxDayMoney); |
| | | } else if (new BigDecimal(minMoney).compareTo(money) > 0) { |
| | | canExtract = false; |
| | | errorMsg = String.format("每次最低提现%s元", minMoney); |
| | | } |
| | | |
| | | if (canExtract) { |
| | | out.print(JsonUtil.loadTrueResult("")); |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(errorMsg)); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getalipayaccount", method = RequestMethod.POST) |
| | | public void getAlipayAccount(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请登录")); |
| | | return; |
| | | } |
| | | |
| | | List<BindingAccount> bindingAccountList = bindingAccountService.getBindingAccountByUid(uid); |
| | | |
| | | if (bindingAccountList == null || bindingAccountList.size() == 0) { |
| | | out.print(JsonUtil.loadFalseResult(2, "尚未绑定支付宝")); |
| | | return; |
| | | } |
| | | |
| | | out.print(JsonUtil.loadTrueResult(JsonUtil.getSimpleGsonWithDate().toJson(bindingAccountList.get(0)))); |
| | | } |
| | | |
| | | public static List<BindingAccount> filterBindingAccount(List<BindingAccount> bindingAccountList) { |
| | | List<BindingAccount> accountList = new ArrayList<>(); |
| | | |
| | | if (bindingAccountList != null) |
| | | for (BindingAccount bindingAccount : bindingAccountList) { |
| | | BindingAccount dest = new BindingAccount(); |
| | | try { |
| | | PropertyUtils.copyProperties(dest, bindingAccount); |
| | | if (!StringUtil.isNullOrEmpty(dest.getAccount()) && !StringUtil.isNullOrEmpty(dest.getName())) { |
| | | String name = ""; |
| | | if ((dest.getName() + "").length() > 2) |
| | | for (int i = 0; i < (dest.getName() + "").length(); i++) { |
| | | if (i == 0) |
| | | name += dest.getName().charAt(i); |
| | | else |
| | | name += "*"; |
| | | } |
| | | else |
| | | name = dest.getName().charAt(0) + "*"; |
| | | dest.setName(name); |
| | | |
| | | String account = ""; |
| | | if (dest.getAccount().indexOf("@") > -1) {// 邮箱 |
| | | int index = dest.getAccount().indexOf("@"); |
| | | |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 3 || i >= index) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } else if (StringUtil.isMobile(dest.getAccount())) {// 电话 |
| | | account = dest.getAccount().substring(0, 3) + "*****" + dest.getAccount() |
| | | .substring(dest.getAccount().length() - 2, dest.getAccount().length()); |
| | | |
| | | } else {// 其他 |
| | | if (dest.getAccount().length() >= 6) { |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 3 || i >= dest.getAccount().length() - 2) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } else { |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 1 || i >= dest.getAccount().length() - 1) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | dest.setAccount(account); |
| | | |
| | | } |
| | | accountList.add(dest); |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } catch (InvocationTargetException e) { |
| | | e.printStackTrace(); |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return accountList; |
| | | } |
| | | |
| | | public static BindingAccount filterBindingAccount(BindingAccount bindingAccount) { |
| | | BindingAccount dest = new BindingAccount(); |
| | | try { |
| | | PropertyUtils.copyProperties(dest, bindingAccount); |
| | | if (!StringUtil.isNullOrEmpty(dest.getAccount()) && !StringUtil.isNullOrEmpty(dest.getName())) { |
| | | String name = ""; |
| | | if ((dest.getName() + "").length() > 2) |
| | | for (int i = 0; i < (dest.getName() + "").length(); i++) { |
| | | if (i == 0) |
| | | name += dest.getName().charAt(i); |
| | | else |
| | | name += "*"; |
| | | } |
| | | else |
| | | name = dest.getName().charAt(0) + "*"; |
| | | dest.setName(name); |
| | | |
| | | String account = ""; |
| | | if (dest.getAccount().indexOf("@") > -1) {// 邮箱 |
| | | int index = dest.getAccount().indexOf("@"); |
| | | |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 3 || i >= index) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } else if (StringUtil.isMobile(dest.getAccount())) {// 电话 |
| | | account = dest.getAccount().substring(0, 3) + "*****" |
| | | + dest.getAccount().substring(dest.getAccount().length() - 2, dest.getAccount().length()); |
| | | |
| | | } else {// 其他 |
| | | if (dest.getAccount().length() >= 6) { |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 3 || i >= dest.getAccount().length() - 2) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } else { |
| | | for (int i = 0; i < dest.getAccount().length(); i++) { |
| | | if (i < 1 || i >= dest.getAccount().length() - 1) |
| | | account += dest.getAccount().charAt(i); |
| | | else |
| | | account += "*"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | dest.setAccount(account); |
| | | |
| | | } |
| | | } catch (IllegalAccessException e) { |
| | | e.printStackTrace(); |
| | | } catch (InvocationTargetException e) { |
| | | e.printStackTrace(); |
| | | } catch (NoSuchMethodException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return dest; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 添加用户提现账号 |
| | | * |
| | | * @param acceptData |
| | | * @param uid 用户id |
| | | * @param account 账号 |
| | | * @param name 真实名字 |
| | | * @param type 账号类型:1.支付宝 2.微信 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "addbindingaccount", method = RequestMethod.POST) |
| | | public void addBindingAccount(AcceptData acceptData, long uid, String account, String name, int type, |
| | | PrintWriter out) { |
| | | |
| | | if (Constant.ZHIFUBAO != type && Constant.WEIXIN != type) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE)); |
| | | return; |
| | | } |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | BindingAccount addAccount = new BindingAccount(); |
| | | addAccount.setAccount(account); |
| | | addAccount.setType(type); |
| | | addAccount.setUserInfo(user); |
| | | addAccount.setName(name); |
| | | try { |
| | | bindingAccountService.addBindingAccount(addAccount); |
| | | } catch (BindingAccountException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMessage())); |
| | | return; |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(Constant.BA_SUCCESS)); |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 删除用户提现账号 |
| | | * |
| | | * @param acceptData |
| | | * @param uid 用户id |
| | | * @param type 账号类型 |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "deletebindingaccount", method = RequestMethod.POST) |
| | | public void deleteBindingAccount(AcceptData acceptData, long uid, int type, PrintWriter out) { |
| | | |
| | | if (type != Constant.ZHIFUBAO && type != Constant.WEIXIN) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE)); |
| | | return; |
| | | } |
| | | |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | BindingAccount account = new BindingAccount(); |
| | | account.setType(type); |
| | | account.setUserInfo(user); |
| | | Integer deletecount = bindingAccountService.deleteBindingAccount(account); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", deletecount); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 新版提现 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param money |
| | | * @param vcode 手机验证码 |
| | | * @param request |
| | | * @param type |
| | | * @param out |
| | | */ |
| | | @RequestSerializableByKey(key = "#uid") |
| | | @RequestMapping(value = "extractmoneynew", method = RequestMethod.POST) |
| | | public void extractMoneyNew(AcceptData acceptData, long uid, BigDecimal money, String vcode, |
| | | HttpServletRequest request, int type, PrintWriter out) { |
| | | UserInfo user = userInfoService.getUserById(uid); |
| | | if (user == null) { |
| | | user = userInfoService.getUserByIdWithMybatis(uid); |
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | |
| | | out.print(JsonUtil.loadFalseResult("用户不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (money == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传提现金额")); |
| | | return; |
| | | } |
| | | |
| | | if (!Constant.IS_TEST) { |
| | | // 判断手机验证码的正确性 |
| | | String oldCode = redisManager.getSMSVCode(user.getPhone(), SMSHistory.TYPE_LOGIN); |
| | | if (StringUtil.isNullOrEmpty(oldCode) || !oldCode.equalsIgnoreCase(vcode)) { |
| | | out.print(JsonUtil.loadFalseResult(90001, "验证码错误")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | LogHelper.userInfo("提现时,不存在该系统"); |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | String minMoney = configService.getValue(EXTRACT_MIN_MONEY, acceptData.getSystem()); // 单笔提现最小金额 |
| | | |
| | | if (money.compareTo(new BigDecimal("0.1")) < 0) { // 转帐到支付宝的最小金额 |
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额需要大于:" + 0.1 + "元")); |
| | | return; |
| | | } |
| | | |
| | | if (money.compareTo(new BigDecimal(minMoney)) < 0) { // 后台设置的单笔转账的最小金额 |
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额需要大于:" + minMoney + "元")); |
| | | return; |
| | | } |
| | | String maxMoney = configService.getValue(EXTRACT_MAX_MONEY, acceptData.getSystem()); // 单笔提现最大金额 |
| | | if (new BigDecimal(maxMoney).compareTo(money) < 0) { // 后台设置的单笔转账的最大金额 |
| | | out.print(JsonUtil.loadFalseResult("单笔提现金额多为:" + maxMoney + "元")); |
| | | return; |
| | | } |
| | | |
| | | if (type != Constant.ZHIFUBAO && type != Constant.WEIXIN) { // 提现类型必须是支付宝类型或者微信类型,目前(20170506)仅支持支付宝 |
| | | out.print(JsonUtil.loadFalseResult(Constant.NOTYPE)); |
| | | return; |
| | | } |
| | | |
| | | BindingAccount bindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid, type); |
| | | if (bindingAccount == null) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.NOACCOUNT)); |
| | | return; |
| | | } |
| | | |
| | | Extract extract = new Extract(); |
| | | extract.setIp(IPUtil.getRemotIP(request)); |
| | | extract.setAccount(bindingAccount.getAccount()); |
| | | extract.setName(bindingAccount.getName()); |
| | | extract.setMoney(new BigDecimal(String.valueOf(money))); |
| | | extract.setUserInfo(user); |
| | | extract.setExtractTime(java.lang.System.currentTimeMillis()); |
| | | extract.setType(type); |
| | | extract.setState(0); |
| | | extract.setSystem(system); |
| | | Integer etype = extractService.addExtract(extract); |
| | | if (etype == null) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id", extract.getId()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | ThreadUtil.run(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | JSONObject json = new JSONObject(); |
| | | json.put("timeStamp", java.lang.System.currentTimeMillis()); |
| | | json.put("adminId", 4L); |
| | | String sign = AESUtil.encrypt(json.toString(), Constant.ADMINH5_AESKEY); |
| | | String url = ""; |
| | | try { |
| | | url = String.format("%s?from=emailh5&sign=%s", |
| | | Constant.systemCommonConfig.getExtractNotifyUrl(), URLEncoder.encode(sign, "UTF-8")); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | long[] targetUids = new long[]{3L, 4L, 5L}; |
| | | Config config = configService.getConfig(ConfigKeyEnum.extractCodeEmailFrom.getKey(), acceptData.getSystem()); |
| | | String[] sts = config.getValue().split(","); |
| | | String account = sts[0]; |
| | | String pwd = sts[1]; |
| | | for (long adminId : targetUids) { |
| | | AdminUser adminUser = adminUserService.selectByPrimaryKey(adminId); |
| | | String msg = "提现审核链接:" + url; |
| | | boolean isS = MailSenderUtil.sendEmail(adminUser.getEmail(), account, pwd, "有新的提现审核", msg); |
| | | } |
| | | } |
| | | }); |
| | | return; |
| | | } else if (etype == 1) { |
| | | out.print(JsonUtil.loadFalseResult("已超过当日提现次数")); |
| | | } else if (etype == 2) { |
| | | out.print(JsonUtil.loadFalseResult("已超过当日提现金额")); |
| | | } else if (etype == 3) { |
| | | out.print(JsonUtil.loadFalseResult("提现金额大于我的红包")); |
| | | } else if (etype == 111) { |
| | | out.print(JsonUtil.loadFalseResult("修改手机号后,7天内无法提现")); |
| | | } else if (etype == 110) { |
| | | out.print(JsonUtil.loadFalseResult("有售后订单尚未扣款")); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取提现进度 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getextractprocess", method = RequestMethod.POST) |
| | | public void getExtractProcess(AcceptData acceptData, long id, Long uid, PrintWriter out) { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("请上传用户ID")); |
| | | return; |
| | | } |
| | | Extract extract = extractService.getExtractById(id); |
| | | if (extract == null) { |
| | | out.print(JsonUtil.loadFalseResult("提现记录不存在")); |
| | | return; |
| | | } |
| | | if (extract.getUserInfo().getId().longValue() != uid) { |
| | | out.print(JsonUtil.loadFalseResult("不属于当前用户的提现记录")); |
| | | return; |
| | | } |
| | | |
| | | BindingAccount account = new BindingAccount(); |
| | | account.setAccount(extract.getAccount()); |
| | | account.setName(extract.getName()); |
| | | List<BindingAccount> bindingAccountList = new ArrayList<>(); |
| | | bindingAccountList.add(account); |
| | | bindingAccountList = filterBindingAccount(bindingAccountList); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("id", extract.getId()); |
| | | data.put("money", "¥" + extract.getMoney().toString()); |
| | | data.put("account", bindingAccountList.get(0).getAccount()); |
| | | data.put("expireTime", |
| | | TimeUtil.getGernalTime(extract.getExtractTime() + 1000 * 60 * 60 * 24L, "yyyy-MM-dd HH:mm"));// 24小时后到账 |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("findLostOrder") |
| | | public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, PrintWriter out) { |
| | | boolean orderNum = true; |
| | | |
| | | if (!NumberUtil.isNumeric(lostOrder.getOrderId())) { |
| | | orderNum = false; |
| | | } else if (lostOrder.getOrderId().length() < 12 || lostOrder.getOrderId().length() > 20) { |
| | | orderNum = false; |
| | | } else |
| | | orderNum = Utils.isOrderNum(lostOrder.getOrderId()); |
| | | |
| | | int state; |
| | | String stateInfo = "提交成功,请等待审核结果。"; |
| | | if (!orderNum) { |
| | | state = -4; |
| | | stateInfo = "请提交标准的订单号"; |
| | | } else { |
| | | state = lostOrderService.addLostOrder(lostOrder); |
| | | if (state == -3) { |
| | | stateInfo = "该订单已是返利订单。"; |
| | | } else if (state == -2) { |
| | | stateInfo = "请勿重复提交,该订单已在审核中。"; |
| | | } else if (state == -1) { |
| | | stateInfo = "该订单申诉已通过,请稍后查看。"; |
| | | } else if (state == -5) { |
| | | stateInfo = "该订单为分享奖金订单"; |
| | | } else if (state == -1001) { |
| | | stateInfo = "该订单为违规订单"; |
| | | } else if (state == -1002) { |
| | | stateInfo = "该订单已发起维权"; |
| | | } |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | data.put("state", state); |
| | | data.put("info", stateInfo); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("findOrderItemList") |
| | | public void findOrderItemList(AcceptData acceptData, long uid, int page, PrintWriter out) { |
| | | List<HongBaoOrder> list = hongBaoOrderService.listFanLiOrder(uid, page, Constant.PAGE_SIZE); |
| | | |
| | | List<OrderItem> orderList = new ArrayList<>(); |
| | | for (HongBaoOrder oi : list) { |
| | | OrderItem orderItem = OrderItemFactory.create(oi); |
| | | orderItem.setDesc(); |
| | | orderItem.setPicture(TbImgUtil.getTBSize220Img(orderItem.getPicture())); |
| | | orderList.add(orderItem); |
| | | } |
| | | long count = hongBaoOrderService.countFanLiOrder(uid); |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) |
| | | .excludeFieldsWithoutExposeAnnotation().create(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", gson.toJson(orderList)); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 获取提成订单列表 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param page |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getTiChengOrderList") |
| | | public void getTiChengOrderList(AcceptData acceptData, long uid, int page, PrintWriter out) { |
| | | List<HongBaoDTO> hongBaoDTOList = hongBaoV2Service.listJiangJinByUid(uid, page, Constant.PAGE_SIZE); |
| | | List<HongBao> list = new ArrayList<>(); |
| | | if (hongBaoDTOList != null) |
| | | for (HongBaoDTO dto : hongBaoDTOList) { |
| | | list.add(HongBaoFactory.createHongBao(dto)); |
| | | } |
| | | long count = hongBaoV2Service.countJiangJinByUid(uid); |
| | | List<OrderItem> orderItemList = HongBaoUtil.convertToTiChengOrder(list); |
| | | Gson gson = JsonUtil.getApiCommonGson(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", gson.toJson(orderItemList)); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("findAccountMessageList") |
| | | public void findAccountMessageList(AcceptData acceptData, long uid, int page, PrintWriter out) { |
| | | accountMessageService.syncSystemZnx(uid); |
| | | List<AccountMessage> list = accountMessageService.findAccountMessageList(uid, page); |
| | | int count = accountMessageService.getCount(uid); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", GsonUtil.toJsonExpose(list)); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("openAccountMessage") |
| | | public void openAccountMessage(AcceptData acceptData, long id, PrintWriter out) { |
| | | accountMessageService.open(id); |
| | | out.print(JsonUtil.loadTrueResult("打开成功")); |
| | | } |
| | | |
| | | @RequestMapping("findCanOpenMessage") |
| | | public void findCanOpenMessage(AcceptData acceptData, long uid, PrintWriter out) { |
| | | accountMessageService.syncSystemZnx(uid); |
| | | // count>0 有消息 |
| | | int count = accountMessageService.getCanOpenCount(uid); |
| | | out.print(JsonUtil.loadTrueResult(count)); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | // 用户等级更新 |
| | | try { |
| | | userInfoExtraService.updateUserRankByUid(uid); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @RequestMapping("collectionGoods") |
| | | public void collectionGoods(AcceptData acceptData, long uid, String auctionId, int type, PrintWriter out) { |
| | | try { |
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId, |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | if (type == 1) { |
| | | if (find != null) { |
| | | out.print(JsonUtil.loadFalseResult("")); |
| | | return; |
| | | } |
| | | try { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId); |
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief); |
| | | out.print(JsonUtil.loadTrueResult("收藏成功")); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架")); |
| | | } |
| | | } else { |
| | | if (find == null) { |
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功")); |
| | | return; |
| | | } else { |
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); |
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功")); |
| | | } |
| | | } |
| | | } catch (CollectionGoodsException e1) { |
| | | out.print(JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * h5收藏 |
| | | * |
| | | * @param callback |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param auctionId |
| | | * @param out |
| | | */ |
| | | @RequestMapping("collectionGoodsJp") |
| | | public void collectionGoodsJp(String callback, AcceptData acceptData, Long uid, String auctionId, Integer goodsType, |
| | | PrintWriter out) { |
| | | |
| | | if (uid == null || auctionId == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("")); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == null) { |
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO; |
| | | } |
| | | |
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, auctionId, goodsType); |
| | | |
| | | if (find == null) { |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | |
| | | } else { |
| | | try { |
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId); |
| | | collectionGoodsV2Service.addCollection(uid, taoBaoGoodsBrief); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(1)); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | JsonUtil.printMode(out, callback, (JsonUtil.loadFalseResult(1, "商品已下架"))); |
| | | } catch (CollectionGoodsException e1) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e1.getCode(), e1.getMsg())); |
| | | } |
| | | } |
| | | } else { |
| | | // 取消收藏 |
| | | try { |
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, auctionId, goodsType); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("取消收藏成功")); |
| | | } catch (CollectionGoodsException e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping("collectionGoodsList") |
| | | public void collectionGoodsList(AcceptData acceptData, long uid, int page, PrintWriter out) { |
| | | |
| | | List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page + 1, |
| | | Constant.PAGE_SIZE, Constant.SOURCE_TYPE_TAOBAO, true); |
| | | |
| | | List<TaoBaoGoodsBriefExtra> list = new ArrayList<TaoBaoGoodsBriefExtra>(); |
| | | |
| | | long count = collectionGoodsV2Service.getCollectionGoodsCount(uid, Constant.SOURCE_TYPE_TAOBAO, true); |
| | | JSONObject data = new JSONObject(); |
| | | |
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = new ArrayList<TaoBaoGoodsBrief>(); |
| | | if (collectionGoodsList != null && collectionGoodsList.size() > 0) { |
| | | |
| | | BigDecimal proportion = hongBaoManageService.getFanLiRate(acceptData.getSystem()); |
| | | |
| | | List<String> listGid = new ArrayList<>(); |
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) { |
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods(); |
| | | if (commonGoods == null) { |
| | | continue; |
| | | } |
| | | listGid.add(commonGoods.getGoodsId()); |
| | | } |
| | | |
| | | try { |
| | | // API网络接口验证是否在售 |
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) { |
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods(); |
| | | if (commonGoods == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) { |
| | | int state = 1; // 默认停售 |
| | | String goodsId = commonGoods.getGoodsId(); |
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) { |
| | | String auctionId = taoKeGoods.getAuctionId(); |
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) { |
| | | state = 0; // 在售 |
| | | break; |
| | | } |
| | | } |
| | | commonGoods.setState(state); |
| | | } |
| | | |
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods); |
| | | goodsBrief.setSalesCount(TaoBaoUtil.getSaleCount(goodsBrief.getBiz30day())); |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, |
| | | proportion.toString(), ""); |
| | | taoBaoGoodsBriefExtra.setCreatetime(collectionGoodsV2.getCreateTime()); |
| | | |
| | | list.add(taoBaoGoodsBriefExtra); |
| | | } |
| | | |
| | | } |
| | | |
| | | GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(value.getTime() + ""); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(builder).excludeFieldsWithoutExposeAnnotation() |
| | | .create(); |
| | | data.put("list", gson.toJson(list)); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("deleteCollectionGoods") |
| | | public void deleteCollectionGoods(AcceptData acceptData, String ids, Integer type, long uid, Integer goodsType, |
| | | PrintWriter out) { |
| | | if (type != null && type == 1) { |
| | | clearConllectionGoods(acceptData, uid, out); |
| | | } else { |
| | | if (!StringUtil.isNullOrEmpty(ids)) { |
| | | Arrays.asList(ids.split(",")).parallelStream().forEach(auctionIdStr -> { |
| | | try { |
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, (auctionIdStr), |
| | | goodsType); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("删除成功")); |
| | | } |
| | | |
| | | @RequestMapping("clearConllectionGoods") |
| | | public void clearConllectionGoods(AcceptData acceptData, long uid, PrintWriter out) { |
| | | try { |
| | | collectionGoodsV2Service.cancelCollectionByUid(uid); |
| | | } catch (CollectionGoodsException e) { |
| | | e.printStackTrace(); |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("删除成功")); |
| | | } |
| | | |
| | | @RequestMapping("ruleMessage") |
| | | public void ruleMessage(AcceptData acceptData, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("rank3", String.format("成功邀请50个好友完成注册安装%sAPP(包括一度好友和二度好友之和)", |
| | | Constant.systemCommonConfig.getProjectChineseName())); |
| | | data.put("rank2", String.format("成功邀请5个好友完成注册安装%sAPP(包括一度好友和二度好友之和)", |
| | | Constant.systemCommonConfig.getProjectChineseName())); |
| | | data.put("rank1", String.format("成功邀请1个好友完成注册安装%sAPP(包括一度好友和二度好友之和)", |
| | | Constant.systemCommonConfig.getProjectChineseName())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("findAccountDetailsList") |
| | | public void findAccountDetailsList(AcceptData acceptData, long uid, int page, PrintWriter out) { |
| | | List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE); |
| | | List<AccountDetails> list = new ArrayList<>(); |
| | | for (UserMoneyDetail detail : detailList) |
| | | list.add(AccountDetailsFactory.create(detail)); |
| | | long count = userMoneyDetailService.countByUidWithState(uid); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("list", GsonUtil.toJsonExpose(list)); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping("findAccountDetailsListV2") |
| | | public void findAccountDetailsListNew(AcceptData acceptData, Long uid, int page, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "UID为空")); |
| | | return; |
| | | } |
| | | |
| | | List<UserMoneyDetail> detailList = userMoneyDetailService.listByUidWithState(uid, page, Constant.PAGE_SIZE); |
| | | |
| | | List<AccountDetails> list = new ArrayList<>(); |
| | | for (UserMoneyDetail detail : detailList) |
| | | list.add(AccountDetailsFactory.create(detail)); |
| | | |
| | | long count = userMoneyDetailService.countByUidWithState(uid); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | JSONArray array = new JSONArray(); |
| | | for (AccountDetails ad : list) { |
| | | JSONObject item = JSONObject.fromObject(GsonUtil.toJsonExpose(ad)); |
| | | if (ad.getState() != null && ad.getState() != -1) |
| | | item.put("stateIcon", |
| | | "http://hcj-1255749512.file.myqcloud.com/resource/app/extract_state_" + ad.getState() + ".png"); |
| | | array.add(item); |
| | | } |
| | | data.put("list", array); |
| | | data.put("count", count); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | // 获取商品分享链接 |
| | | @RequestMapping(value = "getGoodsShareUrl") |
| | | public void getGoodsShareUrl(AcceptData acceptData, long id, PrintWriter out) { |
| | | out.print(JsonUtil |
| | | .loadTrueResult(String.format("%s?id=" + id, Constant.systemCommonConfig.getAppShareInfoUrl()))); |
| | | } |
| | | |
| | | /** |
| | | * 用户队员列表查询 1.4.1 |
| | | * |
| | | * @param acceptData |
| | | * @param page |
| | | * @param uid |
| | | * @param type |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getMyTeam", method = RequestMethod.POST) |
| | | public void getMyTeam(AcceptData acceptData, long page, long uid, long type, PrintWriter out) { |
| | | |
| | | try { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | JSONObject resultData = new JSONObject(); |
| | | if (type == 1) { |
| | | resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid); |
| | | } else if (type == 2) { |
| | | resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid); |
| | | } |
| | | |
| | | // 安卓系统返回所有数据 |
| | | String platform = acceptData.getPlatform(); |
| | | if ("android".equalsIgnoreCase(platform)) { |
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid); |
| | | |
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid); |
| | | |
| | | JSONObject bossData = null; |
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); |
| | | if (threeSale != null) { |
| | | bossData = new JSONObject(); |
| | | UserInfo boss = threeSale.getBoss(); |
| | | if (boss != null) { |
| | | bossData.put("nickName", boss.getNickName()); |
| | | bossData.put("portrait", boss.getPortrait()); |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); |
| | | Long createTime = threeSale.getCreateTime(); |
| | | Date inviteTime = new Date(createTime); |
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime)); |
| | | } |
| | | |
| | | String helpLink = configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(), acceptData.getSystem()); |
| | | if (helpLink == null) { |
| | | helpLink = ""; |
| | | } |
| | | |
| | | boolean hasCode = false; |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (inviteCode != null && inviteCode.trim().length() > 0) { |
| | | hasCode = true; // 已有邀请码 |
| | | } else { |
| | | // 邀请激活链接 |
| | | resultData.put("activationlink", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(), acceptData.getSystem())); |
| | | } |
| | | resultData.put("hasCode", hasCode); |
| | | |
| | | resultData.put("helpLink", helpLink); |
| | | resultData.put("firstTeam", firstTeam); |
| | | resultData.put("firstTeamTotal", firstTeam); |
| | | resultData.put("secondTeam", secondTeam); |
| | | resultData.put("secondTeamTotal", secondTeam); |
| | | resultData.put("boss", bossData); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(resultData)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("统计失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 用户队员列表查询 1.5.3查询有效队员 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getMyTeamNew", method = RequestMethod.POST) |
| | | public void getMyTeamNew(AcceptData acceptData, long page, long uid, long type, PrintWriter out) { |
| | | |
| | | try { |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | JSONObject resultData = new JSONObject(); |
| | | if (type == 1) { |
| | | resultData = threeSaleSerivce.getMyFirstTeam((page - 1) * pageSize, pageSize, uid); |
| | | } else if (type == 2) { |
| | | resultData = threeSaleSerivce.getMySecondTeam((page - 1) * pageSize, pageSize, uid); |
| | | } |
| | | |
| | | // 安卓系统返回所有数据 |
| | | String platform = acceptData.getPlatform(); |
| | | if ("android".equalsIgnoreCase(platform)) { |
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid); |
| | | |
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid); |
| | | |
| | | JSONObject bossData = null; |
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); |
| | | if (threeSale != null) { |
| | | bossData = new JSONObject(); |
| | | UserInfo boss = threeSale.getBoss(); |
| | | if (boss != null) { |
| | | bossData.put("nickName", boss.getNickName()); |
| | | bossData.put("portrait", boss.getPortrait()); |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); |
| | | Long createTime = threeSale.getCreateTime(); |
| | | Date inviteTime = new Date(createTime); |
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime)); |
| | | } |
| | | |
| | | String helpLink = configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(), acceptData.getSystem()); |
| | | if (helpLink == null) { |
| | | helpLink = ""; |
| | | } |
| | | |
| | | boolean hasCode = false; |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (inviteCode != null && inviteCode.trim().length() > 0) { |
| | | hasCode = true; // 已有邀请码 |
| | | } else { |
| | | // 邀请激活链接 |
| | | resultData.put("activationlink", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(), acceptData.getSystem())); |
| | | } |
| | | resultData.put("hasCode", hasCode); |
| | | |
| | | resultData.put("helpLink", helpLink); |
| | | resultData.put("firstTeam", firstTeam); |
| | | resultData.put("secondTeam", secondTeam); |
| | | resultData.put("boss", bossData); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(resultData)); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("统计失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户队员统计 1.4.1 |
| | | * |
| | | * @param acceptData |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "countMyTeam", method = RequestMethod.POST) |
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) { |
| | | try { |
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid); |
| | | |
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid); |
| | | JSONObject bossData = new JSONObject(); |
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); |
| | | if (threeSale != null) { |
| | | UserInfo boss = threeSale.getBoss(); |
| | | if (boss != null) { |
| | | bossData.put("nickName", boss.getNickName()); |
| | | bossData.put("portrait", boss.getPortrait()); |
| | | } |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); |
| | | Long createTime = threeSale.getCreateTime(); |
| | | Date inviteTime = new Date(createTime); |
| | | bossData.put("inviteTime", "邀请时间: " + sdf.format(inviteTime)); |
| | | } |
| | | |
| | | JSONObject resultData = new JSONObject(); |
| | | |
| | | String helpLink = configService.getValue(ConfigKeyEnum.teamHelpUrl.getKey(), acceptData.getSystem()); |
| | | if (helpLink == null) { |
| | | helpLink = ""; |
| | | } |
| | | resultData.put("helpLink", helpLink); |
| | | resultData.put("firstTeam", firstTeam); |
| | | resultData.put("firstTeamTotal", firstTeam); |
| | | resultData.put("secondTeam", secondTeam); |
| | | resultData.put("secondTeamTotal", secondTeam); |
| | | resultData.put("boss", bossData); |
| | | |
| | | boolean hasCode = false; |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | if (inviteCode != null && inviteCode.trim().length() > 0) { |
| | | hasCode = true; // 已有邀请码 |
| | | } else { |
| | | // 邀请激活链接 |
| | | resultData.put("activationlink", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(), acceptData.getSystem())); |
| | | } |
| | | resultData.put("hasCode", hasCode); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(resultData)); |
| | | |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("统计失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户队员信息保存 1.4.1 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param inviteId 邀请id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "setextrainfo", method = RequestMethod.POST) |
| | | public void setExtraInfo(AcceptData acceptData, long uid, long inviteId, String memoName, PrintWriter out) { |
| | | ThreeSale threeSale = threeSaleSerivce.selectByPrimaryKey(inviteId); |
| | | if (threeSale == null) { |
| | | out.print(JsonUtil.loadFalseResult("该记录不存在")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo worker = threeSale.getWorker(); |
| | | if (worker == null) { |
| | | out.print(JsonUtil.loadFalseResult("该记录不存在")); |
| | | return; |
| | | } |
| | | |
| | | int type = 1; |
| | | if (threeSale.getBoss().getId() != uid) { |
| | | type = 2; |
| | | } |
| | | |
| | | ThreeSaleExtraInfo extraInfo = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(uid, worker.getId()); |
| | | if (extraInfo == null) { |
| | | extraInfo = new ThreeSaleExtraInfo(); |
| | | Long bossUid = threeSale.getBoss().getId(); |
| | | if (uid == bossUid) { |
| | | extraInfo.setType(1); // 直接 |
| | | } else { |
| | | extraInfo.setType(2); // 间接 |
| | | } |
| | | |
| | | extraInfo.setWorker(worker); |
| | | extraInfo.setNickname(memoName); |
| | | extraInfo.setCreateTime(new Date()); |
| | | extraInfo.setUpdateTime(new Date()); |
| | | extraInfo.setBoss(new UserInfo(uid)); |
| | | threeSaleExtraInfoSerivce.insertSelective(extraInfo); |
| | | } else { |
| | | ThreeSaleExtraInfo updateInfo = new ThreeSaleExtraInfo(); |
| | | updateInfo.setId(extraInfo.getId()); |
| | | updateInfo.setNickname(memoName); |
| | | updateInfo.setUpdateTime(new Date()); |
| | | threeSaleExtraInfoSerivce.updateByPrimaryKeySelective(updateInfo); |
| | | } |
| | | |
| | | // 更新粉丝记录信息 |
| | | teamFansInfoService.updateMemoName(worker.getId(), type, memoName); |
| | | |
| | | out.print(JsonUtil.loadTrueResult("保存成功")); |
| | | } |
| | | |
| | | /** |
| | | * 设置界面开关状态 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param params |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "setModuleState", method = RequestMethod.POST) |
| | | public void setModuleState(AcceptData acceptData, Long uid, String params, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | if (params == null || params.trim().length() == 0) { |
| | | out.print(JsonUtil.loadFalseResult("传递参数为空")); |
| | | return; |
| | | } |
| | | |
| | | JSONObject json = JSONObject.fromObject(params); |
| | | Iterator<String> iterator = json.keys(); |
| | | while (iterator.hasNext()) { |
| | | String type = (String) iterator.next(); |
| | | int state = json.getInt(type); |
| | | userCustomSettingsService.saveModuleState(uid, type, state); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult("设置成功")); |
| | | |
| | | } catch (UserCustomSettingsException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("设置失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取等级信息 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRankInfo", method = RequestMethod.POST) |
| | | public void getRankInfo(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | UserInfoExtraVO rankInfo = userInfoExtraService.getRankInfo(uid); |
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()); |
| | | gsonBuilder.excludeFieldsWithoutExposeAnnotation(); |
| | | Gson gson = gsonBuilder.setDateFormat("yyyy.MM.dd").create(); |
| | | |
| | | JSONObject resultData = new JSONObject(); |
| | | resultData.put("rankInfo", gson.toJson(rankInfo)); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(resultData)); |
| | | |
| | | } catch (UserInfoExtraException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("获取失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取等级信息 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getUserConfig", method = RequestMethod.POST) |
| | | public void getUserConfig(AcceptData acceptData, Long uid, PrintWriter out) { |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid); |
| | | |
| | | JSONObject inviteData = new JSONObject(); |
| | | if (inviteCode == null || inviteCode.trim().length() == 0) { |
| | | // 无邀请码 |
| | | inviteData.put("content", "邀请激活"); |
| | | inviteData.put("link", configService.getValue(ConfigKeyEnum.inviteActivationUrl.getKey(), acceptData.getSystem())); |
| | | } else { |
| | | // 已有邀请码 |
| | | inviteData.put("content", "邀请码"); |
| | | inviteData.put("link", configService.getValue(ConfigKeyEnum.inviteActivationSuccessUrl.getKey(), acceptData.getSystem())); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("invite", inviteData); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("获取失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | | * |
| | | * @param acceptData |
| | | * @param requst |
| | | * @param out |
| | | */ |
| | | @UserActive(uid = "#uid") |
| | | @RequestMapping(value = "getuserinfoNew", method = RequestMethod.POST) |
| | | public void getuserinfoNew(AcceptData acceptData, Long uid, HttpServletRequest requst, PrintWriter out) { |
| | | try { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("请求参数为空")); |
| | | return; |
| | | } |
| | | |
| | | UserInfo userInfo = userInfoService.getUserInfo(uid); |
| | | |
| | | // 添加用户活跃记录 |
| | | UserActiveLog userActiveLog = new UserActiveLog(); |
| | | userActiveLog.setChannel(acceptData.getChannel()); |
| | | userActiveLog.setIp(requst.getRemoteHost()); |
| | | userActiveLog.setUid(userInfo.getId()); |
| | | userActiveLog.setVersionCode(acceptData.getVersion()); |
| | | userActiveLog.setOsVersion(acceptData.getOsVersion()); |
| | | userActiveLog.setDeviceType(acceptData.getDeviceType()); |
| | | userActiveLog.setDevice(acceptData.getDevice()); |
| | | userActiveLogService.addUserActiveLog(userActiveLog); |
| | | //是否绑定淘宝 |
| | | UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid); |
| | | if (taoBaoInfo != null) |
| | | if (!StringUtil.isNullOrEmpty(taoBaoInfo.getSpecialId()) && taoBaoInfo.getSpecialValid() != null && taoBaoInfo.getSpecialValid()) { |
| | | if (!StringUtil.isNullOrEmpty(taoBaoInfo.getRelationId()) && taoBaoInfo.getRelationValid() != null && taoBaoInfo.getRelationValid()) { |
| | | userInfo.setTbName(taoBaoInfo.getTaoBaoNickName()); |
| | | userInfo.setOpenid(taoBaoInfo.getTaoBaoUid() + ""); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 处理用户信息 |
| | | outUserInfoHandle(userInfo); |
| | | |
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); |
| | | JSONObject data = new JSONObject(); |
| | | // 界面状态 |
| | | UserSettingsVO mySettings = null; |
| | | try { |
| | | mySettings = userCustomSettingsService.getMySettings(uid); |
| | | } catch (UserCustomSettingsException e) { |
| | | mySettings = new UserSettingsVO(); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (mySettings.getCancelNotice() == null) { |
| | | mySettings.setCancelNotice(0); |
| | | } |
| | | if (mySettings.getNoBonusCount() == null) { |
| | | mySettings.setNoBonusCount(0); |
| | | } |
| | | if (mySettings.getNoNewsRedDot() == null) { |
| | | mySettings.setNoNewsRedDot(0); |
| | | } |
| | | if (mySettings.getNoShareRecordAndStorage() == null) { |
| | | mySettings.setNoShareRecordAndStorage(0); |
| | | } |
| | | if (mySettings.getNoInvitationBonus() == null) { |
| | | mySettings.setNoInvitationBonus(0); |
| | | } |
| | | |
| | | if (mySettings.getNoDisplayPhoneNum() == null) { |
| | | mySettings.setNoDisplayPhoneNum(0); |
| | | } |
| | | |
| | | if (mySettings.getOpenSpreadHongBao() == null) { |
| | | if (userTaoLiJinDetailService.countDetail(uid) > 0) { |
| | | mySettings.setOpenSpreadHongBao(1); |
| | | } else { |
| | | mySettings.setOpenSpreadHongBao(0); |
| | | } |
| | | } |
| | | data.put("moduleState", mySettings); |
| | | |
| | | boolean tailor = false; |
| | | int welfareCenterNews = 0; |
| | | String invitCode = null; |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | if (userInfoExtra.getCouponNews() != null) { |
| | | welfareCenterNews = userInfoExtra.getCouponNews(); |
| | | } |
| | | // vip邀请码优先 |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) { |
| | | invitCode = userInfoExtra.getInviteCodeVip(); |
| | | } else if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) { |
| | | tailor = true; |
| | | invitCode = userInfoExtra.getInviteCode(); |
| | | } |
| | | |
| | | if (userInfoExtra.getUserRank() != null) { |
| | | String picture = userInfoExtra.getUserRank().getPicture(); |
| | | String icon = userInfoExtra.getUserRank().getIcon(); |
| | | userInfo.setRankNamePicture(picture); |
| | | userInfo.setRankIcon(icon); |
| | | } else { |
| | | userInfo.setRankNamePicture(null); |
| | | userInfo.setRankIcon(null); |
| | | } |
| | | |
| | | // 1.6.5 之后返回性别、微信号 |
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (userInfoExtra.getSex() != null) |
| | | userInfo.setSex(userInfoExtra.getSex()); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) |
| | | userInfo.setWeiXin(userInfoExtra.getWeiXin()); |
| | | } |
| | | |
| | | // 二维码 |
| | | userInfo.setErCode(userInfoExtra.getErCode()); |
| | | } |
| | | // 显示邀请码特制入口 |
| | | data.put("tailor", tailor); |
| | | |
| | | // 1.6.5 之后返回 微信号提示 |
| | | if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | userInfo.setWeiXinTip("添加微信号后,你的邀请人和直接粉丝可以通过微信与你建立联系。"); |
| | | |
| | | // 查询是否为VIP |
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | userInfo.setVip(userVIPInfoService.isVIP(uid)); |
| | | |
| | | boolean verifyForbid = redPackForbidService.verifyForbid(uid); |
| | | data.put("redPackLock", verifyForbid); |
| | | } |
| | | |
| | | data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo)); |
| | | data.put("invitCode", invitCode); // 邀请码 |
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCodeVip())) |
| | | data.put("invitCodeUpdated", true);// 邀请码是否已经修改过 |
| | | else |
| | | data.put("invitCodeUpdated", false); |
| | | data.put("welfareCenterNews", welfareCenterNews);// 福利中心消息 |
| | | data.put("vipLink", userVipConfigService.getValueByKey("vip_link"));// 超级会员升级链接 |
| | | |
| | | if (SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.bindPhone)) { |
| | | // 2.0.1之后绑定手机号 |
| | | if (VersionUtil.greaterThan_2_0_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | boolean bindPhone = false; |
| | | if (StringUtil.isNullOrEmpty(userInfo.getPhone())) |
| | | bindPhone = bindRemindService.bindRemind(uid, BindRemind.TYPE_PHONE); |
| | | data.put("bindPhone", bindPhone); |
| | | } |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(invitCode)) { |
| | | // 2.0.6 返回邀请人 |
| | | if (VersionUtil.greaterThan_2_0_6(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String bossName = ""; |
| | | ThreeSale threeSale = threeSaleSerivce.getMyBoss(uid); |
| | | if (threeSale != null && threeSale.getBoss() != null) { |
| | | bossName = threeSale.getBoss().getNickName(); |
| | | } |
| | | data.put("bossName", bossName); |
| | | } |
| | | } |
| | | |
| | | if (VersionUtil.greaterThan_2_0_7(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | UserInviteLevelEnum level = null; |
| | | // VIP预览信息 |
| | | if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | String redisContent = previewInfoService.getRedisContent(uid, PreviewEnum.mineInfo); |
| | | if (!StringUtil.isNullOrEmpty(redisContent)) { |
| | | MineInfoVO vo = new Gson().fromJson(redisContent, MineInfoVO.class); |
| | | if (vo != null) { |
| | | if (!StringUtil.isNullOrEmpty(vo.getBalance())) |
| | | userInfo.setMyHongBao(new BigDecimal(vo.getBalance())); |
| | | |
| | | if (!StringUtil.isNullOrEmpty(vo.getLevel())) |
| | | for (UserInviteLevelEnum levelEnum : UserInviteLevelEnum.values()) { |
| | | if (levelEnum.name().equals(vo.getLevel())) { |
| | | level = levelEnum; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (level == null) { |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | level = userInviteService.getUserInviteLevelNew(uid); |
| | | } else { |
| | | level = userInviteService.getUserInviteLevel(uid); |
| | | } |
| | | } |
| | | JSONObject inviteLevel = new JSONObject(); |
| | | inviteLevel.put("level", level.name()); |
| | | inviteLevel.put("link", level.getLink()); |
| | | data.put("inviteLevel", inviteLevel); |
| | | } |
| | | |
| | | if (VersionUtil.greaterThan_2_1_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | data.put("fansCountLink", configService.getValue(ConfigKeyEnum.teamStatisticsLink.getKey(), acceptData.getSystem())); |
| | | // 会员动作 |
| | | // 查询是否为超级会员,是的话返回超会管理链接 |
| | | UserLevelEnum level = userLevelManager.getUserLevel(uid); |
| | | |
| | | JSONObject vipAction = null; |
| | | String managerLink = userVipConfigService.getValueByKey("vip_manager_link"); |
| | | if ((level == UserLevelEnum.superVIP || level == UserLevelEnum.tearcher) |
| | | && !StringUtil.isNullOrEmpty(managerLink)) { |
| | | vipAction = new JSONObject(); |
| | | vipAction.put("name", "超会管理"); |
| | | vipAction.put("jumpDetail", |
| | | jumpDetailV2Service.getByTypeCache("web", |
| | | acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2, |
| | | Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", userVipConfigService.getValueByKey("vip_manager_link")); |
| | | vipAction.put("params", params); |
| | | } else { |
| | | // 查询是否可以提交会员申请,是的话返回资料填写页面 |
| | | List<GiveVIPApplyInfo> list = giveVIPApplyInfoService.listByStateAndTargetUid(uid, |
| | | GiveVIPApplyInfo.STATE_NO_INFO, 1, 20); |
| | | if (list != null && list.size() > 0) { |
| | | String link = userVipConfigService.getValueByKey("apply_vip_upload_info_link"); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | vipAction = new JSONObject(); |
| | | vipAction.put("name", "申请会员"); |
| | | vipAction.put("jumpDetail", |
| | | jumpDetailV2Service.getByTypeCache("web", |
| | | acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2, |
| | | Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())); |
| | | JSONObject params = new JSONObject(); |
| | | params.put("url", link.replace("[ID]", list.get(0).getId())); |
| | | vipAction.put("params", params); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (vipAction != null) |
| | | data.put("vipAction", vipAction); |
| | | |
| | | } |
| | | |
| | | data.put("user", JsonUtil.getConvertBigDecimalToStringBuilder(gsonBuilder).create().toJson(userInfo)); |
| | | //拼多多是否绑定 |
| | | if (VersionUtil.greaterThan_2_1_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | boolean pddBuyBind = PinDuoDuoApiUtil.isAuth(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli), pddAuthService.getFanliCustomParams(uid)); |
| | | boolean pddShareBind = PinDuoDuoApiUtil.isAuth(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.share), pddAuthService.getFanliCustomParams(uid)); |
| | | data.put("pddBuyBind", pddBuyBind); |
| | | data.put("pddShareBind", pddShareBind); |
| | | } |
| | | |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | final UserInfo uuser = userInfo; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 获取邀请码:若无邀请码且存在有效的队员关系 则自动生成邀请码 |
| | | userInfoExtraService.getInviteCodeByUid(uuser.getId()); |
| | | |
| | | // 更新用户附加信息,老用户不存在的需要添加 |
| | | try { |
| | | userInfoExtraService.updateUserRankByUid(uuser.getId()); |
| | | } catch (UserInfoExtraException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } catch (UserInfoException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg())); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("获取失败")); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | private void outUserInfoHandle(UserInfo user) { |
| | | |
| | | // 红包处理 |
| | | user.setTotalHongBao(new BigDecimal(0)); |
| | | user.setNoOpenHongBao(new BigDecimal(0)); |
| | | user.setCanOpenHongBao(new BigDecimal(0)); |
| | | |
| | | // 电话号码处理 |
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) { |
| | | if (user.getPhone().length() > 5) { |
| | | String phone = user.getPhone().substring(0, 3); |
| | | phone += "******"; |
| | | phone += user.getPhone().substring(user.getPhone().length() - 2, user.getPhone().length()); |
| | | user.setPhone(phone); |
| | | } |
| | | } |
| | | |
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId()); |
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) { |
| | | String picture = userInfoExtra.getUserRank().getPicture(); |
| | | String icon = userInfoExtra.getUserRank().getIcon(); |
| | | user.setRankNamePicture(picture); |
| | | user.setRankIcon(icon); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 用户更换头像 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "uploadPortrait") |
| | | public void uploadPortrait(AcceptData acceptData, MultipartFile file, Long uid, HttpServletRequest request, |
| | | PrintWriter out) { |
| | | try { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | if (file == null) { |
| | | out.print(JsonUtil.loadFalseResult("上传文件不能为空")); |
| | | return; |
| | | } |
| | | |
| | | userInfoService.uploadPortrait(file, uid); |
| | | |
| | | out.print(JsonUtil.loadTrueResult("保存成功")); |
| | | |
| | | } catch (UserInfoException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } catch (IOException e) { |
| | | out.print(JsonUtil.loadFalseResult("图片上传失败失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("保存失败")); |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更换基础信息 |
| | | * |
| | | * @param acceptData |
| | | * @param nickName |
| | | * @param uid |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "saveInfo") |
| | | public void saveInfo(AcceptData acceptData, String nickName, String weiXin, Integer sex, Long uid, |
| | | String inviteCode, MultipartFile qrCodeFile, HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | if (uid == null) { |
| | | out.print(JsonUtil.loadFalseResult("用户未登录")); |
| | | return; |
| | | } |
| | | |
| | | // 修改昵称 |
| | | if (!StringUtil.isNullOrEmpty(nickName)) { |
| | | if (nickName.length() > 200) { |
| | | out.print(JsonUtil.loadFalseResult("昵称过长")); |
| | | return; |
| | | } |
| | | |
| | | if (maskKeyService.examineContent(nickName)) { |
| | | out.print(JsonUtil.loadFalseResult("不能包含敏感词汇")); |
| | | return; |
| | | } |
| | | userInfoService.saveUserInfo(nickName, uid); |
| | | |
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.nickName, nickName); |
| | | } |
| | | |
| | | // 修改微信号 |
| | | if (!StringUtil.isNullOrEmpty(weiXin)) { |
| | | if (weiXin.length() > 32) { |
| | | out.print(JsonUtil.loadFalseResult("微信号过长")); |
| | | return; |
| | | } |
| | | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | UserInfoExtra extra = new UserInfoExtra(); |
| | | extra.setId(userInfoExtra.getId()); |
| | | extra.setWeiXin(weiXin); |
| | | userInfoExtraService.saveUserInfoExtra(extra); |
| | | |
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.setWeiXinNum, weiXin); |
| | | } |
| | | } |
| | | |
| | | // 修改性别 |
| | | if (sex != null && sex > 0 && sex < 3) { |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); |
| | | if (userInfoExtra != null) { |
| | | UserInfoExtra extra = new UserInfoExtra(); |
| | | extra.setId(userInfoExtra.getId()); |
| | | extra.setSex(sex); |
| | | userInfoExtraService.saveUserInfoExtra(extra); |
| | | |
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.gender, sex + ""); |
| | | } |
| | | } |
| | | |
| | | // 修改邀请码 |
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {// 邀请码不为空 |
| | | inviteCode = inviteCode.trim(); |
| | | if (inviteCode.length() >= 4 && inviteCode.length() <= 12) { |
| | | try { |
| | | userInfoExtraService.updateInviteCodeVip(inviteCode, uid); |
| | | out.print(JsonUtil.loadTrueResult("保存成功")); |
| | | return; |
| | | } catch (UserInfoExtraException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage())); |
| | | } |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(1, "邀请码必须为4到12位")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 二维码 |
| | | if (qrCodeFile != null) { |
| | | userInfoExtraService.uploadERCode(qrCodeFile, uid); |
| | | } |
| | | |
| | | out.print(JsonUtil.loadTrueResult("保存成功")); |
| | | } catch (UserInfoException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult("保存失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |