From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java | 4923 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 2,489 insertions(+), 2,434 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java index a958c72..fd30ade 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserInfoController.java @@ -1,2434 +1,2489 @@ -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.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.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.system.ConfigKeyEnum; -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.invite.UserInviteService; -import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; -import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService; -import com.yeshi.fanli.util.AESUtil; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.FilePathEnum; -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 UserVipConfigService userVipConfigService; - - @Resource - private RedPackForbidService redPackForbidService; - - @Resource - private UserInviteService userInviteService; - - 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; - } - } - // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 - 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锛歩os if(firstIos == "1") { //绗竴娆$櫥闄� first = true; } else { - * first = false; } } - */ - if (first) { - int loginType = form.getLoginType(); - // WeiXinUserParam wxParam = null; - // 濡傛灉鏄井淇$櫥闄嗭紝閭i渶瑕佸厛鑾峰彇鍒板井淇$殑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鍒欐槸绗竴娆$櫥闄嗭紝閭d箞闇�瑕佸垽鏂敤鎴锋槸涓嶆槸琚紶閿�鏉ョ殑,濡傛灉鏄殑璇濓紝閭i渶瑕佷慨鏀圭浉鍏充笁绾у垎閿�鐨勭姸鎬� - ThreadUtil.run(new Runnable() { - @Override - public void run() { - threeSaleSerivce.effective(temp); - } - - }); - } - return; - } - // 鏌ヨ鍒扮殑鐢ㄦ埛淇℃伅涓虹┖,閭d箞闇�瑕佸~鍏呬竴浜涚敤鎴蜂俊鎭� - 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()); - 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()), - FilePathEnum.userPortrait + 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 锛宮ainUser != 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; - } - } - // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 - 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(ConfigKeyEnum.teamList.getKey())); - - // 鐣岄潰鐘舵�� - 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()), - 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(), - 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("褰撳墠鍙粦瀹氫簡涓�涓处鎴凤紝涓嶈兘瑙g粦锛�")); - return; - } - userInfoService.unBindUserInfo(find, type); - out.print(JsonUtil.loadTrueResult("瑙g粦鎴愬姛")); - } - - /** - * 鑾峰彇鐢ㄦ埛鎻愮幇璐﹀彿 - * - * @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(ConfigKeyEnum.extractMoneyDay.getKey()); // 姣忔棩鏈�澶ф彁鐜伴噾棰� - int maxDayCount = Integer.parseInt(configService.get(ConfigKeyEnum.extractDayCount.getKey())); - 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(ConfigKeyEnum.extractMoneyDay.getKey()); // 姣忔棩鏈�澶ф彁鐜伴噾棰� - int maxDayCount = Integer.parseInt(configService.get(ConfigKeyEnum.extractDayCount.getKey())); - 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) { - // 鍒ゆ柇鎵嬫満楠岃瘉鐮佺殑姝g‘鎬� - 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(ConfigKeyEnum.extractCodeEmailFrom.getKey()); - 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("璇蜂笂浼犵敤鎴稩D")); - 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(ConfigKeyEnum.teamHelpUrl.getKey()); - 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(ConfigKeyEnum.inviteActivationUrl.getKey())); - } - 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(ConfigKeyEnum.teamHelpUrl.getKey()); - 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(ConfigKeyEnum.inviteActivationUrl.getKey())); - } - 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(ConfigKeyEnum.teamHelpUrl.getKey()); - 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(ConfigKeyEnum.inviteActivationUrl.getKey())); - } - 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 - * 閭�璇穒d - * @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 - * 閭�璇穒d - * @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(ConfigKeyEnum.inviteActivationUrl.getKey())); - } else { - // 宸叉湁閭�璇风爜 - inviteData.put("content", "閭�璇风爜"); - inviteData.put("link", configService.get(ConfigKeyEnum.inviteActivationSuccessUrl.getKey())); - } - - 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); - - 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("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�"); - - // 鏌ヨ鏄惁涓篤IP - 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"));// 瓒呯骇浼氬憳鍗囩骇閾炬帴 - - // 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; - 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); - } - - 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, 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(); - } - } -} +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; + } + } + // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 + 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锛歩os if(firstIos == "1") { //绗竴娆$櫥闄� first = true; } else { + * first = false; } } + */ + if (first) { + int loginType = form.getLoginType(); + // WeiXinUserParam wxParam = null; + // 濡傛灉鏄井淇$櫥闄嗭紝閭i渶瑕佸厛鑾峰彇鍒板井淇$殑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鍒欐槸绗竴娆$櫥闄嗭紝閭d箞闇�瑕佸垽鏂敤鎴锋槸涓嶆槸琚紶閿�鏉ョ殑,濡傛灉鏄殑璇濓紝閭i渶瑕佷慨鏀圭浉鍏充笁绾у垎閿�鐨勭姸鎬� + ThreadUtil.run(new Runnable() { + @Override + public void run() { + threeSaleSerivce.effective(temp); + } + + }); + } + return; + } + // 鏌ヨ鍒扮殑鐢ㄦ埛淇℃伅涓虹┖,閭d箞闇�瑕佸~鍏呬竴浜涚敤鎴蜂俊鎭� + 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 锛宮ainUser != 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; + } + } + // 涓嶆槸鐢↖D鐨勭櫥闄嗙殑浜嬪氨澶氫簡 + 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("褰撳墠鍙粦瀹氫簡涓�涓处鎴凤紝涓嶈兘瑙g粦锛�")); + return; + } + userInfoService.unBindUserInfo(find, type); + out.print(JsonUtil.loadTrueResult("瑙g粦鎴愬姛")); + } + + /** + * 鑾峰彇鐢ㄦ埛鎻愮幇璐﹀彿 + * + * @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) { + // 鍒ゆ柇鎵嬫満楠岃瘉鐮佺殑姝g‘鎬� + 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("璇蜂笂浼犵敤鎴稩D")); + 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 閭�璇穒d + * @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("娣诲姞寰俊鍙峰悗锛屼綘鐨勯個璇蜂汉鍜岀洿鎺ョ矇涓濆彲浠ラ�氳繃寰俊涓庝綘寤虹珛鑱旂郴銆�"); + + // 鏌ヨ鏄惁涓篤IP + 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(); + } + } +} -- Gitblit v1.8.0