Преглед изворни кода

销售订单维度统计、通话统计字段、导出字段更新

yjwang пре 1 недеља
родитељ
комит
9297d6da15

+ 57 - 0
fs-admin/src/main/java/com/fs/store/controller/FsStoreOrderController.java

@@ -31,6 +31,7 @@ import com.fs.store.param.*;
 import com.fs.store.service.*;
 import com.fs.store.vo.*;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -40,6 +41,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -578,4 +580,59 @@ public class FsStoreOrderController extends BaseController {
         FsStoreOrder order=fsStoreOrderService.selectFsStoreOrderByOrderCode(orderCode);
         return fsStoreOrderService.createOmsOrder(order.getId());
     }
+
+    /**
+     * 订单维度分页查询接口
+     * @param param 查询条件
+     * @return AjaxResult
+     * **/
+    @GetMapping("/orderDimensionStatisticsList")
+    public TableDataInfo orderDimensionStatisticsList(OrderStatisticsParam param){
+        return getDataTable(fsStoreOrderService.selectOrderDimensionStatisticsList(param));
+    }
+
+    /**
+     * 导出订单维度统计接口
+     * @param param 查询条件
+     * @return AjaxResult
+     * **/
+    @Log(title = "订单维度统计", businessType = BusinessType.EXPORT)
+    @GetMapping("/orderDimensionStatisticsExport")
+    public AjaxResult orderDimensionStatisticsExport(OrderStatisticsParam param){
+        List<OrderStatisticsVo> list = fsStoreOrderService.selectOrderDimensionStatisticsList(param);
+//        switch (param.getGroupType()){
+//            case 2:
+//                List<OrderCateStatisticsVo> cateStatisticsVoList = convertTo(list,OrderCateStatisticsVo.class);
+//                ExcelUtil<OrderCateStatisticsVo> cateUtil = new ExcelUtil<>(OrderCateStatisticsVo.class);
+//                return cateUtil.exportExcel(cateStatisticsVoList, "订单标签维度统计");
+//            case 3:
+//                List<OrderProductStatisticsVo> productStatisticsVoList =  convertTo(list,OrderProductStatisticsVo.class);
+//                ExcelUtil<OrderProductStatisticsVo> productUtil = new ExcelUtil<>(OrderProductStatisticsVo.class);
+//                return productUtil.exportExcel(productStatisticsVoList, "订单商品维度统计");
+//        }
+
+        ExcelUtil<OrderStatisticsVo> util = new ExcelUtil<>(OrderStatisticsVo.class);
+        return util.exportExcel(list, "订单员工维度统计");
+    }
+
+    /**
+     * 对象列表类型转换
+     */
+    public static <T> List<T> convertTo(List<?> sourceList, Class<T> targetClass) {
+        if (sourceList == null || sourceList.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        List<T> resultList = new ArrayList<>(sourceList.size());
+        try {
+            for (Object source : sourceList) {
+                T target = targetClass.getDeclaredConstructor().newInstance();
+                BeanUtils.copyProperties(source, target);
+                resultList.add(target);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("数据转换异常", e);
+        }
+        return resultList;
+    }
 }

+ 9 - 1
fs-service-system/src/main/java/com/fs/company/mapper/CompanyVoiceLogsMapper.java

@@ -205,7 +205,15 @@ public interface CompanyVoiceLogsMapper
             "</script>"})
     Integer selectCompanyVoiceLogsCountByCallerMobile(@Param("mobile")String callerMobile,@Param("type")Integer type);
     @Select({"<script> " +
-            "select u.nick_name, count(l.company_user_id) as call_count,count(ifnull(l.times &gt; 0,null)) as call_success_count ,sum(l.times) as times,sum(l.billing_time) as billing_time from  company_voice_logs l left join company_user u on l.company_user_id=u.user_id  " +
+            "SELECT\n" +
+            "\tu.user_id,\n" +
+            "\tu.nick_name,\n" +
+            "\tcount(ifnull(l.`status`=4,null)) as call_success_count,\n" +
+            "\tSUM(CASE WHEN l.`status`=4 THEN l.times ELSE 0 END) call_success_item,\n" +
+            "\tcount(l.company_user_id) as call_count,\n" +
+            "\tSUM(IF(l.times,l.times,0)) as times,\n" +
+            "\tsum(IF(l.billing_time,l.billing_time,0)) as billing_time,\n" +
+            "\tSUM(IF(l.times,l.times,0)) as amount_item from  company_voice_logs l left join company_user u on l.company_user_id=u.user_id  " +
             "where 1=1 " +
             "<if test = 'maps.type != null and maps.type ==1 '> " +
             "and TO_DAYS(l.start_time) = TO_DAYS(NOW()) " +

+ 12 - 6
fs-service-system/src/main/java/com/fs/company/vo/CompanyVoiceLogsStatisticsVO.java

@@ -9,18 +9,24 @@ import java.util.Date;
 @Data
 public class CompanyVoiceLogsStatisticsVO implements Serializable
 {
-    @Excel(name = "员工姓名")
+    @Excel(name = "序号",sort = 0,width = 20)
+    Long userId;
+    @Excel(name = "员工姓名",sort = 1,width = 20)
     String nickName;
-    @Excel(name = "拔打数")
+    @Excel(name = "外呼电话数",sort = 4,width = 20)
     Integer callCount;
-    @Excel(name = "接通数")
+    @Excel(name = "接听电活数",sort = 2,width = 20)
     Integer callSuccessCount;
-    @Excel(name = "接通率")
+    @Excel(name = "接听总时长",sort = 3,width = 20)
+    Integer callSuccessItem;
+    @Excel(name = "接通率",sort = 6,width = 20)
     Double callRate;
-    @Excel(name = "通话时长")
+    @Excel(name = "外呼通话时长",sort = 5,width = 20)
     Integer times;
-    @Excel(name = "消耗分钟")
+    @Excel(name = "消耗分钟",sort = 7,width = 20)
     Integer billingTime;
+    @Excel(name = "合计时间长",sort = 8,width = 20)
+    Integer amountItem;
 
 
 

+ 15 - 0
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreOrderMapper.java

@@ -1040,4 +1040,19 @@ public interface FsStoreOrderMapper
     int selectFsStoreOrderCount(FsStoreOrderStatisticsParam param);
 
     BigDecimal selectFsStoreOrderByPayPriceCount(FsStoreOrderStatisticsParam param);
+
+    /**
+     * 订单维度分页查询接口
+     * @param param 查询条件
+     * @return List<OrderStatisticsVo>
+     * **/
+    List<OrderStatisticsVo> selectOrderDimensionStatisticsList(@Param("param") OrderStatisticsParam param);
+
+
+    /**
+     * 订单销售维度分页查询接口
+     * @param param 查询条件
+     * @return List<OrderStatisticsVo>
+     * **/
+    List<OrderStatisticsVo> selectOrderSaleStatisticsList(@Param("param") OrderStatisticsParam param);
 }

+ 63 - 0
fs-service-system/src/main/java/com/fs/store/param/OrderStatisticsParam.java

@@ -0,0 +1,63 @@
+package com.fs.store.param;
+
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.io.Serializable;
+import java.time.LocalDate;
+import java.util.Set;
+
+@Data
+public class OrderStatisticsParam implements Serializable {
+    /**
+     * 企业ID
+     **/
+    private Long companyId;
+
+    /**
+     * 员工账号
+     **/
+    private String userName;
+
+    /**
+     * 销售名称
+     **/
+    private String companyUser;
+
+    /**
+     * 商品名称
+     **/
+    private String productName;
+
+    /**
+     * 标签名称
+     **/
+    private String cateName;
+
+    /**
+     * 起始日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate startDate;
+
+    /**
+     * 结束日期
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate endDate;
+
+    /**
+     * 分组类型(1:员工、2:标签、3:商品)
+     **/
+    private Integer groupType;
+
+    /**
+     * 标签ID
+     * **/
+    private Long cateId;
+
+
+    /**
+     * 商品ID
+     * **/
+    private Long productId;
+}

+ 7 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStoreOrderService.java

@@ -226,4 +226,11 @@ public interface IFsStoreOrderService
      * @return
      */
     BigDecimal selectFsStoreOrderByPayPriceCount(FsStoreOrderStatisticsParam param);
+
+    /**
+     * 订单维度分页查询接口
+     * @param param 查询条件
+     * @return List<OrderStatisticsVo>
+     * **/
+    List<OrderStatisticsVo> selectOrderDimensionStatisticsList(OrderStatisticsParam param);
 }

+ 10 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -2651,4 +2651,14 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         }
         return erpOrderService;
     }
