Sfoglia il codice sorgente

订单详情,物流详情

chao 3 anni fa
parent
commit
35a2aa238f

+ 50 - 6
src/main/java/com/caimei365/order/controller/OrderClubApi.java

@@ -2,7 +2,7 @@ package com.caimei365.order.controller;
 
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.OrderDto;
-import com.caimei365.order.model.vo.AddressVo;
+import com.caimei365.order.model.vo.LogisticsBatchVo;
 import com.caimei365.order.model.vo.OrderVo;
 import com.caimei365.order.model.vo.SearchHistoryVo;
 import com.caimei365.order.service.OrderClubService;
@@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 机构订单API
@@ -30,7 +31,6 @@ import java.util.List;
 public class OrderClubApi {
 
     private final OrderClubService orderClubService;
-    private final String ID_EMPTY = "订单Id不能为空!";
 
     /**
      * 机构订单列表
@@ -78,6 +78,25 @@ public class OrderClubApi {
         return orderClubService.getOrderListByKeyword(userId, searchWord, pageNum, pageSize);
     }
 
+    /**
+     * 机构订单详情
+     */
+    @ApiOperation("机构订单详情(旧:/order/detail)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
+    })
+    @GetMapping("/detail")
+    public ResponseJson<Map<String, Object>> getOrderDetail(Integer userId, Integer orderId) {
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        if (null == orderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        return orderClubService.getOrderDetail(userId, orderId);
+    }
+
     /**
      * 机构确认订单
      *
@@ -89,7 +108,7 @@ public class OrderClubApi {
     @PostMapping("/confirm")
     public ResponseJson<Void> confirmOrder(OrderDto orderDto){
         if (null == orderDto.getOrderId()) {
-            return ResponseJson.error(ID_EMPTY, null);
+            return ResponseJson.error("订单Id不能为空!", null);
         }
         return orderClubService.confirmMainOrder(orderDto.getOrderId());
     }
@@ -106,7 +125,7 @@ public class OrderClubApi {
     @PostMapping("/cancel")
     public ResponseJson<Void> cancelOrder(OrderDto orderDto){
         if (null == orderDto.getOrderId()) {
-            return ResponseJson.error(ID_EMPTY, null);
+            return ResponseJson.error("订单Id不能为空!", null);
         }
         return orderClubService.cancelMainOrder(orderDto.getOrderId(), orderDto.getRemark());
     }
@@ -122,7 +141,7 @@ public class OrderClubApi {
     @PostMapping("/delete")
     public ResponseJson<Void> deleteOrder(OrderDto orderDto){
         if (null == orderDto.getOrderId()) {
-            return ResponseJson.error(ID_EMPTY, null);
+            return ResponseJson.error("订单Id不能为空!", null);
         }
         return orderClubService.deleteMainOrder(orderDto.getOrderId());
     }
@@ -138,7 +157,7 @@ public class OrderClubApi {
     @PostMapping("/receive")
     public ResponseJson<Void> receiveGoods(OrderDto orderDto){
         if (null == orderDto.getOrderId()) {
-            return ResponseJson.error(ID_EMPTY, null);
+            return ResponseJson.error("订单Id不能为空!", null);
         }
         return orderClubService.receiveGoods(orderDto.getOrderId());
     }
@@ -156,4 +175,29 @@ public class OrderClubApi {
         return orderClubService.getOrderSearchHistory(userId);
     }
 
+    /**
+     * 根据用户Id删除订单搜索历史记录
+     */
+    @ApiOperation("根据用户Id删除订单搜索历史记录(旧:/order/searchHistory/delete)")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/search/history/delete")
+    public ResponseJson<Void> deleteOrderSearchHistory(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        return orderClubService.deleteOrderSearchHistory(userId);
+    }
+
+    /**
+     * 物流详情
+     */
+    @ApiOperation("物流详情(旧:/order/logistics)")
+    @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
+    @GetMapping("/logistics")
+    public ResponseJson<List<LogisticsBatchVo>> getOrderLogistics(Integer orderId) {
+        if (null == orderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        return orderClubService.getOrderLogistics(orderId);
+    }
 }

+ 54 - 0
src/main/java/com/caimei365/order/mapper/OrderClubMapper.java

@@ -187,4 +187,58 @@ public interface OrderClubMapper {
      * @param userId 用户Id
      */
     List<SearchHistoryVo> getOrderSearchHistory(Integer userId);
+    /**
+     * 根据用户Id删除订单搜索历史记录
+     * @param userId 用户Id
+     */
+    void deleteOrderSearchHistory(Integer userId);
+    /**
+     * 已退货数量
+     * @param shopOrderId 子订单Id
+     * @param productId   商品Id
+     */
+    Integer countReturnedNum(Integer shopOrderId, Integer productId);
+    /**
+     * 已取消发货数量
+     * @param shopOrderId 子订单Id
+     * @param productId   商品Id
+     */
+    Integer countActualCancelNum(Integer shopOrderId, Integer productId);
+    /**
+     * 退款记录
+     * @param orderId 订单Id
+     */
+    List<ReturnedPurchaseVo> getReturnedPurchaseList(Integer orderId);
+    /**
+     * 售后条款
+     * @param clauseId 条款Id
+     */
+    ClauseVo getClauseById(Integer clauseId);
+    /**
+     * 收货地址
+     * @param orderId 订单Id
+     */
+    OrderUserinfoVo getOrderUserinfo(Integer orderId);
+    /**
+     * 获取物流批次列表
+     * @param orderId 订单Id
+     */
+    List<LogisticsBatchVo> getLogisticsBatchList(Integer orderId);
+    /**
+     * 获取物流批次子订单Id列表
+     * @param orderId 订单Id
+     * @param id 物流批次Id
+     */
+    List<String> getBatchShopOrderIds(Integer orderId, Integer id);
+    /**
+     * 获取发货物流记录
+     * @param shopOrderId      子订单Id
+     * @param logisticsBatchId 物流批次Id
+     */
+    List<LogisticsRecordVo> getLogisticsRecord(Integer shopOrderId, Integer logisticsBatchId);
+    /**
+     * 获取物流信息
+     * @param logisticsBatchId 物流批次Id
+     */
+    List<LogisticsInformationVo> getLogisticsInfoList(Integer logisticsBatchId);
 }

+ 34 - 0
src/main/java/com/caimei365/order/model/vo/ClauseVo.java

@@ -0,0 +1,34 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class ClauseVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    /**
+     * 名称
+     */
+    private String name;
+    /**
+     * 内容
+     */
+    private String content;
+    /**
+     * 条款启用类型,0非分期中启用 1分期启用,2同时启用
+     */
+    private String clauseType;
+    /**
+     * 启用/禁用状态 0否 1是
+     */
+    private String enabledStatus;
+}

