|
|
@@ -1400,7 +1400,7 @@ ORDER BY
|
|
|
AND BCD.belongtoarea like concat('%', #{statisticsVo.belongtoarea}, '%')
|
|
|
</if>
|
|
|
<if test="statisticsVo.corpName != null and statisticsVo.corpName != ''">
|
|
|
- AND BCD.cname like concat('%', #{statisticsVo.corpName}, '%')
|
|
|
+ AND BCD.cname = #{statisticsVo.corpName}
|
|
|
</if>
|
|
|
<if test="statisticsVo.beginTime !=null and statisticsVo.beginTime != ''">
|
|
|
and BO.receipt_time >= #{statisticsVo.beginTime}
|
|
|
@@ -1412,6 +1412,65 @@ ORDER BY
|
|
|
GROUP BY BCD.cname
|
|
|
order by quantity desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="corpStatisticsItem" 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_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.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.belongtoarea != null and statisticsVo.belongtoarea != ''">
|
|
|
+ AND BCD.belongtoarea like concat('%', #{statisticsVo.belongtoarea}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.corpName != null and statisticsVo.corpName != ''">
|
|
|
+ AND BCD.cname = #{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="corpStatisticsExport" resultType="org.springblade.purchase.sales.excel.CorpStatisticsExcel">
|
|
|
SELECT
|
|
|
BCD.cname as corpName,
|
|
|
@@ -1468,6 +1527,7 @@ ORDER BY
|
|
|
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,
|
|
|
@@ -1516,6 +1576,60 @@ ORDER BY
|
|
|
GROUP BY BO.charge_member
|
|
|
order by quantity desc
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="salesmanStatisticsItem" 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.debit_amount - BOI.purchaseAmount AS grossProfit
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( sum( actual_quantity * purchase_amount ), 0 ) AS purchaseAmount,
|
|
|
+ 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="salesmanStatisticsExport" resultType="org.springblade.purchase.sales.excel.SalesmanStatisticsExcel">
|
|
|
SELECT
|
|
|
BO.charge_member as chargeMember,
|
|
|
@@ -1874,6 +1988,7 @@ ORDER BY
|
|
|
ORDER BY
|
|
|
quantity DESC
|
|
|
</select>
|
|
|
+
|
|
|
<select id="specificationsProfit" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
SELECT
|
|
|
@rank := @rank + 1 AS rankNo,
|
|
|
@@ -1945,6 +2060,70 @@ ORDER BY
|
|
|
) temp,
|
|
|
( SELECT @rank := 0 ) b
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="specificationsProfitItem" resultType="org.springblade.purchase.sales.vo.OrderStatisticsVo">
|
|
|
+ SELECT
|
|
|
+ BO.create_time as createTime,
|
|
|
+ BO.order_no as orderNo,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BOI.amount AS amount,
|
|
|
+ BOI.actualQuantity AS actualQuantity,
|
|
|
+ BOI.arrivalAmount AS arrivalAmount
|
|
|
+ FROM
|
|
|
+ business_order BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ id,
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( sum( order_quantity ), 0 ) AS quantity,
|
|
|
+ IFNULL( SUM( order_quantity * price ), 0 ) AS amount,
|
|
|
+ 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
|
|
|
+ id
|
|
|
+ ) 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.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.corpId != null and statisticsVo.corpId != ''">
|
|
|
+ and BO.corp_id = #{statisticsVo.corpId}
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.code != null and statisticsVo.code != ''">
|
|
|
+ AND BGD.CODE like concat('%', #{statisticsVo.code}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="statisticsVo.typeNo != null and statisticsVo.typeNo != ''">
|
|
|
+ AND BGD.Typeno like concat('%', #{statisticsVo.typeNo}, '%')
|
|
|
+ </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="specificationsProfitExport" resultType="org.springblade.purchase.sales.excel.SpecificationsProfitExcel">
|
|
|
SELECT
|
|
|
@rank := @rank + 1 AS rankNo,
|