haungfuli пре 3 година
родитељ
комит
1018c2e0c7

+ 46 - 3
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/OrderInfoController.java

@@ -1,9 +1,11 @@
 package com.yh.saas.plugin.yiliangyiyun.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.IOrderInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -17,5 +19,46 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/orderInfo")
 public class OrderInfoController {
 
+    @Autowired
+    private IOrderInfoService orderInfoService;
+
+    /**
+     * 订单列表
+     *
+     * @param orderInfo
+     * @return
+     */
+    @GetMapping("/selectOrderInfo")
+    public Page<OrderInfo> selectOrderInfo(OrderInfo orderInfo) {
+        return orderInfoService.selectOrderInfo(orderInfo);
+    }
+
+    /**
+     * 订单详情
+     */
+    @GetMapping("/getOrderInfo")
+    public OrderInfo getOrderInfo(@RequestParam String id) {
+        return orderInfoService.getOrderInfo(id);
+    }
+
+    /**
+     * 终止
+     * @param orderInfo
+     * @return
+     */
+    @PostMapping("/api/end")
+    public String end(@RequestBody OrderInfo orderInfo){
+        return orderInfoService.end(orderInfo);
+    }
+
+    /**
+     * 签约
+     * @param orderInfo
+     * @return
+     */
+    @PostMapping("/api/signContract")
+    public String signContract(@RequestBody OrderInfo orderInfo){
+        return orderInfoService.signContract(orderInfo);
+    }
 }
 

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/CarrierInfo.java

@@ -131,5 +131,9 @@ public class CarrierInfo extends BaseModel<CarrierInfo> {
     protected Serializable pkVal() {
         return this.id;
     }
+    public static class QueryFiles {
 
+        public static final String ORDER_ID = "order_id";
+
+    }
 }

+ 4 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/FreightInfo.java

@@ -57,5 +57,9 @@ public class FreightInfo extends BaseModel<FreightInfo> {
     protected Serializable pkVal() {
         return this.id;
     }
+    public static class QueryFiles {
 
+        public static final String ORDER_ID = "order_id";
+
+    }
 }

+ 25 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/OrderInfo.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.entity;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.yh.saas.common.support.entity.BaseModel;
 import lombok.Data;