+ 76 - 0
src/main/java/com/caimei365/order/model/vo/LogisticsBatchVo.java

@@ -0,0 +1,76 @@
+package com.caimei365.order.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class LogisticsBatchVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 子订单Id
+     */
+    private Integer shopOrderId;
+    /**
+     * 主订单Id
+     */
+    private String orderId;
+    /**
+     * 第几批发货
+     */
+    private Integer outStoreTimes;
+    /**
+     * 是否确认收货(0:否,1:是)
+     */
+    private String status;
+    /**
+     * 邮寄者  0 采美   1 供应商
+     */
+    private String mailer;
+    /**
+     * 供应商Id
+     */
+    private Integer shopId;
+    /**
+     * 最后更新时间
+     */
+    private Date updateDate;
+    /**
+     * 发货时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date deliveryTime;
+    /**
+     * 收货时间
+     */
+    private Date receiptTime;
+    /**
+     * 备注图片,以"||"隔开
+     */
+    private String remarkImage;
+    /**
+     * 备注
+     */
+    private String remark;
+    /**
+     * 物流跟踪信息
+     */
+    private List<LogisticsInformationVo> logisticsInformationList;
+    /**
+     * 子订单信息
+     */
+    private List<ShopOrderVo> shopOrderList;
+}

+ 81 - 0
src/main/java/com/caimei365/order/model/vo/LogisticsInformationVo.java

@@ -0,0 +1,81 @@
+package com.caimei365.order.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class LogisticsInformationVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 发货批次表ID
+     */
+    private Integer logisticsBatchID;
+    /**
+     * 类型:1 采美365  2 呵呵商城 3 大宗采购
+     */
+    private String type;
+    /**
+     * 子订单编号
+     */
+    private Integer shopOrderID;
+    /**
+     * 订单商品ID
+     */
+    private Integer orderProductID;
+    /**
+     * 订单ID
+     */
+    private Integer orderID;
+    /**
+     * 快递单号
+     */
+    private String nu;
+    /**
+     * 快递单当前的状态(0:在途,即货物处于运输过程中;1:揽件,货物已由快递公司揽收并且产生了第一条跟踪信息;2:疑难,货物寄送过程出了问题;3:签收,收件人已签收;4:退签,即货物由于用户拒签、超区等原因退回,而且发件人已经签收;5:派件,即快递正在进行同城派件;6:退回,货物正处于退回发件人的途中;)
+     */
+    private String state;
+    /**
+     * 物流跟踪信息
+     */
+    private String info;
+    /**
+     * 物流公司名称
+     */
+    private String logisticsCompanyName;
+    /**
+     * 物流公司代码
+     */
+    private String logisticsCompanyCode;
+    /**
+     * 供应商ID
+     */
+    private Integer shopID;
+    /**
+     * 最后更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateDate;
+    /**
+     * 备注
+     */
+    private String remarks;
+    /**
+     * json转换物流追踪信息
+     */
+    private List<LogisticsRouterVo> routerList;
+
+}

+ 56 - 0
src/main/java/com/caimei365/order/model/vo/LogisticsRecordVo.java

@@ -0,0 +1,56 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class LogisticsRecordVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * id
+     */
+    private Integer id;
+    /**
+     * 发货物流批次Id
+     */
+    private Integer logisticsBatchId;
+    /**
+     * 子订单Id
+     */
+    private Integer shopOrderId;
+    /**
+     * 主订单Id
+     */
+    private Integer orderId;
+    /**
+     * 订单商品Id
+     */
+    private Integer orderProductId;
+    /**
+     * 商品购买数量
+     */
+    private Integer buyNum;
+    /**
+     * 此次发货数量
+     */
+    private Integer num;
+    /**
+     * 商品Id
+     */
+    private Integer productId;
+    /**
+     * 商品名称
+     */
+    private String productName;
+    /**
+     * 商品图片
+     */
+    private String image;
+}

+ 25 - 0
src/main/java/com/caimei365/order/model/vo/LogisticsRouterVo.java

@@ -0,0 +1,25 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class LogisticsRouterVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 描述
+     */
+    private String desc;
+    private String context;
+    /**
+     * 时间
+     */
+    private String time;
+}

+ 18 - 1
src/main/java/com/caimei365/order/model/vo/OrderProductVo.java

@@ -3,7 +3,6 @@ package com.caimei365.order.model.vo;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.util.List;
 
 /**
  * Description
@@ -206,4 +205,22 @@ public class OrderProductVo implements Serializable {
      * 商品促销活动
      */
     private PromotionsVo productPromotion;
+    /**
+     * 已发货数量
+     */
+    private Integer shipmentsNum;
+
+    /**
+     * 已退货数量
+     */
+    private Integer returnedNum;
+
+    /**
+     * 已取消发货数量
+     */
+    private Integer actualCancelNum;
+    /**
+     * 商品前台展示单价是否含税,1不含税,2含税,3其他
+     */
+    private Integer includedTaxFlag;
 }

+ 81 - 0
src/main/java/com/caimei365/order/model/vo/OrderUserinfoVo.java

@@ -0,0 +1,81 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class OrderUserinfoVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 订单用户信息表Id
+     */
+    private Integer id;
+    /**
+     * 订单ID
+     */
+    private Integer orderId;
+    /**
+     * 机构ID
+     */
+    private Integer clubId;
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+    /**
+     * 买家(name)
+     */
+    private String userName;
+    /**
+     * 收货人(shouHuoRen)
+     */
+    private String name;
+    /**
+     * 手机
+     */
+    private String mobile;
+    /**
+     * 电话
+     */
+    private String phone;
+    /**
+     * 邮编
+     */
+    private String postalCode;
+    /**
+     * 县区ID
+     */
+    private Integer townId;
+    /**
+     * 省、直辖市
+     */
+    private String province;
+    /**
+     * 市
+     */
+    private String city;
+    /**
+     * 县、区
+     */
+    private String town;
+    /**
+     * 收货地址
+     */
+    private String address;
+    /**
+     * 买家
+     */
+    //private String name;
+
+    /**
+     * 收货人
+     */
+    //private String shouHuoRen;
+}

