Commit 451589be by guojuxing

微盟授权加日志

parent a1edd21f
......@@ -154,13 +154,11 @@ public class WmMallStoreController {
@RequestMapping("/get-auth-url")
public RestResponse getAuthUrl(Integer wmMallStoreId) {
//
ServiceResponse<String> response = weimobMerchantService.getAuthUrl();
ServiceResponse<String> response = weimobMerchantService.getAuthUrl(wmMallStoreId);
if (response.isSuccess()) {
String authUrl = response.getResult();
String mainHost = DomainUtils.getCurrentDomain() + "/gic-enterprise-web/wm-mall-store/auth-callback";
//为了授权回调取用的店铺主键ID
RedisUtil.setCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId(), wmMallStoreId);
return RestResponse.success(authUrl + "&redirect_uri=" + mainHost);
} else {
return RestResponse.failure(response.getCode(), response.getMessage());
......@@ -374,17 +372,13 @@ public class WmMallStoreController {
* @param code
*/
@RequestMapping("auth-callback")
public RestResponse authCallBack(String code) throws IOException {
Object obj = RedisUtil.getCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId());
public RestResponse authCallBack(String code, Integer state) throws IOException {
try {
if (obj == null) {
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "微盟授权-店铺ID缓存不存在");
}
ServiceResponse<Void> authWmResponse = weimobMerchantService.weimobStoreAuth((Integer) obj, code);
ServiceResponse<Void> authWmResponse = weimobMerchantService.weimobStoreAuth(state, code);
LOGGER.info("微盟中间件返回结果:{}", JSON.toJSONString(authWmResponse));
if (authWmResponse.isSuccess()) {
//更新gic侧店铺授权状态
ServiceResponse<String> wmMallStoreResponse = wmStoreApiService.authWmStore((Integer) obj);
ServiceResponse<String> wmMallStoreResponse = wmStoreApiService.authWmStore(state);
if (!wmMallStoreResponse.isSuccess()) {
LOGGER.warn("企业侧微盟店铺授权结果:{}", JSON.toJSONString(wmMallStoreResponse));
}
......@@ -394,10 +388,6 @@ public class WmMallStoreController {
} catch (Exception e) {
LOGGER.warn("微盟授权返回结果:{}", e.getMessage(), e);
return RestResponse.failure(ErrorCode.SYSTEM_ERROR.getCode(), e.getMessage());
} finally {
//清空缓存
LOGGER.warn("微盟授权-缓存:{}", obj);
RedisUtil.delCache("enterprise:wm:auth:" + UserDetailUtils.getUserDetail().getEnterpriseId());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment