Browse Source

2022年10月28 20:46

wangzhuo 3 years ago
parent
commit
cc17b813e6

+ 94 - 0
blade-service-api/blade-purchase-sales-api/src/main/java/org/springblade/purchase/sales/vo/OrderStatisticsVo.java

@@ -0,0 +1,94 @@
+package org.springblade.purchase.sales.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 统计分析 发货客户,业务员统计
+ *
+ * @author BladeX
+ * @since 2022-10-28
+ */
+
+@Data
+public class OrderStatisticsVo  implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 租户
+	 */
+	private String tenantId;
+
+	/**
+	 * 省份
+	 */
+	private String belongtoarea;
+
+	/**
+	 * 客户
+	 */
+	private String corpName;
+
+	/**
+	 * 业务员
+	 */
+	private String chargeMember;
+
+	/**
+	 * 发货数量
+	 */
+	private BigDecimal quantity;
+
+	/**
+	 * 销售收入
+	 */
+	private BigDecimal amount;
+
+	/**
+	 * 品牌
+	 */
+	private String brand;
+
+	/**
+	 * 毛利额
+	 */
+	private BigDecimal grossProfit;
+
+	/**
+	 * 销售成本
+	 */
+	private BigDecimal purchaseAmount;
+
+	/**
+	 * 返利
+	 */
+	private BigDecimal thisUsedProfit;
+
+	/**
+	 * 订单运费
+	 */
+	private BigDecimal predictOceanFreight;
+
+	/**
+	 * 净毛利额
+	 */
+	private BigDecimal netGrossProfit;
+
+	/**
+	 * 毛利率
+	 */
+	private BigDecimal grossProfitRate;
+
+	/**
+	 * 开始时间
+	 */
+	private String beginTime;
+
+	/**
+	 * 结束时间
+	 */
+	private String endTime;
+}

+ 53 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/CorpStatisticsExcel.java

@@ -0,0 +1,53 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 统计分析 发货客户统计导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class CorpStatisticsExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 省份
+	 */
+	@ExcelProperty(value = "省份")
+	private String belongtoarea;
+
+	/**
+	 * 客户
+	 */
+	@ExcelProperty(value = "客户")
+	private String corpName;
+
+	/**
+	 * 业务员
+	 */
+	@ExcelProperty(value = "业务员")
+	private String chargeMember;
+
+	/**
+	 * 发货数量
+	 */
+	@ExcelProperty(value = "发货数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 销售收入
+	 */
+	@ExcelProperty(value = "销售收入")
+	private BigDecimal amount;
+
+}

+ 76 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/CustomerProfitExcel.java

@@ -0,0 +1,76 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 统计分析 发货业务员统计导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class CustomerProfitExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 客户
+	 */
+	@ExcelProperty(value = "客户")
+	private String corpName;
+
+	/**
+	 * 销售收入
+	 */
+	@ExcelProperty(value = "销售收入")
+	private BigDecimal amount;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 销售成本
+	 */
+	@ExcelProperty(value = "销售成本")
+	private BigDecimal purchaseAmount;
+
+	/**
+	 * 返利
+	 */
+	@ExcelProperty(value = "返利")
+	private BigDecimal thisUsedProfit;
+
+	/**
+	 * 毛利额
+	 */
+	@ExcelProperty(value = "毛利额")
+	private BigDecimal grossProfit;
+
+	/**
+	 * 订单运费
+	 */
+	@ExcelProperty(value = "订单运费")
+	private BigDecimal predictOceanFreight;
+
+	/**
+	 * 净毛利额
+	 */
+	@ExcelProperty(value = "净毛利额")
+	private BigDecimal netGrossProfit;
+
+	/**
+	 * 毛利率
+	 */
+	@ExcelProperty(value = "毛利率")
+	private BigDecimal grossProfitRate;
+}

+ 76 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/SalesmanProfitExcel.java