+ 16 - 1
src/main/java/com/caimei365/order/model/vo/OrderVo.java

@@ -3,7 +3,6 @@ package com.caimei365.order.model.vo;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -216,4 +215,20 @@ public class OrderVo implements Serializable {
      * 付款总金额
      */
     private Double receiptAmount;
+    /**
+     * 订单标识:#订单号#
+     */
+    private String orderMark;
+    /**
+     * 是否包含充值商品
+     */
+    private boolean rechargeGoods = false;
+    /**
+     * 总税费
+     */
+    private Double expensesOfTaxation;
+    /**
+     * 退款总金额
+     */
+    private Double returnedPurchaseFee;
 }

+ 154 - 0
src/main/java/com/caimei365/order/model/vo/ReturnedPurchaseVo.java

@@ -0,0 +1,154 @@
+package com.caimei365.order.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/22
+ */
+@Data
+public class ReturnedPurchaseVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+    /**
+     * 退款退货编号
+     */
+    private String returnedNo;
+    /**
+     * 主订单Id
+     */
+    private Integer orderId;
+    /**
+     * 用户Id(买家)
+     */
+    private Integer userId;
+    /**
+     * 状态:1待审核、2审核通过、3审核不通过
+     */
+    private String status;
+    /**
+     * 退款方式 1有支付有退款(退款方式可多选具体参考以上金额)、4未支付无退款(未支付发起退款)
+     */
+    private Integer returnedWay;
+    /**
+     * 付款方式 付款方式 1建设银行7297, 2中信银行0897, 3中信银行7172, 4广发银行0115, 5广发银行5461
+     */
+    private String payType;
+    /**
+     * 发起该操作时订单状态快照:0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
+     */
+    private String operatingOrderStatus;
+    /**
+     * 退款银行信息(银行名称、户名、开户行、银行账号)【V6.1.1版本已废弃拆分显示】
+     */
+    private String returnedBankInfo;
+    /**
+     * 银行账户名
+     */
+    private String bankAccountName;
+    /**
+     * 开户银行账户
+     */
+    private String bankAccountNo;
+    /**
+     * 开户银行
+     */
+    private String openBank;
+    /**
+     * 账户类型:1公账,2私账
+     */
+    private String bankAccountType;
+    /**
+     * 退款(退货)总金额【此金额为不包含经理折扣和余额抵扣的商品退款金额记录不作实际退款用,适用二次退款抵扣经理计算】
+     */
+    private Double returnedPurchaseFee;
+    /**
+     * 退款总额(给买家)
+     */
+    private Double refundFee;
+    /**
+     * 退账户余额
+     */
+    private Double refundBalanceFee;
+    /**
+     * 退线上退回
+     */
+    private Double refundOnlineFee;
+    /**
+     * 退线下转账
+     */
+    private Double refundOfflineFee;
+    /**
+     * 凭证图片1
+     */
+    private String image1;
+    /**
+     * 凭证图片2
+     */
+    private String image2;
+    /**
+     * 凭证图片3
+     */
+    private String image3;
+    /**
+     * 凭证图片4
+     */
+    private String image4;
+    /**
+     * 凭证图片5
+     */
+    private String image5;
+    /**
+     * 审核凭证图片1
+     */
+    private String reviewImage1;
+    /**
+     * 审核凭证图片2
+     */
+    private String reviewImage2;
+    /**
+     * 审核凭证图片3
+     */
+    private String reviewImage3;
+    /**
+     * 审核凭证图片4
+     */
+    private String reviewImage4;
+    /**
+     * 审核凭证图片5
+     */
+    private String reviewImage5;
+    /**
+     * 备注信息
+     */
+    private String remarks;
+    /**
+     * 审核备注信息
+     */
+    private String reviewRemarks;
+    /**
+     * 申请人Id
+     */
+    private Integer applicationUserId;
+    /**
+     * 申请退款时间
+     */
+    private String returnTime;
+    /**
+     * 审核人Id
+     */
+    private Integer reviewUserId;
+    /**
+     * 确认退款时间(审核退款时间)
+     */
+    private String confirmReturnTime;
+    /**
+     * 是否有效状态 0 有效  其它无效(适用取消退款等)
+     */
+    private String delFlag;
+
+}

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java

