framework/src/main/java/cn/lili/modules/lmk/domain/entity/CustomerBlack.java
New file @@ -0,0 +1,29 @@ package cn.lili.modules.lmk.domain.entity; import cn.lili.mybatis.BaseEntity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; /** * 客户黑名单 * * @author zxl * @since 2025-05-15 */ @Data @TableName("lmk_customer_black") public class CustomerBlack extends BaseEntity { private static final long serialVersionUID = 1L; @TableField("store_id") /** 店铺id */ private String storeId; @TableField("user_id") /** 用户id */ private String userId; } framework/src/main/java/cn/lili/modules/lmk/domain/entity/CustomerTag.java
@@ -22,5 +22,8 @@ /** 标签名称*/ private String tagName; @TableField("create_type") /** 创建方式 */ private String createType; } framework/src/main/java/cn/lili/modules/lmk/domain/form/CustomerBlackForm.java
New file @@ -0,0 +1,41 @@ package cn.lili.modules.lmk.domain.form; import cn.lili.base.AbsForm; import cn.lili.group.Add; import cn.lili.group.Update; import cn.lili.modules.lmk.domain.entity.CustomerBlack; import org.springframework.beans.BeanUtils; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import org.springframework.lang.NonNull; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; /** * 客户黑名单表单 * * @author zxl * @since 2025-05-15 */ @Data @ApiModel(value = "CustomerBlack表单", description = "客户黑名单表单") public class CustomerBlackForm extends AbsForm { @ApiModelProperty("店铺id") private String storeId; @NotBlank(message = "用户id不能为空", groups = {Add.class, Update.class}) @ApiModelProperty("用户id") private String userId; public static CustomerBlack getEntityByForm(@NonNull CustomerBlackForm form, CustomerBlack entity) { if(entity == null) { entity = new CustomerBlack(); } BeanUtils.copyProperties(form, entity); return entity; } } framework/src/main/java/cn/lili/modules/lmk/domain/query/CustomerBlackQuery.java
New file @@ -0,0 +1,29 @@ package cn.lili.modules.lmk.domain.query; import cn.lili.base.AbsQuery; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * 客户黑名单查询 * * @author zxl * @since 2025-05-15 */ @Data @ApiModel(value = "CustomerBlack查询参数", description = "客户黑名单查询参数") public class CustomerBlackQuery extends AbsQuery { @ApiModelProperty(value = "用户名") private String username; @ApiModelProperty(value = "昵称") private String nickName; @ApiModelProperty(value = "商户id") private String storeId; } framework/src/main/java/cn/lili/modules/lmk/domain/query/CustomerQuery.java
@@ -19,7 +19,7 @@ @ApiModelProperty(value = "用户手机号码") private String mobile; @ApiModelProperty(value = "商户名") @ApiModelProperty(value = "商户id") private String storeId; /** framework/src/main/java/cn/lili/modules/lmk/domain/vo/CustomerBlackVO.java
New file @@ -0,0 +1,52 @@ package cn.lili.modules.lmk.domain.vo; import cn.lili.base.AbsVo; import cn.lili.modules.lmk.domain.entity.CustomerBlack; import org.springframework.lang.NonNull; import org.springframework.beans.BeanUtils; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; /** * 客户黑名单展示 * * @author zxl * @since 2025-05-15 */ @Data @ApiModel(value = "客户黑名单响应数据", description = "客户黑名单响应数据") public class CustomerBlackVO extends AbsVo { /** 店铺id */ @ApiModelProperty("店铺id") private String storeId; /** 用户id */ @ApiModelProperty("用户id") private String userId; /** 创建方式 */ @ApiModelProperty("创建方式") private String createType; @ApiModelProperty("用户名") private String username; @ApiModelProperty("昵称") private String nickName; @ApiModelProperty(value = "会员地址") private String region; public static CustomerBlackVO getVoByEntity(@NonNull CustomerBlack entity, CustomerBlackVO vo) { if(vo == null) { vo = new CustomerBlackVO(); } BeanUtils.copyProperties(entity, vo); return vo; } } framework/src/main/java/cn/lili/modules/lmk/mapper/CustomerBlackMapper.java
New file @@ -0,0 +1,33 @@ package cn.lili.modules.lmk.mapper; import cn.lili.modules.lmk.domain.entity.CustomerBlack; import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; import cn.lili.modules.lmk.domain.vo.CustomerBlackVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; /** * 客户黑名单 Mapper 接口 * * @author zxl * @since 2025-05-15 */ @Mapper public interface CustomerBlackMapper extends BaseMapper<CustomerBlack> { /** * id查找客户黑名单 * @param id * @return */ CustomerBlackVO getById(Integer id); /** * 分页 */ IPage getPage(IPage page, @Param("query") CustomerBlackQuery query); } framework/src/main/java/cn/lili/modules/lmk/service/CustomerBlackService.java
New file @@ -0,0 +1,67 @@ package cn.lili.modules.lmk.service; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.entity.CustomerBlack; import cn.lili.modules.lmk.domain.form.CustomerBlackForm; import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * 客户黑名单 服务类 * * @author zxl * @since 2025-05-15 */ public interface CustomerBlackService extends IService<CustomerBlack> { /** * 添加 * @param form * @return */ Result add(CustomerBlackForm form); /** * 修改 * @param form * @return */ Result update(CustomerBlackForm form); /** * 批量删除 * @param ids * @return */ Result remove(List<String> ids); /** * id删除 * @param id * @return */ Result removeById(String id); /** * 分页查询 * @param query * @return */ Result page(CustomerBlackQuery query); /** * 根据id查找 * @param id * @return */ Result detail(Integer id); /** * 列表 * @return */ Result all(); } framework/src/main/java/cn/lili/modules/lmk/service/impl/CustomerBlackServiceImpl.java
New file @@ -0,0 +1,136 @@ package cn.lili.modules.lmk.service.impl; import cn.lili.base.Result; import cn.lili.modules.lmk.domain.entity.CustomerBlack; import cn.lili.modules.lmk.domain.form.CustomerBlackForm; import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; import cn.lili.modules.lmk.domain.vo.CustomerBlackVO; import cn.lili.modules.lmk.mapper.CustomerBlackMapper; import cn.lili.modules.lmk.service.CustomerBlackService; import cn.lili.utils.PageUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.util.Assert; import java.util.List; import java.util.stream.Collectors; /** * 客户黑名单 服务实现类 * * @author zxl * @since 2025-05-15 */ @Service @RequiredArgsConstructor public class CustomerBlackServiceImpl extends ServiceImpl<CustomerBlackMapper, CustomerBlack> implements CustomerBlackService { private final CustomerBlackMapper customerBlackMapper; /** * 添加 * @param form * @return */ @Override public Result add(CustomerBlackForm form) { CustomerBlack entity = CustomerBlackForm.getEntityByForm(form, null); //判断是否已存在黑名单中 CustomerBlack customerBlack = new LambdaQueryChainWrapper<CustomerBlack>(customerBlackMapper) .eq(CustomerBlack::getUserId,entity.getUserId()) .and(customer -> { if (form.getStoreId() == null) { customer.isNull(CustomerBlack::getStoreId); } else { customer.isNotNull(CustomerBlack::getStoreId); } } ).one(); if (customerBlack != null) { return Result.ok("该客户已被添加到黑名单中!"); } baseMapper.insert(entity); return Result.ok("添加成功"); } /** * 修改 * @param form * @return */ @Override public Result update(CustomerBlackForm form) { CustomerBlack entity = baseMapper.selectById(form.getId()); // 为空抛IllegalArgumentException,做全局异常处理 Assert.notNull(entity, "记录不存在"); BeanUtils.copyProperties(form, entity); baseMapper.updateById(entity); return Result.ok("修改成功"); } /** * 批量删除 * @param ids * @return */ @Override public Result remove(List<String> ids) { baseMapper.deleteBatchIds(ids); return Result.ok("删除成功"); } /** * id删除 * @param id * @return */ @Override public Result removeById(String id) { baseMapper.deleteById(id); return Result.ok("删除成功"); } /** * 分页查询 * @param query * @return */ @Override public Result page(CustomerBlackQuery query) { IPage<CustomerBlackVO> page = PageUtil.getPage(query, CustomerBlackVO.class); baseMapper.getPage(page, query); return Result.ok().data(page.getRecords()).total(page.getTotal()); } /** * 根据id查找 * @param id * @return */ @Override public Result detail(Integer id) { CustomerBlackVO vo = baseMapper.getById(id); Assert.notNull(vo, "记录不存在"); return Result.ok().data(vo); } /** * 列表 * @return */ @Override public Result all() { List<CustomerBlack> entities = baseMapper.selectList(null); List<CustomerBlackVO> vos = entities.stream() .map(entity -> CustomerBlackVO.getVoByEntity(entity, null)) .collect(Collectors.toList()); return Result.ok().data(vos); } } framework/src/main/resources/mapper/lmk/CustomerBlackMapper.xml
New file @@ -0,0 +1,70 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="cn.lili.modules.lmk.mapper.CustomerBlackMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.CustomerBlackVO"> <result column="store_id" property="storeId" /> <result column="user_id" property="userId" /> <result column="create_time" property="createTime" /> <result column="create_by" property="createBy" /> <result column="update_by" property="updateBy" /> <result column="update_time" property="updateTime" /> <result column="username" property="username" /> <result column="nickName" property="nick_name" /> <result property="region" column="region"/> <result property="storeId" column="store_id"/> </resultMap> <select id="getById" resultMap="BaseResultMap"> SELECT LCB.store_id, LCB.user_id, LCB.create_time, LCB.create_by, LCB.update_by, LCB.update_time, LCB.id FROM lmk_customer_black LCB WHERE LCB.id = #{id} AND LCB.delete_flag = 0 </select> <select id="getPage" resultMap="BaseResultMap"> SELECT LCB.store_id, LCB.user_id, LCB.create_time, LCB.create_by, LCB.update_by, LCB.update_time, LCB.id, lm.username, lm.nick_name, lm.region FROM lmk_customer_black LCB LEFT JOIN li_member lm ON LCB.user_id = lm.id <where> LCB.delete_flag = 0 <!-- 用户名模糊查询 --> <if test="query.username != null and query.username != ''"> AND lm.username LIKE CONCAT('%', #{query.username}, '%') </if> <!-- 昵称模糊查询 --> <if test="query.nickName != null and query.nickName != ''"> AND lm.nick_name LIKE CONCAT('%', #{query.nickName}, '%') </if> <!-- 商铺id --> <if test="query.storeId != null and query.storeId != ''"> AND lm.store_id = #{query.storeId} </if> </where> </select> </mapper> framework/src/main/resources/mapper/lmk/CustomerMapper.xml
@@ -83,25 +83,4 @@ </select> <select id="getById" resultMap="BaseResultMap"> SELECT LCT.tag_name, LCT.create_type, LCT.create_by, LCT.create_time, LCT.update_by, LCT.update_time, LCT.delete_flag, LCT.id FROM lmk_customer_tag LCT WHERE LCT.id = #{id} AND LCT.delete_flag = 0 </select> </mapper> framework/src/main/resources/mapper/lmk/CustomerTagMapper.xml
@@ -41,7 +41,6 @@ LCT.create_time, LCT.update_by, LCT.update_time, LCT.delete_flag, LCT.id FROM lmk_customer_tag LCT framework/src/main/resources/mapper/lmk/CustomerTagRefMapper.xml
@@ -8,7 +8,6 @@ <result column="customer_tag_id" property="customerTagId" /> <result column="create_time" property="createTime" /> <result column="update_time" property="updateTime" /> <result column="delete_flag" property="deleteFlag" /> </resultMap> <select id="getById" resultMap="BaseResultMap"> manager-api/src/main/java/cn/lili/controller/lmk/CustomerBlackController.java
New file @@ -0,0 +1,76 @@ package cn.lili.controller.lmk; import cn.lili.base.Result; import cn.lili.group.Add; import cn.lili.group.Update; import cn.lili.modules.lmk.domain.form.CustomerBlackForm; import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; import cn.lili.modules.lmk.service.CustomerBlackService; import io.swagger.annotations.ApiOperation; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; import lombok.RequiredArgsConstructor; import java.util.List; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotEmpty; import io.swagger.annotations.Api;; import org.springframework.web.bind.annotation.*; /** * 客户黑名单 前端控制器 * * @author zxl * @since 2025-05-15 */ @Validated @RequiredArgsConstructor @Api(value = "客户黑名单", tags = "客户黑名单管理") @RestController @RequestMapping("/manager/customer-black") public class CustomerBlackController { private final CustomerBlackService customerBlackService; @PostMapping @ApiOperation(value = "添加", notes = "添加") public Result add(@RequestBody @Validated(Add.class) CustomerBlackForm form) { return customerBlackService.add(form); } @PutMapping @ApiOperation(value = "修改", notes = "修改") public Result update(@RequestBody @Validated(Update.class) CustomerBlackForm form) { return customerBlackService.update(form); } @DeleteMapping("/{id}") @ApiOperation(value = "ID删除", notes = "ID删除") public Result removeById(@PathVariable("id") String id) { return customerBlackService.removeById(id); } @DeleteMapping("/batch") @ApiOperation(value = "批量删除", notes = "批量删除") public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { return customerBlackService.remove(ids); } @GetMapping("/page") @ApiOperation(value = "分页", notes = "分页") public Result page(CustomerBlackQuery query) { return customerBlackService.page(query); } @GetMapping("/{id}") @ApiOperation(value = "详情", notes = "详情") public Result detail(@PathVariable("id") Integer id) { return customerBlackService.detail(id); } @GetMapping("/list") @ApiOperation(value = "列表", notes = "列表") public Result list() { return customerBlackService.all(); } } manager-api/src/main/java/cn/lili/controller/lmk/CustomerController.java
@@ -39,7 +39,7 @@ } @ApiOperation(value = "会员分页列表") @ApiOperation(value = "客户分页列表") @GetMapping public Result getByPage(CustomerQuery customerQuery) { return customerService.getMemberPage(customerQuery);