@@ -0,0 +1,76 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 统计分析 业务员利润统计
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class SalesmanProfitExcel implements Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 业务员
+	 */
+	@ExcelProperty(value = "业务员")
+	private String chargeMember;
+
+	/**
+	 * 销售收入
+	 */
+	@ExcelProperty(value = "销售收入")
+	private BigDecimal amount;
+
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 销售成本
+	 */
+	@ExcelProperty(value = "销售成本")
+	private BigDecimal purchaseAmount;
+
+	/**
+	 * 返利
+	 */
+	@ExcelProperty(value = "返利")
+	private BigDecimal thisUsedProfit;
+
+	/**
+	 * 毛利额
+	 */
+	@ExcelProperty(value = "毛利额")
+	private BigDecimal grossProfit;
+
+	/**
+	 * 订单运费
+	 */
+	@ExcelProperty(value = "订单运费")
+	private BigDecimal predictOceanFreight;
+
+	/**
+	 * 净毛利额
+	 */
+	@ExcelProperty(value = "净毛利额")
+	private BigDecimal netGrossProfit;
+
+	/**
+	 * 毛利率
+	 */
+	@ExcelProperty(value = "毛利率")
+	private BigDecimal grossProfitRate;
+}

+ 45 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/excel/SalesmanStatisticsExcel.java

@@ -0,0 +1,45 @@
+package org.springblade.purchase.sales.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 统计分析 发货业务员统计导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class SalesmanStatisticsExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 业务员
+	 */
+	@ExcelProperty(value = "业务员")
+	private String chargeMember;
+
+	/**
+	 * 发货数量
+	 */
+	@ExcelProperty(value = "发货数量")
+	private BigDecimal quantity;
+
+	/**
+	 * 毛利额
+	 */
+	@ExcelProperty(value = "毛利额")
+	private BigDecimal grossProfit;
+
+	/**
+	 * 销售收入
+	 */
+	@ExcelProperty(value = "销售收入")
+	private BigDecimal amount;
+}

+ 89 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/export/ExportOrderController.java

@@ -976,4 +976,93 @@ public class ExportOrderController extends BladeController {
 		List<OrderDetailedExcel> list = orderService.orderDetailedExport(order);
 		ExcelUtil.export(response, "销售明细对账", "销售明细对账", list, OrderDetailedExcel.class);
 	}
