Browse Source

订单接口定义

zhh 6 years ago
parent
commit
201960328b

+ 77 - 0
mall-admin/src/main/java/com/macro/mall/controller/OmsOrderController.java

@@ -0,0 +1,77 @@
+package com.macro.mall.controller;
+
+import com.macro.mall.dto.CommonResult;
+import com.macro.mall.dto.OmsOrderDetail;
+import com.macro.mall.dto.OmsOrderQueryParam;
+import com.macro.mall.model.OmsOrder;
+import com.macro.mall.service.OmsOrderService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 订单管理Controller
+ * Created by macro on 2018/10/11.
+ */
+@Controller
+@Api(tags = "OmsOrderController", description = "订单管理")
+@RequestMapping("/order")
+public class OmsOrderController {
+    @Autowired
+    private OmsOrderService orderService;
+
+    @ApiOperation("查询订单")
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    @ResponseBody
+    public Object list(OmsOrderQueryParam queryParam,
+                       @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
+                       @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
+        List<OmsOrder> orderList = orderService.list(queryParam, pageSize, pageNum);
+        return new CommonResult().pageSuccess(orderList);
+    }
+
+    @ApiOperation("批量发货")
+    @RequestMapping(value = "/update/delivery", method = RequestMethod.POST)
+    @ResponseBody
+    public Object delivery(@RequestParam("ids") List<Long> ids) {
+        int count = orderService.delivery(ids);
+        if (count > 0) {
+            return new CommonResult().success(count);
+        }
+        return new CommonResult().failed();
+    }
+
+    @ApiOperation("批量关闭订单")
+    @RequestMapping(value = "/update/close", method = RequestMethod.POST)
+    @ResponseBody
+    public Object close(@RequestParam("ids") List<Long> ids) {
+        int count = orderService.close(ids);
+        if (count > 0) {
+            return new CommonResult().success(count);
+        }
+        return new CommonResult().failed();
+    }
+
+    @ApiOperation("批量删除订单")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ResponseBody
+    public Object delete(@RequestParam("ids") List<Long> ids) {
+        int count = orderService.delete(ids);
+        if (count > 0) {
+            return new CommonResult().success(count);
+        }
+        return new CommonResult().failed();
+    }
+
+    @ApiOperation("获取订单详情:订单信息、商品信息、操作记录")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    @ResponseBody
+    public Object detail(@PathVariable Long id) {
+        OmsOrderDetail orderDetailResult = orderService.detail(id);
+        return new CommonResult().success(orderDetailResult);
+    }
+}

+ 22 - 0
mall-admin/src/main/java/com/macro/mall/dto/OmsOrderDetail.java

@@ -0,0 +1,22 @@
+package com.macro.mall.dto;
+
+import com.macro.mall.model.OmsOrder;
+import com.macro.mall.model.OmsOrderItem;
+import com.macro.mall.model.OmsOrderOperateHistory;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * 订单详情信息
+ * Created by macro on 2018/10/11.
+ */
+public class OmsOrderDetail extends OmsOrder {
+    @Getter
+    @Setter
+    private List<OmsOrderItem> orderItemList;
+    @Getter
+    @Setter
+    private List<OmsOrderOperateHistory> historyList;
+}

+ 28 - 0
mall-admin/src/main/java/com/macro/mall/dto/OmsOrderQueryParam.java

@@ -0,0 +1,28 @@
+package com.macro.mall.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * 订单查询参数
+ * Created by macro on 2018/10/11.
+ */
+@Getter
+@Setter
+public class OmsOrderQueryParam {
+    @ApiModelProperty(value = "订单编号")
+    private String orderSn;
+    @ApiModelProperty(value = "收货人姓名/号码")
+    private String receiverKeyword;
+    @ApiModelProperty(value = "订单状态:0->待付款;1->待发货;2->已发货;3->已完成;4->已关闭;5->无效订单")
+    private Integer status;
+    @ApiModelProperty(value = "订单类型:0->正常订单;1->秒杀订单")
+    private Integer orderType;
+    @ApiModelProperty(value = "订单来源:0->PC订单;1->app订单")
+    private Integer sourceType;
+    @ApiModelProperty(value = "订单提交时间")
+    private Date createTime;
+}

+ 38 - 0
mall-admin/src/main/java/com/macro/mall/service/OmsOrderService.java

@@ -0,0 +1,38 @@
+package com.macro.mall.service;
+
+import com.macro.mall.dto.OmsOrderDetail;
+import com.macro.mall.dto.OmsOrderQueryParam;
+import com.macro.mall.model.OmsOrder;
+
+import java.util.List;
+
+/**
+ * 订单管理Service
+ * Created by macro on 2018/10/11.
+ */
+public interface OmsOrderService {
+    /**
+     * 订单查询
+     */
+    List<OmsOrder> list(OmsOrderQueryParam queryParam, Integer pageSize, Integer pageNum);
+
+    /**
+     * 批量发货
+     */
+    int delivery(List<Long> ids);
+
+    /**
+     * 批量关闭订单
+     */
+    int close(List<Long> ids);
+
+    /**
+     * 批量删除订单
+     */
+    int delete(List<Long> ids);
+
+    /**
+     * 获取指定订单详情
+     */
+    OmsOrderDetail detail(Long id);
+}

+ 70 - 0
mall-admin/src/main/java/com/macro/mall/service/impl/OmsOrderServiceImpl.java

@@ -0,0 +1,70 @@
+package com.macro.mall.service.impl;
+
+import com.aliyun.oss.common.utils.DateUtil;
+import com.github.pagehelper.PageHelper;
+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.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;
+
+/**
+ * 订单管理Service实现类
+ * Created by macro on 2018/10/11.
+ */
+@Service
+public class OmsOrderServiceImpl implements OmsOrderService {
+    @Autowired
+    private OmsOrderMapper orderMapper;
+    @Override
+    public List<OmsOrder> list(OmsOrderQueryParam queryParam, Integer pageSize, Integer pageNum) {
+        PageHelper.startPage(pageNum,pageSize);
+        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;
+    }
+
+    @Override
+    public int delete(List<Long> ids) {
+        return 0;
+    }
+
+    @Override
+    public OmsOrderDetail detail(Long id) {
+        return null;
+    }
+}