| | |
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionAuthRecord;
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionAuthRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserActiveLogService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | |
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @RequestMapping(value = "tb")
|
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
|
| | |
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(uid);
|
| | |
|
| | | boolean isNewJump = false;
|
| | | if (activeLog != null) {
|
| | | String platform = null;
|
| | | String version = activeLog.getVersionCode();
|
| | | if (activeLog.getChannel().equalsIgnoreCase("appstore")) {
|
| | | platform = "ios";
|
| | | } else {
|
| | | platform = "android";
|
| | | }
|
| | | if (VersionUtil.greaterThan_2_0(platform, version)) {
|
| | | isNewJump = true;
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | if (errCode == 0)// 成功
|
| | | {
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | | // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=0");
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=0");
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | else {
|
| | | String script = String.format(
|
| | | "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"恭喜你,淘宝绑定成功\");yestv.finishPage();}</script>",
|
| | | StringUtil.getBase64String("恭喜你,淘宝绑定成功"));
|
| | | response.getWriter().print(script);
|
| | | }
|
| | | }
|
| | | } else {// 失败
|
| | | if ("share".equalsIgnoreCase(source)) {
|
| | | // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_bonusState.html?code=1");
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | // response.sendRedirect("http://apph5.yeshitv.com/apppage/flq_rebateState.html?code=1");
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | else {
|
| | | String script = String.format(
|
| | | "<script>if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {window.location.href = 'yestv://toast#%s';setTimeout(function(){window.location.href = 'yestv://finishPage';},100);} else {yestv.toast(\"抱歉,淘宝绑定失败\");yestv.finishPage();}</script>",
|
| | | StringUtil.getBase64String("抱歉,淘宝绑定失败"));
|
| | | response.getWriter().print(script);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
| | | data.put("serviceProtocolLink", serviceProtocol);
|
| | | data.put("privacyProtocolLink", privacyProtocol);
|
| | | // 购物车跳转方式(包含jumpDetail与params)
|
| | | JSONObject source = JSONObject.fromObject(configService.get("taobao_cart_jump_detail"));
|
| | | JSONObject source = JSONObject.fromObject(configService.getByVersion("taobao_cart_jump_detail",
|
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion())));
|
| | | data.put("taoBaoCart", source);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | |
| | | data.put("topBanner", pictureJson);
|
| | | }
|
| | |
|
| | |
|
| | | data.put("desc", configService.get("invite_desc"));
|
| | |
|
| | | boolean hasCode = false;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 激活邀请
|
| | | *
|
| | |
| | | @RequestMapping(value = "activationInviteWX")
|
| | | public void activationInviteWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
|
| | | try {
|
| | | userInfoExtraService.activationInviteWX(uid, code);
|
| | | userInfoExtraService.activationInviteWX(
|
| | | Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()), uid, code);
|
| | | out.print(JsonUtil.loadTrueResult("邀请码激活成功"));
|
| | | } catch (UserInfoExtraException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取邀请码
|
| | |
| | | import org.yeshi.utils.encrypt.DESUtil;
|
| | |
|
| | | import com.alipay.api.AlipayApiException;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
|
| | |
| | | tbUserInfo.setTbPic(tbPortrait);
|
| | |
|
| | | try {
|
| | | LoginResult result = userAccountService.login(request, first, system.getAppid(), code, phone, tbUserInfo,
|
| | | wxinstall, loginType);
|
| | | LoginResult result = userAccountService.login(request, acceptData, first, system.getAppid(), code, phone,
|
| | | tbUserInfo, wxinstall, loginType);
|
| | | if (result == null)
|
| | | LogHelper.error("login-result为空值");
|
| | |
|
| | |
| | | }
|
| | | UserInfo user = null;
|
| | | if (!StringUtil.isNullOrEmpty(code)) {
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO accountInfo = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | |
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, accountInfo.getAppId(),
|
| | | accountInfo.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "获取微信用户信息失败"));
|
| | | return;
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | userAccountService.changeWXBind(uid, code);
|
| | | userAccountService.changeWXBind(acceptData, uid, code);
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | // 判断taoBaoUid是否已经封禁
|
| | | ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
|
| | |
| | | String[] ALIPAY_CODES = new String[] { "SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
|
| | | "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
|
| | | "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT" };
|
| | | BindingAccount oldBindingAccount = bindingAccountService.getBindingAccountByUidAndType(uid,
|
| | | BindingAccount.TYPE_ALIPAY);
|
| | | try {
|
| | | BigDecimal balance = user.getMyHongBao();
|
| | | BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
|
| | |
| | | } catch (AlipayAccountException e3) {
|
| | | // 账户无余额
|
| | | if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
|
| | | out.print(JsonUtil.loadFalseResult(5, "你的账户目前没有余额,无需绑定提现账号。"));
|
| | | if (oldBindingAccount != null) {
|
| | | out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,无需修改,请有余额后修改"));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(5, "当前账户没有余额,请有余额后绑定"));
|
| | | }
|
| | | return;
|
| | | // 提现次数限制
|
| | | } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
|
| | |
| | |
|
| | | // 微信登录
|
| | | if (loginType == 2) {
|
| | | userInfo = userAccountService.loginWinXin(request, loginType, code, system.getAppid());
|
| | | userInfo = userAccountService.loginWinXin(request, acceptData, loginType, code, system.getAppid());
|
| | | }
|
| | |
|
| | | if (userInfo == null) {
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | userAccountService.bindWeiXin(uid, code);
|
| | | userAccountService.bindWeiXin(acceptData,uid, code);
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | // 判断taoBaoUid是否已经封禁
|
| | |
| | | import com.yeshi.fanli.dto.HongBaoDTO;
|
| | | import com.yeshi.fanli.dto.money.AccountDetails;
|
| | | import com.yeshi.fanli.dto.order.OrderItem;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountMessage;
|
| | |
| | | int loginType = form.getLoginType();
|
| | | // WeiXinUserParam wxParam = null;
|
| | | // 如果是微信登陆,那需要先获取到微信的unionid
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | 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) {
|
| | |
| | | * StringUtil.isNullOrEmpty(form
|
| | | * .getWxOpenId())
|
| | | */) {
|
| | | WeiXinUser xinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | |
|
| | | 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;
|
| | |
| | | }
|
| | | int loginType = form.getLoginType();
|
| | | if (loginType == Constant.WEIXIN) {
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO account = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, account.getAppId(),
|
| | | account.getAppSecret());
|
| | |
|
| | | if (weiXinUser == null) {
|
| | | out.print(JsonUtil.loadFalseResult("绑定失败,用户异常请重试!"));
|
| | |
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | if (url != null && url.contains("ifeeds.tmall.com/article.html?")) {
|
| | | if (VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | data.put("baichuan", false);
|
| | | else
|
| | | data.put("baichuan", true);
|
| | | data.put("goodsDetail", false);
|
| | | } else if (url != null && (url.contains("s.click") || url.contains("taobao.com") || url.contains("tmall.com")
|
| | | || url.contains("m.tb.cn"))) {
|
| | | data.put("baichuan", true);// 采用阿里百川的方式加载webview
|
| | | if (VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | data.put("baichuan", false);
|
| | | else
|
| | | data.put("baichuan", true);
|
| | | data.put("goodsDetail", true);// 需要拦截商品详情
|
| | | } else if (url != null && (url.contains("jd.com"))) {
|
| | | // 不能包含详情页
|
| | |
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/invite")
|
| | | public class InviteControllerV2 {
|
| | |
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | |
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 邀请码验证
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "verifyCode")
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 邀请码微信
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "verifyWX")
|
| | | public void verifyWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
|
| | | try {
|
| | | UserInfo userInfo = userInfoExtraService.getInviterInfo(uid, code);
|
| | | UserInfo userInfo = userInfoExtraService.getInviterInfo(
|
| | | Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()), uid, code);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("nickName", userInfo.getNickName());
|
| | | data.put("portrait", userInfo.getPortrait());
|
| | |
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 组织数据
|
| | | * |
| | | * @param count
|
| | | * @param list
|
| | | * @param uid
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户队员统计- IOS
|
| | | *
|
| | |
| | |
|
| | | /**
|
| | | * 上级信息组织
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param threeSale
|
| | |
| | | return bossData;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 站内信提醒队员添加微信号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId
|
| | |
| | | // 提示队长
|
| | | bossId = remindId;
|
| | | workerId = uid;
|
| | | content = "你的一级队员"+ userInfo.getNickName() +",提醒你添加微信号,以便于和你取得联系和学习省钱技巧,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | content = "你的一级队员" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系和学习省钱技巧,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | } else {
|
| | | // 提示队员
|
| | | bossId = uid;
|
| | | workerId = remindId;
|
| | | content = "你的邀请人"+ userInfo.getNickName() +",提醒你添加微信号,以便于和你取得联系帮助你更好的省钱,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | content = "你的邀请人" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系帮助你更好的省钱,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | }
|
| | |
|
| | | try {
|
| | |
| | | List<String> listAndroid = new ArrayList<String>();
|
| | | pushService.pushZNX(remindId, title, content, listIOS, listAndroid);
|
| | |
|
| | | userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common,
|
| | | title, content, UserSystemMsg.TIME_TAG_COMMON, null);
|
| | | userSystemMsgService.addUserSystemMsg(remindId, UserSystemMsgTypeEnum.common, title, content,
|
| | | UserSystemMsg.TIME_TAG_COMMON, null);
|
| | |
|
| | | ThreeSaleExtraInfo newInfo = new ThreeSaleExtraInfo();
|
| | | if (remindBoss) {
|
| | |
| | | try {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(auctionId);
|
| | | } catch (TaobaoGoodsDownException e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (goods.getTkRate() == null || goods.getTkRate().compareTo(new BigDecimal(0)) <= 0) {
|
| | | //TaoKeApiUtil.specialConvertCoupon(auctionId, app);
|
| | |
|
| | | }
|
| | |
|
| | | // 计算推广红包
|
| | | String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
|
| | | LogHelper.error("推广红包比例:"+warningRate);
|
New file |
| | |
| | | package com.yeshi.fanli.dto.wx;
|
| | |
|
| | | public class WXAccountInfoDTO {
|
| | | // 公众号
|
| | | private String gzAppId;
|
| | | private String gzAppSecret;
|
| | | // APP
|
| | | private String appId;
|
| | | private String appSecret;
|
| | |
|
| | | public WXAccountInfoDTO(String gzAppId, String gzAppSecret, String appId, String appSecret) {
|
| | | this.gzAppId = gzAppId;
|
| | | this.gzAppSecret = gzAppSecret;
|
| | | this.appId = appId;
|
| | | this.appSecret = appSecret;
|
| | | }
|
| | | |
| | | public WXAccountInfoDTO() {
|
| | | }
|
| | |
|
| | | public String getGzAppId() {
|
| | | return gzAppId;
|
| | | }
|
| | |
|
| | | public void setGzAppId(String gzAppId) {
|
| | | this.gzAppId = gzAppId;
|
| | | }
|
| | |
|
| | | public String getGzAppSecret() {
|
| | | return gzAppSecret;
|
| | | }
|
| | |
|
| | | public void setGzAppSecret(String gzAppSecret) {
|
| | | this.gzAppSecret = gzAppSecret;
|
| | | }
|
| | |
|
| | | public String getAppId() {
|
| | | return appId;
|
| | | }
|
| | |
|
| | | public void setAppId(String appId) {
|
| | | this.appId = appId;
|
| | | }
|
| | |
|
| | | public String getAppSecret() {
|
| | | return appSecret;
|
| | | }
|
| | |
|
| | | public void setAppSecret(String appSecret) {
|
| | | this.appSecret = appSecret;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.BindingAccount;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
|
| | |
| | | @Resource
|
| | | private JedisPool jedisPool;
|
| | |
|
| | | |
| | | @Lazy
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public LoginResult login(HttpServletRequest request, Boolean first, String appId, String code, String phone,
|
| | | UserInfo tbUserInfo, boolean wxinstall, int loginType) throws UserAccountException {
|
| | | public LoginResult login(HttpServletRequest request, AcceptData acceptData, Boolean first, String appId,
|
| | | String code, String phone, UserInfo tbUserInfo, boolean wxinstall, int loginType)
|
| | | throws UserAccountException {
|
| | |
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | |
| | |
|
| | | case 2:// 微信
|
| | | // 通过Code换取信息
|
| | | weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(1001, "无法获取到微信个人信息");
|
| | | LogHelper.test("微信授权用户信息:" + new Gson().toJson(weiXinUser));
|
| | |
| | | }
|
| | |
|
| | | } else {// 没有安装微信
|
| | | LoginResult result = loginNoInstallWX(appId, code, phone, tbUserInfo, loginType);
|
| | | LoginResult result = loginNoInstallWX(acceptData, appId, code, phone, tbUserInfo, loginType);
|
| | | if (result.getType() == LoginResult.TYPE_CREATE)
|
| | | session.setAttribute("LAST_LOGIN_USER", result.getUser());
|
| | | return result;
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public LoginResult loginNoInstallWX(String appId, String code, String phone, UserInfo tbUserInfo, int loginType)
|
| | | throws UserAccountException {
|
| | | public LoginResult loginNoInstallWX(AcceptData acceptData, String appId, String code, String phone,
|
| | | UserInfo tbUserInfo, int loginType) throws UserAccountException {
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | | logInfo.put("code", code);
|
| | |
| | | break;
|
| | | case 2:// 微信
|
| | | // 通过Code换取信息
|
| | | weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(1001, "无法获取到微信个人信息");
|
| | |
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(user.getPhone()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone());
|
| | |
|
| | |
| | | update.setPhone(phone);
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void changeWXBind(Long uid, String code) throws UserAccountException {
|
| | | public void changeWXBind(AcceptData acceptData, Long uid, String code) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(10, "获取微信用户信息失败");
|
| | | if (weiXinUser.getUnionid().equalsIgnoreCase(user.getWxUnionId()))
|
| | |
| | |
|
| | | UserInfo newUser = getUserInfoByWXUnionId(user.getAppId(), weiXinUser.getUnionid());
|
| | | if (newUser != null)
|
| | | throw new UserAccountException(13, "亲,你要更换绑定的微信号已被其他账号绑定");
|
| | | throw new UserAccountException(13, "该微信号已被其他账号绑定");
|
| | |
|
| | | UserInfo updateUserInfo = new UserInfo(uid);
|
| | | updateUserInfo.setWxName(weiXinUser.getNickname());
|
| | |
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | | userAccountMsgNotificationService.changeBindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX);
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid());
|
| | | }
|
| | |
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public UserInfo loginWinXin(HttpServletRequest request, int loginType, String code, String appId)
|
| | | throws UserAccountException {
|
| | | public UserInfo loginWinXin(HttpServletRequest request, AcceptData acceptData, int loginType, String code,
|
| | | String appId) throws UserAccountException {
|
| | | // 日志信息
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | |
| | | LogHelper.lgoinInfo(logInfo.toString());
|
| | |
|
| | | // 通过Code换取信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(1, "微信帐号授权失败");
|
| | | }
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid());
|
| | | userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin,
|
| | | weiXinUser.getUnionid());
|
| | | }
|
| | | return userInfo;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void bindWeiXin(Long uid, String code) throws UserAccountException {
|
| | | public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | | if (user == null) {
|
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | |
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(),
|
| | | wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | |
| | | userAccountBindingHistoryService.addUserAccountBindingHistory(history);
|
| | |
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX);
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, wxUnionId);
|
| | | }
|
| | |
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserInfoExtraMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserRankRecordMapper;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public void activationInviteWX(Long uid, String code) throws UserInfoExtraException{
|
| | | public void activationInviteWX(WXAccountInfoDTO wxAccount, Long uid, String code) throws UserInfoExtraException{
|
| | | if (uid == null || code == null) {
|
| | | throw new UserInfoExtraException(1, "激活信息不完整");
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 获取微信信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code);
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code,wxAccount.getAppId(),wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public UserInfo getInviterInfo(Long uid, String code) throws UserInfoExtraException{
|
| | | public UserInfo getInviterInfo(WXAccountInfoDTO wxAccount,Long uid, String code) throws UserInfoExtraException{
|
| | | if (code == null) {
|
| | | throw new UserInfoExtraException(1, "code信息不完整");
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 获取微信信息
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code);
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code,wxAccount.getAppId(),wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserInfoExtraException(1, "微信授权失败");
|
| | | }
|
| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.LoginResult;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | |
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public LoginResult login(HttpServletRequest request, Boolean first, String appId, String code, String phone,
|
| | | public LoginResult login(HttpServletRequest request,AcceptData acceptData, Boolean first, String appId, String code, String phone,
|
| | | UserInfo tbUserInfo, boolean wxinstall, int loginType) throws UserAccountException;
|
| | |
|
| | | /**
|
| | |
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public LoginResult loginNoInstallWX(String appId, String code, String phone, UserInfo tbUserInfo, int loginType)
|
| | | public LoginResult loginNoInstallWX(AcceptData acceptData, String appId, String code, String phone, UserInfo tbUserInfo, int loginType)
|
| | | throws UserAccountException;
|
| | |
|
| | | /**
|
| | |
| | | * @param uid
|
| | | * @param code
|
| | | */
|
| | | public void changeWXBind(Long uid, String code) throws UserAccountException;
|
| | | public void changeWXBind(AcceptData acceptData,Long uid, String code) throws UserAccountException;
|
| | |
|
| | | /**
|
| | | * 清理用户头像
|
| | |
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public UserInfo loginWinXin(HttpServletRequest request,int loginType, String code, String appId)
|
| | | public UserInfo loginWinXin(HttpServletRequest request,AcceptData acceptData,int loginType, String code, String appId)
|
| | | throws UserAccountException;
|
| | |
|
| | | /**
|
| | |
| | | * @param code
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public void bindWeiXin(Long uid, String code) throws UserAccountException;
|
| | | public void bindWeiXin(AcceptData acceptData,Long uid, String code) throws UserAccountException;
|
| | |
|
| | | /**
|
| | | * 账户封禁
|
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.UserRank;
|
| | |
| | | * @param code
|
| | | * @throws UserInfoExtraException
|
| | | */
|
| | | public void activationInviteWX(Long uid, String code) throws UserInfoExtraException;
|
| | | public void activationInviteWX(WXAccountInfoDTO wxAccount,Long uid, String code) throws UserInfoExtraException;
|
| | |
|
| | | /**
|
| | | * 判断是否是新用户
|
| | |
| | | * @return
|
| | | * @throws UserInfoExtraException
|
| | | */
|
| | | public UserInfo getInviterInfo(Long uid, String code) throws UserInfoExtraException;
|
| | | public UserInfo getInviterInfo(WXAccountInfoDTO wxAccount,Long uid, String code) throws UserInfoExtraException;
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import org.yeshi.utils.annotation.MapUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.dto.wx.WXAccountInfoDTO;
|
| | | import com.yeshi.fanli.entity.config.AlipayConfig;
|
| | | import com.yeshi.fanli.entity.config.ConstantConfig;
|
| | | import com.yeshi.fanli.entity.config.SMSConfig;
|
| | |
| | | else
|
| | | return "返利券";
|
| | | }
|
| | |
|
| | | public static WXAccountInfoDTO getWXAccount(String platform, String version) {
|
| | | // if (VersionUtil.greaterThan_2_0(platform, version)) {
|
| | | // return new WXAccountInfoDTO("wxa99686bb65a9f466", "57390718ddedaa1591f6876cdcf96f43", "wx879fb78463222cd5",
|
| | | // "2ad8ec333a9f96b13c5c5c1c2b13cd67");
|
| | | // } else {
|
| | | return new WXAccountInfoDTO("wx43617e2ed82c5b28", "f8a65908fb4681bdd181de70f6ab9a3b", "wx5c0d167c6e3ad726",
|
| | | "0c79d5869bb0f2d7c13e43f9a18f440d");
|
| | | // }
|
| | | }
|
| | | }
|
| | |
| | | public static String WEXIN_APPID = "wx43617e2ed82c5b28";
|
| | | public static String WEXIN_SECRET = "f8a65908fb4681bdd181de70f6ab9a3b";
|
| | |
|
| | | static String APPID = "wx5c0d167c6e3ad726";
|
| | | static String SECRET = "0c79d5869bb0f2d7c13e43f9a18f440d";
|
| | |
|
| | | static {
|
| | | WEXIN_APPID = Constant.systemCommonConfig.getWxGZAppId();
|
| | | WEXIN_SECRET = Constant.systemCommonConfig.getWxGZAppSecret();
|
| | | APPID = Constant.systemCommonConfig.getWxOpenAppId();
|
| | | SECRET = Constant.systemCommonConfig.getWxOpenAppSecret();
|
| | | }
|
| | |
|
| | | // 通过code获取access_token openId
|
| | |
| | |
|
| | | public static String weiXinUrl2 = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";
|
| | |
|
| | | public static WeiXinUserParam getWxParam(String code) {
|
| | | String wxUrl = String.format(weiXinUrl1, APPID, SECRET, code);
|
| | | public static WeiXinUserParam getWxParam(String code,String appId,String appSecret) {
|
| | | String wxUrl = String.format(weiXinUrl1, appId, appSecret, code);
|
| | | String result = HttpUtil.get(wxUrl);
|
| | | WeiXinUserParam weiXinUserParam = getWeiXinUserParam(result);
|
| | | return weiXinUserParam;
|
| | |
| | | return weiXinUser;
|
| | | }
|
| | |
|
| | | public static WeiXinUser getWeiXinUser(String code) {
|
| | | WeiXinUserParam param = getWxParam(code);
|
| | | public static WeiXinUser getWeiXinUser(String code,String appId,String appSecret) {
|
| | | WeiXinUserParam param = getWxParam(code,appId,appSecret);
|
| | | if (param == null) {
|
| | | return null;
|
| | | }
|
| | |
| | | * @param code
|
| | | * @return
|
| | | */
|
| | | public static WeiXinUser getWeiXinUserWithSavePortrait(String code) {
|
| | | WeiXinUser user = getWeiXinUser(code);
|
| | | public static WeiXinUser getWeiXinUserWithSavePortrait(String code,String appId,String appSecret) {
|
| | | WeiXinUser user = getWeiXinUser(code,appId,appSecret);
|
| | | if (user != null) {
|
| | | if (!StringUtil.isNullOrEmpty(user.getHeadimgurl())) {
|
| | |
|