@@ -127,4 +127,8 @@ public class ShopOrderVo implements Serializable {
      * 订单商品信息
      */
     private List<OrderProductVo> orderProductList;
+    /**
+     * 发货物流记录
+     */
+    private List<LogisticsRecordVo> logisticsRecordList;
 }

+ 22 - 4
src/main/java/com/caimei365/order/service/OrderClubService.java

@@ -1,12 +1,14 @@
 package com.caimei365.order.service;
 
 import com.caimei365.order.model.ResponseJson;
+import com.caimei365.order.model.vo.LogisticsBatchVo;
 import com.caimei365.order.model.vo.OrderVo;
 import com.caimei365.order.model.vo.SearchHistoryVo;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.ApiImplicitParam;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -35,20 +37,26 @@ public interface OrderClubService {
      * @param pageSize   每页数量
      */
     ResponseJson<PageInfo<OrderVo>> getOrderListByKeyword(Integer userId, String searchWord, int pageNum, int pageSize);
+    /**
+     * 机构订单详情
+     * @param userId     用户Id
+     * @param orderId    订单Id
+     */
+    ResponseJson<Map<String, Object>> getOrderDetail(Integer userId, Integer orderId);
     /**
      * 机构确认订单
-     * @param orderId 订单Id
+     * @param orderId  订单Id
      */
     ResponseJson<Void> confirmMainOrder(Integer orderId);
     /**
      * 机构取消订单
-     * @param orderId 订单Id
+     * @param orderId  订单Id
      * @param remark    备注(订单取消原因)
      */
     ResponseJson<Void> cancelMainOrder(Integer orderId, String remark);
     /**
      * 机构删除订单
-     * @param orderId 订单Id
+     * @param orderId  订单Id
      */
     ResponseJson<Void> deleteMainOrder(Integer orderId);
     /**
@@ -58,7 +66,17 @@ public interface OrderClubService {
     ResponseJson<Void> receiveGoods(Integer orderId);
     /**
      * 根据用户Id查找订单搜索历史记录
-     * @param userId     用户Id
+     * @param userId  用户Id
      */
     ResponseJson<List<SearchHistoryVo>> getOrderSearchHistory(Integer userId);
+    /**
+     * 根据用户Id删除订单搜索历史记录
+     * @param userId  用户Id
+     */
+    ResponseJson<Void> deleteOrderSearchHistory(Integer userId);
+    /**
+     * 物流详情
+     * @param orderId 订单Id
+     */
+    ResponseJson<List<LogisticsBatchVo>> getOrderLogistics(Integer orderId);
 }

+ 158 - 6
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -1,5 +1,6 @@
 package com.caimei365.order.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.caimei365.order.components.ProductService;
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.OrderClubMapper;
@@ -19,15 +20,15 @@ import com.github.pagehelper.PageInfo;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * Description
@@ -104,6 +105,103 @@ public class OrderClubServiceImpl implements OrderClubService {
         return ResponseJson.success(pageInfo);
     }
 
