Commit 70abf9cf authored by 李灿灿's avatar 李灿灿

订单详情接口

parent deb58761
...@@ -18,6 +18,10 @@ public class OrderConstants { ...@@ -18,6 +18,10 @@ public class OrderConstants {
* 订单id不可为空 * 订单id不可为空
*/ */
public static final String ORDER_ID_IS_EMPTY = "订单id不可为空"; public static final String ORDER_ID_IS_EMPTY = "订单id不可为空";
/**
* 附件id不可为空
*/
public static final String ENCLOSURE_ID_IS_EMPTY = "附件id不可为空";
/** /**
* 订单已办结,不可操作 * 订单已办结,不可操作
*/ */
......
package com.yifu.cloud.plus.v1.yifu.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author licancan
* @description 订单详情VO
* @date 2022-08-29 15:18:50
*/
@Data
@Schema(description = "订单详情VO")
public class OrderDetailVO implements Serializable {
private static final long serialVersionUID = -6669349004826405691L;
/**
* 创建人姓名(下单人)
*/
@Schema(description = "创建人姓名(下单人)")
private String createName;
/**
* 创建时间(下单时间)
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间(下单时间)")
private LocalDateTime createTime;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String deptName;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 客户名称
*/
@Schema(description = "客户名称")
private String customerName;
/**
* 订单状态 0待办理 1办理中 2已办结
*/
@Schema(description = "订单状态 0待办理 1办理中 2已办结")
private Integer orderStatus;
/**
* 订单内容
*/
@Schema(description = "订单内容")
private String orderContent;
/**
* 原始单据
*/
@Schema(description = "原始单据")
private List<TOrderEnclosure> orderEnclosure;
}
...@@ -4,15 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -4,15 +4,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService; import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
...@@ -71,4 +70,30 @@ public class OrderController { ...@@ -71,4 +70,30 @@ public class OrderController {
return tOrderService.handleOrder(id,status); return tOrderService.handleOrder(id,status);
} }
/**
* 通过id查询详情
*
* @author licancan
* @param id 订单id
* @return {@link R<OrderDetailVO>}
*/
@Operation(summary = "通过id查询详情", description = "通过id查询详情")
@GetMapping("/{id}")
public R<OrderDetailVO> getInsuranceDetailById(@PathVariable("id") String id) {
return tOrderService.getOrderDetailById(id);
}
/**
* 附件预览下载地址
*
* @author licancan
* @param id 附件表id
* @return {@link R}
*/
@Schema(description = "附件预览下载地址,附件表id")
@GetMapping("/getEnclosureUrl/{id}")
public R getEnclosureUrl(@PathVariable String id) {
return tOrderService.getEnclosureUrl(id);
}
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -47,4 +48,13 @@ public interface TOrderMapper extends BaseMapper<TOrder> { ...@@ -47,4 +48,13 @@ public interface TOrderMapper extends BaseMapper<TOrder> {
* @return {@link List< OrderListVO>} * @return {@link List< OrderListVO>}
*/ */
List<OrderListVO> getOrderList(@Param("param") OrderListParam param); List<OrderListVO> getOrderList(@Param("param") OrderListParam param);
/**
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link OrderDetailVO}
*/
OrderDetailVO getOrderDetailById(@Param("id") String id);
} }
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
...@@ -46,4 +47,22 @@ public interface TOrderService extends IService<TOrder> { ...@@ -46,4 +47,22 @@ public interface TOrderService extends IService<TOrder> {
* @return {@link R<String>} * @return {@link R<String>}
*/ */
R<String> handleOrder(String id, Integer status); R<String> handleOrder(String id, Integer status);
/**
* 通过id查询详情
*
* @author licancan
* @param id
* @return {@link R<OrderDetailVO>}
*/
R<OrderDetailVO> getOrderDetailById(String id);
/**
* 附件预览下载地址
*
* @author licancan
* @param id 附件表id
* @return {@link R}
*/
R getEnclosureUrl(String id);
} }
package com.yifu.cloud.plus.v1.yifu.order.service.impl; package com.yifu.cloud.plus.v1.yifu.order.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser; import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils; import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants; import com.yifu.cloud.plus.v1.yifu.order.constants.OrderConstants;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.entity.TOrderEnclosure;
import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper; import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderEnclosureService;
import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService; import com.yifu.cloud.plus.v1.yifu.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO; import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.compress.utils.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.net.URL;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -31,6 +38,10 @@ import java.util.Optional; ...@@ -31,6 +38,10 @@ import java.util.Optional;
@Slf4j @Slf4j
@Service @Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService { public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {
@Resource
private TOrderEnclosureService tOrderEnclosureService;
@Resource
private OSSUtil ossUtil;
/** /**
* 订单列表分页查询 * 订单列表分页查询
...@@ -93,7 +104,59 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme ...@@ -93,7 +104,59 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
byId.setUpdateName(user.getNickname()); byId.setUpdateName(user.getNickname());
byId.setUpdateTime(LocalDateTime.now()); byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId); this.updateById(byId);
// todo 如果是办结完成同步给ekp
return R.ok(OrderConstants.OPERATE_SUCCESS); return R.ok(OrderConstants.OPERATE_SUCCESS);
} }
/**
* 通过id查询详情
*
* @param id
* @return {@link R<OrderDetailVO>}
* @author licancan
*/
@Override
public R<OrderDetailVO> getOrderDetailById(String id) {
if (StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ORDER_ID_IS_EMPTY);
}
OrderDetailVO orderDetailVO = this.baseMapper.getOrderDetailById(id);
//处理订单附件
if (Optional.ofNullable(orderDetailVO).isPresent()){
List<TOrderEnclosure> list = tOrderEnclosureService.list(Wrappers.<TOrderEnclosure>query().lambda()
.eq(TOrderEnclosure::getOrderNo, orderDetailVO.getOrderNo())
.eq(TOrderEnclosure::getEnclosureFlag,CommonConstants.ZERO_INT)
.eq(TOrderEnclosure::getDeleteFlag,CommonConstants.ZERO_INT)
);
if (CollectionUtils.isNotEmpty(list)){
orderDetailVO.setOrderEnclosure(list);
}else {
orderDetailVO.setOrderEnclosure(Lists.newArrayList());
}
}
return R.ok(orderDetailVO);
}
/**
* 附件预览下载地址
*
* @param id 附件表id
* @return {@link R}
* @author licancan
*/
@Override
public R getEnclosureUrl(String id) {
if(StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ENCLOSURE_ID_IS_EMPTY);
}
TOrderEnclosure orderEnclosure = tOrderEnclosureService.getById(id);
if (!Optional.ofNullable(orderEnclosure).isPresent()) {
return R.failed(OrderConstants.DATA_IS_EMPTY);
}
String enclosureAddress = orderEnclosure.getEnclosureAddress();
log.info("key:"+enclosureAddress);
URL url = ossUtil.getObjectUrl(null, orderEnclosure.getEnclosureAddress());
return new R<>(url.toString());
}
} }
...@@ -115,4 +115,18 @@ ...@@ -115,4 +115,18 @@
ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC
</select> </select>
<select id="getOrderDetailById" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderDetailVO">
select
t.CREATE_NAME as createName,
t.CREATE_TIME as createTime,
t.DEPT_NO as deptNo,
t.DEPT_NAME as deptName,
t.ORDER_NO as orderNo,
t.CUSTOMER_NAME as customerName,
t.ORDER_STATUS as orderStatus,
t.ORDER_CONTENT as orderContent
from t_order t
where t.ID = #{id}
</select>
</mapper> </mapper>
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