|
|
@@ -1678,6 +1678,7 @@ ORDER BY
|
|
|
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,
|
|
|
@@ -1731,6 +1732,61 @@ ORDER BY
|
|
|
GROUP BY BO.charge_member
|
|
|
order by quantity desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="salesmanProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ BO.create_time as createTime,
|
|
|
+ BO.order_no as orderNo,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BO.debit_amount AS amount,
|
|
|
+ BOI.actualQuantity AS actualQuantity,
|
|
|
+ BOI.arrivalAmount AS arrivalAmount,
|
|
|
+ BO.this_used_profit AS thisUsedProfit,
|
|
|
+ BO.gross_profit AS netGrossProfit,
|
|
|
+ BO.predict_ocean_freight AS predictOceanFreight
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( sum( actual_quantity ), 0 ) AS actualQuantity,
|
|
|
+ IFNULL( SUM( actual_quantity * price ), 0 ) AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ is_deleted = 0
|
|
|
+ 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'
|
|
|
+ AND BO.receipt_time IS NOT NULL
|
|
|
+ <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.chargeMember != null and statisticsVo.chargeMember != ''">
|
|
|
+ and BO.charge_member in
|
|
|
+ <foreach item="member" index="index" collection="chargeMember.split(',')" open="(" separator="," close=")">
|
|
|
+ '${member}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.receipt_time >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.receipt_time <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="salesmanProfitExport" resultType="org.springblade.purchase.sales.excel.SalesmanProfitExcel">
|
|
|
SELECT
|
|
|
BO.charge_member as chargeMember,
|
|
|
@@ -1784,6 +1840,7 @@ ORDER BY
|
|
|
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,
|
|
|
@@ -1835,6 +1892,59 @@ ORDER BY
|
|
|
GROUP BY BCD.cname
|
|
|
order by quantity desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="customerProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ BO.create_time as createTime,
|
|
|
+ BO.order_no as orderNo,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BO.debit_amount AS amount,
|
|
|
+ BOI.actualQuantity AS actualQuantity,
|
|
|
+ BOI.arrivalAmount AS arrivalAmount,
|
|
|
+ BO.this_used_profit AS thisUsedProfit,
|
|
|
+ BO.gross_profit AS netGrossProfit,
|
|
|
+ BO.predict_ocean_freight AS predictOceanFreight
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( sum( actual_quantity ), 0 ) AS actualQuantity,
|
|
|
+ IFNULL( SUM( actual_quantity * price ), 0 ) AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ is_deleted = 0
|
|
|
+ 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'
|
|
|
+ AND BO.receipt_time IS NOT NULL
|
|
|
+ <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.corpName != null and statisticsVo.corpName != ''">
|
|
|
+ AND BCD.cname like concat('%', #{statisticsVo.corpName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.receipt_time >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.receipt_time <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="customerProfitExport" resultType="org.springblade.purchase.sales.excel.CustomerProfitExcel">
|
|
|
SELECT
|
|
|
BCD.cname AS corpName,
|
|
|
@@ -1886,6 +1996,7 @@ ORDER BY
|
|
|
GROUP BY BCD.cname
|
|
|
order by quantity desc
|
|
|
</select>
|
|
|
+
|
|
|
<select id="brandProfit" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
SELECT
|
|
|
BGD.brand AS brand,
|
|
|
@@ -1937,6 +2048,55 @@ ORDER BY
|
|
|
ORDER BY
|
|
|
quantity DESC
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="brandProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ BO.create_time as createTime,
|
|
|
+ BO.order_no as orderNo,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BO.debit_amount AS amount,
|
|
|
+ BOI.actualQuantity AS actualQuantity,
|
|
|
+ BOI.arrivalAmount AS arrivalAmount,
|
|
|
+ BO.this_used_profit AS thisUsedProfit,
|
|
|
+ BO.gross_profit AS netGrossProfit,
|
|
|
+ BO.predict_ocean_freight AS predictOceanFreight
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( sum( actual_quantity ), 0 ) AS actualQuantity,
|
|
|
+ IFNULL( SUM( actual_quantity * price ), 0 ) AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ is_deleted = 0
|
|
|
+ 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'
|
|
|
+ AND BO.receipt_time IS NOT NULL
|
|
|
+ <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.receipt_time >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.receipt_time <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="brandProfitExport" resultType="org.springblade.purchase.sales.excel.BrandProfitExcel">
|
|
|
SELECT
|
|
|
BGD.brand AS brand,
|
|
|
@@ -2195,6 +2355,7 @@ ORDER BY
|
|
|
) temp,
|
|
|
( SELECT @rank := 0 ) b
|
|
|
</select>
|
|
|
+
|
|
|
<select id="totalSummary" resultType="org.springblade.purchase.sales.vo.TotalSummaryVo">
|
|
|
SELECT
|
|
|
BGD.Brand AS brand,
|
|
|
@@ -2581,6 +2742,56 @@ ORDER BY
|
|
|
GROUP BY
|
|
|
BGD.Brand
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="totalSummaryItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ BO.create_time as createTime,
|
|
|
+ BO.order_no as orderNo,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BO.debit_amount AS amount,
|
|
|
+ BOI.actualQuantity AS actualQuantity,
|
|
|
+ BOI.arrivalAmount AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( sum( actual_quantity ), 0 ) AS actualQuantity,
|
|
|
+ IFNULL( SUM( actual_quantity * price ), 0 ) AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ is_deleted = 0
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI ON BOI.pid = BO.id
|
|
|
+ LEFT JOIN basic_goods_desc BGD ON BOI.Item_id = BGD.id
|
|
|
+ <where>
|
|
|
+ BO.tenant_id = #{totalSummaryVo.tenantId}
|
|
|
+ and BO.is_deleted = 0
|
|
|
+ and BO.bill_type = 'XS'
|
|
|
+ and BGD.Brand is not null
|
|
|
+ <if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.year !=null and statisticsVo.year != ''">
|
|
|
+ AND YEAR ( BO.create_time ) = #{statisticsVo.year}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.month !=null and statisticsVo.month != ''">
|
|
|
+ AND IF
|
|
|
+ ( BO.receipt_time IS NOT NULL, MONTH ( BO.receipt_time ) = #{statisticsVo.month}, MONTH ( BO.create_time ) = #{statisticsVo.month} )
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.status != null and statisticsVo.status != '' and statisticsVo.status == 0">
|
|
|
+ AND BO.receipt_time IS NOT NULL
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="totalSummaryExport" resultType="org.springblade.purchase.sales.excel.TotalSummaryExcel">
|
|
|
SELECT
|
|
|
BGD.Brand AS brand,
|