@@ -113,7 +114,7 @@ public class OrderInfo extends BaseModel<OrderInfo> {
      */
     private String billingMethod;
     /**
-     * 订单状态key(1未发运3运输中5待收货7待结算9已结)
+     * 订单状态key(1未发运3运输中5待收货7待结算9已结算11待签约13已终止
      */
     private String orderStatusKey;
     /**
@@ -121,6 +122,29 @@ public class OrderInfo extends BaseModel<OrderInfo> {
      */
     private String orderStatus;
 
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+
+    /**
+     * 查询类型
+     */
+    @TableField(exist = false)
+    private String searchType;
+
+    /**
+     * 运费信息表
+     */
+    @TableField(exist = false)
+    private FreightInfo freightInfo;
+
+    /**
+     * 承运信息表
+     */
+    @TableField(exist = false)
+    private CarrierInfo carrierInfo;
 
     @Override
     protected Serializable pkVal() {

+ 18 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/OrderInfoMapper.java

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录订单详情信息 Mapper 接口
@@ -13,4 +16,19 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  */
 public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
 
+    /**
+     * 根据条件查询订单总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询订单列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<OrderInfo> getListByCondition(Map<String, Object> pageView);
 }

+ 29 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/IOrderInfoService.java

@@ -1,5 +1,6 @@
 package com.yh.saas.plugin.yiliangyiyun.service;
 
+import com.baomidou.mybatisplus.plugins.Page;
 import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -13,4 +14,32 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface IOrderInfoService extends IService<OrderInfo> {
 
+    /**
+     * 订单列表
+     *
+     * @param orderInfo
+     * @return
+     */
+    Page<OrderInfo> selectOrderInfo(OrderInfo orderInfo);
+
+    /**
+     * 订单详情
+     *
+     * @param
+     */
+    OrderInfo getOrderInfo(String id);
+
+    /**
+     * 终止
+     * @param orderInfo
+     * @return
+     */
+    String end (OrderInfo orderInfo);
+
+    /**
+     * 签约
+     * @param orderInfo
+     * @return
+     */
+    String signContract (OrderInfo orderInfo);
 }

+ 97 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/OrderInfoServiceImpl.java

@@ -1,11 +1,24 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
+import com.yh.saas.plugin.yiliangyiyun.entity.CarrierInfo;
+import com.yh.saas.plugin.yiliangyiyun.entity.FreightInfo;
 import com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.OrderInfoMapper;
+import com.yh.saas.plugin.yiliangyiyun.service.ICarrierInfoService;
+import com.yh.saas.plugin.yiliangyiyun.service.IFreightInfoService;
 import com.yh.saas.plugin.yiliangyiyun.service.IOrderInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录订单详情信息 服务实现类
@@ -17,4 +30,88 @@ import org.springframework.stereotype.Service;
 @Service
 public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService {
 
+    @Autowired
+    private IFreightInfoService freightInfoService;
+    @Autowired
+    private ICarrierInfoService carrierInfoService;
+
+    /**
+     * 订单列表
+     *
+     * @param orderInfo
+     * @return
+     */
+    @Override
+    public Page<OrderInfo> selectOrderInfo(OrderInfo orderInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (orderInfo.getCurrentPage() - 1)
+                * orderInfo.getPageSize());
+        //用户id
+        pageView.put("commonId", orderInfo.getCommonId());
+        pageView.put("searchKeyWord", orderInfo.getSearchKeyWord());
+        pageView.put("searchType", orderInfo.getSearchType());
+        pageView.put("pageSize", orderInfo.getPageSize());
+        pageView.put("currentPage", orderInfo.getCurrentPage());
+        // 查询采购订单总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<OrderInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<OrderInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(orderInfo.getCurrentPage());
+        page.setSize(orderInfo.getPageSize());
+        return page;
+    }
+
+    /**
+     * 订单详情
+     * @param id
+     * @return
+     */
+    @Override
+    public OrderInfo getOrderInfo (String id){
+        //基本信息
+        OrderInfo orderInfo = this.selectById(id);
+        //承运信息
+        CarrierInfo carrierInfo = carrierInfoService.selectOne(new EntityWrapper<CarrierInfo>().eq(CarrierInfo.QueryFiles.ORDER_ID,id));
+        orderInfo.setCarrierInfo(carrierInfo);
+        //运费信息
+        FreightInfo freightInfo = freightInfoService.selectOne(new EntityWrapper<FreightInfo>().eq(FreightInfo.QueryFiles.ORDER_ID,id));
+        orderInfo.setFreightInfo(freightInfo);
+        return orderInfo;
+    }
+
+    /**
+     * 终止
+     * @param orderInfo
+     * @return
+     */
+    @Override
+    public String end (OrderInfo orderInfo){
+        //查询订单
+        OrderInfo orderInfo1 = this.selectById(orderInfo.getId());
+        if(orderInfo1 != null){
+            orderInfo1.setOrderStatusKey(StatusEnum.DRIVER_ORDER_END.getFlag());
+            orderInfo1.setOrderStatus(StatusEnum.DRIVER_ORDER_END.getName());
+            this.updateById(orderInfo1);
+        }
+        return "ok";
+    }
+
+    /**
+     * 签约
+     * @param orderInfo
+     * @return
+     */
+    @Override
+    public String signContract (OrderInfo orderInfo){
+        //查询订单
+        OrderInfo orderInfo1 = this.selectById(orderInfo.getId());
+        if(orderInfo1 != null){
+            orderInfo1.setOrderStatusKey(StatusEnum.DRIVER_ORDER_SHIPPING.getFlag());
+            orderInfo1.setOrderStatus(StatusEnum.DRIVER_ORDER_SHIPPING.getName());
+            this.updateById(orderInfo1);
+        }
+        return "ok";
+    }
 }

+ 81 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/OrderInfoMapper.xml

@@ -1,5 +1,85 @@
 <?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.yh.saas.plugin.yiliangyiyun.mapper.OrderInfoMapper">
-
+    <!-- 获得订单总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM order_info
+        WHERE delete_flag = '0'
+        AND common_id = #{commonId}
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(order_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND order_status_key = '1'
+                OR order_status_key = '11'
+            </if>
+            <if test="searchType == 2">
+                AND order_status_key = '3'
+            </if>
+            <if test="searchType == 3">
+                AND order_status_key = '5'
+            </if>
+            <if test="searchType == 4">
+                AND order_status_key = '7'
+            </if>
+            <if test="searchType == 5">
+                AND order_status_key = '9'
+                OR order_status_key = '13'
+            </if>
+        </if>
+    </select>
+    <!-- 获得采购计划列表 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.OrderInfo">
+        SELECT
+        id,
+        order_no as orderNo,
+        goods_name as goodsName,
+        send_private as sendPrivate,
+        send_city as sendCity,
+        send_area as sendArea,
+        unload_private as unloadPrivate,
+        unload_city as unloadCity,
+        unload_area as unloadArea,
+        comp_name as compName,
+        cargo_owner as cargoOwner,
+        distance,
+        freight,
+        order_status as orderStatus,
+        order_status_key as orderStatusKey,
+        create_date as createDate,
+        update_date as updateDate
+        FROM order_info
+        WHERE delete_flag = '0'
+        AND common_id = #{commonId}
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(order_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND order_status_key = '1'
+                OR order_status_key = '11'
+            </if>
+            <if test="searchType == 2">
+                AND order_status_key = '3'
+            </if>
+            <if test="searchType == 3">
+                AND order_status_key = '5'
+            </if>
+            <if test="searchType == 4">
+                AND order_status_key = '7'
+            </if>
+            <if test="searchType == 5">
+                AND order_status_key = '9'
+                OR order_status_key = '13'
+            </if>
+        </if>
+        ORDER BY create_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>