+    /**
+     * 机构订单详情
+     *
+     * @param userId  用户Id
+     * @param orderId 订单Id
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getOrderDetail(Integer userId, Integer orderId) {
+        OrderPo orderPo = orderClubMapper.getMainOrderByOrderId(orderId);
+        if (null == orderPo) {
+            return ResponseJson.error("该订单不存在!", null);
+        }
+        if (!userId.equals(orderPo.getUserId())) {
+            return ResponseJson.error("无权限查看此订单!", null);
+        }
+        OrderVo order = new OrderVo();
+        // OrderPo -> OrderVo
+        BeanUtils.copyProperties(orderPo, order);
+        order.setOrderMark("#" + order.getOrderId() + "#");
+        // 设置订单状态
+        setOrderStatus(order);
+        // 设置子订单数据
+        getShopOrderData(order);
+        // 子订单列表
+        List<ShopOrderVo> shopOrderList = order.getShopOrderList();
+        AtomicDouble expensesOfTaxation = new AtomicDouble(0d);
+        shopOrderList.forEach(shopOrder -> {
+            List<OrderProductVo> orderProductList = shopOrder.getOrderProductList();
+            orderProductList.forEach(orderProduct -> {
+                // 是否充值商品
+                boolean recharge = productService.isRechargeProduct(orderProduct.getProductId());
+                if (recharge) {
+                    order.setRechargeGoods(true);
+                }
+                // 总税费
+                expensesOfTaxation.set(MathUtil.add(expensesOfTaxation.get(), orderProduct.getTotalAddedValueTax()).doubleValue());
+                //已发货数量
+                orderProduct.setShipmentsNum(orderProduct.getNum() + orderProduct.getPresentNum() - orderProduct.getNotOutStore());
+                //已退货数量
+                Integer returnedNum = orderClubMapper.countReturnedNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
+                returnedNum = null != returnedNum ? returnedNum : 0;
+                orderProduct.setReturnedNum(returnedNum);
+                //已取消发货数量
+                Integer actualCancelNum = orderClubMapper.countActualCancelNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
+                actualCancelNum = null != actualCancelNum ? actualCancelNum : 0;
+                orderProduct.setActualCancelNum(actualCancelNum);
+                //判断商品价格是否含税
+                boolean taxFlag = (1 == orderProduct.getIncludedTax() || (0 == orderProduct.getIncludedTax() && (1 == orderProduct.getInvoiceType() || 2 == orderProduct.getInvoiceType())));
+                if (taxFlag) {
+                    orderProduct.setIncludedTaxFlag(2);
+                } else if (orderProduct.getIncludedTax() != null && 0 == orderProduct.getIncludedTax() && 3 == orderProduct.getInvoiceType()) {
+                    orderProduct.setIncludedTaxFlag(1);
+                } else {
+                    orderProduct.setIncludedTaxFlag(3);
+                }
+            });
+        });
+        order.setExpensesOfTaxation(expensesOfTaxation.get());
+
+        // 发票信息
+        InvoiceVo invoice = baseMapper.getUserInvoice(userId);
+        // 可用余额
+        Double availableMoney = baseMapper.getAbleUserMoney(userId);
+        // 付款金额
+        List<DiscernReceiptVo> discernReceiptList = getDiscernReceiptAndSetOrder(order);
+        // 退款记录
+        List<ReturnedPurchaseVo> returnedPurchaseList = orderClubMapper.getReturnedPurchaseList(order.getOrderId());
+        if (!returnedPurchaseList.isEmpty()) {
+            AtomicDouble returnedPurchaseFee = new AtomicDouble(0d);
+            returnedPurchaseList.forEach(returnedPurchase -> {
+                returnedPurchaseFee.set(MathUtil.add(returnedPurchaseFee.get(), returnedPurchase.getRefundFee()).doubleValue());
+            });
+            //退款总金额
+            order.setReturnedPurchaseFee(returnedPurchaseFee.get());
+        }
+        //售后条款
+        ClauseVo clause = null;
+        // 非二手
+        if (0 == order.getSecondHandOrderFlag()) {
+            Integer clauseId = order.getClauseId() == null ? 1 : order.getClauseId();
+            clause = orderClubMapper.getClauseById(clauseId);
+        }
+        // 收货地址
+        OrderUserinfoVo userInfo = orderClubMapper.getOrderUserinfo(orderId);
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("order", order);
+        map.put("shopOrderList", shopOrderList);
+        map.put("orderInvoice", invoice);
+        map.put("ableUserMoney", availableMoney);
+        map.put("userInfo", userInfo);
+        map.put("discernReceiptList", discernReceiptList);
+        map.put("returnedPurchaseList", returnedPurchaseList);
+        map.put("clause", clause);
+        return ResponseJson.success(map);
+    }
+
     /**
      * 设置订单状态
      */
@@ -142,7 +240,8 @@ public class OrderClubServiceImpl implements OrderClubService {
                 shopOrder.setShopPromotion(shopPromotion);
             }
             List<OrderProductVo> orderProductList = orderClubMapper.getShopOrderProduct(shopOrder.getShopOrderId());
-            for (OrderProductVo orderProduct : orderProductList) {
+            orderProductList.forEach(orderProduct -> {
+                // 不含税可开票商品,单价/折后单价在原基础上加上税费
                 boolean taxFlag = (0 == orderProduct.getIncludedTax() && (1 == orderProduct.getInvoiceType() || 2 == orderProduct.getInvoiceType()));
                 if (taxFlag) {
                     orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), orderProduct.getAddedValueTax()).doubleValue());
@@ -159,7 +258,7 @@ public class OrderClubServiceImpl implements OrderClubService {
                         orderProduct.setProductPromotion(promotions);
                     }
                 }
