From 9a3ba7dff4d2a8ea2f5035b0f1f51763dee02227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Fri, 28 Feb 2025 13:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=E4=BC=9A=E5=91=98=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=BC=98=E6=83=A0=E5=88=B8=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/user/UShopUserController.java | 5 +-- .../user/UserAuthorizationController.java | 4 +-- .../dto/shopuser/ShopUserDetailDTO.java | 32 +++++++++++++++++++ .../czg/account/service/ShopUserService.java | 2 ++ .../service/impl/ShopUserServiceImpl.java | 32 ++++++++++++++----- 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopuser/ShopUserDetailDTO.java 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 836661bfb..3a36862e0 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 @@ -1,6 +1,7 @@ package com.czg.controller.user; import com.czg.account.dto.shopuser.ShopUserAddDTO; +import com.czg.account.dto.shopuser.ShopUserDetailDTO; import com.czg.account.dto.shopuser.ShopUserVipCardDTO; import com.czg.account.entity.PointsExchangeRecord; import com.czg.account.entity.ShopUser; @@ -39,8 +40,8 @@ public class UShopUserController { * @return 店铺会员信息 */ @GetMapping - public CzgResult get(Long shopId) { - return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId))); + public CzgResult get(Long shopId) { + return CzgResult.success(shopUserService.getInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong())); } /** diff --git a/cash-api/account-server/src/main/java/com/czg/controller/user/UserAuthorizationController.java b/cash-api/account-server/src/main/java/com/czg/controller/user/UserAuthorizationController.java index c63f4df36..4547a2c7f 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/user/UserAuthorizationController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/user/UserAuthorizationController.java @@ -37,8 +37,8 @@ public class UserAuthorizationController { * @return 登录信息 */ @PostMapping("/test") - public CzgResult login() { - StpKit.USER.login(103L, "2342", null, MyStpLogic.LoginType.USER, false); + public CzgResult login(@RequestParam long id) { + StpKit.USER.login(id, "2342", null, MyStpLogic.LoginType.USER, false); return CzgResult.success(StpKit.USER.getTokenValue()); } } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopuser/ShopUserDetailDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopuser/ShopUserDetailDTO.java new file mode 100644 index 000000000..4a65750f8 --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopuser/ShopUserDetailDTO.java @@ -0,0 +1,32 @@ +package com.czg.account.dto.shopuser; + +import com.czg.account.entity.ShopUser; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +/** + * @author Administrator + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class ShopUserDetailDTO extends ShopUser { + /** + * 店铺logo + */ + private String logo; + /** + * 店铺名 + */ + private String shopName; + /** + * 优惠券数量 + */ + private long couponNum; + /** + * 店铺id + */ + private Long shopId; + +} 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 578ddc027..54804133d 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 @@ -37,4 +37,6 @@ public interface ShopUserService extends IService { CzgResult getCode(long userInfoId, long shopId); boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO); + + ShopUserDetailDTO getInfo(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 2497ea3c4..040ec4f07 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 @@ -5,19 +5,15 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.czg.account.dto.shopuser.*; -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.account.entity.*; +import com.czg.account.service.*; import com.czg.config.RedisCst; import com.czg.exception.ApiNotPrintException; import com.czg.resp.CzgResult; import com.czg.sa.StpKit; import com.czg.service.RedisService; +import com.czg.service.account.mapper.ShopInfoMapper; import com.czg.service.account.mapper.ShopUserMapper; -import com.czg.system.dto.SysParamsDTO; import com.czg.system.entity.SysParams; import com.czg.system.service.SysParamsService; import com.czg.utils.AssertUtil; @@ -34,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional; import java.math.RoundingMode; -import static com.mybatisflex.core.query.QueryMethods.column; /** * 商户储值会员 服务层实现。 @@ -54,6 +49,10 @@ public class ShopUserServiceImpl extends ServiceImpl i private UserInfoService userInfoService; @Resource private RedisService redisService; + @Resource + private ShopActivateCouponRecordService shopActivateCouponRecordService; + @Resource + private ShopInfoMapper shopInfoMapper; private ShopUser getUserInfo(Long shopId, Long shopUserId) { ShopUser shopUser = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getId, shopUserId).one(); @@ -251,4 +250,21 @@ public class ShopUserServiceImpl extends ServiceImpl i shopUser.setUserId(userId); return save(shopUser); } + + @Override + public ShopUserDetailDTO getInfo(Long shopId, long userId) { + ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId)); + if (shopUser == null) { + return null; + } + + long couponNum = shopActivateCouponRecordService.count(new QueryWrapper().eq(ShopActivateCouponRecord::getShopUserId, shopUser.getId()).eq(ShopActivateCouponRecord::getStatus, 0)); + ShopUserDetailDTO shopUserDetailDTO = BeanUtil.copyProperties(shopUser, ShopUserDetailDTO.class); + shopUserDetailDTO.setCouponNum(couponNum); + + ShopInfo shopInfo = shopInfoMapper.selectOneById(shopId); + shopUserDetailDTO.setShopName(shopInfo.getShopName()); + shopUserDetailDTO.setShopId(shopInfo.getId()); + return shopUserDetailDTO; + } }