diff --git a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java index 48b756f0..a3bdfc01 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopUserController.java @@ -26,6 +26,6 @@ public class UShopUserController { */ @GetMapping public CzgResult get() { - return CzgResult.success(shopUserService.queryChain().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getId, StpKit.USER.getLoginIdAsLong()).one()); + return CzgResult.success(shopUserService.getShopUserInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong())); } } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java index f352776c..4f379b6d 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopUserService.java @@ -22,4 +22,6 @@ public interface ShopUserService extends IService { Boolean updateMoney(Long shopId, ShopUserMoneyEditDTO shopUserEditDTO); ShopUserSummaryDTO getSummary(Long shopId, Integer isVip); + + ShopUser getShopUserInfo(Long shopId, long userId); } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java index ff8585d5..d4448658 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopUserServiceImpl.java @@ -7,8 +7,10 @@ import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; import com.czg.account.dto.shopuser.ShopUserSummaryDTO; import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUserFlow; +import com.czg.account.entity.UserInfo; import com.czg.account.service.ShopUserFlowService; import com.czg.account.service.ShopUserService; +import com.czg.account.service.UserInfoService; import com.czg.enums.ShopUserFlowBizEnum; import com.czg.exception.ApiNotPrintException; import com.czg.sa.StpKit; @@ -31,6 +33,8 @@ import java.math.RoundingMode; public class ShopUserServiceImpl extends ServiceImpl implements ShopUserService { @Resource private ShopUserFlowService shopUserFlowService; + @Resource + private UserInfoService userInfoService; private ShopUser getUserInfo(Long shopUserId, Long shopId) { ShopUser shopUser = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getId, shopUserId).one(); @@ -83,4 +87,19 @@ public class ShopUserServiceImpl extends ServiceImpl public ShopUserSummaryDTO getSummary(Long shopId, Integer isVip) { return mapper.selectUserSummary(shopId, isVip); } + + @Override + public ShopUser getShopUserInfo(Long shopId, long userId) { + ShopUser shopUser = queryChain().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getId, StpKit.USER.getLoginIdAsLong()).one(); + if (shopUser == null) { + shopUser = new ShopUser(); + UserInfo userInfo = userInfoService.getById(userId); + BeanUtil.copyProperties(userInfo, shopUser); + shopUser.setShopId(shopId); + shopUser.setUserId(userId); + shopUser.setId(null); + save(shopUser); + } + return shopUser; + } }