|
@@ -8,7 +8,8 @@
|
|
|
<select id="getSumInfo" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
|
|
|
round((t.totalFee - tt.totalFee) / tt.totalFee * 100, 2) AS 'totalFeeRate',
|
|
|
- t.*,ttt.*
|
|
|
+ t.*,ttt.*,ifnull(tttt.costPrice,0) as 'costPrice',
|
|
|
+ ifnull(round(ttt.estimatedIncome - tttt.costPrice,3 ) , 0) as 'estimatedGrossProfit'
|
|
|
FROM (
|
|
|
SELECT COUNT(t1.oid) AS 'orderNum',
|
|
|
IFNULL(SUM(CASE WHEN t1.status != 80 AND t1.status != 10 THEN 1 ELSE 0 END), 0) AS 'validOrderNum',
|
|
@@ -115,7 +116,16 @@
|
|
|
</foreach>
|
|
|
</if>
|
|
|
|
|
|
- ) ttt
|
|
|
+ ) ttt join
|
|
|
+ (
|
|
|
+ select sum(cost_price) as 'costPrice'
|
|
|
+ from kwaixiaodian_cost_detail_end
|
|
|
+ where send_time >= #{start}
|
|
|
+ AND send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ )tttt
|
|
|
</select>
|
|
|
<select id="getMonthInfo" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
SELECT round((t.orderNum - tt.orderNum) / tt.orderNum * 100, 2) AS 'orderNumRate',
|
|
@@ -810,4 +820,131 @@
|
|
|
order by t1.orderNum desc
|
|
|
|
|
|
</select>
|
|
|
+ <select id="getCostTotal" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select
|
|
|
+ ifnull(t1.income, 0) as 'income',
|
|
|
+ ifnull(round((t1.income - t2.income) / t2.income * 100, 2) , 0) as 'incomeRate',
|
|
|
+ ifnull(t3.costPrice, 0) as 'costPrice',
|
|
|
+ ifnull(round((t3.costPrice - t4.costPrice) / t4.costPrice * 100, 2), 0) as 'costPriceRate',
|
|
|
+ ifnull(t5.purchaseCost , 0) as 'purchaseCost',
|
|
|
+ ifnull(round((t5.purchaseCost - t6.purchaseCost) / t6.purchaseCost * 100, 2), 0) as 'purchaseCostRate'
|
|
|
+ from (select round(
|
|
|
+ sum(total_fee) / 100, 2
|
|
|
+ ) as 'income'
|
|
|
+ from kwaixiaodian_order_cursor_list
|
|
|
+ where send_time >= #{start}
|
|
|
+ and send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and status in (40, 50, 70) ) t1
|
|
|
+ join (
|
|
|
+ select round(
|
|
|
+ sum(total_fee) / 100, 2
|
|
|
+ ) as 'income'
|
|
|
+ from kwaixiaodian_order_cursor_list
|
|
|
+ where send_time >= #{lastStart}
|
|
|
+ and send_time <= #{lastEnd}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and status in (40, 50, 70) ) t2
|
|
|
+ join (
|
|
|
+ select round(sum(cost_price), 2) as 'costPrice'
|
|
|
+ from kwaixiaodian_cost_detail_end
|
|
|
+ where send_time >= #{start}
|
|
|
+ and send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ ) t3
|
|
|
+ join (select round(sum(cost_price), 2) as 'costPrice'
|
|
|
+ from kwaixiaodian_cost_detail_end
|
|
|
+ where send_time >= #{lastStart}
|
|
|
+ and send_time <= #{lastEnd}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>) t4
|
|
|
+ join (
|
|
|
+ select round(sum(t2.price * t2.qty), 2) as 'purchaseCost'
|
|
|
+ from kwaixiaodian_jst_purchase t1
|
|
|
+ left join kwaixiaodian_jst_purchase_items t2
|
|
|
+ on t1.po_id = t2.po_id
|
|
|
+ where t1.po_date >= concat(date_format(#{start}, '%Y-%m-%d'), '00:00:01')
|
|
|
+ and t1.po_date <= concat(date_format(#{end}, '%Y-%m-%d'), '23:59:59')
|
|
|
+ and t1.status in ('Confirmed', 'Finished')) t5
|
|
|
+
|
|
|
+
|
|
|
+ join (select round(sum(t2.price * t2.qty), 2) as 'purchaseCost'
|
|
|
+ from kwaixiaodian_jst_purchase t1
|
|
|
+ left join kwaixiaodian_jst_purchase_items t2
|
|
|
+ on t1.po_id = t2.po_id
|
|
|
+ where t1.po_date >=str_to_date(concat(date_format( #{lastStart}, '%Y-%m-%d'), '00:00:01'), '%Y-%m-%d
|
|
|
+ %H:%i:%s')
|
|
|
+ and t1.po_date <=str_to_date(concat(date_format( #{lastEnd}, '%Y-%m-%d'), '23:59:59'), '%Y-%m-%d
|
|
|
+ %H:%i:%s')
|
|
|
+ and t1.status in ('Confirmed', 'Finished')) t6
|
|
|
+
|
|
|
+ </select>
|
|
|
+ <select id="getCostDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select send_time as 'sendTime',
|
|
|
+ round(sum(total_fee) / 100, 2) as 'totalFee'
|
|
|
+ from kwaixiaodian_order_cursor_list
|
|
|
+ where send_time >= #{start}
|
|
|
+ and send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and status in(40,50,70)
|
|
|
+ group by send_time
|
|
|
+ order by send_time
|
|
|
+ </select>
|
|
|
+ <select id="getItemCostList" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
+ select count(t.oid) as 'orderNum',
|
|
|
+ t.itemId,
|
|
|
+ t.itemTitle,
|
|
|
+ t.itemPicUrl,
|
|
|
+ round(sum(t.totalFee) / 100, 2) as 'totalFee',
|
|
|
+ round(sum(t.costPrice), 2) as 'costPrice',
|
|
|
+ tt.user_name as 'userName',
|
|
|
+ tt.courtship_purchase_name as 'courtshipPurchaseName',
|
|
|
+ (
|
|
|
+ CASE when tt.item_type = 1
|
|
|
+ then '自选品'
|
|
|
+ when tt.item_type = 2
|
|
|
+ then '推品'
|
|
|
+ else '-'
|
|
|
+ end
|
|
|
+ ) as 'itemType'
|
|
|
+ from (select t1.oid as 'oid',
|
|
|
+ t1.item_id as 'itemId',
|
|
|
+ t1.item_pic_url as 'itemPicUrl',
|
|
|
+ t1.item_title as 'itemTitle',
|
|
|
+ t2.costPrice as 'costPrice',
|
|
|
+ t1.total_fee as 'totalFee'
|
|
|
+
|
|
|
+ from kwaixiaodian_order_cursor_list t1
|
|
|
+ left join (select oid as 'oid',
|
|
|
+ sum(cost_price) as 'costPrice',
|
|
|
+ group_concat(distinct sku_id) as 'skuId',
|
|
|
+ group_concat(distinct po_id) as 'poId'
|
|
|
+ from kwaixiaodian_cost_detail_end
|
|
|
+ where send_time >= #{start}
|
|
|
+ and send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ group by oid) t2
|
|
|
+ on t1.oid = t2.oid
|
|
|
+ where t1.send_time >= #{start}
|
|
|
+ and t1.send_time <= #{end}
|
|
|
+ <if test='companyId != null and companyId != ""'>
|
|
|
+ and t1.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ and t1.status in (40, 50, 70)) t
|
|
|
+ left join kwaixiaodian_item_get tt
|
|
|
+ on t.itemId = tt.item_id
|
|
|
+ group by t.itemId
|
|
|
+ order by count(t.oid) desc
|
|
|
+ </select>
|
|
|
</mapper>
|