Commit b79864b0 authored by 李灿灿's avatar 李灿灿

订单 部分接口

parent a674ae2f
package com.yifu.cloud.plus.v1.yifu.order.constants;
/**
* @author licancan
* @description 订单常量
* @date 2022-08-29 11:36:21
*/
public class OrderConstants {
/**
* 状态不合法
*/
public static final String STATUS_ERROR = "状态不合法";
/**
* 数据不存在
*/
public static final String DATA_IS_EMPTY = "数据不存在";
/**
* 订单id不可为空
*/
public static final String ORDER_ID_IS_EMPTY = "订单id不可为空";
/**
* 订单已办结,不可操作
*/
public static final String ORDER_IS_HANDLED= "订单已办结,不可操作";
/**
* 操作成功
*/
public static final String OPERATE_SUCCESS = "操作成功";
}
package com.yifu.cloud.plus.v1.yifu.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author licancan
* @description 订单列表入参
* @date 2022-08-29 09:10:02
*/
@Data
@Schema(description = "订单列表入参")
public class OrderListParam implements Serializable {
private static final long serialVersionUID = 2575913025864285604L;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 订单开始时间
*/
@Schema(description = "订单开始时间")
private String startDate;
/**
* 订单结束时间
*/
@Schema(description = "订单结束时间")
private String endDate;
/**
* 创建人姓名(下单人)
*/
@Schema(description = "创建人姓名(下单人)")
private String createName;
/**
* 客户名称
*/
@Schema(description = "客户名称")
private String customerName;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String deptName;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 订单状态 0待办理 1办理中 2已办结
*/
@Schema(description = "订单状态 0待办理 1办理中 2已办结")
private Integer orderStatus;
/**
* 订单id集合
*/
@Schema(description = "订单id集合")
private List<String> idList;
}
package com.yifu.cloud.plus.v1.yifu.order.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author licancan
* @description 订单列表VO
* @date 2022-08-29 09:16:07
*/
@Data
@Schema(description = "订单列表VO")
public class OrderListVO implements Serializable{
private static final long serialVersionUID = 4067597933537194227L;
/**
* 主键
*/
@Schema(description = "主键")
private String id;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private String orderNo;
/**
* 创建时间(下单时间)
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建时间(下单时间)")
private LocalDateTime createTime;
/**
* 创建人姓名(下单人)
*/
@Schema(description = "创建人姓名(下单人)")
private String createName;
/**
* 客户名称
*/
@Schema(description = "客户名称")
private String customerName;
/**
* 项目名称
*/
@Schema(description = "项目名称")
private String deptName;
/**
* 项目编码
*/
@Schema(description = "项目编码")
private String deptNo;
/**
* 订单状态 0待办理 1办理中 2已办结
*/
@Schema(description = "订单状态 0待办理 1办理中 2已办结")
private Integer orderStatus;
}
package com.yifu.cloud.plus.v1.yifu.order.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.order.service.TOrderService;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
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 java.util.List;
/**
* @author licancan
* @description 订单controller
* @date 2022-08-29 09:05:23
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/order")
@Tag(name = "订单相关")
public class OrderController {
@Resource
private TOrderService tOrderService;
/**
* 订单列表分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link R<IPage<OrderListVO>>}
*/
@Operation(summary = "订单列表分页查询", description = "订单列表分页查询")
@GetMapping("/getOrderPageList")
public R<IPage<OrderListVO>> getOrderPageList(Page<OrderListParam> page, OrderListParam param) {
return R.ok(tOrderService.getOrderPageList(page,param));
}
/**
* 订单列表不分页查询
*
* @author licancan
* @param param
* @return {@link R<List<OrderListVO>>}
*/
@Operation(summary = "订单列表不分页查询", description = "订单列表不分页查询")
@GetMapping("/getOrderList")
public R<List<OrderListVO>> getOrderList(OrderListParam param) {
return R.ok(tOrderService.getOrderList(param));
}
/**
* 变更订单状态
*
* @author licancan
* @param id
* @param status
* @return {@link R< String>}
*/
@GetMapping("/handleOrder")
@Operation(summary = "变更订单状态", description = "变更订单状态")
public R<String> handleOrder(@RequestParam String id,@RequestParam Integer status) {
return tOrderService.handleOrder(id,status);
}
}
...@@ -2,8 +2,15 @@ package com.yifu.cloud.plus.v1.yifu.order.mapper; ...@@ -2,8 +2,15 @@ package com.yifu.cloud.plus.v1.yifu.order.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author licancan * @author licancan
...@@ -13,5 +20,31 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -13,5 +20,31 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface TOrderMapper extends BaseMapper<TOrder> { public interface TOrderMapper extends BaseMapper<TOrder> {
/**
* 订单列表分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link IPage<OrderListVO>}
*/
IPage<OrderListVO> getOrderPageList(Page<OrderListParam> page,@Param("param") OrderListParam param);
/**
* 导出勾选查询结果
*
* @author licancan
* @param idList
* @return {@link List<OrderListVO>}
*/
List<OrderListVO> getOrderListBySelect(@Param("idList") List<String> idList);
/**
* 导出非勾选查询结果
*
* @author licancan
* @param param
* @return {@link List< OrderListVO>}
*/
List<OrderListVO> getOrderList(@Param("param") OrderListParam param);
} }
package com.yifu.cloud.plus.v1.yifu.order.service; package com.yifu.cloud.plus.v1.yifu.order.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.order.entity.TOrder; import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListParam;
import com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO;
import java.util.List;
/** /**
* @author licancan * @author licancan
...@@ -11,4 +18,32 @@ import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder; ...@@ -11,4 +18,32 @@ import com.yifu.cloud.plus.v1.yifu.order.entity.TOrder;
*/ */
public interface TOrderService extends IService<TOrder> { public interface TOrderService extends IService<TOrder> {
/**
* 订单列表分页查询
*
* @author licancan
* @param page
* @param param
* @return {@link IPage<OrderListVO>}
*/
IPage<OrderListVO> getOrderPageList(Page<OrderListParam> page, OrderListParam param);
/**
* 订单列表不分页查询
*
* @author licancan
* @param param
* @return {@link List<OrderListVO>}
*/
List<OrderListVO> getOrderList(OrderListParam param);
/**
* 变更订单状态
*
* @author licancan
* @param id
* @param status
* @return {@link R<String>}
*/
R<String> handleOrder(String id, Integer status);
} }
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.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.util.R;
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.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.mapper.TOrderMapper; import com.yifu.cloud.plus.v1.yifu.order.mapper.TOrderMapper;
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.OrderListParam;
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.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/** /**
* @author licancan * @author licancan
* @description 针对表【t_order(订单表)】的数据库操作Service实现 * @description 针对表【t_order(订单表)】的数据库操作Service实现
...@@ -16,4 +32,68 @@ import org.springframework.stereotype.Service; ...@@ -16,4 +32,68 @@ import org.springframework.stereotype.Service;
@Service @Service
public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService { public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> implements TOrderService {
/**
* 订单列表分页查询
*
* @param page
* @param param
* @return {@link IPage <OrderListVO>}
* @author licancan
*/
@Override
public IPage<OrderListVO> getOrderPageList(Page<OrderListParam> page, OrderListParam param) {
IPage<OrderListVO> orderList = baseMapper.getOrderPageList(page,param);
return orderList;
}
/**
* 订单列表不分页查询
*
* @param param
* @return {@link List<OrderListVO>}
* @author licancan
*/
@Override
public List<OrderListVO> getOrderList(OrderListParam param) {
List<OrderListVO> list;
if (CollectionUtils.isNotEmpty(param.getIdList())){
list = baseMapper.getOrderListBySelect(param.getIdList());
}else {
list = baseMapper.getOrderList(param);
}
return list;
}
/**
* 变更订单状态
*
* @param id
* @param status
* @return {@link R <String>}
* @author licancan
*/
@Override
public R<String> handleOrder(String id, Integer status) {
if (StringUtils.isEmpty(id)){
return R.failed(OrderConstants.ORDER_ID_IS_EMPTY);
}
if (CommonConstants.TWO_INT != status && CommonConstants.THREE_INT != status){
return R.failed(OrderConstants.STATUS_ERROR);
}
YifuUser user = SecurityUtils.getUser();
TOrder byId = this.getById(id);
if (!Optional.ofNullable(byId).isPresent()){
return R.failed(OrderConstants.DATA_IS_EMPTY);
}
if (CommonConstants.THREE_INT == byId.getOrderStatus()){
return R.failed(OrderConstants.ORDER_IS_HANDLED);
}
byId.setOrderStatus(status);
byId.setUpdateBy(user.getId());
byId.setUpdateName(user.getNickname());
byId.setUpdateTime(LocalDateTime.now());
this.updateById(byId);
return R.ok(OrderConstants.OPERATE_SUCCESS);
}
} }
...@@ -27,4 +27,92 @@ ...@@ -27,4 +27,92 @@
UPDATE_BY,UPDATE_NAME,UPDATE_TIME, UPDATE_BY,UPDATE_NAME,UPDATE_TIME,
DELETE_FLAG DELETE_FLAG
</sql> </sql>
<select id="getOrderPageList" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO">
select t.id as id,
t.ORDER_NO as orderNo,
t.CREATE_TIME as createTime,
t.CREATE_NAME as createName,
t.CUSTOMER_NAME as customerName,
t.DEPT_NAME as deptName,
t.DEPT_NO as deptNo,
t.ORDER_STATUS as orderStatus
from t_order t
where t.DELETE_FLAG = 0
<if test="param.orderNo != null and param.orderNo.trim() != ''">
and t.ORDER_NO = #{param.orderNo}
</if>
<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
and t.CREATE_TIME <![CDATA[ >= ]]> concat(#{param.startDate}, ' 00:00:00') and t.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
</if>
<if test="param.createName != null and param.createName.trim() != ''">
and t.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.customerName != null and param.customerName.trim() != ''">
and t.CUSTOMER_NAME = #{param.customerName}
</if>
<if test="param.deptName != null and param.deptName.trim() != ''">
and t.DEPT_NAME = #{param.deptName}
</if>
<if test="param.deptNo != null and param.deptNo.trim() != ''">
and t.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.orderStatus != null">
and t.ORDER_STATUS = #{param.orderStatus}
</if>
ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC
</select>
<select id="getOrderListBySelect" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO">
select t.id as id,
t.ORDER_NO as orderNo,
t.CREATE_TIME as createTime,
t.CREATE_NAME as createName,
t.CUSTOMER_NAME as customerName,
t.DEPT_NAME as deptName,
t.DEPT_NO as deptNo,
t.ORDER_STATUS as orderStatus
from t_order t
where t.DELETE_FLAG = 0 and t.id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC
</select>
<select id="getOrderList" resultType="com.yifu.cloud.plus.v1.yifu.order.vo.OrderListVO">
select t.id as id,
t.ORDER_NO as orderNo,
t.CREATE_TIME as createTime,
t.CREATE_NAME as createName,
t.CUSTOMER_NAME as customerName,
t.DEPT_NAME as deptName,
t.DEPT_NO as deptNo,
t.ORDER_STATUS as orderStatus
from t_order t
where t.DELETE_FLAG = 0
<if test="param.orderNo != null and param.orderNo.trim() != ''">
and t.ORDER_NO = #{param.orderNo}
</if>
<if test="param.startDate != null and param.startDate.trim() != '' and param.endDate != null and param.endDate.trim() != ''">
and t.CREATE_TIME <![CDATA[ >= ]]> concat(#{param.startDate}, ' 00:00:00') and t.CREATE_TIME <![CDATA[ <= ]]> concat(#{param.endDate}, ' 23:59:59')
</if>
<if test="param.createName != null and param.createName.trim() != ''">
and t.CREATE_NAME like concat('%',replace(replace(#{param.createName},'_','\_'),'%','\%'),'%')
</if>
<if test="param.customerName != null and param.customerName.trim() != ''">
and t.CUSTOMER_NAME = #{param.customerName}
</if>
<if test="param.deptName != null and param.deptName.trim() != ''">
and t.DEPT_NAME = #{param.deptName}
</if>
<if test="param.deptNo != null and param.deptNo.trim() != ''">
and t.DEPT_NO like concat('%',replace(replace(#{param.deptNo},'_','\_'),'%','\%'),'%')
</if>
<if test="param.orderStatus != null">
and t.ORDER_STATUS = #{param.orderStatus}
</if>
ORDER BY t.ORDER_STATUS,t.CREATE_TIME DESC
</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