Browse Source

销售线索分配

yangzian 3 năm trước cách đây
mục cha
commit
812b483fa6

+ 31 - 3
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/controller/SaleClueInfoController.java

@@ -1,6 +1,7 @@
 package com.ruixuan.salesLeads.controller;
 
-import com.alibaba.excel.EasyExcel;
+
+import com.alibaba.excel.util.ConverterUtils;
 import com.ruixuan.common.core.controller.BaseController;
 import com.ruixuan.common.core.domain.ResultResponse;
 import com.ruixuan.common.utils.DateUtils;
@@ -12,6 +13,7 @@ import com.ruixuan.salesLeads.pojo.TestPojo;
 import com.ruixuan.salesLeads.service.ISaleClueInfoService;
 import com.ruixuan.salesLeads.service.ITestService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.io.File;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * ***************************************************
@@ -79,15 +82,40 @@ public class SaleClueInfoController extends BaseController {
             @ApiParam("是否分配销售 0-否 1-是") @RequestParam(value = "distributionSaleFlag",required = false)String distributionSaleFlag,
             @ApiParam("行业id") @RequestParam(value = "industryId",required = false)String industryId,
             @ApiParam("粉丝量级 1:0~50w 2:50W~200W 3:200W~500W 4:500W以上") @RequestParam(value = "fansType",required = false)String fansType,
-            @ApiParam("创建人") @RequestParam(value = "createUserId",required = false) Long createUserId) throws Exception{
+            @ApiParam("状态 1-未开始 2-进行中 3-已结束") @RequestParam(value = "state",required = false)String state,
+            @ApiParam("当前用户id") @RequestParam(value = "userId",required = false) Long userId) throws Exception{
 
         return saleClueInfoServiceImpl.selectSaleClueInfoList(sellerName,
                 StringUtils.isEmpty(uploadDate) ? null : DateUtils.strDateToInt(uploadDate),
-                distributionSaleFlag,industryId,fansType, createUserId);
+                distributionSaleFlag,industryId,fansType,state, userId);
+
+    }
+
+
+
+    @ApiOperation(value = "销售线索-分配-显示数据信息",notes = "销售线索-分配-显示数据信息(可以传多个卖家id)")
+    @GetMapping(value = "/selectSaleClueInfoBySellers")
+    public ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoBySellers(
+            @ApiParam(value = "卖家ids") @RequestParam(value = "sellerIds") List<String> sellerIds){
+        List<Long> longList = sellerIds.stream().map(sellerId -> Long.parseLong(sellerId.trim())).collect(Collectors.toList());
+        return saleClueInfoServiceImpl.selectSaleClueInfoBySellers(longList);
+    }
+
+
 
+
+    @ApiOperation(value = "销售线索-分配",notes = "销售线索-分配-(可以传多个卖家id)")
+    @PostMapping(value = "/saleClueDistribution")
+    public ResultResponse saleClueDistribution(
+            @ApiParam(value = "卖家ids") @RequestParam(value = "sellerIds") List<String> sellerIds,
+            @ApiParam(value = "销售id") @RequestParam(value = "saleId") Long saleId,
+            @ApiParam(value = "创建人id") @RequestParam(value = "createUserId") Long createUserId){
+
+        return saleClueInfoServiceImpl.saleClueDistribution(sellerIds,saleId,createUserId);
     }
 
 
 
 
+
 }

+ 25 - 0
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/mapper/SaleClueDistributionInfoMapper.java

@@ -0,0 +1,25 @@
+package com.ruixuan.salesLeads.mapper;
+
+import com.ruixuan.salesLeads.pojo.SaleClueDistributionInfoPojo;
+import com.ruixuan.salesLeads.pojo.SaleQuotaInfoPojo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * ***************************************************
+ *
+ * @Auther: zianY
+ * @Descipion: 销售线索-分配记录信息表
+ * @CreateDate: 2022-05-31
+ * ****************************************************
+ */
+public interface SaleClueDistributionInfoMapper {
+
+
+    /**
+     * 新增销售线索 分配信息
+     * @param saleClueDistributionInfoPojo
+     */
+    void insertSaleClueDistribution(SaleClueDistributionInfoPojo saleClueDistributionInfoPojo);
+}

