Commit a30c7e989b66afdbf16e357e0acb03e9a42099b4
Merge remote-tracking branch 'origin/dev' into dev
Showing
12 changed files
with
333 additions
and
324 deletions
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/common/ErrorMessage.java
@@ -45,6 +45,7 @@ public final class ErrorMessage { | @@ -45,6 +45,7 @@ public final class ErrorMessage { | ||
45 | public static final String USER_NOT_LOGIN = "用户没有登录,请登录"; | 45 | public static final String USER_NOT_LOGIN = "用户没有登录,请登录"; |
46 | public static final String USER_LOGIN_MULTI = "你的账号在其他设备登录,您被迫下线!"; | 46 | public static final String USER_LOGIN_MULTI = "你的账号在其他设备登录,您被迫下线!"; |
47 | public static final String USER_NOT_EXIST = "用户信息不存在,请重新操作"; | 47 | public static final String USER_NOT_EXIST = "用户信息不存在,请重新操作"; |
48 | + public static final String USER_SEARCH_FAILED = "查询用户信息失败"; | ||
48 | public static final String USER_PASSWORD_WRONG = "原始密码输入错误,请重新输入"; | 49 | public static final String USER_PASSWORD_WRONG = "原始密码输入错误,请重新输入"; |
49 | public static final String USER_MOBILE_EXIST = "手机号码已经存在,请重新输入"; | 50 | public static final String USER_MOBILE_EXIST = "手机号码已经存在,请重新输入"; |
50 | public static final String USER_MOBILE_NOT_EXIST = "用户不存在,请重新输入"; | 51 | public static final String USER_MOBILE_NOT_EXIST = "用户不存在,请重新输入"; |
@@ -63,7 +64,7 @@ public final class ErrorMessage { | @@ -63,7 +64,7 @@ public final class ErrorMessage { | ||
63 | public static final String SELLER_NOT_OPEN_SHOP ="您还未开通店铺,请到网站进行开通"; | 64 | public static final String SELLER_NOT_OPEN_SHOP ="您还未开通店铺,请到网站进行开通"; |
64 | public static final String SELLER_SHOP_NOT_AUDIT ="您的店铺还未审核通过,请等待审核"; | 65 | public static final String SELLER_SHOP_NOT_AUDIT ="您的店铺还未审核通过,请等待审核"; |
65 | public static final String USER_FAVORITE_ADD_ERROR ="添加收藏失败,请重新操作"; | 66 | public static final String USER_FAVORITE_ADD_ERROR ="添加收藏失败,请重新操作"; |
66 | - | 67 | + public static final String BUYER_NOT_OPEN_SHOP ="您还未绑定店铺"; |
67 | 68 | ||
68 | 69 | ||
69 | /** | 70 | /** |
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/common/ResultCode.java
@@ -47,6 +47,8 @@ public final class ResultCode { | @@ -47,6 +47,8 @@ public final class ResultCode { | ||
47 | * 用户电话已经存在 | 47 | * 用户电话已经存在 |
48 | */ | 48 | */ |
49 | public static final int USER_MOBILE_EXIST = 1100; | 49 | public static final int USER_MOBILE_EXIST = 1100; |
50 | + | ||
51 | + | ||
50 | /** | 52 | /** |
51 | * 设置默认提货人失败 | 53 | * 设置默认提货人失败 |
52 | */ | 54 | */ |
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/login/LoginResp.java
@@ -52,8 +52,8 @@ public class LoginResp extends BaseResp { | @@ -52,8 +52,8 @@ public class LoginResp extends BaseResp { | ||
52 | @ApiModelProperty(value = "当前绑定的店铺id") | 52 | @ApiModelProperty(value = "当前绑定的店铺id") |
53 | private Long currentShopId; | 53 | private Long currentShopId; |
54 | 54 | ||
55 | - @ApiModelProperty(value = "店铺购买者ID") | ||
56 | - private Long shopBuyerId; | 55 | + //@ApiModelProperty(value = "店铺购买者ID") |
56 | + //private Long shopBuyerId; | ||
57 | 57 | ||
58 | 58 | ||
59 | public Long getBuyerId() { | 59 | public Long getBuyerId() { |
@@ -73,13 +73,13 @@ public class LoginResp extends BaseResp { | @@ -73,13 +73,13 @@ public class LoginResp extends BaseResp { | ||
73 | this.currentShopId = currentShopId; | 73 | this.currentShopId = currentShopId; |
74 | } | 74 | } |
75 | 75 | ||
76 | - public Long getShopBuyerId() { | ||
77 | - return shopBuyerId; | ||
78 | - } | ||
79 | - | ||
80 | - public void setShopBuyerId(Long shopBuyerId) { | ||
81 | - this.shopBuyerId = shopBuyerId; | ||
82 | - } | 76 | + //public Long getShopBuyerId() { |
77 | + // return shopBuyerId; | ||
78 | + //} | ||
79 | + // | ||
80 | + //public void setShopBuyerId(Long shopBuyerId) { | ||
81 | + // this.shopBuyerId = shopBuyerId; | ||
82 | + //} | ||
83 | 83 | ||
84 | /** | 84 | /** |
85 | * get value of LoginResp.accountName | 85 | * get value of LoginResp.accountName |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/PassportRPC.java
1 | package com.diligrp.mobsite.getway.rpc; | 1 | package com.diligrp.mobsite.getway.rpc; |
2 | 2 | ||
3 | +import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | ||
4 | +import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | ||
3 | import com.diligrp.mobsite.getway.domain.protocol.login.LoginReq; | 5 | import com.diligrp.mobsite.getway.domain.protocol.login.LoginReq; |
4 | -import com.diligrp.mobsite.getway.domain.protocol.login.LoginResp; | ||
5 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterReq; | 6 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterReq; |
6 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterResp; | 7 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterResp; |
7 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; | 8 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; |
8 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; | 9 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; |
9 | -import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | ||
10 | import com.diligrp.mobsite.getway.rpc.base.BaseService; | 10 | import com.diligrp.mobsite.getway.rpc.base.BaseService; |
11 | 11 | ||
12 | import java.util.Map; | 12 | import java.util.Map; |
@@ -22,7 +22,7 @@ import java.util.Map; | @@ -22,7 +22,7 @@ import java.util.Map; | ||
22 | */ | 22 | */ |
23 | public interface PassportRPC extends BaseService { | 23 | public interface PassportRPC extends BaseService { |
24 | 24 | ||
25 | - SellerLoginResp sellerLogin(LoginReq req); | 25 | + SellerInfoOutput sellerLogin(LoginReq req); |
26 | 26 | ||
27 | UserRegisterResp register(UserRegisterReq req); | 27 | UserRegisterResp register(UserRegisterReq req); |
28 | 28 | ||
@@ -30,7 +30,7 @@ public interface PassportRPC extends BaseService { | @@ -30,7 +30,7 @@ public interface PassportRPC extends BaseService { | ||
30 | 30 | ||
31 | SellerRegisterResp sellerRegister(SellerRegisterReq req); | 31 | SellerRegisterResp sellerRegister(SellerRegisterReq req); |
32 | 32 | ||
33 | - LoginResp buyerLogin(LoginReq req); | 33 | + BuyerInfoOutput buyerLogin(LoginReq req); |
34 | 34 | ||
35 | boolean sendVeriCodeOfSeller(String mobile,Integer msgType); | 35 | boolean sendVeriCodeOfSeller(String mobile,Integer msgType); |
36 | 36 |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/SellerRPC.java
1 | package com.diligrp.mobsite.getway.rpc; | 1 | package com.diligrp.mobsite.getway.rpc; |
2 | 2 | ||
3 | -import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | ||
4 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | 3 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; |
5 | -import com.diligrp.mobsite.getway.domain.protocol.PickInfo; | ||
6 | -import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; | ||
7 | - | ||
8 | -import java.util.List; | ||
9 | 4 | ||
10 | 5 | ||
11 | /** | 6 | /** |
@@ -35,14 +30,7 @@ public interface SellerRPC { | @@ -35,14 +30,7 @@ public interface SellerRPC { | ||
35 | boolean checkMobile(String mobile); | 30 | boolean checkMobile(String mobile); |
36 | 31 | ||
37 | 32 | ||
38 | - /** | ||
39 | - * 修改进货单数量 | ||
40 | - * @param req | ||
41 | - * @return | ||
42 | - * @createTime 2015年3月9日 下午2:49:27 | ||
43 | - * @author zhangshirui | ||
44 | - */ | ||
45 | - boolean modifyAmount(ModifyAmountReq req); | 33 | + |
46 | 34 | ||
47 | /** | 35 | /** |
48 | * 修改密码 | 36 | * 修改密码 |
@@ -54,44 +42,11 @@ public interface SellerRPC { | @@ -54,44 +42,11 @@ public interface SellerRPC { | ||
54 | */ | 42 | */ |
55 | boolean modifyPwd(String accountName, String newPassword); | 43 | boolean modifyPwd(String accountName, String newPassword); |
56 | 44 | ||
57 | - Long addConsignee(PickInfo pickInfo, Long userId); | ||
58 | - | ||
59 | - boolean updateConsignee(PickInfo pickInfo, Long userId); | ||
60 | 45 | ||
61 | - PickInfo getConsignee(Long id); | ||
62 | - | ||
63 | - boolean delConsignee(Long id); | ||
64 | - | ||
65 | - List<PickInfo> getConsigneeByUserId(Long userId); | ||
66 | - | ||
67 | - PickInfo getDefaultConsignee(Long userId); | ||
68 | - | ||
69 | - boolean setDefaultConsignee(Long id, Long userId); | ||
70 | - | ||
71 | - | ||
72 | - /** | ||
73 | - * 密码加密 | ||
74 | - * @param pwd | ||
75 | - * @return | ||
76 | - * @createTime 2014年9月19日 上午10:04:35 | ||
77 | - * @author zhangshirui | ||
78 | - */ | ||
79 | - String getEncryptPwd(String pwd); | ||
80 | - | ||
81 | - | ||
82 | - | ||
83 | - /** | ||
84 | - * 验证用户密码 | ||
85 | - * @param userId | ||
86 | - * @param password | ||
87 | - * @return | ||
88 | - * @createTime 2015年6月24日 下午1:45:53 | ||
89 | - * @author zhangshirui | ||
90 | - */ | ||
91 | - boolean checkPassword(Long userId, String password); | ||
92 | - | ||
93 | - | ||
94 | - BuyerInfoOutput getUserByMobile(String accountName); | ||
95 | 46 | ||
96 | SellerInfoOutput getSellerByMobile(String accountName); | 47 | SellerInfoOutput getSellerByMobile(String accountName); |
48 | + | ||
49 | + //ShopOutput getShopBySellerId(Long id); | ||
50 | + // | ||
51 | + //ShopOutput getShopById(Long id); | ||
97 | } | 52 | } |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/PassportRPCImpl.java
@@ -4,18 +4,15 @@ import com.alibaba.fastjson.JSONObject; | @@ -4,18 +4,15 @@ import com.alibaba.fastjson.JSONObject; | ||
4 | import com.alibaba.fastjson.TypeReference; | 4 | import com.alibaba.fastjson.TypeReference; |
5 | import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | 5 | import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; |
6 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | 6 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; |
7 | -import com.diligrp.mobsite.getway.domain.common.Constant; | ||
8 | -import com.diligrp.mobsite.getway.domain.common.RedisKey; | 7 | +import com.diligrp.mobsite.getway.domain.common.ErrorMessage; |
9 | import com.diligrp.mobsite.getway.domain.common.ResultCode; | 8 | import com.diligrp.mobsite.getway.domain.common.ResultCode; |
10 | import com.diligrp.mobsite.getway.domain.except.ServiceException; | 9 | import com.diligrp.mobsite.getway.domain.except.ServiceException; |
11 | import com.diligrp.mobsite.getway.domain.protocol.login.LoginReq; | 10 | import com.diligrp.mobsite.getway.domain.protocol.login.LoginReq; |
12 | -import com.diligrp.mobsite.getway.domain.protocol.login.LoginResp; | ||
13 | import com.diligrp.mobsite.getway.domain.protocol.login.SendVeriCodeReq; | 11 | import com.diligrp.mobsite.getway.domain.protocol.login.SendVeriCodeReq; |
14 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterReq; | 12 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterReq; |
15 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterResp; | 13 | import com.diligrp.mobsite.getway.domain.protocol.register.SellerRegisterResp; |
16 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; | 14 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterReq; |
17 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; | 15 | import com.diligrp.mobsite.getway.domain.protocol.register.UserRegisterResp; |
18 | -import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | ||
19 | import com.diligrp.mobsite.getway.rpc.PassportRPC; | 16 | import com.diligrp.mobsite.getway.rpc.PassportRPC; |
20 | import com.diligrp.mobsite.getway.rpc.base.BaseOutput; | 17 | import com.diligrp.mobsite.getway.rpc.base.BaseOutput; |
21 | import com.diligrp.mobsite.getway.rpc.base.impl.BaseServiceImpl; | 18 | import com.diligrp.mobsite.getway.rpc.base.impl.BaseServiceImpl; |
@@ -52,58 +49,64 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -52,58 +49,64 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
52 | 49 | ||
53 | @Value("${passport.login.passportSign}") | 50 | @Value("${passport.login.passportSign}") |
54 | private String passportSign; | 51 | private String passportSign; |
55 | - /** | ||
56 | - * 登录超时时间:秒 | ||
57 | - */ | ||
58 | - @Value("${login.timeout.second}") | ||
59 | - private int loginExpireTime; | 52 | + |
60 | 53 | ||
61 | public PassportRPCImpl(String token, String baseUrl) { | 54 | public PassportRPCImpl(String token, String baseUrl) { |
62 | super(token, baseUrl); | 55 | super(token, baseUrl); |
63 | } | 56 | } |
64 | 57 | ||
65 | @Override | 58 | @Override |
66 | - public SellerLoginResp sellerLogin(LoginReq req) { | ||
67 | - Map<String,String> params = new HashMap<String, String>(); | 59 | + public SellerInfoOutput sellerLogin(LoginReq req) { |
60 | + Map<String,String> params = new HashMap<>(); | ||
68 | params.put("username", req.getAccountName()); | 61 | params.put("username", req.getAccountName()); |
69 | params.put("password", req.getPassword()); | 62 | params.put("password", req.getPassword()); |
70 | BaseOutput<SellerInfoOutput> output = null; | 63 | BaseOutput<SellerInfoOutput> output = null; |
71 | try { | 64 | try { |
72 | output = super.httpPost("/api/login/sellerLogin", params, new TypeReference<BaseOutput<SellerInfoOutput>>(){}); | 65 | output = super.httpPost("/api/login/sellerLogin", params, new TypeReference<BaseOutput<SellerInfoOutput>>(){}); |
73 | } catch (Exception e) { | 66 | } catch (Exception e) { |
74 | - log.error("调用passport卖家登录接口失败",e); | 67 | + log.error("error:调用passport卖家登录接口失败",e); |
75 | throw new ServiceException(); | 68 | throw new ServiceException(); |
76 | } | 69 | } |
77 | SellerInfoOutput sellerInfo = output.getData(); | 70 | SellerInfoOutput sellerInfo = output.getData(); |
78 | - SellerLoginResp resp = new SellerLoginResp(); | ||
79 | if (output.getCode()!=ResultCode.SUCCESS){ | 71 | if (output.getCode()!=ResultCode.SUCCESS){ |
80 | - log.error("调用passport卖家登录接口失败:msg={}",output.getResult()); | ||
81 | - throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录"); | ||
82 | - } | 72 | + log.error("error:调用passport买家登录失败[mobile=,code=,msg=]",new Object[]{req.getAccountName(),output.getCode(),output.getResult()}); |
73 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); | ||
74 | + } | ||
75 | + if (Validator.isNull(sellerInfo)||Validator.isNull(sellerInfo.getId())){ | ||
76 | + log.error("error:买家登录返回用户信息为空[accountName=]",req.getAccountName()); | ||
77 | + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_NOT_EXIST); | ||
78 | + } | ||
79 | + return sellerInfo; | ||
80 | + } | ||
83 | 81 | ||
84 | 82 | ||
85 | - resp.setSellerId(sellerInfo.getId()); | ||
86 | - resp.setPhone(sellerInfo.getMobilePhone()); | ||
87 | - resp.setShopId(1L); | ||
88 | - resp.setShopLogo("sds.jpg"); | ||
89 | - resp.setShopName("张三的水果店铺"); | ||
90 | - resp.setShopAuthCode(457854); | 83 | + @Override |
84 | + public BuyerInfoOutput buyerLogin(LoginReq req) { | ||
91 | 85 | ||
92 | - //缓存userId | ||
93 | - String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId())); | ||
94 | - redisUtil.setStringByExpire(cookieRedisKey, String.valueOf(resp.getSellerId()), loginExpireTime); | 86 | + Map<String,String> params = new HashMap<>(); |
87 | + params.put("username", req.getAccountName()); | ||
88 | + params.put("password", req.getPassword()); | ||
89 | + BaseOutput<BuyerInfoOutput > output = null; | ||
90 | + try { | ||
91 | + output = super.httpPost("/api/login/buyerLogin", params, new TypeReference<BaseOutput<BuyerInfoOutput>>(){}); | ||
92 | + } catch (Exception e) { | ||
93 | + log.error("error:调用passport买家登录接口失败",e); | ||
94 | + throw new ServiceException(); | ||
95 | + } | ||
96 | + BuyerInfoOutput buyerInfo = output.getData(); | ||
97 | + if (output.getCode()!=ResultCode.SUCCESS){ | ||
98 | + log.error("error:调用passport买家登录失败[mobile=,code=,msg=]",new Object[]{req.getAccountName(),output.getCode(),output.getResult()}); | ||
99 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); | ||
100 | + } | ||
101 | + | ||
102 | + if (Validator.isNull(buyerInfo)||Validator.isNull(buyerInfo.getId())){ | ||
103 | + log.error("error:买家登录返回用户信息为空[accountName=]",req.getAccountName()); | ||
104 | + throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_NOT_EXIST); | ||
105 | + } | ||
106 | + return buyerInfo; | ||
95 | 107 | ||
96 | - //缓存shopId | ||
97 | - //String shopIdKey = redisUtil.makeKey(RedisKey.USER_SELLER_SHOPID, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId())); | ||
98 | - //redisUtil.setStringByExpire(shopIdKey, String.valueOf(resp.getShopId()), loginExpireTime); | ||
99 | 108 | ||
100 | 109 | ||
101 | - //缓存设备id,userId作为key | ||
102 | - if (!Validator.isNull(req.getDeviceId())) { | ||
103 | - String onlyOneLoginRedisKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId())); | ||
104 | - redisUtil.setStringByExpire(onlyOneLoginRedisKey, req.getDeviceId(), loginExpireTime); | ||
105 | - } | ||
106 | - return resp; | ||
107 | } | 110 | } |
108 | 111 | ||
109 | @Override | 112 | @Override |
@@ -118,7 +121,7 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -118,7 +121,7 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
118 | output = super.httpPost("/api/register/buyerRegister.html", params,null); | 121 | output = super.httpPost("/api/register/buyerRegister.html", params,null); |
119 | 122 | ||
120 | } catch (Exception e) { | 123 | } catch (Exception e) { |
121 | - log.error("调用passport注册接口失败",e); | 124 | + log.error("error:调用passport注册接口失败",e); |
122 | throw new ServiceException(); | 125 | throw new ServiceException(); |
123 | } | 126 | } |
124 | 127 | ||
@@ -146,11 +149,11 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -146,11 +149,11 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
146 | output = super.httpPost("/api/forgot/updateSellerPasswordByPhoneNumber", params,null); | 149 | output = super.httpPost("/api/forgot/updateSellerPasswordByPhoneNumber", params,null); |
147 | 150 | ||
148 | } catch (Exception e) { | 151 | } catch (Exception e) { |
149 | - log.error("调用passport修改密码接口失败",e); | 152 | + log.error("error:调用passport修改密码接口失败",e); |
150 | throw new ServiceException(); | 153 | throw new ServiceException(); |
151 | } | 154 | } |
152 | if (Validator.isNull(output)) { | 155 | if (Validator.isNull(output)) { |
153 | - log.error("调用passport修改密码接口失败"); | 156 | + log.error("error:调用passport修改密码接口失败"); |
154 | throw new ServiceException(ResultCode.BUSINESS_FAILED); | 157 | throw new ServiceException(ResultCode.BUSINESS_FAILED); |
155 | } | 158 | } |
156 | return output.getData(); | 159 | return output.getData(); |
@@ -163,86 +166,29 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -163,86 +166,29 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
163 | params.put("accountPwd", req.getPassword()); | 166 | params.put("accountPwd", req.getPassword()); |
164 | params.put("validCode",req.getVeriCode()); | 167 | params.put("validCode",req.getVeriCode()); |
165 | params.put("appType",req.getAppType()+""); | 168 | params.put("appType",req.getAppType()+""); |
166 | - BaseOutput<String> output = null; | 169 | + BaseOutput<SellerInfoOutput > output = null; |
167 | try { | 170 | try { |
168 | - output = super.httpPost("/api/register/sellerRegister", params,null); | ||
169 | - | 171 | + output = super.httpPost("/api/register/sellerRegister", params,new TypeReference<BaseOutput<SellerInfoOutput>>(){}); |
170 | } catch (Exception e) { | 172 | } catch (Exception e) { |
171 | - log.error("调用passport注册接口失败",e); | 173 | + log.error("error:调用passport卖家注册接口失败",e); |
172 | throw new ServiceException(); | 174 | throw new ServiceException(); |
173 | } | 175 | } |
174 | 176 | ||
175 | SellerRegisterResp resp = new SellerRegisterResp(); | 177 | SellerRegisterResp resp = new SellerRegisterResp(); |
176 | - JSONObject jsonBody = JSONObject.parseObject(output.getData()); | ||
177 | - int code = jsonBody.getIntValue("code"); | ||
178 | - //成功 | ||
179 | - if(code == ResultCode.SUCCESS){ | ||
180 | - resp.setResultFlag(UserRegisterResp.RESULT_FLAG_SUCCESS); | ||
181 | - }else{ | ||
182 | - resp.setResultFlag(UserRegisterResp.RESULT_FLAG_FAILED); | ||
183 | - } | ||
184 | - resp.setMsg(jsonBody.getString("msg")); | ||
185 | - | ||
186 | - log.info("注册用户信息:msg={}"+jsonBody.getString("msg")); | ||
187 | - | ||
188 | - return resp; | ||
189 | - } | ||
190 | 178 | ||
191 | - @Override | ||
192 | - public LoginResp buyerLogin(LoginReq req) { | ||
193 | - | ||
194 | - Map<String,String> params = new HashMap<String, String>(); | ||
195 | - params.put("username", req.getAccountName()); | ||
196 | - params.put("password", req.getPassword()); | ||
197 | - BaseOutput<BuyerInfoOutput > output = null; | ||
198 | - try { | ||
199 | - output = super.httpPost("/api/login/buyerLogin", params, new TypeReference<BaseOutput<BuyerInfoOutput>>(){}); | ||
200 | - } catch (Exception e) { | ||
201 | - log.error("调用passport卖家登录接口失败",e); | ||
202 | - throw new ServiceException(); | ||
203 | - } | ||
204 | - BuyerInfoOutput buyerInfo = output.getData(); | ||
205 | if (output.getCode()!=ResultCode.SUCCESS){ | 179 | if (output.getCode()!=ResultCode.SUCCESS){ |
206 | - log.error("调用passport买家登录接口失败:msg={}",output.getResult()); | ||
207 | - throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录"); | ||
208 | - } | ||
209 | - | ||
210 | - LoginResp resp = new LoginResp(); | ||
211 | - resp.setBuyerId(buyerInfo.getId()); | ||
212 | - resp.setHeadImg(buyerInfo.getFace()); | ||
213 | - resp.setMobile(buyerInfo.getMobilePhone()); | ||
214 | - resp.setAccountName(""); | ||
215 | - resp.setCurrentShopId(123L); | ||
216 | - resp.setShopBuyerId(122L); | ||
217 | - | ||
218 | - //缓存userId | ||
219 | - String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
220 | - redisUtil.setStringByExpire(cookieRedisKey, String.valueOf(resp.getBuyerId()), loginExpireTime); | ||
221 | - | ||
222 | - //缓存设备id,userId作为key | ||
223 | - if (!Validator.isNull(req.getDeviceId())) { | ||
224 | - String onlyOneLoginRedisKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
225 | - redisUtil.setStringByExpire(onlyOneLoginRedisKey, req.getDeviceId(), loginExpireTime); | 180 | + log.error("error:调用passport卖家注册失败[mobile=,code=,msg=]",new Object[]{req.getMobile(),output.getCode(),output.getResult()}); |
181 | + throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); | ||
226 | } | 182 | } |
227 | - | ||
228 | - //缓存currentShopId | ||
229 | - //if (!Validator.isNull(resp.getCurrentShopId())){ | ||
230 | - // String currentShopIdKey = redisUtil.makeKey(RedisKey.USER_BUYER_CURRENTSHOPID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
231 | - // redisUtil.setStringByExpire(currentShopIdKey, String.valueOf(resp.getCurrentShopId()), loginExpireTime); | ||
232 | - //} | ||
233 | - | ||
234 | - | ||
235 | - //缓存shopBuyerId | ||
236 | - //if (!Validator.isNull(resp.getShopBuyerId())){ | ||
237 | - // String shopUserIdKey = redisUtil.makeKey(RedisKey.USER_BUYER_SHOPUSERID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
238 | - // redisUtil.setStringByExpire(shopUserIdKey, String.valueOf(resp.getShopBuyerId()), loginExpireTime); | ||
239 | - //} | ||
240 | - | 183 | + //成功 |
184 | + resp.setResultFlag(UserRegisterResp.RESULT_FLAG_SUCCESS); | ||
241 | 185 | ||
242 | 186 | ||
243 | return resp; | 187 | return resp; |
244 | } | 188 | } |
245 | 189 | ||
190 | + | ||
191 | + | ||
246 | @Override | 192 | @Override |
247 | public boolean sendVeriCodeOfSeller(String mobile,Integer msgType) { | 193 | public boolean sendVeriCodeOfSeller(String mobile,Integer msgType) { |
248 | BaseOutput<String> output = null; | 194 | BaseOutput<String> output = null; |
@@ -256,12 +202,22 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -256,12 +202,22 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
256 | output = super.httpGet("/api/forgot/sendSellerForgotPasswordSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){} ); | 202 | output = super.httpGet("/api/forgot/sendSellerForgotPasswordSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){} ); |
257 | } | 203 | } |
258 | } catch (Exception e) { | 204 | } catch (Exception e) { |
259 | - log.error("调用passport卖家注册发送短信失败",e); | 205 | + if (msgType== SendVeriCodeReq.MSG_TYPE_REGISTER){ |
206 | + log.error("error:调用passport卖家注册发送验证码短信失败",e); | ||
207 | + } | ||
208 | + if (msgType== SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD){ | ||
209 | + log.error("error:调用passport卖家忘记密码发送验证码短信失败",e); | ||
210 | + } | ||
260 | throw new ServiceException(); | 211 | throw new ServiceException(); |
261 | } | 212 | } |
262 | - | ||
263 | if (output.getCode()!= 200){ | 213 | if (output.getCode()!= 200){ |
264 | - log.error("调用passport卖家注册发送短信失败[mobile=,msg=]",mobile,output.getResult()); | 214 | + if (msgType== SendVeriCodeReq.MSG_TYPE_REGISTER){ |
215 | + log.error("error:调用passport卖家注册发送验证码短信失败[mobile=,code=,msg=]",new Object[]{mobile,output.getCode(),output.getResult()}); | ||
216 | + } | ||
217 | + if (msgType== SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD){ | ||
218 | + log.error("error:调用passport卖家忘记密码发送验证码短信失败[mobile=,code,msg=]",new Object[]{mobile,output.getCode(),output.getResult()}); | ||
219 | + } | ||
220 | + | ||
265 | throw new ServiceException(output.getCode(),output.getResult()); | 221 | throw new ServiceException(output.getCode(),output.getResult()); |
266 | } | 222 | } |
267 | 223 | ||
@@ -283,12 +239,31 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -283,12 +239,31 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
283 | output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, null); | 239 | output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, null); |
284 | } | 240 | } |
285 | } catch (Exception e) { | 241 | } catch (Exception e) { |
286 | - log.error("调用passport买家注册发送短信失败",e); | 242 | + |
243 | + if (msgType== SendVeriCodeReq.MSG_TYPE_LOGIN){ | ||
244 | + log.error("error:调用passport买家登录发送验证码短信失败",e); | ||
245 | + } | ||
246 | + if (msgType== SendVeriCodeReq.MSG_TYPE_REGISTER){ | ||
247 | + log.error("error:调用passport买家注册发送验证码短信失败",e); | ||
248 | + } | ||
249 | + if (msgType== SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD){ | ||
250 | + log.error("error:调用passport买家忘记密码发送验证码短信失败",e); | ||
251 | + } | ||
287 | throw new ServiceException(); | 252 | throw new ServiceException(); |
288 | } | 253 | } |
289 | 254 | ||
290 | if (output.getCode()!= 200){ | 255 | if (output.getCode()!= 200){ |
291 | - log.error("调用passport买家注册发送短信失败[mobile=,msg=]",mobile,output.getResult()); | 256 | + |
257 | + if (msgType== SendVeriCodeReq.MSG_TYPE_LOGIN){ | ||
258 | + log.error("error:调用passport买家注册发送验证码短信失败[mobile=,code,msg=]",new Object[]{mobile,output.getCode(),output.getResult()}); | ||
259 | + } | ||
260 | + if (msgType== SendVeriCodeReq.MSG_TYPE_REGISTER){ | ||
261 | + log.error("error:调用passport买家注册发送验证码短信失败[mobile=,code,msg=]",new Object[]{mobile,output.getCode(),output.getResult()}); | ||
262 | + } | ||
263 | + if (msgType== SendVeriCodeReq.MSG_TYPE_RETRIEVE_PASSWORD){ | ||
264 | + log.error("error:调用passport买家忘记密码发送验证码短信失败[mobile=,code,msg=]",new Object[]{mobile,output.getCode(),output.getResult()}); | ||
265 | + } | ||
266 | + | ||
292 | throw new ServiceException(output.getCode(),output.getResult()); | 267 | throw new ServiceException(output.getCode(),output.getResult()); |
293 | } | 268 | } |
294 | 269 | ||
@@ -326,12 +301,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | @@ -326,12 +301,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { | ||
326 | try { | 301 | try { |
327 | output = super.httpPost("/api/forgot/verifyBuyerSmsCode", params, null); | 302 | output = super.httpPost("/api/forgot/verifyBuyerSmsCode", params, null); |
328 | } catch (Exception e) { | 303 | } catch (Exception e) { |
329 | - log.error("passport校验买家短信验证码失败",e); | 304 | + log.error("error:调用passport校验买家短信验证码失败",e); |
330 | throw new ServiceException(); | 305 | throw new ServiceException(); |
331 | } | 306 | } |
332 | 307 | ||
333 | if (output.getCode()!= 200){ | 308 | if (output.getCode()!= 200){ |
334 | - log.error("passport校验买家短信验证码失败[mobile=,msg=]",mobile,output.getResult()); | 309 | + log.error("error:调用passport校验买家短信验证码失败[mobile=,msg=]",mobile,output.getResult()); |
335 | throw new ServiceException(output.getCode(),output.getResult()); | 310 | throw new ServiceException(output.getCode(),output.getResult()); |
336 | } | 311 | } |
337 | 312 |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/SellerRPCImpl.java
@@ -2,6 +2,7 @@ package com.diligrp.mobsite.getway.rpc.impl; | @@ -2,6 +2,7 @@ package com.diligrp.mobsite.getway.rpc.impl; | ||
2 | 2 | ||
3 | import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; | 3 | import com.b2c.myapp.common.api.buyerInfo.output.BuyerInfoOutput; |
4 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | 4 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; |
5 | +import com.b2c.myapp.common.api.shop.output.ShopOutput; | ||
5 | import com.b2c.myapp.common.utils.BaseOutput; | 6 | import com.b2c.myapp.common.utils.BaseOutput; |
6 | import com.b2c.myapp.sdk.MyAppClient; | 7 | import com.b2c.myapp.sdk.MyAppClient; |
7 | import com.diligrp.mobsite.getway.domain.common.ErrorMessage; | 8 | import com.diligrp.mobsite.getway.domain.common.ErrorMessage; |
@@ -68,83 +69,16 @@ public class SellerRPCImpl implements SellerRPC { | @@ -68,83 +69,16 @@ public class SellerRPCImpl implements SellerRPC { | ||
68 | return flag; | 69 | return flag; |
69 | } | 70 | } |
70 | 71 | ||
71 | - @Override | ||
72 | - public boolean modifyAmount(ModifyAmountReq req) { | ||
73 | - return false; | ||
74 | - } | ||
75 | - | ||
76 | - @Override | ||
77 | - public boolean modifyPwd(String accountName, String newPassword) { | ||
78 | - return false; | ||
79 | - } | ||
80 | - | ||
81 | - @Override | ||
82 | - public Long addConsignee(PickInfo pickInfo, Long userId) { | ||
83 | - return null; | ||
84 | - } | ||
85 | - | ||
86 | - @Override | ||
87 | - public boolean updateConsignee(PickInfo pickInfo, Long userId) { | ||
88 | - return false; | ||
89 | - } | ||
90 | 72 | ||
91 | - @Override | ||
92 | - public PickInfo getConsignee(Long id) { | ||
93 | - return null; | ||
94 | - } | ||
95 | 73 | ||
96 | @Override | 74 | @Override |
97 | - public boolean delConsignee(Long id) { | ||
98 | - return false; | ||
99 | - } | ||
100 | - | ||
101 | - @Override | ||
102 | - public List<PickInfo> getConsigneeByUserId(Long userId) { | ||
103 | - return null; | ||
104 | - } | ||
105 | - | ||
106 | - @Override | ||
107 | - public PickInfo getDefaultConsignee(Long userId) { | ||
108 | - return null; | ||
109 | - } | ||
110 | - | ||
111 | - @Override | ||
112 | - public boolean setDefaultConsignee(Long id, Long userId) { | 75 | + public boolean modifyPwd(String accountName, String newPassword) { |
113 | return false; | 76 | return false; |
114 | } | 77 | } |
115 | 78 | ||
116 | - @Override | ||
117 | - public String getEncryptPwd(String pwd) { | ||
118 | - return null; | ||
119 | - } | ||
120 | 79 | ||
121 | - @Override | ||
122 | - public boolean checkPassword(Long userId, String password) { | ||
123 | - return false; | ||
124 | - } | ||
125 | 80 | ||
126 | - @Override | ||
127 | - public BuyerInfoOutput getUserByMobile(String accountName) { | ||
128 | - BaseOutput<BuyerInfoOutput> output = null; | ||
129 | - boolean flag = false; | ||
130 | - try { | ||
131 | - output = userClient.getBuyerInfoService().getBuyerInfoByMobilePhone(accountName); | ||
132 | - } catch (Exception e) { | ||
133 | - logger.error("检测电话号码接口挂掉:msg={}",e.getMessage()); | ||
134 | - throw new ServiceException(); | ||
135 | - } | ||
136 | - | ||
137 | - if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | ||
138 | - logger.error("手机号查询买家接口失败:[userId={},code={},result={}]",new Object[]{accountName,output.getCode(),output.getResult()}); | ||
139 | - throw new ServiceException(); | ||
140 | - } | ||
141 | 81 | ||
142 | - if(Validator.isNull(output.getData())){ | ||
143 | - logger.info("查询用户为空:[mobile={}]",new Object[]{accountName}); | ||
144 | - throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_NOT_EXIST); | ||
145 | - } | ||
146 | - return output.getData(); | ||
147 | - } | ||
148 | 82 | ||
149 | @Override | 83 | @Override |
150 | public SellerInfoOutput getSellerByMobile(String accountName) { | 84 | public SellerInfoOutput getSellerByMobile(String accountName) { |
@@ -169,4 +103,49 @@ public class SellerRPCImpl implements SellerRPC { | @@ -169,4 +103,49 @@ public class SellerRPCImpl implements SellerRPC { | ||
169 | return output.getData(); | 103 | return output.getData(); |
170 | } | 104 | } |
171 | 105 | ||
106 | + //@Override | ||
107 | + //public ShopOutput getShopBySellerId(Long id) { | ||
108 | + // BaseOutput<ShopOutput> output = null; | ||
109 | + // boolean flag = false; | ||
110 | + // try { | ||
111 | + // output = userClient.getShopInfoService().getShopBySellerId(id); | ||
112 | + // } catch (Exception e) { | ||
113 | + // logger.error("调用根据id查询店铺接口挂掉",e); | ||
114 | + // throw new ServiceException(); | ||
115 | + // } | ||
116 | + // | ||
117 | + // if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | ||
118 | + // logger.error("根据id查询店铺异常:[userId={},code={},result={}]",new Object[]{id,output.getCode(),output.getResult()}); | ||
119 | + // throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_SEARCH_FAILED); | ||
120 | + // } | ||
121 | + // | ||
122 | + // if(Validator.isNull(output.getData())){ | ||
123 | + // logger.info("查询用户为空:[userId={}]",new Object[]{id}); | ||
124 | + // throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.SHOP_NOT_EXIST); | ||
125 | + // } | ||
126 | + // return output.getData(); | ||
127 | + //} | ||
128 | + // | ||
129 | + //@Override | ||
130 | + //public ShopOutput getShopById(Long id) { | ||
131 | + // BaseOutput<ShopOutput> output = null; | ||
132 | + // try { | ||
133 | + // output = userClient.getShopInfoService().getShopByShopId(id); | ||
134 | + // } catch (Exception e) { | ||
135 | + // logger.error("调用根据id查询店铺接口挂掉:msg={}",e.getMessage()); | ||
136 | + // throw new ServiceException(); | ||
137 | + // } | ||
138 | + // | ||
139 | + // if (output==null||!output.getCode().equals(ResultCode.SUCCESS)){ | ||
140 | + // logger.error("根据id查询店铺接口挂掉:[userId={},code={},result={}]",new Object[]{id,output.getCode(),output.getResult()}); | ||
141 | + // throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.USER_SEARCH_FAILED); | ||
142 | + // } | ||
143 | + // | ||
144 | + // if(Validator.isNull(output.getData())){ | ||
145 | + // logger.info("查询店铺为空:[userId={}]",new Object[]{id}); | ||
146 | + // throw new ServiceException(ResultCode.BUSINESS_FAILED, ErrorMessage.SHOP_NOT_EXIST); | ||
147 | + // } | ||
148 | + // return output.getData(); | ||
149 | + //} | ||
150 | + | ||
172 | } | 151 | } |
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/UserRPCImpl.java
@@ -8,11 +8,8 @@ import com.diligrp.mobsite.getway.domain.common.ResultCode; | @@ -8,11 +8,8 @@ import com.diligrp.mobsite.getway.domain.common.ResultCode; | ||
8 | import com.diligrp.mobsite.getway.domain.except.ServiceException; | 8 | import com.diligrp.mobsite.getway.domain.except.ServiceException; |
9 | import com.diligrp.mobsite.getway.domain.protocol.AddCartProduct; | 9 | import com.diligrp.mobsite.getway.domain.protocol.AddCartProduct; |
10 | import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; | 10 | import com.diligrp.mobsite.getway.domain.protocol.cart.ModifyAmountReq; |
11 | -import com.diligrp.mobsite.getway.rpc.GoodsRPC; | ||
12 | import com.diligrp.mobsite.getway.rpc.UserRPC; | 11 | import com.diligrp.mobsite.getway.rpc.UserRPC; |
13 | -import com.diligrp.website.util.redis.RedisUtil; | ||
14 | import com.diligrp.website.util.security.Validator; | 12 | import com.diligrp.website.util.security.Validator; |
15 | -import com.diligrp.website.web.interfaces.WebsiteClient; | ||
16 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
17 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
18 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
@@ -35,13 +32,8 @@ public class UserRPCImpl implements UserRPC { | @@ -35,13 +32,8 @@ public class UserRPCImpl implements UserRPC { | ||
35 | 32 | ||
36 | 33 | ||
37 | @Resource | 34 | @Resource |
38 | - private RedisUtil redisUtil; | ||
39 | - @Resource | ||
40 | private MyAppClient myAppClient; | 35 | private MyAppClient myAppClient; |
41 | - @Resource | ||
42 | - private WebsiteClient websiteClient; | ||
43 | - @Resource | ||
44 | - private GoodsRPC goodsRPC; | 36 | + |
45 | 37 | ||
46 | 38 | ||
47 | private static final Logger logger = LoggerFactory.getLogger(UserRPCImpl.class); | 39 | private static final Logger logger = LoggerFactory.getLogger(UserRPCImpl.class); |
@@ -90,20 +82,6 @@ public class UserRPCImpl implements UserRPC { | @@ -90,20 +82,6 @@ public class UserRPCImpl implements UserRPC { | ||
90 | return false; | 82 | return false; |
91 | } | 83 | } |
92 | 84 | ||
93 | - @Override | ||
94 | - public boolean modifyPwd(String accountName, String newPassword) { | ||
95 | - return false; | ||
96 | - } | ||
97 | - | ||
98 | - @Override | ||
99 | - public String getEncryptPwd(String pwd) { | ||
100 | - return null; | ||
101 | - } | ||
102 | - | ||
103 | - @Override | ||
104 | - public boolean checkPassword(Long userId, String password) { | ||
105 | - return false; | ||
106 | - } | ||
107 | 85 | ||
108 | @Override | 86 | @Override |
109 | public BuyerInfoOutput getUserByMobile(String accountName) { | 87 | public BuyerInfoOutput getUserByMobile(String accountName) { |
@@ -112,7 +90,7 @@ public class UserRPCImpl implements UserRPC { | @@ -112,7 +90,7 @@ public class UserRPCImpl implements UserRPC { | ||
112 | try { | 90 | try { |
113 | output = myAppClient.getBuyerInfoService().getBuyerInfoByMobilePhone(accountName); | 91 | output = myAppClient.getBuyerInfoService().getBuyerInfoByMobilePhone(accountName); |
114 | } catch (Exception e) { | 92 | } catch (Exception e) { |
115 | - logger.error("检测电话号码接口挂掉:msg={}",e.getMessage()); | 93 | + logger.error("手机号查询买家接口挂掉:msg={}",e.getMessage()); |
116 | throw new ServiceException(); | 94 | throw new ServiceException(); |
117 | } | 95 | } |
118 | 96 | ||
@@ -127,4 +105,21 @@ public class UserRPCImpl implements UserRPC { | @@ -127,4 +105,21 @@ public class UserRPCImpl implements UserRPC { | ||
127 | } | 105 | } |
128 | return output.getData(); | 106 | return output.getData(); |
129 | } | 107 | } |
108 | + | ||
109 | + @Override | ||
110 | + public boolean modifyPwd(String accountName, String newPassword) { | ||
111 | + return false; | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + public String getEncryptPwd(String pwd) { | ||
116 | + return null; | ||
117 | + } | ||
118 | + | ||
119 | + @Override | ||
120 | + public boolean checkPassword(Long userId, String password) { | ||
121 | + return false; | ||
122 | + } | ||
123 | + | ||
124 | + | ||
130 | } | 125 | } |
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/buyer/user/UserService.java
@@ -27,7 +27,7 @@ public interface UserService { | @@ -27,7 +27,7 @@ public interface UserService { | ||
27 | * @createTime 2014年8月26日 下午5:37:05 | 27 | * @createTime 2014年8月26日 下午5:37:05 |
28 | * @author zhangshirui | 28 | * @author zhangshirui |
29 | */ | 29 | */ |
30 | - LoginResp login(LoginReq req); | 30 | + LoginResp buyerlogin(LoginReq req); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * 验证用户名是否合法 | 33 | * 验证用户名是否合法 |
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/buyer/user/impl/UserServiceImpl.java
@@ -23,6 +23,7 @@ import com.diligrp.website.web.interfaces.domain.output.DataDictionaryResp; | @@ -23,6 +23,7 @@ import com.diligrp.website.web.interfaces.domain.output.DataDictionaryResp; | ||
23 | import org.slf4j.Logger; | 23 | import org.slf4j.Logger; |
24 | import org.slf4j.LoggerFactory; | 24 | import org.slf4j.LoggerFactory; |
25 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
26 | +import org.springframework.beans.factory.annotation.Value; | ||
26 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
27 | 28 | ||
28 | import javax.annotation.Resource; | 29 | import javax.annotation.Resource; |
@@ -64,42 +65,94 @@ public class UserServiceImpl implements UserService { | @@ -64,42 +65,94 @@ public class UserServiceImpl implements UserService { | ||
64 | @Autowired | 65 | @Autowired |
65 | private MessageRPC messageRPC; | 66 | private MessageRPC messageRPC; |
66 | 67 | ||
68 | + /** | ||
69 | + * 登录超时时间:秒 | ||
70 | + */ | ||
71 | + @Value("${login.timeout.second}") | ||
72 | + private int loginExpireTime; | ||
73 | + | ||
67 | 74 | ||
68 | private static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class); | 75 | private static Logger logger = LoggerFactory.getLogger(UserServiceImpl.class); |
69 | 76 | ||
70 | @Override | 77 | @Override |
71 | - public LoginResp login(LoginReq req) { | ||
72 | - LoginResp resp = (LoginResp) passportRPC.buyerLogin(req); | ||
73 | - | ||
74 | - if (!Validator.isEmpty(req.getRegisterNo())) { | ||
75 | - // 缓存 | ||
76 | - String redisKey = redisUtil.makeKey(RedisKey.USER_REGISTERNO,Constant.USER_ROLE_SIGN_BUYER+ | ||
77 | - String.valueOf(resp.getBuyerId())); | 78 | + public LoginResp buyerlogin(LoginReq req) { |
79 | + BuyerInfoOutput userInfo = passportRPC.buyerLogin(req); | ||
78 | 80 | ||
79 | - GetRegisterNoResp mappers = redisUtil.getObject(redisKey, | ||
80 | - GetRegisterNoResp.class); | ||
81 | - // 绑定极光ID | ||
82 | - RegisterNoMapper mapper = new RegisterNoMapper(); | ||
83 | - mapper.setRegisterNo(req.getRegisterNo()); | ||
84 | - mapper.setSysFlag(RegisterNoMapper.SYS_FLAG_JPUSH); | ||
85 | - mapper.setUserid(resp.getBuyerId()); | ||
86 | - mapper.setUserType(Constant.USER_ROLE_BUYER); | ||
87 | - mapper.setDeviceType(req.getDeviceType()); | ||
88 | - try { | ||
89 | - //清除当前极光号userid缓存 | ||
90 | - cleanOldredis(mapper); | ||
91 | - //构建缓存信息 | ||
92 | - buildRedisInfo(mappers, mapper); | ||
93 | - redisUtil.setObjectByExpire(redisKey, mappers, | ||
94 | - RedisKey.REGISTERNO_EXPIRE_TIME); | ||
95 | - } catch (Exception e) { | ||
96 | - throw new ServiceException(ResultCode.PUSH_MESSAGE_NO, | ||
97 | - "绑定极光推送系统注册号失败"); | ||
98 | - } | 81 | + //缓存用户信息 |
82 | + cacheUserInfo(userInfo.getId(),req.getDeviceId()); | ||
83 | + if (Validator.isEmpty(req.getRegisterNo())){ | ||
84 | + logger.error("卖家登录激光推送id为空[userId=]",userInfo.getId()); | ||
85 | + }else{ | ||
86 | + //绑定用户激光推送id | ||
87 | + bindUserRegisterNo(userInfo.getId(),req); | ||
88 | + } | ||
89 | + Long currentShopId = userInfo.getCurrentShopId(); | ||
90 | + LoginResp resp = new LoginResp(); | ||
91 | + if (Validator.isNull(currentShopId)){ | ||
92 | + logger.info("用户未绑定店铺[buyerId=]",userInfo.getId()); | ||
93 | + resp.setMsg(ErrorMessage.BUYER_NOT_OPEN_SHOP); | ||
99 | } | 94 | } |
95 | + resp.setBuyerId(userInfo.getId()); | ||
96 | + resp.setHeadImg(userInfo.getFace()); | ||
97 | + resp.setMobile(userInfo.getMobilePhone()); | ||
98 | + resp.setAccountName(userInfo.getAccountName()); | ||
99 | + resp.setCurrentShopId(userInfo.getCurrentShopId()); | ||
100 | return resp; | 100 | return resp; |
101 | } | 101 | } |
102 | 102 | ||
103 | + private void bindUserRegisterNo(Long id, LoginReq req) { | ||
104 | + // 缓存 | ||
105 | + String redisKey = redisUtil.makeKey(RedisKey.USER_REGISTERNO,Constant.USER_ROLE_SIGN_BUYER+ | ||
106 | + String.valueOf(id)); | ||
107 | + | ||
108 | + GetRegisterNoResp mappers = redisUtil.getObject(redisKey, | ||
109 | + GetRegisterNoResp.class); | ||
110 | + // 绑定极光ID | ||
111 | + RegisterNoMapper mapper = new RegisterNoMapper(); | ||
112 | + mapper.setRegisterNo(req.getRegisterNo()); | ||
113 | + mapper.setSysFlag(RegisterNoMapper.SYS_FLAG_JPUSH); | ||
114 | + mapper.setUserid(id); | ||
115 | + mapper.setUserType(Constant.USER_ROLE_BUYER); | ||
116 | + mapper.setDeviceType(req.getDeviceType()); | ||
117 | + try { | ||
118 | + //清除当前极光号userid缓存 | ||
119 | + cleanOldredis(mapper); | ||
120 | + //构建缓存信息 | ||
121 | + buildRedisInfo(mappers, mapper); | ||
122 | + redisUtil.setObjectByExpire(redisKey, mappers, | ||
123 | + RedisKey.REGISTERNO_EXPIRE_TIME); | ||
124 | + } catch (Exception e) { | ||
125 | + throw new ServiceException(ResultCode.PUSH_MESSAGE_NO, | ||
126 | + "绑定极光推送系统注册号失败"); | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | + private void cacheUserInfo(Long id, String deviceId) { | ||
131 | + | ||
132 | + //缓存userId | ||
133 | + String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(id)); | ||
134 | + redisUtil.setStringByExpire(cookieRedisKey, String.valueOf(id), loginExpireTime); | ||
135 | + | ||
136 | + //缓存设备id,userId作为key | ||
137 | + if (!Validator.isNull(deviceId)) { | ||
138 | + String onlyOneLoginRedisKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(id)); | ||
139 | + redisUtil.setStringByExpire(onlyOneLoginRedisKey, deviceId, loginExpireTime); | ||
140 | + } | ||
141 | + | ||
142 | + //缓存currentShopId | ||
143 | + //if (!Validator.isNull(resp.getCurrentShopId())){ | ||
144 | + // String currentShopIdKey = redisUtil.makeKey(RedisKey.USER_BUYER_CURRENTSHOPID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
145 | + // redisUtil.setStringByExpire(currentShopIdKey, String.valueOf(resp.getCurrentShopId()), loginExpireTime); | ||
146 | + //} | ||
147 | + | ||
148 | + | ||
149 | + //缓存shopBuyerId | ||
150 | + //if (!Validator.isNull(resp.getShopBuyerId())){ | ||
151 | + // String shopUserIdKey = redisUtil.makeKey(RedisKey.USER_BUYER_SHOPUSERID, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); | ||
152 | + // redisUtil.setStringByExpire(shopUserIdKey, String.valueOf(resp.getShopBuyerId()), loginExpireTime); | ||
153 | + //} | ||
154 | + } | ||
155 | + | ||
103 | 156 | ||
104 | /** | 157 | /** |
105 | * 清除当前极光号下userid缓存 | 158 | * 清除当前极光号下userid缓存 |
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/impl/SellerUserServiceImpl.java
@@ -2,8 +2,10 @@ package com.diligrp.mobsite.getway.service.seller.impl; | @@ -2,8 +2,10 @@ package com.diligrp.mobsite.getway.service.seller.impl; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; | 4 | import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput; |
5 | +import com.b2c.myapp.common.api.shop.output.ShopOutput; | ||
5 | import com.diligrp.mobsite.getway.domain.RegisterNoMapper; | 6 | import com.diligrp.mobsite.getway.domain.RegisterNoMapper; |
6 | import com.diligrp.mobsite.getway.domain.common.Constant; | 7 | import com.diligrp.mobsite.getway.domain.common.Constant; |
8 | +import com.diligrp.mobsite.getway.domain.common.ErrorMessage; | ||
7 | import com.diligrp.mobsite.getway.domain.common.RedisKey; | 9 | import com.diligrp.mobsite.getway.domain.common.RedisKey; |
8 | import com.diligrp.mobsite.getway.domain.common.ResultCode; | 10 | import com.diligrp.mobsite.getway.domain.common.ResultCode; |
9 | import com.diligrp.mobsite.getway.domain.except.ServiceException; | 11 | import com.diligrp.mobsite.getway.domain.except.ServiceException; |
@@ -17,13 +19,13 @@ import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | @@ -17,13 +19,13 @@ import com.diligrp.mobsite.getway.domain.protocol.saler.user.SellerLoginResp; | ||
17 | import com.diligrp.mobsite.getway.domain.protocol.user.*; | 19 | import com.diligrp.mobsite.getway.domain.protocol.user.*; |
18 | import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager; | 20 | import com.diligrp.mobsite.getway.manager.common.RegisterNoMapperManager; |
19 | import com.diligrp.mobsite.getway.rpc.*; | 21 | import com.diligrp.mobsite.getway.rpc.*; |
20 | -import com.diligrp.mobsite.getway.rpc.utils.UserRedisUtil; | ||
21 | import com.diligrp.mobsite.getway.service.seller.SellerUserService; | 22 | import com.diligrp.mobsite.getway.service.seller.SellerUserService; |
22 | import com.diligrp.website.util.redis.impl.RedisUtilImpl; | 23 | import com.diligrp.website.util.redis.impl.RedisUtilImpl; |
23 | import com.diligrp.website.util.security.Validator; | 24 | import com.diligrp.website.util.security.Validator; |
24 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
25 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
26 | import org.springframework.beans.factory.annotation.Autowired; | 27 | import org.springframework.beans.factory.annotation.Autowired; |
28 | +import org.springframework.beans.factory.annotation.Value; | ||
27 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
28 | 30 | ||
29 | import javax.annotation.Resource; | 31 | import javax.annotation.Resource; |
@@ -50,8 +52,7 @@ public class SellerUserServiceImpl implements SellerUserService { | @@ -50,8 +52,7 @@ public class SellerUserServiceImpl implements SellerUserService { | ||
50 | private GoodsRPC goodsRPC; | 52 | private GoodsRPC goodsRPC; |
51 | @Autowired | 53 | @Autowired |
52 | private RedisUtilImpl redisUtil; | 54 | private RedisUtilImpl redisUtil; |
53 | - @Autowired | ||
54 | - private UserRedisUtil userRedisUtil; | 55 | + |
55 | 56 | ||
56 | @Resource | 57 | @Resource |
57 | private RegisterNoMapperManager registerNoMapperManager; | 58 | private RegisterNoMapperManager registerNoMapperManager; |
@@ -65,42 +66,90 @@ public class SellerUserServiceImpl implements SellerUserService { | @@ -65,42 +66,90 @@ public class SellerUserServiceImpl implements SellerUserService { | ||
65 | @Autowired | 66 | @Autowired |
66 | private MessageRPC messageRPC; | 67 | private MessageRPC messageRPC; |
67 | 68 | ||
69 | + /** | ||
70 | + * 登录超时时间:秒 | ||
71 | + */ | ||
72 | + @Value("${login.timeout.second}") | ||
73 | + private int loginExpireTime; | ||
74 | + | ||
68 | 75 | ||
69 | private static Logger logger = LoggerFactory.getLogger(SellerUserServiceImpl.class); | 76 | private static Logger logger = LoggerFactory.getLogger(SellerUserServiceImpl.class); |
70 | 77 | ||
71 | @Override | 78 | @Override |
72 | public SellerLoginResp sellerLogin(SellerLoginReq req) throws RuntimeException { | 79 | public SellerLoginResp sellerLogin(SellerLoginReq req) throws RuntimeException { |
73 | - SellerLoginResp resp = passportRPC.sellerLogin(req); | 80 | + SellerInfoOutput userInfo = passportRPC.sellerLogin(req); |
81 | + | ||
82 | + //缓存用户信息 | ||
83 | + cacheUserInfo(userInfo.getId(),req.getDeviceId()); | ||
84 | + if (Validator.isEmpty(req.getRegisterNo())){ | ||
85 | + logger.error("卖家登录激光推送id为空[userId=]",userInfo.getId()); | ||
86 | + }else{ | ||
87 | + //绑定用户激光推送id | ||
88 | + bindUserRegisterNo(userInfo.getId(),req); | ||
89 | + } | ||
74 | 90 | ||
75 | - if (!Validator.isEmpty(req.getRegisterNo())) { | ||
76 | - // 缓存 | ||
77 | - String redisKey = redisUtil.makeKey(RedisKey.USER_REGISTERNO,Constant.USER_ROLE_SIGN_SELLER+ | ||
78 | - String.valueOf(resp.getSellerId())); | ||
79 | 91 | ||
80 | - GetRegisterNoResp mappers = redisUtil.getObject(redisKey, | ||
81 | - GetRegisterNoResp.class); | ||
82 | - // 绑定极光ID | ||
83 | - RegisterNoMapper mapper = new RegisterNoMapper(); | ||
84 | - mapper.setRegisterNo(req.getRegisterNo()); | ||
85 | - mapper.setSysFlag(RegisterNoMapper.SYS_FLAG_JPUSH); | ||
86 | - mapper.setUserid(resp.getSellerId()); | ||
87 | - mapper.setUserType(Constant.USER_ROLE_SELLER); | ||
88 | - mapper.setDeviceType(req.getDeviceType()); | ||
89 | - try { | ||
90 | - //清除当前极光号userid缓存 | ||
91 | - cleanOldredis(mapper); | ||
92 | - //构建缓存信息 | ||
93 | - buildRedisInfo(mappers, mapper); | ||
94 | - redisUtil.setObjectByExpire(redisKey, mappers, | ||
95 | - RedisKey.REGISTERNO_EXPIRE_TIME); | ||
96 | - } catch (Exception e) { | ||
97 | - throw new ServiceException(ResultCode.PUSH_MESSAGE_NO, | ||
98 | - "绑定极光推送系统注册号失败"); | ||
99 | - } | 92 | + SellerLoginResp resp = new SellerLoginResp(); |
93 | + ShopOutput shop = shopRPC.getShopBySellerId(userInfo.getId()); | ||
94 | + if (Validator.isNull(shop)||Validator.isNull(shop.getId())){ | ||
95 | + logger.info("卖家未开通店铺[sellerId=]",userInfo.getId()); | ||
96 | + resp.setShopId(null); | ||
97 | + resp.setMsg(ErrorMessage.SELLER_NOT_OPEN_SHOP); | ||
98 | + return resp; | ||
100 | } | 99 | } |
100 | + resp.setSellerId(userInfo.getId()); | ||
101 | + resp.setPhone(shop.getServiceTel()); | ||
102 | + resp.setShopId(shop.getId()); | ||
103 | + resp.setShopLogo(shop.getShopLogo()); | ||
104 | + resp.setShopName(shop.getShopName()); | ||
105 | + resp.setShopAuthCode(shop.getPromoCode().intValue()); | ||
101 | return resp; | 106 | return resp; |
102 | } | 107 | } |
103 | 108 | ||
109 | + private void bindUserRegisterNo(Long id, LoginReq req) { | ||
110 | + // 缓存 | ||
111 | + String redisKey = redisUtil.makeKey(RedisKey.USER_REGISTERNO,Constant.USER_ROLE_SIGN_SELLER+ | ||
112 | + String.valueOf(id)); | ||
113 | + | ||
114 | + GetRegisterNoResp mappers = redisUtil.getObject(redisKey, | ||
115 | + GetRegisterNoResp.class); | ||
116 | + // 绑定极光ID | ||
117 | + RegisterNoMapper mapper = new RegisterNoMapper(); | ||
118 | + mapper.setRegisterNo(req.getRegisterNo()); | ||
119 | + mapper.setSysFlag(RegisterNoMapper.SYS_FLAG_JPUSH); | ||
120 | + mapper.setUserid(id); | ||
121 | + mapper.setUserType(Constant.USER_ROLE_SELLER); | ||
122 | + mapper.setDeviceType(req.getDeviceType()); | ||
123 | + try { | ||
124 | + //清除当前极光号userid缓存 | ||
125 | + cleanOldredis(mapper); | ||
126 | + //构建缓存信息 | ||
127 | + buildRedisInfo(mappers, mapper); | ||
128 | + redisUtil.setObjectByExpire(redisKey, mappers, | ||
129 | + RedisKey.REGISTERNO_EXPIRE_TIME); | ||
130 | + } catch (Exception e) { | ||
131 | + throw new ServiceException(ResultCode.PUSH_MESSAGE_NO, | ||
132 | + "绑定极光推送系统注册号失败"); | ||
133 | + } | ||
134 | + } | ||
135 | + | ||
136 | + private void cacheUserInfo(Long userId,String deviceId) { | ||
137 | + //缓存userId | ||
138 | + String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(userId)); | ||
139 | + redisUtil.setStringByExpire(cookieRedisKey, String.valueOf(userId), loginExpireTime); | ||
140 | + | ||
141 | + //缓存shopId | ||
142 | + //String shopIdKey = redisUtil.makeKey(RedisKey.USER_SELLER_SHOPID, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId())); | ||
143 | + //redisUtil.setStringByExpire(shopIdKey, String.valueOf(resp.getShopId()), loginExpireTime); | ||
144 | + | ||
145 | + | ||
146 | + //缓存设备id,userId作为key | ||
147 | + if (!Validator.isNull(deviceId)) { | ||
148 | + String onlyOneLoginRedisKey = redisUtil.makeKey(RedisKey.USER_DEVICEID, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(deviceId)); | ||
149 | + redisUtil.setStringByExpire(onlyOneLoginRedisKey, deviceId, loginExpireTime); | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
104 | /** | 153 | /** |
105 | * 清除当前极光号下userid缓存 | 154 | * 清除当前极光号下userid缓存 |
106 | * @param mapper | 155 | * @param mapper |
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/buyer/user/UserController.java
@@ -52,7 +52,7 @@ public class UserController extends BaseApiController { | @@ -52,7 +52,7 @@ public class UserController extends BaseApiController { | ||
52 | LoginReq req = super.getRequest(LoginReq.class); | 52 | LoginReq req = super.getRequest(LoginReq.class); |
53 | try { | 53 | try { |
54 | BeanValidator.validator(req); | 54 | BeanValidator.validator(req); |
55 | - LoginResp resp = userService.login(req); | 55 | + LoginResp resp = userService.buyerlogin(req); |
56 | super.sendSuccessResp(resp); | 56 | super.sendSuccessResp(resp); |
57 | LOGGER.info(String.format("用户登陆:[ 设备id<%s>用户名<%s>用户id<%s>ip<%s> ]" | 57 | LOGGER.info(String.format("用户登陆:[ 设备id<%s>用户名<%s>用户id<%s>ip<%s> ]" |
58 | , req.getDeviceId(), req.getAccountName(), req.getUserId(), request.getRemoteAddr())); | 58 | , req.getDeviceId(), req.getAccountName(), req.getUserId(), request.getRemoteAddr())); |
@@ -80,7 +80,7 @@ public class UserController extends BaseApiController { | @@ -80,7 +80,7 @@ public class UserController extends BaseApiController { | ||
80 | try { | 80 | try { |
81 | BeanValidator.validator(req); | 81 | BeanValidator.validator(req); |
82 | req.setPassword(decodeStr(req.getPassword())); | 82 | req.setPassword(decodeStr(req.getPassword())); |
83 | - LoginResp resp = userService.login(req); | 83 | + LoginResp resp = userService.buyerlogin(req); |
84 | super.sendSuccessResp(resp); | 84 | super.sendSuccessResp(resp); |
85 | } catch (ServiceException e){ | 85 | } catch (ServiceException e){ |
86 | LOGGER.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", | 86 | LOGGER.error(String.format("Code=%s,ErrorMessage=%s,UserId=%s", |