Browse Source

商家端新增会员标签增删改查接口业务功能

multiwx
dy-hu 7 months ago
parent
commit
143143eefa
  1. 2
      cereshop-admin/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
  2. 154
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/PlatformLabelController.java
  3. 28
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CerePlatformLabelDAO.java
  4. 26
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelDeleteParam.java
  5. 34
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetAllParam.java
  6. 24
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetByIdParam.java
  7. 152
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelSaveParam.java
  8. 148
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelUpdateParam.java
  9. 26
      cereshop-business/src/main/java/com/shop/cereshop/business/param/label/LabelExcelParam.java
  10. 36
      cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CerePlatformLabelService.java
  11. 218
      cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CerePlatformLabelServiceImpl.java
  12. 130
      cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
  13. 3
      cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/label/CerePlatformLabel.java
  14. 4
      doc/3.0/update.sql

2
cereshop-admin/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml

@ -207,7 +207,7 @@
consumption_money, consumption_day, consumption_start_time, consumption_end_time,
frequency_start, frequency_end, money_start, money_end,IF(b.users IS NULL,0,b.users) users FROM cere_platform_label a
LEFT JOIN (SELECT buyer_label_id,COUNT(buyer_user_id) users from cere_buyer_label GROUP BY buyer_label_id) b ON a.buyer_label_id=b.buyer_label_id
where 1=1
where a.business_id = 0
<if test="labelName!=null and labelName!=''">
and a.label_name like concat('%',#{labelName},'%')
</if>

154
cereshop-business/src/main/java/com/shop/cereshop/business/controller/PlatformLabelController.java

@ -0,0 +1,154 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.controller;
import com.shop.cereshop.business.annotation.NoRepeatSubmit;
import com.shop.cereshop.business.annotation.NoRepeatWebLog;
import com.shop.cereshop.business.param.label.*;
import com.shop.cereshop.business.service.label.CerePlatformLabelService;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.label.PlatformLabel;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.poi.ExcelUtils;
import com.shop.cereshop.commons.result.Result;
import com.shop.cereshop.commons.utils.GsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 标签管理
*/
@RestController
@RequestMapping("label")
/**
* 注解方式生成日志对象指定topic生成对象类名
*/
@Slf4j(topic = "PlatformLabelController")
@Api(value = "标签管理", tags = "标签管理")
public class PlatformLabelController {
@Autowired
private CerePlatformLabelService cerePlatformLabelService;
/**
* 标签管理查询
* @param param
* @return
*/
@PostMapping(value = "getAll")
@ApiOperation(value = "标签管理查询")
public Result<Page<PlatformLabel>> getAll(@RequestBody BusinessBuyerLabelGetAllParam param, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
param.setBusinessId(user.getBusinessId());
Page page=cerePlatformLabelService.getAll(param);
return new Result(page);
}
/**
* 标签编辑查询
* @param param
* @return
*/
@PostMapping(value = "getById")
@ApiOperation(value = "标签编辑查询")
public Result<PlatformLabel> getById(@RequestBody BusinessBuyerLabelGetByIdParam param) throws CoBusinessException{
PlatformLabel label=cerePlatformLabelService.getById(param.getBuyerLabelId());
return new Result(label);
}
/**
* 添加标签
* @param param
* @return
*/
@PostMapping(value = "save")
@NoRepeatSubmit
@ApiOperation(value = "添加标签")
@NoRepeatWebLog
public Result save(@RequestBody @Validated BusinessBuyerLabelSaveParam param, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
param.setBusinessId(user.getBusinessId());
cerePlatformLabelService.save(param,user);
return new Result(user.getUsername(),"添加标签", GsonUtil.objectToGson(param));
}
/**
* 修改标签
* @param label
* @return
*/
@PostMapping(value = "update")
@NoRepeatSubmit
@ApiOperation(value = "修改标签")
@NoRepeatWebLog
public Result update(@RequestBody BusinessBuyerLabelUpdateParam label, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
label.setBusinessId(user.getBusinessId());
cerePlatformLabelService.update(label,user);
return new Result(user.getUsername(),"修改标签", GsonUtil.objectToGson(label));
}
/**
* 删除标签
* @param param
* @return
*/
@PostMapping(value = "delete")
@NoRepeatSubmit
@ApiOperation(value = "删除标签")
@NoRepeatWebLog
public Result delete(@RequestBody BusinessBuyerLabelDeleteParam param, HttpServletRequest request) throws CoBusinessException{
//获取当前登录账户
CerePlatformBusinessUser user = (CerePlatformBusinessUser) request.getAttribute("user");
cerePlatformLabelService.delete(param,user);
return new Result(user.getUsername(),"删除标签", GsonUtil.objectToGson(param));
}
/**
* 标签导出
* @param param
* @param response
*/
@PostMapping(value = "excel_platform_label")
@ApiOperation(value = "标签导出")
public void excelLabel(@RequestBody LabelExcelParam param, HttpServletResponse response) throws CoBusinessException,Exception{
List<PlatformLabel> list=cerePlatformLabelService.findExcel(param);
List<String> titles=new ArrayList<>();
titles.add("标签名");
titles.add("客户");
titles.add("标签类型");
titles.add("达标条件");
XSSFWorkbook excel = ExcelUtils.createPlatformLabelExcel(titles, list);
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String str = "订单管理表"+sdf.format(date);
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-disposition", "attachment;filename=" + str +".xls");// 默认Excel名称
response.flushBuffer();
excel.write(response.getOutputStream());
excel.close();
}
}

28
cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CerePlatformLabelDAO.java

@ -5,9 +5,15 @@
*/
package com.shop.cereshop.business.dao.label;
import com.shop.cereshop.business.param.label.BusinessBuyerLabelGetAllParam;
import com.shop.cereshop.business.param.label.BusinessBuyerLabelUpdateParam;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shop.cereshop.commons.domain.label.PlatformLabel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface CerePlatformLabelDAO extends BaseMapper<CerePlatformLabel> {
@ -17,7 +23,27 @@ public interface CerePlatformLabelDAO extends BaseMapper<CerePlatformLabel> {
CerePlatformLabel selectByPrimaryKey(Long buyerLabelId);
int updateByPrimaryKeySelective(CerePlatformLabel record);
int updateByPrimaryKeySelective(BusinessBuyerLabelUpdateParam record);
int updateByPrimaryKey(CerePlatformLabel record);
List<PlatformLabel> getAll(BusinessBuyerLabelGetAllParam param);
PlatformLabel getById(@Param("buyerLabelId") Long buyerLabelId);
void deleteByIds(@Param("ids") List<Long> ids);
List<CerePlatformLabel> findAll();
List<Long> findAllByDay(@Param("consumptionDay") Integer consumptionDay);
List<Long> findRangeDayBuyers(CerePlatformLabel label);
List<Long> findFrequencyBuyes(CerePlatformLabel label);
List<Long> findMoneyBuyers(CerePlatformLabel label);
List<Long> findAllBuyers(CerePlatformLabel label);
List<PlatformLabel> getAllByIds(@Param("ids") List<Long> ids);
}

26
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelDeleteParam.java

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 删除标签请求
*/
@Data
@ApiModel(value = "LabelDeleteParam", description = "删除标签请求")
public class BusinessBuyerLabelDeleteParam {
/**
* 客户标签id数组
*/
@ApiModelProperty(value = "客户标签id数组")
private List<Long> ids;
}

34
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetAllParam.java

@ -0,0 +1,34 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import com.shop.cereshop.commons.domain.common.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取标签列表请求
*/
@Data
@ApiModel(value = "LabelGetAllParam", description = "获取标签列表请求")
public class BusinessBuyerLabelGetAllParam extends PageParam {
/**
* 标签名称
*/
@ApiModelProperty(value = "标签名称")
private String labelName;
/**
* 标签类型 1-手动标签 2-自动标签
*/
@ApiModelProperty(value = "标签类型 1-手动标签 2-自动标签")
private Integer labelType;
@ApiModelProperty(value = "商家id")
private Long businessId;
}

24
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetByIdParam.java

@ -0,0 +1,24 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 获取标签详情
*/
@Data
@ApiModel(value = "LabelGetByIdParam", description = "获取标签详情")
public class BusinessBuyerLabelGetByIdParam {
/**
* 客户标签id
*/
@ApiModelProperty(value = "客户标签id")
private Long buyerLabelId;
}

152
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelSaveParam.java

@ -0,0 +1,152 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.List;
/**
* 添加标签请求
*/
@Data
@ApiModel(value = "LabelSaveParam", description = "添加标签请求")
public class BusinessBuyerLabelSaveParam {
/**
* 客户标签id
*/
@ApiModelProperty(value = "客户标签id")
@TableId(type = IdType.AUTO)
private Long buyerLabelId;
@ApiModelProperty(value = "客户标签所属商家id")
private Long businessId;
/**
* 标签名称
*/
@ApiModelProperty(value = "标签名称")
@NotBlank(message = "标签名称不能为空")
private String labelName;
/**
* 标签类型 1-手动标签 2-自动标签
*/
@ApiModelProperty(value = "标签类型 1-手动标签 2-自动标签")
private Integer labelType;
/**
* 满足条件 1-满足任意一个被选中条件即可 2-必须满足所有被选中条件
*/
@ApiModelProperty(value = "满足条件 1-满足任意一个被选中条件即可 2-必须满足所有被选中条件")
private Integer meetConditions;
/**
* 选中条件数组
*/
@ApiModelProperty(value = "选中条件数组")
private List<Integer> conditions;
public void setConditions(List<Integer> conditions) {
if(!EmptyUtils.isEmpty(conditions)){
if(conditions.contains(1)){
this.lastConsumptionTime=1;
}else {
this.lastConsumptionTime=0;
}
if(conditions.contains(2)){
this.consumptionFrequency=1;
}else {
this.consumptionFrequency=0;
}
if(conditions.contains(3)){
this.consumptionMoney=1;
}else {
this.consumptionMoney=0;
}
}
}
/**
* 是否选中最后消费时间 1- 0-
*/
@ApiModelProperty(value = "是否选中最后消费时间 1-是 0-否")
private Integer lastConsumptionTime;
/**
* 是否选中累计消费次数 1- 0-
*/
@ApiModelProperty(value = "是否选中累计消费次数 1-是 0-否")
private Integer consumptionFrequency;
/**
* 是否选中累计交易金额 1- 0-
*/
@ApiModelProperty(value = "是否选中累计交易金额 1-是 0-否")
private Integer consumptionMoney;
/**
* 最近几天
*/
@ApiModelProperty(value = "最近几天(天)")
private Integer consumptionDay;
/**
* 最后消费开始时间
*/
@ApiModelProperty(value = "最后消费开始时间")
private String consumptionStartTime;
/**
* 最后消费结束时间
*/
@ApiModelProperty(value = "最后消费结束时间")
private String consumptionEndTime;
/**
* 起始次数
*/
@ApiModelProperty(value = "起始次数")
private Integer frequencyStart;
/**
* 截止次数
*/
@ApiModelProperty(value = "截止次数")
private Integer frequencyEnd;
/**
* 起始金额
*/
@ApiModelProperty(value = "起始金额")
private BigDecimal moneyStart;
/**
* 截止金额
*/
@ApiModelProperty(value = "截止金额")
private BigDecimal moneyEnd;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String updateTime;
}

148
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelUpdateParam.java

@ -0,0 +1,148 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import com.shop.cereshop.commons.utils.EmptyUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 更新标签请求
*/
@Data
@ApiModel(value = "LabelUpdateParam", description = "更新标签请求")
public class BusinessBuyerLabelUpdateParam {
/**
* 客户标签id
*/
@ApiModelProperty(value = "客户标签id")
private Long buyerLabelId;
@ApiModelProperty(value = "客户标签所属商家id")
private Long businessId;
/**
* 标签名称
*/
@ApiModelProperty(value = "标签名称")
private String labelName;
/**
* 标签类型 1-手动标签 2-自动标签
*/
@ApiModelProperty(value = "标签类型 1-手动标签 2-自动标签")
private Integer labelType;
/**
* 满足条件 1-满足任意一个被选中条件即可 2-必须满足所有被选中条件
*/
@ApiModelProperty(value = "满足条件 1-满足任意一个被选中条件即可 2-必须满足所有被选中条件")
private Integer meetConditions;
/**
* 选中条件数组
*/
@ApiModelProperty(value = "选中条件数组")
private List<Integer> conditions;
public void setConditions(List<Integer> conditions) {
if(!EmptyUtils.isEmpty(conditions)){
if(conditions.contains(1)){
this.lastConsumptionTime=1;
}else {
this.lastConsumptionTime=0;
}
if(conditions.contains(2)){
this.consumptionFrequency=1;
}else {
this.consumptionFrequency=0;
}
if(conditions.contains(3)){
this.consumptionMoney=1;
}else {
this.consumptionMoney=0;
}
}
}
/**
* 是否选中最后消费时间 1- 0-
*/
@ApiModelProperty(value = "是否选中最后消费时间 1-是 0-否")
private Integer lastConsumptionTime;
/**
* 是否选中累计消费次数 1- 0-
*/
@ApiModelProperty(value = "是否选中累计消费次数 1-是 0-否")
private Integer consumptionFrequency;
/**
* 是否选中累计交易金额 1- 0-
*/
@ApiModelProperty(value = "是否选中累计交易金额 1-是 0-否")
private Integer consumptionMoney;
/**
* 最近几天
*/
@ApiModelProperty(value = "最近几天(天)")
private Integer consumptionDay;
/**
* 最后消费开始时间
*/
@ApiModelProperty(value = "最后消费开始时间")
private String consumptionStartTime;
/**
* 最后消费结束时间
*/
@ApiModelProperty(value = "最后消费结束时间")
private String consumptionEndTime;
/**
* 起始次数
*/
@ApiModelProperty(value = "起始次数")
private Integer frequencyStart;
/**
* 截止次数
*/
@ApiModelProperty(value = "截止次数")
private Integer frequencyEnd;
/**
* 起始金额
*/
@ApiModelProperty(value = "起始金额")
private BigDecimal moneyStart;
/**
* 截止金额
*/
@ApiModelProperty(value = "截止金额")
private BigDecimal moneyEnd;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String updateTime;
}

26
cereshop-business/src/main/java/com/shop/cereshop/business/param/label/LabelExcelParam.java

@ -0,0 +1,26 @@
/*
* Copyright (C) 2017-2021
* All rights reserved, Designed By 深圳中科鑫智科技有限公司
* Copyright authorization contact 18814114118
*/
package com.shop.cereshop.business.param.label;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 导出标签请求
*/
@Data
@ApiModel(value = "LabelExcelParam", description = "导出标签请求")
public class LabelExcelParam {
/**
* 标签id数组
*/
@ApiModelProperty(value = "标签id数组")
private List<Long> ids;
}

36
cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CerePlatformLabelService.java

@ -5,5 +5,41 @@
*/
package com.shop.cereshop.business.service.label;
import com.shop.cereshop.business.param.label.*;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.shop.cereshop.commons.domain.label.PlatformLabel;
import com.shop.cereshop.commons.domain.user.CerePlatformUser;
import com.shop.cereshop.commons.exception.CoBusinessException;
import java.util.List;
public interface CerePlatformLabelService {
Page getAll(BusinessBuyerLabelGetAllParam param) throws CoBusinessException;
PlatformLabel getById(Long buyerLabelId) throws CoBusinessException;
void save(BusinessBuyerLabelSaveParam label, CerePlatformBusinessUser user) throws CoBusinessException;
void update(BusinessBuyerLabelUpdateParam label, CerePlatformBusinessUser user) throws CoBusinessException;
void delete(BusinessBuyerLabelDeleteParam param, CerePlatformBusinessUser user) throws CoBusinessException;
List<PlatformLabel> findExcel(LabelExcelParam param) throws CoBusinessException;
List<CerePlatformLabel> findAll();
List<Long> findAllByDay(Integer consumptionDay);
List<Long> findRangeDayBuyers(CerePlatformLabel label);
List<Long> findFrequencyBuyes(CerePlatformLabel label);
List<Long> findMoneyBuyers(CerePlatformLabel label);
void insertBatchBuyerLabel(List<CereBuyerLabel> collect);
List<Long> findAllBuyers(CerePlatformLabel label);
}

218
cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CerePlatformLabelServiceImpl.java

@ -5,9 +5,227 @@
*/
package com.shop.cereshop.business.service.label.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.business.dao.label.CerePlatformLabelDAO;
import com.shop.cereshop.business.param.label.*;
import com.shop.cereshop.business.service.label.CereBuyerLabelService;
import com.shop.cereshop.business.service.label.CerePlatformLabelService;
import com.shop.cereshop.business.service.log.CerePlatformLogService;
import com.shop.cereshop.commons.constant.IntegerEnum;
import com.shop.cereshop.commons.domain.business.CerePlatformBusinessUser;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.label.CereBuyerLabel;
import com.shop.cereshop.commons.domain.label.CerePlatformLabel;
import com.shop.cereshop.commons.domain.label.PlatformLabel;
import com.shop.cereshop.commons.exception.CoBusinessException;
import com.shop.cereshop.commons.utils.EmptyUtils;
import com.shop.cereshop.commons.utils.TimeUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CerePlatformLabelServiceImpl implements CerePlatformLabelService {
@Autowired
private CerePlatformLabelDAO cerePlatformLabelDAO;
@Autowired
private CereBuyerLabelService cereBuyerLabelService;
@Autowired
private CerePlatformLogService cerePlatformLogService;
@Override
public Page getAll(BusinessBuyerLabelGetAllParam param) throws CoBusinessException {
PageHelper.startPage(param.getPage(),param.getPageSize());
List<PlatformLabel> list= cerePlatformLabelDAO.getAll(param);
if(!EmptyUtils.isEmpty(list)){
list.stream()
//过滤标签类型为手动标签的
.filter(platformLabel -> !platformLabel.getLabelType().equals("1"))
//设置条件描述
.peek(platformLabel -> {
List<String> conditions=new ArrayList<>();
if(IntegerEnum.YES.getCode().equals(platformLabel.getLastConsumptionTime())){
//如果选中最后消费时间
if(!EmptyUtils.isEmpty(platformLabel.getConsumptionDay())){
//如果选择的最近几天
conditions.add("最后消费时间在"+platformLabel.getConsumptionDay()+"天内");
}else {
//如果选择的最后消费时间段
conditions.add("最后消费时间在"+platformLabel.getConsumptionStartTime()+"到"+platformLabel.getConsumptionEndTime()+"范围内");
}
}
if(IntegerEnum.YES.getCode().equals(platformLabel.getConsumptionFrequency())){
//如果选中累计消费次数
if(!EmptyUtils.isEmpty(platformLabel.getFrequencyEnd())){
//如果有截止次数
conditions.add("累计消费次数在"+platformLabel.getFrequencyStart()+"-"+platformLabel.getFrequencyEnd()+"次");
}else {
conditions.add("累计消费次数在"+platformLabel.getFrequencyStart()+"次以上");
}
}
if(IntegerEnum.YES.getCode().equals(platformLabel.getConsumptionMoney())){
if(!EmptyUtils.isEmpty(platformLabel.getMoneyEnd())){
//如果有截止金额
conditions.add("累计消费金额在"+platformLabel.getMoneyStart()+"-"+platformLabel.getMoneyEnd()+"元");
}else {
conditions.add("累计消费金额在"+platformLabel.getMoneyStart()+"元以上");
}
}
platformLabel.setConditions(conditions);
})
.collect(Collectors.toList());
}
PageInfo<PlatformLabel> pageInfo=new PageInfo<>(list);
Page page=new Page(pageInfo.getList(),pageInfo.getTotal());
return page;
}
@Override
public PlatformLabel getById(Long buyerLabelId) throws CoBusinessException {
PlatformLabel label = cerePlatformLabelDAO.getById(buyerLabelId);
//设置条件
if(label!=null){
List<Integer> consumptions=new ArrayList<>();
if(IntegerEnum.YES.getCode().equals(label.getLastConsumptionTime())){
consumptions.add(1);
}
if(IntegerEnum.YES.getCode().equals(label.getConsumptionFrequency())){
consumptions.add(2);
}
if(IntegerEnum.YES.getCode().equals(label.getConsumptionMoney())){
consumptions.add(3);
}
label.setConsumptions(consumptions);
}
return label;
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void save(BusinessBuyerLabelSaveParam label, CerePlatformBusinessUser user) throws CoBusinessException {
String time= TimeUtils.yyMMddHHmmss();
label.setCreateTime(time);
CerePlatformLabel platformLabel = new CerePlatformLabel();
BeanUtils.copyProperties(label, platformLabel);
cerePlatformLabelDAO.insert(platformLabel);
//新增日志
cerePlatformLogService.addLog(user,"客户标签管理","商家端操作","添加客户标签",label.getBuyerLabelId(),time);
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void update(BusinessBuyerLabelUpdateParam label, CerePlatformBusinessUser user) throws CoBusinessException {
String time= TimeUtils.yyMMddHHmmss();
label.setUpdateTime(time);
cerePlatformLabelDAO.updateByPrimaryKeySelective(label);
//新增日志
cerePlatformLogService.addLog(user,"客户标签管理","商家端操作","修改客户标签",label.getBuyerLabelId(),time);
}
@Override
@Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class})
public void delete(BusinessBuyerLabelDeleteParam param, CerePlatformBusinessUser user) throws CoBusinessException {
String time=TimeUtils.yyMMddHHmmss();
if(!EmptyUtils.isEmpty(param.getIds())){
//删除标签数据
cerePlatformLabelDAO.deleteByIds(param.getIds());
//删除标签绑定客户数据
cereBuyerLabelService.deleteLabelUser(param.getIds());
//新增日志
cerePlatformLogService.addLog(user,"客户标签管理","商家端操作","删除客户标签",null,time);
}
}
@Override
public List<PlatformLabel> findExcel(LabelExcelParam param) throws CoBusinessException {
if(!EmptyUtils.isEmpty(param.getIds())){
List<PlatformLabel> list= cerePlatformLabelDAO.getAllByIds(param.getIds());
if(!EmptyUtils.isEmpty(list)){
list.stream()
//过滤标签类型为手动标签的
.filter(platformLabel -> !platformLabel.getLabelType().equals("1"))
//设置条件描述
.peek(platformLabel -> {
List<String> conditions=new ArrayList<>();
if(IntegerEnum.YES.getCode().equals(platformLabel.getLastConsumptionTime())){
//如果选中最后消费时间
if(!EmptyUtils.isEmpty(platformLabel.getConsumptionDay())){
//如果选择的最近几天
conditions.add("最后消费时间在"+platformLabel.getConsumptionDay()+"天内");
}else {
//如果选择的最后消费时间段
conditions.add("最后消费时间在"+platformLabel.getConsumptionStartTime()+"到"+platformLabel.getConsumptionEndTime()+"范围内");
}
}
if(IntegerEnum.YES.getCode().equals(platformLabel.getConsumptionFrequency())){
//如果选中累计消费次数
if(!EmptyUtils.isEmpty(platformLabel.getFrequencyEnd())){
//如果有截止次数
conditions.add("累计消费次数在"+platformLabel.getFrequencyStart()+"-"+platformLabel.getFrequencyEnd()+"次");
}else {
conditions.add("累计消费次数在"+platformLabel.getFrequencyStart()+"次以上");
}
}
if(IntegerEnum.YES.getCode().equals(platformLabel.getConsumptionMoney())){
if(!EmptyUtils.isEmpty(platformLabel.getMoneyEnd())){
//如果有截止金额
conditions.add("累计消费金额在"+platformLabel.getFrequencyStart()+"-"+platformLabel.getFrequencyEnd()+"元");
}else {
conditions.add("累计消费金额在"+platformLabel.getMoneyStart()+"元以上");
}
}
platformLabel.setConditions(conditions);
})
.collect(Collectors.toList());
return list;
}
}
return null;
}
@Override
public List<CerePlatformLabel> findAll() {
return cerePlatformLabelDAO.findAll();
}
@Override
public List<Long> findAllByDay(Integer consumptionDay) {
return cerePlatformLabelDAO.findAllByDay(consumptionDay);
}
@Override
public List<Long> findRangeDayBuyers(CerePlatformLabel label) {
return cerePlatformLabelDAO.findRangeDayBuyers(label);
}
@Override
public List<Long> findFrequencyBuyes(CerePlatformLabel label) {
return cerePlatformLabelDAO.findFrequencyBuyes(label);
}
@Override
public List<Long> findMoneyBuyers(CerePlatformLabel label) {
return cerePlatformLabelDAO.findMoneyBuyers(label);
}
@Override
public void insertBatchBuyerLabel(List<CereBuyerLabel> collect) {
cereBuyerLabelService.insertBatch(collect);
}
@Override
public List<Long> findAllBuyers(CerePlatformLabel label) {
return cerePlatformLabelDAO.findAllBuyers(label);
}
}

130
cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml

@ -131,26 +131,51 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.commons.domain.label.CerePlatformLabel">
<update id="updateByPrimaryKeySelective" parameterType="com.shop.cereshop.business.param.label.BusinessBuyerLabelUpdateParam">
update cere_platform_label
<set>
<if test="businessId != null">
business_id = #{businessId,jdbcType=BIGINT},
</if>
<if test="labelName != null and labelName!=''">
label_name = #{labelName,jdbcType=VARCHAR},
</if>
<if test="labelType != null">
label_type = #{labelType,jdbcType=BIT},
</if>
<if test="meetConditions != null">
meet_conditions = #{meetConditions,jdbcType=BIT},
</if>
<if test="lastConsumptionTime != null">
last_consumption_time = #{lastConsumptionTime,jdbcType=BIT},
</if>
<if test="consumptionFrequency != null">
consumption_frequency = #{consumptionFrequency,jdbcType=BIT},
</if>
<if test="consumptionMoney != null">
consumption_money = #{consumptionMoney,jdbcType=BIT},
</if>
<if test="consumptionDay != null">
consumption_day = #{consumptionDay,jdbcType=INTEGER},
</if>
<if test="consumptionStartTime != null and consumptionStartTime!=''">
consumption_start_time = #{consumptionStartTime,jdbcType=VARCHAR},
</if>
<if test="consumptionEndTime != null and consumptionEndTime!=''">
consumption_end_time = #{consumptionEndTime,jdbcType=VARCHAR},
</if>
<if test="frequencyStart != null">
frequency_start = #{frequencyStart,jdbcType=INTEGER},
</if>
<if test="frequencyEnd != null">
frequency_end = #{frequencyEnd,jdbcType=INTEGER},
</if>
<if test="moneyStart != null">
money_start = #{moneyStart,jdbcType=DECIMAL},
</if>
<if test="moneyEnd != null">
money_end = #{moneyEnd,jdbcType=DECIMAL},
</if>
<if test="createTime != null and createTime!=''">
create_time = #{createTime,jdbcType=VARCHAR},
</if>
@ -179,4 +204,107 @@
update_time = #{updateTime,jdbcType=VARCHAR}
where buyer_label_id = #{buyerLabelId,jdbcType=BIGINT}
</update>
<select id="getAll" parameterType="com.shop.cereshop.business.param.label.BusinessBuyerLabelGetAllParam" resultType="com.shop.cereshop.commons.domain.label.PlatformLabel">
SELECT a.buyer_label_id, label_name, label_type, meet_conditions, last_consumption_time, consumption_frequency,
consumption_money, consumption_day, consumption_start_time, consumption_end_time,
frequency_start, frequency_end, money_start, money_end,IF(b.users IS NULL,0,b.users) users FROM cere_platform_label a
LEFT JOIN (SELECT buyer_label_id,COUNT(buyer_user_id) users from cere_buyer_label GROUP BY buyer_label_id) b ON a.buyer_label_id=b.buyer_label_id
where a.business_id = #{businessId}
<if test="labelName!=null and labelName!=''">
and a.label_name like concat('%',#{labelName},'%')
</if>
<if test="labelType!=null">
and a.label_type=#{labelType}
</if>
ORDER BY a.update_time DESC,a.create_time DESC
</select>
<select id="getAllByIds" parameterType="java.util.List" resultType="com.shop.cereshop.commons.domain.label.PlatformLabel">
SELECT a.buyer_label_id, label_name, label_type, meet_conditions, last_consumption_time, consumption_frequency,
consumption_money, consumption_day, consumption_start_time, consumption_end_time,
frequency_start, frequency_end, money_start, money_end,IF(b.users IS NULL,0,b.users) users FROM cere_platform_label a
LEFT JOIN (SELECT buyer_label_id,COUNT(buyer_user_id) users from cere_buyer_label GROUP BY buyer_label_id) b ON a.buyer_label_id=b.buyer_label_id
where a.buyer_label_id in (
<foreach collection="ids" item="id" index="index" separator=",">
#{id}
</foreach>
)
</select>
<select id="getById" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.label.PlatformLabel">
SELECT buyer_label_id, label_name, label_type, meet_conditions, last_consumption_time, consumption_frequency,
consumption_money, consumption_day, consumption_start_time, consumption_end_time,
frequency_start, frequency_end, money_start, money_end FROM cere_platform_label
where buyer_label_id=#{buyerLabelId}
</select>
<delete id="deleteByIds" parameterType="java.util.List">
DELETE FROM cere_platform_label where buyer_label_id in (
<foreach collection="ids" item="id" index="index" separator=",">
#{id}
</foreach>
)
</delete>
<select id="findAll" resultType="com.shop.cereshop.commons.domain.label.CerePlatformLabel">
SELECT buyer_label_id, label_name, label_type, meet_conditions, last_consumption_time, consumption_frequency,
consumption_money, consumption_day, consumption_start_time, consumption_end_time,
frequency_start, frequency_end, money_start, money_end FROM cere_platform_label
</select>
<select id="findAllByDay" parameterType="java.lang.Object" resultType="java.lang.Long">
SELECT buyer_user_id FROM cere_shop_order
where DATE_SUB(CURDATE(),INTERVAL #{consumptionDay} DAY)&lt;=create_time
GROUP BY buyer_user_id
</select>
<select id="findRangeDayBuyers" parameterType="com.shop.cereshop.commons.domain.label.CerePlatformLabel" resultType="java.lang.Long">
SELECT buyer_user_id FROM cere_shop_order
where create_time&gt;=#{consumptionStartTime} and create_time&lt;=#{consumptionEndTime}
GROUP BY buyer_user_id
</select>
<select id="findFrequencyBuyes" parameterType="com.shop.cereshop.commons.domain.label.CerePlatformLabel" resultType="java.lang.Long">
SELECT buyer_user_id FROM cere_shop_order
GROUP BY buyer_user_id
HAVING COUNT(buyer_user_id)&gt;=#{frequencyStart}
<if test="frequencyEnd!=null">
and COUNT(buyer_user_id)&lt;=#{frequencyEnd}
</if>
</select>
<select id="findMoneyBuyers" parameterType="com.shop.cereshop.commons.domain.label.CerePlatformLabel" resultType="java.lang.Long">
SELECT buyer_user_id FROM cere_shop_order
where SUM(price)&gt;=#{moneyStart}
<if test="frequencyEnd!=null">
and SUM(price)&lt;=#{moneyEnd}
</if>
GROUP BY buyer_user_id
</select>
<select id="findAllBuyers" parameterType="com.shop.cereshop.commons.domain.label.CerePlatformLabel" resultType="java.lang.Long">
SELECT buyer_user_id FROM cere_shop_order
where 1=1
<if test="consumptionDay!=null">
and create_time&gt;=#{consumptionStartTime} and create_time&lt;=#{consumptionEndTime}
</if>
<if test="consumptionStartTime!=null and consumptionStartTime!=''">
and create_time&gt;=#{consumptionStartTime} and create_time&lt;=#{consumptionEndTime}
</if>
<if test="moneyStart!=null">
and SUM(price)&gt;=#{moneyStart}
</if>
<if test="moneyEnd!=null">
and SUM(price)&lt;=#{moneyEnd}
</if>
GROUP BY buyer_user_id
HAVING 1=1
<if test="frequencyStart!=null">
and COUNT(buyer_user_id)&gt;=#{frequencyStart}
</if>
<if test="frequencyEnd!=null">
and COUNT(buyer_user_id)&lt;=#{frequencyEnd}
</if>
</select>
</mapper>

3
cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/label/CerePlatformLabel.java

@ -29,6 +29,9 @@ public class CerePlatformLabel implements Serializable {
@TableId(type = IdType.AUTO)
private Long buyerLabelId;
@ApiModelProperty(value = "商家id")
private Long businessId;
/**
* 标签名称
*/

4
doc/3.0/update.sql

@ -291,3 +291,7 @@ ALTER TABLE cere_platform_business ADD pc_domain varchar(128) DEFAULT '' COMMENT
ALTER TABLE cere_platform_business ADD mobile_domain varchar(128) DEFAULT '' COMMENT '移动端商城域名';
ALTER TABLE cere_shop_product ADD plat_shelve_state tinyint(1) DEFAULT 0 COMMENT '平台上架商品状态 0-已下架 1-已上架 2-待审核 3-审核失败';
-- 会员标签表增加商家表关联Id
ALTER TABLE `cere_platform_label`
ADD COLUMN `business_id` bigint(20) DEFAULT 0 COMMENT '商家Id';
Loading…
Cancel
Save