店铺会员返回优惠券数量

This commit is contained in:
张松
2025-02-28 13:59:04 +08:00
parent 5499e452fd
commit 9a3ba7dff4
5 changed files with 63 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package com.czg.controller.user; package com.czg.controller.user;
import com.czg.account.dto.shopuser.ShopUserAddDTO; 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.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.PointsExchangeRecord; import com.czg.account.entity.PointsExchangeRecord;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
@@ -39,8 +40,8 @@ public class UShopUserController {
* @return 店铺会员信息 * @return 店铺会员信息
*/ */
@GetMapping @GetMapping
public CzgResult<ShopUser> get(Long shopId) { public CzgResult<ShopUserDetailDTO> get(Long shopId) {
return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId))); return CzgResult.success(shopUserService.getInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
} }
/** /**

View File

@@ -37,8 +37,8 @@ public class UserAuthorizationController {
* @return 登录信息 * @return 登录信息
*/ */
@PostMapping("/test") @PostMapping("/test")
public CzgResult<String> login() { public CzgResult<String> login(@RequestParam long id) {
StpKit.USER.login(103L, "2342", null, MyStpLogic.LoginType.USER, false); StpKit.USER.login(id, "2342", null, MyStpLogic.LoginType.USER, false);
return CzgResult.success(StpKit.USER.getTokenValue()); return CzgResult.success(StpKit.USER.getTokenValue());
} }
} }

View File

@@ -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;
}

View File

@@ -37,4 +37,6 @@ public interface ShopUserService extends IService<ShopUser> {
CzgResult<String> getCode(long userInfoId, long shopId); CzgResult<String> getCode(long userInfoId, long shopId);
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO); boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
ShopUserDetailDTO getInfo(Long shopId, long userId);
} }

View File

@@ -5,19 +5,15 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.shopuser.*; import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.*;
import com.czg.account.entity.ShopUserFlow; import com.czg.account.service.*;
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.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.ApiNotPrintException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopInfoMapper;
import com.czg.service.account.mapper.ShopUserMapper; import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.entity.SysParams; import com.czg.system.entity.SysParams;
import com.czg.system.service.SysParamsService; import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
@@ -34,7 +30,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.RoundingMode; import java.math.RoundingMode;
import static com.mybatisflex.core.query.QueryMethods.column;
/** /**
* 商户储值会员 服务层实现。 * 商户储值会员 服务层实现。
@@ -54,6 +49,10 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Resource @Resource
private RedisService redisService; private RedisService redisService;
@Resource
private ShopActivateCouponRecordService shopActivateCouponRecordService;
@Resource
private ShopInfoMapper shopInfoMapper;
private ShopUser getUserInfo(Long shopId, Long shopUserId) { private ShopUser getUserInfo(Long shopId, Long shopUserId) {
ShopUser shopUser = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getId, shopUserId).one(); ShopUser shopUser = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getId, shopUserId).one();
@@ -251,4 +250,21 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
shopUser.setUserId(userId); shopUser.setUserId(userId);
return save(shopUser); 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;
}
} }