Explorar o código

分享订单,分享码验证通过

plf %!s(int64=4) %!d(string=hai) anos
pai
achega
6da2911323

+ 3 - 0
caimei-applets-weisha-api.iml

@@ -164,5 +164,8 @@
     <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.7" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.13" level="project" />
+    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.14" level="project" />
   </component>
 </module>

+ 65 - 0
src/main/java/com/caimei/controller/OrderApi.java

@@ -1,6 +1,7 @@
 package com.caimei.controller;
 
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.LogisticsBatchVo;
 import com.caimei.model.vo.OrderVo;
 import com.caimei.service.OrderService;
 import com.github.pagehelper.PageInfo;
@@ -14,6 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Description
  *
@@ -48,4 +52,65 @@ public class OrderApi {
                                                         @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
         return orderService.getOrderList(orderState, userId, organizeId, pageNum, pageSize);
     }
+
+    /**
+     * 订单详情
+     */
+    @ApiOperation("订单详情")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    @GetMapping("/detail")
+    public ResponseJson<Map<String, Object>> getOrderDetail(Integer orderId) {
+        if (orderId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return orderService.getOrderDetail(orderId);
+    }
+
+    /**
+     * 查看物流
+     */
+    @ApiOperation("查看物流")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    @GetMapping("/logistics")
+    public ResponseJson<List<LogisticsBatchVo>> logistics(Integer orderId) {
+        if (orderId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return orderService.logistics(orderId);
+    }
+
+    /**
+     * 确认收货
+     */
+    @ApiOperation("确认收货")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    @GetMapping("/affirm")
+    public ResponseJson<String> affirmCargo(Integer orderId) {
+        return orderService.affirmCargo(orderId);
+    }
+
+    /**
+     * 分享订单
+     */
+    @ApiOperation("分享订单")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    @GetMapping("/share")
+    public ResponseJson<String> shareOrder(Integer orderId) {
+        return orderService.shareOrder(orderId);
+    }
+
+    /**
+     * 分享订单,分享码验证通过
+     */
+    @ApiOperation("分享订单,分享码验证通过")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "shareCode", required = false, value = "分享码"),
+            @ApiImplicitParam(name = "code", required = true, value = "微信唯一凭证"),
+            @ApiImplicitParam(name = "orderId", required = true, value = "订单id"),
+            @ApiImplicitParam(name = "organizeId", required = true, value = "组织id")
+    })
+    @GetMapping("/shareCode")
+    public ResponseJson<Boolean> verifyShareCode(String shareCode, String code, Integer orderId, Integer organizeId) {
+        return orderService.verifyShareCode(shareCode, code, orderId, organizeId);
+    }
 }

+ 129 - 0
src/main/java/com/caimei/mapper/OrderMapper.java

@@ -1,6 +1,8 @@
 package com.caimei.mapper;
 
+import com.caimei.model.po.CmMallOrderShareCodePo;
 import com.caimei.model.po.PromotionsPo;
+import com.caimei.model.po.ShareCodeRecordPo;
 import com.caimei.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -73,4 +75,131 @@ public interface OrderMapper {
      * @return
      */
     DiscernReceiptVo findOfflinePayment(Integer orderId);
+
+    /**
+     * 查询订单收货地址
+     *
+     * @param orderId
+     * @return
+     */
+    UserInfoVo findUserInfo(Integer orderId);
+
+    /**
+     * 查询订单信息
+     *
+     * @param orderId
+     * @return
+     */
+    OrderVo findOrder(Integer orderId);
+
+    /**
+     * 查询已退货数量
+     *
+     * @param shopOrderId
+     * @param productId
+     * @return
+     */
+    Integer returnedPurchase(@Param("shopOrderId") Integer shopOrderId, @Param("productId") Integer productId);
+
+    /**
+     * 查询已取消发货数量
+     *
+     * @param shopOrderId
+     * @param productId
+     * @return
+     */
+    Integer actualCancelNum(@Param("shopOrderId") Integer shopOrderId, @Param("productId") Integer productId);
+
+    /**
+     * 查询订单发票
+     *
+     * @param orderId
+     * @return
+     */
+    OrderInvoiceVo getOrderInvoice(Integer orderId);
+
+    /**
+     * 查询退款记录
+     *
+     * @param orderId
+     * @return
+     */
+    List<ReturnedPurchaseVo> findReturnedPurchase(Integer orderId);
+
+    /**
+     * 查询批次物流信息
+     *
+     * @param shopOrderId
+     * @param batchId
+     * @return
+     */
+    List<LogisticsRecordVo> findLogisticsRecord(@Param("shopOrderId") Integer shopOrderId, @Param("batchId") Long batchId);
+
+    /**
+     * 物流信息
+     *
+     * @param batchId
+     * @return
+     */
+    List<LogisticsInformationVo> findLogisticsInfo(Long batchId);
+
+    /**
+     * 更新物流状态
+     *
+     * @param orderId
+     */
+    void updateLogisticsBatch(Integer orderId);
+
+    /**
+     * 更新订单状态
+     *
+     * @param order
+     */
+    void updateOrderStatus(OrderVo order);
+
+    /**
+     * 查询订单分享信息
+     *
+     * @param orderId
+     * @return
+     */
+    CmMallOrderShareCodePo queryCode(Integer orderId);
+
+    /**
+     * 更新订单分享信息
+     *
+     * @param orderShareCode
+     */
+    void updateCode(CmMallOrderShareCodePo orderShareCode);
+
+    /**
+     * 删除订单分享信息
+     *
+     * @param orderId
+     */
+    void deleteCodeRecord(Integer orderId);
+
+    /**
+     * 保存订单分享信息
+     *
+     * @param orderShareCode
+     */
+    void insertCode(CmMallOrderShareCodePo orderShareCode);
+
+
+    /**
+     * 查询被分享人信息
+     *
+     * @param openid
+     * @param orderId
+     * @return
+     */
+    ShareCodeRecordPo findShareCodeRecord(@Param("openid") String openid, @Param("orderId") Integer orderId);
+
+    /**
+     * 保存被分享人信息
+     *
+     * @param codeRecord
+     */
+    void insertShareCodeRecord(ShareCodeRecordPo codeRecord);
 }

+ 44 - 0
src/main/java/com/caimei/model/po/CmMallOrderShareCodePo.java

@@ -0,0 +1,44 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class CmMallOrderShareCodePo implements Serializable {
+    private Integer id;
+
+    /**
+     * 主订单ID,关联cm_order的ID
+     */
+    private Integer orderID;
+
+    /**
+     * 订单分享码,默认24小时有效
+     */
+    private String shareCode;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     * 过期时间
+     */
+    private Date expiredTime;
+
+    /**
+     *  0 有效  其它无效
+     */
+    private String delFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 54 - 0
src/main/java/com/caimei/model/po/ShareCodeRecordPo.java

@@ -0,0 +1,54 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class ShareCodeRecordPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 使用分享码人的openid,方便码有效期内再次查看
+     */
+    private String openid;
+
+    /**
+     * 主订单ID,关联cm_order的ID
+     */
+    private Integer orderID;
+
+    /**
+     * 订单分享码,关联cm_mall_order_share_code表ID
+     */
+    private Integer shareCodeId;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     *  0 有效  其它无效
+     */
+    private String delFlag;
+
+    /**
+     * 分享码过期时间
+     */
+    private Date expiredTime;
+
+    /**
+     * 子订单ID,关联cm_shop_order的ID
+     */
+    private Integer shopOrderID;
+
+    private static final long serialVersionUID = 1L;
+}

+ 72 - 0
src/main/java/com/caimei/model/vo/LogisticsBatchVo.java

@@ -1,8 +1,11 @@
 package com.caimei.model.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
 
 /**
  * Description
@@ -12,4 +15,73 @@ import java.io.Serializable;
  */
 @Data
 public class LogisticsBatchVo implements Serializable {
+    private Long id;
+
+    /**
+     * 子订单ID
+     */
+    private Long shopOrderID;
+
+    /**
+     * 主订单ID
+     */
+    private String orderID;
+
+    /**
+     * 第几批发货
+     */
+    private Long outStoreTimes;
+
+    /**
+     * 是否确认收货(0:否,1:是)
+     */
+    private String status;
+
+    /**
+     * 邮寄者  0 采美   1 供应商
+     */
+    private String mailer;
+
+    /**
+     * 供应商ID
+     */
+    private Long 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;
+
+    private static final long serialVersionUID = 1L;
 }

+ 92 - 0
src/main/java/com/caimei/model/vo/LogisticsInformationVo.java

@@ -0,0 +1,92 @@
+package com.caimei.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 : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class LogisticsInformationVo implements Serializable {
+    private Long id;
+
+    /**
+     * 发货批次表ID
+     */
+    private Long logisticsBatchID;
+
+    /**
+     * 类型:1 采美365  2 呵呵商城 3 大宗采购
+     */
+    private String type;
+
+    /**
+     * 子订单编号
+     */
+    private Long shopOrderID;
+
+    /**
+     * 订单商品ID
+     */
+    private Long orderProductID;
+
+    /**
+     * 订单ID
+     */
+    private Long 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 Long shopID;
+
+    /**
+     * 最后更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateDate;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * json转换物流追踪信息
+     */
+    private List<RouterVo> routerList;
+
+    private static final long serialVersionUID = 1L;
+}

+ 63 - 0
src/main/java/com/caimei/model/vo/LogisticsRecordVo.java

@@ -0,0 +1,63 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class LogisticsRecordVo implements Serializable {
+    private Long id;
+
+    /**
+     * 发货物流批次ID
+     */
+    private Long logisticsBatchID;
+
+    /**
+     * 子订单ID
+     */
+    private Long shopOrderID;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderID;
+
+    /**
+     * 订单商品ID
+     */
+    private Long orderProductID;
+
+    /**
+     * 商品购买数量
+     */
+    private Long buyNum;
+
+    /**
+     * 此次发货数量
+     */
+    private Long num;
+
+    /**
+     * 商品ID
+     */
+    private Long productID;
+
+    /**
+     * 商品名称
+     */
+    private String productName;
+
+    /**
+     * 商品图片
+     */
+    private String image;
+
+    private static final long serialVersionUID = 1L;
+}

+ 73 - 0
src/main/java/com/caimei/model/vo/OrderInvoiceVo.java

@@ -0,0 +1,73 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class OrderInvoiceVo implements Serializable {
+    private Long id;
+
+    /**
+     * 订单ID
+     */
+    private Long orderId;
+
+    /**
+     * 单位名
+     */
+    private String invoiceTitle;
+
+    /**
+     * 发票类型 普通发票---历史遗留字段后期废弃不使用
+     */
+    private String invoiceType;
+
+    /**
+     * 发票类型 0不开发票 1普通发票 2增值税发票
+     */
+    private String type;
+
+    /**
+     * 发票内容 商品明细
+     */
+    private String invoiceContent;
+
+    /**
+     * 发票抬头类型 0个人  1 企业--(普通发票使用)
+     */
+    private String invoiceTitleType;
+
+    /**
+     * 企业税号、纳税人识别号
+     */
+    private String corporationTaxNum;
+
+    /**
+     * 注册地址
+     */
+    private String registeredAddress;
+
+    /**
+     * 注册电话
+     */
+    private String registeredPhone;
+
+    /**
+     * 开户银行账户
+     */
+    private String bankAccountNo;
+
+    /**
+     * 开户银行
+     */
+    private String openBank;
+
+    private static final long serialVersionUID = 1L;
+}

+ 24 - 51
src/main/java/com/caimei/model/vo/OrderProductVo.java

@@ -16,11 +16,6 @@ import java.math.BigDecimal;
 public class OrderProductVo implements Serializable {
     private Integer orderProductId;
 
-    /**
-     * 主订单编号
-     */
-    private String orderNo;
-
     /**
      * 主订单ID
      */
@@ -31,11 +26,6 @@ public class OrderProductVo implements Serializable {
      */
     private Integer shopOrderId;
 
-    /**
-     * 子订单编号
-     */
-    private String shopOrderNo;
-
     /**
      * 供应商ID
      */
@@ -71,21 +61,6 @@ public class OrderProductVo implements Serializable {
      */
     private String outStoreType;
 
-    /**
-     * skuId
-     */
-    private Integer skuID;
-
-    /**
-     * sku属性
-     */
-    private String props;
-
-    /**
-     * 属性名
-     */
-    private String propName;
-
     /**
      * 商品编号
      */
@@ -106,11 +81,6 @@ public class OrderProductVo implements Serializable {
      */
     private BigDecimal costPrice;
 
-    /**
-     * 记录普通用户购买时价格  活动价优先
-     */
-    private BigDecimal price0;
-
     /**
      * 记录会员用户购买时价格  活动价优先
      */
@@ -226,36 +196,16 @@ public class OrderProductVo implements Serializable {
      */
     private String status;
 
-    /**
-     * 是否已评论:1是,空或0未评论(V5.0.0版本后已废弃--)
-     */
-    private String commentFlag;
-
-    /**
-     * 获取到的总采美豆值
-     */
-    private BigDecimal totalBeans;
-
     /**
      * 使用余额金额
      */
     private Double useBalanceAmount;
 
-    /**
-     * 使用采美豆数量
-     */
-    private Integer useBeanAmount;
-
     /**
      * 未出库数量
      */
     private Integer notOutStore;
 
-    /**
-     * 当前采美豆专区价格(采美豆)
-     */
-    private Integer cmbeanPrice;
-
     /**
      * 下单时商品购买价格类型快照 0 机构价,1活动价 ,2阶梯价
      */
@@ -335,7 +285,30 @@ public class OrderProductVo implements Serializable {
 
     private Integer cancelNum;
 
-    private PromotionsPo ProductPromotion;
+    /**
+     * 已发货数量
+     */
+    private Integer shipmentsNum;
+
+    /**
+     * 已退货数量
+     */
+    private Integer returnedNum;
+
+    /**
+     * 已取消发货数量
+     */
+    private Integer actualCancelNum;
+
+    /**
+     * 商品前台展示单价是否含税,1不含税,2含税,3其他
+     */
+    private String includedTaxFlag;
+
+    /**
+     * 促销信息
+     */
+    private PromotionsPo productPromotion;
 
     private static final long serialVersionUID = 1L;
 }

+ 17 - 156
src/main/java/com/caimei/model/vo/OrderVo.java

@@ -1,5 +1,6 @@
 package com.caimei.model.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -27,49 +28,19 @@ public class OrderVo implements Serializable {
     /**
      * 采美组织默认为0,具体对应cm_mall_organize表ID
      */
-    private Integer organizeID;
+    private Integer organizeId;
 
-    private Long userID;
+    private Long userId;
 
     /**
      * 下单人
      */
-    private Integer buyUserID;
+    private Integer buyUserId;
 
     /**
      * 子订单ID
      */
-    private String shopOrderIDs;
-
-    /**
-     * 0:个人自己下单 1:企业自己下单 2:员工帮会所下单 3:协销帮会所下单  4:后台下单 5:采美豆订单【1、5已弃用】
-     */
-    private Integer orderSubmitType;
-
-    /**
-     * 订单类型 0协销订单、 1普通订单
-     */
-    private Integer orderType;
-
-    /**
-     * 二手商品订单标识  0非二手商品订单、 1二手商品订单
-     */
-    private String secondHandOrderFlag;
-
-    /**
-     * 确认付款供应商标志,0未确认,1已确认
-     */
-    private String affirmPaymentFlag;
-
-    /**
-     * 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
-     */
-    private String hasActProduct;
-
-    /**
-     * 订单自动关闭时间点单位毫秒(v5.0版本已废弃)
-     */
-    private BigDecimal autoCloseTimeMills;
+    private String shopOrderIds;
 
     /**
      * 0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
@@ -111,16 +82,6 @@ public class OrderVo implements Serializable {
      */
     private String onlinePayFlag;
 
-    /**
-     * 商品总金额 (商品单价乘以数量,再加上税费)
-     */
-    private BigDecimal productTotalFee;
-
-    /**
-     * 小计金额 (商品折后单价乘以数量,再加上税费)
-     */
-    private BigDecimal orderTotalFee;
-
     /**
      * 订单总额(小计金额减去经理折扣后,再加上运费)
      */
@@ -136,11 +97,6 @@ public class OrderVo implements Serializable {
      */
     private BigDecimal balancePayFee;
 
-    /**
-     * 总优惠 自助下单活动优惠 协销下单price-折后单价
-     */
-    private BigDecimal preferential;
-
     /**
      * 经理折扣
      */
@@ -151,99 +107,31 @@ public class OrderVo implements Serializable {
      */
     private BigDecimal promotionFullReduction;
 
-    private Long spID;
-
-    private Long mainSpID;
-
     /**
      * 订单备注
      */
     private String note;
 
-    /**
-     * 会所ID
-     */
-    private Long clubID;
-
-    /**
-     * 会所扫描确认时间
-     */
-    private String clubScanTime;
-
-    /**
-     * 支付方式,(协销订单可能会存在多种进账方式用,隔开)(v5.0版本已废弃)
-     */
-    private String payWay;
-
     /**
      * 订单来源:1WWW、2CRM、3APP[历史数据]、4客服、5外单、6小程序[采美,星范等]
      */
     private String orderSource;
 
-    /**
-     * 订单取消时间
-     */
-    private String closeTime;
-
-    /**
-     * 订单确认时间
-     */
-    private String confirmTime;
-
-    /**
-     * 订单支付时间
-     */
-    private String payTime;
-
     /**
      * 订单提交时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private String orderTime;
 
-    /**
-     * 购买总数
-     */
-    private Integer productCount;
-
-    /**
-     * 赠送总数  不计算价格
-     */
-    private Integer presentCount;
-
-    /**
-     * 促销赠品总数
-     */
-    private Integer promotionalGiftsCount;
-
-    /**
-     * 库分期免息状态 0、免息 1、不免息[V5.0.0版本已废弃]
-     */
-    private String cooFreeFlag;
-
-    /**
-     * 库分期分期费率[V5.0.0版本已废弃]
-     */
-    private Integer cooFreeRate;
-
-    /**
-     * 库分期免息金额[V5.0.0版本已废弃]
-     */
-    private BigDecimal cooFreeAmount;
-
     /**
      * 是否开发票 没开发票 0 开个人发票 1 开企业发票2
      */
     private String invoiceFlag;
 
-    /**
-     * 订单确认标志,0否,1后台确认,2买家确认(适用协销订单并且1或2都算已确认订单,主动订单默认1为确认)
-     */
-    private String confirmFlag;
-
     /**
      * 条款ID
      */
-    private Long clauseID;
+    private Long clauseId;
 
     /**
      * 条款内容
@@ -255,11 +143,6 @@ public class OrderVo implements Serializable {
      */
     private String clauseName;
 
-    /**
-     * 更新时间
-     */
-    private String updateDate;
-
     /**
      * 免邮标志  运费:-1到付,0包邮,1需要运费,-2仪器到付其它包邮
      */
@@ -270,21 +153,6 @@ public class OrderVo implements Serializable {
      */
     private BigDecimal freight;
 
-    /**
-     * 订单状态 0 有效  其它无效
-     */
-    private String delFlag;
-
-    /**
-     * 包邮券ID  保留字段
-     */
-    private Integer freePostageTicketID;
-
-    /**
-     * 订单是否可拆分   1可拆分 0不可拆分
-     */
-    private String splitFlag;
-
     /**
      * 订单取消原因
      */
@@ -295,23 +163,6 @@ public class OrderVo implements Serializable {
      */
     private String postageOrderFlag;
 
-    /**
-     * 第三方订单编号(绑定第三方订单关系),适用第三方发起订单
-     */
-    private String thirdPartyOrderNo;
-
-    /**
-     * 订单是否同步发货物流给第三方,0未同步,1已同步
-     */
-    private String synchronizeFlag;
-
-    private Boolean authority;
-
-    /**
-     * 返佣订单标识,0非返佣订单,1返佣订单
-     */
-    private String rebateFlag;
-
     /**
      * 订单0成本标识:订单不是0成本,1订单0成本(订单中所有商品成本为0)
      */
@@ -332,6 +183,16 @@ public class OrderVo implements Serializable {
      */
     private BigDecimal returnedPurchaseFee;
 
+    /**
+     * 订单标识:#订单号#
+     */
+    private String orderMark;
+
+    /**
+     * 总税费
+     */
+    private BigDecimal ExpensesOfTaxation;
+
     /**
      * 支付按钮是否消失,true消失
      */

+ 189 - 0
src/main/java/com/caimei/model/vo/ReturnedPurchaseVo.java

@@ -0,0 +1,189 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class ReturnedPurchaseVo implements Serializable {
+    private Long id;
+
+    /**
+     * 退款退货编号
+     */
+    private String returnedNo;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderID;
+
+    /**
+     * 用户ID(买家)
+     */
+    private Long 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 BigDecimal returnedPurchaseFee;
+
+    /**
+     * 退款总额(给买家)
+     */
+    private BigDecimal refundFee;
+
+    /**
+     * 退账户余额
+     */
+    private BigDecimal refundBalanceFee;
+
+    /**
+     * 退线上退回
+     */
+    private BigDecimal refundOnlineFee;
+
+    /**
+     * 退线下转账
+     */
+    private BigDecimal 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 Long applicationUserID;
+
+    /**
+     * 申请退款时间
+     */
+    private String returnTime;
+
+    /**
+     * 审核人ID
+     */
+    private Long reviewUserID;
+
+    /**
+     * 确认退款时间(审核退款时间)
+     */
+    private String confirmReturnTime;
+
+    /**
+     * 是否有效状态 0 有效  其它无效(适用取消退款等)
+     */
+    private String delFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 21 - 0
src/main/java/com/caimei/model/vo/RouterVo.java

@@ -0,0 +1,21 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+/**
+ * 物流跟踪信息描述Entity
+ * @author Administrator
+ */
+@Data
+public class RouterVo {
+
+    /**
+     * 描述
+     */
+    private String desc;
+
+    /**
+     * 时间
+     */
+    private String time;
+}

+ 9 - 83
src/main/java/com/caimei/model/vo/ShopOrderVo.java

@@ -25,45 +25,25 @@ public class ShopOrderVo implements Serializable {
      */
     private String shopOrderNo;
 
-    /**
-     * 订单编号
-     */
-    private String orderNo;
-
     /**
      * 主订单ID
      */
-    private Long orderID;
+    private Long orderId;
 
     /**
      * 采美组织默认为null,具体对应cm_mall_organize表ID
      */
-    private Integer organizeID;
+    private Integer organizeId;
 
     /**
      * 用户Id
      */
-    private Integer userID;
+    private Integer userId;
 
     /**
      * 供应商Id
      */
-    private Integer shopID;
-
-    /**
-     * 订单促销id(主要针对店铺促销)
-     */
-    private Integer orderPromotionsId;
-
-    /**
-     * 普通订单 1 协销订单0 与cm_order一样
-     */
-    private Integer orderType;
-
-    /**
-     * 0:个人自己下单 1:企业自己下单 2:员工帮会所下单 3:协销帮会所下单  4:后台下单 5:采美豆订单
-     */
-    private Integer orderSubmitType;
+    private Integer shopId;
 
     /**
      * 赠品数
@@ -122,11 +102,6 @@ public class ShopOrderVo implements Serializable {
 
     private BigDecimal discountAmount;
 
-    /**
-     * 经理折扣(v5.0版本已废弃,经理折扣只和主订单有关)
-     */
-    private BigDecimal discountFee;
-
     /**
      * 订单总优惠
      */
@@ -162,11 +137,6 @@ public class ShopOrderVo implements Serializable {
      */
     private Long autoOverTimeMills;
 
-    /**
-     * 订单状态:见表c_orderstatus或枚举OrderStatus(v5.0版本已废弃只有主订单状态)
-     */
-    private Integer status;
-
     /**
      * (付款供应商)付款状态:1待付款、2部分付款、3已付款
      */
@@ -208,25 +178,6 @@ public class ShopOrderVo implements Serializable {
 
     private Integer clubID;
 
-    private Integer spID;
-
-    private Integer mainSpID;
-
-    /**
-     * 订单采美豆个数
-     */
-    private Integer orderBeanAmount;
-
-    /**
-     * 使用采美豆数量
-     */
-    private Integer useBeanAmount;
-
-    /**
-     * 是否使用采美豆
-     */
-    private Integer useBeanFlag;
-
     /**
      * 是否可以退货 1可以退款/退货 0不可退款/退货
      */
@@ -237,21 +188,11 @@ public class ShopOrderVo implements Serializable {
      */
     private Integer useBalanceFlag;
 
-    /**
-     * 可以退还的采美豆个数
-     */
-    private Integer canRefundBeans;
-
     /**
      * 订单包邮时本该支付的运费
      */
     private BigDecimal freePostageFee;
 
-    /**
-     * 使用的包邮券Id,为空表示未使用包邮券  保留
-     */
-    private Integer freePostageTicketID;
-
     /**
      * 佣金 =  应付采美
      */
@@ -284,11 +225,6 @@ public class ShopOrderVo implements Serializable {
 
     private Integer orderDeliveryID;
 
-    /**
-     * 订单能否拆分 1 为可拆分, 0为不可拆分
-     */
-    private String splitFlag;
-
     /**
      * 是否处于给供应商状态中   0不是的,  1是的
      */
@@ -338,21 +274,6 @@ public class ShopOrderVo implements Serializable {
      */
     private BigDecimal proportional;
 
-    /**
-     * 修改应付必填备注信息
-     */
-    private String modifyShouldPayNote;
-
-    /**
-     * 修改应付金额的用户ID
-     */
-    private Long modifyShouldPayUserID;
-
-    /**
-     * 修改应付金额的时间
-     */
-    private Date modifyShouldPayDate;
-
     /**
      * 子订单0成本标识:0子订单不是0成本,1子订单0成本(子订单中所有商品成本为0)
      */
@@ -365,5 +286,10 @@ public class ShopOrderVo implements Serializable {
 
     private List<OrderProductVo> orderProductList;
 
+    /**
+     * 发货物流记录
+     */
+    private List<LogisticsRecordVo> logisticsRecordList;
+
     private static final long serialVersionUID = 1L;
 }

+ 51 - 0
src/main/java/com/caimei/model/vo/UserInfoVo.java

@@ -0,0 +1,51 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/29
+ */
+@Data
+public class UserInfoVo implements Serializable {
+    private Long id;
+
+    /**
+     * 买家
+     */
+    private String name;
+
+    /**
+     * 收货人
+     */
+    private String shouHuoRen;
+
+    /**
+     * 手机
+     */
+    private String mobile;
+
+    /**
+     * 省、直辖市
+     */
+    private String province;
+
+    /**
+     * 市
+     */
+    private String city;
+
+    /**
+     * 县、区
+     */
+    private String town;
+
+    /**
+     * 收货地址
+     */
+    private String address;
+}

+ 46 - 0
src/main/java/com/caimei/service/OrderService.java

@@ -1,9 +1,13 @@
 package com.caimei.service;
 
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.LogisticsBatchVo;
 import com.caimei.model.vo.OrderVo;
 import com.github.pagehelper.PageInfo;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * Description
  *
@@ -22,4 +26,46 @@ public interface OrderService {
      * @return
      */
     ResponseJson<PageInfo<OrderVo>> getOrderList(Integer orderState, Integer userId, Integer organizeId, Integer pageNum, Integer pageSize);
+
+    /**
+     * 订单详情
+     *
+     * @param orderId
+     * @return
+     */
+    ResponseJson<Map<String, Object>> getOrderDetail(Integer orderId);
+
+    /**
+     * 物流信息
+     *
+     * @param orderId
+     * @return
+     */
+    ResponseJson<List<LogisticsBatchVo>> logistics(Integer orderId);
+
+    /**
+     * 确认收货
+     *
+     * @param orderId
+     * @return
+     */
+    ResponseJson<String> affirmCargo(Integer orderId);
+
+    /**
+     * 分享订单
+     *
+     * @param orderId
+     * @return
+     */
+    ResponseJson<String> shareOrder(Integer orderId);
+
+    /**
+     * 分享订单,分享码验证通过
+     * @param shareCode
+     * @param code
+     * @param orderId
+     * @param organizeId
+     * @return
+     */
+    ResponseJson<Boolean> verifyShareCode(String shareCode, String code, Integer orderId, Integer organizeId);
 }

+ 241 - 2
src/main/java/com/caimei/service/impl/OrderServiceImpl.java

@@ -1,21 +1,30 @@
 package com.caimei.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.config.WxConfig;
+import com.caimei.mapper.LoginMapper;
 import com.caimei.mapper.OrderMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.enumerate.ReceivablesType;
+import com.caimei.model.po.CmMallOrderShareCodePo;
 import com.caimei.model.po.PromotionsPo;
+import com.caimei.model.po.ShareCodeRecordPo;
 import com.caimei.model.vo.*;
 import com.caimei.service.OrderService;
 import com.caimei.util.MathUtil;
 import com.caimei.util.ProductUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.List;
+import java.util.*;
 
 /**
  * Description
@@ -23,10 +32,13 @@ import java.util.List;
  * @author : plf
  * @date : 2021/3/26
  */
+@Slf4j
 @Service
 public class OrderServiceImpl implements OrderService {
     @Resource
     private OrderMapper orderMapper;
+    @Resource
+    private LoginMapper loginMapper;
     @Value("${caimei.oldapi}")
     private String domain;
 
@@ -70,7 +82,7 @@ public class OrderServiceImpl implements OrderService {
                 shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
             }
             //过滤运费商品
-            shopOrderList.removeIf(shopOrderVo -> shopOrderVo.getShopID() == 998);
+            shopOrderList.removeIf(shopOrderVo -> shopOrderVo.getShopId() == 998);
             order.setShopOrderList(shopOrderList);
             //设置付款金额
             getDiscernReceipt(order);
@@ -79,6 +91,233 @@ public class OrderServiceImpl implements OrderService {
         return ResponseJson.success(pageData);
     }
 
+    @Override
+    public ResponseJson<Map<String, Object>> getOrderDetail(Integer orderId) {
+        Map<String, Object> map = new HashMap<>(6);
+        //收货地址
+        UserInfoVo userInfo = orderMapper.findUserInfo(orderId);
+        //订单信息,运费
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("该订单已删除", null);
+        }
+        order.setOrderMark("#" + order.getOrderId() + "#");
+        //111,待付待收待发
+        if ("11".equals(order.getStatus()) && "1".equals(order.getPayStatus())) {
+            order.setStatus("111");
+        }
+        //判断交易全退情况下,是否发过货,77,交易全退可以查看物流
+        List<LogisticsBatchVo> batchList = orderMapper.findLogistics(orderId);
+        if ("7".equals(order.getStatus()) && batchList != null && batchList.size() > 0) {
+            order.setStatus("77");
+        }
+        //商品信息
+        List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(orderId);
+        BigDecimal expensesOfTaxation = new BigDecimal(0);
+        for (ShopOrderVo shopOrder : shopOrderList) {
+            List<OrderProductVo> orderProductList = orderMapper.findOrderProduct(shopOrder.getShopOrderId());
+            for (OrderProductVo orderProduct : orderProductList) {
+                //运费
+                if (shopOrder.getShopId() == 998) {
+                    order.setFreight(orderProduct.getPrice1());
+                }
+                //总税费
+                expensesOfTaxation = expensesOfTaxation.add(orderProduct.getTotalAddedValueTax());
+                orderProduct.setProductImage(ProductUtils.getImageURL("product", orderProduct.getProductImage(), 0, domain));
+                //已发货数量
+                orderProduct.setShipmentsNum(orderProduct.getNum() + orderProduct.getPresentNum() - orderProduct.getNotOutStore());
+                //已退货数量
+                Integer returnedNum = orderMapper.returnedPurchase(orderProduct.getShopOrderId(), orderProduct.getProductId());
+                returnedNum = null != returnedNum ? returnedNum : 0;
+                orderProduct.setReturnedNum(returnedNum);
+                //已取消发货数量
+                Integer actualCancelNum = orderMapper.actualCancelNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
+                actualCancelNum = null != actualCancelNum ? actualCancelNum : 0;
+                orderProduct.setActualCancelNum(actualCancelNum);
+                //查询订单下商品的促销活动
+                if (orderProduct.getOrderPromotionsId() != null && orderProduct.getOrderPromotionsId() > 0) {
+                    PromotionsPo orderPromotionsById = orderMapper.findOrderPromotionsById(orderProduct.getOrderPromotionsId());
+                    if (orderPromotionsById.getType() == 1) {
+                        if ("0".equals(orderProduct.getIncludedTax()) && ("1".equals(orderProduct.getInvoiceType()) || "2".equals(orderProduct.getInvoiceType()))) {
+                            orderPromotionsById.setTouchPrice(MathUtil.add(orderPromotionsById.getTouchPrice(), MathUtil.div(MathUtil.mul(orderPromotionsById.getTouchPrice(), orderProduct.getTaxRate()), 100)));
+                        }
+                    }
+                    orderProduct.setProductPromotion(orderPromotionsById);
+                }
+                //判断商品价格是否含税
+                if ("1".equals(orderProduct.getIncludedTax()) || ("0".equals(orderProduct.getIncludedTax()) && ("1".equals(orderProduct.getInvoiceType()) || "2".equals(orderProduct.getInvoiceType())))) {
+                    orderProduct.setIncludedTaxFlag("2");
+                } else if (orderProduct.getIncludedTax() != null && "0".equals(orderProduct.getIncludedTax()) && "3".equals(orderProduct.getInvoiceType())) {
+                    orderProduct.setIncludedTaxFlag("1");
+                } else {
+                    orderProduct.setIncludedTaxFlag("3");
+                }
+                //不含税可开票商品,单价/折后单价在原基础上加上税费
+                if ("0".equals(orderProduct.getIncludedTax()) && ("1".equals(orderProduct.getInvoiceType()) || "2".equals(orderProduct.getInvoiceType()))) {
+                    //计算单价的税费
+                    BigDecimal valueTax = MathUtil.div(MathUtil.mul(orderProduct.getPrice(), orderProduct.getTaxRate()), 100);
+                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax));
+                    orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getDiscountPrice(), orderProduct.getAddedValueTax()));
+                }
+            }
+            shopOrder.setOrderProductList(orderProductList);
+            shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
+        }
+        order.setExpensesOfTaxation(expensesOfTaxation);
+        //删除运费商品
+        shopOrderList.removeIf(student -> 998 == student.getShopId());
+        //发票信息
+        OrderInvoiceVo orderInvoice = orderMapper.getOrderInvoice(orderId);
+        List<DiscernReceiptVo> discernReceiptList = getDiscernReceipt(order);
+        //退款记录
+        List<ReturnedPurchaseVo> returnedPurchaseList = orderMapper.findReturnedPurchase(order.getOrderId());
+        if (returnedPurchaseList != null && returnedPurchaseList.size() > 0) {
+            BigDecimal returnedPurchaseFee = new BigDecimal(0);
+            for (ReturnedPurchaseVo returnedPurchase : returnedPurchaseList) {
+                returnedPurchaseFee = returnedPurchaseFee.add(returnedPurchase.getRefundFee());
+            }
+            //退款总金额
+            order.setReturnedPurchaseFee(returnedPurchaseFee);
+        }
+        map.put("order", order);
+        map.put("userInfo", userInfo);
+        map.put("shopOrderList", shopOrderList);
+        map.put("orderInvoice", orderInvoice);
+        map.put("discernReceiptList", discernReceiptList);
+        map.put("returnedPurchaseList", returnedPurchaseList);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson<List<LogisticsBatchVo>> logistics(Integer orderId) {
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("订单已删除", null);
+        }
+        List<LogisticsBatchVo> batchList = orderMapper.findLogistics(orderId);
+        for (LogisticsBatchVo batch : batchList) {
+            List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(orderId);
+            for (ShopOrderVo shopOrder : shopOrderList) {
+                List<LogisticsRecordVo> logisticsRecordList = orderMapper.findLogisticsRecord(shopOrder.getShopOrderId(), batch.getId());
+                for (LogisticsRecordVo logisticsRecord : logisticsRecordList) {
+                    logisticsRecord.setImage(ProductUtils.getImageURL("product", logisticsRecord.getImage(), 0, domain));
+                }
+                shopOrder.setLogisticsRecordList(logisticsRecordList);
+                shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
+            }
+            //物流信息
+            List<LogisticsInformationVo> logisticsInfoList = orderMapper.findLogisticsInfo(batch.getId());
+            for (LogisticsInformationVo logisticsInfo : logisticsInfoList) {
+                List<RouterVo> routers = JSONArray.parseArray(logisticsInfo.getInfo(), RouterVo.class);
+                logisticsInfo.setRouterList(routers);
+            }
+            batch.setLogisticsInformationList(logisticsInfoList);
+            batch.setShopOrderList(shopOrderList);
+        }
+        return ResponseJson.success(batchList);
+    }
+
+    @Override
+    public ResponseJson<String> affirmCargo(Integer orderId) {
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        if ("33".equals(order.getStatus()) && "3".equals(order.getPayStatus())) {
+            //已付款供应商,订单完成
+            order.setStatus("5");
+            orderMapper.updateOrderStatus(order);
+            orderMapper.updateLogisticsBatch(orderId);
+        } else if ("33".equals(order.getStatus())) {
+            //交易完成
+            order.setStatus("4");
+            orderMapper.updateOrderStatus(order);
+            orderMapper.updateLogisticsBatch(orderId);
+        } else {
+            return ResponseJson.error("订单异常", null);
+        }
+        return ResponseJson.success("");
+    }
+
+    @Override
+    public ResponseJson<String> shareOrder(Integer orderId) {
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        CmMallOrderShareCodePo orderShareCode = orderMapper.queryCode(orderId);
+        //生成分享码
+        String shareCode = RandomStringUtils.random(4, false, true);
+        //过期时间
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DATE, 1);
+        if (orderShareCode != null && orderShareCode.getExpiredTime().compareTo(new Date()) > -1) {
+            return ResponseJson.success(orderShareCode.getShareCode());
+        } else if (orderShareCode != null) {
+            orderShareCode.setShareCode(shareCode);
+            orderShareCode.setExpiredTime(calendar.getTime());
+            orderShareCode.setDelFlag("0");
+            orderMapper.updateCode(orderShareCode);
+            orderMapper.deleteCodeRecord(orderId);
+            return ResponseJson.success(shareCode);
+        } else {
+            CmMallOrderShareCodePo code = new CmMallOrderShareCodePo();
+            code.setOrderID(orderId);
+            code.setShareCode(shareCode);
+            code.setExpiredTime(calendar.getTime());
+            code.setAddTime(new Date());
+            code.setDelFlag("0");
+            orderMapper.insertCode(code);
+            return ResponseJson.success(shareCode);
+        }
+    }
+
+    @Override
+    public ResponseJson<Boolean> verifyShareCode(String shareCode, String code, Integer orderId, Integer organizeId) {
+        String infos;
+        try {
+            infos = WxConfig.getWxMallOpenId(code);
+        } catch (Exception e) {
+            log.info("微信服务器异常", e);
+            return ResponseJson.error("微信服务器异常", null);
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        log.info("小程序openid----->" + openid);
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error(-2, "该订单已删除", null);
+        }
+        BuyerUserVo buyer = loginMapper.findBuyer(openid);
+        if (buyer != null && buyer.getOrganizeId().equals(organizeId)) {
+            return ResponseJson.success(true);
+        }
+        ShareCodeRecordPo shareCodeRecord = orderMapper.findShareCodeRecord(openid, orderId);
+        if (shareCodeRecord != null && shareCodeRecord.getExpiredTime().compareTo(new Date()) > 0) {
+            return ResponseJson.success(null);
+        }
+        CmMallOrderShareCodePo shareCodePo = orderMapper.queryCode(orderId);
+        if (shareCodePo == null) {
+            return ResponseJson.error("该订单没有生成分享码", null);
+        }
+        if (shareCodePo.getShareCode().equals(shareCode) && shareCodePo.getExpiredTime().compareTo(new Date()) > 0) {
+            ShareCodeRecordPo codeRecord = new ShareCodeRecordPo();
+            codeRecord.setOpenid(openid);
+            codeRecord.setAddTime(new Date());
+            codeRecord.setOrderID(shareCodePo.getOrderID());
+            codeRecord.setDelFlag("0");
+            codeRecord.setShareCodeId(shareCodePo.getId());
+            orderMapper.insertShareCodeRecord(codeRecord);
+            return ResponseJson.success(null);
+        } else if (shareCodePo.getShareCode().equals(shareCode) && shareCodePo.getExpiredTime().compareTo(new Date()) != 1) {
+            return ResponseJson.error("分享码已失效", null);
+        } else {
+            return ResponseJson.error("分享码错误", null);
+        }
+    }
+
     /**
      * 支付金额,待付金额
      */

+ 5 - 1
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -182,6 +182,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         order.setClubID(user.getClubID().longValue());
         // 订单来源
         order.setOrderSource(orderSource);
+        order.setOrganizeID(user.getUserOrganizeID());
         order.setUpdateDate(curDateStr);
         order.setPayFlag("0");
         order.setCooFreeFlag("0");
@@ -454,6 +455,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         for (CmOrderProductPo orderProduct : orderProductList) {
             orderProduct.setOrderID(order.getOrderID());
             orderProduct.setOrderNo(order.getOrderNo());
+            orderProduct.setOrganizeID(order.getOrganizeID());
             PromotionsPo promotions = productMapper.findPromotionByProductId(orderProduct.getProductID());
             if (promotions != null) {
                 PromotionsPo orderPromotions = orderSubmitMapper.findOrderPromotions(orderProduct.getOrderID(), promotions.getId());
@@ -646,7 +648,8 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
     private CmOrderProductPo setOrderProduct(Integer productNum, CmOrganizeProductPo product, BigDecimal productPrice, Integer priceType, Integer productType, BigDecimal addedValueTax) {
         CmOrderProductPo orderProduct = new CmOrderProductPo();
         orderProduct.setShopID(product.getShopId().longValue());
-        orderProduct.setProductID(product.getId());
+        orderProduct.setProductID(product.getProductId());
+        orderProduct.setOrganizeProductID(product.getId());
         // 预留在保存保存子订单的时候添加
         orderProduct.setProductNo(null);
         orderProduct.setNum(productNum);
@@ -829,6 +832,7 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
         shopOrder.setOrderID(order.getOrderID());
         shopOrder.setOrderNo(order.getOrderNo());
         shopOrder.setUserID(order.getUserID().intValue());
+        shopOrder.setOrganizeID(order.getOrganizeID());
         /*
          *  统计子订单金额信息
          */

+ 5 - 5
src/main/java/com/caimei/service/impl/PayOrderServiceImpl.java

@@ -114,7 +114,7 @@ public class PayOrderServiceImpl implements PayOrderService {
         orderProductList.removeIf(orderProductVo -> orderProductVo.getShopId() == 998);
         map.put("orderProductList", orderProductList);
         //机构信息
-        UserPo user = payOrderMapper.findUser(order.getUserID());
+        UserPo user = payOrderMapper.findUser(order.getUserId());
         map.put("userName", user.getName());
         return ResponseJson.success(map);
     }
@@ -193,7 +193,7 @@ public class PayOrderServiceImpl implements PayOrderService {
             BigDecimal shopTotalAmount = BigDecimal.ZERO;
             String subUserNo = "";
             for (SplitAccountVo account : splitBillDetail) {
-                if ("4".equals(account.getType()) && shopOrder.getShopID().equals(account.getShopId())) {
+                if ("4".equals(account.getType()) && shopOrder.getShopId().equals(account.getShopId())) {
                     shopTotalAmount = MathUtil.add(shopTotalAmount, account.getSplitAccount());
                     subUserNo = account.getSubUserNo();
                 }
@@ -353,7 +353,7 @@ public class PayOrderServiceImpl implements PayOrderService {
                 //运费
                 BigDecimal shopPostFee = shopOrder.getShopPostFee();
                 if (MathUtil.compare(shopPostFee, 0) > 0) {
-                    BigDecimal shipping = payOrderMapper.findShipping(order.getOrderId(), shopOrder.getShopID());
+                    BigDecimal shipping = payOrderMapper.findShipping(order.getOrderId(), shopOrder.getShopId());
                     shopPostFee = MathUtil.sub(shopPostFee, shipping);
                     if (MathUtil.compare(splitAmount, shopPostFee) > -1) {
                         splitAmount = MathUtil.sub(splitAmount, shipping);
@@ -361,10 +361,10 @@ public class PayOrderServiceImpl implements PayOrderService {
                         shopPostFee = splitAmount;
                         splitAmount = BigDecimal.ZERO;
                     }
-                    String commercialCode = payOrderMapper.findCommercialCode(Long.valueOf(shopOrder.getShopID()));
+                    String commercialCode = payOrderMapper.findCommercialCode(Long.valueOf(shopOrder.getShopId()));
                     SplitAccountVo splitAccount = new SplitAccountVo();
                     splitAccount.setOrderId(order.getOrderId());
-                    splitAccount.setShopId(shopOrder.getShopID());
+                    splitAccount.setShopId(shopOrder.getShopId());
                     splitAccount.setSplitAccount(shopPostFee);
                     splitAccount.setProductType("2");
                     if (StringUtils.isNotBlank(commercialCode)) {

+ 237 - 4
src/main/resources/mapper/OrderMapper.xml

@@ -3,16 +3,38 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.mapper.OrderMapper">
-    <select id="findOrderList" resultType="com.caimei.model.vo.OrderVo">
-        select
+    <sql id="cm_Order_List">
           orderID AS orderId,
+          orderNo,
           organizeID AS organizeId,
           userID AS userId,
+          buyUserID AS buyUserId,
           status,
           shopOrderIDs AS shopOrderIds,
           receiptStatus,
           payStatus,
-          sendOutStatus
+          sendOutStatus,
+          refundType,
+          onlinePayFlag,
+          payTotalFee,
+          payableAmount,
+          balancePayFee,
+          discountFee,
+          promotionFullReduction,
+          note,
+          orderSource,
+          orderTime,
+          invoiceFlag,
+          clauseID AS clauseId,
+          clauseContent,
+          clauseName,
+          freePostFlag,
+          freight,
+          closeReason
+    </sql>
+    <select id="findOrderList" resultType="com.caimei.model.vo.OrderVo">
+        select
+          <include refid="cm_Order_List"></include>
         from cm_order
         where delFlag = '0'
         AND userID = #{userId}
@@ -42,6 +64,11 @@
     <select id="findAllShopOrder" resultType="com.caimei.model.vo.ShopOrderVo">
         SELECT
         cso.shopOrderID AS shopOrderId,
+        cso.shopOrderNo,
+        cso.orderID AS orderId,
+        cso.organizeID AS organizeId,
+        cso.userID AS userId,
+        cso.shopID AS shopId,
         s.name AS shopName,
         s.logo AS shopLogo
         FROM
@@ -55,6 +82,29 @@
     <select id="findOrderProduct" resultType="com.caimei.model.vo.OrderProductVo">
         SELECT
           cop.orderProductID AS orderProductId,
+          cop.orderID AS orderId,
+          cop.shopOrderID AS shopOrderId,
+          cop.shopID AS shopId,
+          cop.productID AS productId,
+          cop.organizeProductID AS organizeProductId,
+          cop.organizeID AS organizeId,
+          cop.num,
+          cop.presentNum,
+          cop.outStoreType,
+          cop.productNo,
+          cop.price,
+          cop.normalPrice,
+          cop.costPrice,
+          cop.price1,
+          cop.totalAmount,
+          cop.totalFee,
+          cop.shouldPayFee,
+          cop.discount,
+          cop.discountPrice,
+          cop.includedTax,
+          cop.invoiceType,
+          cop.totalAddedValueTax,
+          cop.notOutStore,
           p.mainImage AS productImage,
           p.productCategory as productCategory
         FROM
@@ -85,7 +135,8 @@
 
     <select id="findDiscernReceipt" resultType="com.caimei.model.vo.DiscernReceiptVo">
         SELECT
-          cdr.*,cror.associateAmount
+          cdr.*,
+          cror.associateAmount
         FROM
           cm_receipt_order_relation cror
           LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
@@ -115,4 +166,186 @@
           AND cdr.payWay = '2'
         LIMIT 1
     </select>
+
+    <select id="findUserInfo" resultType="com.caimei.model.vo.UserInfoVo">
+        SELECT
+          id,
+          name,
+          shouHuoRen,
+          mobile,
+          province,
+          city,
+          town,
+          address
+        FROM
+          bp_order_userinfo
+        WHERE
+          orderId = #{orderID}
+    </select>
+
+    <select id="findOrder" resultType="com.caimei.model.vo.OrderVo">
+        SELECT
+          <include refid="cm_Order_List"></include>
+        FROM
+          cm_order
+        WHERE
+          orderID = #{orderID}
+          AND delFlag = '0'
+    </select>
+
+    <select id="returnedPurchase" resultType="integer">
+        SELECT
+          SUM(
+            crpp.actualReturnedNum
+          ) AS 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="actualCancelNum" resultType="integer">
+        SELECT
+          SUM(
+            crpp.actualCancelNum
+          ) AS 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="getOrderInvoice" resultType="com.caimei.model.vo.OrderInvoiceVo">
+        SELECT
+        a.*
+        FROM bp_order_invoice a
+        WHERE a.orderId = #{orderId}
+    </select>
+
+    <select id="findReturnedPurchase" resultType="com.caimei.model.vo.ReturnedPurchaseVo">
+        SELECT
+          *
+        FROM
+          cm_returned_purchase
+        WHERE
+          orderID = #{orderId}
+          AND STATUS = '2'
+        ORDER BY
+          confirmReturnTime DESC
+    </select>
+
+    <select id="findLogisticsRecord" resultType="com.caimei.model.vo.LogisticsRecordVo">
+        SELECT
+          clr.*,
+          cop.productID
+        FROM
+          cm_logistics_record clr
+          LEFT JOIN cm_order_product cop ON clr.orderProductID = cop.orderProductID
+        WHERE
+          clr.shopOrderID = #{shopOrderId}
+          and clr.logisticsBatchID = #{logisticsBatchId}
+    </select>
+
+    <select id="findLogisticsInfo" resultType="com.caimei.model.vo.LogisticsInformationVo">
+        SELECT DISTINCT
+        li.*,
+        clb.deliveryTime
+        FROM
+        logistics_information li
+        LEFT JOIN cm_logistics_batch clb ON clb.id = li.logisticsBatchID
+        LEFT JOIN cm_logistics_record clr ON clr.logisticsBatchID=clb.id
+        WHERE
+          li.logisticsBatchID = #{logisticsBatchId}
+    </select>
+
+    <update id="updateLogisticsBatch" parameterType="int">
+        UPDATE
+          cm_logistics_batch
+        SET
+          status = '1',
+          updateDate = NOW(),
+          receiptTime = NOW()
+        WHERE
+          orderID = #{orderId}
+    </update>
+
+    <update id="updateOrderStatus">
+        UPDATE
+          cm_order
+        SET
+          status = #{status},
+          updateDate = NOW()
+        WHERE
+          orderID = #{orderID}
+    </update>
+
+    <select id="queryCode" resultType="com.caimei.model.po.CmMallOrderShareCodePo">
+        SELECT *
+        FROM cm_mall_order_share_code
+        WHERE orderID = #{orderId}
+          AND delFlag = '0'
+    </select>
+
+    <update id="updateCode">
+        UPDATE
+          cm_mall_order_share_code
+        SET
+          shareCode = #{shareCode},
+          expiredTime = #{expiredTime},
+          delFlag = #{delFlag}
+        WHERE
+          orderID = #{orderID}
+    </update>
+
+    <delete id="deleteCodeRecord">
+        DELETE FROM
+          cm_mall_share_code_record
+        WHERE
+          orderID = #{orderId}
+    </delete>
+
+    <insert id="insertCode">
+        INSERT INTO cm_mall_order_share_code (
+          orderID, shareCode, ADDTIME, expiredTime,
+          delFlag
+        )
+        VALUES
+          (
+            #{orderID}, #{shareCode}, #{addTime}, #{expiredTime},
+            #{delFlag}
+          )
+    </insert>
+
+    <select id="findShareCodeRecord" resultType="com.caimei.model.po.ShareCodeRecordPo">
+        SELECT
+          scr.*,
+          osc.expiredTime
+        FROM
+          cm_mall_share_code_record scr
+          LEFT JOIN cm_mall_order_share_code osc ON scr.shareCodeId = osc.id
+        WHERE
+          scr.openid = #{openid}
+          AND osc.orderID = #{orderID}
+          AND scr.delFlag = '0'
+    </select>
+
+    <insert id="insertShareCodeRecord">
+        INSERT INTO cm_mall_share_code_record (
+          openid, orderID, shareCodeId, addTime,
+          delFlag
+        )
+        VALUES
+          (
+            #{openid}, #{orderID}, #{shareCodeId}, #{addTime},
+            #{delFlag}
+          )
+    </insert>
 </mapper>