Ver Fonte

销售计划接口

zhangyuewww há 3 anos atrás
pai
commit
e9eeb3b48a

+ 78 - 3
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/controller/SalePlanInfoController.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.SalePlanInfo;
+import com.yh.saas.plugin.yiliangyiyun.service.ISalePlanInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * <p>
@@ -16,6 +18,79 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/salePlanInfo")
 public class SalePlanInfoController {
+    @Autowired
+    private ISalePlanInfoService salePlanInfoService;
+
+    /**
+     * 查看销售计划
+     * @param id
+     * @return
+     */
+    @GetMapping("/getSalePlanInfo")
+    public SalePlanInfo getSalePlanInfo(String id){
+        return salePlanInfoService.getSalePlanInfo(id);
+    }
+
+    /**
+     * 编辑销售计划
+     * @param salePlanInfo
+     * @return
+     */
+    @PostMapping("/api/editSalePlanInfo")
+    public String editSalePlanInfo(@RequestBody SalePlanInfo salePlanInfo){
+        return salePlanInfoService.editSalePlanInfo(salePlanInfo);
+    }
+
+    /**
+     * 删除销售计划
+     *  @param salePlanInfo
+     * @return
+     */
+    @PostMapping("/api/deleteSalePlanInfo")
+    public void deleteSalePlanInfo(@RequestBody SalePlanInfo salePlanInfo) {
+        salePlanInfoService.deleteSalePlanInfo(salePlanInfo.getId());
+    }
+
+    /**
+     * 销售计划列表
+     * @param salePlanInfo
+     * @return
+     */
+    @GetMapping("/selectSalePlanInfo")
+    public Page<SalePlanInfo> selectSalePlanInfo(SalePlanInfo salePlanInfo) {
+        return salePlanInfoService.selectSalePlanInfo(salePlanInfo);
+    }
+
+    /**
+     * 添加销售计划
+     * @param salePlanInfo
+     * @return
+     */
+    @PostMapping("/api/insertSalePlanInfo")
+    public String insertSalePlanInfo(@RequestBody SalePlanInfo salePlanInfo) {
+        return salePlanInfoService.insertSalePlanInfo(salePlanInfo);
+    }
+
+    /**
+     * 更改状态/基差/单价
+     * @param salePlanInfo
+     * @return
+     */
+    @PostMapping("/api/editStatus")
+    public String editStatus(@RequestBody SalePlanInfo salePlanInfo){
+        return salePlanInfoService.editStatus(salePlanInfo);
+
+    }
+    /**
+     * 审核
+     * @param salePlanInfo
+     * @return
+     */
+    @PostMapping("/api/examine")
+    public String examine(@RequestBody SalePlanInfo salePlanInfo){
+        return salePlanInfoService.examine(salePlanInfo);
+
+    }
 
 }
 

+ 29 - 12
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SalePlanInfo.java

@@ -3,6 +3,7 @@ package com.yh.saas.plugin.yiliangyiyun.entity;
 import com.baomidou.mybatisplus.activerecord.Model;
 import java.io.Serializable;
 
