客户编辑添加绑定套餐
This commit is contained in:
+72
@@ -0,0 +1,72 @@
|
||||
package com.ruoyi.customer.customerinfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 客户套餐绑定对象 prc_customer_price_set
|
||||
* 客户管理-客户编辑-绑定套餐 使用;关联 prc_price_set 的字段仅用于页面展示
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-09-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class BmsCustomerPriceSet extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 客户价格套餐ID */
|
||||
private Long customerPricesetId;
|
||||
|
||||
/** 价格套餐ID */
|
||||
private Long priceSetId;
|
||||
|
||||
/** 客户ID */
|
||||
private Long customerId;
|
||||
|
||||
/** 客户代码 */
|
||||
private String customerCode;
|
||||
|
||||
/** 客户名称 */
|
||||
private String customerName;
|
||||
|
||||
/** 绑定优先级,数字越小越优先 */
|
||||
private Integer bindPriority;
|
||||
|
||||
/** 价格开始生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date prBegindate;
|
||||
|
||||
/** 价格失效日期(空=长期) */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date prEnddate;
|
||||
|
||||
/** 绑定备注 */
|
||||
private String priceSetNote;
|
||||
|
||||
/* -------- 关联 prc_price_set 展示字段 -------- */
|
||||
|
||||
/** 套餐编码 */
|
||||
private String priceSetCode;
|
||||
|
||||
/** 套餐名称 */
|
||||
private String priceSetName;
|
||||
|
||||
/** 计价类型 FIXED=固定价 DISCOUNT=折扣 */
|
||||
private String setType;
|
||||
|
||||
/** 套餐状态 D草稿 A审核中 E生效 R驳回 S停用 */
|
||||
private String priceSetStatus;
|
||||
|
||||
/** 套餐生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date setEffectiveDate;
|
||||
|
||||
/** 套餐失效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date setExpireDate;
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.ruoyi.customer.customerinfo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 价格套餐(prc_price_set)简要对象
|
||||
* 仅用于客户编辑-绑定套餐的套餐下拉选择,不参与套餐维护
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-09-16
|
||||
*/
|
||||
@Data
|
||||
public class BmsPriceSetOption
|
||||
{
|
||||
/** 价格套餐ID */
|
||||
private Long priceSetId;
|
||||
|
||||
/** 套餐编码 */
|
||||
private String priceSetCode;
|
||||
|
||||
/** 套餐名称 */
|
||||
private String priceSetName;
|
||||
|
||||
/** 计价类型 FIXED=固定价 DISCOUNT=折扣 */
|
||||
private String setType;
|
||||
|
||||
/** 套餐状态 D草稿 A审核中 E生效 R驳回 S停用 */
|
||||
private String status;
|
||||
|
||||
/** 生效日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date effectiveDate;
|
||||
|
||||
/** 失效日期(空=长期) */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date expireDate;
|
||||
|
||||
/** 关键字(编码/名称模糊) */
|
||||
private String keyword;
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.customer.customerinfo.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsPriceSetOption;
|
||||
|
||||
/**
|
||||
* 客户套餐绑定 数据层(客户管理侧独立实现,操作 prc_customer_price_set)
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-09-16
|
||||
*/
|
||||
public interface BmsCustomerPriceSetMapper
|
||||
{
|
||||
/** 按客户查绑定列表(join prc_price_set 取套餐展示字段) */
|
||||
public List<BmsCustomerPriceSet> selectBindListByCustomerId(@Param("customerId") Long customerId);
|
||||
|
||||
/** 按主键查绑定 */
|
||||
public BmsCustomerPriceSet selectBindById(Long customerPricesetId);
|
||||
|
||||
/** 按客户ID查绑定(uk_customer_one_set 保证至多一条) */
|
||||
public BmsCustomerPriceSet selectBindByCustomerId(@Param("customerId") Long customerId);
|
||||
|
||||
/** 新增绑定 */
|
||||
public int insertBind(BmsCustomerPriceSet bind);
|
||||
|
||||
/** 更新绑定(允许更换套餐 price_set_id 与生效区间/优先级/备注) */
|
||||
public int updateBind(BmsCustomerPriceSet bind);
|
||||
|
||||
/** 按主键批量解绑 */
|
||||
public int deleteBindByIds(Long[] customerPricesetIds);
|
||||
|
||||
/** 套餐下拉选项(只列生效中套餐,可按关键字/类型过滤) */
|
||||
public List<BmsPriceSetOption> selectPriceSetOptionList(BmsPriceSetOption query);
|
||||
|
||||
/** 按主键查套餐简要信息 */
|
||||
public BmsPriceSetOption selectPriceSetOptionById(@Param("priceSetId") Long priceSetId);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.ruoyi.customer.customerinfo.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsPriceSetOption;
|
||||
|
||||
/**
|
||||
* 客户套餐绑定 服务层(客户管理侧)
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-09-16
|
||||
*/
|
||||
public interface IBmsCustomerPriceSetService
|
||||
{
|
||||
/** 查询某客户的套餐绑定列表 */
|
||||
public List<BmsCustomerPriceSet> selectBindList(Long customerId);
|
||||
|
||||
/** 查询可绑定的生效套餐选项 */
|
||||
public List<BmsPriceSetOption> selectOptionList(BmsPriceSetOption query);
|
||||
|
||||
/**
|
||||
* 保存客户套餐绑定(一个客户一条记录):已绑定则更新(支持更换套餐),未绑定则新增
|
||||
*/
|
||||
public int saveBind(BmsCustomerPriceSet bind);
|
||||
|
||||
/** 按绑定主键解绑 */
|
||||
public int deleteBindByIds(Long[] customerPricesetIds);
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.ruoyi.customer.customerinfo.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsCustomer;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet;
|
||||
import com.ruoyi.customer.customerinfo.domain.BmsPriceSetOption;
|
||||
import com.ruoyi.customer.customerinfo.mapper.BmsCustomerPriceSetMapper;
|
||||
import com.ruoyi.customer.customerinfo.service.IBmsCustomerPriceSetService;
|
||||
import com.ruoyi.customer.customerinfo.service.IBmsCustomerService;
|
||||
|
||||
/**
|
||||
* 客户套餐绑定 服务实现(客户管理侧,独立于价格套餐维护模块)
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-09-16
|
||||
*/
|
||||
@Service
|
||||
public class BmsCustomerPriceSetServiceImpl implements IBmsCustomerPriceSetService
|
||||
{
|
||||
@Autowired
|
||||
private BmsCustomerPriceSetMapper bindMapper;
|
||||
|
||||
@Autowired
|
||||
private IBmsCustomerService customerService;
|
||||
|
||||
@Override
|
||||
public List<BmsCustomerPriceSet> selectBindList(Long customerId)
|
||||
{
|
||||
if (customerId == null)
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
return bindMapper.selectBindListByCustomerId(customerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BmsPriceSetOption> selectOptionList(BmsPriceSetOption query)
|
||||
{
|
||||
return bindMapper.selectPriceSetOptionList(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBind(BmsCustomerPriceSet bind)
|
||||
{
|
||||
if (bind.getCustomerId() == null)
|
||||
{
|
||||
throw new ServiceException("客户ID不能为空");
|
||||
}
|
||||
if (bind.getPriceSetId() == null)
|
||||
{
|
||||
throw new ServiceException("请选择要绑定的套餐");
|
||||
}
|
||||
BmsCustomer customer = customerService.selectBmsCustomerByCustomerId(bind.getCustomerId());
|
||||
if (customer == null)
|
||||
{
|
||||
throw new ServiceException("客户不存在或已被删除");
|
||||
}
|
||||
BmsPriceSetOption set = bindMapper.selectPriceSetOptionById(bind.getPriceSetId());
|
||||
if (set == null)
|
||||
{
|
||||
throw new ServiceException("所选套餐不存在");
|
||||
}
|
||||
if (!"E".equals(set.getStatus()))
|
||||
{
|
||||
throw new ServiceException("仅生效中的套餐允许绑定,当前套餐状态不可用");
|
||||
}
|
||||
if (bind.getPrBegindate() == null)
|
||||
{
|
||||
bind.setPrBegindate(set.getEffectiveDate());
|
||||
}
|
||||
if (bind.getPrBegindate() == null)
|
||||
{
|
||||
throw new ServiceException("绑定生效日期不能为空");
|
||||
}
|
||||
if (bind.getPrEnddate() != null && bind.getPrBegindate().after(bind.getPrEnddate()))
|
||||
{
|
||||
throw new ServiceException("失效日期不能早于生效日期");
|
||||
}
|
||||
if (bind.getBindPriority() == null || bind.getBindPriority() < 1)
|
||||
{
|
||||
bind.setBindPriority(1);
|
||||
}
|
||||
|
||||
bind.setCustomerCode(customer.getCustomerCode());
|
||||
bind.setCustomerName(customer.getCustomerName());
|
||||
|
||||
BmsCustomerPriceSet existing = bindMapper.selectBindByCustomerId(bind.getCustomerId());
|
||||
try
|
||||
{
|
||||
if (existing != null)
|
||||
{
|
||||
bind.setCustomerPricesetId(existing.getCustomerPricesetId());
|
||||
return bindMapper.updateBind(bind);
|
||||
}
|
||||
return bindMapper.insertBind(bind);
|
||||
}
|
||||
catch (DuplicateKeyException e)
|
||||
{
|
||||
throw new ServiceException("该客户已存在套餐绑定,请勿重复绑定");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBindByIds(Long[] customerPricesetIds)
|
||||
{
|
||||
if (customerPricesetIds == null || customerPricesetIds.length == 0)
|
||||
{
|
||||
throw new ServiceException("请选择要解绑的记录");
|
||||
}
|
||||
return bindMapper.deleteBindByIds(customerPricesetIds);
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
<?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.ruoyi.customer.customerinfo.mapper.BmsCustomerPriceSetMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet" id="BmsCustomerPriceSetResult">
|
||||
<id property="customerPricesetId" column="customer_priceset_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="customerId" column="customer_id" />
|
||||
<result property="customerCode" column="customer_code" />
|
||||
<result property="customerName" column="customer_name" />
|
||||
<result property="bindPriority" column="bind_priority" />
|
||||
<result property="prBegindate" column="pr_begindate" />
|
||||
<result property="prEnddate" column="pr_enddate" />
|
||||
<result property="priceSetNote" column="price_set_note" />
|
||||
<result property="createBy" column="created_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="priceSetCode" column="price_set_code" />
|
||||
<result property="priceSetName" column="price_set_name" />
|
||||
<result property="setType" column="set_type" />
|
||||
<result property="priceSetStatus" column="price_set_status" />
|
||||
<result property="setEffectiveDate" column="set_effective_date" />
|
||||
<result property="setExpireDate" column="set_expire_date" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.ruoyi.customer.customerinfo.domain.BmsPriceSetOption" id="BmsPriceSetOptionResult">
|
||||
<id property="priceSetId" column="price_set_id" />
|
||||
<result property="priceSetCode" column="price_set_code" />
|
||||
<result property="priceSetName" column="price_set_name" />
|
||||
<result property="setType" column="set_type" />
|
||||
<result property="status" column="status" />
|
||||
<result property="effectiveDate" column="effective_date" />
|
||||
<result property="expireDate" column="expire_date" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="bindVo">
|
||||
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name,
|
||||
c.bind_priority, c.pr_begindate, c.pr_enddate, c.price_set_note,
|
||||
c.created_by, c.create_time, c.updated_by, c.update_time,
|
||||
s.price_set_code, s.price_set_name, s.set_type,
|
||||
s.status as price_set_status,
|
||||
s.effective_date as set_effective_date, s.expire_date as set_expire_date
|
||||
from prc_customer_price_set c
|
||||
left join prc_price_set s on s.price_set_id = c.price_set_id
|
||||
</sql>
|
||||
|
||||
<select id="selectBindListByCustomerId" resultMap="BmsCustomerPriceSetResult">
|
||||
<include refid="bindVo"/>
|
||||
where c.customer_id = #{customerId}
|
||||
order by c.bind_priority asc, c.customer_priceset_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectBindById" parameterType="Long" resultMap="BmsCustomerPriceSetResult">
|
||||
<include refid="bindVo"/>
|
||||
where c.customer_priceset_id = #{customerPricesetId}
|
||||
</select>
|
||||
|
||||
<select id="selectBindByCustomerId" resultMap="BmsCustomerPriceSetResult">
|
||||
select customer_priceset_id, price_set_id, customer_id, customer_code, customer_name,
|
||||
bind_priority, pr_begindate, pr_enddate, price_set_note,
|
||||
created_by, create_time, updated_by, update_time
|
||||
from prc_customer_price_set
|
||||
where customer_id = #{customerId}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertBind" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet"
|
||||
useGeneratedKeys="true" keyProperty="customerPricesetId">
|
||||
insert into prc_customer_price_set (
|
||||
price_set_id, customer_id, customer_code, customer_name,
|
||||
bind_priority, pr_begindate, pr_enddate, price_set_note,
|
||||
created_by, create_time
|
||||
) values (
|
||||
#{priceSetId}, #{customerId}, #{customerCode}, #{customerName},
|
||||
#{bindPriority}, #{prBegindate}, #{prEnddate}, #{priceSetNote},
|
||||
#{createBy}, sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateBind" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerPriceSet">
|
||||
update prc_customer_price_set
|
||||
set price_set_id = #{priceSetId},
|
||||
customer_code = #{customerCode},
|
||||
customer_name = #{customerName},
|
||||
bind_priority = #{bindPriority},
|
||||
pr_begindate = #{prBegindate},
|
||||
pr_enddate = #{prEnddate},
|
||||
price_set_note = #{priceSetNote},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where customer_priceset_id = #{customerPricesetId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteBindByIds" parameterType="Long">
|
||||
delete from prc_customer_price_set where customer_priceset_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectPriceSetOptionList"
|
||||
parameterType="com.ruoyi.customer.customerinfo.domain.BmsPriceSetOption"
|
||||
resultMap="BmsPriceSetOptionResult">
|
||||
select price_set_id, price_set_code, price_set_name, set_type, status, effective_date, expire_date
|
||||
from prc_price_set
|
||||
<where>
|
||||
status = 'E'
|
||||
<if test="setType != null and setType != ''">
|
||||
and set_type = #{setType}
|
||||
</if>
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and (price_set_code like concat('%', #{keyword}, '%')
|
||||
or price_set_name like concat('%', #{keyword}, '%'))
|
||||
</if>
|
||||
</where>
|
||||
order by price_set_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPriceSetOptionById" resultMap="BmsPriceSetOptionResult">
|
||||
select price_set_id, price_set_code, price_set_name, set_type, status, effective_date, expire_date
|
||||
from prc_price_set
|
||||
where price_set_id = #{priceSetId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user