+ 33 - 2
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/mapper/SaleClueInfoMapper.java

@@ -30,7 +30,8 @@ public interface SaleClueInfoMapper {
      * @param distributionSaleFlag 是否分配销售 0-否 1-是
      * @param industryId 行业id
      * @param fansType 粉丝类别
-     * @param createUserId
+     * @param state 状态 1-未开始 2-进行中 3-已结束
+     * @param userId
      * @return
      */
     List<SaleClueInfoPojo> selectSaleClueInfoList(@Param(value = "sellerName") String sellerName,
@@ -38,5 +39,35 @@ public interface SaleClueInfoMapper {
                                                   @Param(value = "distributionSaleFlag") String distributionSaleFlag,
                                                   @Param(value = "industryId") String industryId,
                                                   @Param(value = "fansType") String fansType,
-                                                  @Param(value = "createUserId") Long createUserId);
+                                                  @Param(value = "state") String state,
+                                                  @Param(value = "userId") Long userId);
+
+
+    /**
+     * 根据卖家ids 查询销售线索
+     * @param sellerIds 卖家id
+     * @return
+     */
+     List<SaleClueInfoPojo> selectSaleClueInfoBySellers(@Param(value = "sellerIds") List<Long> sellerIds);
+
+    /**
+     * 修改销售线索 销售人员
+     * @param sellerId  卖家id
+     * @param saleId 销售id
+     * @param distributionSaleFlag 是否分配销售 0-否 1-是
+     * @return
+     */
+     void updateSaleClueSale(@Param(value = "sellerId") Long sellerId, @Param(value = "saleId") Long saleId, @Param(value = "distributionSaleFlag") int distributionSaleFlag);
+
+    /**
+     * 修改销售线索 状态
+     * @param sellerId 卖家id
+     * @param state 进行状态 1-未开始 2-进行中 3-已结束
+     */
+     void updateSaleClueState(@Param(value = "sellerId") Long sellerId, @Param(value = "state") int state);
+
+
+
+
+
 }

+ 42 - 0
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/pojo/SaleClueDistributionInfoPojo.java

@@ -0,0 +1,42 @@
+package com.ruixuan.salesLeads.pojo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * ***************************************************
+ *
+ * @Auther: zianY
+ * @Descipion: 销售线索-分配记录信息表
+ * @CreateDate: 2022-05-31
+ * ****************************************************
+ */
+@Data
+@ApiModel(value = "saleClueDistributionInfoPojo", description = "销售线索-分配记录信息表")
+public class SaleClueDistributionInfoPojo {
+
+    private int id;
+
+    @ApiModelProperty("卖家id")
+    private Long sellerId;
+
+    @ApiModelProperty("'销售id'")
+    private Long saleId;
+
+
+    @ApiModelProperty("创建人")
+    private Long createUserId;
+
+    @ApiModelProperty("创建时间")
+    private String createTime;
+
+    public SaleClueDistributionInfoPojo() {
+    }
+
+    public SaleClueDistributionInfoPojo(Long sellerId, Long saleId, Long createUserId) {
+        this.sellerId = sellerId;
+        this.saleId = saleId;
+        this.createUserId = createUserId;
+    }
+}

+ 5 - 1
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/service/ISaleClueInfoService.java

@@ -21,5 +21,9 @@ public interface ISaleClueInfoService {
     ResultResponse importSaleExcelOrCsv(List<MultipartFile> files,int salesLeadsType,Long uploadDate,Long createUserId)throws Exception;
 
 
-    ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoList(String sellerName, Long uploadDate, String distributionSaleFlag, String industryId, String fansType, Long createUserId)throws Exception;
+    ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoList(String sellerName, Long uploadDate, String distributionSaleFlag, String industryId, String fansType,String state, Long userId)throws Exception;
+
+    ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoBySellers(List<Long> sellerIds);
+
+    ResultResponse saleClueDistribution(List<String> sellerIds, Long saleId,Long createUserId);
 }

+ 64 - 5
ruixuan-salesLeads/src/main/java/com.ruixuan.salesLeads/service/impl/SaleClueInfoServiceImpl.java

