You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 lines
17 KiB

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qs.serve.modules.vtb.mapper.VtbVerForPayReportMapper">
<select id="pageVerificationCheck" resultType="com.qs.serve.modules.vtb.entity.dto.VtbVerificationDTO">
SELECT
vtb.id as verificationId,
vtb.verification_code,
vtb.create_time,
vtb.finished_time,
vtb.user_code,
vtb.user_name,
vtb.supplier_code,
vtb.supplier_name,
vtb.way_title,
IFNULL( vtb.amount, 0 ) AS amount,
IFNULL(pay_item1.pay_amt,0) as pay_amount,
IFNULL(pay_item1.not_pay_amt,0) as not_pay_amount,
IFNULL( vtb.amount, 0 ) - IFNULL(pay_item1.pay_amt,0) - IFNULL(pay_item1.not_pay_amt,0) as unpay_amount,
cost.`code` as costApplyCode,
cost.charge_theme,
cost.submit_time,
act.id as activityId,
act.cost_pass_time,
act.activity_code,
act.act_title
FROM
vtb_verification vtb
LEFT JOIN tbs_cost_apply cost ON cost.id = vtb.cost_apply_id
LEFT JOIN tbs_activity act ON act.id = vtb.activity_id
left join bms_supplier sup on vtb.supplier_id = sup.id
LEFT JOIN (
SELECT
pay.verification_id,
sum( Case pay.pay_type when 'pay' Then pay.item_pay_amount else 0 end ) AS pay_amt ,
sum( Case pay.pay_type when 'unPay' Then pay.item_pay_amount else 0 end ) AS not_pay_amt
FROM
pay_payment_item pay
WHERE pay.del_flag = 0
<!-- <if test="query.startPayTime != null ">-->
<!-- and pay.pay_date &gt;= #{query.startPayTime} </if>-->
<!-- <if test="query.endPayTime != null ">-->
<!-- and pay.pay_date &lt;= #{query.endPayTime} </if>-->
<if test="query.vtbIds !=null and query.vtbIds.size > 0">
and pay.verification_id in
<foreach collection="query.vtbIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
GROUP BY
pay.verification_id
) pay_item1 ON pay_item1.verification_id = vtb.id
WHERE
vtb.del_flag = 0
AND vtb.verification_state = 1
AND act.del_flag = 0
AND act.cancel_flag = 0
AND cost.del_flag = 0
AND cost.cancel_flag = 0
<if test="query.vtbIds !=null and query.vtbIds.size > 0">
and vtb.id in
<foreach collection="query.vtbIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
<if test="query.queryStartCheckTime != null ">
and vtb.create_time &gt;= #{query.queryStartCheckTime} </if>
<if test="query.queryEndCheckTime != null ">
and vtb.create_time &lt;= #{query.queryEndCheckTime} </if>
<if test="query.queryStartFinishCheckTime != null ">
and vtb.finished_time &gt;= #{query.queryStartFinishCheckTime} </if>
<if test="query.queryEndFinishCheckTime != null ">
and vtb.finished_time &lt;= #{query.queryEndFinishCheckTime} </if>
<if test="query.verificationCode != null and query.verificationCode != ''"> and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')</if>
<if test="query.supplierCode != null and query.supplierCode != ''"> and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')</if>
<if test="query.supplierName != null and query.supplierName != ''"> and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')</if>
<if test="query.userCode != null and query.userCode != ''"> and `vtb`.`user_code` like concat('%',#{query.userCode},'%')</if>
<if test="query.userName != null and query.userName != ''"> and `vtb`.`user_name` like concat('%',#{query.userName},'%')</if>
<if test="query.wayTitle != null and query.wayTitle != ''"> and `vtb`.`way_title` = #{query.wayTitle}</if>
<if test="query.costApplyCode != null and query.costApplyCode != ''"> and `cost`.`code` like concat('%',#{query.costApplyCode},'%')</if>
<if test="query.chargeTheme != null and query.chargeTheme != ''"> and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')</if>
<if test="query.activityCode != null and query.activityCode != ''"> and `act`.`activity_code` like concat('%',#{query.activityCode},'%')</if>
<if test="query.actTitle != null and query.actTitle != ''"> and `act`.`act_title` like concat('%',#{query.actTitle},'%')</if>
<if test="query.stopSupplierFlag != null and query.stopSupplierFlag != ''"> and `sup`.`stop_flag` = #{query.stopSupplierFlag}</if>
<if test="query.openPage!=null and query.openPage==1">
limit #{query.startRow},#{query.pageSize}
</if>
</select>
<select id="countVerificationCheck" resultType="java.lang.Long">
SELECT
count(1)
FROM
vtb_verification vtb
LEFT JOIN tbs_cost_apply cost ON cost.id = vtb.cost_apply_id
LEFT JOIN tbs_activity act ON act.id = vtb.activity_id
left join bms_supplier sup on vtb.supplier_id = sup.id
WHERE
vtb.del_flag = 0
AND vtb.verification_state = 1
AND act.del_flag = 0
AND act.cancel_flag = 0
AND cost.del_flag = 0
AND cost.cancel_flag = 0
<if test="query.vtbIds !=null and query.vtbIds.size > 0">
and vtb.id in
<foreach collection="query.vtbIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
<if test="query.queryStartCheckTime != null ">
and vtb.create_time &gt;= #{query.queryStartCheckTime} </if>
<if test="query.queryEndCheckTime != null ">
and vtb.create_time &lt;= #{query.queryEndCheckTime} </if>
<if test="query.queryStartFinishCheckTime != null ">
and vtb.finished_time &gt;= #{query.queryStartFinishCheckTime} </if>
<if test="query.queryEndFinishCheckTime != null ">
and vtb.finished_time &lt;= #{query.queryEndFinishCheckTime} </if>
<if test="query.verificationCode != null and query.verificationCode != ''"> and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')</if>
<if test="query.supplierCode != null and query.supplierCode != ''"> and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')</if>
<if test="query.supplierName != null and query.supplierName != ''"> and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')</if>
<if test="query.userCode != null and query.userCode != ''"> and `vtb`.`user_code` like concat('%',#{query.userCode},'%')</if>
<if test="query.userName != null and query.userName != ''"> and `vtb`.`user_name` like concat('%',#{query.userName},'%')</if>
<if test="query.wayTitle != null and query.wayTitle != ''"> and `vtb`.`way_title` = #{query.wayTitle}</if>
<if test="query.centerType != null and query.centerType != ''"> and `vtb`.`way_title` = #{query.centerType}</if>
<if test="query.costApplyCode != null and query.costApplyCode != ''"> and `cost`.`code` like concat('%',#{query.costApplyCode},'%')</if>
<if test="query.chargeTheme != null and query.chargeTheme != ''"> and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')</if>
<if test="query.activityCode != null and query.activityCode != ''"> and `act`.`activity_code` like concat('%',#{query.activityCode},'%')</if>
<if test="query.actTitle != null and query.actTitle != ''"> and `act`.`act_title` like concat('%',#{query.actTitle},'%')</if>
<if test="query.stopSupplierFlag != null and query.stopSupplierFlag != ''"> and `sup`.`stop_flag` = #{query.stopSupplierFlag}</if>
</select>
<select id="getVerificationIdsForPay" resultType="java.lang.Long">
SELECT
vtb.id
FROM
vtb_verification vtb
LEFT JOIN tbs_cost_apply cost ON cost.id = vtb.cost_apply_id
LEFT JOIN tbs_activity act ON act.id = vtb.activity_id
left join bms_supplier sup on vtb.supplier_id = sup.id
WHERE
vtb.del_flag = 0
AND vtb.verification_state = 1
AND act.del_flag = 0
AND act.cancel_flag = 0
AND cost.del_flag = 0
AND cost.cancel_flag = 0
<if test="query.vtbIds !=null and query.vtbIds.size > 0">
and vtb.id in
<foreach collection="query.vtbIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
<if test="query.queryStartCheckTime != null ">
and vtb.create_time &gt;= #{query.queryStartCheckTime} </if>
<if test="query.queryEndCheckTime != null ">
and vtb.create_time &lt;= #{query.queryEndCheckTime} </if>
<if test="query.queryStartFinishCheckTime != null ">
and vtb.finished_time &gt;= #{query.queryStartFinishCheckTime} </if>
<if test="query.queryEndFinishCheckTime != null ">
and vtb.finished_time &lt;= #{query.queryEndFinishCheckTime} </if>
<if test="query.verificationCode != null and query.verificationCode != ''"> and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')</if>
<if test="query.supplierCode != null and query.supplierCode != ''"> and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')</if>
<if test="query.supplierName != null and query.supplierName != ''"> and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')</if>
<if test="query.userCode != null and query.userCode != ''"> and `vtb`.`user_code` like concat('%',#{query.userCode},'%')</if>
<if test="query.userName != null and query.userName != ''"> and `vtb`.`user_name` like concat('%',#{query.userName},'%')</if>
<if test="query.wayTitle != null and query.wayTitle != ''"> and `vtb`.`way_title` = #{query.wayTitle}</if>
<if test="query.costApplyCode != null and query.costApplyCode != ''"> and `cost`.`code` like concat('%',#{query.costApplyCode},'%')</if>
<if test="query.chargeTheme != null and query.chargeTheme != ''"> and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')</if>
<if test="query.activityCode != null and query.activityCode != ''"> and `act`.`activity_code` like concat('%',#{query.activityCode},'%')</if>
<if test="query.actTitle != null and query.actTitle != ''"> and `act`.`act_title` like concat('%',#{query.actTitle},'%')</if>
<if test="query.stopSupplierFlag != null and query.stopSupplierFlag != ''"> and `sup`.`stop_flag` = #{query.stopSupplierFlag}</if>
<if test="query.openPage!=null and query.openPage==1">
limit #{query.startRow},#{query.pageSize}
</if>
</select>
<select id="countActJoinCheckJoinPay" resultType="java.lang.Long">
</select>
<sql id="payPaymentItemSql">
pay_payment_item.`id`,
pay_payment_item.`verification_main_code`,
pay_payment_item.`verification_code`,
pay_payment.`pay_code`,
pay_payment_item.`pay_time`,
pay_payment_item.`pay_date`,
pay_payment_item.`bill_number`,
pay_payment_item.`erp_id`,
pay_payment_item.`pay_type`,
pay_payment_item.`payment_id`,
pay_payment_item.`supplier_id`,
pay_payment_item.`item_pay_amount`,
pay_payment_item.`verification_id`,
pay_payment_item.`verification_subject_id`,
pay_payment_item.`cost_apply_id`,
cost.`code` as `cost_apply_code`,
cost.`charge_theme` as `cost_apply_title`,
act.`act_title` as `activity_title`,
pay_payment_item.`activity_id`,
pay_payment_item.`activity_code`,
pay_payment_item.`subject_id`,
pay_payment_item.`subject_code`,
pay_payment_item.`subject_name`,
pay_payment_item.`remark`,
pay_payment_item.`create_time`,
pay_payment_item.`policy_item_id`,
pay_payment_item.`policy_item_code` </sql>
<sql id="payBaseWhere">
<where>
and pay_payment_item.del_flag = 0
and vtb.del_flag = 0
and act.del_flag = 0
and act.cancel_flag = 0
and pay_payment.del_flag = 0
<if test="query.payType != null and query.payType != ''"> and `pay_payment_item`.`pay_type` = #{query.payType}</if>
<if test="query.payCode != null and query.payCode != ''"> and `pay_payment`.`pay_code` like concat('%',#{query.payCode},'%') </if>
<if test="query.paymentId != null"> and `pay_payment_item`.`payment_id` = #{query.paymentId}</if>
<if test="query.costApplyCode != null and query.costApplyCode != ''"> and `cost`.`code` like concat('%',#{query.costApplyCode},'%') </if>
<if test="query.supplierCode != null and query.supplierCode != ''"> and `pay_payment`.`supplier_code` like concat('%',#{query.supplierCode},'%') </if>
<if test="query.supplierName != null and query.supplierName != ''"> and `pay_payment`.`supplier_name` like concat('%',#{query.supplierName},'%') </if>
<if test="query.userCode != null and query.userCode != ''"> and `pay_payment`.`user_code` like concat('%',#{query.userCode},'%') </if>
<if test="query.userName != null and query.userName != ''"> and `pay_payment`.`user_name` like concat('%',#{query.userName},'%') </if>
<if test="query.costApplyTitle != null and query.costApplyTitle != ''"> and `cost`.`charge_theme` like concat('%',#{query.costApplyTitle},'%') </if>
<if test="query.activityTitle != null and query.activityTitle != ''"> and `act`.`act_title` like concat('%',#{query.activityTitle},'%') </if>
<if test="query.supplierId != null"> and `pay_payment_item`.`supplier_id` = #{query.supplierId}</if>
<if test="query.costApplyId != null"> and `pay_payment_item`.`cost_apply_id` = #{query.costApplyId}</if>
<if test="query.activityId != null"> and `pay_payment_item`.`activity_id` = #{query.activityId}</if>
<if test="query.activityCode != null and query.activityCode != ''"> and `pay_payment_item`.`activity_code` like concat('%',#{query.activityCode},'%') </if>
<if test="query.subjectCode != null and query.subjectCode != ''"> and `pay_payment_item`.`subject_code` = #{query.subjectCode}</if>
<if test="query.subjectName != null and query.subjectName != ''"> and `pay_payment_item`.`subject_name` = #{query.subjectName}</if>
<if test="query.policyItemCode != null and query.policyItemCode != ''"> and `pay_payment_item`.`policy_item_code` = #{query.policyItemCode}</if>
<if test="query.costApplyIds!=null and query.costApplyIds.size > 0">
and `pay_payment_item`.`cost_apply_id` in
<foreach collection="query.costApplyIds" item="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
</where>
</sql>
<select id="selectPayItemList" resultType="com.qs.serve.modules.vtb.entity.dto.PayPaymentItemExtend">
SELECT <include refid="payPaymentItemSql"/>
FROM `pay_payment_item` `pay_payment_item`
left join pay_payment on pay_payment_item.payment_id = pay_payment.id
left join vtb_verification vtb on pay_payment_item.verification_id = vtb.id
left join tbs_activity act on act.id = vtb.activity_id
left join tbs_cost_apply cost on cost.id = act.cost_apply_id
<include refid="payBaseWhere"></include>
limit #{pageInfo.startIndex},#{pageInfo.size}
</select>
<select id="countPayItemList" resultType="java.lang.Long">
SELECT count(1)
FROM `pay_payment_item` `pay_payment_item`
left join pay_payment on pay_payment_item.payment_id = pay_payment.id
left join vtb_verification vtb on pay_payment_item.verification_id = vtb.id
left join tbs_activity act on act.id = vtb.activity_id
left join tbs_cost_apply cost on cost.id = act.cost_apply_id
<include refid="payBaseWhere"></include>
</select>
<select id="sumPayItemListAmt" resultType="java.math.BigDecimal">
SELECT SUM(pay_payment_item.item_pay_amount)
FROM `pay_payment_item` `pay_payment_item`
left join pay_payment on pay_payment_item.payment_id = pay_payment.id
left join vtb_verification vtb on pay_payment_item.verification_id = vtb.id
left join tbs_activity act on act.id = vtb.activity_id
left join tbs_cost_apply cost on cost.id = act.cost_apply_id
<include refid="payBaseWhere"></include>
</select>
</mapper>