| | |
| | | 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 UserAccountMsgNotificationService userAccountMsgNotificationService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private UserActiveLogService userActiveLogService;
|
| | |
|
| | | @RequestMapping(value = "tb")
|
| | | public void tb(String code, String state, HttpServletRequest request, HttpServletResponse response) {
|
| | |
| | | String relationId = null;
|
| | |
|
| | | try {
|
| | | relationId= TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | relationId = TaoKeApiUtil.getRelationId(accessToken, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);// 渠道ID
|
| | | } catch (TaoBaoAuthException e) {
|
| | | if (e.getCode() == TaoBaoAuthException.CODE_NOT_REAL_NAME)
|
| | |
| | | LogHelper.test(e.getMsg());
|
| | | errCode = 5;
|
| | | }
|
| | | |
| | | final String relationId2 = relationId;
|
| | |
|
| | | final String relationId2 = relationId;
|
| | | // 异步申请会员ID
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | |
| | | LogHelper.test(uid + "会员备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addSpecialId(uid, specialId, taoBaoUid, name, true);
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId2))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | |
| | | //稍作延迟
|
| | |
|
| | | // 稍作延迟
|
| | | Thread.sleep(50);
|
| | | } else if ("zigou".equalsIgnoreCase(source)) {
|
| | | String specialId = null;
|
| | |
| | | LogHelper.test(uid + "渠道备案失败");
|
| | | try {
|
| | | userExtraTaoBaoInfoService.addRelationId(uid, relationId, taoBaoUid, name, true);
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(specialId2) && !StringUtil.isNullOrEmpty(relationId))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | //稍作延迟
|
| | | // 稍作延迟
|
| | | Thread.sleep(50);
|
| | |
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | |
| | | try {
|
| | | userExtraTaoBaoInfoService.saveUserTaoBaoInfo(uid, relationId, specialId, taoBaoUid, nickName,
|
| | | true);
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(specialId) && !StringUtil.isNullOrEmpty(relationId))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindTaoBao, taoBaoUid);
|
| | | } catch (UserExtraTaoBaoInfoException e) {
|
| | |
| | | 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");
|
| | | closeWebPage(response.getWriter());
|
| | | 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");
|
| | | closeWebPage(response.getWriter());
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/success.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | 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);
|
| | | 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");
|
| | | closeWebPage(response.getWriter());
|
| | | 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");
|
| | | closeWebPage(response.getWriter());
|
| | | if (isNewJump)
|
| | | response.sendRedirect("http://apph5.yeshitv.com/flqWeb/h5/tbauth/fail.html");
|
| | | else
|
| | | closeWebPage(response.getWriter());
|
| | | } else if ("bind".equalsIgnoreCase(source)) {
|
| | | 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);
|
| | | 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;
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | @RequestMapping(value = "/listInviteFriendImg", method = RequestMethod.POST)
|
| | | public void listInviteFriendImg(AcceptData acceptData, Long uid, PrintWriter out)
|
| | | public void listInviteFriendImg(AcceptData acceptData, Long uid, PrintWriter out)
|
| | | throws NotExistObjectException, IOException {
|
| | | JSONObject data = new JSONObject();
|
| | | if (uid != null && !uid.equals("0")) {
|
| | |
| | | }
|
| | |
|
| | | // 邀请链接
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/" |
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | String shortLink = HttpUtil.getShortLink("http://" + Constant.wxGZConfig.getLoginHost() + "/"
|
| | | + Constant.systemCommonConfig.getProjectName() + "/client/threeShareNew?uid=" + uid);
|
| | | data.put("inviteLink", shortLink);
|
| | | |
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | data.put("inviteCode", userInfoExtra.getInviteCode());
|
| | | }
|
| | | |
| | |
|
| | | // 邀请规则
|
| | | String key = "inviteRules"; // key值
|
| | | BusinessSystem system = new BusinessSystem();
|
| | |
| | | String valueBr = valueN.replace("\n", "<br><br>");
|
| | |
|
| | | data.put("helpLink", configService.get("invite_help_link"));
|
| | | |
| | |
|
| | | data.put("inviteRules", valueBr);
|
| | | out.print(JsonUtil.loadTrue(0, JsonUtil.getSimpleGson().toJson(data), "成功"));
|
| | | }
|
| | |
| | | * 邀请嘛
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key ="'activationInvite-'+#uid")
|
| | | @RequestSerializableByKey(key = "'activationInvite-'+#uid")
|
| | | @RequestMapping(value = "activationInvite")
|
| | | public void activationInvite(AcceptData acceptData, String callback, Long uid, String inviteCode, PrintWriter out) {
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 激活邀请
|
| | | *
|
| | |
| | | * 邀请嘛
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key ="'activationInviteWX-'+#uid")
|
| | | @RequestSerializableByKey(key = "'activationInviteWX-'+#uid")
|
| | | @RequestMapping(value = "activationInviteWX")
|
| | | public void activationInviteWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
|
| | | 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()));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取邀请码
|
| | | *
|
| | |
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoModifyRecordService userInfoModifyRecordService;
|
| | |
|
| | |
| | | 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);
|
| | |
| | | else
|
| | | out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount),
|
| | | "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。注:此0.1元将会在后续产生的余额中合理扣除,敬请知晓。"));
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindAlipay, account);
|
| | | } catch (AlipayTransferException e1) {
|
| | | if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
|
| | |
| | | } 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?")) {
|
| | | data.put("baichuan", true);
|
| | | 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 ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemMsgService userSystemMsgService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleExtraInfoSerivce threeSaleExtraInfoSerivce;
|
| | |
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 邀请码验证
|
| | | * |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "verifyCode")
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 邀请码微信
|
| | | * |
| | | * @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.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 用户队员列表查询 1.5.3查询有效队员
|
| | | *
|
| | |
| | | listTeam = threeSaleSerivce.listSecondTeam((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid, 1);
|
| | | count = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | }
|
| | | |
| | |
|
| | | // 组织数据
|
| | | JSONObject resultData = organizeTeam(count, listTeam, uid, type);
|
| | | |
| | |
|
| | | // 第一页判断是否激活 是否有队员
|
| | | if (type == 1 && page == 1) {
|
| | | boolean hasCode = false;
|
| | |
| | | hasCode = true;
|
| | | }
|
| | | resultData.put("hasCode", hasCode);
|
| | | resultData.put("hasTeam", count > 0? true:false);
|
| | | resultData.put("hasTeam", count > 0 ? true : false);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 组织数据
|
| | | * |
| | | * @param count
|
| | | * @param list
|
| | | * @param uid
|
| | |
| | | private JSONObject organizeTeam(long count, List<ThreeSale> list, Long uid, int type) {
|
| | | JSONObject result = new JSONObject();
|
| | | JSONArray resultArray = new JSONArray();
|
| | | |
| | |
|
| | | Date todayTime = new Date();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("MM.dd HH:mm");
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | SimpleDateFormat formatYears = new SimpleDateFormat("yyyy");
|
| | | |
| | |
|
| | | for (ThreeSale threeSale : list) {
|
| | | UserInfo worker = threeSale.getWorker();
|
| | | if (worker == null) {
|
| | | continue;
|
| | | }
|
| | | Long workerId = worker.getId();
|
| | | |
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("workerId", worker.getId());
|
| | | object.put("nickName", worker.getNickName());
|
| | | object.put("portrait", worker.getPortrait());
|
| | | object.put("inviteId", threeSale.getId());
|
| | | |
| | |
|
| | | Date inviteTime = new Date(threeSale.getCreateTime());
|
| | | object.put("inviteTime", format.format(inviteTime) + " 加入");
|
| | | |
| | |
|
| | | String fontColor1 = "#888888";
|
| | | JSONArray array = new JSONArray();
|
| | | if (threeSale.getState()) {
|
| | |
| | | contentJson.put("content", "最近登录 " + format.format(lastLoginTime));
|
| | | }
|
| | | array.add(contentJson);
|
| | | |
| | |
|
| | | // 一级队员 查询
|
| | | if(type == 1) {
|
| | | if (type == 1) {
|
| | | String memoName = null;
|
| | | ThreeSaleExtraInfo threeSaleExtraInfo = threeSale.getThreeSaleExtraInfo();
|
| | | if (threeSaleExtraInfo != null) {
|
| | |
| | | }
|
| | | }
|
| | | object.put("memoName", memoName);
|
| | | |
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(workerId);
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | object.put("weiXin", userInfoExtra.getWeiXin());
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | } |
| | | }
|
| | | object.put("state", 1);
|
| | | object.put("recentMsg", array);
|
| | | resultArray.add(object);
|
| | |
| | | return result;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户队员统计- IOS
|
| | | *
|
| | |
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | JSONObject bossData = getBossInfo(acceptData, uid, threeSaleSerivce.getMyBoss(uid));
|
| | | JSONObject resultData = new JSONObject();
|
| | | |
| | |
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | resultData.put("boss", bossData);
|
| | | resultData.put("helpLink", configService.get("team_help_url"));
|
| | |
| | | resultData.put("firstTeamTotal", threeSaleSerivce.countFirstTeam(uid, null));
|
| | | resultData.put("secondTeam", threeSaleSerivce.countSecondTeam(uid, 1));
|
| | | resultData.put("secondTeamTotal", threeSaleSerivce.countSecondTeam(uid, null));
|
| | | |
| | |
|
| | | boolean hasTeam = true;
|
| | | if (firstTeam <= 0) {
|
| | | hasTeam = false;
|
| | | resultData.put("invitelink", configService.get("invite_activation_url"));
|
| | | }
|
| | | resultData.put("hasTeam", hasTeam);
|
| | | |
| | |
|
| | | boolean hasCode = false;
|
| | | boolean bdWeiXin = false;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null) {
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode()))
|
| | | hasCode = true;
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin()))
|
| | | bdWeiXin = true;
|
| | | }
|
| | | |
| | |
|
| | | // 未激活邀请码
|
| | | resultData.put("hasCode", hasCode);
|
| | | if (!hasCode) {
|
| | |
| | | tipCode.add("邀请激活功能,必须要有邀请码,邀请码可以通过金币兑换,也可以全网搜索。");
|
| | | resultData.put("tipCode", tipCode);
|
| | | }
|
| | | |
| | |
|
| | | // 未添加微信号
|
| | | List<String> tipWeiXin = new ArrayList<String>();
|
| | | if (!bdWeiXin) {
|
| | |
| | | resultData.put("tipWeiXin", tipWeiXin);
|
| | | resultData.put("tipWeiXinAdd", "添加微信号后,你的邀请人和一级队员可以通过微信与你建立联系。");
|
| | | resultData.put("bdWeiXin", bdWeiXin);
|
| | | |
| | |
|
| | | out.print(JsonUtil.loadTrueResult(resultData));
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 上级信息组织
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param threeSale
|
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | | |
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | bossData.put("weiXin", userInfoExtra.getWeiXin());
|
| | |
| | | } else {
|
| | | bossData.put("hasBoss", false);
|
| | | bossData.put("helpLink", configService.get("invite_code_hlep_link"));
|
| | | bossData.put("weiXinTip", "恭喜你,我们的优质用户;\r\n你并没有邀请人,但你的邀请激活功能是被默认开启的;\r\n你拥有独特的无邀请人激活码。"); |
| | | bossData.put("weiXinTip", "恭喜你,我们的优质用户;\r\n你并没有邀请人,但你的邀请激活功能是被默认开启的;\r\n你拥有独特的无邀请人激活码。");
|
| | | }
|
| | | return bossData;
|
| | | } |
| | | |
| | | |
| | | |
| | | }
|
| | |
|
| | | /**
|
| | | * 站内信提醒队员添加微信号
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param inviteId
|
| | |
| | | out.print(JsonUtil.loadFalseResult("传递参数缺失"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户信息不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | ThreeSale threeSale = threeSaleSerivce.selectByPrimaryKey(inviteId);
|
| | | if (threeSale == null) {
|
| | | out.print(JsonUtil.loadFalseResult("关系id不存在"));
|
| | | return;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | Long remindId = null;
|
| | | boolean remindBoss = true;
|
| | | if (uid.longValue() == threeSale.getWorker().getId().longValue()) {
|
| | |
| | | } else if (uid.longValue() == threeSale.getBoss().getId().longValue()) {
|
| | | remindBoss = false;
|
| | | remindId = threeSale.getWorker().getId(); // 提醒下级
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | if (remindId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("信息验证未通过"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Long bossId = null;
|
| | | Long workerId = null;
|
| | | String title = "队员提醒消息";
|
| | |
| | | // 提示队长
|
| | | bossId = remindId;
|
| | | workerId = uid;
|
| | | content = "你的一级队员"+ userInfo.getNickName() +",提醒你添加微信号,以便于和你取得联系和学习省钱技巧,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | content = "你的一级队员" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系和学习省钱技巧,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | } else {
|
| | | // 提示队员
|
| | | bossId = uid;
|
| | | workerId = remindId;
|
| | | content = "你的邀请人"+ userInfo.getNickName() +",提醒你添加微信号,以便于和你取得联系帮助你更好的省钱,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | content = "你的邀请人" + userInfo.getNickName()
|
| | | + ",提醒你添加微信号,以便于和你取得联系帮助你更好的省钱,赶快去添加吧;注:请升级到本软件最新版本在“我的-我的信息”中添加。";
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | List<String> listIOS = new ArrayList<String>();
|
| | | 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) {
|
| | | newInfo.setRemindBoss(1);
|
| | | } else {
|
| | | newInfo.setRemindWorker(1);
|
| | | }
|
| | | |
| | |
|
| | | ThreeSaleExtraInfo threeExtra = threeSaleExtraInfoSerivce.getbyBossIdAndWorkerId(bossId, workerId);
|
| | | if (threeExtra != null) {
|
| | | newInfo.setId(threeExtra.getId());
|
| | |
| | | newInfo.setUpdateTime(new Date());
|
| | | threeSaleExtraInfoSerivce.insertSelective(newInfo);
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("weiXinState", 2);
|
| | | data.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | |
| | | 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);
|
| | | LogHelper.error("推广红包比例:" + warningRate);
|
| | | BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
|
| | | LogHelper.error("推广红包:"+spreadMoney);
|
| | | LogHelper.error("推广红包:" + spreadMoney);
|
| | | // 推广红包 不能小于1
|
| | | if (spreadMoney.compareTo(new BigDecimal(1.1)) < 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "该商品淘礼金不足"));
|
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, "无法获取到微信个人信息");
|
| | |
|
| | |
| | | if (StringUtil.isNullOrEmpty(user.getPortrait()))
|
| | | user.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | userInfoMapper.insertSelective(user);
|
| | | |
| | |
|
| | | // 昵称为空时 默认昵称
|
| | | if (StringUtil.isNullOrEmpty(user.getNickName())) {
|
| | | UserInfo updateUserInfo = new UserInfo(user.getId());
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | |
| | | if (!StringUtil.isNullOrEmpty(user.getPhone())) |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone());
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId());
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | 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());
|
| | | updateUserInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | updateUserInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | updateUserInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | |
| | |
|
| | | // 将默认昵称替换成微信昵称
|
| | | String defaultNickName = Constant.systemCommonConfig.getDefaultNickName();
|
| | | if (!StringUtil.isNullOrEmpty(defaultNickName) && !StringUtil.isNullOrEmpty(weiXinUser.getNickname())) {
|
| | |
| | | && defaultPortrait.equals(user.getPortrait())) {
|
| | | updateUserInfo.setPortrait(weiXinUser.getHeadimgurl());
|
| | | }
|
| | | |
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | | userAccountMsgNotificationService.changeBindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX);
|
| | | |
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid());
|
| | | }
|
| | |
|
| | |
| | | if (exec == null || exec.size() == 0) {
|
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | } else {
|
| | | |
| | |
|
| | | // 查询是否存在该电话历史用户
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | if (userInfo != null) {
|
| | |
| | | } else {
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setAppId(appId);
|
| | | //userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName());
|
| | | // userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName());
|
| | | userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | userInfo.setPhone(phone);
|
| | | userInfo.setLoginType(loginType);
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindPhone, phone);
|
| | | }
|
| | | |
| | |
|
| | | return userInfo;
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | @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, "微信帐号授权失败");
|
| | | }
|
| | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid());
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin,
|
| | | weiXinUser.getUnionid());
|
| | | }
|
| | | return userInfo;
|
| | | }
|
| | |
| | |
|
| | | // 发送消息
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | | |
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone);
|
| | | |
| | |
|
| | | }
|
| | |
|
| | | @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, "微信帐号授权失败");
|
| | | }
|
| | |
| | | updateUserInfo.setNickName(weiXinUser.getNickname());
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | // 将默认头像替换成微信头像
|
| | | String defaultPortrait = Constant.systemCommonConfig.getDefaultPortrait();
|
| | | if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl()) && !StringUtil.isNullOrEmpty(defaultPortrait)
|
| | |
| | | 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())) {
|
| | |
|