会员信息相关接口

This commit is contained in:
张松 2025-02-27 15:16:23 +08:00
parent 2871e9f7ee
commit 3be9ca1710
4 changed files with 38 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -52,6 +53,17 @@ public class ShopUserController {
return CzgResult.success(shopUserService.getPage(key, isVip));
}
/**
* 获取店铺用户详情
* @param id 会员用户id
* @return 用户详情
*/
@SaAdminCheckPermission("shopUser:detail")
@GetMapping("/detail")
public CzgResult<ShopUser> detail(@RequestParam Integer id) {
return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getId, id).eq(ShopUser::getShopId, StpKit.USER.getShopId())));
}
/**
* 店铺用户信息添加
*

View File

@ -1,15 +1,16 @@
package com.czg.controller.user;
import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 店铺会员相关
@ -30,7 +31,7 @@ public class UShopUserController {
*/
@GetMapping
public CzgResult<ShopUser> get(Long shopId) {
return CzgResult.success(shopUserService.getShopUserInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
return CzgResult.success(shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId)));
}
/**
@ -53,4 +54,9 @@ public class UShopUserController {
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), shopId == null ? StpKit.USER.getShopId() : shopId);
}
@PostMapping
public CzgResult<Boolean> join(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
return shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO);
}
}

View File

@ -35,4 +35,6 @@ public interface ShopUserService extends IService<ShopUser> {
Page<ShopUserVipCardDTO> vipCard(long userInfoId);
CzgResult<String> getCode(long userInfoId, long shopId);
CzgResult<Boolean> join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO);
}

View File

@ -182,4 +182,18 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
return date + platformNumber + shopIdLastTwoDigits + randomPart;
}
@Override
public CzgResult<Boolean> join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId));
if (shopUser != null) {
throw new ApiNotPrintException("您已加入店铺会员");
}
shopUser = BeanUtil.copyProperties(shopUserAddDTO, ShopUser.class);
shopUser.setIsVip(1);
// shopUser.setCode();
return null;
}
}