diff --git a/README.md b/README.md index 6b26101c..c2ef7b97 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \ --data-raw '{ "appId":"7264840234423027259", "authId":"4463798", -"method":"getPlatformAuthUrl", +"method":"memberAuthCallBack", "data":"{\"pageNo\":\"1\",\"pageSize\":\"20\"}" }' diff --git a/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java b/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java index 7bf5c1c4..3049b2c1 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java +++ b/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java @@ -23,6 +23,8 @@ import com.ms.dal.entity.ShopTo1688DsMember; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import java.net.URLDecoder; +import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -41,21 +43,36 @@ public class MemberAuthCallback extends SPIBaseService implements ExtensionServi // ----参数校验---- MemberAuthCallBackRequestDTO fields = req.getData(); log.info("receive callback: " + JSON.toJSONString(fields)); - authCode = fields.getAuthCode(); + String body = "userId=gfZbbg6BSAlPMmw75xlCzQ%3D%3D&cnaliMemberId=b2b-221123084407697b20&authCode=NGNiYzEyODUtNzFhOS01ZmIwLWE5MDEtYzI3ZTAyYWFjOTA2&gmtMemberExpireTime=2023-11-13+23%3A59%3A59&type=auth"; + Map map = new HashMap(); // ----逻辑校验---- // ----业务处理---- try { + final String charset = "utf-8"; + String contents = URLDecoder.decode(body, charset); + String[] keyValues = contents.split("&"); + for (int i = 0; i < keyValues.length; i++) { + String key = keyValues[i].substring(0, keyValues[i].indexOf("=")); + String value = keyValues[i].substring(keyValues[i].indexOf("=") + 1); + map.put(key, value); + } + String authCode = map.get("authCode"); + String cnaliMemberId = map.get("cnaliMemberId"); + String gmtMemberExpireTime = map.get("gmtMemberExpireTime"); + this.authCode = fields.getAuthCode(); + log.info(map.toString()); + Shop1688DsAuth shop1688DsAuth = new Shop1688DsAuth(); - shop1688DsAuth.setAuthCode(fields.getAuthCode()); + shop1688DsAuth.setAuthCode(authCode); shop1688DsAuth.setShopId(shopId); shop1688DsAuthService.insert(shop1688DsAuth); ShopTo1688DsMember shopTo1688DsMember= new ShopTo1688DsMember(); - shopTo1688DsMember.setCnaliMemberId(fields.getCnaliMemberId()); + shopTo1688DsMember.setCnaliMemberId(cnaliMemberId); shopTo1688DsMember.setShopId(shopId); - shopTo1688DsMember.setGmtExpire(fields.getGmtMemberExpireTime()); + shopTo1688DsMember.setGmtExpire(gmtMemberExpireTime); shopTo1688DsMemberService.insert(shopTo1688DsMember); } catch (Exception e) { log.error(e.getMessage());