Commit 9c84456336a835cdda4b5f99d81ac08122691122

Authored by jiangchengyong
2 parents 48101350 5f71d667

Merge remote-tracking branch 'origin/dev' into dev

mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/PassportRPC.java
@@ -37,4 +37,8 @@ public interface PassportRPC extends BaseService { @@ -37,4 +37,8 @@ public interface PassportRPC extends BaseService {
37 boolean sendVeriCodeOfBuyer(String mobile,Integer msgType); 37 boolean sendVeriCodeOfBuyer(String mobile,Integer msgType);
38 38
39 boolean verifySellerSmsCode(String mobile, String veriCode); 39 boolean verifySellerSmsCode(String mobile, String veriCode);
  40 +
  41 + boolean verifyBuyerSmsCode(String mobile, String veriCode);
  42 +
  43 +
40 } 44 }
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/PassportRPCImpl.java
@@ -2,6 +2,8 @@ package com.diligrp.mobsite.getway.rpc.impl; @@ -2,6 +2,8 @@ package com.diligrp.mobsite.getway.rpc.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 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;
  6 +import com.b2c.myapp.common.api.sellerInfo.output.SellerInfoOutput;
5 import com.diligrp.mobsite.getway.domain.common.Constant; 7 import com.diligrp.mobsite.getway.domain.common.Constant;
6 import com.diligrp.mobsite.getway.domain.common.RedisKey; 8 import com.diligrp.mobsite.getway.domain.common.RedisKey;
7 import com.diligrp.mobsite.getway.domain.common.ResultCode; 9 import com.diligrp.mobsite.getway.domain.common.ResultCode;
@@ -63,46 +65,29 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -63,46 +65,29 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
63 @Override 65 @Override
64 public SellerLoginResp sellerLogin(LoginReq req) { 66 public SellerLoginResp sellerLogin(LoginReq req) {
65 Map<String,String> params = new HashMap<String, String>(); 67 Map<String,String> params = new HashMap<String, String>();
66 - params.put("userName", req.getAccountName()); 68 + params.put("username", req.getAccountName());
67 params.put("password", req.getPassword()); 69 params.put("password", req.getPassword());
68 - params.put("src", "zadeapp");  
69 - BaseOutput<String> output = null; 70 + BaseOutput<SellerInfoOutput> output = null;
70 try { 71 try {
71 - output = super.httpPost("/api/login/login.html", params, null); 72 + output = super.httpPost("/api/login/sellerLogin", params, new TypeReference<BaseOutput<SellerInfoOutput>>(){});
72 } catch (Exception e) { 73 } catch (Exception e) {
73 - log.error("调用passport用户验证接口失败",e); 74 + log.error("调用passport卖家登录接口失败",e);
74 throw new ServiceException(); 75 throw new ServiceException();
75 } 76 }
76 - 77 + SellerInfoOutput sellerInfo = output.getData();
77 SellerLoginResp resp = new SellerLoginResp(); 78 SellerLoginResp resp = new SellerLoginResp();
78 - JSONObject jsonBody = JSONObject.parseObject(output.getData());  
79 - int code = 0;  
80 - try {  
81 - code = jsonBody.getIntValue("code");  
82 - } catch (Exception e) {  
83 - log.error("passport返回数据:msg={}",jsonBody); 79 + if (output.getCode()!=ResultCode.SUCCESS){
  80 + log.error("调用passport卖家登录接口失败:msg={}",output.getResult());
84 throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录"); 81 throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录");
85 } 82 }
86 83
87 - String msg = jsonBody.getString("msg");  
88 84
89 - if (code == PASSPORT_LOGIN_CODE_LOCKED || code == PASSPORT_LOGIN_CODE_ACCOUNT_NOT_EXIST  
90 - || code == PASSPORT_LOGIN_CODE_PASSWORD_WRONG) {  
91 - throw new ServiceException(code,msg);  
92 - }else if (code != ResultCode.SUCCESS) {  
93 - throw new ServiceException(ResultCode.BUSINESS_FAILED,msg);  
94 - }  
95 -  
96 - //resp.setToken(jsonBody.getString("token"));  
97 - JSONObject jsonUser = jsonBody.getJSONObject("accountInfo");  
98 - resp.setSellerId(jsonUser.getLong("accountId"));  
99 - resp.setPhone(jsonUser.getString("mobile"));  
100 - resp.setShopId(jsonUser.getLong("shopId")); 85 + resp.setSellerId(sellerInfo.getId());
  86 + resp.setPhone(sellerInfo.getMobilePhone());
  87 + resp.setShopId(1L);
101 resp.setShopLogo("sds.jpg"); 88 resp.setShopLogo("sds.jpg");
102 resp.setShopName("张三的水果店铺"); 89 resp.setShopName("张三的水果店铺");
103 resp.setShopAuthCode(457854); 90 resp.setShopAuthCode(457854);
104 - resp.setCode(code);  
105 - resp.setMsg(msg);  
106 91
107 //缓存userId 92 //缓存userId
108 String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId())); 93 String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_SELLER+String.valueOf(resp.getSellerId()));
@@ -207,46 +192,28 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -207,46 +192,28 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
207 public LoginResp buyerLogin(LoginReq req) { 192 public LoginResp buyerLogin(LoginReq req) {
208 193
209 Map<String,String> params = new HashMap<String, String>(); 194 Map<String,String> params = new HashMap<String, String>();
210 - params.put("userName", req.getAccountName()); 195 + params.put("username", req.getAccountName());
211 params.put("password", req.getPassword()); 196 params.put("password", req.getPassword());
212 - params.put("src", "zadeapp");  
213 - BaseOutput<String> output = null; 197 + BaseOutput<BuyerInfoOutput > output = null;
214 try { 198 try {
215 - output = super.httpPost("/api/login/login.html", params, null); 199 + output = super.httpPost("/api/login/buyerLogin", params, new TypeReference<BaseOutput<BuyerInfoOutput>>(){});
216 } catch (Exception e) { 200 } catch (Exception e) {
217 - log.error("调用passport用户验证接口失败",e); 201 + log.error("调用passport卖家登录接口失败",e);
218 throw new ServiceException(); 202 throw new ServiceException();
219 } 203 }
220 -  
221 - JSONObject jsonBody = JSONObject.parseObject(output.getData());  
222 - int code = 0;  
223 - try {  
224 - code = jsonBody.getIntValue("code");  
225 - } catch (Exception e) {  
226 - log.error("passport返回数据:msg={}",jsonBody); 204 + BuyerInfoOutput buyerInfo = output.getData();
  205 + if (output.getCode()!=ResultCode.SUCCESS){
  206 + log.error("调用passport买家登录接口失败:msg={}",output.getResult());
227 throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录"); 207 throw new ServiceException(ResultCode.BUSINESS_FAILED,"登录失败请重新登录");
228 } 208 }
229 209
230 - String msg = jsonBody.getString("msg");  
231 -  
232 - if (code == PASSPORT_LOGIN_CODE_LOCKED || code == PASSPORT_LOGIN_CODE_ACCOUNT_NOT_EXIST  
233 - || code == PASSPORT_LOGIN_CODE_PASSWORD_WRONG) {  
234 - throw new ServiceException(code,msg);  
235 - }else if (code != ResultCode.SUCCESS) {  
236 - throw new ServiceException(ResultCode.BUSINESS_FAILED,msg);  
237 - }  
238 -  
239 - //resp.setToken(jsonBody.getString("token"));  
240 - JSONObject jsonUser = jsonBody.getJSONObject("accountInfo");  
241 LoginResp resp = new LoginResp(); 210 LoginResp resp = new LoginResp();
242 - resp.setBuyerId(jsonUser.getLong("accountId"));  
243 - resp.setHeadImg(jsonUser.getString("img"));  
244 - resp.setMobile("13985454555"); 211 + resp.setBuyerId(buyerInfo.getId());
  212 + resp.setHeadImg(buyerInfo.getFace());
  213 + resp.setMobile(buyerInfo.getMobilePhone());
245 resp.setAccountName(""); 214 resp.setAccountName("");
246 resp.setCurrentShopId(123L); 215 resp.setCurrentShopId(123L);
247 resp.setShopBuyerId(122L); 216 resp.setShopBuyerId(122L);
248 - resp.setCode(code);  
249 - resp.setMsg(msg);  
250 217
251 //缓存userId 218 //缓存userId
252 String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId())); 219 String cookieRedisKey = redisUtil.makeKey(RedisKey.USER_LOGININFO, Constant.USER_ROLE_SIGN_BUYER+String.valueOf(resp.getBuyerId()));
@@ -289,12 +256,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -289,12 +256,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
289 output = super.httpGet("/api/forgot/sendSellerForgotPasswordSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){} ); 256 output = super.httpGet("/api/forgot/sendSellerForgotPasswordSMS/"+mobile, null, new TypeReference<BaseOutput<String>>(){} );
290 } 257 }
291 } catch (Exception e) { 258 } catch (Exception e) {
292 - log.error("调用passport用户验证接口失败",e); 259 + log.error("调用passport卖家注册发送短信失败",e);
293 throw new ServiceException(); 260 throw new ServiceException();
294 } 261 }
295 262
296 if (output.getCode()!= 200){ 263 if (output.getCode()!= 200){
297 - log.error("调用passport用户验证接口失败[mobile=,msg=]",mobile,output.getResult()); 264 + log.error("调用passport卖家注册发送短信失败[mobile=,msg=]",mobile,output.getResult());
298 throw new ServiceException(output.getCode(),output.getResult()); 265 throw new ServiceException(output.getCode(),output.getResult());
299 } 266 }
300 267
@@ -316,12 +283,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -316,12 +283,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
316 output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, null); 283 output = super.httpGet("/api/forgot/sendBuyerForgotPasswordSMS/"+mobile, null, null);
317 } 284 }
318 } catch (Exception e) { 285 } catch (Exception e) {
319 - log.error("调用passport用户验证接口失败",e); 286 + log.error("调用passport买家注册发送短信失败",e);
320 throw new ServiceException(); 287 throw new ServiceException();
321 } 288 }
322 289
323 if (output.getCode()!= 200){ 290 if (output.getCode()!= 200){
324 - log.error("调用passport用户验证接口失败[mobile=,msg=]",mobile,output.getResult()); 291 + log.error("调用passport买家注册发送短信失败[mobile=,msg=]",mobile,output.getResult());
325 throw new ServiceException(output.getCode(),output.getResult()); 292 throw new ServiceException(output.getCode(),output.getResult());
326 } 293 }
327 294
@@ -337,12 +304,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -337,12 +304,12 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
337 try { 304 try {
338 output = super.httpPost("/api/forgot/verifySellerSmsCode", params, null); 305 output = super.httpPost("/api/forgot/verifySellerSmsCode", params, null);
339 } catch (Exception e) { 306 } catch (Exception e) {
340 - log.error("调用passport用户验证接口失败",e); 307 + log.error("passport校验卖家短信验证码失败",e);
341 throw new ServiceException(); 308 throw new ServiceException();
342 } 309 }
343 310
344 if (output.getCode()!= 200){ 311 if (output.getCode()!= 200){
345 - log.error("调用passport用户验证接口失败[mobile=,msg=]",mobile,output.getResult()); 312 + log.error("passport校验卖家短信验证码失败[mobile=,msg=]",mobile,output.getResult());
346 throw new ServiceException(output.getCode(),output.getResult()); 313 throw new ServiceException(output.getCode(),output.getResult());
347 } 314 }
348 315
@@ -350,4 +317,24 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC { @@ -350,4 +317,24 @@ public class PassportRPCImpl extends BaseServiceImpl implements PassportRPC {
350 } 317 }
351 318
352 319
  320 + @Override
  321 + public boolean verifyBuyerSmsCode(String mobile, String veriCode) {
  322 + BaseOutput<String> output = null;
  323 + Map<String,String> params = new HashMap<String, String>();
  324 + params.put("phoneNumber", mobile);
  325 + params.put("code", veriCode);
  326 + try {
  327 + output = super.httpPost("/api/forgot/verifyBuyerSmsCode", params, null);
  328 + } catch (Exception e) {
  329 + log.error("passport校验买家短信验证码失败",e);
  330 + throw new ServiceException();
  331 + }
  332 +
  333 + if (output.getCode()!= 200){
  334 + log.error("passport校验买家短信验证码失败[mobile=,msg=]",mobile,output.getResult());
  335 + throw new ServiceException(output.getCode(),output.getResult());
  336 + }
  337 +
  338 + return output.getCode().equals("200");
  339 + }
353 } 340 }