insert into kuaishou_item_bind_user(item_id, user_id, user_name)
value
(#{itemId},#{userId},#{nikeName})
delete
from kuaishou_item_bind_user
where item_id = #{itemId}
select *
from (
select promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end),4) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
and promoter_id = #{promoterId}
and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
group by promoter_id) t
order by t.orderNum desc
select *
from
(select item_id as 'itemId',
item_title as 'itemTitle',
image_url as 'imageUrl',
count(oid) as 'orderNum'
from kuaishou_supply_chain
where promoter_id = #{promoterId}
and order_create_time >= #{start}
and order_create_time <= #{end}
group by item_id) t
order by t.orderNum desc limit 3
select *
from (select
item_title as 'itemTitle',
item_id as 'itemId',
reserve_price as 'reservePrice',
image_url 'imageUrl',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
regimental_promotion_rate as 'regimentalPromotionRate',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end),4) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and promoter_id = #{promoterId}
and order_create_time >= #{start}
and order_create_time <= #{end}
and item_id = #{itemId}
and item_title like concat(concat('%',#{itemTitle}),'%')
group by item_id) t
order by t.orderNum desc
select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
count(t.oid) as 'orderNum'
from (select oid,
order_create_time
from kuaishou_supply_chain
where 1 = 1
and promoter_id = #{promoterId}
and order_create_time >= #{start}
and order_create_time <= #{end}
) t
group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
select *
from (select t2.user_id as 'userId',
t2.user_name as 'userName',
t1.item_id as 'itemId',
t1.reserve_price as 'reservePrice',
t1.item_title as 'itemTitle',
t1.image_url as 'imageUrl',
count(t1.oid) as 'orderNum',
sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid), 4) as 'validRadio',
sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) / sum(case when
t1.order_status != 80 then 1 else 0 end), 4) as 'deliveryRadio',
t1.item_commission_rate as 'itemCommissionRate'
from kuaishou_supply_chain t1
left join kuaishou_item_bind_user t2
on t1.item_id = t2.item_id
where 1 = 1
and t1.order_create_time >= #{start}
and t1.order_create_time <= #{end}
and t1.item_id = #{itemId}
and t1.item_title like concat(concat('%',#{itemTitle}),'%')
group by t1.item_id) t
where 1 = 1
and t.userId = #{userId}
order by ${fieId} ${sort}
select
*
from
(select promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
count(oid) as 'orderNum'
from kuaishou_supply_chain
where item_id = #{itemId}
and order_create_time >= #{start}
and order_create_time <= #{end}
group by promoter_id) t
order by t.orderNum desc limit 3
select *
from (
select
promoter_nick_name as 'promoterNickName',
promoter_id as 'promoterId',
count(oid) as 'orderNum',
sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
regimental_promotion_rate as 'regimentalPromotionRate',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end),4) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and item_id = #{itemId}
and order_create_time >= #{start}
and order_create_time <= #{end}
and promoter_id = #{promoterId}
and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
group by promoter_id) t
order by t.orderNum desc
select *
from (
select
item_id as 'itemId',
item_title as 'itemTitle',
image_url as 'imageUrl',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end),4) as 'deliveryRadio',
sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
regimental_promotion_rate as 'regimentalPromotionRate',
sum(case when order_status != 80 then pay_amount else 0 end) as 'payAmount',
sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
'totalRegimentalSettleAmount',
item_commission_rate as 'itemCommissionRate'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
and item_id = #{itemId}
and item_title like concat(concat('%',#{itemTitle}),'%')
group by item_id) t
order by t.orderNum desc
select
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
sum(case when order_status = 80 then 1 else 0 end) as 'invalidOrderNUm'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
select
round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio'
from (select count(oid) as 'oid'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{nowStartHourTemp}
and order_create_time <= #{nowEndHourTemp}
) t1
join (select count(oid) as 'oid'
from kuaishou_supply_chain
where 1=1
and order_create_time >= #{yesterdayStartHourTemp}
and order_create_time <= #{yesterdayEndHourTemp}
) t2
select
sum(order_amount) as 'orderAmount',
sum(base_amount) as 'baseAmount',
sum(case when order_status != 80 then regimental_promotion_amount else 0 end) as 'regimentalPromotionAmount',
sum(case when order_status != 80 then total_regimental_settle_amount else 0 end) as
'totalRegimentalSettleAmount'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
select
round((t1.payAmount -t2.payAmount) / t2.payAmount , 4) as 'amountTotalRatio'
from (select sum(pay_amount) as 'payAmount'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{nowStartHourTemp}
and order_create_time <= #{nowEndHourTemp}
) t1
join (select sum(pay_amount) as 'payAmount'
from kuaishou_supply_chain
where 1=1
and order_create_time >= #{yesterdayStartHourTemp}
and order_create_time <= #{yesterdayEndHourTemp}
) t2
select
count(distinct promoter_id) as 'promoterNum',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
select
t1.*,
round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
from (select
item_id as 'itemId',
item_title as 'itemTitle',
image_url as 'imageUrl',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when send_status = 1 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 then 1 else 0 end) / sum(case when order_status != 80 then 1 else 0 end),4)
as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{nowStartHourTemp}
and order_create_time <= #{nowEndHourTemp}
group by item_id
) t1
left join (select
item_id as 'itemId',
count(oid) as 'orderNum'
from kuaishou_supply_chain
where 1=1
and order_create_time >= #{yesterdayStartHourTemp}
and order_create_time <= #{yesterdayEndHourTemp}
group by item_id
) t2 on t1.itemId = t2.itemId
order by t1.orderNum desc
select * from (
select
item_id as 'itemId',
item_title as 'itemTitle',
image_url as 'imageUrl',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end),4) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
group by item_id) t
order by t.orderNum desc
select
t1.*,
round((t1.orderNum - t2.orderNum) / t2.orderNum,4) as 'radio'
from (
select
promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
from kuaishou_supply_chain
where 1= 1
AND promoter_id IN
#{item}
and order_create_time >= #{nowStartHourTemp}
and order_create_time <= #{nowEndHourTemp}
group by promoter_id
) t1
left join (select
promoter_id as 'promoterId',
count(oid) as 'orderNum'
from kuaishou_supply_chain
where 1=1
AND promoter_id IN
#{item}
and order_create_time >= #{yesterdayStartHourTemp}
and order_create_time <= #{yesterdayEndHourTemp}
group by promoter_id
) t2 on t1.promoterId = t2.promoterId
order by t1.orderNum desc
select * from (
select
promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid),4) as 'validRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
group by promoter_id) t
order by t.orderNum desc
select *
from (
select
promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end) * 100,2) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
and promoter_id = #{promoterId}
and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
and item_id = #{itemId}
and item_title like concat(concat('%',#{itemTitle}),'%')
group by promoter_id) t
order by t.orderNum desc
select *
from (
select
promoter_id as 'promoterId',
promoter_nick_name as 'promoterNickName',
item_id as 'itemId',
item_title as 'itemTitle',
image_url as 'imageUrl',
count(oid) as 'orderNum',
sum(case when order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when order_status != 80 then 1 else 0 end) / count(oid) * 100,2) as 'validRadio',
sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when send_status = 0 and order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when order_status != 80
then 1 else 0 end) * 100,2) as 'deliveryRadio'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{start}
and order_create_time <= #{end}
and promoter_id = #{promoterId}
and promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
and item_id = #{itemId}
and item_title like concat(concat('%',#{itemTitle}),'%')
group by promoter_id,item_id) t
order by t.promoterId,t.orderNum desc
select *
from (select
t2.user_id as 'userId',
t2.user_name as 'userName',
t1.item_id as 'itemId',
t1.item_title as 'itemTitle',
t1.image_url as 'imageUrl',
count(t1.oid) as 'orderNum',
sum(case when t1.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when t1.order_status != 80 then 1 else 0 end) / count(t1.oid) * 100, 2) as 'validRadio',
sum(case when t1.send_status = 1 and t1.order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when t1.send_status = 0 and t1.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when t1.send_status = 1 and order_status != 80 then 1 else 0 end) / sum(case when t1.order_status
!= 80 then 1 else 0 end) * 100, 2) as 'deliveryRadio',
round(t1.item_commission_rate / 10,2) as 'itemCommissionRate'
from kuaishou_supply_chain t1
left join kuaishou_item_bind_user t2
on t1.item_id = t2.item_id
where 1 = 1
and t1.order_create_time >= #{start}
and t1.order_create_time <= #{end}
and t1.promoter_id = #{promoterId}
and t1.promoter_nick_name like concat(concat('%',#{promoterNickName}),'%')
and t1.item_id = #{itemId}
and t1.item_title like concat(concat('%',#{itemTitle}),'%')
group by t1.item_id) t
where 1 = 1
and t.userId = #{userId}
order by t.orderNum desc
select *
from (select t1.item_id as 'itemId',
t1.item_title as 'itemTitle',
t1.reserve_price as 'reservePrice',
t1.image_url as 'imageUrl',
t1.activity_id as 'activityId',
t1.regimental_promotion_rate as 'regimentalPromotionRate',
t2.user_id as 'userId',
case when t2.user_id is null then 1 else 2 end as 'status',
t2.user_name as 'userName',
t2.create_time as 'bindTime',
t1.item_commission_rate as 'itemCommissionRate'
from kuaishou_item_info t1
left join kuaishou_item_bind_user t2 on t1.item_id = t2.item_id
where 1 = 1
and t2.user_id = #{userId}
and t1.item_id = #{itemId}
and t1.item_title like concat(concat('%',#{itemTitle}),'%')
and t1.activity_id = #{activityId}
order by t1.create_time desc) t
where 1 = 1
and t.status = #{status}
select t3.user_id as 'userId', t3.nick_name as 'nickMame', t1.role_name as 'roleName', t3.status
from sys_role t1
left join sys_user_role t2 on t1.role_id = t2.role_id
left join sys_user t3 on t2.user_id = t3.user_id
where t1.role_key in (
'supplyChainAdmin',
'associationManager',
'bd',
'bdManager',
'association',
'courtshipManager',
'courtship'
)
group by t3.user_id
order by t3.create_time asc
select *
from (select t1.user_id as 'userId',
t1.user_name as 'userName',
count(distinct t2.item_id) as 'itemCount',
count(t2.oid) as 'orderNum',
sum(case when t2.order_status != 80 then 1 else 0 end) as 'validOrderNUm',
round(sum(case when t2.order_status != 80 then 1 else 0 end) / count(t2.oid),4) as 'validRadio',
sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) as 'deliveryNum',
sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(sum(case when t2.send_status = 1 and t2.order_status != 80 then 1 else 0 end) / sum(case
when t2.order_status != 80
then 1
else 0 end),
4) as 'deliveryRadio',
sum(case when t2.order_status = 80 then 1 else 0 end) as 'invalidOrderNUm',
sum(case when t2.order_status != 80 then t2.pay_amount else 0 end) as 'payAmount',
sum(case
when t2.order_status != 80 then t2.regimental_promotion_amount
else 0 end) as 'regimentalPromotionAmount',
sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
'totalRegimentalSettleAmount'
from kuaishou_item_bind_user t1
left join kuaishou_supply_chain t2
on t1.item_id = t2.item_id
where 1= 1
and t2.order_create_time >= #{start}
and t2.order_create_time <= #{end}
group by t1.user_id) t
where 1 =1
and t.userId = #{userId}
order by t.orderNum desc
SELECT
*
FROM
(
SELECT
t1.user_id,
t1.user_name AS 'userName',
t2.item_id AS 'itemId',
t2.item_title AS 'itemTitle',
t2.image_url AS 'imageUrl',
t2.reserve_price AS 'reservePrice',
count(t2.oid) AS 'orderNum',
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'validOrderNUm',
round(
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) / count(t2.oid),
4
) AS 'validRadio',
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'deliveryNum',
sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) / sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
),
4
) AS 'deliveryRadio',
sum(
CASE
WHEN t2.order_status = 80 THEN 1
ELSE 0
END
) AS 'invalidOrderNUm',
sum(
CASE
WHEN t2.order_status != 80 THEN t2.pay_amount
ELSE 0
END
) AS 'payAmount',
t2.regimental_promotion_rate AS 'regimentalPromotionRate',
sum(
CASE
WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
ELSE 0
END
) AS 'regimentalPromotionAmount',
sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
'totalRegimentalSettleAmount',
t2.item_commission_rate as 'itemCommissionRate'
FROM
kuaishou_item_bind_user t1
LEFT JOIN
kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
WHERE
1 = 1
and t2.order_create_time >= #{start}
and t2.order_create_time <= #{end}
and t1.item_id = #{itemId}
and t1.item_title like concat(concat('%',#{itemTitle}),'%')
GROUP BY
t1.item_id
) t
where 1 = 1
and t.user_id = #{userId}
order by ${fieId} ${sort}
select
round((t1.oid -t2.oid) / t2.oid , 4) as 'orderTotalRatio',
round((t1.orderAmount -t2.orderAmount) / t2.orderAmount , 4) as 'orderAmountRatio'
from (
select count(oid) as 'oid',
sum(order_amount) as 'orderAmount'
from kuaishou_supply_chain
where 1= 1
and order_create_time >= #{thisCycleStartTemp}
and order_create_time <= #{thisCycleEndTemp}
) t1
join (
select count(oid) as 'oid',
sum(order_amount) as 'orderAmount'
from kuaishou_supply_chain
where 1=1
and order_create_time >= #{lastCycleStartTemp}
and order_create_time <= #{lastCycleEndTemp}
) t2
select FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') as 'date',
count(t.oid) as 'orderNum'
sum(case when t.order_status = 80 then 1 else 0 end) as 'validOrderNum'
sum(t.order_amount) as 'orderAmount'
sum(t.base_amount) as 'baseAmount'
sum(case when t.send_status = 1 and t.order_status != 80 then 1 else 0 end) as 'deliveryNum'
from (select
oid,
order_status,
order_amount,
base_amount,
send_status,
order_create_time
from kuaishou_supply_chain
where 1 = 1
and order_create_time >= #{startTemp}
and order_create_time <= #{endTemp}
) t
group by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d')
order by FROM_UNIXTIME(t.order_create_time / 1000, '%y-%m-%d') asc
select count(t1.item_id) as 'itemTotal', sum(case when t2.item_id is not null then 1 else 0 end) as 'claimCount', sum(case when t2.item_id is null then 1 else 0 end) as 'unClaimCount'
from kuaishou_item_info t1
left join kuaishou_item_bind_user t2
on t1.item_id = t2.item_id
where 1 = 1
SELECT count(t2.oid) AS 'orderNum',
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'validOrderNUm',
round(
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) / count(t2.oid),
4
) AS 'validRadio',
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'deliveryNum',
sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) / sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
),
4
) AS 'deliveryRadio',
sum(
CASE
WHEN t2.order_status = 80 THEN 1
ELSE 0
END
) AS 'invalidOrderNUm',
sum(
CASE
WHEN t2.order_status != 80 THEN t2.pay_amount
ELSE 0
END
) AS 'payAmount',
sum(
CASE
WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
ELSE 0
END
) AS 'regimentalPromotionAmount',
sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) as
'totalRegimentalSettleAmount'
FROM kuaishou_item_bind_user t1
LEFT JOIN
kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
WHERE 1 = 1
and t2.order_create_time >= #{start}
and t2.order_create_time <= #{end}
and t1.user_id = #{userId}
SELECT
*
FROM
(
SELECT
t1.user_id as 'user_id',
t1.user_name AS 'userName',
t2.item_id AS 'itemId',
t2.item_title AS 'itemTitle',
t2.image_url AS 'imageUrl',
round(t2.reserve_price / 100,2) AS 'reservePrice',
count(t2.oid) AS 'orderNum',
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'validOrderNUm',
round(
sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) / count(t2.oid) * 100,
2
) AS 'validRadio',
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) AS 'deliveryNum',
sum(case when t2.send_status = 0 and t2.order_status != 80 then 1 else 0 end) as 'notDeliveryNum',
round(
sum(
CASE
WHEN t2.send_status = 1
AND t2.order_status != 80 THEN 1
ELSE 0
END
) / sum(
CASE
WHEN t2.order_status != 80 THEN 1
ELSE 0
END
) * 100,
2
) AS 'deliveryRadio',
sum(
CASE
WHEN t2.order_status = 80 THEN 1
ELSE 0
END
) AS 'invalidOrderNUm',
round( sum(
CASE
WHEN t2.order_status != 80 THEN t2.pay_amount
ELSE 0
END
)/ 100,2 )AS 'payAmount',
concat(round(t2.regimental_promotion_rate / 10 ,2),'%') AS 'regimentalPromotionRate',
round(
sum(
CASE
WHEN t2.order_status != 80 THEN t2.regimental_promotion_amount
ELSE 0
END
) / 100 , 2)AS 'regimentalPromotionAmount',
round(
sum(case when t2.order_status != 80 then t2.total_regimental_settle_amount else 0 end) / 100,2) as
'totalRegimentalSettleAmount',
concat(round(t2.item_commission_rate / 10),'%') as 'itemCommissionRate'
FROM
kuaishou_item_bind_user t1
LEFT JOIN
kuaishou_supply_chain t2 ON t1.item_id = t2.item_id
WHERE
1 = 1
and t2.order_create_time >= #{start}
and t2.order_create_time <= #{end}
and t1.item_id = #{itemId}
and t1.item_title like concat(concat('%',#{itemTitle}),'%')
GROUP BY
t1.item_id
) t
where 1 = 1
and t.user_id = #{userId}
order by t.orderNum desc
select cookie
from ruixuan.kuaishou_supply_chain_cookie limit 1
SELECT COUNT(oid) as 'allNumber', IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
'validOrderNUm', IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
IFNULL(
SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
0) AS 'regimentalPromotionAmount', IFNULL(sum(base_amount), 0) as 'baseAmount'
FROM kuaishou_supply_chain
WHERE stat_date >= #{startDate}
AND stat_date <= #{endDate}
AND promoter_id in
#{item}
SELECT t.*,
CONCAT(IFNULL(ROUND(sendCount / allNumber * 100, 2),0), '%') as 'sendRate'
FROM (SELECT COUNT(oid) as 'allNumber',
IFNULL(SUM(CASE WHEN order_status != 80 THEN 1 ELSE 0 END), 0) AS
'validOrderNUm',
IFNULL(SUM(CASE WHEN order_status != 80 THEN order_amount ELSE 0 END), 0) AS 'orderAmount',
IFNULL(
SUM(CASE WHEN order_status != 80 THEN regimental_promotion_amount ELSE 0 END),
0) AS 'regimentalPromotionAmount',
IFNULL(sum(base_amount), 0) as 'baseAmount',
IFNULL(COUNT(CASE WHEN send_status = 1 THEN oid ELSE null END), 0) AS 'sendCount'
FROM kuaishou_supply_chain
WHERE stat_date >= #{startDate}
AND stat_date <= #{endDate}
AND item_id in
#{item}
) t
SELECT
count(oid) as 'allNumber',
sum(
CASE
WHEN order_status != 80 THEN order_amount
ELSE 0
END
) AS 'orderAmount'
FROM kuaishou_supply_chain
WHERE stat_date >= #{statDate}
AND stat_date <= #{endDate}
AND promoter_id in
#{item}
AND item_id in
#{item}
SELECT
FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
IFNULL(promoterCount,0) AS 'promoterCount'
FROM kuaishou_supply_chain t1
LEFT JOIN (
SELECT count(promoter_id) as 'promoterCount', DATE_FORMAT(create_time, '%Y-%m-%d') as 'date'
FROM kuaishou_promoter
WHERE user_id = #{userId}
AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{start}
AND DATE_FORMAT(create_time, '%Y-%m-%d') <= #{end}
GROUP BY DATE_FORMAT(create_time, '%Y-%m-%d')
) t2 ON t1.FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') = t2.date
WHERE order_status != 80
AND promoter_id in
#{item}
AND order_create_time >= #{startLong}
AND order_create_time <= #{endLong}
GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
SELECT
FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d') as 'date',
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
count(oid) AS 'orderCount'
FROM kuaishou_supply_chain
WHERE order_status != 80
AND item_id in
#{item}
AND order_create_time >= #{startLong}
AND order_create_time <= #{endLong}
GROUP BY FROM_UNIXTIME(order_create_time / 1000, '%Y-%m-%d')
SELECT
t1.orderAmount,
t1.totalRegimentalSettleAmount,
CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
'totalRegimentalSettleAmountRate'
FROM
(
SELECT
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
FROM kuaishou_supply_chain t1
WHERE order_status != 80
AND promoter_id in
#{item}
AND order_create_time >= #{startLong}
AND order_create_time <= #{endLong}) t1
LEFT JOIN
(
SELECT
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount'
FROM kuaishou_supply_chain t1
WHERE order_status != 80
AND promoter_id in
#{item}
AND order_create_time >= #{toStartLong}
AND order_create_time <= #{endLong})t2 ON 1=1
SELECT
t1.orderAmount,
t1.totalRegimentalSettleAmount,
t1.orderCount,
CONCAT(IFNULL(ROUND(t2.orderAmount/t1.orderAmount*100,2),0),'%') as 'orderAmountRate',
CONCAT(IFNULL(ROUND(t2.orderCount/t1.orderCount*100,2),0),'%') as 'orderCountRate',
CONCAT(IFNULL(ROUND(t2.totalRegimentalSettleAmount/t1.totalRegimentalSettleAmount*100,2),0),'%') as
'totalRegimentalSettleAmountRate'
FROM
(
SELECT
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
COUNT(oid) as 'orderCount'
FROM kuaishou_supply_chain t1
WHERE order_status != 80
AND item_id in
#{item}
AND order_create_time >= #{startLong}
AND order_create_time <= #{endLong}
)t1
LEFT JOIN
(
SELECT
IFNULL(SUM(order_amount),0) AS 'orderAmount',
IFNULL(SUM(total_regimental_settle_amount),0) AS 'totalRegimentalSettleAmount',
COUNT(oid) as 'orderCount'
FROM kuaishou_supply_chain t1
WHERE order_status != 80
AND item_id in
#{item}
AND order_create_time >= #{toStartLong}
AND order_create_time <= #{endLong}
)t2 ON 1=1