diff --git a/cereshop-admin/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml b/cereshop-admin/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
index 356e221..25fe862 100644
--- a/cereshop-admin/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
+++ b/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
and a.label_name like concat('%',#{labelName},'%')
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/controller/PlatformLabelController.java b/cereshop-business/src/main/java/com/shop/cereshop/business/controller/PlatformLabelController.java
new file mode 100644
index 0000000..063d0a4
--- /dev/null
+++ b/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> 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 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 list=cerePlatformLabelService.findExcel(param);
+ List 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();
+ }
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CerePlatformLabelDAO.java b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CerePlatformLabelDAO.java
index ec39120..83d3d8e 100644
--- a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/label/CerePlatformLabelDAO.java
+++ b/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 {
@@ -17,7 +23,27 @@ public interface CerePlatformLabelDAO extends BaseMapper {
CerePlatformLabel selectByPrimaryKey(Long buyerLabelId);
- int updateByPrimaryKeySelective(CerePlatformLabel record);
+ int updateByPrimaryKeySelective(BusinessBuyerLabelUpdateParam record);
int updateByPrimaryKey(CerePlatformLabel record);
+
+ List getAll(BusinessBuyerLabelGetAllParam param);
+
+ PlatformLabel getById(@Param("buyerLabelId") Long buyerLabelId);
+
+ void deleteByIds(@Param("ids") List ids);
+
+ List findAll();
+
+ List findAllByDay(@Param("consumptionDay") Integer consumptionDay);
+
+ List findRangeDayBuyers(CerePlatformLabel label);
+
+ List findFrequencyBuyes(CerePlatformLabel label);
+
+ List findMoneyBuyers(CerePlatformLabel label);
+
+ List findAllBuyers(CerePlatformLabel label);
+
+ List getAllByIds(@Param("ids") List ids);
}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelDeleteParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelDeleteParam.java
new file mode 100644
index 0000000..440631c
--- /dev/null
+++ b/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 ids;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetAllParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetAllParam.java
new file mode 100644
index 0000000..e9918e8
--- /dev/null
+++ b/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;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetByIdParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelGetByIdParam.java
new file mode 100644
index 0000000..d92e48e
--- /dev/null
+++ b/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;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelSaveParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelSaveParam.java
new file mode 100644
index 0000000..d05827f
--- /dev/null
+++ b/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 conditions;
+
+ public void setConditions(List 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;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelUpdateParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/BusinessBuyerLabelUpdateParam.java
new file mode 100644
index 0000000..63a7dc9
--- /dev/null
+++ b/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 conditions;
+
+ public void setConditions(List 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;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/LabelExcelParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/label/LabelExcelParam.java
new file mode 100644
index 0000000..69dd68e
--- /dev/null
+++ b/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 ids;
+}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CerePlatformLabelService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CerePlatformLabelService.java
index 6830d2c..70bf055 100644
--- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/CerePlatformLabelService.java
+++ b/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 findExcel(LabelExcelParam param) throws CoBusinessException;
+
+ List findAll();
+
+ List findAllByDay(Integer consumptionDay);
+
+ List findRangeDayBuyers(CerePlatformLabel label);
+
+ List findFrequencyBuyes(CerePlatformLabel label);
+
+ List findMoneyBuyers(CerePlatformLabel label);
+
+ void insertBatchBuyerLabel(List collect);
+
+ List findAllBuyers(CerePlatformLabel label);
}
diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CerePlatformLabelServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CerePlatformLabelServiceImpl.java
index 09221e2..a08ad22 100644
--- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/label/impl/CerePlatformLabelServiceImpl.java
+++ b/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 list= cerePlatformLabelDAO.getAll(param);
+ if(!EmptyUtils.isEmpty(list)){
+ list.stream()
+ //过滤标签类型为手动标签的
+ .filter(platformLabel -> !platformLabel.getLabelType().equals("1"))
+ //设置条件描述
+ .peek(platformLabel -> {
+ List 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 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 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 findExcel(LabelExcelParam param) throws CoBusinessException {
+ if(!EmptyUtils.isEmpty(param.getIds())){
+ List list= cerePlatformLabelDAO.getAllByIds(param.getIds());
+ if(!EmptyUtils.isEmpty(list)){
+ list.stream()
+ //过滤标签类型为手动标签的
+ .filter(platformLabel -> !platformLabel.getLabelType().equals("1"))
+ //设置条件描述
+ .peek(platformLabel -> {
+ List 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 findAll() {
+ return cerePlatformLabelDAO.findAll();
+ }
+
+ @Override
+ public List findAllByDay(Integer consumptionDay) {
+ return cerePlatformLabelDAO.findAllByDay(consumptionDay);
+ }
+
+ @Override
+ public List findRangeDayBuyers(CerePlatformLabel label) {
+ return cerePlatformLabelDAO.findRangeDayBuyers(label);
+ }
+
+ @Override
+ public List findFrequencyBuyes(CerePlatformLabel label) {
+ return cerePlatformLabelDAO.findFrequencyBuyes(label);
+ }
+
+ @Override
+ public List findMoneyBuyers(CerePlatformLabel label) {
+ return cerePlatformLabelDAO.findMoneyBuyers(label);
+ }
+
+ @Override
+ public void insertBatchBuyerLabel(List collect) {
+ cereBuyerLabelService.insertBatch(collect);
+ }
+
+ @Override
+ public List findAllBuyers(CerePlatformLabel label) {
+ return cerePlatformLabelDAO.findAllBuyers(label);
+ }
}
diff --git a/cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
index 18a4e6b..70dde87 100644
--- a/cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
+++ b/cereshop-business/src/main/resources/mybatis/mapper/label/CerePlatformLabelDAO.xml
@@ -131,26 +131,51 @@
-
+
update cere_platform_label
+
+ business_id = #{businessId,jdbcType=BIGINT},
+
label_name = #{labelName,jdbcType=VARCHAR},
label_type = #{labelType,jdbcType=BIT},
+
meet_conditions = #{meetConditions,jdbcType=BIT},
+
+
last_consumption_time = #{lastConsumptionTime,jdbcType=BIT},
+
+
consumption_frequency = #{consumptionFrequency,jdbcType=BIT},
+
+
consumption_money = #{consumptionMoney,jdbcType=BIT},
+
+
consumption_day = #{consumptionDay,jdbcType=INTEGER},
+
+
consumption_start_time = #{consumptionStartTime,jdbcType=VARCHAR},
+
+
consumption_end_time = #{consumptionEndTime,jdbcType=VARCHAR},
+
+
frequency_start = #{frequencyStart,jdbcType=INTEGER},
+
+
frequency_end = #{frequencyEnd,jdbcType=INTEGER},
+
+
money_start = #{moneyStart,jdbcType=DECIMAL},
+
+
money_end = #{moneyEnd,jdbcType=DECIMAL},
+
create_time = #{createTime,jdbcType=VARCHAR},
@@ -179,4 +204,107 @@
update_time = #{updateTime,jdbcType=VARCHAR}
where buyer_label_id = #{buyerLabelId,jdbcType=BIGINT}
+
+
+
+
+
+
+
+
+ DELETE FROM cere_platform_label where buyer_label_id in (
+
+ #{id}
+
+ )
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/label/CerePlatformLabel.java b/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/label/CerePlatformLabel.java
index b929847..83b4658 100644
--- a/cereshop-commons/src/main/java/com/shop/cereshop/commons/domain/label/CerePlatformLabel.java
+++ b/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;
+
/**
* 标签名称
*/
diff --git a/doc/3.0/update.sql b/doc/3.0/update.sql
index 36d7b7c..3c2b5a4 100644
--- a/doc/3.0/update.sql
+++ b/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';