添加订单列表接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.dto.OmsOrderDeliveryParam;
|
||||
import com.macro.mall.dto.OmsOrderDetail;
|
||||
import com.macro.mall.dto.OmsOrderQueryParam;
|
||||
import com.macro.mall.model.OmsOrder;
|
||||
@@ -37,8 +38,8 @@ public class OmsOrderController {
|
||||
@ApiOperation("批量发货")
|
||||
@RequestMapping(value = "/update/delivery", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delivery(@RequestParam("ids") List<Long> ids) {
|
||||
int count = orderService.delivery(ids);
|
||||
public Object delivery(@RequestBody List<OmsOrderDeliveryParam> deliveryParamList) {
|
||||
int count = orderService.delivery(deliveryParamList);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
@@ -48,8 +49,8 @@ public class OmsOrderController {
|
||||
@ApiOperation("批量关闭订单")
|
||||
@RequestMapping(value = "/update/close", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object close(@RequestParam("ids") List<Long> ids) {
|
||||
int count = orderService.close(ids);
|
||||
public Object close(@RequestParam("ids") List<Long> ids,@RequestParam String note) {
|
||||
int count = orderService.close(ids,note);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
|
||||
30
mall-admin/src/main/java/com/macro/mall/dao/OmsOrderDao.java
Normal file
30
mall-admin/src/main/java/com/macro/mall/dao/OmsOrderDao.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package com.macro.mall.dao;
|
||||
|
||||
import com.macro.mall.dto.OmsOrderDeliveryParam;
|
||||
import com.macro.mall.dto.OmsOrderDetail;
|
||||
import com.macro.mall.dto.OmsOrderQueryParam;
|
||||
import com.macro.mall.model.OmsOrder;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单自定义查询Dao
|
||||
* Created by macro on 2018/10/12.
|
||||
*/
|
||||
public interface OmsOrderDao {
|
||||
/**
|
||||
* 条件查询订单
|
||||
*/
|
||||
List<OmsOrder> getList(@Param("queryParam") OmsOrderQueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 批量发货
|
||||
*/
|
||||
int delivery(@Param("list") List<OmsOrderDeliveryParam> deliveryParamList);
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*/
|
||||
OmsOrderDetail getDetail(@Param("id") Long id);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.macro.mall.dao;
|
||||
|
||||
import com.macro.mall.model.OmsOrderOperateHistory;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单操作记录自定义Dao
|
||||
* Created by macro on 2018/10/12.
|
||||
*/
|
||||
public interface OmsOrderOperateHistoryDao {
|
||||
int insertList(@Param("list") List<OmsOrderOperateHistory> orderOperateHistoryList);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 订单发货参数
|
||||
* Created by macro on 2018/10/12.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class OmsOrderDeliveryParam {
|
||||
@ApiModelProperty("订单id")
|
||||
private Long orderId;
|
||||
@ApiModelProperty("物流公司")
|
||||
private String deliveryCompany;
|
||||
@ApiModelProperty("物流单号")
|
||||
private String deliverySn;
|
||||
}
|
||||
@@ -4,8 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 订单查询参数
|
||||
* Created by macro on 2018/10/11.
|
||||
@@ -24,5 +22,5 @@ public class OmsOrderQueryParam {
|
||||
@ApiModelProperty(value = "订单来源:0->PC订单;1->app订单")
|
||||
private Integer sourceType;
|
||||
@ApiModelProperty(value = "订单提交时间")
|
||||
private Date createTime;
|
||||
private String createTime;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.dto.OmsOrderDeliveryParam;
|
||||
import com.macro.mall.dto.OmsOrderDetail;
|
||||
import com.macro.mall.dto.OmsOrderQueryParam;
|
||||
import com.macro.mall.model.OmsOrder;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,12 +21,14 @@ public interface OmsOrderService {
|
||||
/**
|
||||
* 批量发货
|
||||
*/
|
||||
int delivery(List<Long> ids);
|
||||
@Transactional
|
||||
int delivery(List<OmsOrderDeliveryParam> deliveryParamList);
|
||||
|
||||
/**
|
||||
* 批量关闭订单
|
||||
*/
|
||||
int close(List<Long> ids);
|
||||
@Transactional
|
||||
int close(List<Long> ids, String note);
|
||||
|
||||
/**
|
||||
* 批量删除订单
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.aliyun.oss.common.utils.DateUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dao.OmsOrderDao;
|
||||
import com.macro.mall.dao.OmsOrderOperateHistoryDao;
|
||||
import com.macro.mall.dto.OmsOrderDeliveryParam;
|
||||
import com.macro.mall.dto.OmsOrderDetail;
|
||||
import com.macro.mall.dto.OmsOrderQueryParam;
|
||||
import com.macro.mall.mapper.OmsOrderMapper;
|
||||
import com.macro.mall.model.OmsOrder;
|
||||
import com.macro.mall.model.OmsOrderExample;
|
||||
import com.macro.mall.model.OmsOrderOperateHistory;
|
||||
import com.macro.mall.service.OmsOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 订单管理Service实现类
|
||||
@@ -24,47 +26,67 @@ import java.util.List;
|
||||
public class OmsOrderServiceImpl implements OmsOrderService {
|
||||
@Autowired
|
||||
private OmsOrderMapper orderMapper;
|
||||
@Autowired
|
||||
private OmsOrderDao orderDao;
|
||||
@Autowired
|
||||
private OmsOrderOperateHistoryDao orderOperateHistoryDao;
|
||||
|
||||
@Override
|
||||
public List<OmsOrder> list(OmsOrderQueryParam queryParam, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
return orderDao.getList(queryParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delivery(List<OmsOrderDeliveryParam> deliveryParamList) {
|
||||
//批量发货
|
||||
int count = orderDao.delivery(deliveryParamList);
|
||||
//添加操作记录
|
||||
List<OmsOrderOperateHistory> operateHistoryList = deliveryParamList.stream()
|
||||
.map(omsOrderDeliveryParam -> {
|
||||
OmsOrderOperateHistory history = new OmsOrderOperateHistory();
|
||||
history.setOrderId(omsOrderDeliveryParam.getOrderId());
|
||||
history.setCreateTime(new Date());
|
||||
history.setOperateMan("后台管理员");
|
||||
history.setOrderStatus(2);
|
||||
history.setNote("完成发货");
|
||||
return history;
|
||||
}).collect(Collectors.toList());
|
||||
orderOperateHistoryDao.insertList(operateHistoryList);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int close(List<Long> ids, String note) {
|
||||
OmsOrder record = new OmsOrder();
|
||||
record.setStatus(4);
|
||||
OmsOrderExample example = new OmsOrderExample();
|
||||
OmsOrderExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andDeleteStatusEqualTo(0);
|
||||
if(!StringUtils.isEmpty(queryParam.getOrderSn())){
|
||||
criteria.andOrderSnEqualTo(queryParam.getOrderSn());
|
||||
}
|
||||
if(!StringUtils.isEmpty(queryParam.getReceiverKeyword())){
|
||||
criteria.andReceiverNameEqualTo(queryParam.getReceiverKeyword());
|
||||
}
|
||||
if(queryParam.getStatus()!=null){
|
||||
criteria.andStatusEqualTo(queryParam.getStatus());
|
||||
}
|
||||
if(queryParam.getSourceType()!=null){
|
||||
criteria.andSourceTypeEqualTo(queryParam.getSourceType());
|
||||
}
|
||||
if(queryParam.getOrderType()!=null){
|
||||
criteria.andOrderTypeEqualTo(queryParam.getOrderType());
|
||||
}
|
||||
return orderMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delivery(List<Long> ids) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int close(List<Long> ids) {
|
||||
return 0;
|
||||
example.createCriteria().andDeleteStatusEqualTo(0).andIdIn(ids);
|
||||
int count = orderMapper.updateByExampleSelective(record, example);
|
||||
List<OmsOrderOperateHistory> historyList = ids.stream().map(orderId -> {
|
||||
OmsOrderOperateHistory history = new OmsOrderOperateHistory();
|
||||
history.setOrderId(orderId);
|
||||
history.setCreateTime(new Date());
|
||||
history.setOperateMan("后台管理员");
|
||||
history.setOrderStatus(4);
|
||||
history.setNote("订单关闭:"+note);
|
||||
return history;
|
||||
}).collect(Collectors.toList());
|
||||
orderOperateHistoryDao.insertList(historyList);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
return 0;
|
||||
OmsOrder record = new OmsOrder();
|
||||
record.setDeleteStatus(1);
|
||||
OmsOrderExample example = new OmsOrderExample();
|
||||
example.createCriteria().andDeleteStatusEqualTo(0).andIdIn(ids);
|
||||
return orderMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OmsOrderDetail detail(Long id) {
|
||||
return null;
|
||||
return orderDao.getDetail(id);
|
||||
}
|
||||
}
|
||||
|
||||
91
mall-admin/src/main/resources/dao/OmsOrderDao.xml
Normal file
91
mall-admin/src/main/resources/dao/OmsOrderDao.xml
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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.macro.mall.dao.OmsOrderDao">
|
||||
<resultMap id="orderDetailResultMap" type="com.macro.mall.dto.OmsOrderDetail" extends="com.macro.mall.mapper.OmsOrderMapper.BaseResultMap">
|
||||
<collection property="orderItemList" resultMap="com.macro.mall.mapper.OmsOrderItemMapper.BaseResultMap" columnPrefix="item_"/>
|
||||
<collection property="historyList" resultMap="com.macro.mall.mapper.OmsOrderOperateHistoryMapper.BaseResultMap" columnPrefix="history_"/>
|
||||
</resultMap>
|
||||
<select id="getList" resultMap="com.macro.mall.mapper.OmsOrderMapper.BaseResultMap">
|
||||
SELECT *
|
||||
FROM
|
||||
oms_order
|
||||
WHERE
|
||||
delete_status = 0
|
||||
<if test="queryParam.orderSn!=null and queryParam.orderSn!=''">
|
||||
AND order_sn = #{queryParam.orderSn}
|
||||
</if>
|
||||
<if test="queryParam.status!=null">
|
||||
AND `status` = #{queryParam.status}
|
||||
</if>
|
||||
<if test="queryParam.sourceType!=null">
|
||||
AND source_type = #{queryParam.sourceType}
|
||||
</if>
|
||||
<if test="queryParam.orderType!=null">
|
||||
AND order_type = #{queryParam.orderType}
|
||||
</if>
|
||||
<if test="queryParam.createTime!=null and queryParam.createTime!=''">
|
||||
AND create_time LIKE concat(#{queryParam.createTime},"%")
|
||||
</if>
|
||||
<if test="queryParam.receiverKeyword!=null and queryParam.receiverKeyword!=''">
|
||||
AND (
|
||||
receiver_name LIKE concat("%",#{queryParam.receiverKeyword},"%")
|
||||
OR receiver_phone LIKE concat("%",#{queryParam.receiverKeyword},"%")
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
<update id="delivery">
|
||||
UPDATE oms_order
|
||||
SET
|
||||
delivery_sn = CASE id
|
||||
<foreach collection="list" item="item">
|
||||
WHEN #{item.orderId} THEN #{item.deliverySn}
|
||||
</foreach>
|
||||
END,
|
||||
delivery_company = CASE id
|
||||
<foreach collection="list" item="item">
|
||||
WHEN #{item.orderId} THEN #{item.deliveryCompany}
|
||||
</foreach>
|
||||
END,
|
||||
delivery_time = CASE id
|
||||
<foreach collection="list" item="item">
|
||||
WHEN #{item.orderId} THEN now()
|
||||
</foreach>
|
||||
END,
|
||||
`status` = CASE id
|
||||
<foreach collection="list" item="item">
|
||||
WHEN #{item.orderId} THEN 2
|
||||
</foreach>
|
||||
END
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
#{item.orderId}
|
||||
</foreach>
|
||||
AND `status` = 1
|
||||
</update>
|
||||
<select id="getDetail" resultMap="orderDetailResultMap">
|
||||
SELECT o.*,
|
||||
oi.id item_id,
|
||||
oi.product_id item_product_id,
|
||||
oi.product_sn item_product_sn,
|
||||
oi.product_pic item_product_pic,
|
||||
oi.product_name item_product_name,
|
||||
oi.product_brand item_product_brand,
|
||||
oi.product_price item_product_price,
|
||||
oi.product_quantity item_product_quantity,
|
||||
oi.sp1 item_sp1,
|
||||
oi.sp2 item_sp2,
|
||||
oi.sp3 item_sp3,
|
||||
oh.id history_id,
|
||||
oh.operate_man history_operate_man,
|
||||
oh.create_time history_create_time,
|
||||
oh.order_status history_order_status,
|
||||
oh.note history_note
|
||||
FROM
|
||||
oms_order o
|
||||
LEFT JOIN oms_order_item oi ON o.id = oi.order_id
|
||||
LEFT JOIN oms_order_operate_history oh ON o.id = oh.order_id
|
||||
WHERE
|
||||
o.id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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.macro.mall.dao.OmsOrderOperateHistoryDao">
|
||||
<insert id="insertList">
|
||||
INSERT INTO oms_order_operate_history (order_id, operate_man, create_time, order_status, note) VALUES
|
||||
<foreach collection="list" separator="," item="item" index="index">
|
||||
(#{item.orderId},
|
||||
#{item.operateMan},
|
||||
#{item.createTime,jdbcType=TIMESTAMP},
|
||||
#{item.orderStatus},
|
||||
#{item.note})
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user