店铺会员新增
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user