|
@@ -104,6 +104,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
+ <!-- 获取快手 账户 日流水信息 代理商 和 账户 维度-->
|
|
|
+ <select id="getTransactionDayKuaiShouAgentAndAccount" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t.*
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ date_time as date,
|
|
|
+ account_id AS accountId,
|
|
|
+ total_charged_in_yuan as dailyCharge,
|
|
|
+ contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
|
|
|
+ direct_rebate_real_charged_in_yuan as directRebateRealCharged,
|
|
|
+ ( real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan ) realCharged,
|
|
|
+ account_name AS accountName,
|
|
|
+ user_id AS ksId
|
|
|
+ FROM
|
|
|
+ ctop_kuaishou_daily_agent
|
|
|
+ WHERE
|
|
|
+ account_id = #{accountId}
|
|
|
+ ) t
|
|
|
+ WHERE
|
|
|
+ DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
|
|
|
+ ORDER BY
|
|
|
+ t.date
|
|
|
+ LIMIT 31
|
|
|
+ ) a
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ t.*,
|
|
|
+ c.auth_name AS accountNameF,
|
|
|
+ base.user_id AS ksIdF
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ account_id AS accountIdF,
|
|
|
+ date,
|
|
|
+ daily_transfer_in as dailyTransferIn,
|
|
|
+ daily_transfer_out as dailyTransferOut,
|
|
|
+ balance as balance,
|
|
|
+ real_recharged as realRecharged,
|
|
|
+ contract_rebate_real_recharged as contractRebateRealRecharged,
|
|
|
+ direct_rebate_real_recharged as directRebateRealRecharged
|
|
|
+ FROM
|
|
|
+ ctop_kuaishou_daily_flows
|
|
|
+ WHERE
|
|
|
+ account_id = #{accountId}
|
|
|
+ ) t
|
|
|
+ LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
|
|
|
+ LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
|
|
|
+ WHERE
|
|
|
+ DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
|
|
|
+ ORDER BY
|
|
|
+ date
|
|
|
+ LIMIT 31
|
|
|
+ ) b ON a.accountId = b.accountIdF
|
|
|
+ AND a.date = b.date
|
|
|
+ LIMIT 31
|
|
|
+
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
<!-- 查询 头条利润表 所用账户-->
|
|
@@ -188,13 +254,13 @@
|
|
|
<if test="productName !=null and productName != ''">
|
|
|
AND pp.policy_product_name = #{productName}
|
|
|
</if>
|
|
|
- <if test="startTime !=null and startTime != ''">
|
|
|
+ <!-- <if test="startTime !=null and startTime != ''">
|
|
|
AND cp.policy_start_date >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime !=null and endTime != ''">
|
|
|
AND cp.policy_end_date <= #{endTime}
|
|
|
</if>
|
|
|
-
|
|
|
+-->
|
|
|
</select>
|
|
|
|
|
|
|
|
@@ -292,26 +358,30 @@
|
|
|
d.account_id;-->
|
|
|
|
|
|
SELECT
|
|
|
- d.account_id,
|
|
|
+ d.account_id as accountId,
|
|
|
d.user_id AS ksId,
|
|
|
SUM(d.total_charged_in_yuan) AS cost,
|
|
|
SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost,
|
|
|
c.product_id as productId,
|
|
|
- (SELECT p.product_name from ctop_product p where p.id = c.product_id) AS productName
|
|
|
+ (SELECT p.product_name from ctop_product p where p.id = c.product_id) AS productName,
|
|
|
+ (SELECT d.name as advertiserName from ctop_advertiser d where d.id = c.advertiser_id) advertiserName
|
|
|
FROM
|
|
|
ctop_kuaishou_daily_agent d
|
|
|
RIGHT JOIN ctop_cwjs_settlement_info c
|
|
|
on d.account_id = c.account_id
|
|
|
and c.kuai_shou_id = d.user_id
|
|
|
- <if test="accountId !=null and accountId != ''">
|
|
|
- AND d.account_id = #{accountId}
|
|
|
- </if>
|
|
|
- <if test="startTime !=null and startTime != ''">
|
|
|
- AND d.date_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime !=null and endTime != ''">
|
|
|
- AND d.date_time <= #{endTime}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="accountId !=null and accountId != ''">
|
|
|
+ AND d.account_id = #{accountId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime !=null and startTime != ''">
|
|
|
+ AND d.date_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null and endTime != ''">
|
|
|
+ AND d.date_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
GROUP BY d.account_id
|
|
|
</select>
|
|
|
|
|
@@ -346,15 +416,18 @@
|
|
|
SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)) as cashCost
|
|
|
FROM
|
|
|
ctop_kuaishou_daily_agent d
|
|
|
- <if test="accountId !=null and accountId != ''">
|
|
|
- AND d.account_id = #{accountId}
|
|
|
- </if>
|
|
|
- <if test="startTime !=null and startTime != ''">
|
|
|
- AND d.date >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime !=null and endTime != ''">
|
|
|
- AND d.date <= #{endTime}
|
|
|
- </if>
|
|
|
+ <where>
|
|
|
+ <if test="accountId !=null and accountId != ''">
|
|
|
+ AND d.account_id = #{accountId}
|
|
|
+ </if>
|
|
|
+ <if test="startTime !=null and startTime != ''">
|
|
|
+ AND d.date_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null and endTime != ''">
|
|
|
+ AND d.date_time <= #{endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
|
|
|
</select>
|
|
|
|
|
@@ -393,7 +466,7 @@
|
|
|
LEFT JOIN ctop_advertiser d on d.id = c.advertiser_id
|
|
|
where c.del_flag = 0
|
|
|
<if test="accountId !=null and accountId != ''">
|
|
|
- AND u.account_id = #{accountId}
|
|
|
+ AND c.account_id = #{accountId}
|
|
|
</if>
|
|
|
</select>
|
|
|
|