店铺会员返回优惠券数量
This commit is contained in:
@@ -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<ShopUser> get(Long shopId) {
|
||||
return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId)));
|
||||
public CzgResult<ShopUserDetailDTO> get(Long shopId) {
|
||||
return CzgResult.success(shopUserService.getInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,8 +37,8 @@ public class UserAuthorizationController {
|
||||
* @return 登录信息
|
||||
*/
|
||||
@PostMapping("/test")
|
||||
public CzgResult<String> login() {
|
||||
StpKit.USER.login(103L, "2342", null, MyStpLogic.LoginType.USER, false);
|
||||
public CzgResult<String> login(@RequestParam long id) {
|
||||
StpKit.USER.login(id, "2342", null, MyStpLogic.LoginType.USER, false);
|
||||
return CzgResult.success(StpKit.USER.getTokenValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -37,4 +37,6 @@ public interface ShopUserService extends IService<ShopUser> {
|
||||
CzgResult<String> getCode(long userInfoId, long shopId);
|
||||
|
||||
boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
|
||||
|
||||
ShopUserDetailDTO getInfo(Long shopId, long userId);
|
||||
}
|
||||
|
||||
@@ -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<ShopUserMapper, ShopUser> 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<ShopUserMapper, ShopUser> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user