-            }
+            });
             shopOrder.setOrderProductList(orderProductList);
             shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
         });
@@ -457,7 +556,6 @@ public class OrderClubServiceImpl implements OrderClubService {
     public ResponseJson<Void> receiveGoods(Integer orderId) {
         OrderPo order = orderClubMapper.getMainOrderByOrderId(orderId);
         if (null == order) {
-            // 非已关闭订单
             return ResponseJson.error("订单不存在!", null);
         }
         if (33 == order.getStatus() && 3 == order.getPayStatus()) {
@@ -507,4 +605,58 @@ public class OrderClubServiceImpl implements OrderClubService {
         List<SearchHistoryVo> historyList = orderClubMapper.getOrderSearchHistory(userId);
         return ResponseJson.success(historyList);
     }
+
+    /**
+     * 根据用户Id删除订单搜索历史记录
+     *
+     * @param userId 用户Id
+     */
+    @Override
+    public ResponseJson<Void> deleteOrderSearchHistory(Integer userId) {
+        orderClubMapper.deleteOrderSearchHistory(userId);
+        return ResponseJson.success(null);
+    }
+
+    /**
+     * 物流详情
+     *
+     * @param orderId 订单Id
+     */
+    @Override
+    public ResponseJson<List<LogisticsBatchVo>> getOrderLogistics(Integer orderId) {
+        OrderPo order = orderClubMapper.getMainOrderByOrderId(orderId);
+        if (null == order) {
+            return ResponseJson.error("订单不存在!", null);
+        }
+        // 获取物流批次列表
+        List<LogisticsBatchVo> batchList = orderClubMapper.getLogisticsBatchList(orderId);
+        batchList.forEach(batch -> {
+            // 根据物流批次获取子订单
+            List<String> shopOrderIds = orderClubMapper.getBatchShopOrderIds(orderId, batch.getId());
+            List<ShopOrderVo> shopOrderList = orderClubMapper.getShopOrderList(shopOrderIds);
+            shopOrderList.forEach(shopOrder -> {
+                shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
+                // 获取发货物流记录
+                List<LogisticsRecordVo> logisticsRecordList = orderClubMapper.getLogisticsRecord(shopOrder.getShopOrderId(), batch.getId());
+                shopOrder.setLogisticsRecordList(logisticsRecordList);
+            });
+            // 获取物流信息
+            List<LogisticsInformationVo> logisticsInfoList = orderClubMapper.getLogisticsInfoList(batch.getId());
+            logisticsInfoList.forEach(logisticsInfo -> {
+                List<LogisticsRouterVo> routers = JSONArray.parseArray(logisticsInfo.getInfo(), LogisticsRouterVo.class);
+                if (!CollectionUtils.isEmpty(routers)) {
+                    routers.forEach(router -> {
+                        if (StringUtils.isEmpty(router.getDesc())) {
+                            router.setDesc(router.getContext());
+                        }
+                    });
+                    logisticsInfo.setRouterList(routers);
+                }
+            });
+            batch.setLogisticsInformationList(logisticsInfoList);
+            batch.setShopOrderList(shopOrderList);
+        });
+
+        return ResponseJson.success(batchList);
+    }
 }

+ 144 - 0
src/main/resources/mapper/OrderClubMapper.xml

@@ -102,6 +102,9 @@
             SELECT temp.id FROM (SELECT id FROM user_order_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10) AS temp
         )
     </delete>
+    <delete id="deleteOrderSearchHistory">
+        DELETE FROM user_order_history WHERE userId=#{userId}
+    </delete>
     <insert id="insertSearchHistory">
         INSERT INTO user_order_history (userId, searchWord, searchDate, delFlag)
         VALUES (#{userId}, #{searchWord}, #{searchDate}, #{delFlag})
@@ -500,5 +503,146 @@
         WHERE userId = #{userId}
         ORDER BY id DESC
     </select>
+    <select id="countReturnedNum" resultType="java.lang.Integer">
+        SELECT SUM(crpp.actualReturnedNum)
+        FROM cm_returned_purchase_product crpp
+        LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
+        WHERE crpp.productID = #{productId}
+        AND crpp.shopOrderID = #{shopOrderId}
+        AND rp.status = '2' AND rp.delFlag = '0'
+    </select>
+    <select id="countActualCancelNum" resultType="java.lang.Integer">
+        SELECT SUM(crpp.actualCancelNum)
+        FROM cm_returned_purchase_product crpp
+        LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
+        WHERE crpp.productID = #{productId}
+        AND crpp.shopOrderID = #{shopOrderId}
+        AND rp.status = '2' AND rp.delFlag = '0'
+    </select>
+    <select id="getReturnedPurchaseList" resultType="com.caimei365.order.model.vo.ReturnedPurchaseVo">
+        SELECT
+            id,
+            returnedNo,
+            orderID AS orderId,
+            userID AS userId,
+            status,
+            returnedWay,
+            payType,
+            operatingOrderStatus,
+            returnedBankInfo,
+            bankAccountName,
+            bankAccountNo,
+            openBank,
+            bankAccountType,
+            returnedPurchaseFee,
+            refundFee,
+            refundBalanceFee,
+            refundOnlineFee,
+            refundOfflineFee,
+            image1,
+            image2,
+            image3,
+            image4,
+            image5,
+            reviewImage1,
+            reviewImage2,
+            reviewImage3,
+            reviewImage4,
+            reviewImage5,
+            remarks,
+            reviewRemarks,
+            applicationUserID AS applicationUserId,
+            returnTime,
+            reviewUserID AS reviewUserId,
+            confirmReturnTime,
+            delFlag
+        FROM cm_returned_purchase
+        WHERE orderID = #{orderId} AND STATUS = '2'
+        ORDER BY confirmReturnTime DESC
+    </select>
+    <select id="getClauseById" resultType="com.caimei365.order.model.vo.ClauseVo">
+        SELECT
+            id,
+            name,
+            content,
+            clauseType,
+            enabledStatus
+        FROM bp_clause
+        where id = #{clauseId}
+    </select>
+    <select id="getOrderUserinfo" resultType="com.caimei365.order.model.vo.OrderUserinfoVo">
+        SELECT
+            id,
+            orderId,
+            clubId,
+            userId,
+            name AS userName,
+            shouHuoRen AS name,
+            mobile,
+            phone,
+            postalCode,
+            townId,
+            province,
+            city,
+            town,
+            address
+        FROM bp_order_userinfo
+        WHERE orderId = #{orderId}
+    </select>
+    <select id="getLogisticsBatchList" resultType="com.caimei365.order.model.vo.LogisticsBatchVo">
+        SELECT
+            id,
+            shopOrderID AS shopOrderId,
+            orderID AS orderId,
+            outStoreTimes,
+            status,
+            mailer,
+            shopID AS shopId,
+            updateDate,
+            deliveryTime,
+            receiptTime,
+            remarkImage,
+            remark
+        FROM cm_logistics_batch WHERE orderID= #{orderId}
+    </select>
+    <select id="getBatchShopOrderIds" resultType="java.lang.String">
+        SELECT shopOrderID
+        FROM cm_logistics_record
+        WHERE orderID = #{orderId}
+        AND logisticsBatchID = #{id}
+    </select>
+    <select id="getLogisticsRecord" resultType="com.caimei365.order.model.vo.LogisticsRecordVo">
+        SELECT
+            clr.id,
+            clr.logisticsBatchID AS shopOrderId,
+            clr.shopOrderID AS shopOrderId,
+            clr.orderID AS orderProductId,
+            clr.orderProductID AS orderProductId,
+            clr.buyNum,
+            clr.num,
+            clr.productID AS productId,
+            clr.productName,
+            clr.image
+        FROM cm_logistics_record clr
+        WHERE clr.shopOrderID = #{shopOrderId} AND clr.logisticsBatchID = #{logisticsBatchId}
+    </select>
+    <select id="getLogisticsInfoList" resultType="com.caimei365.order.model.vo.LogisticsInformationVo">
+        SELECT DISTINCT
+            li.id,
+            li.logisticsBatchID AS logisticsBatchId,
+            li.type,
+            li.shopOrderID AS shopOrderId,
+            li.orderProductID AS orderProductId,
+            li.orderID AS orderId,
+            li.nu,
+            li.state,
+            li.info,
+            li.logisticsCompanyName,
+            li.logisticsCompanyCode,
+            li.shopID AS shopId,
+            li.updateDate,
+            li.remarks
+            WHERE li.logisticsBatchID = #{logisticsBatchId}
+    </select>
 
 </mapper>