+
+    @Override
+    public List<OrderStatisticsVo> selectOrderDimensionStatisticsList(OrderStatisticsParam param) {
+        return fsStoreOrderMapper.selectOrderSaleStatisticsList(param);
+//        if(param.getGroupType()==1){
+//            return fsStoreOrderMapper.selectOrderSaleStatisticsList(param);
+//        }else {
+//            return fsStoreOrderMapper.selectOrderDimensionStatisticsList(param);
+//        }
+    }
 }

+ 31 - 0
fs-service-system/src/main/java/com/fs/store/vo/OrderCateStatisticsVo.java

@@ -0,0 +1,31 @@
+package com.fs.store.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+/**
+ * 订单维度统计实体
+ **/
+@Data
+public class OrderCateStatisticsVo implements Serializable {
+    /**
+     * 标签名称
+     **/
+    @Excel(name = "标签名称", sort = 4, width = 20)
+    private String cateName;
+
+    /**
+     * 订单数
+     **/
+    @Excel(name = "销售订单数量", sort = 5, width = 20)
+    private BigInteger orderNum;
+
+    /**
+     * 标签ID
+     * **/
+    @Excel(name = "标签编码", sort = 1, width = 20)
+    private Long cateId;
+}

+ 31 - 0
fs-service-system/src/main/java/com/fs/store/vo/OrderProductStatisticsVo.java