+
+	/**
+	 * 统计分析 发货客户统计
+	 */
+	@GetMapping("/corpStatistics")
+	@ApiOperation(value = "发货客户统计", notes = "发货客户统计")
+	public R corpStatistics(OrderStatisticsVo statisticsVo, Query query){
+		statisticsVo.setTenantId(AuthUtil.getTenantId());
+		IPage<OrderStatisticsVo> pages = orderService.corpStatistics(Condition.getPage(query), statisticsVo);
+		return R.data(pages);
+	}
+
+	/**
+	 * 统计分析 发货客户统计导出
+	 */
+	@GetMapping("/corpStatisticsExport")
+	@ApiOperation(value = "发货客户统计导出", notes = "发货客户统计导出")
+	public void corpStatisticsExport(OrderStatisticsVo statisticsVo, HttpServletResponse response){
+		statisticsVo.setTenantId(SecureUtil.getTenantId());
+		List<CorpStatisticsExcel> list = orderService.corpStatisticsExport(statisticsVo);
+		ExcelUtil.export(response, "发货客户统计", "发货客户统计", list, CorpStatisticsExcel.class);
+	}
+
+	/**
+	 * 统计分析 发货业务员统计
+	 */
+	@GetMapping("/salesmanStatistics")
+	@ApiOperation(value = "发货业务员统计", notes = "发货业务员统计")
+	public R salesmanStatistics(OrderStatisticsVo statisticsVo, Query query){
+		statisticsVo.setTenantId(AuthUtil.getTenantId());
+		IPage<OrderStatisticsVo> pages = orderService.salesmanStatistics(Condition.getPage(query), statisticsVo);
+		return R.data(pages);
+	}
+
+	/**
+	 * 统计分析 发货业务员统计导出
+	 */
+	@GetMapping("/salesmanStatisticsExport")
+	@ApiOperation(value = "发货业务员统计导出", notes = "发货业务员统计导出")
+	public void salesmanStatisticsExport(OrderStatisticsVo statisticsVo, HttpServletResponse response){
+		statisticsVo.setTenantId(SecureUtil.getTenantId());
+		List<SalesmanStatisticsExcel> list = orderService.salesmanStatisticsExport(statisticsVo);
+		ExcelUtil.export(response, "发货业务员统计", "发货业务员统计", list, SalesmanStatisticsExcel.class);
+	}
+
+	/**
+	 * 统计分析 业务员利润统计
+	 */
+	@GetMapping("/salesmanProfit")
+	@ApiOperation(value = "业务员利润统计", notes = "业务员利润统计")
+	public R salesmanProfit(OrderStatisticsVo statisticsVo, Query query){
+		statisticsVo.setTenantId(AuthUtil.getTenantId());
+		IPage<OrderStatisticsVo> pages = orderService.salesmanProfit(Condition.getPage(query), statisticsVo);
+		return R.data(pages);
+	}
+
+	/**
+	 * 统计分析 业务员利润导出
+	 */
+	@GetMapping("/salesmanProfitExport")
+	@ApiOperation(value = "业务员利润导出", notes = "业务员利润导出")
+	public void salesmanProfitExport(OrderStatisticsVo statisticsVo, HttpServletResponse response){
+		statisticsVo.setTenantId(SecureUtil.getTenantId());
+		List<SalesmanProfitExcel> list = orderService.salesmanProfitExport(statisticsVo);
+		ExcelUtil.export(response, "业务员利润统计", "业务员利润统计", list, SalesmanProfitExcel.class);
+	}
+
+	/**
+	 * 统计分析 客户利润统计
+	 */
+	@GetMapping("/customerProfit")
+	@ApiOperation(value = "客户利润统计", notes = "客户利润统计")
+	public R customerProfit(OrderStatisticsVo statisticsVo, Query query){
+		statisticsVo.setTenantId(AuthUtil.getTenantId());
+		IPage<OrderStatisticsVo> pages = orderService.customerProfit(Condition.getPage(query), statisticsVo);
+		return R.data(pages);
+	}
+
+	/**
+	 * 统计分析 客户利润导出
+	 */
+	@GetMapping("/customerProfitExport")
+	@ApiOperation(value = "客户利润导出", notes = "客户利润导出")
+	public void customerProfitExport(OrderStatisticsVo statisticsVo, HttpServletResponse response){
+		statisticsVo.setTenantId(SecureUtil.getTenantId());
+		List<CustomerProfitExcel> list = orderService.customerProfitExport(statisticsVo);
+		ExcelUtil.export(response, "客户利润统计", "客户利润统计", list, CustomerProfitExcel.class);
+	}
+
 }

+ 15 - 10
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/feign/OrderDescClient.java

@@ -12,6 +12,7 @@ import org.apache.commons.lang.time.DateUtils;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tenant.annotation.NonDS;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.ObjectUtil;
 import org.springblade.purchase.sales.entity.Order;
 import org.springblade.purchase.sales.entity.OrderFiles;
 import org.springblade.purchase.sales.service.IOrderFilesService;