+import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.annotations.Version;
@@ -103,21 +104,21 @@ public class SalePlanInfo extends BaseModel<SalePlanInfo> {
      */
     private String priceTypeKey;
     /**
-     * 货库
+     * 货库
      */
-    private String receiveWarehouse;
+    private String sendWarehouse;
     /**
-     * 货库所在地省
+     * 货库所在地省
      */
-    private String receivePrivate;
+    private String sendPrivate;
     /**
-     * 货库所在地市
+     * 货库所在地市
      */
-    private String receiveCity;
+    private String sendCity;
     /**
-     * 货库所在地区
+     * 货库所在地区
      */
-    private String receiveArea;
+    private String sendArea;
     /**
      * 运费承担方(1可议2卖方承担3买方承担)
      */
@@ -131,13 +132,13 @@ public class SalePlanInfo extends BaseModel<SalePlanInfo> {
      */
     private String baggingNotes;
     /**
-     * 
+     * 
      */
-    private String buyer;
+    private String seller;
     /**
-     * 方电话
+     * 方电话
      */
-    private String buyerPhone;
+    private String sellerPhone;
     /**
      * 水分
      */
@@ -226,6 +227,22 @@ public class SalePlanInfo extends BaseModel<SalePlanInfo> {
      * pc端标识
      */
     private String pcFlag;
+    /**
+     * 模糊查询
+     */
+    @TableField(exist = false)
+    private String searchKeyWord;
+    /**
+     * 通过1驳回2
+     * 0 修改状态 1修改基差 2 修改单价
+     */
+    @TableField(exist = false)
+    private Integer flag;
+    /**
+     * 查询类型
+     */
+    @TableField(exist = false)
+    private String searchType;
 
 
     @Override

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

@@ -3,6 +3,9 @@ package com.yh.saas.plugin.yiliangyiyun.mapper;
 import com.yh.saas.plugin.yiliangyiyun.entity.SalePlanInfo;
 import com.baomidou.mybatisplus.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  * 记录销售计划 Mapper 接口
@@ -12,5 +15,20 @@ import com.baomidou.mybatisplus.mapper.BaseMapper;
  * @since 2021-08-04
  */
 public interface SalePlanInfoMapper extends BaseMapper<SalePlanInfo> {
+    /**
+     * 根据条件查询销售订单总数
+     *
+     * @param pageView
+     * @return
+     */
+    Integer getCountByCondition(Map<String, Object> pageView);
+
+    /**
+     * 根据条件查询销售订单列表
+     *
+     * @param pageView
+     * @return
+     */
+    List<SalePlanInfo> getListByCondition(Map<String, Object> pageView);
 
 }

+ 47 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/ISalePlanInfoService.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.SalePlanInfo;
 import com.baomidou.mybatisplus.service.IService;
 
@@ -13,4 +14,50 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface ISalePlanInfoService extends IService<SalePlanInfo> {
 
+    /**
+     * 查看销售计划
+     * @param id
+     */
+    SalePlanInfo getSalePlanInfo(String id);
+
+    /**
+     * 编辑销售计划
+     * @param salePlanInfo
+     */
+    String editSalePlanInfo(SalePlanInfo salePlanInfo);
+
+    /**
+     * 删除销售计划
+     * @param id
+     */
+    void deleteSalePlanInfo(String id);
+
+    /**
+     * 销售计划列表
+     * @param salePlanInfo
+     * @return
+     */
+    Page<SalePlanInfo> selectSalePlanInfo(SalePlanInfo salePlanInfo);
+
+    /**
+     * 添加销售计划
+     * @param salePlanInfo
+     * @return
+     */
+    String insertSalePlanInfo(SalePlanInfo salePlanInfo);
+
+    /**
+     * 更改状态
+     * @param salePlanInfo
+     * @return
+     */
+    String editStatus(SalePlanInfo salePlanInfo);
+
+    /**
+     * 审核
+     * @param salePlanInfo
+     * @return
+     */
+    String examine(SalePlanInfo salePlanInfo);
+
 }

+ 185 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/SalePlanInfoServiceImpl.java

@@ -1,11 +1,23 @@
 package com.yh.saas.plugin.yiliangyiyun.service.impl;
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.google.common.collect.Lists;
+import com.yh.saas.common.support.util.IdGenerator;
+import com.yh.saas.plugin.base.service.ICommonBillOperateHisService;
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
+import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
 import com.yh.saas.plugin.yiliangyiyun.entity.SalePlanInfo;
 import com.yh.saas.plugin.yiliangyiyun.mapper.SalePlanInfoMapper;
 import com.yh.saas.plugin.yiliangyiyun.service.ISalePlanInfoService;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.yh.saas.plugin.yiliangyiyun.util.GeTuiUtils;
+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>
  * 记录销售计划 服务实现类
@@ -16,5 +28,178 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class SalePlanInfoServiceImpl extends ServiceImpl<SalePlanInfoMapper, SalePlanInfo> implements ISalePlanInfoService {
+    @Autowired
+    private ICommonBillOperateHisService billOperateHisService;
+    @Autowired
+    private GeTuiUtils geTuiUtils;
+    /**
+     * 查看销售计划
+     * @param id
+     * @return
+     */
+    @Override
+    public SalePlanInfo getSalePlanInfo(String id) {
+        //查看销售计划信息
+        SalePlanInfo salePlanInfo = this.selectById(id);
+        return salePlanInfo;
+    }
+
+    /**
+     * 编辑销售计划
+     * @param salePlanInfo
+     * @return
+     */
+    @Override
+    public String editSalePlanInfo(SalePlanInfo salePlanInfo) {
+        //状态改为待审核
+        salePlanInfo.setStatus(StatusEnum.ORDER_REVIEWED.getName());
+        salePlanInfo.setStatusFlag(StatusEnum.ORDER_REVIEWED.getFlag());
+        boolean one = this.updateById(salePlanInfo);
+        if (one) {
+            return "OK";
+        } else {
+            return "NG";
+        }
+    }
+
+    /**
+     * 删除销售计划
+     *  @param id
+     * @return
+     */
+    @Override
+    public void deleteSalePlanInfo(String id) {
+        //查询销售计划信息
+        SalePlanInfo salePlanInfo = this.selectById(id);
+        if(salePlanInfo != null){
+            //删除销售计划信息
+            this.deleteById(salePlanInfo.getId());
+        }
+    }
+
+    /**
+     * 销售计划列表
+     * @param salePlanInfo
+     * @return
+     */
+    @Override
+    public Page<SalePlanInfo> selectSalePlanInfo(SalePlanInfo salePlanInfo) {
+        Map<String, Object> pageView = new HashMap<>();
+        pageView.put("startRecord", (salePlanInfo.getCurrentPage() - 1)
+                * salePlanInfo.getPageSize());
+        //公司id
+        pageView.put("compId",salePlanInfo.getCompId());
+        pageView.put("commonId",salePlanInfo.getCommonId());
+        pageView.put("searchKeyWord",salePlanInfo.getSearchKeyWord());
+        pageView.put("searchType", salePlanInfo.getSearchType());
+        pageView.put("pcFlag",salePlanInfo.getPcFlag());
+        pageView.put("showFlag",salePlanInfo.getShowFlag());
+        pageView.put("sendPrivate",salePlanInfo.getSendPrivate());
+        pageView.put("pageSize",salePlanInfo.getPageSize());
+        pageView.put("currentPage",salePlanInfo.getCurrentPage());
+        // 查询销售订单总数
+        Integer dataCount = baseMapper.getCountByCondition(pageView);
+        List<SalePlanInfo> dataList = baseMapper.getListByCondition(pageView);
+        Page<SalePlanInfo> page = new Page<>();
+        page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
+        page.setTotal(dataCount == null ? 0 : dataCount);
+        page.setCurrent(salePlanInfo.getCurrentPage());
+        page.setSize(salePlanInfo.getPageSize());
+        return page;
+    }
+
+    /**
+     * 添加销售计划
+     * @param salePlanInfo
+     * @return
+     */
+    @Override
+    public String insertSalePlanInfo(SalePlanInfo salePlanInfo) {
+        //新增主键id
+        salePlanInfo.setId(IdGenerator.generateUUID());
+        salePlanInfo.setStatus(StatusEnum.ORDER_REVIEWED.getName());
+        salePlanInfo.setStatusFlag(StatusEnum.ORDER_REVIEWED.getFlag());
+        salePlanInfo.setShowFlag(StatusEnum.PURCHASE_SHOW.getFlag());
+        // 操作主表数据
+        this.insert(salePlanInfo);
+        // 插入操作历史
+        String staffName = this.billOperateHisService.getStaffAndName();
+        // 插入操作历史
+        this.billOperateHisService.saveBillOperateHis(salePlanInfo.getId(), NumberConstant.CONSTANT_PURCHASE, staffName, null,
+                salePlanInfo.getStatus(), null, "");
+        return salePlanInfo.getId();
+    }
+
+    /**
+     * 更改状态
+     * @param salePlanInfo
+     * @return
+     */
+    @Override
+    public String editStatus(SalePlanInfo salePlanInfo) {
+        //查询销售计划列表
+        SalePlanInfo salePlanInfo1=this.selectById(salePlanInfo.getId());
+        if (salePlanInfo1 != null ){
+            //更改状态
+            if(salePlanInfo.getFlag() == 0) {
+                if (StatusEnum.PURCHASE_HIDE.getFlag().equals(salePlanInfo1.getShowFlag())) {
+                    salePlanInfo1.setShowFlag(StatusEnum.PURCHASE_SHOW.getFlag());
+                } else {
+                    salePlanInfo1.setShowFlag(StatusEnum.PURCHASE_HIDE.getFlag());
+                }
+                //更改销售计划信息
+                this.updateById(salePlanInfo1);
+                // 插入操作历史
+                String staffName = this.billOperateHisService.getStaffAndName();
+                // 插入操作历史
+                this.billOperateHisService.saveBillOperateHis(salePlanInfo1.getId(), NumberConstant.CONSTANT_PURCHASE, staffName, null,
+                        salePlanInfo1.getStatus(), null, "");
+                return "OK";
+            }
+            //更改基差
+            else if(salePlanInfo.getFlag()==1){
+                salePlanInfo1.setBasisPrice(salePlanInfo.getBasisPrice());
+                //更改销售计划信息
+                this.updateById(salePlanInfo1);
+                return "OK";
+            }
+            //更改单价
+            else {
+                salePlanInfo1.setUnitPrice(salePlanInfo.getUnitPrice());
+                //更改销售计划信息
+                this.updateById(salePlanInfo1);
+                return "OK";
+            }
+        }
+        return "NG";
+    }
 
+    /**
+     * 审核
+     * @param salePlanInfo
+     * @return
+     */
+    @Override
+    public String examine(SalePlanInfo salePlanInfo) {
+        //查询销售计划列表
+        SalePlanInfo salePlanInfo1=this.selectById(salePlanInfo.getId());
+        if (salePlanInfo1 != null ){
+            //通过
+            if(salePlanInfo.getFlag()==1){
+                salePlanInfo1.setStatusFlag(StatusEnum.ORDER_PASSED.getFlag());
+                salePlanInfo1.setStatus(StatusEnum.ORDER_PASSED.getName());
+                geTuiUtils.pushByCid("审核通知","您申请的交易已审核通过",salePlanInfo1.getCommonId());
+            }
+            //驳回
+            else{
+                salePlanInfo1.setStatusFlag(StatusEnum.ORDER_REJECTED.getFlag());
+                salePlanInfo1.setStatus(StatusEnum.ORDER_REJECTED.getName());
+                geTuiUtils.pushByCid("审核通知","您申请的交易已被驳回",salePlanInfo1.getCommonId());
+            }
+            //更改销售计划信息
+            this.updateById(salePlanInfo1);
+            return "OK";
+        }
+        return "NG";
+    }
 }

+ 93 - 1
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/SalePlanInfoMapper.xml

@@ -1,5 +1,97 @@
 <?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.SalePlanInfoMapper">
-
+    <!-- 获得销售计划总数 -->
+    <select id="getCountByCondition" parameterType="Map" resultType="java.lang.Integer">
+        SELECT
+        COUNT(id)
+        FROM sale_plan_info
+        WHERE delete_flag = '0'
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(sale_plan_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(title) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(goods_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="sendPrivate != null and sendPrivate != '' and sendPrivate != '全国'">
+            AND (lower(send_private) like lower(CONCAT('%',#{sendPrivate},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <if test="searchType == 2">
+                AND status_flag = '7'
+            </if>
+        </if>
+        <if test="pcFlag != null and pcFlag != ''">
+            <if test="pcFlag == 0">
+                AND common_id = #{commonId}
+            </if>
+            <if test="pcFlag == 1">
+                AND comp_id = #{compId}
+            </if>
+        </if>
+        <if test="showFlag != null and showFlag != ''">
+            AND show_flag = #{showFlag}
+        </if>
+    </select>
+    <!-- 获得销售计划列表 -->
+    <select id="getListByCondition" parameterType="Map"
+            resultType="com.yh.saas.plugin.yiliangyiyun.entity.SalePlanInfo">
+        SELECT
+        id,
+        sale_plan_no as salePlanNo,
+        sale_plan_type as salePlanType,
+        title,
+        goods_name as goodsName,
+        weight,
+        basis_price as basisPrice,
+        unit_price as unitPrice,
+        send_private as sendPrivate,
+        sale_price as salePrice,
+        planned_sale_volume as plannedSaleVolume,
+        send_city as sendCity,
+        send_area as sendArea,
+        send_warehouse as sendWarehouse,
+        status,
+        status_flag as statusFlag,
+        seller,
+        seller_phone as sellerPhone,
+        pc_flag as pcFlag,
+        show_flag as showFlag,
+        update_date as updateDate
+        FROM sale_plan_info
+        WHERE delete_flag = '0'
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(sale_plan_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(title) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower(goods_name) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        <if test="sendPrivate != null and sendPrivate != '' and sendPrivate != '全国'">
+            AND (lower(send_private) like lower(CONCAT('%',#{sendPrivate},'%')))
+        </if>
+        <if test="searchType != null and searchType != ''">
+            <if test="searchType == 1">
+                AND status_flag = '1'
+            </if>
+            <if test="searchType == 2">
+                AND status_flag = '7'
+            </if>
+        </if>
+        <if test="pcFlag != null and pcFlag != ''">
+            <if test="pcFlag == 0">
+                AND common_id = #{commonId}
+            </if>
+            <if test="pcFlag == 1">
+                AND comp_id = #{compId}
+            </if>
+        </if>
+        <if test="showFlag != null and showFlag != ''">
+            AND show_flag = #{showFlag}
+        </if>
+        ORDER BY status DESC , update_date DESC
+        <if test="currentPage != null and currentPage != ''">
+            LIMIT ${startRecord}, ${pageSize}
+        </if>
+    </select>
 </mapper>