师傅入驻接口开发,师傅detail订单修改接口开发,detail单列表查询接口修改
This commit is contained in:
parent
d3af40e1a2
commit
740a19a565
|
|
@ -127,7 +127,10 @@ public class OrderDetailController extends BaseController {
|
|||
}
|
||||
|
||||
// 编辑返回属性
|
||||
orderListResponse.setOrderMasterId(detail.getId());
|
||||
orderListResponse.setOrderDetailId(detail.getId());
|
||||
orderListResponse.setOrderDetailCode(detail.getCode());
|
||||
orderListResponse.setOrderMasterId(detail.getOrderMasterId());
|
||||
orderListResponse.setOrderMasterCode(detail.getOrderMasterCode());
|
||||
orderListResponse.setGoodsName(goods.getGoodsName());
|
||||
orderListResponse.setGoodsLogoUrl(goods.getGoodsImgUrl());
|
||||
orderListResponse.setDiscountMoney(financialDetail.getDiscountMoney());
|
||||
|
|
@ -141,7 +144,6 @@ public class OrderDetailController extends BaseController {
|
|||
orderListResponse.setOrderStatus(detail.getOrderStatus());
|
||||
orderListResponse.setPayStatus(orderMaster.getPayStatus());
|
||||
orderListResponse.setPayType(orderMaster.getPayType());
|
||||
orderListResponse.setOrderMasterCode(detail.getCode());
|
||||
orderListResponse.setStandardList(standardList);
|
||||
orderListResponse.setAddress(customerAddress.getAddress());
|
||||
orderListResponse.setServerTime(detail.getRevTime());
|
||||
|
|
@ -198,6 +200,18 @@ public class OrderDetailController extends BaseController {
|
|||
return toAjax(orderDetailService.updateOrderDetail(orderDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存详细订单
|
||||
*/
|
||||
@PostMapping("/app/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult appEdit(@RequestBody OrderDetail orderDetail) {
|
||||
if (UserConstants.ORDER_CODE_NOT_UNIQUE.equals(orderDetailService.checkOrderDetailCodeUnique(orderDetail))) {
|
||||
return error("修改详细订单'" + orderDetail.getCode() + "'失败,详细订单编码已存在");
|
||||
}
|
||||
return toAjax(orderDetailService.updateOrderDetail(orderDetail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验详细订单编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,13 +4,21 @@ import com.ghy.common.core.controller.BaseController;
|
|||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.web.pojo.vo.WorkerSettledRequest;
|
||||
import com.ghy.worker.domain.Worker;
|
||||
import com.ghy.worker.service.WorkerAreaService;
|
||||
import com.ghy.worker.service.WorkerGoodsCategoryService;
|
||||
import com.ghy.worker.service.WorkerService;
|
||||
import com.ghy.worker.service.WorkerSpecialSkillService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -26,6 +34,15 @@ public class WorkerController extends BaseController {
|
|||
@Autowired
|
||||
private WorkerService workerService;
|
||||
|
||||
@Autowired
|
||||
private WorkerAreaService workerAreaService;
|
||||
|
||||
@Autowired
|
||||
private WorkerGoodsCategoryService workerGoodsCategoryService;
|
||||
|
||||
@Autowired
|
||||
private WorkerSpecialSkillService specialSkillService;
|
||||
|
||||
@RequiresPermissions("worker:worker:view")
|
||||
@GetMapping()
|
||||
public String worker(){
|
||||
|
|
@ -54,4 +71,22 @@ public class WorkerController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@PostMapping("/settled")
|
||||
@ResponseBody
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult settled(@RequestBody WorkerSettledRequest request) {
|
||||
try {
|
||||
// TODO:参数校验
|
||||
// 入驻区域信息持久化
|
||||
workerAreaService.updateWorkerServArea(request.getWorkerId(), request.getWorkerAreas());
|
||||
// 入驻服务品类信息持久化
|
||||
workerGoodsCategoryService.updateWorkerGoodsCategory(request.getWorkerId(), request.getGoodsCategories());
|
||||
// 入驻特殊技能信息持久化
|
||||
specialSkillService.updateWorkerSpecialSkill(request.getWorkerId(), request.getSpecialSkills());
|
||||
return AjaxResult.success("保存成功");
|
||||
} catch (Exception e) {
|
||||
logger.error(ExceptionUtil.getExceptionMessage(e));
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ public class OrderListResponse {
|
|||
|
||||
private String orderMasterCode;
|
||||
|
||||
private Long orderDetailId;
|
||||
|
||||
private String orderDetailCode;
|
||||
|
||||
private String workerName;
|
||||
|
||||
private String workerPhone;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ghy.web.pojo.vo;
|
||||
|
||||
import com.ghy.worker.domain.WorkerArea;
|
||||
import com.ghy.worker.domain.WorkerGoodsCategory;
|
||||
import com.ghy.worker.domain.WorkerSpecialSkill;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 师傅入驻请求参数
|
||||
*
|
||||
* @author ydq
|
||||
* @date : 2022-06-14 15:35
|
||||
*/
|
||||
@Data
|
||||
public class WorkerSettledRequest {
|
||||
// 师傅id
|
||||
private Long workerId;
|
||||
|
||||
// 入驻区域
|
||||
private List<WorkerArea> workerAreas;
|
||||
|
||||
// 服务品类
|
||||
private List<WorkerGoodsCategory> goodsCategories;
|
||||
|
||||
// 特殊技能
|
||||
private List<WorkerSpecialSkill> specialSkills;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.worker.mapper;
|
||||
|
||||
import com.ghy.worker.domain.WorkerArea;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,6 +14,8 @@ public interface WorkerAreaMapper {
|
|||
|
||||
int insert(WorkerArea workerArea);
|
||||
|
||||
int batchInsert(@Param("workerAreas") List<WorkerArea> workerAreas);
|
||||
|
||||
int delete(Long[] ids);
|
||||
|
||||
int deleteByWorker(Long workerId);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.worker.mapper;
|
||||
|
||||
import com.ghy.worker.domain.WorkerGoodsCategory;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,6 +14,8 @@ public interface WorkerGoodsCategoryMapper {
|
|||
|
||||
int insert(WorkerGoodsCategory workerGoodsCategory);
|
||||
|
||||
int batchInsert(@Param("workerCategories") List<WorkerGoodsCategory> workerGoodsCategories);
|
||||
|
||||
int delete(Long[] ids);
|
||||
|
||||
int deleteByWorker(Long workerId);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.worker.mapper;
|
||||
|
||||
import com.ghy.worker.domain.WorkerSpecialSkill;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -13,6 +14,8 @@ public interface WorkerSpecialSkillMapper {
|
|||
|
||||
int insert(WorkerSpecialSkill workerArea);
|
||||
|
||||
int batchInsert(@Param("workerSpecialSkills") List<WorkerSpecialSkill> workerSpecialSkills);
|
||||
|
||||
int delete(Long[] ids);
|
||||
|
||||
int deleteByWorker(Long workerId);
|
||||
|
|
|
|||
|
|
@ -18,4 +18,6 @@ public interface WorkerAreaService {
|
|||
int deleteByWorker(Long workerId);
|
||||
|
||||
List<WorkerArea> getByWorker(Long workerId);
|
||||
|
||||
void updateWorkerServArea(Long workerId, List<WorkerArea> areas);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,4 +18,6 @@ public interface WorkerGoodsCategoryService {
|
|||
int deleteByWorker(Long workerId);
|
||||
|
||||
List<WorkerGoodsCategory> getByWorker(Long workerId);
|
||||
|
||||
void updateWorkerGoodsCategory(Long workerId, List<WorkerGoodsCategory> categories);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,5 @@ public interface WorkerSpecialSkillService {
|
|||
|
||||
List<WorkerSpecialSkill> getByWorker(Long workerId);
|
||||
|
||||
void updateWorkerSpecialSkill(Long workerId, List<WorkerSpecialSkill> skills);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@ package com.ghy.worker.service.impl;
|
|||
import com.ghy.worker.domain.WorkerArea;
|
||||
import com.ghy.worker.mapper.WorkerAreaMapper;
|
||||
import com.ghy.worker.service.WorkerAreaService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class WorkerAreaServiceImpl implements WorkerAreaService {
|
||||
|
|
@ -33,4 +37,26 @@ public class WorkerAreaServiceImpl implements WorkerAreaService {
|
|||
public List<WorkerArea> getByWorker(Long workerId) {
|
||||
return workerAreaMapper.getByWorker(workerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWorkerServArea(Long workerId, List<WorkerArea> areas) {
|
||||
List<WorkerArea> existAreas = getByWorker(workerId);
|
||||
Set<Long> existAreaIds = existAreas.stream().map(WorkerArea::getStreetId).collect(Collectors.toSet());
|
||||
Set<Long> areaIds = areas.stream().map(WorkerArea::getStreetId).collect(Collectors.toSet());
|
||||
|
||||
// 新的区域-已存在区域的差集,为需要新加入的区域
|
||||
List<WorkerArea> areas2Insert = areas.stream().distinct().filter(x -> !existAreaIds.contains(x.getStreetId()))
|
||||
.collect(Collectors.toList());
|
||||
// 已存在区域-新的区域的差集,为需要删除的区域
|
||||
List<Long> id2DelList = existAreas.stream().filter(x -> !areaIds.contains(x.getStreetId()))
|
||||
.map(WorkerArea::getWorkerAreaId).collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(areas2Insert)) {
|
||||
workerAreaMapper.batchInsert(areas2Insert);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(id2DelList)) {
|
||||
Long[] id2Del = new Long[]{};
|
||||
workerAreaMapper.delete(id2DelList.toArray(id2Del));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@ package com.ghy.worker.service.impl;
|
|||
import com.ghy.worker.domain.WorkerGoodsCategory;
|
||||
import com.ghy.worker.mapper.WorkerGoodsCategoryMapper;
|
||||
import com.ghy.worker.service.WorkerGoodsCategoryService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 师傅服务类目Service
|
||||
|
|
@ -38,4 +41,30 @@ public class WorkerGoodsCategoryServiceImpl implements WorkerGoodsCategoryServic
|
|||
public List<WorkerGoodsCategory> getByWorker(Long workerId) {
|
||||
return workerGoodsCategoryMapper.getByWorker(workerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWorkerGoodsCategory (Long workerId, List<WorkerGoodsCategory> categories) {
|
||||
List<WorkerGoodsCategory> existCategories = getByWorker(workerId);
|
||||
Set<Long> existCategoryIds = existCategories.stream().map(WorkerGoodsCategory::getGoodsCategoryId).collect(Collectors.toSet());
|
||||
Set<Long> categoryIds = categories.stream().map(WorkerGoodsCategory::getGoodsCategoryId).collect(Collectors.toSet());
|
||||
|
||||
// 新的区域-已存在区域的差集,为需要新加入的区域
|
||||
List<WorkerGoodsCategory> categories2Insert = CollectionUtils.subtract(categoryIds, existCategoryIds).stream().map(x -> {
|
||||
WorkerGoodsCategory obj = new WorkerGoodsCategory();
|
||||
obj.setWorkerId(workerId);
|
||||
obj.setGoodsCategoryId(x);
|
||||
return obj;
|
||||
}).collect(Collectors.toList());
|
||||
// 已存在区域-新的区域的差集,为需要删除的区域
|
||||
List<Long> id2DelList = existCategories.stream().filter(x -> !categoryIds.contains(x.getGoodsCategoryId()))
|
||||
.map(WorkerGoodsCategory::getWorkerGoodsCategoryId).collect(Collectors.toList());
|
||||
|
||||
if (!CollectionUtils.isEmpty(categories2Insert)) {
|
||||
workerGoodsCategoryMapper.batchInsert(categories2Insert);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(id2DelList)) {
|
||||
Long[] id2Del = new Long[]{};
|
||||
workerGoodsCategoryMapper.delete(id2DelList.toArray(id2Del));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,10 @@ public class WorkerSpecialSkillServiceImpl implements WorkerSpecialSkillService
|
|||
public List<WorkerSpecialSkill> getByWorker(Long workerId) {
|
||||
return workerSpecialSkillMapper.getByWorker(workerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWorkerSpecialSkill(Long workerId, List<WorkerSpecialSkill> skills) {
|
||||
workerSpecialSkillMapper.deleteByWorker(workerId);
|
||||
workerSpecialSkillMapper.batchInsert(skills);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="list" >
|
||||
INSERT INTO worker_area ( worker_id, province_id, city_id, district_id, street_id, create_by, create_time)
|
||||
VALUES
|
||||
<foreach collection="workerAreas" separator="," item="workerArea">
|
||||
(#{workerArea.workerId}, #{workerArea.provinceId}, #{workerArea.cityId}, #{workerArea.districtId},
|
||||
#{workerArea.streetId}, #{workerArea.workerId}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getByWorker" parameterType="Long" resultMap="WorkerAreaResult">
|
||||
SELECT * FROM worker_area WHERE worker_id = #{workerId}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="list" >
|
||||
INSERT INTO worker_goods_category ( worker_id, goods_category_id, create_by, create_time)
|
||||
VALUES
|
||||
<foreach collection="workerCategories" separator="," item="item">
|
||||
(#{item.workerId}, #{item.goodsCategoryId}, #{item.workerId}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getByWorker" parameterType="Long" resultMap="WorkerGoodsCategoryResult">
|
||||
SELECT * FROM worker_goods_category WHERE worker_id = #{workerId}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -42,6 +42,16 @@
|
|||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsert" parameterType="list" >
|
||||
INSERT INTO worker_special_skill ( worker_id, special_skill_id, credential, insurance, insurance_start, insurance_end,
|
||||
create_by, create_time)
|
||||
VALUES
|
||||
<foreach collection="workerSpecialSkills" separator="," item="item">
|
||||
(#{item.workerId}, #{item.specialSkillId}, #{item.credential}, #{item.insurance}, #{item.insuranceStart}
|
||||
#{item.insuranceEnd}, #{item.workerId}, sysdate())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getByWorker" parameterType="Long" resultMap="WorkerSpecialSkillResult">
|
||||
SELECT *
|
||||
FROM worker_special_skill
|
||||
|
|
|
|||
Loading…
Reference in New Issue