|
@@ -90,67 +90,79 @@
|
|
|
|
|
|
<!-- 查询 财务结算-结算单列表-->
|
|
|
<select id="getSettlementSheetList" resultType="java.util.LinkedHashMap">
|
|
|
- SELECT * FROM
|
|
|
+ SELECT t.*
|
|
|
+ FROM
|
|
|
(
|
|
|
SELECT
|
|
|
f.id,
|
|
|
- f.upload_years as uploadYears,
|
|
|
- f.media_id as mediaId,
|
|
|
- f.advertiser_id as advertiserId,
|
|
|
- ( SELECT ad.NAME FROM ctop_advertiser ad WHERE ad.id = f.advertiser_id LIMIT 1 ) advertiserName,
|
|
|
- f.product_id as productId,
|
|
|
- ( SELECT cp.product_name FROM ctop_product cp WHERE cp.id = f.product_id LIMIT 1 ) productName,
|
|
|
- IFNULL((SELECT u.project_id from ctop_user_allocation u where u.account_id = f.account_id),cwjs.project_id) as projectId,
|
|
|
- IFNULL((SELECT project.project_name from ctop_user_allocation u,ctop_project project where u.account_id = f.account_id and project.id = u.project_id),
|
|
|
- (SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 )) as projectName,
|
|
|
- IFNULL(cwjs.account_id,f.account_id) as accountId,
|
|
|
- IFNULL((SELECT u.auth_name from ctop_user_allocation u where u.account_id = f.account_id),cwjs.account_name) as accountName,
|
|
|
+ f.upload_years AS uploadYears,
|
|
|
+ f.media_id AS mediaId,
|
|
|
+ f.advertiser_id AS advertiserId,
|
|
|
+ ad.NAME as advertiserName,
|
|
|
+ f.product_id AS productId,
|
|
|
+ cp.product_name as productName,
|
|
|
+ IFNULL(u.project_id, cwjs.project_id ) AS projectId,
|
|
|
+ IFNULL((SELECT project.project_name FROM ctop_user_allocation u,ctop_project project WHERE u.account_id = f.account_id AND project.id = u.project_id),
|
|
|
+ (SELECT project.project_name FROM ctop_project project WHERE project.id = cwjs.project_id LIMIT 1 )
|
|
|
+ ) AS projectName,
|
|
|
+ IFNULL(cwjs.account_id, f.account_id) AS accountId,
|
|
|
+ IFNULL(u.auth_name,cwjs.account_name) AS accountName,
|
|
|
f.del_flag,
|
|
|
- IFNULL((SELECT cp.sale_id from ctop_user_allocation ua, ctop_project cp where f.account_id = ua.account_id and ua.project_id = cp.id),cwjs.create_user_id) as saleUserId,
|
|
|
- IFNULL((SELECT su.realname from ctop_user_allocation ua, ctop_project cp,sys_user su where f.account_id = ua.account_id and ua.project_id = cp.id and cp.sale_id = su.id), (SELECT su.realname FROM sys_user su WHERE su.id = cwjs.create_user_id LIMIT 1 )) as saleUserName,
|
|
|
- f.create_user_id as operateUserId,
|
|
|
- ( SELECT su.realname FROM sys_user su WHERE su.id = f.create_user_id LIMIT 1 ) operateUserName,
|
|
|
- cwjs.create_time,
|
|
|
- cwjs.update_time
|
|
|
- FROM ctop_cwjs_settlement_file_info f
|
|
|
- LEFT JOIN ctop_cwjs_settlement_info cwjs on f.account_id = cwjs.account_id
|
|
|
- where f.del_flag = 0
|
|
|
- GROUP BY f.account_id,f.upload_years,f.create_user_id
|
|
|
- ORDER BY f.upload_years DESC
|
|
|
+ IFNULL(project.sale_id,cwjs.create_user_id) AS saleUserId,
|
|
|
+ IFNULL((SELECT su.realname FROM sys_user su WHERE f.account_id = u.account_id AND u.project_id = project.id AND project.sale_id = su.id),
|
|
|
+ (SELECT su.realname FROM sys_user su LEFT JOIN ctop_cwjs_settlement_info cwjs1 on su.id = cwjs1.create_user_id LIMIT 1 )
|
|
|
+ ) as saleUserName,
|
|
|
+ f.create_user_id AS operateUserId,
|
|
|
+ (SELECT su.realname FROM sys_user su LEFT JOIN ctop_cwjs_settlement_file_info f1 on su.id = f1.create_user_id LIMIT 1 ) as operateUserName,
|
|
|
+ MAX(f.create_time) create_time,
|
|
|
+ MAX(f.update_time) update_time
|
|
|
+ FROM
|
|
|
+ ctop_cwjs_settlement_file_info f
|
|
|
+ LEFT JOIN ctop_cwjs_settlement_info cwjs ON f.account_id = cwjs.account_id
|
|
|
+ LEFT JOIN ctop_user_allocation u on u.account_id = f.account_id
|
|
|
+ LEFT JOIN ctop_advertiser ad on ad.id = f.advertiser_id
|
|
|
+ LEFT JOIN ctop_product cp on cp.id = f.product_id
|
|
|
+ LEFT JOIN ctop_project project on project.id = u.project_id
|
|
|
+ WHERE
|
|
|
+ f.del_flag = 0
|
|
|
+ GROUP BY
|
|
|
+ f.account_id,
|
|
|
+ f.upload_years,
|
|
|
+ f.create_user_id
|
|
|
) t
|
|
|
<where>
|
|
|
<if test="advertiserName !=null and advertiserName != ''">
|
|
|
- AND advertiserName like concat ('%',#{advertiserName},'%')
|
|
|
+ AND t.advertiserName like concat ('%',#{advertiserName},'%')
|
|
|
</if>
|
|
|
<if test="productName !=null and productName != ''">
|
|
|
- AND productName like concat ('%',#{productName},'%')
|
|
|
+ AND t.productName like concat ('%',#{productName},'%')
|
|
|
</if>
|
|
|
<if test="projectName !=null and projectName != ''">
|
|
|
- AND projectName like concat ('%',#{projectName},'%')
|
|
|
+ AND t.projectName like concat ('%',#{projectName},'%')
|
|
|
</if>
|
|
|
<if test="accountName !=null and accountName != ''">
|
|
|
- AND accountName like concat ('%',#{accountName},'%')
|
|
|
+ AND t.accountName like concat ('%',#{accountName},'%')
|
|
|
</if>
|
|
|
<if test="mediaId !=null and mediaId != ''">
|
|
|
- AND mediaId = #{mediaId}
|
|
|
+ AND t.mediaId = #{mediaId}
|
|
|
</if>
|
|
|
<if test="startTime !=null and startTime != ''">
|
|
|
- AND uploadYears >= #{startTime}
|
|
|
+ AND t.uploadYears >= #{startTime}
|
|
|
</if>
|
|
|
<if test="endTime !=null and endTime != ''">
|
|
|
- AND uploadYears <= #{endTime}
|
|
|
+ AND t.uploadYears <= #{endTime}
|
|
|
</if>
|
|
|
<if test="createUserName !=null and createUserName != ''">
|
|
|
- AND operateUserId like concat ('%',#{createUserName},'%')
|
|
|
+ AND t.operateUserId like concat ('%',#{createUserName},'%')
|
|
|
</if>
|
|
|
|
|
|
<if test="saleUserIds !=null and saleUserIds.size() >0 ">
|
|
|
- AND (operateUserId in
|
|
|
+ AND (t.operateUserId in
|
|
|
<foreach collection="saleUserIds" item="item" separator=","
|
|
|
open="(" close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
- or saleUserId in
|
|
|
+ or t.saleUserId in
|
|
|
<foreach collection="saleUserIds" item="item" separator=","
|
|
|
open="(" close=")">
|
|
|
#{item}
|
|
@@ -161,7 +173,7 @@
|
|
|
AND (operateUserId = #{createUserId} or saleUserId = #{createUserId})
|
|
|
</if>-->
|
|
|
</where>
|
|
|
- ORDER BY t.update_time DESC,t.projectId
|
|
|
+ ORDER BY t.update_time DESC,t.projectId,t.accountId
|
|
|
</select>
|
|
|
|
|
|
|