@@ -6,9 +6,11 @@ import com.ruixuan.common.utils.PageUtils;
 import com.ruixuan.common.utils.StringUtils;
 import com.ruixuan.common.utils.file.FileTypeUtils;
 import com.ruixuan.salesLeads.listener.ImportExcelListener;
+import com.ruixuan.salesLeads.mapper.SaleClueDistributionInfoMapper;
 import com.ruixuan.salesLeads.mapper.SaleClueInfoMapper;
 import com.ruixuan.salesLeads.mapper.SaleClueRecordInfoMapper;
 import com.ruixuan.salesLeads.mapper.SaleQuotaInfoMapper;
+import com.ruixuan.salesLeads.pojo.SaleClueDistributionInfoPojo;
 import com.ruixuan.salesLeads.pojo.SaleClueInfoPojo;
 import com.ruixuan.salesLeads.pojo.SaleQuotaInfoPojo;
 import com.ruixuan.salesLeads.service.ISaleClueInfoService;
@@ -52,6 +54,15 @@ public class SaleClueInfoServiceImpl implements ISaleClueInfoService {
     @Autowired
     private SysAreaInfoMapper sysAreaInfoMapper;
 
+    @Autowired
+    private SaleClueRecordInfoMapper saleClueRecordInfoMapper;
+
+
+    @Autowired
+    private SaleClueDistributionInfoMapper saleClueDistributionInfoMapper;
+
+
+
 
 
 
@@ -151,24 +162,72 @@ public class SaleClueInfoServiceImpl implements ISaleClueInfoService {
 
 
 
-    @Autowired
-    private SaleClueRecordInfoMapper saleClueRecordInfoMapper;
 
+    /**
+     *
+     * @description: 销售线索列表查询
+     *
+     * @param sellerName 卖家昵称
+     * @param uploadDate 年月
+     * @param distributionSaleFlag 是否分配销售 0-否 1-是
+     * @param industryId 行业id
+     * @param fansType 粉丝量级 1:0~50w 2:50W~200W 3:200W~500W 4:500W以上
+     * @param createUserId
+     * @return: com.ruixuan.common.core.domain.ResultResponse<java.util.List<com.ruixuan.salesLeads.pojo.SaleClueInfoPojo>>
+     * @author: zianY
+     */
     @Override
-    public ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoList(String sellerName, Long uploadDate, String distributionSaleFlag, String industryId, String fansType, Long createUserId) throws Exception {
+    public ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoList(String sellerName, Long uploadDate, String distributionSaleFlag, String industryId, String fansType, String state,Long userId) throws Exception {
 
         PageUtils.startPage();
-        List<SaleClueInfoPojo> saleList =  saleClueInfoMapper.selectSaleClueInfoList(sellerName,uploadDate,distributionSaleFlag,industryId,fansType, createUserId);
+        List<SaleClueInfoPojo> saleList =  saleClueInfoMapper.selectSaleClueInfoList(sellerName,uploadDate,distributionSaleFlag,industryId,fansType,state, userId);
         saleList.forEach(clue ->{
             clue.setFirstRecord(saleClueRecordInfoMapper.getSaleClueRecordNumber(clue.getSellerId(),1));
             clue.setSecondRecord(saleClueRecordInfoMapper.getSaleClueRecordNumber(clue.getSellerId(),2));
         });
+        return ResultResponse.successMsg("查询成功。",saleList);
+    }
 
 
 
+    /**
+     *
+     * @description:
+     *
+     * @param sellerIds 卖家id
+     * @return: com.ruixuan.common.core.domain.ResultResponse<java.util.List<com.ruixuan.salesLeads.pojo.SaleClueInfoPojo>>
+     * @author: zianY
+     */
+    @Override
+    public ResultResponse<List<SaleClueInfoPojo>> selectSaleClueInfoBySellers(List<Long> sellerIds){
+        List<SaleClueInfoPojo> saleList =  saleClueInfoMapper.selectSaleClueInfoBySellers(sellerIds);
+        return ResultResponse.successMsg("查询成功。",saleList);
+    }
 
 
-        return ResultResponse.successMsg("查询成功。",saleList);
+    /**
+     *
+     * @description: 销售线索-分配
+     *
+     * @param sellerIds 卖家ids
+     * @param saleId 销售id
+     * @param createUserId
+     * @return: com.ruixuan.common.core.domain.ResultResponse
+     * @author: zianY
+     */
+    @Override
+    public ResultResponse saleClueDistribution(List<String> sellerIds, Long saleId,Long createUserId){
+
+         sellerIds.forEach(sellerId -> {
+             //修改销售线索 销售
+             saleClueInfoMapper.updateSaleClueSale(Long.valueOf(sellerId),saleId,1);
+             // 修改线索 状态
+             saleClueInfoMapper.updateSaleClueState(Long.valueOf(sellerId),2);
+             //添加 分配记录
+             saleClueDistributionInfoMapper.insertSaleClueDistribution(new SaleClueDistributionInfoPojo(Long.valueOf(sellerId),saleId,createUserId));
+         });
+
+        return ResultResponse.successMsg("分配销售成功。",null);
     }
 
 

+ 29 - 0
ruixuan-salesLeads/src/main/resources/mapper/salesLeads/SaleClueDistributionInfoMapper.xml

@@ -0,0 +1,29 @@
+<?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.ruixuan.salesLeads.mapper.SaleClueDistributionInfoMapper">
+
+
+	
+
+
+<!-- 新增销售线索 分配信息-->
+	<insert id="insertSaleClueDistribution">
+		insert into sale_clue_distribution_info(
+		seller_id,
+		sale_id,
+		create_user_id,
+		create_time)
+		values
+			(
+			#{sellerId},
+			#{saleId},
+			#{createUserId},
+			NOW()
+			)
+	</insert>
+
+
+
+</mapper> 

+ 64 - 0
ruixuan-salesLeads/src/main/resources/mapper/salesLeads/SaleClueInfoMapper.xml

@@ -48,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		</foreach>
 	</insert>
 
+	<!-- 销售线索列表信息 -->
 	<select id="selectSaleClueInfoList" resultType="com.ruixuan.salesLeads.pojo.SaleClueInfoPojo">
 		SELECT
 			s.id,
@@ -87,6 +88,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 			<if test="industryId !=null and industryId != ''">
 				and s.industry_id = #{industryId}
 			</if>
+			<if test="state !=null and state != ''">
+				and s.state = #{state}
+			</if>
+			<if test="userId !=null and userId != ''">
+				and s.update_user_id = #{userId}
+			</if>
 			<if test="fansType == '1'.toString()">
 				and s.fans BETWEEN 0 AND 500000
 			</if>
@@ -110,6 +117,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 	</select>
 
+	<!-- 根据卖家ids 查询销售线索 -->
+	<select id="selectSaleClueInfoBySellers" resultType="com.ruixuan.salesLeads.pojo.SaleClueInfoPojo">
+		SELECT
+			s.id,
+			s.sales_leads_type,
+			s.seller_id,
+			s.seller_name,
+			s.fans,
+			s.industry_id,
+			s.province_id,
+			s.city_id,
+			s.telephone,
+			s.provider_flag,
+			s.transition_flag,
+			s.upload_date,
+			s.distribution_sale_flag,
+			s.sale_id,
+			s.state,
+			s.offline_sale_flag,
+			s.create_user_id,
+			s.create_time
+		FROM
+			sale_clue_info s
+		<where>
+			<if test="sellerIds != null and sellerIds.size() != 0 ">
+				and s.seller_id in
+				<foreach collection="sellerIds" item="item" separator=","
+						 open="(" close=")">
+					#{item}
+				</foreach>
+			</if>
+		</where>
+	</select>
+
+
+
+	<!--  修改销售线索 销售人员 -->
+	<update id="updateSaleClueSale">
+		UPDATE sale_clue_info
+		SET
+		    distribution_sale_flag = #{distributionSaleFlag},
+			sale_id = #{saleId}
+			WHERE
+				seller_id = #{sellerId}
+	</update>
+
+
+
+	<!--  修改销售线索 状态 -->
+	<update id="updateSaleClueState">
+		UPDATE sale_clue_info
+		SET
+			state = #{state}
+			WHERE
+				seller_id = #{sellerId}
+	</update>
+