@@ -0,0 +1,31 @@
+package com.fs.store.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+
+/**
+ * 订单维度统计实体
+ **/
+@Data
+public class OrderProductStatisticsVo implements Serializable {
+    /**
+     * 商品名称
+     **/
+    @Excel(name = "商品名称", sort = 4, width = 20)
+    private String productName;
+
+    /**
+     * 订单数
+     **/
+    @Excel(name = "销售订单数量", sort = 5, width = 20)
+    private BigInteger orderNum;
+
+    /**
+     * 商品ID
+     * **/
+    @Excel(name = "商品编码", sort = 1, width = 20)
+    private Long productId;
+}

+ 150 - 0
fs-service-system/src/main/java/com/fs/store/vo/OrderStatisticsVo.java

@@ -0,0 +1,150 @@
+package com.fs.store.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+/**
+ * 订单维度统计实体
+ **/
+@Data
+public class OrderStatisticsVo implements Serializable {
+    /**
+     * 员工账号
+     **/
+    @Excel(name = "员工账号", sort = 1, width = 30)
+    private String userName;
+    /**
+     * 员工名称
+     **/
+    @Excel(name = "员工名称", sort = 2, width = 20)
+    private String nickName;
+
+    /**
+     * 企业名称
+     **/
+    @Excel(name = "企业名称", sort = 0, width = 20)
+    private String companyName;
+
+    /**
+     * 商品名称
+     **/
+    private String productName;
+
+    /**
+     * 标签名称
+     **/
+    private String cateName;
+
+    /**
+     * 订单数
+     **/
+    private BigInteger orderNum;
+
+    /**
+     * 用户ID
+     **/
+    private Long userId;
+
+    /**
+     * 商品ID
+     **/
+    private Long productId;
+
+    /**
+     * 标签ID
+     **/
+    private Long cateId;
+
+    /**
+     * 总单数
+     **/
+    @Excel(name = "总单数", sort = 6, width = 20)
+    private BigInteger totalNum;
+
+    /**
+     * 总金额
+     **/
+    @Excel(name = "总金额", sort = 7, width = 20)
+    private BigDecimal totalPrice;
+
+    /**
+     * 成交单数
+     **/
+    @Excel(name = "成交单数", sort = 8, width = 20)
+    private BigInteger dealNum;
+
+    /**
+     * 成交金额
+     **/
+    @Excel(name = "成交金额", sort = 9, width = 20)
+    private BigDecimal dealPrice;
+
+    /**
+     * 取消单数
+     **/
+    @Excel(name = "取消单数", sort = 10, width = 20)
+    private BigInteger cancelNum;
+
+    /**
+     * 取消金额
+     **/
+    @Excel(name = "取消金额", sort = 11, width = 20)
+    private BigDecimal cancelPrice;
+
+    /**
+     * 待发货单数
+     **/
+    @Excel(name = "待发货单数", sort = 12, width = 20)
+    private BigInteger pendingNum;
+
+    /**
+     * 待发货金额
+     **/
+    @Excel(name = "待发货金额", sort = 13, width = 20)
+    private BigDecimal pendingPrice;
+
+    /**
+     * 发货单数
+     **/
+    @Excel(name = "发货单数", sort = 14, width = 20)
+    private BigInteger invoiceNum;
+
+    /**
+     * 发货金额
+     **/
+    @Excel(name = "发货金额", sort = 15, width = 20)
+    private BigDecimal invoicePrice;
+
+    /**
+     * 签收单数
+     **/
+    @Excel(name = "签收单数", sort = 14, width = 20)
+    private BigInteger signForNum;
+
+    /**
+     * 签收金额
+     **/
+    @Excel(name = "签收金额", sort = 15, width = 20)
+    private BigDecimal signFPrice;
+
+    /**
+     * 退单数
+     **/
+    @Excel(name = "退单数", sort = 16, width = 20)
+    private BigInteger chargebackNum;
+
+    /**
+     * 退单金额
+     **/
+    @Excel(name = "退单金额", sort = 17, width = 20)
+    private BigDecimal chargebackPrice;
+
+    /**
+     * 企业ID
+     * **/
+    private Long companyId;
+}

