|
|
@@ -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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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 >= #{statisticsVo.beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.endTime !=null and statisticsVo.endTime != ''">
|
|
|
+ and BO.actual_delivery_date <= #{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=",">
|