|
|
@@ -1372,12 +1372,18 @@ ORDER BY
|
|
|
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 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.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1413,12 +1419,18 @@ ORDER BY
|
|
|
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 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.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1452,12 +1464,18 @@ ORDER BY
|
|
|
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 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.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1491,13 +1509,16 @@ ORDER BY
|
|
|
and BO.is_deleted = 0
|
|
|
and BO.bill_type = 'XS'
|
|
|
<if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
- and BGD.brand in #{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 statisticsVo.chargeMember != ''">
|
|
|
- BO.charge_member in #{statisticsVo.chargeMember}
|
|
|
- </if>
|
|
|
- <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
|
|
|
- and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
+ <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.endTime !=null and statisticsVo.endTime != ''">
|
|
|
and BO.actual_delivery_date <= #{statisticsVo.endTime}
|
|
|
@@ -1536,9 +1557,12 @@ ORDER BY
|
|
|
and BO.is_deleted = 0
|
|
|
and BO.bill_type = 'XS'
|
|
|
<if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
- and BGD.brand in #{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 order.beginTime != ''">
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1578,9 +1602,12 @@ ORDER BY
|
|
|
and BO.is_deleted = 0
|
|
|
and BO.bill_type = 'XS'
|
|
|
<if test="statisticsVo.brand != null and statisticsVo.brand != ''">
|
|
|
- and BGD.brand in #{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 order.beginTime != ''">
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1614,15 +1641,19 @@ ORDER BY
|
|
|
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}
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
</if>
|
|
|
- <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1656,15 +1687,19 @@ ORDER BY
|
|
|
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}
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
</if>
|
|
|
- <if test="statisticsVo.beginTime !=null and order.beginTime != ''">
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
</if>
|
|
|
<if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
@@ -1674,6 +1709,643 @@ 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,
|
|
|
+ SUM( BO.debit_amount ) AS amount,
|
|
|
+ SUM( BOI.purchaseAmount ) AS purchaseAmount,
|
|
|
+ SUM( BOI.quantity ) AS quantity,
|
|
|
+ SUM( BO.this_used_profit ) AS thisUsedProfit,
|
|
|
+ (SUM( BO.debit_amount ) / SUM( BOI.quantity )) AS price,
|
|
|
+ (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BOI.quantity ) AS singleGrossProfit,
|
|
|
+ SUM( BO.predict_ocean_freight ) AS predictOceanFreight,
|
|
|
+ SUM( BO.gross_profit ) - SUM( BO.this_used_profit ) AS netGrossProfit,
|
|
|
+ SUM( BO.gross_profit ) AS grossProfit,
|
|
|
+ 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
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ BGD.brand
|
|
|
+ ORDER BY
|
|
|
+ quantity DESC
|
|
|
+ </select>
|
|
|
+ <select id="brandProfitExport" resultType="org.springblade.purchase.sales.excel.BrandProfitExcel">
|
|
|
+ SELECT
|
|
|
+ BGD.brand AS brand,
|
|
|
+ SUM( BO.debit_amount ) AS amount,
|
|
|
+ SUM( BOI.purchaseAmount ) AS purchaseAmount,
|
|
|
+ SUM( BOI.quantity ) AS quantity,
|
|
|
+ SUM( BO.this_used_profit ) AS thisUsedProfit,
|
|
|
+ (SUM( BO.debit_amount ) / SUM( BOI.quantity )) AS price,
|
|
|
+ (SUM( BO.debit_amount ) - SUM( BOI.purchaseAmount )) / SUM( BOI.quantity ) AS singleGrossProfit,
|
|
|
+ SUM( BO.predict_ocean_freight ) AS predictOceanFreight,
|
|
|
+ SUM( BO.gross_profit ) - SUM( BO.this_used_profit ) AS netGrossProfit,
|
|
|
+ SUM( BO.gross_profit ) AS grossProfit,
|
|
|
+ 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
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY BGD.brand
|
|
|
+ ORDER BY quantity DESC
|
|
|
+ </select>
|
|
|
+ <select id="specificationsProfit" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ @rank := @rank + 1 AS rankNo,
|
|
|
+ temp.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ BGD.CODE AS code,
|
|
|
+ BGD.Typeno AS typeNo,
|
|
|
+ BGD.brand AS brand,
|
|
|
+ BGD.brand_item AS brandItem,
|
|
|
+ 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,
|
|
|
+ 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
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.chargeMember != null and statisticsVo.chargeMember != ''">
|
|
|
+ BO.charge_member in #{statisticsVo.chargeMember}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ BGD.Typeno
|
|
|
+ ORDER BY
|
|
|
+ quantity DESC
|
|
|
+ ) temp,
|
|
|
+ ( SELECT @rank := 0 ) b
|
|
|
+ </select>
|
|
|
+ <select id="specificationsProfitExport" resultType="org.springblade.purchase.sales.excel.SpecificationsProfitExcel">
|
|
|
+ SELECT
|
|
|
+ @rank := @rank + 1 AS rankNo,
|
|
|
+ temp.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ BGD.CODE AS code,
|
|
|
+ BGD.Typeno AS typeNo,
|
|
|
+ BGD.brand AS brand,
|
|
|
+ BGD.brand_item AS brandItem,
|
|
|
+ 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,
|
|
|
+ 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
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.chargeMember != null and statisticsVo.chargeMember != ''">
|
|
|
+ BO.charge_member in #{statisticsVo.chargeMember}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
+ and BO.actual_delivery_date >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{statisticsVo.endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ BGD.Typeno
|
|
|
+ ORDER BY
|
|
|
+ quantity DESC
|
|
|
+ ) temp,
|
|
|
+ ( SELECT @rank := 0 ) b
|
|
|
+ </select>
|
|
|
+ <select id="totalSummary" resultType="org.springblade.purchase.sales.vo.TotalSummaryVo">
|
|
|
+ SELECT
|
|
|
+ BGD.Brand AS brand,
|
|
|
+ SUM( BOI1.quantity ) AS quantity1,
|
|
|
+ SUM( BOI1.amount ) AS amount1,
|
|
|
+ SUM( BOI2.quantity ) AS quantity2,
|
|
|
+ SUM( BOI2.amount ) AS amount2,
|
|
|
+ SUM( BOI3.quantity ) AS quantity3,
|
|
|
+ SUM( BOI3.amount ) AS amount3,
|
|
|
+ SUM( BOI4.quantity ) AS quantity4,
|
|
|
+ SUM( BOI4.amount ) AS amount4,
|
|
|
+ SUM( BOI5.quantity ) AS quantity5,
|
|
|
+ SUM( BOI5.amount ) AS amount5,
|
|
|
+ SUM( BOI6.quantity ) AS quantity6,
|
|
|
+ SUM( BOI6.amount ) AS amount6,
|
|
|
+ SUM( BOI7.quantity ) AS quantity7,
|
|
|
+ SUM( BOI7.amount ) AS amount7,
|
|
|
+ SUM( BOI8.quantity ) AS quantity8,
|
|
|
+ SUM( BOI8.amount ) AS amount8,
|
|
|
+ SUM( BOI9.quantity ) AS quantity9,
|
|
|
+ SUM( BOI9.amount ) AS amount9,
|
|
|
+ SUM( BOI10.quantity ) AS quantity10,
|
|
|
+ SUM( BOI10.amount ) AS amount10,
|
|
|
+ SUM( BOI11.quantity ) AS quantity11,
|
|
|
+ SUM( BOI11.amount ) AS amount11,
|
|
|
+ SUM( BOI12.quantity ) AS quantity12,
|
|
|
+ SUM( BOI12.amount ) AS amount12
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 1
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI1 ON BOI1.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 2
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI2 ON BOI2.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 3
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI3 ON BOI3.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 4
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI4 ON BOI4.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 5
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI5 ON BOI5.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 6
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI6 ON BOI6.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 7
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI7 ON BOI7.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 8
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI8 ON BOI8.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 9
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI9 ON BOI9.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 10
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI10 ON BOI10.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 11
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI11 ON BOI11.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 12
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI12 ON BOI12.pid = BO.id
|
|
|
+ LEFT JOIN basic_goods_desc BGD ON BOI1.Item_id = BGD.id
|
|
|
+ OR BOI2.Item_id = BGD.id
|
|
|
+ OR BOI3.Item_id = BGD.id
|
|
|
+ OR BOI4.Item_id = BGD.id
|
|
|
+ OR BOI5.Item_id = BGD.id
|
|
|
+ OR BOI6.Item_id = BGD.id
|
|
|
+ OR BOI7.Item_id = BGD.id
|
|
|
+ OR BOI8.Item_id = BGD.id
|
|
|
+ OR BOI9.Item_id = BGD.id
|
|
|
+ OR BOI10.Item_id = BGD.id
|
|
|
+ OR BOI11.Item_id = BGD.id
|
|
|
+ OR BOI12.Item_id = BGD.id
|
|
|
+ <where>
|
|
|
+ BO.tenant_id = #{totalSummaryVo.tenantId}
|
|
|
+ and BO.is_deleted = 0
|
|
|
+ and BO.bill_type = 'XS'
|
|
|
+ <if test="totalSummaryVo.brand != null and totalSummaryVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="totalSummaryVo.year !=null and totalSummaryVo.year != ''">
|
|
|
+ AND YEAR ( BO.create_time ) = #{totalSummaryVo.year}
|
|
|
+ </if>
|
|
|
+ <if test="totalSummaryVo.status != null and totalSummaryVo.status != '' and totalSummaryVo.status = '0'">
|
|
|
+ AND BO.create_deliver not in (#{totalSummaryVo.status})
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ BGD.Brand
|
|
|
+ </select>
|
|
|
+ <select id="totalSummaryExport" resultType="org.springblade.purchase.sales.excel.TotalSummaryExcel">
|
|
|
+ SELECT
|
|
|
+ BGD.Brand AS brand,
|
|
|
+ SUM( BOI1.quantity ) AS quantity1,
|
|
|
+ SUM( BOI1.amount ) AS amount1,
|
|
|
+ SUM( BOI2.quantity ) AS quantity2,
|
|
|
+ SUM( BOI2.amount ) AS amount2,
|
|
|
+ SUM( BOI3.quantity ) AS quantity3,
|
|
|
+ SUM( BOI3.amount ) AS amount3,
|
|
|
+ SUM( BOI4.quantity ) AS quantity4,
|
|
|
+ SUM( BOI4.amount ) AS amount4,
|
|
|
+ SUM( BOI5.quantity ) AS quantity5,
|
|
|
+ SUM( BOI5.amount ) AS amount5,
|
|
|
+ SUM( BOI6.quantity ) AS quantity6,
|
|
|
+ SUM( BOI6.amount ) AS amount6,
|
|
|
+ SUM( BOI7.quantity ) AS quantity7,
|
|
|
+ SUM( BOI7.amount ) AS amount7,
|
|
|
+ SUM( BOI8.quantity ) AS quantity8,
|
|
|
+ SUM( BOI8.amount ) AS amount8,
|
|
|
+ SUM( BOI9.quantity ) AS quantity9,
|
|
|
+ SUM( BOI9.amount ) AS amount9,
|
|
|
+ SUM( BOI10.quantity ) AS quantity10,
|
|
|
+ SUM( BOI10.amount ) AS amount10,
|
|
|
+ SUM( BOI11.quantity ) AS quantity11,
|
|
|
+ SUM( BOI11.amount ) AS amount11,
|
|
|
+ SUM( BOI12.quantity ) AS quantity12,
|
|
|
+ SUM( BOI12.amount ) AS amount12
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 1
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI1 ON BOI1.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 2
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI2 ON BOI2.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 3
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI3 ON BOI3.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 4
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI4 ON BOI4.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 5
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI5 ON BOI5.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 6
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI6 ON BOI6.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 7
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI7 ON BOI7.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 8
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI8 ON BOI8.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 9
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI9 ON BOI9.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 10
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI10 ON BOI10.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 11
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI11 ON BOI11.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE
|
|
|
+ MONTH ( create_time ) = 12
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI12 ON BOI12.pid = BO.id
|
|
|
+ LEFT JOIN basic_goods_desc BGD ON BOI1.Item_id = BGD.id
|
|
|
+ OR BOI2.Item_id = BGD.id
|
|
|
+ OR BOI3.Item_id = BGD.id
|
|
|
+ OR BOI4.Item_id = BGD.id
|
|
|
+ OR BOI5.Item_id = BGD.id
|
|
|
+ OR BOI6.Item_id = BGD.id
|
|
|
+ OR BOI7.Item_id = BGD.id
|
|
|
+ OR BOI8.Item_id = BGD.id
|
|
|
+ OR BOI9.Item_id = BGD.id
|
|
|
+ OR BOI10.Item_id = BGD.id
|
|
|
+ OR BOI11.Item_id = BGD.id
|
|
|
+ OR BOI12.Item_id = BGD.id
|
|
|
+ <where>
|
|
|
+ BO.tenant_id = #{totalSummaryVo.tenantId}
|
|
|
+ and BO.is_deleted = 0
|
|
|
+ and BO.bill_type = 'XS'
|
|
|
+ <if test="totalSummaryVo.brand != null and totalSummaryVo.brand != ''">
|
|
|
+ and BGD.brand in
|
|
|
+ <foreach item="item" index="index" collection="brand.split(',')" open="(" separator="," close=")">
|
|
|
+ '${item}'
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="totalSummaryVo.year !=null and totalSummaryVo.year != ''">
|
|
|
+ AND YEAR ( BO.create_time ) = #{totalSummaryVo.year}
|
|
|
+ </if>
|
|
|
+ <if test="totalSummaryVo.status != null and totalSummaryVo.status != '' and totalSummaryVo.status = '0'">
|
|
|
+ AND BO.create_deliver not in (#{totalSummaryVo.status})
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ BGD.Brand
|
|
|
+ </select>
|
|
|
<update id="updateOrderMessage" parameterType="org.springblade.purchase.sales.entity.Order">
|
|
|
update business_order
|
|
|
<trim prefix="SET" suffixOverrides=",">
|