活动规则
This commit is contained in:
parent
10721afe48
commit
972e63f475
@ -0,0 +1,112 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceService;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceSaveVO;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 价格营销活动主表(分时优惠/限时特价);(active_price)表控制层
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("business/activePrice")
|
||||
public class ActivePriceController extends BaseController {
|
||||
@Resource
|
||||
private ActivePriceService activePriceService;
|
||||
|
||||
/**
|
||||
* 分页列表查询价格营销活动(分时优惠列表/限时特价列表通用方法)
|
||||
*
|
||||
* @param pageNo 分页参数
|
||||
* @param pageSize 分页参数
|
||||
* @param actPriceReq ActivePriceReqVO实体(activeType:价格营销活动类型(1-分时优惠|2-限时特价))
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 10:12 2024/9/2
|
||||
**/
|
||||
@GetMapping("/page")
|
||||
public ResponseObject page(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@Param("actPriceReq") ActivePriceReqVO actPriceReq) {
|
||||
Page<ActivePriceRespVO> page = new Page<>(pageNo, pageSize);
|
||||
return getSuccessResult(activePriceService.pageActivePrice(page, actPriceReq));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据活动id查询详情
|
||||
*
|
||||
* @param id 活动id
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 11:36 2024/9/2
|
||||
**/
|
||||
@GetMapping("{id}")
|
||||
public ResponseObject selectOne(@PathVariable Integer id) {
|
||||
return getSuccessResult(activePriceService.getActPriceById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增营销活动(与更新调用同一个接口,为方便从Controller层控制后端权限分开写)
|
||||
*
|
||||
* @param saveVO ActivePriceSaveVO
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 11:14 2024/9/2
|
||||
**/
|
||||
@PostMapping("/add")
|
||||
public ResponseObject add(@RequestBody ActivePriceSaveVO saveVO) {
|
||||
try {
|
||||
activePriceService.saveActivePrice(true, saveVO);
|
||||
} catch (BusinessCheckException businessCheckException) {
|
||||
return getFailureResult(businessCheckException.getMessage());
|
||||
}
|
||||
return getSuccessResult("保存成功", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新营销活动(与新增调用同一个接口,为方便从Controller层控制后端权限分开写)
|
||||
*
|
||||
* @param saveVO ActivePriceSaveVO
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 11:15 2024/9/2
|
||||
**/
|
||||
@PostMapping("/update")
|
||||
public ResponseObject update(@RequestBody ActivePriceSaveVO saveVO) {
|
||||
try {
|
||||
activePriceService.saveActivePrice(false, saveVO);
|
||||
} catch (BusinessCheckException businessCheckException) {
|
||||
return getFailureResult(businessCheckException.getMessage());
|
||||
}
|
||||
return getSuccessResult("保存成功", null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据营销活动id删除营销活动
|
||||
*
|
||||
* @param id 营销活动id
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 11:30 2024/9/2
|
||||
**/
|
||||
@DeleteMapping("del")
|
||||
public ResponseObject del(@RequestParam("id") Integer id) {
|
||||
activePriceService.removeByActId(id);
|
||||
return getSuccessResult("删除成功", null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.controller;
|
||||
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 价格营销活动适用油品油号;(active_price_oil)表控制层
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("business/activePriceOil")
|
||||
public class ActivePriceOilController extends BaseController {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceRuleService;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.*;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则;(active_price_rule)表服务实现类
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("business/activePriceRule")
|
||||
public class ActivePriceRuleController extends BaseController {
|
||||
@Resource
|
||||
private ActivePriceRuleService activePriceRuleService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询活动规则(分时优惠/限时特价通用接口)
|
||||
*
|
||||
* @param pageNo 分页参数
|
||||
* @param pageSize 分页参数
|
||||
* @param actPriceRuleReq ActivePriceRuleReqVO实体
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 13:42 2024/9/2
|
||||
**/
|
||||
@GetMapping("/page")
|
||||
public ResponseObject page(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@Param("actPriceReq") ActivePriceRuleReqVO actPriceRuleReq) {
|
||||
Page<ActivePriceRuleRespVO> page = new Page<>(pageNo, pageSize);
|
||||
return getSuccessResult(activePriceRuleService.pageActivePriceRule(page, actPriceRuleReq));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据规则id查询规则详情
|
||||
*
|
||||
* @param id id
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 14:08 2024/9/2
|
||||
**/
|
||||
@GetMapping("{id}")
|
||||
public ResponseObject selectOne(@PathVariable Integer id) {
|
||||
return getSuccessResult(activePriceRuleService.getActPriceRuleById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增活动规则(与更新调用同一个接口,为方便从Controller层控制后端权限分开写)
|
||||
*
|
||||
* @param saveVO ActivePriceRuleSaveVO实体
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
* @author PQZ
|
||||
* @date 14:11 2024/9/2
|
||||
**/
|
||||
@PostMapping("/add")
|
||||
public ResponseObject add(@RequestBody ActivePriceRuleSaveVO saveVO) {
|
||||
try {
|
||||
activePriceRuleService.saveActivePriceRule(true, saveVO);
|
||||
} catch (BusinessCheckException businessCheckException) {
|
||||
return getFailureResult(businessCheckException.getMessage());
|
||||
}
|
||||
return getSuccessResult("保存成功", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新活动规则(与更新调用同一个接口,为方便从Controller层控制后端权限分开写)
|
||||
* @author PQZ
|
||||
* @date 14:12 2024/9/2
|
||||
* @param saveVO ActivePriceRuleSaveVO实体
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
**/
|
||||
@PostMapping("/update")
|
||||
public ResponseObject update(@RequestBody ActivePriceRuleSaveVO saveVO) {
|
||||
try {
|
||||
activePriceRuleService.saveActivePriceRule(true, saveVO);
|
||||
} catch (BusinessCheckException businessCheckException) {
|
||||
return getFailureResult(businessCheckException.getMessage());
|
||||
}
|
||||
return getSuccessResult("保存成功", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除活动规则
|
||||
* @author PQZ
|
||||
* @date 14:13 2024/9/2
|
||||
* @param id 活动规则id
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
**/
|
||||
@DeleteMapping("del")
|
||||
public ResponseObject del(@RequestParam("id") Integer id) {
|
||||
activePriceRuleService.removeById(id);
|
||||
return getSuccessResult("删除成功", null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 价格营销活动主表(分时优惠/限时特价);
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("active_price")
|
||||
public class ActivePrice extends Model<ActivePrice> {
|
||||
/** 主键id */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id ;
|
||||
/** 所属连锁店id */
|
||||
private Integer chainStorId ;
|
||||
/** 所属店铺id */
|
||||
private Integer storeId ;
|
||||
/** 价格营销活动类型(1-分时优惠|2-限时特价) */
|
||||
private String activeType ;
|
||||
/** 分时优惠名称 */
|
||||
private String title ;
|
||||
/** 优惠类型(1-固定价格|2-折扣|3-减价) */
|
||||
private String category ;
|
||||
/** 折扣/减价金额(两个字段合用一个) */
|
||||
private Double disValue ;
|
||||
/** 创建人 */
|
||||
private String createBy ;
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date createTime ;
|
||||
/** 更新人 */
|
||||
private String updateBy ;
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date updateTime ;
|
||||
|
||||
public static final String ACTIVE_TYPE_1 = "1";
|
||||
public static final String ACTIVE_TYPE_2 = "2";
|
||||
public static final String ACTIVE_TYPE_1_TEXT = "分时优惠";
|
||||
public static final String ACTIVE_TYPE_2_TEXT = "限时特价";
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 价格营销活动适用油品油号;
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("active_price_oil")
|
||||
public class ActivePriceOil extends Model<ActivePriceOil> {
|
||||
/** 主键id */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id ;
|
||||
/** 所属连锁店id */
|
||||
private Integer chainStorId ;
|
||||
/** 所属店铺id */
|
||||
private Integer storeId ;
|
||||
/** 价格营销活动主表id */
|
||||
private Integer activeId ;
|
||||
/** 油品油号id */
|
||||
private Integer oilId ;
|
||||
/** 固定价格 */
|
||||
private Double price ;
|
||||
/** 创建人 */
|
||||
private String createBy ;
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date createTime ;
|
||||
/** 更新人 */
|
||||
private String updateBy ;
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date updateTime ;
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则;
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("active_price_rule")
|
||||
public class ActivePriceRule extends Model<ActivePriceRule> {
|
||||
/** 主键id */
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id ;
|
||||
/** 所属连锁店id */
|
||||
private Integer chainStorId ;
|
||||
/** 所属店铺id */
|
||||
private Integer storeId ;
|
||||
/** 价格营销活动主表id */
|
||||
private Integer activeId ;
|
||||
/** 活动规则名称 */
|
||||
private String ruleName ;
|
||||
/** 可使用支付方式 0:微信支付 1:支付宝 2:云闪付 3:会员卡 4:现金 5:POS刷卡 */
|
||||
private String paymentType ;
|
||||
/** 适用会员等级id */
|
||||
private String levelId ;
|
||||
/** 会员标签ids,多个以英文逗号隔开 */
|
||||
private String babelIds ;
|
||||
/** 生效起始时间 */
|
||||
private Date activeStartTime ;
|
||||
/** 生效截止时间 */
|
||||
private Date activeEndTime ;
|
||||
/** 适用实收金额下限 */
|
||||
private Double moneyMin ;
|
||||
/** 适用实收金额上限 */
|
||||
private Double moneyMax ;
|
||||
/** 适用加油升数下限 */
|
||||
private Double literMin ;
|
||||
/** 适用加油升数上限 */
|
||||
private Double literMax ;
|
||||
/** 最大优惠金额 */
|
||||
private Double disMax ;
|
||||
/** 适用时间类型(1-每周|2-每月) */
|
||||
private String timeType ;
|
||||
/** 适用时间段(1、2、3、4..31,代表周一、周二、周三或者1号、2号、3号)数字之间英文逗号隔开 */
|
||||
private String timeSlots ;
|
||||
/** 每日生效时间,09:20 */
|
||||
private String dayStartTime ;
|
||||
/** 每日失效时间,09:20 */
|
||||
private String dayEndTime ;
|
||||
/** 每人每日参与限制次数 */
|
||||
private Integer dayLimitNum ;
|
||||
/** 每人累计参与限制次数 */
|
||||
private Integer limitNum ;
|
||||
/** 创建人 */
|
||||
private String createBy ;
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date createTime ;
|
||||
/** 更新人 */
|
||||
private String updateBy ;
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date updateTime ;
|
||||
public static final String ACTIVE_TYPE_RULE_1_TEXT = "分时优惠活动规则";
|
||||
public static final String ACTIVE_TYPE_RULE_2_TEXT = "限时特价活动规则";
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 价格营销活动主表(分时优惠/限时特价);(active_price)表数据库访问层
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivePriceMapper extends BaseMapper<ActivePrice> {
|
||||
|
||||
/**
|
||||
* 分页查询价格营销活动 (分时优惠列表/限时特价列表通用方法)
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param entity 入参查询实体
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO>
|
||||
* @author PQZ
|
||||
* @date 10:36 2024/9/2
|
||||
**/
|
||||
IPage<ActivePriceRespVO> pageActivePrice(@Param("page") Page<ActivePriceRespVO> page, @Param("entity") ActivePriceReqVO entity);
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 价格营销活动适用油品油号;
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivePriceOilMapper extends BaseMapper<ActivePriceOil> {
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则;(active_price_rule)表数据库访问层
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Mapper
|
||||
public interface ActivePriceRuleMapper extends BaseMapper<ActivePriceRule> {
|
||||
|
||||
/**
|
||||
* 分页查询活动规则(分时优惠/限时特价通用接口)
|
||||
* @author PQZ
|
||||
* @date 13:47 2024/9/2
|
||||
* @param page 分页参数
|
||||
* @param entity ActivePriceRuleReqVO
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO>
|
||||
**/
|
||||
IPage<ActivePriceRuleRespVO> pageActivePriceRule(@Param("page") Page<ActivePriceRuleRespVO> page, @Param("entity") ActivePriceRuleReqVO entity);
|
||||
|
||||
/**
|
||||
* 根据id查询活动规则详情
|
||||
* @author PQZ
|
||||
* @date 14:42 2024/9/2
|
||||
* @param id 活动规则id
|
||||
* @return com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO
|
||||
**/
|
||||
ActivePriceRuleRespVO getRuleById(@Param("id") int id);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?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="com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceMapper">
|
||||
|
||||
<select id="pageActivePrice"
|
||||
resultType="com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO">
|
||||
SELECT
|
||||
main.id AS id,
|
||||
main.title AS title,
|
||||
main.create_by AS createBy,
|
||||
main.create_time AS createTime,
|
||||
COUNT( apo.id ) AS countCom
|
||||
FROM
|
||||
active_price main
|
||||
LEFT JOIN active_price_oil apo ON main.id = apo.active_id
|
||||
<where>
|
||||
<if test="entity.activeType != null and entity.activeType != ''">
|
||||
AND main.active_type = #{entity.activeType}
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
main.id
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,5 @@
|
||||
<?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="com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceOilMapper">
|
||||
|
||||
</mapper>
|
@ -0,0 +1,54 @@
|
||||
<?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="com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceRuleMapper">
|
||||
|
||||
<resultMap id="ActivePriceRuleMap" type="com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO">
|
||||
<id column="id" property="id"/>
|
||||
<id column="levelId" property="levelId"/>
|
||||
<id column="babelIds" property="babelIds"/>
|
||||
<collection select="getLevel" property="levelList" javaType="list"
|
||||
column="levelId"
|
||||
ofType="com.fuint.repository.model.MtUserGrade"/>
|
||||
<collection select="getLabel" property="labelList" javaType="list"
|
||||
column="babelIds"
|
||||
ofType="com.fuint.business.userManager.entity.UserLabel"/>
|
||||
|
||||
</resultMap>
|
||||
<select id="pageActivePriceRule" resultMap="ActivePriceRuleMap">
|
||||
SELECT
|
||||
main.*,
|
||||
ap.title AS activeTitle
|
||||
FROM
|
||||
active_price_rule main
|
||||
LEFT JOIN active_price ap ON main.active_id = ap.id
|
||||
<where>
|
||||
<if test="entity.activeType != null and entity.activeType != ''">
|
||||
AND ap.active_type = #{entity.activeType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getLevel" resultType="com.fuint.repository.model.MtUserGrade">
|
||||
select * from mt_user_grade
|
||||
where id in
|
||||
<foreach collection="levelId" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getLabel" resultType="com.fuint.business.userManager.entity.UserLabel">
|
||||
select * from user_label
|
||||
where id in
|
||||
<foreach collection="babelIds" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getRuleById"
|
||||
resultMap="ActivePriceRuleMap">
|
||||
SELECT
|
||||
main.*,
|
||||
ap.title AS activeTitle
|
||||
FROM
|
||||
active_price_rule main
|
||||
LEFT JOIN active_price ap ON main.active_id = ap.id
|
||||
where id = #{id}
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,45 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动适用油品油号;(active_price_oil)表服务接口
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
public interface ActivePriceOilService extends IService<ActivePriceOil> {
|
||||
|
||||
/**
|
||||
* 根据营销活动id删除油品
|
||||
*
|
||||
* @param actId 营销活动id
|
||||
* @author PQZ
|
||||
* @date 10:52 2024/9/2
|
||||
**/
|
||||
void removeOilByActId(Integer actId);
|
||||
|
||||
/**
|
||||
* 保存营销活动下的油品信息
|
||||
*
|
||||
* @param actId 营销活动id
|
||||
* @param oilList 油品集合
|
||||
* @author PQZ
|
||||
* @date 10:53 2024/9/2
|
||||
**/
|
||||
void saveOilList(Integer actId, List<ActivePriceOil> oilList);
|
||||
|
||||
/**
|
||||
* 通过优惠活动id查询绑定的油品信息
|
||||
*
|
||||
* @param actId 优惠活动id
|
||||
* @return java.util.List<com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil>
|
||||
* @author PQZ
|
||||
* @date 11:39 2024/9/2
|
||||
**/
|
||||
List<ActivePriceOil> listByActId(Integer actId);
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.*;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则;(active_price_rule)表服务接口
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
public interface ActivePriceRuleService extends IService<ActivePriceRule> {
|
||||
|
||||
/**
|
||||
* 分页查询活动规则(分时优惠/限时特价通用接口)
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param actPriceRuleReq ActivePriceRuleReqVO实体
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO>
|
||||
* @author PQZ
|
||||
* @date 13:43 2024/9/2
|
||||
**/
|
||||
IPage<ActivePriceRuleRespVO> pageActivePriceRule(Page<ActivePriceRuleRespVO> page, ActivePriceRuleReqVO actPriceRuleReq);
|
||||
|
||||
/**
|
||||
* 根据规则id查询规则详情
|
||||
*
|
||||
* @param id 规则id
|
||||
* @return com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO
|
||||
* @author PQZ
|
||||
* @date 14:07 2024/9/2
|
||||
**/
|
||||
ActivePriceRuleRespVO getActPriceRuleById(Integer id);
|
||||
|
||||
/**
|
||||
* 保存活动规则
|
||||
*
|
||||
* @param isAdd 是否新增
|
||||
* @param saveVO 扩展类实体
|
||||
* @author PQZ
|
||||
* @date 14:09 2024/9/2
|
||||
**/
|
||||
void saveActivePriceRule(boolean isAdd, ActivePriceRuleSaveVO saveVO) throws BusinessCheckException;
|
||||
|
||||
/**
|
||||
* 根据活动id删除活动规则
|
||||
* @author PQZ
|
||||
* @date 14:14 2024/9/2
|
||||
* @param actId 活动id
|
||||
**/
|
||||
void removeByActId(Integer actId);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceSaveVO;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
|
||||
/**
|
||||
* 价格营销活动主表(分时优惠/限时特价);(active_price)表服务接口
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
public interface ActivePriceService extends IService<ActivePrice> {
|
||||
|
||||
/**
|
||||
* 分页查询价格营销活动(分时优惠列表/限时特价列表通用方法)
|
||||
*
|
||||
* @param page Page<ActivePriceRespVO>
|
||||
* @param actPriceReq ActivePriceReqVO实体(activeType:价格营销活动类型(1-分时优惠|2-限时特价))
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.entity.ActivePrice>
|
||||
* @author PQZ
|
||||
* @date 10:25 2024/9/2
|
||||
**/
|
||||
IPage<ActivePriceRespVO> pageActivePrice(Page<ActivePriceRespVO> page, ActivePriceReqVO actPriceReq);
|
||||
|
||||
/**
|
||||
* 保存分时优惠/限时特价内容(新增编辑通用接口)
|
||||
*
|
||||
* @param isAdd 是否新增
|
||||
* @param saveVO ActivePriceSaveVO
|
||||
* @author PQZ
|
||||
* @date 10:49 2024/9/2
|
||||
**/
|
||||
void saveActivePrice(boolean isAdd,ActivePriceSaveVO saveVO) throws BusinessCheckException;
|
||||
|
||||
/**
|
||||
* 根据优惠活动id删除活动及油品信息
|
||||
*
|
||||
* @param actId 活动id
|
||||
* @author PQZ
|
||||
* @date 11:25 2024/9/2
|
||||
**/
|
||||
void removeByActId(Integer actId);
|
||||
|
||||
/**
|
||||
* 根据优惠活动id查询详情
|
||||
*
|
||||
* @param id 活动id
|
||||
* @return com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO
|
||||
* @author PQZ
|
||||
* @date 11:38 2024/9/2
|
||||
**/
|
||||
ActivePriceRespVO getActPriceById(Integer id);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,74 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
import com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceOilMapper;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceOilService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动适用油品油号;(active_price_oil)表服务实现类
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Service("activeOneCouponService")
|
||||
public class ActivePriceOilServiceImpl extends ServiceImpl<ActivePriceOilMapper, ActivePriceOil> implements ActivePriceOilService {
|
||||
|
||||
|
||||
/**
|
||||
* 根据营销活动id删除油品
|
||||
*
|
||||
* @param actId 营销活动id
|
||||
* @author PQZ
|
||||
* @date 10:52 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public void removeOilByActId(Integer actId) {
|
||||
LambdaQueryWrapper<ActivePriceOil> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ActivePriceOil::getActiveId, actId);
|
||||
remove(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存营销活动下的油品信息
|
||||
*
|
||||
* @param actId 营销活动id
|
||||
* @param oilList 油品集合
|
||||
* @return void
|
||||
* @author PQZ
|
||||
* @date 10:53 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public void saveOilList(Integer actId, List<ActivePriceOil> oilList) {
|
||||
//编辑情况下优先删除当前营销活动下的油品信息
|
||||
if (null != actId) {
|
||||
removeOilByActId(actId);
|
||||
}
|
||||
//批量保存油品信息
|
||||
oilList.forEach(item -> {
|
||||
//为每一条油品数据绑定营销活动id
|
||||
item.setActiveId(actId);
|
||||
});
|
||||
saveBatch(oilList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过优惠活动id查询绑定的油品信息
|
||||
*
|
||||
* @param actId 优惠活动id
|
||||
* @return java.util.List<com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil>
|
||||
* @author PQZ
|
||||
* @date 11:39 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public List<ActivePriceOil> listByActId(Integer actId) {
|
||||
LambdaQueryWrapper<ActivePriceOil> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ActivePriceOil::getActiveId, actId);
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,168 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceRuleMapper;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceRuleService;
|
||||
import com.fuint.business.marketingActivity.activePrice.util.ActPriceUtil;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleSaveVO;
|
||||
import com.fuint.business.userManager.entity.UserLabel;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.quartz.util.BeanUtils;
|
||||
import com.fuint.repository.model.MtUserGrade;
|
||||
import com.fuint.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.fuint.business.marketingActivity.activePrice.entity.ActivePrice.*;
|
||||
import static com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule.ACTIVE_TYPE_RULE_1_TEXT;
|
||||
import static com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule.ACTIVE_TYPE_RULE_2_TEXT;
|
||||
import static com.fuint.common.constant.ActConstants.*;
|
||||
import static com.fuint.common.constant.ActConstants.LOG_SYSTEM_MODULE_ACTIVE;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则;(active_price_rule)表服务实现类
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Service("ActivePriceRuleService")
|
||||
public class ActivePriceRuleServiceImpl extends ServiceImpl<ActivePriceRuleMapper, ActivePriceRule> implements ActivePriceRuleService {
|
||||
@Resource
|
||||
private ActivePriceRuleMapper activePriceRuleMapper;
|
||||
@Resource
|
||||
private ActPriceUtil actPriceUtil;
|
||||
|
||||
/**
|
||||
* 分页查询活动规则(分时优惠/限时特价通用接口)
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param actPriceRuleReq ActivePriceRuleReqVO实体
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO>
|
||||
* @author PQZ
|
||||
* @date 13:43 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public IPage<ActivePriceRuleRespVO> pageActivePriceRule(Page<ActivePriceRuleRespVO> page, ActivePriceRuleReqVO actPriceRuleReq) {
|
||||
/*1、列表数据查询,返回结构中带有会员等级集合和会员标签集合*/
|
||||
IPage<ActivePriceRuleRespVO> result = activePriceRuleMapper.pageActivePriceRule(page, actPriceRuleReq);
|
||||
/*2、数据处理*/
|
||||
result.getRecords().forEach(item -> {
|
||||
item.setPaymentTypeText(replacePayment(item.getPaymentType()));
|
||||
//会员等级集合转文字列表展示
|
||||
item.setLevelText(item.getLevelList().stream().map(MtUserGrade::getName).collect(Collectors.joining(",")));
|
||||
//会员标签集合转文字列表展示
|
||||
item.setLabelText(item.getLabelList().stream().map(UserLabel::getLabelName).collect(Collectors.joining(",")));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据规则id查询规则详情
|
||||
*
|
||||
* @param id 规则id
|
||||
* @return com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO
|
||||
* @author PQZ
|
||||
* @date 14:07 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public ActivePriceRuleRespVO getActPriceRuleById(Integer id) {
|
||||
/*1、根据活动规则id查询规则详情,返回结构中带有会员等级集合和会员标签集合*/
|
||||
ActivePriceRuleRespVO result = activePriceRuleMapper.getRuleById(id);
|
||||
/*2、数据处理,将会员等级和会员标签抽出id组成新的集合,方便前端展示*/
|
||||
//会员标签id集合抽取id方便前端展示
|
||||
if (!result.getLabelList().isEmpty()) {
|
||||
//会员标签id集合
|
||||
result.setLabelIdList(result.getLabelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList()));
|
||||
}
|
||||
//会员等级集合抽取id方便前端展示
|
||||
if (!result.getLevelList().isEmpty()){
|
||||
//会员等级id集合
|
||||
result.setLevelIdList(result.getLevelList().stream().map(item -> String.valueOf(item.getId())).collect(Collectors.toList()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存活动规则
|
||||
*
|
||||
* @param isAdd 是否新增
|
||||
* @param saveVO 扩展类实体
|
||||
* @author PQZ
|
||||
* @date 14:09 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveActivePriceRule(boolean isAdd, ActivePriceRuleSaveVO saveVO) throws BusinessCheckException {
|
||||
/*1、数据校验*/
|
||||
//activeType用于区分分时优惠/限时特价,在保存日志中用到,故不能为空
|
||||
if (StringUtils.isEmpty(saveVO.getActiveType())) {
|
||||
throw new BusinessCheckException("价格营销活动类型不能为空");
|
||||
}
|
||||
/*2、数据转换*/
|
||||
//实体类转换
|
||||
ActivePriceRule activePriceRule = new ActivePriceRule();
|
||||
BeanUtils.copyProperties(saveVO,activePriceRule);
|
||||
//会员等级id转换
|
||||
String levelId = String.join(",", saveVO.getLevelIdList());
|
||||
//会员标签id转换
|
||||
String babelIds = String.join(",",saveVO.getLabelIdList());
|
||||
activePriceRule.setLevelId(levelId);
|
||||
activePriceRule.setBabelIds(babelIds);
|
||||
/*3、保存数据库*/
|
||||
//保存活动规则
|
||||
saveOrUpdate(activePriceRule);
|
||||
/*4、日志操作*/
|
||||
//保存日志
|
||||
String content = actPriceUtil.transActLogContent(isAdd ? LOG_OPERATE_ADD : LOG_OPERATE_UPDATE,
|
||||
ACTIVE_TYPE_1.equals(saveVO.getActiveType()) ? ACTIVE_TYPE_RULE_1_TEXT : ACTIVE_TYPE_RULE_2_TEXT,
|
||||
saveVO.getRuleName());
|
||||
actPriceUtil.saveActLog(LOG_SYSTEM_NAME_SIGN, LOG_SYSTEM_MODULE_ACTIVE, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据活动id删除活动规则
|
||||
*
|
||||
* @param actId 活动id
|
||||
* @author PQZ
|
||||
* @date 14:14 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public void removeByActId(Integer actId) {
|
||||
LambdaQueryWrapper<ActivePriceRule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ActivePriceRule::getActiveId,actId);
|
||||
remove(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 支付方式转换
|
||||
*
|
||||
* @param paymentType 支付方式
|
||||
* @return java.lang.String
|
||||
* @author PQZ
|
||||
* @date 14:01 2024/9/2
|
||||
**/
|
||||
public String replacePayment(String paymentType) {
|
||||
if (StringUtil.isNotBlank(paymentType)) {
|
||||
paymentType = paymentType.replace("0", "微信支付");
|
||||
paymentType = paymentType.replace("1", "支付宝");
|
||||
paymentType = paymentType.replace("2", "云闪付");
|
||||
paymentType = paymentType.replace("3", "会员卡");
|
||||
paymentType = paymentType.replace("4", "现金");
|
||||
paymentType = paymentType.replace("5", "POS刷卡");
|
||||
} else {
|
||||
paymentType = "无限制";
|
||||
}
|
||||
return paymentType;
|
||||
}
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
import com.fuint.business.marketingActivity.activePrice.mapper.ActivePriceMapper;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceOilService;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceRuleService;
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActivePriceService;
|
||||
import com.fuint.business.marketingActivity.activePrice.util.ActPriceUtil;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceReqVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceSaveVO;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.framework.exception.BusinessCheckException;
|
||||
import com.fuint.quartz.util.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fuint.business.marketingActivity.activePrice.entity.ActivePrice.*;
|
||||
import static com.fuint.common.constant.ActConstants.*;
|
||||
|
||||
/**
|
||||
* 价格营销活动主表(分时优惠/限时特价);(active_price)表服务接口
|
||||
*
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@Service("ActivePriceService")
|
||||
public class ActivePriceServiceImpl extends ServiceImpl<ActivePriceMapper, ActivePrice> implements ActivePriceService {
|
||||
|
||||
@Resource
|
||||
private ActivePriceMapper activePriceMapper;
|
||||
@Resource
|
||||
private ActivePriceOilService activePriceOilService;
|
||||
@Resource
|
||||
private ActivePriceRuleService activePriceRuleService;
|
||||
@Resource
|
||||
private ActPriceUtil actPriceUtil;
|
||||
|
||||
/**
|
||||
* 分页查询价格营销活动(分时优惠列表/限时特价列表通用方法)
|
||||
*
|
||||
* @param page Page<ActivePriceRespVO>
|
||||
* @param actPriceReq ActivePriceReqVO实体(activeType:价格营销活动类型(1-分时优惠|2-限时特价))
|
||||
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.fuint.business.marketingActivity.activePrice.entity.ActivePrice>
|
||||
* @author PQZ
|
||||
* @date 10:25 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public IPage<ActivePriceRespVO> pageActivePrice(Page<ActivePriceRespVO> page, ActivePriceReqVO actPriceReq) {
|
||||
return activePriceMapper.pageActivePrice(page, actPriceReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存分时优惠/限时特价内容(新增编辑通用接口)
|
||||
*
|
||||
* @param isAdd 是否新增
|
||||
* @param saveVO ActivePriceSaveVO
|
||||
* @author PQZ
|
||||
* @date 10:49 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveActivePrice(boolean isAdd, ActivePriceSaveVO saveVO) throws BusinessCheckException {
|
||||
/*1、数据校验*/
|
||||
//activeType用于区分分时优惠/限时特价,在保存日志中用到,故不能为空
|
||||
if (StringUtils.isEmpty(saveVO.getActiveType())) {
|
||||
throw new BusinessCheckException("价格营销活动类型不能为空");
|
||||
}
|
||||
/*2、基础数据准备*/
|
||||
//实体类转换
|
||||
ActivePrice activePrice = new ActivePrice();
|
||||
BeanUtils.copyProperties(saveVO, activePrice);
|
||||
/*3、数据保存*/
|
||||
//保存营销活动
|
||||
saveOrUpdate(activePrice);
|
||||
//保存关联油品信息
|
||||
activePriceOilService.saveOilList(activePrice.getId(), saveVO.getOilList());
|
||||
/*4、日志操作*/
|
||||
//转换日志保存内容
|
||||
String content = actPriceUtil.transActLogContent(isAdd ? LOG_OPERATE_ADD : LOG_OPERATE_UPDATE,
|
||||
ACTIVE_TYPE_1.equals(saveVO.getActiveType()) ? ACTIVE_TYPE_1_TEXT : ACTIVE_TYPE_2_TEXT,
|
||||
saveVO.getTitle());
|
||||
actPriceUtil.saveActLog(LOG_SYSTEM_NAME_SIGN, LOG_SYSTEM_MODULE_ACTIVE, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据优惠活动id删除活动及油品信息
|
||||
*
|
||||
* @param actId 活动id
|
||||
* @author PQZ
|
||||
* @date 11:25 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeByActId(Integer actId) {
|
||||
/*1、日志操作*/
|
||||
//查询油品信息用于保存日志
|
||||
ActivePrice activePrice = getById(actId);
|
||||
//转换日志保存内容
|
||||
String content = actPriceUtil.transActLogContent(LOG_OPERATE_DEL,
|
||||
ACTIVE_TYPE_1.equals(activePrice.getActiveType()) ? ACTIVE_TYPE_1_TEXT : ACTIVE_TYPE_2_TEXT,
|
||||
activePrice.getTitle());
|
||||
//保存日志
|
||||
actPriceUtil.saveActLog(LOG_SYSTEM_NAME_SIGN, LOG_SYSTEM_MODULE_ACTIVE, content);
|
||||
/*2、删除活动及关联表信息*/
|
||||
//删除活动
|
||||
removeById(actId);
|
||||
//删除关联油品
|
||||
activePriceOilService.removeOilByActId(actId);
|
||||
//删除关联规则
|
||||
activePriceRuleService.removeByActId(actId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据优惠活动id查询详情
|
||||
*
|
||||
* @param id 活动id
|
||||
* @return com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRespVO
|
||||
* @author PQZ
|
||||
* @date 11:38 2024/9/2
|
||||
**/
|
||||
@Override
|
||||
public ActivePriceRespVO getActPriceById(Integer id) {
|
||||
ActivePriceRespVO respVO = new ActivePriceRespVO();
|
||||
//查询优惠活动详情
|
||||
ActivePrice activePrice = getById(id);
|
||||
BeanUtils.copyProperties(activePrice, respVO);
|
||||
//查询关联油品信息
|
||||
List<ActivePriceOil> oilList = activePriceOilService.listByActId(id);
|
||||
respVO.setOilList(oilList);
|
||||
return respVO;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.util;
|
||||
|
||||
import com.fuint.business.setting.entity.SysLog;
|
||||
import com.fuint.business.setting.service.SysLogService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
* @author PQZ
|
||||
* @date 15:14 2024/9/2
|
||||
* @return
|
||||
**/
|
||||
@Component
|
||||
public class ActPriceUtil {
|
||||
@Resource
|
||||
private SysLogService sysLogService;
|
||||
|
||||
/**
|
||||
* 日志内容转换
|
||||
*
|
||||
* @param operate 操作
|
||||
* @param contentModule 子模块
|
||||
* @param actTile 业务标题
|
||||
* @return java.lang.String
|
||||
* @author PQZ
|
||||
* @date 12:17 2024/9/2
|
||||
**/
|
||||
public String transActLogContent(String operate, String contentModule, String actTile) {
|
||||
return operate + contentModule + "【" + actTile + "】";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PQZ
|
||||
* @date 11:57 2024/9/2
|
||||
* @param systemName 系统标识
|
||||
* @param module 模块名称
|
||||
* @param content 内容
|
||||
**/
|
||||
public void saveActLog(String systemName, String module, String content) {
|
||||
SysLog sysLog =new SysLog();
|
||||
sysLog.setSystemName(systemName);
|
||||
sysLog.setMoudle(module);
|
||||
sysLog.setContent(content);
|
||||
sysLogService.saveVo(sysLog);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 价格营销活动前段请求扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceReqVO extends ActivePrice {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动前端返回扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceRespVO extends ActivePrice {
|
||||
/**适用商品数量*/
|
||||
private Integer countCom;
|
||||
/**价格营销活动适用油品油号*/
|
||||
private List<ActivePriceOil> oilList;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 价格营销活动前端请求扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceRuleReqVO extends ActivePriceRule {
|
||||
/** 价格营销活动类型(1-分时优惠|2-限时特价) */
|
||||
private String activeType ;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.userManager.entity.UserLabel;
|
||||
import com.fuint.repository.model.MtUserGrade;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则请求返回扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceRuleRespVO extends ActivePriceRule {
|
||||
/** 活动名称 */
|
||||
private String activeTitle ;
|
||||
/** 支付方式字符串 */
|
||||
private String paymentTypeText;
|
||||
/**会员等级文字*/
|
||||
private String levelText;
|
||||
/**标签文字*/
|
||||
private String labelText;
|
||||
/**会员等级*/
|
||||
private List<MtUserGrade> levelList;
|
||||
/**标签集合*/
|
||||
private List<UserLabel> labelList;
|
||||
/**会员等级*/
|
||||
private List<String> levelIdList;
|
||||
/**标签集合*/
|
||||
private List<String> labelIdList;
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.userManager.entity.UserLabel;
|
||||
import com.fuint.repository.model.MtUserGrade;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动规则实体保存扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceRuleSaveVO extends ActivePriceRule {
|
||||
/** 价格营销活动类型(1-分时优惠|2-限时特价) */
|
||||
private String activeType ;
|
||||
/**会员等级*/
|
||||
private List<String> levelIdList;
|
||||
/**标签集合*/
|
||||
private List<String> labelIdList;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.fuint.business.marketingActivity.activePrice.vo;
|
||||
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePrice;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceOil;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 价格营销活动保存扩展类
|
||||
* @author : pqz
|
||||
* @date : 2024-9-2
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ActivePriceSaveVO extends ActivePrice {
|
||||
|
||||
/**价格营销活动适用油品油号*/
|
||||
private List<ActivePriceOil> oilList;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.fuint.common.constant;
|
||||
|
||||
|
||||
/**
|
||||
* 营销活动常量类
|
||||
*/
|
||||
public class ActConstants {
|
||||
/**
|
||||
* 油站端
|
||||
*/
|
||||
public static final String LOG_SYSTEM_NAME_SIGN = "2";
|
||||
/**
|
||||
* 日志保存-活动中心
|
||||
*/
|
||||
public static final String LOG_SYSTEM_MODULE_ACTIVE = "活动中心";
|
||||
/**日志记录操作常量-新增*/
|
||||
public static final String LOG_OPERATE_ADD = "新增";
|
||||
/**日志记录操作常量-编辑*/
|
||||
public static final String LOG_OPERATE_UPDATE = "更新";
|
||||
/**日志记录操作常量-删除*/
|
||||
public static final String LOG_OPERATE_DEL = "删除";
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user