+ 217 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreOrderMapper.xml

@@ -543,4 +543,221 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and company_user_id = #{companyUserId}
         </if>
     </select>
+
+    <select id="selectOrderDimensionStatisticsList" resultType="com.fs.store.vo.OrderStatisticsVo">
+        SELECT
+        <if test="param.groupType == 2">
+            fsp.cate_id,
+            fspc.cate_name,
+        </if>
+        <if test="param.groupType == 3">
+            fsoi.product_id,
+            fsp.product_name,
+        </if>
+        COUNT(*) orderNum
+        FROM
+        company_user cu
+        INNER JOIN company c ON cu.company_id = c.company_id
+        INNER JOIN fs_store_order fso ON cu.user_id = fso.company_user_id
+        INNER JOIN fs_store_order_item fsoi ON fso.id = fsoi.order_id
+        INNER JOIN fs_store_product fsp ON fsoi.product_id = fsp.product_id
+        INNER JOIN fs_store_product_category fspc ON fspc.cate_id = fsp.cate_id
+        WHERE
+        fso.is_del = '0'
+        AND fso.`status` > 1
+
+        <if test="param.companyId != null and param.companyId != ''">
+            AND  c.company_id = #{param.companyId}
+        </if>
+
+        <if test="param.userName != null and param.userName != ''">
+            AND cu.user_name Like CONCAT('%',#{param.userName},'%')
+        </if>
+
+        <if test="param.companyUser != null and param.companyUser != ''">
+            AND cu.nick_name Like CONCAT('%',#{param.companyUser},'%')
+        </if>
+
+        <if test="param.productName != null and param.productName != ''">
+            AND fsp.product_name Like CONCAT('%',#{param.productName},'%')
+        </if>
+
+        <if test="param.cateId != null and param.cateId != ''">
+            AND fspc.cate_id = #{param.cateId}
+        </if>
+
+        <if test="param.cateName != null and param.cateName != ''">
+            AND fspc.cate_name Like CONCAT('%',#{param.cateName},'%')
+        </if>
+
+        <if test="param.startDate != null">
+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') >= DATE_FORMAT(#{param.startDate},'%Y-%m')
+        </if>
+
+        <if test="param.endDate != null">
+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') &lt;= DATE_FORMAT(#{param.endDate},'%Y-%m')
+        </if>
+
+        GROUP BY
+
+        <if test="param.groupType == 2">
+            fsp.cate_id
+        </if>
+
+        <if test="param.groupType == 3">
+            fsoi.product_id
+        </if>
+        ORDER BY
+        cu.company_id DESC
+    </select>
+
+    <select id="selectOrderSaleStatisticsList" resultType="com.fs.store.vo.OrderStatisticsVo">
+      SELECT * FROM (  SELECT
+        cu.user_id,
+        cu.user_name,
+        cu.nick_name,
+        c.company_name,
+        c.company_id,
+        SUM(fso.`status` != 0) AS totalNum,
+        SUM(
+        CASE
+        WHEN fso.`status` != 0 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) totalPrice,
+        SUM(fso.`status` = 5) AS dealNum,
+        SUM(
+        CASE
+        WHEN fso.`status` = 5 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) AS dealPrice,
+        SUM(
+        fso.`status` = 1
+        OR fso.`status` = -2
+        ) AS cancelNum,
+        SUM(
+        CASE
+        WHEN fso.`status` = 1
+        OR fso.`status` = -2 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) AS cancelPrice,
+        SUM(
+        fso.`status` = 2
+        AND (
+        fso.delivery_pay_status = 0
+        OR fso.delivery_pay_status IS NULL
+        )
+        ) AS pendingNum,
+        SUM(
+        CASE
+        WHEN fso.`status` = 2
+        AND (
+        fso.delivery_pay_status = 0
+        OR fso.delivery_pay_status IS NULL
+        ) THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        )  AS pendingPrice,
+        SUM(
+        fso.`status` = 3
+        AND fso.delivery_pay_status > 0
+        ) AS invoiceNum,
+        SUM(
+        CASE
+        WHEN fso.`status` = 3
+        AND fso.delivery_pay_status > 0 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) AS invoicePrice,
+        IFNULL(
+        SUM(
+        fso.`status` > 3
+        AND fso.delivery_pay_status = 3
+        ),
+        0
+        ) AS signForNum,
+        SUM(
+        CASE
+        WHEN fso.`status` > 3
+        AND fso.delivery_pay_status = 3 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) AS signFPrice,
+        SUM(
+        fso.`status` = -1
+        AND fso.refund_status = 2
+        ) AS chargebackNum,
+        SUM(
+        CASE
+        WHEN fso.`status` = -1
+        AND fso.refund_status = 2 THEN
+        fso.total_price
+        ELSE
+        0
+        END
+        ) AS chargebackPrice
+        FROM
+        company_user cu
+        INNER JOIN company c ON cu.company_id = c.company_id
+        LEFT JOIN fs_store_order fso ON cu.user_id = fso.company_user_id
+        INNER JOIN fs_store_order_item fsoi ON fso.id = fsoi.order_id
+        INNER JOIN fs_store_product fsp ON fsoi.product_id = fsp.product_id
+        INNER JOIN fs_store_product_category fspc ON fspc.cate_id = fsp.cate_id
+        WHERE
+        fso.is_del = '0'
+        AND fso.`status` != 0
+        <if test="param.companyId != null and param.companyId != ''">
+            AND  c.company_id = #{param.companyId}
+        </if>
+
+        <if test="param.userName != null and param.userName != ''">
+            AND cu.user_name Like CONCAT('%',#{param.userName},'%')
+        </if>
+
+        <if test="param.companyUser != null and param.companyUser != ''">
+            AND cu.nick_name Like CONCAT('%',#{param.companyUser},'%')
+        </if>
+
+        <if test="param.productId != null and param.productId != ''">
+            AND fsp.product_id = #{param.productId}
+        </if>
+
+        <if test="param.productName != null and param.productName != ''">
+            AND fsp.product_name Like CONCAT('%',#{param.productName},'%')
+        </if>
+
+        <if test="param.cateName != null and param.cateName != ''">
+            AND fspc.cate_name Like CONCAT('%',#{param.cateName},'%')
+        </if>
+
+        <if test="param.cateId != null and param.cateId != ''">
+            AND fspc.cate_id = #{param.cateId}
+        </if>
+
+        <if test="param.startDate != null">
+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') >= DATE_FORMAT(#{param.startDate},'%Y-%m')
+        </if>
+
+        <if test="param.endDate != null">
+            AND DATE_FORMAT(fso.pay_time,'%Y-%m') &lt;= DATE_FORMAT(#{param.endDate},'%Y-%m')
+        </if>
+        GROUP BY
+        cu.user_id
+        ) a ORDER BY
+        a.company_id DESC,a.totalNum DESC
+    </select>
 </mapper>