Commit 30321953 authored by shangtx's avatar shangtx

feat: 订单管理-订单列表详情

parent 236ac225
package com.onsiteservice.admin.controller.order;
import com.onsiteservice.admin.controller.order.dto.OrderPageDTO;
import com.onsiteservice.admin.controller.order.vo.OrderDetailVO;
import com.onsiteservice.admin.controller.order.vo.OrderPageVO;
import com.onsiteservice.admin.service.order.AdminOrderService;
import com.onsiteservice.common.annotation.dict.Dict;
import com.onsiteservice.entity.order.ServiceOrder;
import com.onsiteservice.core.result.Result;
import com.onsiteservice.dao.common.page.PageInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import javax.validation.constraints.Positive;
import static com.onsiteservice.core.result.ResultGenerator.success;
/**
* @author 商天翔
* @date 2022-07-14 15:11
* @description ServiceOrderController控制类
*/
@ApiIgnore
@Api(tags = "ServiceOrderController")
@RestController
@RequestMapping("/order")
@Validated
public class ServiceOrderController {
@Resource
private AdminOrderService adminOrderService;
@Dict(code = "BIZ0002", name = "orderStatus")
@ApiOperation(value = "分页查询列表", notes = "作者: 商天翔")
@PostMapping("/page")
public Result<PageInfoVO<OrderPageVO>> getPage(@RequestBody @NonNull @Validated OrderPageDTO param) {
return success(adminOrderService.getPage(param), "获取分页列表");
}
@ApiOperation(value = "根据id查询", notes = "作者: 商天翔")
@GetMapping("/{id}")
public Result<OrderDetailVO> getDetails(@PathVariable @Positive Long id) {
return success(adminOrderService.getOrderDetail(id));
}
}
package com.onsiteservice.admin.controller.order.convert;
import com.onsiteservice.admin.controller.order.vo.OrderDetailVO;
import com.onsiteservice.entity.order.ServiceOrder;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
@Mapper(componentModel = "spring")
public interface OrderConvert {
@Mappings({})
OrderDetailVO toVO(ServiceOrder order);
}
package com.onsiteservice.admin.controller.order.dto;
import com.onsiteservice.dao.common.page.PageParams;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class OrderPageDTO extends PageParams {
@ApiModelProperty("订单号")
private String orderNo;
@ApiModelProperty("服务类型id")
private Integer subclassId;
@ApiModelProperty("客户服务手机号")
private String phone;
@ApiModelProperty("期望上门时间")
private Date expectArrivalTimeBegin;
private Date expectArrivalTimeEnd;
@ApiModelProperty("订单状态:1已预约,2已派单,3进行中,4完成,5取消,6已评价")
private Integer orderStatus;
@ApiModelProperty("创建时间(下单时间)")
private Date createTimeBegin;
private Date createTimeEnd;
@ApiModelProperty("地址")
private String address;
}
package com.onsiteservice.admin.controller.order.vo;
import com.onsiteservice.common.order.vo.ServiceOrderLogVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 订单详情VO
*/
@Data
public class OrderDetailVO {
@ApiModelProperty(value = "订单id")
private Long id;
@ApiModelProperty(value = "订单号")
private String orderNo;
@ApiModelProperty(value = "客户名")
private String name;
@ApiModelProperty(value = "客户手机号")
private String phone;
@ApiModelProperty(value = "客户下单服务地址")
private String address;
private Integer orderStatus;
@ApiModelProperty(value = "期望上门时间")
private Date expectArrivalTime;
@ApiModelProperty(value = "服务数量")
private Integer num;
@ApiModelProperty(value = "子类服务图片,待受理标题图片url地址")
private String subclassImg;
@ApiModelProperty(value = "服务说明")
private String demandDesc;
private String serviceName;
@ApiModelProperty(value = "下单备注信息")
private String remark;
@ApiModelProperty(value = "订单创建时间")
private Date createTime;
@ApiModelProperty(value = "订单修改时间")
private Date modifyTime;
@ApiModelProperty(value = "客户上传需求图片,最多8张")
private List<String> demandImgUrls;
@ApiModelProperty(value = "订单流程信息")
private List<ServiceOrderLogVO> process;
}
package com.onsiteservice.admin.controller.order.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 订单分页VO
*/
@Data
public class OrderPageVO {
private Long id;
@ApiModelProperty("订单号")
private String orderNo;
@ApiModelProperty("服务名")
private String serviceName;
private String userName;
@ApiModelProperty("账号")
private Long accountNo;
@ApiModelProperty("服务类型id")
private Integer subclassId;
@ApiModelProperty("地址")
private String address;
@ApiModelProperty("客户服务手机号")
private String phone;
@ApiModelProperty("期望上门时间")
private Date expectArrivalTime;
@ApiModelProperty("服务数量")
private Integer num;
@ApiModelProperty("订单状态:1已预约,2已派单,3进行中,4完成,5取消,6已评价")
private Integer orderStatus;
@ApiModelProperty("订单价格")
private BigDecimal price;
@ApiModelProperty("创建时间")
private Date createTime;
}
......@@ -16,8 +16,11 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;
import java.util.List;
import static com.onsiteservice.core.result.ResultGenerator.fail;
import static com.onsiteservice.core.result.ResultGenerator.success;
......@@ -38,6 +41,14 @@ public class ServiceValuatorController {
private ServiceValuatorService serviceValuatorService;
@ApiOperation(value = "根据姓名查询")
@GetMapping("search")
public Result<List<ServiceValuatorVO>> getDetails(@RequestParam("name") @ApiParam(name = "name", value = "估价员姓名") @PathVariable @NotBlank String name) {
return success(serviceValuatorService.selectByName(name));
}
@ApiOperation(value = "分页查询列表")
@PostMapping("page")
public Result<PageInfoVO<ServiceValuatorVO>> getPage(@RequestBody @NonNull @Validated PageServiceValuatorDTO dto) {
......@@ -56,16 +67,4 @@ public class ServiceValuatorController {
return serviceValuatorService.save(dto, userId) == 1 ? success() : fail("新增失败");
}
@ApiOperation(value = "修改")
@PutMapping("update")
public Result update(@RequestBody @NonNull @Validated UpdateServiceValuatorDTO dto, @CurrentUserId Long userId) {
return serviceValuatorService.update(dto, userId) == 1 ? success() : fail("修改失败");
}
@ApiOperation(value = "根据id删除")
@DeleteMapping("/{id}")
public Result deleteById(@ApiParam(name = "id", value = "估价员id") @PathVariable @Positive Long id, @CurrentUserId Long userId) {
return serviceValuatorService.delete(id, userId) == 1 ? success() : fail("删除失败");
}
}
......@@ -10,6 +10,7 @@ import lombok.ToString;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class ServiceValuatorVO {
......@@ -36,4 +37,7 @@ public class ServiceValuatorVO {
*/
private Date modifyTime;
@ApiModelProperty(value = "估价员已被指派的时间")
private List<Date> assignTime;
}
\ No newline at end of file
package com.onsiteservice.admin.mapper.order;
import com.onsiteservice.admin.controller.order.dto.OrderPageDTO;
import com.onsiteservice.admin.controller.order.vo.OrderPageVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author 商天翔
* @date 2022-07-14 15:11
* @description ServiceOrderBizMapper业务接口
*/
public interface ServiceOrderBizMapper {
List<OrderPageVO> getPage(@Param("param") OrderPageDTO param);
}
......@@ -3,6 +3,7 @@ package com.onsiteservice.admin.mapper.service;
import com.onsiteservice.admin.controller.service.dto.PageServiceValuatorDTO;
import com.onsiteservice.entity.service.ServiceValuator;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -10,4 +11,6 @@ public interface ServiceValuatorBizMapper {
List<ServiceValuator> selectServiceValuatorPage(PageServiceValuatorDTO dto);
@Select("select * from service_valuator where name like '%${name}%' order by create_time asc")
List<ServiceValuator> selectByNameLike(String name);
}
package com.onsiteservice.admin.service.order;
import com.github.pagehelper.PageHelper;
import com.onsiteservice.admin.controller.order.convert.OrderConvert;
import com.onsiteservice.admin.controller.order.dto.OrderPageDTO;
import com.onsiteservice.admin.controller.order.vo.OrderDetailVO;
import com.onsiteservice.admin.controller.order.vo.OrderPageVO;
import com.onsiteservice.admin.mapper.order.ServiceOrderBizMapper;
import com.onsiteservice.common.order.vo.ServiceOrderLogVO;
import com.onsiteservice.constant.constant.BizConstants;
import com.onsiteservice.constant.enums.BizCodeEnum;
import com.onsiteservice.core.exception.ServiceException;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.dao.mapper.service.ServiceOrderImgMapper;
import com.onsiteservice.dao.mapper.service.ServiceOrderLogMapper;
import com.onsiteservice.dao.mapper.service.ServiceSubclassMapper;
import com.onsiteservice.entity.order.ServiceOrder;
import com.onsiteservice.entity.service.ServiceOrderImg;
import com.onsiteservice.entity.service.ServiceOrderLog;
import com.onsiteservice.util.AttrCopyUtils;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Condition;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author 商天翔
* @date 2022-07-14 15:11
* @description ServiceOrderService服务类
*/
@Service
@Transactional(rollbackFor = Exception.class)
@AllArgsConstructor(onConstructor_ = {@Autowired})
public class AdminOrderService extends AbstractMapper<ServiceOrder> {
private ServiceOrderBizMapper serviceOrderBizMapper;
private OrderConvert orderConvert;
private ServiceOrderImgMapper serviceOrderImgMapper;
private ServiceOrderLogMapper serviceOrderLogMapper;
private ServiceSubclassMapper serviceSubclassMapper;
/**
* 分页查询列表
*/
public PageInfoVO<OrderPageVO> getPage(OrderPageDTO param) {
PageHelper.startPage(param.getPage(), param.getSize());
return new PageInfoVO<>(serviceOrderBizMapper.getPage(param));
}
/**
* 获取订单详情
*/
public OrderDetailVO getOrderDetail(Long id) {
// 订单信息
ServiceOrder order = selectByPrimaryKey(id);
if (order == null) {
throw new ServiceException(BizCodeEnum.SERVICE_ORDER_NOT_EXIST);
}
// 基础订单信息
var serviceOrderVO = orderConvert.toVO(order);
// 服务信息
var subService = serviceSubclassMapper.selectByPrimaryKey(order.getSubclassId());
serviceOrderVO.setServiceName(subService.getServiceName());
// 需求图片
Condition c1 = new Condition(ServiceOrderImg.class);
c1.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, serviceOrderVO.getId());
List<ServiceOrderImg> serviceOrderImgList = serviceOrderImgMapper.selectByCondition(c1);
List<String> serviceOrderImgUrlList = serviceOrderImgList.parallelStream().map(ServiceOrderImg::getUrl).collect(Collectors.toList());
serviceOrderVO.setDemandImgUrls(serviceOrderImgUrlList);
// 流程信息
Condition c2 = new Condition(ServiceOrderLog.class);
c2.createCriteria().andEqualTo(BizConstants.OrderConstants.ORDER_ID, id);
List<ServiceOrderLog> serviceOrderLogList = serviceOrderLogMapper.selectByCondition(c2);
List<ServiceOrderLogVO> serviceOrderLogVOList = serviceOrderLogList.parallelStream()
.map(e -> AttrCopyUtils.copy(e, new ServiceOrderLogVO()))
.sorted(Comparator.comparing(ServiceOrderLogVO::getCreateTime).reversed()).collect(Collectors.toList());
serviceOrderVO.setProcess(serviceOrderLogVOList);
return serviceOrderVO;
}
}
package com.onsiteservice.admin.service.service;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import com.onsiteservice.admin.controller.service.dto.PageServiceValuatorDTO;
import com.onsiteservice.admin.controller.service.dto.SaveServiceValuatorDTO;
import com.onsiteservice.admin.controller.service.dto.UpdateServiceValuatorDTO;
......@@ -13,8 +14,10 @@ import com.onsiteservice.core.result.Result;
import com.onsiteservice.core.result.ResultGenerator;
import com.onsiteservice.dao.common.AbstractMapper;
import com.onsiteservice.dao.common.page.PageInfoVO;
import com.onsiteservice.dao.mapper.service.ServiceValuatorAssignMapper;
import com.onsiteservice.dao.mapper.user.UserMapper;
import com.onsiteservice.entity.service.ServiceValuator;
import com.onsiteservice.entity.service.ServiceValuatorAssign;
import com.onsiteservice.entity.service.ServiceWorker;
import com.onsiteservice.entity.user.User;
import com.onsiteservice.util.AttrCopyUtils;
......@@ -25,7 +28,9 @@ import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Condition;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
......@@ -42,9 +47,11 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
@Resource
private ServiceValuatorBizMapper serviceValuatorBizMapper;
@Resource
private UserMapper userMapper;
@Resource
private ServiceValuatorAssignMapper serviceValuatorAssignMapper;
;
/**
......@@ -88,29 +95,38 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
}
public int update(UpdateServiceValuatorDTO dto, Long userId) {
log.info("valuator update dto: {}, userId: {}", dto, userId);
// checkAuth(userId);
public List<ServiceValuatorVO> selectByName(String name) {
log.info("valuator selectByName name: {}", name);
return this.updateByPrimaryKeySelective(AttrCopyUtils.copy(dto, new ServiceValuator()));
List<ServiceValuator> serviceValuatorList = serviceValuatorBizMapper.selectByNameLike(name);
return handle(serviceValuatorList);
}
public int delete(Long id, Long userId) {
log.info("valuator delete id: {}, userId: {}", id, userId);
private List<ServiceValuatorVO> handle(List<ServiceValuator> serviceValuatorList){
if (CollectionUtils.isEmpty(serviceValuatorList)) {
return Lists.newArrayList();
}
// checkAuth(userId);
// 估价员id列表
List<Long> valuatorIds = serviceValuatorList.parallelStream().map(ServiceValuator::getId).collect(Collectors.toList());
// 已被指派的时间
List<ServiceValuatorAssign> serviceValuatorAssignList = serviceValuatorAssignMapper.selectByDeletedAndIdListAndAssignTime(valuatorIds);
Map<Long, List<ServiceValuatorAssign>> serviceValuatorAssignMap =
serviceValuatorAssignList.parallelStream()
.collect(Collectors.groupingBy(ServiceValuatorAssign::getValuatorId));
return this.deleteByPrimaryKey(id);
}
return serviceValuatorList.parallelStream().map(e1 -> {
ServiceValuatorVO serviceValuatorVO = AttrCopyUtils.copy(e1, new ServiceValuatorVO());
// 估价员已经被指派的时间
List<ServiceValuatorAssign> assigns = serviceValuatorAssignMap.getOrDefault(e1.getId(), Lists.newArrayList());
List<Date> assignTimes = assigns.parallelStream().map(ServiceValuatorAssign::getAssignTime).collect(Collectors.toList());
serviceValuatorVO.setAssignTime(assignTimes);
private void checkAuth(Long userId) {
User user = userMapper.selectByPrimaryKey(userId);
if (Objects.isNull(user) || !user.getRoleType().equals(ServiceUserTypeEnum.ADMIN.getId())) {
throw new ServiceException(BizCodeEnum.NO_AUTH);
}
return serviceValuatorVO;
}).collect(Collectors.toList());
}
......
<?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.onsiteservice.admin.mapper.order.ServiceOrderBizMapper">
<select id="getPage" resultType="com.onsiteservice.admin.controller.order.vo.OrderPageVO">
select t.id,
t.order_no,
t.service_name,
t.account_no,
t.subclass_id,
t.address_id,
t.phone,
t.expect_arrival_time,
t.num,
t.order_status,
t.price,
t.create_time,
ifnull(t2.user_name, t2.nick_name) user_name
from service_order t
join user t2 on t.account_no = t2.id
<where>
<if test="param.orderNo != null">
and t.order_no like "%"#{param.orderNo}"%"
</if>
<if test="param.subclassId != null">
and t.subclass_id = #{param.subclassId}
</if>
<if test="param.phone != null">
and t.phone like "%"#{param.phone}"%"
</if>
<if test="param.expectArrivalTimeBegin != null and param.expectArrivalTimeEnd != null">
and t.expect_arrival_time <![CDATA[>]]> #{param.expectArrivalTimeBegin}
and t.expect_arrival_time <![CDATA[<]]> date_add(#{param.expectArrivalTimeEnd}, INTERVAL 1 DAY)
</if>
<if test="param.orderStatus != null">
and t.order_status = #{param.orderStatus}
</if>
<if test="param.createTimeBegin != null and param.createTimeEnd != null">
and t.create_time <![CDATA[>]]> #{param.createTimeBegin}
and t.create_time <![CDATA[<]]> date_add(#{param.createTimeEnd}, INTERVAL 1 DAY)
</if>
<if test="param.address != null">
and t.address like "%"#{param.address}"%"
</if>
</where>
order by
<choose>
<when test="param.sort != null and param.sort != ''">
${param.sort} ${param.order}
</when>
<otherwise>
t.id desc
</otherwise>
</choose>
</select>
</mapper>
......@@ -71,7 +71,11 @@ public class DictConstants {
/**
* ------------------业务自定义字典数据------------------
*/
// 小程序用户角色类型
public final static String ROLE_TYPE = "BIZ0001";
// 订单状态
public final static String ORDER_STATUS = "BIZ0002";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment