plf il y a 4 ans
Parent
commit
d72a2ce891

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

@@ -0,0 +1,161 @@
+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;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Api(tags = "订单相关")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/order")
+public class OrderApi {
+    private final OrderService orderService;
+
+    /**
+     * 我的订单
+     */
+    @ApiOperation("我的订单")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "orderState", required = true, value = "1:待付款,2:待发货,3:已发货,4:退货款"),
+            @ApiImplicitParam(name = "userId", required = false, value = "用户id"),
+            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
+            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
+    })
+    @GetMapping("/list")
+    public ResponseJson<PageInfo<OrderVo>> getOrderList(Integer orderState, Integer userId,
+                                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        return orderService.getOrderList(orderState, userId, 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);
+    }
+
+    /**
+     * 删除订单
+     */
+    @GetMapping("/delete")
+    @ApiOperation("删除订单")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    public ResponseJson<String> deleteOrder(Integer orderId) {
+        return orderService.deleteOrder(orderId);
+    }
+
+    /**
+     * 取消订单
+     */
+    @ApiOperation("取消订单")
+    @ApiImplicitParam(name = "orderId", required = true, value = "订单id")
+    @GetMapping("/cancel")
+    public ResponseJson<String> cancelOrder(Integer orderId) {
+        return orderService.cancelOrder(orderId);
+    }
+
+    /**
+     * 根据关键词获取订单
+     */
+    @ApiOperation("根据关键词获取订单")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "searchWord", required = true, value = "搜索关键词"),
+            @ApiImplicitParam(name = "userId", required = true, value = "用户id"),
+            @ApiImplicitParam(name = "pageNum", required = false, value = "第几页"),
+            @ApiImplicitParam(name = "pageSize", required = false, value = "一页多少条")
+    })
+    @GetMapping("/search")
+    public ResponseJson<PageInfo<OrderVo>> getProductsBySearch(String searchWord, Integer userId,
+                                                               @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (StringUtils.isBlank(searchWord)) {
+            return ResponseJson.error("请输入搜索关键词", null);
+        }
+        if (userId == null) {
+            return ResponseJson.error("用户参数异常", null);
+        }
+        return orderService.searchOrder(searchWord, userId, pageNum, pageSize);
+    }
+
+    /**
+     * 根据组织ID查找历史记录
+     */
+    @ApiOperation("根据组织ID查找历史记录")
+    @ApiImplicitParam(name = "userId", required = true, value = "用户id")
+    @GetMapping("/searchHistory")
+    public ResponseJson<List<String>> getSearchHistory(Integer userId) {
+        return orderService.getSearchHistory(userId);
+    }
+
+    /**
+     * 根据组织ID删除历史记录
+     */
+    @ApiOperation("根据组织ID删除历史记录")
+    @ApiImplicitParam(name = "userId", required = true, value = "用户id")
+    @GetMapping("/searchHistory/delete")
+    public ResponseJson<String> deleteSearchHistory(Integer userId) {
+        return orderService.deleteSearchHistory(userId);
+    }
+
+    /**
+     * 订单数量统计
+     */
+    @ApiOperation("订单数量统计")
+    @ApiImplicitParam(name = "userId", required = true, value = "用户id")
+    @GetMapping("/order/total")
+    public ResponseJson<Map<String, Object>> orderTotal(Integer userId) {
+        return orderService.orderTotal(userId);
+    }
+}

+ 34 - 0
src/main/java/com/caimei/controller/ProductApi.java

@@ -1,6 +1,7 @@
 package com.caimei.controller;
 
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.HeHeActivityVo;
 import com.caimei.model.vo.ProductVo;
 import com.caimei.service.ProductService;
 import com.github.pagehelper.PageInfo;
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -74,4 +76,36 @@ public class ProductApi {
         }
         return productService.deleteHistory(userId);
     }
+
+    @ApiOperation("活动专区")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
+            @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
+    })
+    @GetMapping("/activityArea")
+    public ResponseJson<PageInfo<HeHeActivityVo>> activityArea(Integer userId, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (userId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return productService.activityArea(userId, pageNum, pageSize);
+    }
+
+    @ApiOperation("活动详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
+            @ApiImplicitParam(name = "activityId", value = "活动id", required = true),
+            @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
+    })
+    @GetMapping("/activity/details")
+    public ResponseJson<Map<String, Object>> activityDetails(Integer userId, Integer activityId,
+                                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (userId == null || activityId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return productService.activityDetails(userId, activityId, pageNum, pageSize);
+    }
 }

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

@@ -0,0 +1,255 @@
+package com.caimei.mapper;
+
+import com.caimei.model.po.CmPayShopRecordPo;
+import com.caimei.model.po.UserSearchHistoryPo;
+import com.caimei.model.vo.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Mapper
+public interface OrderMapper {
+
+    /**
+     * 查询
+     *
+     * @param userId
+     * @param orderState
+     * @return
+     */
+    List<OrderVo> findOrderList(@Param("userId") Integer userId, @Param("orderState") Integer orderState);
+
+    /**
+     * 查询物流详情
+     *
+     * @param orderId
+     * @return
+     */
+    List<LogisticsBatchVo> findLogistics(Integer orderId);
+
+
+    /**
+     * 查询该主订单下所有子订单
+     *
+     * @param orderId
+     * @return
+     */
+    List<ShopOrderVo> findAllShopOrder(Integer orderId);
+
+    /**
+     * 查询子订单下所有商品
+     *
+     * @param shopOrderId
+     * @return
+     */
+    List<OrderProductVo> findOrderProduct(Integer shopOrderId);
+
+    /**
+     * 查询收款记录
+     *
+     * @param orderId
+     * @return
+     */
+    List<DiscernReceiptVo> findDiscernReceipt(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
+     */
+    BigDecimal 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
+     */
+    void deleteOrder(Integer orderId);
+
+    /**
+     * 逻辑删除子订单
+     *
+     * @param orderId
+     */
+    void deleteShopOrder(Integer orderId);
+
+    /**
+     * 逻辑删除订单收款记录
+     *
+     * @param orderId
+     */
+    void deleteReceiptOrderRelation(Integer orderId);
+
+    /**
+     * 逻辑删除收款记录
+     *
+     * @param id
+     */
+    void deleteDiscernReceipt(Integer id);
+
+    /**
+     * 查询付款记录
+     *
+     * @param shopOrderId
+     * @return
+     */
+    List<CmPayShopRecordPo> findPayShopRecord(Integer shopOrderId);
+
+    /**
+     * 逻辑删除子订单付款记录
+     *
+     * @param shopOrderId
+     */
+    void deletePayShopRecord(Integer shopOrderId);
+
+    /**
+     * 逻辑删除付款记录
+     *
+     * @param payShopId
+     */
+    void updatePayShop(Integer payShopId);
+
+    /**
+     * 取消订单
+     *
+     * @param orderId
+     */
+    void cancelOrder(Integer orderId);
+
+    /**
+     * 查询相关商品名称订单
+     *
+     * @param searchWord
+     * @param userId
+     * @return
+     */
+    List<OrderVo> searchOrder(@Param("searchWord") String searchWord, @Param("userId") Integer userId);
+
+    /**
+     * 查询组织订单搜索历史记录
+     *
+     * @param userId
+     * @return
+     */
+    List<String> getSearchHistoryList(Integer userId);
+
+    /**
+     * 删除订单搜索历史记录
+     *
+     * @param userId
+     */
+    void deleteSearchHistory(Integer userId);
+
+    /**
+     * 保存订单搜索历史记录
+     *
+     * @param searchHistoryPo
+     */
+    void insertHistory(UserSearchHistoryPo searchHistoryPo);
+
+    /**
+     * 查询订单关键字历史是否存在
+     *
+     * @param userId
+     * @param searchWord
+     * @return
+     */
+    Long getHistoryIdByWord(@Param("userId") Integer userId, @Param("searchWord") String searchWord);
+
+    /**
+     * 更新订单搜索历史记录
+     *
+     * @param historyRecord
+     */
+    void updateHistoryById(UserSearchHistoryPo historyRecord);
+
+    /**
+     * 删除10条以上的记录
+     *
+     * @param userId
+     */
+    void deleteHistoryByUserId(Integer userId);
+
+    /**
+     * 查询订单数量
+     *
+     * @param userId 用户id
+     * @param status
+     * @return
+     */
+    Integer findOrderCount(@Param("userId") Integer userId,@Param("status") int status);
+}

+ 26 - 4
src/main/java/com/caimei/mapper/ProductMapper.java

@@ -2,10 +2,7 @@ package com.caimei.mapper;
 
 import com.caimei.model.po.ProductDetailInfoPo;
 import com.caimei.model.po.UserSearchHistoryPo;
-import com.caimei.model.vo.ActivityLadderVo;
-import com.caimei.model.vo.ProductDetailsVo;
-import com.caimei.model.vo.ProductVo;
-import com.caimei.model.vo.RelatedParametersVo;
+import com.caimei.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -145,4 +142,29 @@ public interface ProductMapper {
      * @param userId
      */
     void deleteHistory(Integer userId);
+
+    /**
+     * 查询分销者下所有活动
+     *
+     * @param userId
+     * @return
+     */
+    List<HeHeActivityVo> findActivityAll(Integer userId);
+
+    /**
+     * 查询活动详情图片
+     *
+     * @param activityId
+     * @return
+     */
+    String findActivityById(Integer activityId);
+
+    /**
+     * 查询活动商品
+     *
+     * @param userId     分销者id
+     * @param activityId 活动id
+     * @return
+     */
+    List<ProductVo> findActivityProduct(@Param("userId") Integer userId, @Param("activityId") Integer activityId);
 }

+ 72 - 0
src/main/java/com/caimei/model/po/CmPayShopRecordPo.java

@@ -0,0 +1,72 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * cm_pay_shop_record
+ * @author 
+ */
+@Data
+public class CmPayShopRecordPo implements Serializable {
+    private Long id;
+
+    /**
+     * 供应商Id
+     */
+    private Integer shopID;
+
+    /**
+     * 子订单ID
+     */
+    private Integer shopOrderID;
+
+    /**
+     * 子订单No
+     */
+    private String shopOrderNo;
+
+    /**
+     * 付款金额
+     */
+    private BigDecimal payAmount;
+
+    /**
+     * 付款抹平金额
+     */
+    private BigDecimal wipePayment;
+
+    /**
+     * 付款方式 1建设银行7297, 2中信银行0897, 3中信银行7172, 4广发银行0115, 5广发银行5461, 6线上分账
+     */
+    private String payType;
+
+    /**
+     * 付款时间
+     */
+    private String payTime;
+
+    /**
+     * 抹平申请时间
+     */
+    private String wipeTime;
+
+    /**
+     * 付款单表id
+     */
+    private Integer payShopID;
+
+    /**
+     * 0待审核, 1审核通过, 2审核不通过
+     */
+    private String status;
+
+    /**
+     * 删除标记 0 否,其余是
+     */
+    private String delFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 26 - 0
src/main/java/com/caimei/model/vo/DiscernReceiptVo.java

@@ -0,0 +1,26 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/27
+ */
+@Data
+public class DiscernReceiptVo implements Serializable {
+    private Integer id;
+    /**
+     * 单次收款金额
+     */
+    private BigDecimal associateAmount;
+
+    /**
+     * 收款时间
+     */
+    private String receiptDate;
+}

+ 49 - 0
src/main/java/com/caimei/model/vo/HeHeActivityVo.java

@@ -0,0 +1,49 @@
+package com.caimei.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/27
+ */
+@Data
+public class HeHeActivityVo implements Serializable {
+    /**
+     * 活动id
+     */
+    private Integer activityId;
+
+    /**
+     * 活动名称
+     */
+    private String name;
+
+    /**
+     * 小程序列表缩略图
+     */
+    private String listImage;
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date beginTime;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+
+    /**
+     * 商品数量
+     */
+    private Integer productCount;
+
+}

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

@@ -0,0 +1,82 @@
+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/26
+ */
+@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;
+
+    /**
+     * 发货时间
+     */
+    @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;
+}

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

@@ -0,0 +1,85 @@
+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 {
+    /**
+     * 发货批次表ID
+     */
+    private Long logisticsBatchId;
+
+    /**
+     * 子订单编号
+     */
+    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;
+}

+ 273 - 0
src/main/java/com/caimei/model/vo/OrderProductVo.java

@@ -0,0 +1,273 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Data
+public class OrderProductVo implements Serializable {
+    private Integer orderProductId;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderId;
+
+    /**
+     * 订单Id
+     */
+    private Integer shopOrderId;
+
+    /**
+     * 供应商ID
+     */
+    private Long shopId;
+
+    /**
+     * 商品Id(采美商城和组织小程序都保存product表ID)
+     */
+    private Integer productId;
+
+    /**
+     * 组织的商品Id,关联cm_mall_organize_products表ID[适用于组织订单]
+     */
+    private Integer organizeProductId;
+
+    /**
+     * 采美组织默认为null,具体对应cm_mall_organize表ID[适用于组织订单]
+     */
+    private Integer organizeId;
+
+    /**
+     * 购买数量
+     */
+    private Integer num;
+
+    /**
+     * 赠送数量
+     */
+    private Integer presentNum;
+
+    /**
+     * 出库类型 0 采美出库  1 供应商出库
+     */
+    private String outStoreType;
+
+    /**
+     * 商品编号
+     */
+    private String productNo;
+
+    /**
+     * 商品价格(协销 市场价 普通 购买价)
+     */
+    private BigDecimal price;
+
+    /**
+     * 市场价 = 商品表市场价
+     */
+    private BigDecimal normalPrice;
+
+    /**
+     * 购买时商品成本价
+     */
+    private BigDecimal costPrice;
+
+    /**
+     * 记录会员用户购买时价格  活动价优先
+     */
+    private BigDecimal price1;
+
+    /**
+     * 总价  = price X num
+     */
+    private BigDecimal totalAmount;
+
+    /**
+     * 总价  = discountPrice X num + totalAddedValueTax
+     */
+    private BigDecimal totalFee;
+
+    /**
+     * 应付金额 = totalFee - discountFee
+     */
+    private BigDecimal shouldPayFee;
+
+    /**
+     * 折扣比例
+     */
+    private BigDecimal discount;
+
+    /**
+     * 折后单价
+     */
+    private BigDecimal discountPrice;
+
+    /**
+     * 是否含税 0不含税 1含税 2未知
+     */
+    private String includedTax;
+
+    /**
+     * 发票类型 1增值税专用发票 2增值税普通发票 3不开发票
+     */
+    private String invoiceType;
+
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    private String ladderPriceFlag;
+
+    /**
+     * 后台设置该商品税率
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 供应商税率:增值专用发票默认13%,增值税普通发票6%取值范围[0-100]
+     */
+    private BigDecimal supplierTaxRate;
+
+    /**
+     * 单个税费=税率X折后单价
+     */
+    private BigDecimal addedValueTax;
+
+    /**
+     * 总税费=单个税费X购买数量
+     */
+    private BigDecimal totalAddedValueTax;
+
+    /**
+     * 总税费(应付税费)默认值和应收税费一样
+     */
+    private BigDecimal shouldPayTotalTax;
+
+    /**
+     * 单个付供应商税费
+     */
+    private BigDecimal singleShouldPayTotalTax;
+
+    /**
+     * 商品费
+     */
+    private BigDecimal shopProductAmount;
+
+    /**
+     * 订单商品状态
+     */
+    private String status;
+
+    /**
+     * 使用余额金额
+     */
+    private Double useBalanceAmount;
+
+    /**
+     * 未出库数量
+     */
+    private Integer notOutStore;
+
+    /**
+     * 下单时商品购买价格类型快照 0 机构价,1活动价 ,2阶梯价
+     */
+    private String isActProduct;
+
+    /**
+     * 是否是赠品 0 不是 1 是
+     */
+    private String isGiftProduct;
+
+    /**
+     * 活动信息 已享受满XX减XX 之类
+     */
+    private String productActInfo;
+
+    /**
+     * 订单商品再次购买标识 0否 1是
+     */
+    private String buyAgainFlag;
+
+    /**
+     * 订单商品供应商确认标志 0否 1是
+     */
+    private String confirmProductFlag;
+
+    /**
+     * 支付状态 0 未进账 1 待财务审核 2 已进账(适用协销的单笔线下进账和自助订单线下或异常进账)
+     */
+    private String payStatus;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 商品单位
+     */
+    private String productUnit;
+
+    private String productImage;
+
+    /**
+     * 活动类型 1000 热卖 1001 团购 1003 满减 1004满赠 1005 买赠
+     */
+    private String actType;
+
+    /**
+     * 活动优惠  类似满减优惠金额
+     */
+    private BigDecimal actPreferential;
+
+    /**
+     * 商品类型(0正常商品,1协商赠品,2促销赠品)
+     */
+    private String productType;
+
+    /**
+     * 优惠 (price - discountPrice) * num
+     */
+    private BigDecimal preferential;
+
+    /**
+     * 协销订单:经理折扣(平摊到每个商品上,  按照每种商品的总价占订单总价的比例来均分);普通订单 无
+     */
+    private BigDecimal discountFee;
+
+    private Integer cancelNum;
+
+    /**
+     * 已发货数量
+     */
+    private Integer shipmentsNum;
+
+    /**
+     * 已退货数量
+     */
+    private Integer returnedNum;
+
+    /**
+     * 已取消发货数量
+     */
+    private Integer actualCancelNum;
+
+    /**
+     * 商品前台展示单价是否含税,1不含税,2含税,3其他
+     */
+    private String includedTaxFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 233 - 0
src/main/java/com/caimei/model/vo/OrderVo.java

@@ -0,0 +1,233 @@
+package com.caimei.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Data
+public class OrderVo implements Serializable {
+    /**
+     * orderID
+     */
+    private Integer orderId;
+
+    /**
+     * 订单编号(后台:p,网站:W,小程序:x,第三方:T)
+     */
+    private String orderNo;
+
+    private Long userId;
+
+    /**
+     * 下单人
+     */
+    private Integer buyUserId;
+
+    /**
+     * 子订单ID
+     */
+    private String shopOrderIds;
+
+    /**
+     * 0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
+     */
+    private String status;
+
+    /**
+     * (收款买家)收款状态:1待收款、2部分收款、3已收款
+     */
+    private String receiptStatus;
+
+    /**
+     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
+     */
+    private String payStatus;
+
+    /**
+     * 发货状态:1待发货、2部分发货、3已发货
+     */
+    private String sendOutStatus;
+
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private String refundType;
+
+    /**
+     * 已支付成功次数统计(适用线上多笔付款用来确认当前是哪一笔)
+     */
+    private Integer paySuccessCounter;
+
+    /**
+     * 是否已支付 未支付0 已支付1
+     */
+    private String payFlag;
+
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private String onlinePayFlag;
+
+    /**
+     * 订单总额(小计金额减去经理折扣后,再加上运费)
+     */
+    private BigDecimal payTotalFee;
+
+    /**
+     * 真实支付金额(订单总额减去抵扣的账户余额)
+     */
+    private BigDecimal payableAmount;
+
+    /**
+     * 余额支付金额
+     */
+    private BigDecimal balancePayFee;
+
+    /**
+     * 经理折扣
+     */
+    private BigDecimal discountFee;
+
+    /**
+     * 促销满减优惠
+     */
+    private BigDecimal promotionFullReduction;
+
+    /**
+     * 订单备注
+     */
+    private String note;
+
+    /**
+     * 订单来源:1WWW、2CRM、3APP[历史数据]、4客服、5外单、6小程序[采美,星范等]
+     */
+    private String orderSource;
+
+    /**
+     * 订单提交时间
+     */
+    @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 开企业发票2
+     */
+    private String invoiceFlag;
+
+    /**
+     * 条款ID
+     */
+    private Long clauseId;
+
+    /**
+     * 条款内容
+     */
+    private String clauseContent;
+
+    /**
+     * 条款名称
+     */
+    private String clauseName;
+
+    /**
+     * 免邮标志  运费:-1到付,0包邮,1需要运费,-2仪器到付其它包邮
+     */
+    private String freePostFlag;
+
+    /**
+     * -1到付,0包邮,大于0具体金额,-2仪器到付其它包邮(且运费已使用商品形式存储)
+     */
+    private BigDecimal freight;
+
+    /**
+     * 订单取消原因
+     */
+    private String closeReason;
+
+    /**
+     * 邮费订单标识(适用于补录邮费订单) 1是邮费订单  0不是邮费订单
+     */
+    private String postageOrderFlag;
+
+    /**
+     * 订单0成本标识:订单不是0成本,1订单0成本(订单中所有商品成本为0)
+     */
+    private Integer zeroCostFlag;
+
+    /**
+     * 付款总金额
+     */
+    private BigDecimal receiptAmount;
+
+    /**
+     * 待付总金额
+     */
+    private BigDecimal pendingPayments;
+
+    /**
+     * 退款总金额
+     */
+    private BigDecimal returnedPurchaseFee;
+
+    /**
+     * 订单标识:#订单号#
+     */
+    private String orderMark;
+
+    /**
+     * 总税费
+     */
+    private BigDecimal expensesOfTaxation;
+
+    /**
+     * 已退货数量
+     */
+    private Integer returnedNum;
+
+    /**
+     * 已取消数量
+     */
+    private Integer actualCancelNum;
+
+    /**
+     * 支付按钮是否消失,true消失
+     */
+    private boolean payButton = false;
+
+    /**
+     * 订单内是否包含确定能否开发票的商品
+     */
+    private boolean invoiceStatus = false;
+
+    /**
+     * 子订单列表
+     */
+    private List<ShopOrderVo> shopOrderList;
+
+    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;
+}

+ 260 - 0
src/main/java/com/caimei/model/vo/ShopOrderVo.java

@@ -0,0 +1,260 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Data
+public class ShopOrderVo implements Serializable {
+    /**
+     * 子订单ID
+     */
+    private Integer shopOrderId;
+
+    /**
+     * 子订单编号
+     */
+    private String shopOrderNo;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderId;
+
+    /**
+     * 用户Id
+     */
+    private Integer userId;
+
+    /**
+     * 供应商Id
+     */
+    private Integer shopId;
+
+    /**
+     * 购买数量
+     */
+    private Integer itemCount;
+
+    /**
+     * 已经发货的商品数量
+     */
+    private Integer outStoreNum;
+
+    /**
+     * 收货地址县区Id
+     */
+    private Integer townID;
+
+    /**
+     * 子订单备注信息
+     */
+    private String note;
+
+    /**
+     * 运费:-1到付,0包邮,其他为具体运费(v5.0版本已废弃,运费已使用商品形式存储)
+     */
+    private Double fee;
+
+    /**
+     * 余额支付时使用的金额
+     */
+    private BigDecimal accountAmount;
+
+    /**
+     * 总金额 = 订单商品totalAmount
+     */
+    private BigDecimal productAmount;
+
+    /**
+     * 总价 = totalFee
+     */
+    private BigDecimal totalAmount;
+
+    /**
+     * 需要支付金额 shouldPayFee +运费
+     */
+    private BigDecimal needPayAmount;
+
+    private BigDecimal discountAmount;
+
+    /**
+     * 订单总优惠
+     */
+    private BigDecimal preferential;
+
+    /**
+     * 是否已支付:1是,0否
+     */
+    private String payFlag;
+
+    /**
+     * 订单提交时间
+     */
+    private String orderTime;
+
+    /**
+     * 支付时间
+     */
+    private String payTime;
+
+    /**
+     * 订单完成时间
+     */
+    private String finishTime;
+
+    /**
+     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
+     */
+    private String payStatus;
+
+    /**
+     * 发货状态:1待发货、2部分发货、3已发货
+     */
+    private String sendOutStatus;
+
+    private Integer refundStatus;
+
+    private Integer returnGoodsStatus;
+
+    /**
+     * 收货时间
+     */
+    private String receiveGoodsTime;
+
+    /**
+     * 总税费
+     */
+    private BigDecimal totalAddedValueTax;
+
+    /**
+     * 可退款金额 = 余额抵扣金额
+     */
+    private Double canRefundAmount;
+
+    /**
+     * 退款金额
+     */
+    private Double refundAmount;
+
+    private Integer clubID;
+
+    /**
+     * 是否可以退货 1可以退款/退货 0不可退款/退货
+     */
+    private Integer canRefundFlag;
+
+    /**
+     * 是否使用余额
+     */
+    private Integer useBalanceFlag;
+
+    /**
+     * 订单包邮时本该支付的运费
+     */
+    private BigDecimal freePostageFee;
+
+    /**
+     * 佣金 =  应付采美
+     */
+    private BigDecimal brokerage;
+
+    /**
+     * 后台删除状态 0正常,其他删除
+     */
+    private String delFlag;
+
+    /**
+     * 订单退款金额
+     */
+    private BigDecimal refundsAmount;
+
+    /**
+     * 订单状态标识,1:非退货退款订单、2:退货退款中、3退货退款完成
+     */
+    private String orderStatusFlag;
+
+    /**
+     * 购买状态
+     */
+    private String buyStatus;
+
+    /**
+     * 全部发货时间
+     */
+    private String deliveryTimeMills;
+
+    private Integer orderDeliveryID;
+
+    /**
+     * 是否处于给供应商状态中   0不是的,  1是的
+     */
+    private String paying;
+
+    /**
+     * 商品费
+     */
+    private BigDecimal shopProductAmount;
+
+    /**
+     * 运费
+     */
+    private BigDecimal shopPostFee;
+
+    /**
+     * 税费
+     */
+    private BigDecimal shopTaxFee;
+
+    /**
+     * 付供应商 = 商品费 + 运费 + 税费
+     */
+    private BigDecimal shouldPayShopAmount;
+
+    /**
+     * 已付款金额
+     */
+    private BigDecimal payedShopAmount;
+
+    /**
+     * 固定成本1,  比例成本2  为空就是还没有设置过
+     */
+    private String costType;
+
+    /**
+     * 比例成本的比例值
+     */
+    private BigDecimal proportional;
+
+    /**
+     * 子订单0成本标识:0子订单不是0成本,1子订单0成本(子订单中所有商品成本为0)
+     */
+    private Integer zeroCostFlag;
+
+    /**
+     * 供应商logo
+     */
+    private String shopLogo;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    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;
+}

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

@@ -0,0 +1,103 @@
+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
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+public interface OrderService {
+    /**
+     * 订单数据
+     *
+     * @param orderState
+     * @param userId
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<PageInfo<OrderVo>> getOrderList(Integer orderState, Integer userId, 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> deleteOrder(Integer orderId);
+
+    /**
+     * 取消订单
+     *
+     * @param orderId
+     * @return
+     */
+    ResponseJson<String> cancelOrder(Integer orderId);
+
+    /**
+     * 根据关键词获取订单
+     *
+     * @param searchWord
+     * @param userId
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<PageInfo<OrderVo>> searchOrder(String searchWord, Integer userId, Integer pageNum, Integer pageSize);
+
+    /**
+     * 根据组织ID查找历史记录
+     *
+     * @param userId
+     * @return
+     */
+    ResponseJson<List<String>> getSearchHistory(Integer userId);
+
+    /**
+     * 删除历史记录
+     *
+     * @param userId
+     * @return
+     */
+    ResponseJson<String> deleteSearchHistory(Integer userId);
+
+    /**
+     * 订单数量统计
+     *
+     * @param userId
+     * @return
+     */
+    ResponseJson<Map<String, Object>> orderTotal(Integer userId);
+}

+ 23 - 0
src/main/java/com/caimei/service/ProductService.java

@@ -1,10 +1,12 @@
 package com.caimei.service;
 
 import com.caimei.model.ResponseJson;
+import com.caimei.model.vo.HeHeActivityVo;
 import com.caimei.model.vo.ProductVo;
 import com.github.pagehelper.PageInfo;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -54,4 +56,25 @@ public interface ProductService {
      * @return
      */
     ResponseJson<String> deleteHistory(Integer userId);
+
+    /**
+     * 活动专区
+     *
+     * @param userId   分销者id
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<PageInfo<HeHeActivityVo>> activityArea(Integer userId, Integer pageNum, Integer pageSize);
+
+    /**
+     * 活动详情
+     *
+     * @param userId     分销者id
+     * @param activityId 活动id
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    ResponseJson<Map<String, Object>> activityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize);
 }

+ 356 - 0
src/main/java/com/caimei/service/impl/OrderServiceImpl.java

@@ -0,0 +1,356 @@
+package com.caimei.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.caimei.mapper.OrderMapper;
+import com.caimei.mapper.OrderSubmitMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.po.CmPayShopRecordPo;
+import com.caimei.model.po.UserPo;
+import com.caimei.model.po.UserSearchHistoryPo;
+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.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/26
+ */
+@Slf4j
+@Service
+public class OrderServiceImpl implements OrderService {
+    @Resource
+    private OrderMapper orderMapper;
+    @Resource
+    private OrderSubmitMapper orderSubmitMapper;
+    @Value("${caimei.oldapi}")
+    private String domain;
+
+    @Override
+    public ResponseJson<PageInfo<OrderVo>> getOrderList(Integer orderState, Integer userId, Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<OrderVo> orderList = orderMapper.findOrderList(userId, orderState);
+        getOrderData(orderList);
+        PageInfo<OrderVo> pageData = new PageInfo<>(orderList);
+        return ResponseJson.success(pageData);
+    }
+
+    /**
+     * 主订单下信息
+     */
+    private void getOrderData(List<OrderVo> orderList) {
+        for (OrderVo order : orderList) {
+            //111,待付待收待发
+            if ("11".equals(order.getStatus()) && "1".equals(order.getPayStatus())) {
+                order.setStatus("111");
+            }
+            //判断交易全退情况下,是否发过货,77,交易全退可以查看物流
+            List<LogisticsBatchVo> batchList = orderMapper.findLogistics(order.getOrderId());
+            if ("7".equals(order.getStatus()) && batchList != null && batchList.size() > 0) {
+                order.setStatus("77");
+            }
+            List<ShopOrderVo> shopOrderList = orderMapper.findAllShopOrder(order.getOrderId());
+            for (ShopOrderVo shopOrder : shopOrderList) {
+                List<OrderProductVo> orderProductList = orderMapper.findOrderProduct(shopOrder.getShopOrderId());
+                for (OrderProductVo orderProduct : orderProductList) {
+                    orderProduct.setProductImage(ProductUtils.getImageURL("product", orderProduct.getProductImage(), 0, domain));
+                    //不含税可开票商品,单价/折后单价=税前单价+税费
+                    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.getPrice(), orderProduct.getAddedValueTax()));
+                    }
+                }
+                shopOrder.setOrderProductList(orderProductList);
+                shopOrder.setShopLogo(ProductUtils.getImageURL("shopLogo", shopOrder.getShopLogo(), 0, domain));
+            }
+            //过滤运费商品
+            shopOrderList.removeIf(shopOrderVo -> shopOrderVo.getShopId() == 998);
+            order.setShopOrderList(shopOrderList);
+            //设置付款金额
+            getDiscernReceipt(order);
+        }
+    }
+
+    @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);
+        int returnedNumTotal = 0;
+        int actualCancelNumTotal = 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;
+                returnedNumTotal += returnedNum;
+                orderProduct.setReturnedNum(returnedNum);
+                //已取消发货数量
+                Integer actualCancelNum = orderMapper.actualCancelNum(orderProduct.getShopOrderId(), orderProduct.getProductId());
+                actualCancelNum = null != actualCancelNum ? actualCancelNum : 0;
+                actualCancelNumTotal += actualCancelNum;
+                orderProduct.setActualCancelNum(actualCancelNum);
+                //判断商品价格是否含税
+                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);
+        order.setReturnedNum(returnedNumTotal);
+        order.setActualCancelNum(actualCancelNumTotal);
+        //删除运费商品
+        shopOrderList.removeIf(student -> 998 == student.getShopId());
+        List<DiscernReceiptVo> discernReceiptList = getDiscernReceipt(order);
+        //退款总金额
+        BigDecimal returnedPurchaseFee = orderMapper.findReturnedPurchase(order.getOrderId());
+        order.setReturnedPurchaseFee(returnedPurchaseFee);
+        map.put("order", order);
+        map.put("userInfo", userInfo);
+        map.put("shopOrderList", shopOrderList);
+        map.put("discernReceiptList", discernReceiptList);
+        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
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseJson<String> deleteOrder(Integer orderId) {
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        if (!("6".equals(order.getStatus()))) {
+            return ResponseJson.error("订单异常", null);
+        }
+        orderMapper.deleteOrder(orderId);
+        //逻辑删除子订单
+        orderMapper.deleteShopOrder(orderId);
+        //逻辑删除收款记录
+        List<DiscernReceiptVo> discernReceipt = orderMapper.findDiscernReceipt(orderId);
+        if (discernReceipt != null && discernReceipt.size() > 0) {
+            orderMapper.deleteReceiptOrderRelation(orderId);
+            for (DiscernReceiptVo receipt : discernReceipt) {
+                orderMapper.deleteDiscernReceipt(receipt.getId());
+            }
+        }
+        String[] shopOrderIds = order.getShopOrderIds().split(",");
+        //逻辑删除付款记录
+        for (String shopOrderId : shopOrderIds) {
+            if (StringUtils.isNotBlank(shopOrderId)) {
+                List<CmPayShopRecordPo> payShopRecordList = orderMapper.findPayShopRecord(Integer.valueOf(shopOrderId));
+                if (payShopRecordList != null && payShopRecordList.size() > 0) {
+                    orderMapper.deletePayShopRecord(Integer.valueOf(shopOrderId));
+                    for (CmPayShopRecordPo payShopRecord : payShopRecordList) {
+                        orderMapper.updatePayShop(payShopRecord.getPayShopID());
+                    }
+                }
+            }
+        }
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<String> cancelOrder(Integer orderId) {
+        OrderVo order = orderMapper.findOrder(orderId);
+        if (order == null) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        if (!("11".equals(order.getStatus()) || "0".equals(order.getStatus()))) {
+            return ResponseJson.error("订单异常", null);
+        }
+        order.setStatus("6");
+        orderMapper.cancelOrder(orderId);
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<PageInfo<OrderVo>> searchOrder(String searchWord, Integer userId, Integer pageNum, Integer pageSize) {
+        //保存并删除大于10条的历史记录
+        UserSearchHistoryPo historyRecord = new UserSearchHistoryPo();
+        historyRecord.setUserId(userId.longValue());
+        historyRecord.setSearchDate(new Date());
+        historyRecord.setSearchWord(searchWord);
+        historyRecord.setDelFlag("0");
+        Long recordId = orderMapper.getHistoryIdByWord(userId, searchWord);
+        if (recordId != null && recordId > 0L) {
+            historyRecord.setId(recordId);
+            orderMapper.updateHistoryById(historyRecord);
+        } else {
+            orderMapper.insertHistory(historyRecord);
+        }
+        orderMapper.deleteHistoryByUserId(userId);
+
+        PageHelper.startPage(pageNum, pageSize);
+        List<OrderVo> orderList = orderMapper.searchOrder(searchWord, userId);
+
+        //获取主订单数据
+        getOrderData(orderList);
+
+        PageInfo<OrderVo> pageData = new PageInfo<>(orderList);
+        return ResponseJson.success(pageData);
+    }
+
+    @Override
+    public ResponseJson<List<String>> getSearchHistory(Integer userId) {
+        List<String> searchHistoryList = orderMapper.getSearchHistoryList(userId);
+        return ResponseJson.success(searchHistoryList);
+    }
+
+    @Override
+    public ResponseJson<String> deleteSearchHistory(Integer userId) {
+        orderMapper.deleteSearchHistory(userId);
+        return ResponseJson.success(null);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> orderTotal(Integer userId) {
+        Map<String, Object> map = new HashMap<>(5);
+        //待付款数量
+        Integer paymentCount = orderMapper.findOrderCount(userId, 1);
+        paymentCount = paymentCount == null ? 0 : paymentCount;
+        map.put("paymentCount", paymentCount);
+        //待发货数量
+        Integer waitShipmentsCount = orderMapper.findOrderCount(userId, 2);
+        waitShipmentsCount = waitShipmentsCount == null ? 0 : waitShipmentsCount;
+        map.put("waitShipmentsCount", waitShipmentsCount);
+        //已发货数量
+        Integer shipmentsCount = orderMapper.findOrderCount(userId, 3);
+        shipmentsCount = shipmentsCount == null ? 0 : shipmentsCount;
+        map.put("shipmentsCount", shipmentsCount);
+        //退货款数量
+        Integer salesReturnCount = orderMapper.findOrderCount(userId, 4);
+        salesReturnCount = salesReturnCount == null ? 0 : salesReturnCount;
+        map.put("salesReturnCount", salesReturnCount);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 支付金额,待付金额
+     */
+    public List<DiscernReceiptVo> getDiscernReceipt(OrderVo order) {
+        //支付记录
+        List<DiscernReceiptVo> discernReceiptList = orderMapper.findDiscernReceipt(order.getOrderId());
+        BigDecimal receiptAmount = BigDecimal.ZERO;
+        //订单款
+        if (discernReceiptList != null && discernReceiptList.size() > 0) {
+            for (DiscernReceiptVo discernReceipt : discernReceiptList) {
+                receiptAmount = receiptAmount.add(discernReceipt.getAssociateAmount());
+            }
+        }
+        //待付总金额
+        order.setPendingPayments(MathUtil.sub(order.getPayableAmount(), receiptAmount));
+        //支付总金额
+        order.setReceiptAmount(receiptAmount);
+        return discernReceiptList;
+    }
+}
+

+ 22 - 7
src/main/java/com/caimei/service/impl/ProductServiceImpl.java

@@ -4,10 +4,7 @@ import com.caimei.mapper.ProductMapper;
 import com.caimei.model.ResponseJson;
 import com.caimei.model.po.ProductDetailInfoPo;
 import com.caimei.model.po.UserSearchHistoryPo;
-import com.caimei.model.vo.ActivityLadderVo;
-import com.caimei.model.vo.ProductDetailsVo;
-import com.caimei.model.vo.ProductVo;
-import com.caimei.model.vo.RelatedParametersVo;
+import com.caimei.model.vo.*;
 import com.caimei.service.ProductService;
 import com.caimei.util.MathUtil;
 import com.caimei.util.ProductUtils;
@@ -19,9 +16,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 
 /**
  * Description
@@ -171,4 +166,24 @@ public class ProductServiceImpl implements ProductService {
         productMapper.deleteHistory(userId);
         return ResponseJson.success(null);
     }
+
+    @Override
+    public ResponseJson<PageInfo<HeHeActivityVo>> activityArea(Integer userId, Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<HeHeActivityVo> activityList = productMapper.findActivityAll(userId);
+        PageInfo<HeHeActivityVo> pageInfo = new PageInfo<>(activityList);
+        return ResponseJson.success(pageInfo);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> activityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize) {
+        Map<String, Object> map = new HashMap<>(2);
+        String image = productMapper.findActivityById(activityId);
+        PageHelper.startPage(pageNum, pageSize);
+        List<ProductVo> productList = productMapper.findActivityProduct(userId, activityId);
+        PageInfo<ProductVo> pageInfo = new PageInfo<>(productList);
+        map.put("image", image);
+        map.put("pageInfo", pageInfo);
+        return ResponseJson.success(map);
+    }
 }

+ 2 - 1
src/main/resources/backup.sql

@@ -77,7 +77,8 @@ COMMENT='呵呵商城活动阶梯表';
 
 ALTER TABLE `user`
   CHANGE `userPermission` `userPermission` INT DEFAULT 0  NULL   COMMENT '用户权限 0游客 1 普通用户 2 会员机构 3 供应商 4 协销 5 普通机构 6 呵呵商城用户【V6.2.0版本后0和1不存在】',
-  CHANGE `userIdentity` `userIdentity` INT DEFAULT 0  NULL   COMMENT '用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户【V6.2.0版本后0不存在】';
+  CHANGE `userIdentity` `userIdentity` INT DEFAULT 0  NULL   COMMENT '用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户【V6.2.0版本后0不存在】',
+  CHANGE `registerUserTypeID` `registerUserTypeID` INT NULL   COMMENT '见枚举UserType(1供应商,2协销经理,32协销,3会员机构,4普通机构,6呵呵商城)';
 
 CREATE TABLE `cm_hehe_user_activity`(
   `id` INT NOT NULL AUTO_INCREMENT,

+ 497 - 0
src/main/resources/mapper/OrderMapper.xml

@@ -0,0 +1,497 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.mapper.OrderMapper">
+    <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,
+          refundType,
+          onlinePayFlag,
+          payTotalFee,
+          payableAmount,
+          balancePayFee,
+          discountFee,
+          promotionFullReduction,
+          note,
+          orderSource,
+          orderTime,
+          productCount,
+          presentCount,
+          promotionalGiftsCount,
+          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 orderType = 2
+        <if test="userId != null ">
+            AND userID = #{userId}
+        </if>
+        <if test="orderState == 1 ">
+            AND status IN(11,12,13,21,22,23)
+        </if>
+        <if test="orderState == 2 ">
+            AND status IN(11,12,21,22,31,32)
+        </if>
+        <if test="orderState == 3 ">
+            AND status IN(12,13,22,23,32,33)
+        </if>
+        <if test="orderState == 4 ">
+            AND refundType IN(1,2)
+        </if>
+        ORDER BY orderTime DESC
+    </select>
+
+    <select id="findLogistics" resultType="com.caimei.model.vo.LogisticsBatchVo">
+        SELECT
+          `id`,
+          `shopOrderID` AS shopOrderId,
+          `orderID` AS orderId,
+          `outStoreTimes`,
+          `mailer`,
+          `shopID` AS shopId,
+          `deliveryTime`,
+          `receiptTime`,
+          `remarkImage`,
+          `remark`,
+          `status`
+        FROM
+          `cm_logistics_batch`
+        WHERE
+          orderID = #{orderId}
+    </select>
+
+    <select id="findAllShopOrder" resultType="com.caimei.model.vo.ShopOrderVo">
+        SELECT
+        cso.shopOrderID AS shopOrderId,
+        cso.shopOrderNo,
+        cso.orderID AS orderId,
+        cso.userID AS userId,
+        cso.shopID AS shopId,
+        cso.itemCount,
+        cso.totalAmount,
+        cso.note,
+        s.name AS shopName,
+        s.logo AS shopLogo
+        FROM
+        cm_shop_order cso
+        LEFT JOIN shop s ON cso.shopID = s.shopID
+        WHERE
+        cso.orderID = #{orderId}
+        AND cso.delFlag = '0'
+    </select>
+
+    <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.taxRate,
+          cop.addedValueTax,
+          cop.totalAddedValueTax,
+          cop.notOutStore,
+          cop.name,
+          cop.productUnit,
+          cop.productImage,
+          cop.productType,
+          cop.ladderPriceFlag
+        FROM
+          cm_order_product cop
+        WHERE
+          cop.shopOrderID = #{shopOrderId}
+    </select>
+
+    <select id="findDiscernReceipt" resultType="com.caimei.model.vo.DiscernReceiptVo">
+        SELECT
+          cdr.id,
+          cdr.receiptDate,
+          cror.associateAmount
+        FROM
+          cm_receipt_order_relation cror
+          LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE
+          cror.orderID = #{orderID}
+          AND cror.relationType = '2'
+          AND cror.delFlag = '0'
+          AND cdr.delFlag = '0'
+          AND cdr.receiptStatus = '3'
+          AND cdr.payType != '16'
+        ORDER BY
+          cdr.receiptDate DESC
+    </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="findReturnedPurchase" resultType="java.math.BigDecimal">
+        SELECT
+          SUM(refundFee)
+        FROM
+          cm_returned_purchase
+        WHERE
+          orderID = #{orderId}
+          AND STATUS = '2'
+    </select>
+
+    <select id="findLogisticsRecord" resultType="com.caimei.model.vo.LogisticsRecordVo">
+        SELECT
+          clr.id,
+          clr.logisticsBatchID AS logisticsBatchId,
+          clr.shopOrderID AS shopOrderId,
+          clr.orderID AS orderId,
+          clr.orderProductID AS orderProductId,
+          clr.buyNum,
+          clr.num,
+          clr.productID AS productId,
+          clr.productName,
+          clr.image,
+          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 = #{batchId}
+    </select>
+
+    <select id="findLogisticsInfo" resultType="com.caimei.model.vo.LogisticsInformationVo">
+        SELECT DISTINCT
+        li.`orderProductID` AS orderProductId,
+        li.`shopOrderID` AS shopOrderId,
+        li.`orderID` AS orderId,
+        li.`nu`,
+        li.`state`,
+        li.`info`,
+        li.`logisticsCompanyName`,
+        li.`logisticsCompanyCode`,
+        li.`shopID`,
+        li.`remarks`,
+        li.`logisticsBatchID` AS logisticsBatchId,
+        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>
+
+    <update id="deleteOrder">
+        UPDATE
+          cm_order
+        SET
+          delFlag = 1,
+          updateDate = NOW(),
+          note = '用户发起删除订单'
+        WHERE
+          orderID = #{orderId}
+    </update>
+
+    <update id="deleteShopOrder">
+        UPDATE cm_shop_order SET delFlag = 1 WHERE orderID = #{orderId}
+    </update>
+
+    <update id="deleteReceiptOrderRelation">
+        UPDATE
+          cm_receipt_order_relation
+        SET
+          delFlag = '1'
+        WHERE
+          orderID = #{orderID}
+    </update>
+
+    <update id="deleteDiscernReceipt">
+         UPDATE
+          cm_discern_receipt
+        SET
+          delFlag = '1'
+        WHERE
+          id =  #{id}
+    </update>
+
+    <select id="findPayShopRecord" resultType="com.caimei.model.po.CmPayShopRecordPo">
+        SELECT
+            id,
+            shopID,
+            shopOrderID,
+            shopOrderNo,
+            payAmount,
+            wipePayment,
+            payType,
+            payTime,
+            payShopID,
+            status,
+            delFlag
+        FROM
+          cm_pay_shop_record
+        WHERE
+          delFlag = '0'
+          AND shopOrderID = #{shopOrderId}
+        ORDER BY payTime desc
+    </select>
+
+    <update id="deletePayShopRecord">
+        UPDATE
+          cm_pay_shop_record
+        SET
+          delFlag = '0'
+        WHERE
+          shopOrderID = #{shopOrderId}
+    </update>
+
+    <update id="updatePayShop">
+        UPDATE
+          cm_pay_shop
+        SET
+          delFlag = '0'
+    WHERE
+          id = #{payShopId}
+    </update>
+
+    <update id="cancelOrder">
+        UPDATE
+          cm_order
+        SET
+          STATUS = 6,
+          updateDate = NOW(),
+          closeReason = '用户主动取消订单',
+          closeTime = NOW()
+        WHERE
+          orderID = #{orderId}
+    </update>
+
+    <select id="searchOrder" resultType="com.caimei.model.vo.OrderVo">
+        SELECT
+          co.orderID AS orderId,
+          co.orderNo,
+          co.organizeID AS organizeId,
+          co.userID AS userId,
+          co.buyUserID AS buyUserId,
+          co.status,
+          co.shopOrderIDs AS shopOrderIds,
+          co.receiptStatus,
+          co.payStatus,
+          co.sendOutStatus,
+          co.refundType,
+          co.onlinePayFlag,
+          co.payTotalFee,
+          co.payableAmount,
+          co.balancePayFee,
+          co.discountFee,
+          co.promotionFullReduction,
+          co.note,
+          co.orderSource,
+          co.orderTime,
+          co.productCount,
+          co.presentCount,
+          co.promotionalGiftsCount,
+          co.invoiceFlag,
+          co.clauseID AS clauseId,
+          co.clauseContent,
+          co.clauseName,
+          co.freePostFlag,
+          co.freight,
+          co.closeReason
+        FROM
+          cm_order co
+          LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
+        WHERE
+          co.userID = #{userId}
+          AND co.delFlag = '0'
+          AND cop.name LIKE CONCAT('%',#{searchWord},'%')
+        GROUP BY
+          co.orderID
+        ORDER BY
+          co.orderTime DESC
+    </select>
+
+    <select id="getSearchHistoryList" resultType="string">
+        SELECT
+          searchWord
+        FROM
+          user_order_history
+        WHERE
+          userId = #{userId}
+          AND delFlag = 0
+        ORDER BY
+          searchDate DESC
+        LIMIT
+          10
+    </select>
+
+    <delete id="deleteSearchHistory">
+        DELETE FROM user_order_history WHERE userId = #{userId}
+    </delete>
+
+    <insert id="insertHistory">
+        INSERT INTO `user_order_history` (
+          `userId`, `searchWord`, `searchDate`,
+          `delFlag`
+        )
+        VALUES
+          (
+            #{userId}, #{searchWord}, #{searchDate},
+            #{delFlag}
+          )
+    </insert>
+
+    <select id="getHistoryIdByWord" resultType="long">
+        SELECT
+          id
+        FROM
+          user_order_history
+        WHERE
+          searchWord = #{userId}
+          AND userId = #{searchWord}
+          AND delFlag = 0
+    </select>
+
+    <update id="updateHistoryById">
+        UPDATE user_order_history SET searchDate = #{searchDate} WHERE id = #{id}
+    </update>
+
+    <delete id="deleteHistoryByUserId">
+        DELETE FROM user_order_history
+        WHERE userId=#{userId}
+        AND id NOT IN (
+            SELECT temp.id FROM (
+                SELECT id FROM user_order_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10
+            ) AS temp
+        )
+    </delete>
+
+    <select id="findOrderCount" resultType="integer">
+        SELECT
+        COUNT(*)
+        FROM
+        cm_order
+        WHERE
+        userId = #{userId}
+        AND delFlag = '0'
+        <if test="status == 0">
+            AND status = '0'
+        </if>
+        <if test="status == 1">
+            AND status IN(11,12,13,21,22,23)
+        </if>
+        <if test="status == 2">
+            AND status IN(11,12,21,22,31,32)
+        </if>
+        <if test="status == 3">
+            AND status IN(12,13,22,23,32,33)
+        </if>
+        <if test="status == 4">
+            AND refundType IN(1,2)
+        </if>
+    </select>
+</mapper>

+ 47 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -200,4 +200,51 @@
         DELETE FROM user_search_history WHERE userId + #{userId}
     </delete>
 
+    <select id="findActivityAll" resultType="com.caimei.model.vo.HeHeActivityVo">
+        SELECT
+          cha.id AS activityId,
+          cha.name,
+          cha.listImage,
+          cha.beginTime,
+          cha.endTime,
+          COUNT(chua.id) AS productCount
+        FROM
+          cm_hehe_user_activity chua
+          LEFT JOIN cm_hehe_activity cha ON chua.activityId = cha.id
+        WHERE
+          chua.userId = #{userId}
+          AND cha.delFlag = 0
+          AND cha.status = 1
+          AND cha.beginTime <![CDATA[ <= ]]> NOW()
+          AND cha.endTime <![CDATA[ >= ]]> NOW()
+        GROUP BY
+          cha.id
+        ORDER BY
+          cha.addTime DESC
+    </select>
+
+    <select id="findActivityById" resultType="string">
+        SELECT detailsImage FROM cm_hehe_activity WHERE id = #{activityId}
+    </select>
+
+    <select id="findActivityProduct" resultType="com.caimei.model.vo.ProductVo">
+        SELECT
+          chp.productId,
+          chp.recommend,
+          chp.price,
+          chp.includedTax,
+          chp.invoiceType,
+          chp.clubTaxPoint,
+          p.name,
+          P.unit,
+          p.mainImage
+        FROM
+          cm_hehe_user_activity chua
+          LEFT JOIN cm_hehe_product chp ON chua.productId = chp.productId
+          LEFT JOIN product p ON chua.productId = p.productID
+        WHERE
+          chua.userId = #{userId}
+          AND chua.activityId = #{activityId}
+    </select>
+
 </mapper>