店铺会员新增

This commit is contained in:
张松
2025-02-15 11:28:08 +08:00
parent ec0809a783
commit 95c56e1b03
4 changed files with 90 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserEditDTO;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.dto.shopuser.ShopUserSummaryDTO;
@@ -102,4 +103,21 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser>
}
return shopUser;
}
@Override
public Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO) {
long userCount = userInfoService.queryChain().eq(UserInfo::getId, shopUserAddDTO.getUserId()).count();
if (userCount == 0) {
throw new ApiNotPrintException("用户信息不存在");
}
long count = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, shopUserAddDTO.getUserId()).count();
if (count > 0) {
throw new ApiNotPrintException("此用户已存在");
}
ShopUser shopUser = BeanUtil.copyProperties(shopUserAddDTO, ShopUser.class);
shopUser.setShopId(shopId);
shopUser.setJoinTime(shopUser.getIsVip() != null &&shopUser.getIsVip() == 1 ? DateUtil.date().toLocalDateTime() : null);
return save(shopUser);
}
}