diff --git a/ms-biz/src/main/java/com/ms/api/service/Shop1688DsAuthService.java b/ms-biz/src/main/java/com/ms/api/service/Shop1688DsAuthService.java index 4ebdb726..75539e66 100644 --- a/ms-biz/src/main/java/com/ms/api/service/Shop1688DsAuthService.java +++ b/ms-biz/src/main/java/com/ms/api/service/Shop1688DsAuthService.java @@ -18,4 +18,6 @@ public interface Shop1688DsAuthService { int updateByPrimaryKeySelective(Shop1688DsAuth record); int updateByPrimaryKey(Shop1688DsAuth record); + + Shop1688DsAuth getDetailByShopId(Long shopId); } diff --git a/ms-biz/src/main/java/com/ms/api/service/ShopTo1688DsMemberService.java b/ms-biz/src/main/java/com/ms/api/service/ShopTo1688DsMemberService.java index 9a526654..4dacf551 100644 --- a/ms-biz/src/main/java/com/ms/api/service/ShopTo1688DsMemberService.java +++ b/ms-biz/src/main/java/com/ms/api/service/ShopTo1688DsMemberService.java @@ -18,4 +18,6 @@ public interface ShopTo1688DsMemberService { int updateByPrimaryKeySelective(ShopTo1688DsMember record); int updateByPrimaryKey(ShopTo1688DsMember record); + + ShopTo1688DsMember getDetailByShopId(Long shopId); } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/Shop1688DsAuthServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/Shop1688DsAuthServiceImpl.java index 77ac8f64..d678098d 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/Shop1688DsAuthServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/Shop1688DsAuthServiceImpl.java @@ -46,6 +46,11 @@ public class Shop1688DsAuthServiceImpl implements Shop1688DsAuthService{ return shop1688DsAuthMapper.updateByPrimaryKey(record); } + @Override + public Shop1688DsAuth getDetailByShopId(Long shopId) { + return shop1688DsAuthMapper.getDetailByShopId(shopId); + } + } diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/ShopTo1688DsMemberServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/ShopTo1688DsMemberServiceImpl.java index da38a688..62d10c1a 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/ShopTo1688DsMemberServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/ShopTo1688DsMemberServiceImpl.java @@ -46,6 +46,11 @@ public class ShopTo1688DsMemberServiceImpl implements ShopTo1688DsMemberService{ return shopTo1688DsMemberMapper.updateByPrimaryKey(record); } + @Override + public ShopTo1688DsMember getDetailByShopId(Long shopId) { + return shopTo1688DsMemberMapper.getDetailByShopId(shopId); + } + } 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 8b2ef72d..d3e8c8ea 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 @@ -44,7 +44,7 @@ public class MemberAuthCallback extends SPIBaseService implements ExtensionServi MemberAuthCallBackRequestDTO fields = req.getData(); log.info("receive callback: " + JSON.toJSONString(fields)); String body = fields.getBody(); - +// String body = "userId=gfZbbg6BSAlPMmw75xlCzQ%3D%3D&cnaliMemberId=b2b-221123084407697b20&authCode=NGNiYzEyODUtNzFhOS01ZmIwLWE5MDEtYzI3ZTAyYWFjOTA2&gmtMemberExpireTime=2023-11-13+23%3A59%3A59&type=auth"; Map map = new HashMap(); // ----逻辑校验---- @@ -65,17 +65,26 @@ public class MemberAuthCallback extends SPIBaseService implements ExtensionServi this.authCode = fields.getAuthCode(); log.info(map.toString()); - Shop1688DsAuth shop1688DsAuth = new Shop1688DsAuth(); + Shop1688DsAuth shop1688DsAuth = shop1688DsAuthService.getDetailByShopId(Long.valueOf(SecurityTool.decodeByAES(userId))); + if (Objects.isNull(shop1688DsAuth)) { + shop1688DsAuth = new Shop1688DsAuth(); + shop1688DsAuthService.insert(shop1688DsAuth); + } shop1688DsAuth.setAuthCode(authCode); shop1688DsAuth.setShopId(Long.valueOf(SecurityTool.decodeByAES(userId))); - shop1688DsAuthService.insert(shop1688DsAuth); + shop1688DsAuthService.updateByPrimaryKey(shop1688DsAuth); - ShopTo1688DsMember shopTo1688DsMember= new ShopTo1688DsMember(); + ShopTo1688DsMember shopTo1688DsMember = shopTo1688DsMemberService.getDetailByShopId(Long.valueOf(SecurityTool.decodeByAES(userId))); + if (Objects.isNull(shopTo1688DsMember)) { + shopTo1688DsMember = new ShopTo1688DsMember(); + shopTo1688DsMemberService.insert(shopTo1688DsMember); + } shopTo1688DsMember.setCnaliMemberId(cnaliMemberId); shopTo1688DsMember.setShopId(Long.valueOf(SecurityTool.decodeByAES(userId))); shopTo1688DsMember.setGmtExpire(gmtMemberExpireTime); - shopTo1688DsMemberService.insert(shopTo1688DsMember); + shopTo1688DsMemberService.updateByPrimaryKey(shopTo1688DsMember); } catch (Exception e) { + e.printStackTrace(); log.error(e.getMessage()); } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/Shop1688DsAuthMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/Shop1688DsAuthMapper.java index a57c9645..fad297a4 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/Shop1688DsAuthMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/Shop1688DsAuthMapper.java @@ -21,4 +21,5 @@ public interface Shop1688DsAuthMapper { int updateByPrimaryKey(Shop1688DsAuth record); + Shop1688DsAuth getDetailByShopId(Long shopId); } diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/ShopTo1688DsMemberMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/ShopTo1688DsMemberMapper.java index 09a2ec4b..8898d868 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/ShopTo1688DsMemberMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/ShopTo1688DsMemberMapper.java @@ -22,4 +22,6 @@ public interface ShopTo1688DsMemberMapper { int updateByPrimaryKey(ShopTo1688DsMember record); ShopTo1688DsMember selectByShopId(Long shopId); + + ShopTo1688DsMember getDetailByShopId(Long shopId); } diff --git a/ms-dal/src/main/resources/mapper/Shop1688DsAuthMapper.xml b/ms-dal/src/main/resources/mapper/Shop1688DsAuthMapper.xml index 6a175323..42dde241 100644 --- a/ms-dal/src/main/resources/mapper/Shop1688DsAuthMapper.xml +++ b/ms-dal/src/main/resources/mapper/Shop1688DsAuthMapper.xml @@ -24,6 +24,13 @@ where shop_1688_ds_auth_id = #{shop1688DsAuthId,jdbcType=BIGINT} + + delete from shop_1688_ds_auth where shop_1688_ds_auth_id = #{shop1688DsAuthId,jdbcType=BIGINT} diff --git a/ms-dal/src/main/resources/mapper/ShopTo1688DsMemberMapper.xml b/ms-dal/src/main/resources/mapper/ShopTo1688DsMemberMapper.xml index 06372a92..527bfd62 100644 --- a/ms-dal/src/main/resources/mapper/ShopTo1688DsMemberMapper.xml +++ b/ms-dal/src/main/resources/mapper/ShopTo1688DsMemberMapper.xml @@ -26,6 +26,12 @@ from shop_to_1688_ds_member where shop_to_1688_ds_member_id = #{shopTo1688DsMemberId,jdbcType=BIGINT} +