|
|
@@ -852,16 +852,163 @@ ORDER BY
|
|
|
</select>
|
|
|
<select id="selSalesProfit" resultType="org.springblade.purchase.sales.vo.SalesDetailsVo">
|
|
|
SELECT
|
|
|
- BO.id AS orderId,
|
|
|
- BO.order_no as orderNo,
|
|
|
- BGD.Brand AS brand,
|
|
|
+ BO.id AS orderId,
|
|
|
+ BO.order_no AS orderNo,
|
|
|
+ BGD.Brand AS brand,
|
|
|
+ BCD.cname AS corpName,
|
|
|
+ BO.create_time AS careteTime,
|
|
|
+ BO.charge_member AS salesName,
|
|
|
+ BO.this_used_profit AS thisUsedProfit,
|
|
|
+ BO.gross_profit AS grossProfit,
|
|
|
+ BO.gross_profit_rate AS grossProfitRate,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BOI.amount AS amount,
|
|
|
+ BOI.purchaseAmount AS purchaseAmount,
|
|
|
+ BOI2.seventeenQuantity AS seventeenQuantity,
|
|
|
+ BOI2.seventeenAmount AS seventeenAmount,
|
|
|
+ BOI3.nonSpecialOfferQuantity AS nonSpecialOfferQuantity,
|
|
|
+ BOI3.nonSpecialOfferAmount AS nonSpecialOfferAmount,
|
|
|
+ BOI4.specialOfferQuantity AS specialOfferQuantity,
|
|
|
+ BOI4.specialOfferAmount AS specialOfferAmount,
|
|
|
+ (BOI.amount + BO.other_amount) AS totalAmount
|
|
|
+ FROM
|
|
|
+ business_order AS BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount,
|
|
|
+ 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 (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS seventeenQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS seventeenAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE size >= 17
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI2 ON BOI2.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS nonSpecialOfferQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS nonSpecialOfferAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE price_type IS NULL OR trim(price_type)=''
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI3 ON BOI3.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS specialOfferQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS specialOfferAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE trim(price_type) != ''
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI4 ON BOI4.pid = BO.id
|
|
|
+ LEFT JOIN basic_goods_desc BGD ON BOI.Item_id = BGD.id
|
|
|
+ LEFT JOIN business_order_fees BOF ON BOF.pid = BO.id
|
|
|
+ LEFT JOIN basic_corps_desc BCD ON BO.Corp_id = BCD.id
|
|
|
+ <where>
|
|
|
+ BOI.is_deleted = 0
|
|
|
+ AND BO.bill_type = 'XS'
|
|
|
+ AND BO.tenant_id = #{detailsVo.tenantId}
|
|
|
+ <if test="detailsVo.brand != null and detailsVo.brand != ''">
|
|
|
+ AND BGD.Brand like concat('%', #{detailsVo.brand}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="detailsVo.beginCreateTime !=null and detailsVo.beginCreateTime != ''">
|
|
|
+ and BO.create_time >= #{detailsVo.beginCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="detailsVo.endCreateTime !=null and detailsVo.endCreateTime != ''">
|
|
|
+ and BO.create_time <= #{detailsVo.endCreateTime}
|
|
|
+ </if>
|
|
|
+ <if test="detailsVo.salesName != null and detailsVo.salesName != ''">
|
|
|
+ AND BGD.charge_member like concat('%', #{detailsVo.salesName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="detailsVo.corpid != null and detailsVo.corpid != ''">
|
|
|
+ AND BO.corp_id like concat('%', #{detailsVo.corpid}, '%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ order by BO.create_time desc
|
|
|
+ </select>
|
|
|
+ <select id="selSalesProfitExport" resultType="org.springblade.purchase.sales.excel.SalesProfitExcel">
|
|
|
+ SELECT
|
|
|
+ BO.order_no AS orderNo,
|
|
|
BCD.cname AS corpName,
|
|
|
BO.create_time AS careteTime,
|
|
|
BO.charge_member AS salesName,
|
|
|
- BO.create_time AS careteTime,
|
|
|
- BOI.order_quantity AS quantity
|
|
|
- FROM business_order_items AS BOI
|
|
|
- LEFT JOIN business_order BO ON BOI.pid = BO.id
|
|
|
+ BO.this_used_profit AS thisUsedProfit,
|
|
|
+ BO.gross_profit AS grossProfit,
|
|
|
+ BO.gross_profit_rate AS grossProfitRate,
|
|
|
+ BOI.quantity AS quantity,
|
|
|
+ BOI.amount AS amount,
|
|
|
+ BOI.purchaseAmount AS purchaseAmount,
|
|
|
+ BOI2.seventeenQuantity AS seventeenQuantity,
|
|
|
+ BOI2.seventeenAmount AS seventeenAmount,
|
|
|
+ BOI3.nonSpecialOfferQuantity AS nonSpecialOfferQuantity,
|
|
|
+ BOI3.nonSpecialOfferAmount AS nonSpecialOfferAmount,
|
|
|
+ BOI4.specialOfferQuantity AS specialOfferQuantity,
|
|
|
+ BOI4.specialOfferAmount AS specialOfferAmount,
|
|
|
+ (BOI.amount + BO.other_amount) AS totalAmount
|
|
|
+ FROM
|
|
|
+ business_order AS BO
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ item_id,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS amount,
|
|
|
+ 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 (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS seventeenQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS seventeenAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE size >= 17
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI2 ON BOI2.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS nonSpecialOfferQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS nonSpecialOfferAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE price_type IS NULL OR trim(price_type)=''
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI3 ON BOI3.pid = BO.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ pid,
|
|
|
+ IFNULL( SUM( order_quantity ), 0 ) AS specialOfferQuantity,
|
|
|
+ IFNULL( SUM( amount ), 0 ) AS specialOfferAmount
|
|
|
+ FROM
|
|
|
+ business_order_items
|
|
|
+ WHERE trim(price_type) != ''
|
|
|
+ GROUP BY
|
|
|
+ pid
|
|
|
+ ) BOI4 ON BOI4.pid = BO.id
|
|
|
LEFT JOIN basic_goods_desc BGD ON BOI.Item_id = BGD.id
|
|
|
LEFT JOIN business_order_fees BOF ON BOF.pid = BO.id
|
|
|
LEFT JOIN basic_corps_desc BCD ON BO.Corp_id = BCD.id
|
|
|
@@ -878,9 +1025,16 @@ ORDER BY
|
|
|
<if test="detailsVo.endCreateTime !=null and detailsVo.endCreateTime != ''">
|
|
|
and BO.create_time <= #{detailsVo.endCreateTime}
|
|
|
</if>
|
|
|
+ <if test="detailsVo.salesName != null and detailsVo.salesName != ''">
|
|
|
+ AND BGD.charge_member like concat('%', #{detailsVo.salesName}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="detailsVo.corpid != null and detailsVo.corpid != ''">
|
|
|
+ AND BO.corp_id like concat('%', #{detailsVo.corpid}, '%')
|
|
|
+ </if>
|
|
|
</where>
|
|
|
order by BO.create_time desc
|
|
|
</select>
|
|
|
+
|
|
|
<update id="updateOrderMessage" parameterType="org.springblade.purchase.sales.entity.Order">
|
|
|
update business_order
|
|
|
<trim prefix="SET" suffixOverrides=",">
|