@@ -43,17 +44,21 @@ public class OrderDescClient implements IOrderDescClient {
 		}
 
 		if("681169".equals(AuthUtil.getTenantId())){
-			if (order.getDeliverQuantity().compareTo(BigDecimal.ZERO) == 0) {
-				iOrderService.update(null, new LambdaUpdateWrapper<Order>()
-					.set(Order::getDeliverTime, null)
-					.eq(Order::getId, order.getId())
-				);
+			if (ObjectUtil.isNotEmpty(order.getDeliverQuantity())){
+				if (order.getDeliverQuantity().compareTo(BigDecimal.ZERO) == 0) {
+					iOrderService.update(null, new LambdaUpdateWrapper<Order>()
+						.set(Order::getDeliverTime, null)
+						.eq(Order::getId, order.getId())
+					);
+				}
 			}
-			if (order.getReceiveQuantity().compareTo(BigDecimal.ZERO) == 0) {
-				iOrderService.update(null, new LambdaUpdateWrapper<Order>()
-					.set(Order::getReceiveTime, null)
-					.eq(Order::getId, order.getId())
-				);
+			if (ObjectUtil.isNotEmpty(order.getReceiveQuantity())){
+				if (order.getReceiveQuantity().compareTo(BigDecimal.ZERO) == 0) {
+					iOrderService.update(null, new LambdaUpdateWrapper<Order>()
+						.set(Order::getReceiveTime, null)
+						.eq(Order::getId, order.getId())
+					);
+				}
 			}
 		}
 		iOrderService.updateById(order);

+ 40 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.java

@@ -227,6 +227,46 @@ public interface OrderMapper extends BaseMapper<Order> {
 	 */
 	List<OrderDetailedExcel> orderDetailedExport(@Param("order") OrderReconciliationVo order);
 
+	/**
+	 * 发货客户统计
+	 */
+	List<OrderStatisticsVo> corpStatistics(IPage<OrderStatisticsVo> page,@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货客户统计导出
+	 */
+	List<CorpStatisticsExcel> corpStatisticsExport(@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货业务员统计
+	 */
+	List<OrderStatisticsVo> salesmanStatistics(IPage<OrderStatisticsVo> page,@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货客户统计导出
+	 */
+	List<SalesmanStatisticsExcel> salesmanStatisticsExport(@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 业务员利润统计
+	 */
+	List<OrderStatisticsVo> salesmanProfit(IPage<OrderStatisticsVo> page,@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 业务员利润导出
+	 */
+	List<SalesmanProfitExcel> salesmanProfitExport(@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 客户利润统计
+	 */
+	List<OrderStatisticsVo> customerProfit(IPage<OrderStatisticsVo> page,@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 客户利润导出
+	 */
+	List<CustomerProfitExcel> customerProfitExport(@Param("statisticsVo") OrderStatisticsVo statisticsVo);
+
 	int updateStockGoods(StockGoods stockGoods);
 
 	BigDecimal arrears(@Param("tenantId") String tenantId,

+ 329 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/mapper/OrderMapper.xml

@@ -1345,6 +1345,335 @@ ORDER BY
         </where>
         order by BO.create_time desc
     </select>
+    <select id="corpStatistics" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
+        SELECT
+            BCD.cname as corpName,
+            SUBSTRING_INDEX(BCD.belongtoarea,'/',1) AS belongtoarea,
+            GROUP_CONCAT(DISTINCT BO.charge_member Order BY BCD.cname ASC ) as chargeMember,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BO.debit_amount) AS amount,
+            BGD.brand AS brand
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity
+            FROM
+                business_order_items
+            GROUP BY
+                pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_corps_desc BCD ON BCD.id = BO.corp_id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.chargeMember != null statisticsVo.chargeMember != ''">
+                BO.charge_member in #{statisticsVo.chargeMember}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BCD.cname
+        order by quantity desc
+    </select>
+    <select id="corpStatisticsExport" resultType="org.springblade.purchase.sales.excel.CorpStatisticsExcel">
+        SELECT
+            BCD.cname as corpName,
+            SUBSTRING_INDEX(BCD.belongtoarea,'/',1) AS belongtoarea,
+            GROUP_CONCAT(DISTINCT BO.charge_member Order BY BCD.cname ASC ) as chargeMember,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BO.debit_amount) AS amount
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_corps_desc BCD ON BCD.id = BO.corp_id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.chargeMember != null statisticsVo.chargeMember != ''">
+                BO.charge_member in #{statisticsVo.chargeMember}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BCD.cname
+        order by quantity desc
+    </select>
+    <select id="salesmanStatistics" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
+        SELECT
+            BO.charge_member as chargeMember,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.debit_amount) AS amount
+        FROM
+        business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.chargeMember != null statisticsVo.chargeMember != ''">
+                BO.charge_member in #{statisticsVo.chargeMember}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BO.charge_member
+        order by quantity desc
+    </select>
+    <select id="salesmanStatisticsExport" resultType="org.springblade.purchase.sales.excel.SalesmanStatisticsExcel">
+        SELECT
+            BO.charge_member as chargeMember,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.debit_amount) AS amount
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.chargeMember != null statisticsVo.chargeMember != ''">
+                BO.charge_member in #{statisticsVo.chargeMember}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BO.charge_member
+        order by quantity desc
+    </select>
+    <select id="salesmanProfit" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
+        SELECT
+            BO.charge_member as chargeMember,
+            SUM(BO.debit_amount) AS amount,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BOI.purchaseAmount) AS purchaseAmount,
+            SUM(BO.this_used_profit) AS thisUsedProfit,
+            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.predict_ocean_freight) AS predictOceanFreight,
+            SUM(BO.gross_profit) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
+            SUM(BO.gross_profit_rate) AS grossProfitRate
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity,
+                IFNULL( SUM( purchase_amount ), 0 ) AS purchaseAmount
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BO.charge_member
+        order by quantity desc
+    </select>
+    <select id="salesmanProfitExport" resultType="org.springblade.purchase.sales.excel.SalesmanProfitExcel">
+        SELECT
+            BO.charge_member as chargeMember,
+            SUM(BO.debit_amount) AS amount,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BOI.purchaseAmount) AS purchaseAmount,
+            SUM(BO.this_used_profit) AS thisUsedProfit,
+            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.predict_ocean_freight) AS predictOceanFreight,
+            SUM(BO.gross_profit) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
+            SUM(BO.gross_profit_rate) AS grossProfitRate
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity,
+                IFNULL( SUM( purchase_amount ), 0 ) AS purchaseAmount
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BO.charge_member
+        order by quantity desc
+    </select>
+    <select id="customerProfit" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
+        SELECT
+        BCD.cname as corpName,
+        SUM(BO.debit_amount) AS amount,
+        SUM(BOI.quantity) AS quantity,
+        SUM(BOI.purchaseAmount) AS purchaseAmount,
+        SUM(BO.this_used_profit) AS thisUsedProfit,
+        SUM(BO.gross_profit) AS grossProfit,
+        SUM(BO.predict_ocean_freight) AS predictOceanFreight,
+        SUM(BO.debit_amount) - SUM(BOI.purchaseAmount) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
+        SUM(BO.gross_profit_rate) AS grossProfitRate
+        FROM
+        business_order BO
+        LEFT JOIN (
+        SELECT
+        pid,
+        item_id,
+        IFNULL( SUM( actual_quantity ), 0 ) AS quantity,
+        IFNULL( SUM( purchase_amount ), 0 ) AS purchaseAmount
+        FROM
+        business_order_items
+        GROUP BY
+        pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BCD.cname
+        order by quantity desc
+    </select>
+    <select id="customerProfitExport" resultType="org.springblade.purchase.sales.excel.CustomerProfitExcel">
+        SELECT
+            BCD.cname as corpName,
+            SUM(BO.debit_amount) AS amount,
+            SUM(BOI.quantity) AS quantity,
+            SUM(BOI.purchaseAmount) AS purchaseAmount,
+            SUM(BO.this_used_profit) AS thisUsedProfit,
+            SUM(BO.gross_profit) AS grossProfit,
+            SUM(BO.predict_ocean_freight) AS predictOceanFreight,
+            SUM(BO.debit_amount) - SUM(BOI.purchaseAmount) - SUM(BO.predict_ocean_freight) AS netGrossProfit,
+            SUM(BO.gross_profit_rate) AS grossProfitRate
+        FROM
+            business_order BO
+        LEFT JOIN (
+            SELECT
+                pid,
+                item_id,
+                IFNULL( SUM( actual_quantity ), 0 ) AS quantity,
+                IFNULL( SUM( purchase_amount ), 0 ) AS purchaseAmount
+            FROM
+                business_order_items
+            GROUP BY
+            pid
+        ) BOI ON BOI.pid = BO.id
+        LEFT JOIN basic_goods_desc BGD ON BGD.id = BOI.item_id
+        <where>
+            BO.tenant_id = #{statisticsVo.tenantId}
+            and BO.is_deleted = 0
+            and BO.bill_type = 'XS'
+            <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
+                and BGD.brand in #{statisticsVo.brand}
+            </if>
+            <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
+                and BO.actual_delivery_date &gt;= #{statisticsVo.beginTime}
+            </if>
+            <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
+                and BO.actual_delivery_date &lt;= #{statisticsVo.endTime}
+            </if>
+        </where>
+        GROUP BY BCD.cname
+        order by quantity desc
+    </select>
     <update id="updateOrderMessage" parameterType="org.springblade.purchase.sales.entity.Order">
         update  business_order
         <trim prefix="SET" suffixOverrides=",">

+ 40 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/IOrderService.java

@@ -264,6 +264,46 @@ public interface IOrderService extends IService<Order> {
 	List<OrderDetailedExcel> orderDetailedExport(OrderReconciliationVo order);
 
 	/**
+	 * 发货客户统计
+	 */
+	IPage<OrderStatisticsVo> corpStatistics(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货客户统计导出
+	 */
+	List<CorpStatisticsExcel> corpStatisticsExport(OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货业务员统计
+	 */
+	IPage<OrderStatisticsVo> salesmanStatistics(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 发货业务员统计导出
+	 */
+	List<SalesmanStatisticsExcel> salesmanStatisticsExport(OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 业务员利润统计
+	 */
+	IPage<OrderStatisticsVo> salesmanProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 业务员利润导出
+	 */
+	List<SalesmanProfitExcel> salesmanProfitExport(OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 客户利润统计
+	 */
+	IPage<OrderStatisticsVo> customerProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo);
+
+	/**
+	 * 客户利润导出
+	 */
+	List<CustomerProfitExcel> customerProfitExport(OrderStatisticsVo statisticsVo);
+
+	/**
 	 * 计算国内费用
 	 */
 	Map<String,Object> calculationDomesticFees(Order order);

+ 64 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/OrderServiceImpl.java

@@ -1674,6 +1674,70 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 	}
 
 	/**
+	 * 发货客户统计
+	 */
+	@Override
+	public IPage<OrderStatisticsVo> corpStatistics(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo){
+		return page.setRecords(baseMapper.corpStatistics(page, statisticsVo));
+	}
+
+	/**
+	 * 发货客户统计导出
+	 */
+	@Override
+	public List<CorpStatisticsExcel> corpStatisticsExport(OrderStatisticsVo statisticsVo){
+		return baseMapper.corpStatisticsExport(statisticsVo);
+	}
+
+	/**
+	 * 发货业务员统计
+	 */
+	@Override
+	public IPage<OrderStatisticsVo> salesmanStatistics(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo){
+		return page.setRecords(baseMapper.salesmanStatistics(page, statisticsVo));
+	}
+
+	/**
+	 * 发货业务员统计导出
+	 */
+	@Override
+	public List<SalesmanStatisticsExcel> salesmanStatisticsExport(OrderStatisticsVo statisticsVo){
+		return baseMapper.salesmanStatisticsExport(statisticsVo);
+	}
+
+	/**
+	 * 业务员利润统计
+	 */
+	@Override
+	public IPage<OrderStatisticsVo> salesmanProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo){
+		return page.setRecords(baseMapper.salesmanProfit(page, statisticsVo));
+	}
+
+	/**
+	 * 业务员利润导出
+	 */
+	@Override
+	public List<SalesmanProfitExcel> salesmanProfitExport(OrderStatisticsVo statisticsVo){
+		return baseMapper.salesmanProfitExport(statisticsVo);
+	}
+
+	/**
+	 * 客户利润统计
+	 */
+	@Override
+	public IPage<OrderStatisticsVo> customerProfit(IPage<OrderStatisticsVo> page, OrderStatisticsVo statisticsVo){
+		return page.setRecords(baseMapper.customerProfit(page, statisticsVo));
+	}
+
+	/**
+	 * 客户利润导出
+	 */
+	@Override
+	public List<CustomerProfitExcel> customerProfitExport(OrderStatisticsVo statisticsVo){
+		return baseMapper.customerProfitExport(statisticsVo);
+	}
+
+	/**
 	 * 计算国内费用
 	 *
 	 * @param order