|
@@ -3,7 +3,8 @@
|
|
|
<mapper namespace="org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper">
|
|
|
|
|
|
<!-- 获取头条 账户 日流水信息 -->
|
|
|
- <select id="getAccountTransactionDayBytedance" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo">
|
|
|
+ <select id="getAccountTransactionDayBytedance"
|
|
|
+ resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo">
|
|
|
select t.*,c.auth_name as accountName from (select id,
|
|
|
advertiser_id,
|
|
|
date,DATE_FORMAT(date,'%Y-%m') as uploadYears,
|
|
@@ -35,31 +36,33 @@
|
|
|
where uploadYears = #{uploadYears}
|
|
|
ORDER BY date
|
|
|
</select>
|
|
|
-<!-- 获取头条 账户 日流水信息 汇总页数据 -->
|
|
|
+ <!-- 获取头条 账户 日流水信息 汇总页数据 -->
|
|
|
<select id="getAccountTransactionDayBytedanceSheet" resultType="java.util.LinkedHashMap">
|
|
|
SELECT
|
|
|
- t.advertiser_id accountId,
|
|
|
+ t.advertiser_id accountId,
|
|
|
ua.auth_name accountName,
|
|
|
ROUND( SUM( t.balance ), 3 ) balance,
|
|
|
- ROUND( SUM( t.cash_cost ), 3 ) cash_cost,
|
|
|
- ROUND( SUM( t.cost ), 3 ) cost,
|
|
|
- ROUND( SUM( t.frozen ), 3 ) frozen,
|
|
|
- ROUND( SUM( t.income ), 3 ) income,
|
|
|
- ROUND( SUM( t.reward_cost ), 3 ) reward_cost,
|
|
|
- ROUND( SUM( t.shared_wallet_cost ), 3 ) shared_wallet_cost,
|
|
|
- ROUND( SUM( t.transfer_in ), 3 ) transfer_in,
|
|
|
- ROUND( SUM( t.transfer_out ), 3 ) transfer_out,
|
|
|
- ag.agent_id agentId,
|
|
|
- ag.NAME agentName,
|
|
|
+ ROUND( SUM( t.cash_cost ), 3 ) cash_cost,
|
|
|
+ ROUND( SUM( t.cost ), 3 ) cost,
|
|
|
+ ROUND( SUM( t.frozen ), 3 ) frozen,
|
|
|
+ ROUND( SUM( t.income ), 3 ) income,
|
|
|
+ ROUND( SUM( t.reward_cost ), 3 ) reward_cost,
|
|
|
+ ROUND( SUM( t.shared_wallet_cost ), 3 ) shared_wallet_cost,
|
|
|
+ ROUND( SUM( t.transfer_in ), 3 ) transfer_in,
|
|
|
+ ROUND( SUM( t.transfer_out ), 3 ) transfer_out,
|
|
|
+ ag.agent_id agentId,
|
|
|
+ ag.NAME agentName,
|
|
|
ua.project_id,
|
|
|
(SELECT ad.id from ctop_advertiser ad WHERE ad.id = ua.advertiser_id) advertiserId,
|
|
|
(SELECT ad.name from ctop_advertiser ad WHERE ad.id = ua.advertiser_id) advertiserName,
|
|
|
- (SELECT pd.id from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id = pd.id) productId,
|
|
|
- (SELECT pd.product_name from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id = pd.id) productName
|
|
|
+ (SELECT pd.id from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id = pd.id)
|
|
|
+ productId,
|
|
|
+ (SELECT pd.product_name from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id =
|
|
|
+ pd.id) productName
|
|
|
|
|
|
|
|
|
FROM
|
|
|
- ctop_account_transaction_day t
|
|
|
+ ctop_account_transaction_day t
|
|
|
LEFT JOIN (SELECT DISTINCT account_id,agent_id from ctop_agent_account where 1 = 1
|
|
|
<if test='accountIds != null and accountIds.size() > 0'>
|
|
|
AND account_id in
|
|
@@ -68,12 +71,12 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- ) ac ON t.advertiser_id = ac.account_id
|
|
|
- LEFT JOIN ctop_cwjs_agent_info ag ON ag.agent_id = ac.agent_id
|
|
|
- LEFT JOIN ctop_user_allocation ua on ua.account_id = t.advertiser_id
|
|
|
+ ) ac ON t.advertiser_id = ac.account_id
|
|
|
+ LEFT JOIN ctop_cwjs_agent_info ag ON ag.agent_id = ac.agent_id
|
|
|
+ LEFT JOIN ctop_user_allocation ua on ua.account_id = t.advertiser_id
|
|
|
WHERE
|
|
|
- t.cost > 0
|
|
|
- AND DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
|
|
|
+ t.cost > 0
|
|
|
+ AND DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
|
|
|
<if test='accountIds != null and accountIds.size() > 0'>
|
|
|
AND t.advertiser_id in
|
|
|
<foreach collection="accountIds" item="item" separator=","
|
|
@@ -82,7 +85,7 @@
|
|
|
</foreach>
|
|
|
</if>
|
|
|
GROUP BY
|
|
|
- t.advertiser_id
|
|
|
+ t.advertiser_id
|
|
|
</select>
|
|
|
|
|
|
<!-- 查询 头条 账户id-->
|
|
@@ -125,16 +128,16 @@
|
|
|
ctop_account_transaction_day
|
|
|
WHERE
|
|
|
cost > 0
|
|
|
- <if test="uploadYears !=null and uploadYears != ''">
|
|
|
- AND DATE_FORMAT( date, '%Y-%m' ) = #{uploadYears}
|
|
|
- </if>
|
|
|
- <if test='accountIds !=null and accountIds.size() >0'>
|
|
|
- AND advertiser_id in
|
|
|
- <foreach collection="accountIds" item="item" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
+ <if test="uploadYears !=null and uploadYears != ''">
|
|
|
+ AND DATE_FORMAT( date, '%Y-%m' ) = #{uploadYears}
|
|
|
+ </if>
|
|
|
+ <if test='accountIds !=null and accountIds.size() >0'>
|
|
|
+ AND advertiser_id in
|
|
|
+ <foreach collection="accountIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
advertiser_id
|
|
|
</select>
|
|
@@ -147,30 +150,21 @@
|
|
|
ctop_kuaishou_daily_agent
|
|
|
WHERE
|
|
|
total_charged_in_yuan > 0
|
|
|
- <if test="uploadYears !=null and uploadYears != ''">
|
|
|
- AND DATE_FORMAT( date_time, '%Y-%m' ) = #{uploadYears}
|
|
|
- </if>
|
|
|
- <if test='accountIds != null and accountIds.size() > 0'>
|
|
|
- AND account_id in
|
|
|
- <foreach collection="accountIds" item="item" separator=","
|
|
|
- open="(" close=")">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
+ <if test="uploadYears !=null and uploadYears != ''">
|
|
|
+ AND DATE_FORMAT( date_time, '%Y-%m' ) = #{uploadYears}
|
|
|
+ </if>
|
|
|
+ <if test='accountIds != null and accountIds.size() > 0'>
|
|
|
+ AND account_id in
|
|
|
+ <foreach collection="accountIds" item="item" separator=","
|
|
|
+ open="(" close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
GROUP BY
|
|
|
account_id
|
|
|
</select>
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
<!-- 查询 头条 账户 图片-->
|
|
|
<select id="getAccountImagesBytedance" resultType="java.lang.String">
|
|
|
SELECT
|
|
@@ -183,7 +177,8 @@
|
|
|
</select>
|
|
|
|
|
|
<!-- 获取快手 账户 日流水信息 账户维度-->
|
|
|
- <select id="getAccountTransactionDayKuaiShou" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
+ <select id="getAccountTransactionDayKuaiShou"
|
|
|
+ resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
select t.*,c.auth_name as accountName,
|
|
|
base.user_id as ksId from (select id,
|
|
|
account_id,
|
|
@@ -202,7 +197,8 @@
|
|
|
</select>
|
|
|
|
|
|
<!-- 获取快手 账户 日流水信息 代理商维度-->
|
|
|
- <select id="getAccountTransactionDayKuaiShouAgent" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
+ <select id="getAccountTransactionDayKuaiShouAgent"
|
|
|
+ resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
|
|
|
SELECT
|
|
|
t.*
|
|
@@ -231,7 +227,8 @@
|
|
|
</select>
|
|
|
|
|
|
<!-- 获取快手 账户 日流水信息 代理商 和 账户 维度-->
|
|
|
- <select id="getTransactionDayKuaiShouAgentAndAccount" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
+ <select id="getTransactionDayKuaiShouAgentAndAccount"
|
|
|
+ resultType="org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo">
|
|
|
SELECT
|
|
|
*
|
|
|
FROM
|
|
@@ -303,14 +300,14 @@
|
|
|
FROM
|
|
|
ctop_account_transaction_day d
|
|
|
WHERE d.cost >0
|
|
|
- <if test="startTime !=null and startTime != ''">
|
|
|
- AND d.date >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime !=null and endTime != ''">
|
|
|
- AND d.date <= #{endTime}
|
|
|
- </if>
|
|
|
+ <if test="startTime !=null and startTime != ''">
|
|
|
+ AND d.date >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null and endTime != ''">
|
|
|
+ AND d.date <= #{endTime}
|
|
|
+ </if>
|
|
|
GROUP BY d.advertiser_id;
|
|
|
-</select>
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 查询 头条利润表 所用账户-->
|
|
|
<select id="getProfitBytedanceAccountCost" resultType="java.util.LinkedHashMap">
|
|
@@ -319,30 +316,34 @@
|
|
|
ROUND(SUM( d.cost ),2) AS cost,
|
|
|
ROUND(SUM( d.cash_cost ),2) AS cashCost,
|
|
|
ROUND(SUM( d.reward_cost ),2) as rewardCost,
|
|
|
- IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.advertiser_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
|
|
|
- from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.advertiser_id and c.advertiser_id = a.id)) as advertiserName,
|
|
|
+ IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.advertiser_id = u.account_id and
|
|
|
+ u.advertiser_id = a.id),(SELECT a.name
|
|
|
+ from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.advertiser_id and c.advertiser_id =
|
|
|
+ a.id)) as advertiserName,
|
|
|
IFNULL((SELECT
|
|
|
p.product_name
|
|
|
- FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.advertiser_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
|
|
|
+ FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.advertiser_id = u.account_id and u.project_id
|
|
|
+ = pj.id and pj.product_id = p.id
|
|
|
),(SELECT p.product_name
|
|
|
- FROM ctop_cwjs_settlement_info c,ctop_product p where d.advertiser_id = c.account_id and c.product_id = p.id)) productName
|
|
|
+ FROM ctop_cwjs_settlement_info c,ctop_product p where d.advertiser_id = c.account_id and c.product_id = p.id))
|
|
|
+ productName
|
|
|
FROM
|
|
|
ctop_account_transaction_day d
|
|
|
-<where>
|
|
|
- <if test="accountId !=null and accountId != ''">
|
|
|
- AND d.advertiser_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>
|
|
|
+ <where>
|
|
|
+ <if test="accountId !=null and accountId != ''">
|
|
|
+ AND d.advertiser_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>
|
|
|
GROUP BY d.advertiser_id
|
|
|
limit 1
|
|
|
|
|
|
-</select>
|
|
|
+ </select>
|
|
|
|
|
|
<!-- 查询 头条利润表 总花费-->
|
|
|
<select id="getProfitBytedanceCost" resultType="java.util.LinkedHashMap">
|
|
@@ -374,7 +375,6 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
-
|
|
|
<!-- 查询 头条利润表 返点类型和比列-->
|
|
|
<select id="getProfitBytedance" resultType="java.util.LinkedHashMap">
|
|
|
SELECT t.* from (
|
|
@@ -394,13 +394,13 @@
|
|
|
<if test="mediaType !=null and mediaType != ''">
|
|
|
AND cp.media_type = #{mediaType}
|
|
|
</if>
|
|
|
- AND r.advertiser_name = #{advertiserName}
|
|
|
- AND r.product_name = #{productName}
|
|
|
+ AND r.advertiser_name = #{advertiserName}
|
|
|
+ AND r.product_name = #{productName}
|
|
|
<if test="saleId !=null and saleId != ''">
|
|
|
AND r.create_user_id = #{saleId}
|
|
|
</if>
|
|
|
<if test="startTime !=null and startTime != ''">
|
|
|
- AND r.policy_date >= #{startTime}
|
|
|
+ AND r.policy_date >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime !=null and endTime != ''">
|
|
|
AND r.policy_date <= #{endTime}
|
|
@@ -426,12 +426,12 @@
|
|
|
</if>
|
|
|
AND r.advertiser_name = #{advertiserName}
|
|
|
AND r.product_name = #{productName}
|
|
|
- <if test="saleId !=null and saleId != ''">
|
|
|
- AND r.create_user_id = #{saleId}
|
|
|
- </if>
|
|
|
+ <if test="saleId !=null and saleId != ''">
|
|
|
+ AND r.create_user_id = #{saleId}
|
|
|
+ </if>
|
|
|
|
|
|
<if test="startTime !=null and startTime != ''">
|
|
|
- AND r.policy_date >= #{startTime}
|
|
|
+ AND r.policy_date >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime !=null and endTime != ''">
|
|
|
AND r.policy_date <= #{endTime}
|
|
@@ -493,12 +493,12 @@
|
|
|
SELECT k.* from
|
|
|
ctop_kuaishou_daily_agent k
|
|
|
where k.total_charged_in_yuan !=0
|
|
|
- <if test="startTime !=null and startTime != ''">
|
|
|
- AND k.date_time >= #{startTime}
|
|
|
- </if>
|
|
|
- <if test="endTime !=null and endTime != ''">
|
|
|
- AND k.date_time <= #{endTime}
|
|
|
- </if>
|
|
|
+ <if test="startTime !=null and startTime != ''">
|
|
|
+ AND k.date_time >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null and endTime != ''">
|
|
|
+ AND k.date_time <= #{endTime}
|
|
|
+ </if>
|
|
|
GROUP BY k.account_id
|
|
|
</select>
|
|
|
|
|
@@ -508,14 +508,19 @@
|
|
|
d.account_id as accountId,
|
|
|
d.user_id AS ksId,
|
|
|
round(SUM(d.total_charged_in_yuan),3) AS cost,
|
|
|
- round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as cashCost,
|
|
|
- IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
|
|
|
- from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id = a.id)) as advertiserName,
|
|
|
+ round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as
|
|
|
+ cashCost,
|
|
|
+ IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and
|
|
|
+ u.advertiser_id = a.id),(SELECT a.name
|
|
|
+ from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id =
|
|
|
+ a.id)) as advertiserName,
|
|
|
IFNULL((SELECT
|
|
|
p.product_name
|
|
|
- FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
|
|
|
+ FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id =
|
|
|
+ pj.id and pj.product_id = p.id
|
|
|
),(SELECT p.product_name
|
|
|
- FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id)) productName
|
|
|
+ FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id))
|
|
|
+ productName
|
|
|
FROM
|
|
|
ctop_kuaishou_daily_agent d
|
|
|
<where>
|
|
@@ -542,14 +547,19 @@
|
|
|
(SELECT ua.auth_name from ctop_user_allocation ua where ua.account_id = d.account_id) as accountName,
|
|
|
d.user_id AS ksId,
|
|
|
round(SUM(d.total_charged_in_yuan),3) AS cost,
|
|
|
- round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as cashCost,
|
|
|
- IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
|
|
|
- from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id = a.id)) as advertiserName,
|
|
|
+ round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as
|
|
|
+ cashCost,
|
|
|
+ IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and
|
|
|
+ u.advertiser_id = a.id),(SELECT a.name
|
|
|
+ from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id =
|
|
|
+ a.id)) as advertiserName,
|
|
|
IFNULL((SELECT
|
|
|
p.product_name
|
|
|
- FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
|
|
|
+ FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id =
|
|
|
+ pj.id and pj.product_id = p.id
|
|
|
),(SELECT p.product_name
|
|
|
- FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id)) productName
|
|
|
+ FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id))
|
|
|
+ productName
|
|
|
FROM
|
|
|
ctop_kuaishou_daily_agent d
|
|
|
<where>
|
|
@@ -663,11 +673,9 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
<!-- 获取快手 账户 日流水信息 代理商 和 账户 结算单 -汇总页-->
|
|
|
- <select id="getTransactionDayKuaiShouSheet" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo">
|
|
|
+ <select id="getTransactionDayKuaiShouSheet"
|
|
|
+ resultType="org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo">
|
|
|
SELECT
|
|
|
*,
|
|
|
IFNULL(b.balance1,0) as balance
|
|
@@ -708,6 +716,7 @@
|
|
|
(
|
|
|
SELECT
|
|
|
account_id AS accountIdF,
|
|
|
+ daily_charge as flowDailyCharge,
|
|
|
date,
|
|
|
daily_transfer_in as dailyTransferIn,
|
|
|
daily_transfer_out as dailyTransferOut,
|
|
@@ -735,10 +744,4 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
</mapper>
|