增加区域 类型划分

This commit is contained in:
cb 2025-08-30 12:28:04 +08:00
parent 65ca7bf9aa
commit 270ad85a10
8 changed files with 110 additions and 7 deletions

View File

@ -57,12 +57,41 @@ public class WorkerAreaController extends BaseController {
* 查询某个师傅的所有接单地区
*
* @param workerId 师傅ID
* @param serviceType 服务类型1=服务, 2=商品不传则查询所有
*/
@GetMapping("worker")
@ResponseBody
public AjaxResult getByWorker(Long workerId) {
public AjaxResult getByWorker(Long workerId, Integer serviceType) {
if (serviceType != null) {
// 根据服务类型查询
return AjaxResult.success(workerAreaService.getByWorkerIdAndType(workerId, serviceType));
} else {
// 查询所有区域保持向后兼容
return AjaxResult.success(workerAreaService.getByWorker(workerId));
}
}
/**
* 查询某个师傅的服务区域类型1
*
* @param workerId 师傅ID
*/
@GetMapping("worker/service")
@ResponseBody
public AjaxResult getServiceAreasByWorker(Long workerId) {
return AjaxResult.success(workerAreaService.getByWorkerIdAndType(workerId, 1));
}
/**
* 查询某个师傅的商品区域类型2
*
* @param workerId 师傅ID
*/
@GetMapping("worker/goods")
@ResponseBody
public AjaxResult getGoodsAreasByWorker(Long workerId) {
return AjaxResult.success(workerAreaService.getByWorkerIdAndType(workerId, 2));
}
@GetMapping("worker/edit")
@ResponseBody

View File

@ -415,15 +415,21 @@ public class WorkerController extends BaseController {
@ResponseBody
@Transactional(rollbackFor = Exception.class)
public AjaxResult settled(@RequestBody WorkerSettledRequest request) {
// 入驻区域信息持久化
workerAreaService.updateWorkerServArea(request.getWorkerId(), request.getWorkerAreas());
// 入驻服务区域信息持久化类型1
workerAreaService.updateWorkerAreaByType(request.getWorkerId(), request.getWorkerAreas(), 1);
// 入驻商品区域信息持久化类型2
workerAreaService.updateWorkerAreaByType(request.getWorkerId(), request.getWorkerGoodsAreas(), 2);
// 入驻服务品类信息持久化
workerGoodsCategoryService.updateWorkerGoodsCategory(request.getWorkerId(), request.getGoodsCategories());
// 更新师傅入驻类型为服务商
Worker worker = new Worker();
worker.setWorkerId(request.getWorkerId());
worker.setType(WorkerType.SP.getCode());
workerService.updateWorker(worker);
return AjaxResult.success("保存成功");
}
}

View File

@ -21,6 +21,9 @@ public class WorkerSettledRequest {
// 入驻区域
private List<WorkerArea> workerAreas;
// 入驻商品区域
private List<WorkerArea> workerGoodsAreas;
// 服务品类
private List<WorkerGoodsCategory> goodsCategories;

View File

@ -42,4 +42,9 @@ public class WorkerArea extends BaseEntity {
private List<String> streetIds;
private String mergerName;
/**
* 服务类型1=服务, 2=商品
*/
private Integer serviceType;
}

View File

@ -22,5 +22,15 @@ public interface WorkerAreaMapper {
List<WorkerArea> getByWorker(Long workerId);
/**
* 根据师傅ID和服务类型删除区域
*/
int deleteByWorkerIdAndType(@Param("workerId") Long workerId, @Param("serviceType") Integer serviceType);
/**
* 根据师傅ID和服务类型查询区域
*/
List<WorkerArea> getByWorkerIdAndType(@Param("workerId") Long workerId, @Param("serviceType") Integer serviceType);
List<WorkerArea> getWorkerAreaList(WorkerArea workerArea);
}

View File

@ -21,5 +21,21 @@ public interface WorkerAreaService {
void updateWorkerServArea(Long workerId, List<WorkerArea> areas);
/**
* 根据服务类型更新师傅区域
* @param workerId 师傅ID
* @param areas 区域列表
* @param serviceType 服务类型1=服务, 2=商品
*/
void updateWorkerAreaByType(Long workerId, List<WorkerArea> areas, Integer serviceType);
/**
* 根据师傅ID和服务类型查询区域
* @param workerId 师傅ID
* @param serviceType 服务类型1=服务, 2=商品
* @return 区域列表
*/
List<WorkerArea> getByWorkerIdAndType(Long workerId, Integer serviceType);
List<WorkerArea> getWorkerAreaList(WorkerArea area);
}

View File

@ -60,6 +60,28 @@ public class WorkerAreaServiceImpl implements WorkerAreaService {
}
}
@Override
public void updateWorkerAreaByType(Long workerId, List<WorkerArea> areas, Integer serviceType) {
if (areas == null || areas.isEmpty()) {
return;
}
// 先删除该师傅该类型的旧区域
workerAreaMapper.deleteByWorkerIdAndType(workerId, serviceType);
// 插入新的区域并设置类型
for (WorkerArea area : areas) {
area.setWorkerId(workerId);
area.setServiceType(serviceType); // 设置类型1=服务, 2=商品
workerAreaMapper.insert(area);
}
}
@Override
public List<WorkerArea> getByWorkerIdAndType(Long workerId, Integer serviceType) {
return workerAreaMapper.getByWorkerIdAndType(workerId, serviceType);
}
@Override
public List<WorkerArea> getWorkerAreaList(WorkerArea area) {
return workerAreaMapper.getWorkerAreaList(area);

View File

@ -15,11 +15,12 @@
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="mergerName" column="merger_name"/>
<result property="serviceType" column="service_type"/>
</resultMap>
<sql id="selectWorkerArea">
SELECT wa.worker_area_id, wa.worker_id, wa.province_id, wa.city_id, wa.district_id, wa.street_id, wa.create_by, wa.create_time,
wa.update_by, wa.update_time, wa.remark, sa.area_name, sa.merger_name
wa.update_by, wa.update_time, wa.remark, wa.service_type, sa.area_name, sa.merger_name
FROM worker_area wa
LEFT JOIN sys_area sa on wa.street_id = sa.area_id
</sql>
@ -31,6 +32,7 @@
<if test="cityId != null and cityId > 0">city_id,</if>
<if test="districtId != null and districtId > 0">district_id,</if>
<if test="streetId != null and streetId > 0">street_id,</if>
<if test="serviceType != null">service_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
@ -40,6 +42,7 @@
<if test="cityId != null and cityId > 0">#{cityId},</if>
<if test="districtId != null and districtId > 0">#{districtId},</if>
<if test="streetId != null and streetId > 0">#{streetId},</if>
<if test="serviceType != null">#{serviceType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
sysdate()
@ -47,11 +50,11 @@
</insert>
<insert id="batchInsert" parameterType="list" >
INSERT INTO worker_area ( worker_id, province_id, city_id, district_id, street_id, create_by, create_time)
INSERT INTO worker_area ( worker_id, province_id, city_id, district_id, street_id, service_type, create_by, create_time)
VALUES
<foreach collection="workerAreas" separator="," item="workerArea">
(#{workerArea.workerId}, #{workerArea.provinceId}, #{workerArea.cityId}, #{workerArea.districtId},
#{workerArea.streetId}, #{workerArea.workerId}, sysdate())
#{workerArea.streetId}, #{workerArea.serviceType}, #{workerArea.workerId}, sysdate())
</foreach>
</insert>
@ -60,6 +63,11 @@
WHERE wa.worker_id = #{workerId}
</select>
<select id="getByWorkerIdAndType" resultMap="WorkerAreaResult">
<include refid="selectWorkerArea"></include>
WHERE wa.worker_id = #{workerId} AND wa.service_type = #{serviceType}
</select>
<select id="getWorkerAreaList" parameterType="com.ghy.worker.domain.WorkerArea" resultMap="WorkerAreaResult">
<include refid="selectWorkerArea"></include>
<where>
@ -97,6 +105,10 @@
DELETE FROM worker_area WHERE worker_id = #{workerId}
</delete>
<delete id="deleteByWorkerIdAndType">
DELETE FROM worker_area WHERE worker_id = #{workerId} AND service_type = #{serviceType}
</delete>
<delete id="delete" parameterType="Long">
DELETE FROM worker_area WHERE worker_area_id IN
<foreach collection="array" item="areaId" open="(" separator="," close=")">