客服相关功能
This commit is contained in:
parent
21f2a75713
commit
cc0d20ddc1
|
@ -2,6 +2,7 @@ package com.ruoyi.bst.area.mapper;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.ruoyi.bst.area.domain.Area;
|
||||
|
@ -81,4 +82,6 @@ public interface AreaMapper
|
|||
int logicDel(@Param("ids") List<Long> ids);
|
||||
|
||||
|
||||
public Long selectAreaByStoreId(Long storeId);
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
|
||||
null,
|
||||
"ba.user_id,ba.create_id",
|
||||
"ba.user_id,ba.create_id,su.agent_id",
|
||||
null,
|
||||
null,
|
||||
query.scope
|
||||
|
@ -242,6 +242,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAreaByStoreId" resultType="java.lang.Long">
|
||||
select id from bst_area where user_id = #{storeId}
|
||||
</select>
|
||||
|
||||
<!-- logicDel -->
|
||||
|
||||
<update id="logicDel">
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.ruoyi.bst.area.domain.Area;
|
||||
import com.ruoyi.bst.area.domain.AreaQuery;
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
|
||||
/**
|
||||
* 运营区Service接口
|
||||
|
@ -76,4 +77,6 @@ public interface AreaService
|
|||
|
||||
public AreaVO selectOne(AreaQuery query);
|
||||
|
||||
public Long selectAreaByStoreId(Long storeId);
|
||||
|
||||
}
|
||||
|
|
|
@ -49,4 +49,10 @@ public interface AreaValidator {
|
|||
*/
|
||||
boolean canCheckForJoin(Long areaId);
|
||||
|
||||
/**
|
||||
* 是否允许添加客服
|
||||
* @param areaId
|
||||
* @return
|
||||
*/
|
||||
boolean canAddCustomerService(Long areaId);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.ruoyi.bst.area.service.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -57,6 +59,11 @@ public class AreaServiceImpl implements AreaService
|
|||
return CollectionUtils.firstElement(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long selectAreaByStoreId(Long storeId) {
|
||||
return areaMapper.selectAreaByStoreId(storeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询运营区列表
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.bst.area.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -93,6 +94,11 @@ public class AreaValidatorImpl implements AreaValidator {
|
|||
return canOperate(Arrays.asList(areaId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAddCustomerService(Long areaId) {
|
||||
return canOperate(Collections.singletonList(areaId));
|
||||
}
|
||||
|
||||
private boolean isAgent(AreaVO area, Long userId) {
|
||||
return area != null && area.getAgentId() != null && area.getAgentId().equals(userId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package com.ruoyi.bst.customerService.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 客服对象 bst_customer_service
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-04-02
|
||||
*/
|
||||
@Data
|
||||
public class CustomerService extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Excel(name = "所属运营区id")
|
||||
@ApiModelProperty("所属运营区id")
|
||||
private Long areaId;
|
||||
|
||||
@Excel(name = "运营商id")
|
||||
@ApiModelProperty("运营商id")
|
||||
private Long storeId;
|
||||
|
||||
@Excel(name = "客服姓名")
|
||||
@ApiModelProperty("客服姓名")
|
||||
private String name;
|
||||
|
||||
@Excel(name = "客服电话")
|
||||
@ApiModelProperty("客服电话")
|
||||
private String contact;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm:ss")
|
||||
@Excel(name = "工作开始时间", width = 30, dateFormat = "HH:mm:ss")
|
||||
@ApiModelProperty("工作开始时间")
|
||||
private Date startTime;
|
||||
|
||||
@JsonFormat(pattern = "HH:mm:ss")
|
||||
@Excel(name = "工作结束时间", width = 30, dateFormat = "HH:mm:ss")
|
||||
@ApiModelProperty("工作结束时间")
|
||||
private Date endTime;
|
||||
|
||||
@Excel(name = "是否启用")
|
||||
@ApiModelProperty("是否启用")
|
||||
private String isEnabled;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.bst.customerService.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CustomerServiceQuery extends CustomerService{
|
||||
|
||||
@ApiModelProperty("客服ID列表")
|
||||
private List<Long> ids;
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.ruoyi.bst.customerService.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CustomerServiceVO extends CustomerService{
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.ruoyi.bst.customerService.domain.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CustomerServiceStatus {
|
||||
|
||||
DISABLE("0", "禁用"),
|
||||
ENABLE("1", "启用");
|
||||
|
||||
|
||||
private final String status;
|
||||
private final String msg;
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.ruoyi.bst.customerService.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerService;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import com.ruoyi.system.user.domain.UserQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 客服Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-04-02
|
||||
*/
|
||||
public interface CustomerServiceMapper
|
||||
{
|
||||
/**
|
||||
* 查询客服
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 客服
|
||||
*/
|
||||
CustomerServiceVO selectCustomerServiceById(Long id);
|
||||
|
||||
/**
|
||||
* 查询客服列表
|
||||
*
|
||||
* @param query 客服
|
||||
* @return 客服集合
|
||||
*/
|
||||
List<CustomerServiceVO> selectCustomerServiceList(@Param("query")CustomerServiceQuery query);
|
||||
|
||||
/**
|
||||
* 新增客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
int insertCustomerService(CustomerService customerService);
|
||||
|
||||
/**
|
||||
* 批量新增客服
|
||||
*/
|
||||
int batchInsert(@Param("list") List<? extends CustomerService> list);
|
||||
|
||||
/**
|
||||
* 批量修改客服
|
||||
*/
|
||||
int batchUpdate(@Param("list") List<? extends CustomerService> list);
|
||||
|
||||
/**
|
||||
* 修改客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCustomerService(@Param("data") CustomerService customerService);
|
||||
|
||||
/**
|
||||
* 删除客服
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteCustomerServiceById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除客服
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCustomerServiceByIds(Long[] ids);
|
||||
|
||||
public int logicDel(@Param("ids") List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
<?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.bst.customerService.mapper.CustomerServiceMapper">
|
||||
|
||||
<resultMap type="CustomerServiceVO" id="CustomerServiceResult" autoMapping="true">
|
||||
<result property="id" column="id" />
|
||||
<result property="areaId" column="area_id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="contact" column="contact" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="isEnabled" column="is_enabled" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCustomerServiceVo">
|
||||
select
|
||||
bcs.id,
|
||||
bcs.area_id,
|
||||
bcs.name,
|
||||
bcs.contact,
|
||||
bcs.start_time,
|
||||
bcs.end_time,
|
||||
bcs.is_enabled,
|
||||
bcs.create_time,
|
||||
bcs.store_id,
|
||||
su.agent_id
|
||||
from bst_customer_service bcs
|
||||
left join sys_user su on bcs.store_id = su.user_id
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.id != null "> and id = #{query.id}</if>
|
||||
<if test="query.areaId != null "> and area_id = #{query.areaId}</if>
|
||||
<if test="query.name != null and query.name != ''"> and name like concat('%', #{query.name}, '%')</if>
|
||||
<if test="query.contact != null and query.contact != ''"> and contact = #{query.contact}</if>
|
||||
<if test="query.startTime != null "> and start_time = #{query.startTime}</if>
|
||||
<if test="query.endTime != null "> and end_time = #{query.endTime}</if>
|
||||
<if test="query.isEnabled != null "> and is_enabled = #{query.isEnabled}</if>
|
||||
${@com.ruoyi.framework.util.DataScopeUtil@dataScope(
|
||||
null,
|
||||
"bcs.store_id,su.agent_id",
|
||||
null,
|
||||
null,
|
||||
query.scope
|
||||
)}
|
||||
${query.params.dataScope}
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
<select id="selectCustomerServiceList" parameterType="CustomerServiceQuery" resultMap="CustomerServiceResult">
|
||||
<include refid="selectCustomerServiceVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectCustomerServiceById" parameterType="Long" resultMap="CustomerServiceResult">
|
||||
<include refid="selectCustomerServiceVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertCustomerService" parameterType="CustomerService" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bst_customer_service
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="areaId != null">area_id,</if>
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="contact != null and contact != ''">contact,</if>
|
||||
<if test="startTime != null">start_time,</if>
|
||||
<if test="endTime != null">end_time,</if>
|
||||
<if test="isEnabled != null">is_enabled,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="areaId != null">#{areaId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="contact != null and contact != ''">#{contact},</if>
|
||||
<if test="startTime != null">#{startTime},</if>
|
||||
<if test="endTime != null">#{endTime},</if>
|
||||
<if test="isEnabled != null">#{isEnabled},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="CustomerService" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into bst_customer_service
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
area_id,
|
||||
name,
|
||||
contact,
|
||||
start_time,
|
||||
end_time,
|
||||
is_enabled,
|
||||
create_time,
|
||||
</trim>
|
||||
values
|
||||
<foreach collection="list" item="i" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="i.areaId != null ">#{i.areaId},</if>
|
||||
<if test="i.areaId == null ">default,</if>
|
||||
<if test="i.name != null ">#{i.name},</if>
|
||||
<if test="i.name == null ">default,</if>
|
||||
<if test="i.contact != null and i.contact != ''">#{i.contact},</if>
|
||||
<if test="i.contact == null or i.contact == ''">default,</if>
|
||||
<if test="i.startTime != null ">#{i.startTime},</if>
|
||||
<if test="i.startTime == null ">default,</if>
|
||||
<if test="i.endTime != null ">#{i.endTime},</if>
|
||||
<if test="i.endTime == null ">default,</if>
|
||||
<if test="i.isEnabled != null ">#{i.isEnabled},</if>
|
||||
<if test="i.isEnabled == null ">default,</if>
|
||||
<if test="i.createTime != null ">#{i.createTime},</if>
|
||||
<if test="i.createTime == null ">default,</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="batchUpdate">
|
||||
update bst_customer_service
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<foreach open="area_id = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.areaId != null ">
|
||||
WHEN #{item.id} THEN #{item.areaId}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `area_id`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="name = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.name != null ">
|
||||
WHEN #{item.id} THEN #{item.name}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `name`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="contact = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.contact != null and item.contact != ''">
|
||||
WHEN #{item.id} THEN #{item.contact}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `contact`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="start_time = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.startTime != null ">
|
||||
WHEN #{item.id} THEN #{item.startTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `start_time`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="end_time = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.endTime != null ">
|
||||
WHEN #{item.id} THEN #{item.endTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `end_time`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="is_enabled = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.isEnabled != null ">
|
||||
WHEN #{item.id} THEN #{item.isEnabled}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `is_enabled`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<foreach open="create_time = CASE id" collection="list" item="item" close="END,">
|
||||
<choose>
|
||||
<when test="item.createTime != null ">
|
||||
WHEN #{item.id} THEN #{item.createTime}
|
||||
</when>
|
||||
<otherwise>
|
||||
WHEN #{item.id} THEN `create_time`
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
where id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateCustomerService" parameterType="CustomerService">
|
||||
update bst_customer_service
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<include refid="updateColumns"/>
|
||||
</trim>
|
||||
where id = #{data.id}
|
||||
</update>
|
||||
|
||||
<!--logicDel-->
|
||||
<update id="logicDel">
|
||||
update bst_customer_service
|
||||
set deleted = true
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and deleted = false
|
||||
</update>
|
||||
|
||||
<sql id="updateColumns">
|
||||
<if test="data.areaId != null">area_id = #{data.areaId},</if>
|
||||
<if test="data.name != null">name = #{data.name},</if>
|
||||
<if test="data.contact != null and data.contact != ''">contact = #{data.contact},</if>
|
||||
<if test="data.startTime != null">start_time = #{data.startTime},</if>
|
||||
<if test="data.endTime != null">end_time = #{data.endTime},</if>
|
||||
<if test="data.isEnabled != null">is_enabled = #{data.isEnabled},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteCustomerServiceById" parameterType="Long">
|
||||
delete from bst_customer_service where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteCustomerServiceByIds" parameterType="String">
|
||||
delete from bst_customer_service where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,65 @@
|
|||
package com.ruoyi.bst.customerService.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerService;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
|
||||
/**
|
||||
* 客服Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-04-02
|
||||
*/
|
||||
public interface CustomerServiceService
|
||||
{
|
||||
/**
|
||||
* 查询客服
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 客服
|
||||
*/
|
||||
public CustomerServiceVO selectCustomerServiceById(Long id);
|
||||
|
||||
/**
|
||||
* 查询客服列表
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 客服集合
|
||||
*/
|
||||
public List<CustomerServiceVO> selectCustomerServiceList(CustomerServiceQuery customerService);
|
||||
|
||||
/**
|
||||
* 新增客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertCustomerService(CustomerService customerService);
|
||||
|
||||
/**
|
||||
* 修改客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateCustomerService(CustomerService customerService);
|
||||
|
||||
/**
|
||||
* 批量删除客服
|
||||
*
|
||||
* @param ids 需要删除的客服主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCustomerServiceByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除客服信息
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteCustomerServiceById(Long id);
|
||||
|
||||
public int logicDel(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.ruoyi.bst.customerService.service;
|
||||
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public interface CustomerServiceValidator {
|
||||
|
||||
/**
|
||||
* 当前用户是否可编辑客服
|
||||
* @param customerId
|
||||
* @return
|
||||
*/
|
||||
boolean canEdit(Long customerId);
|
||||
|
||||
|
||||
boolean canDeleteAll(List<Long> ids);
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.ruoyi.bst.customerService.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.area.service.AreaService;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.bst.customerService.mapper.CustomerServiceMapper;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerService;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import com.ruoyi.bst.customerService.service.CustomerServiceService;
|
||||
|
||||
/**
|
||||
* 客服Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-04-02
|
||||
*/
|
||||
@Service
|
||||
public class CustomerServiceServiceImpl implements CustomerServiceService
|
||||
{
|
||||
@Autowired
|
||||
private CustomerServiceMapper customerServiceMapper;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
/**
|
||||
* 查询客服
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 客服
|
||||
*/
|
||||
@Override
|
||||
public CustomerServiceVO selectCustomerServiceById(Long id)
|
||||
{
|
||||
return customerServiceMapper.selectCustomerServiceById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客服列表
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 客服
|
||||
*/
|
||||
@Override
|
||||
public List<CustomerServiceVO> selectCustomerServiceList(CustomerServiceQuery customerService)
|
||||
{
|
||||
return customerServiceMapper.selectCustomerServiceList(customerService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertCustomerService(CustomerService customerService)
|
||||
{
|
||||
Long storeId = areaService.selectAreaById(customerService.getAreaId()).getUserId();
|
||||
customerService.setStoreId(storeId);
|
||||
customerService.setCreateTime(DateUtils.getNowDate());
|
||||
return customerServiceMapper.insertCustomerService(customerService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客服
|
||||
*
|
||||
* @param customerService 客服
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateCustomerService(CustomerService customerService)
|
||||
{
|
||||
return customerServiceMapper.updateCustomerService(customerService);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除客服
|
||||
*
|
||||
* @param ids 需要删除的客服主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCustomerServiceByIds(Long[] ids)
|
||||
{
|
||||
return customerServiceMapper.deleteCustomerServiceByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客服信息
|
||||
*
|
||||
* @param id 客服主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteCustomerServiceById(Long id)
|
||||
{
|
||||
return customerServiceMapper.deleteCustomerServiceById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int logicDel(List<Long> ids) {
|
||||
return customerServiceMapper.logicDel(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.ruoyi.bst.customerService.service.impl;
|
||||
|
||||
import com.ruoyi.bst.area.domain.AreaQuery;
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.area.service.AreaService;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
||||
import com.ruoyi.bst.customerService.mapper.CustomerServiceMapper;
|
||||
import com.ruoyi.bst.customerService.service.CustomerServiceValidator;
|
||||
import com.ruoyi.common.core.domain.vo.UserVO;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||
import com.ruoyi.system.user.domain.UserQuery;
|
||||
import com.ruoyi.system.user.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class CustomerServiceValidatorImpl implements CustomerServiceValidator {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CustomerServiceMapper customerServiceMapper;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public boolean canEdit(Long customerId) {
|
||||
return canOperate(Arrays.asList(customerId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDeleteAll(List<Long> ids) {
|
||||
return canOperate(ids);
|
||||
}
|
||||
|
||||
|
||||
// 是否可以操作客服
|
||||
private boolean canOperate(List<Long> customerIds) {
|
||||
|
||||
if (SecurityUtils.isSysAdmin()) {
|
||||
return true;
|
||||
}
|
||||
if (CollectionUtils.isEmptyElement(customerIds)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 查询客服
|
||||
CustomerServiceQuery query = new CustomerServiceQuery();
|
||||
query.setIds(customerIds);
|
||||
query.setScope(true);
|
||||
List<CustomerServiceVO> customerServiceList = customerServiceMapper.selectCustomerServiceList(query);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
// 判断是否可以操作客服
|
||||
for (Long customerId : customerIds) {
|
||||
CustomerServiceVO customerService = customerServiceList.stream()
|
||||
.filter(item -> item.getId().equals(customerId))
|
||||
.findFirst().orElse(null);
|
||||
if (customerService == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean canOperate = isStore(customerService, userId) || isAgent(customerService, userId);
|
||||
if (!canOperate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private boolean isStore(CustomerServiceVO customerService, Long userId) {
|
||||
return customerService != null && customerService.getStoreId() != null && customerService.getStoreId().equals(userId);
|
||||
}
|
||||
|
||||
|
||||
private boolean isAgent(CustomerServiceVO customerService, Long userId) {
|
||||
UserVO user = userService.selectUserById(customerService.getStoreId());
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
return user.getAgentId() != null && user.getAgentId().equals(userId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.ruoyi.bst.fault.service;
|
||||
|
||||
public interface FaultValidator {
|
||||
boolean canEdit(Long faultId);
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.ruoyi.bst.fault.service.impl;
|
||||
|
||||
import com.ruoyi.bst.fault.domain.FaultQuery;
|
||||
import com.ruoyi.bst.fault.domain.FaultVO;
|
||||
import com.ruoyi.bst.fault.mapper.FaultMapper;
|
||||
import com.ruoyi.bst.fault.service.FaultValidator;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FaultValidatorImpl implements FaultValidator {
|
||||
|
||||
@Autowired
|
||||
private FaultMapper faultMapper;
|
||||
|
||||
@Override
|
||||
public boolean canEdit(Long faultId) {
|
||||
return canOperate(Arrays.asList(faultId));
|
||||
}
|
||||
|
||||
private boolean canOperate(List<Long> faultIds) {
|
||||
if (SecurityUtils.isSysAdmin()){
|
||||
return true;
|
||||
}
|
||||
|
||||
FaultQuery query = new FaultQuery();
|
||||
query.setId(faultIds.get(0));
|
||||
query.setScope(true);
|
||||
List<FaultVO> faultList = faultMapper.selectFaultList(query);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
|
||||
// 判断是否可以处理故障
|
||||
for (Long faultId : faultIds) {
|
||||
FaultVO fault = faultList.stream()
|
||||
.filter(item -> item.getId().equals(faultId))
|
||||
.findFirst().orElse(null);
|
||||
if (fault == null) {
|
||||
return false;
|
||||
}
|
||||
boolean canOperate = isStore(fault, userId);
|
||||
if (!canOperate) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isStore(FaultVO fault, Long userId) {
|
||||
return fault != null && fault.getStoreId() != null && fault.getStoreId().equals(userId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
|
||||
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import com.ruoyi.bst.customerService.domain.enums.CustomerServiceStatus;
|
||||
import com.ruoyi.bst.customerService.service.CustomerServiceService;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/customerService")
|
||||
public class AppCustomerServiceController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CustomerServiceService customerServiceService;
|
||||
|
||||
@ApiOperation("获取客服列表")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CustomerServiceQuery query) {
|
||||
startPage();
|
||||
startOrderBy();
|
||||
query.setIsEnabled(CustomerServiceStatus.ENABLE.getStatus());
|
||||
return getDataTable(customerServiceService.selectCustomerServiceList(query));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.ruoyi.web.bst;
|
||||
|
||||
import com.ruoyi.bst.area.domain.AreaVO;
|
||||
import com.ruoyi.bst.area.service.AreaService;
|
||||
import com.ruoyi.bst.area.service.AreaValidator;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerService;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
|
||||
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
|
||||
import com.ruoyi.bst.customerService.service.CustomerServiceService;
|
||||
import com.ruoyi.bst.customerService.service.CustomerServiceValidator;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客服Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-04-02
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bst/customerService")
|
||||
public class CustomerServiceController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private CustomerServiceService customerServiceService;
|
||||
|
||||
@Autowired
|
||||
private CustomerServiceValidator customerServiceValidator;
|
||||
|
||||
@Autowired
|
||||
private AreaService areaService;
|
||||
|
||||
@Autowired
|
||||
private AreaValidator areaValidator;
|
||||
|
||||
/**
|
||||
* 查询客服列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(CustomerServiceQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出客服列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:export')")
|
||||
@Log(title = "客服", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CustomerServiceQuery query)
|
||||
{
|
||||
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
|
||||
ExcelUtil<CustomerServiceVO> util = new ExcelUtil<CustomerServiceVO>(CustomerServiceVO.class);
|
||||
util.exportExcel(response, list, "客服数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客服详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(customerServiceService.selectCustomerServiceById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增客服
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:add')")
|
||||
@Log(title = "客服", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody CustomerService customerService)
|
||||
{
|
||||
if (customerService.getAreaId() != null) {
|
||||
AreaVO area = areaService.selectAreaById(customerService.getAreaId());
|
||||
ServiceUtil.assertion(area==null, "当前运营区不存在");
|
||||
ServiceUtil.assertion(!areaValidator.canAddCustomerService(customerService.getAreaId()), "您无权插入客服");
|
||||
}
|
||||
return toAjax(customerServiceService.insertCustomerService(customerService));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客服
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:edit')")
|
||||
@Log(title = "客服", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody CustomerService customerService)
|
||||
{
|
||||
if (customerService.getAreaId() != null) {
|
||||
ServiceUtil.assertion(!areaValidator.canAddCustomerService(customerService.getAreaId()), "您无权修改该运营区下的信息");
|
||||
}
|
||||
|
||||
if (!customerServiceValidator.canEdit(customerService.getId())) {
|
||||
return AjaxResult.error("您没有权限修改ID为" + customerService.getId() + "的客服信息");
|
||||
}
|
||||
return toAjax(customerServiceService.updateCustomerService(customerService));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客服
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('bst:customerService:remove')")
|
||||
@Log(title = "客服", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable List<Long> ids)
|
||||
{
|
||||
if (!customerServiceValidator.canDeleteAll(ids)) {
|
||||
return AjaxResult.error("您没有权限删除ID为" + ids + "的客服信息");
|
||||
}
|
||||
return toAjax(customerServiceService.logicDel(ids));
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.ruoyi.bst.fault.domain.enums.FaultHandleStatus;
|
|||
import com.ruoyi.bst.fault.domain.enums.FaultStatus;
|
||||
import com.ruoyi.bst.fault.service.FaultConverter;
|
||||
import com.ruoyi.bst.fault.service.FaultService;
|
||||
import com.ruoyi.bst.fault.service.FaultValidator;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
@ -35,6 +36,8 @@ public class FaultController extends BaseController
|
|||
private FaultService faultService;
|
||||
@Autowired
|
||||
private FaultConverter faultConverter;
|
||||
@Autowired
|
||||
private FaultValidator faultValidator;
|
||||
|
||||
/**
|
||||
* 查询故障列表
|
||||
|
@ -118,7 +121,7 @@ public class FaultController extends BaseController
|
|||
@ApiOperation("处理申报信息")
|
||||
@PutMapping("/handle")
|
||||
public AjaxResult update(@RequestBody Fault fault) {
|
||||
if (!faultConverter.canEdit(fault.getId())){
|
||||
if (!faultValidator.canEdit(fault.getId())){
|
||||
return AjaxResult.error("您没有权限修改id为" + fault.getId() + "的故障申报");
|
||||
}
|
||||
faultService.updateFault(faultService.handle(fault));
|
||||
|
|
Loading…
Reference in New Issue
Block a user