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.
283 lines
16 KiB
283 lines
16 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 >= #{query.startPayTime} </if>-->
|
|
<!-- <if test="query.endPayTime != null ">-->
|
|
<!-- and pay.pay_date <= #{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 >= #{query.queryStartCheckTime} </if>
|
|
<if test="query.queryEndCheckTime != null ">
|
|
and vtb.create_time <= #{query.queryEndCheckTime} </if>
|
|
<if test="query.queryStartFinishCheckTime != null ">
|
|
and vtb.finished_time >= #{query.queryStartFinishCheckTime} </if>
|
|
<if test="query.queryEndFinishCheckTime != null ">
|
|
and vtb.finished_time <= #{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 >= #{query.queryStartCheckTime} </if>
|
|
<if test="query.queryEndCheckTime != null ">
|
|
and vtb.create_time <= #{query.queryEndCheckTime} </if>
|
|
<if test="query.queryStartFinishCheckTime != null ">
|
|
and vtb.finished_time >= #{query.queryStartFinishCheckTime} </if>
|
|
<if test="query.queryEndFinishCheckTime != null ">
|
|
and vtb.finished_time <= #{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 >= #{query.queryStartCheckTime} </if>
|
|
<if test="query.queryEndCheckTime != null ">
|
|
and vtb.create_time <= #{query.queryEndCheckTime} </if>
|
|
<if test="query.queryStartFinishCheckTime != null ">
|
|
and vtb.finished_time >= #{query.queryStartFinishCheckTime} </if>
|
|
<if test="query.queryEndFinishCheckTime != null ">
|
|
and vtb.finished_time <= #{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.`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`,
|
|
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.`update_time`,
|
|
pay_payment_item.`tenant_id`,
|
|
pay_payment_item.`create_by`,
|
|
pay_payment_item.`update_by`,
|
|
pay_payment_item.`del_flag`,
|
|
pay_payment_item.`policy_item_id`,
|
|
pay_payment_item.`policy_item_code` </sql>
|
|
|
|
<sql id="payBaseWhere">
|
|
<where>
|
|
<if test="query.cancelFlag != null"> and `pay_payment`.`cancel_flag` = #{query.cancelFlag}</if>
|
|
<if test="query.id != null"> and `pay_payment_item`.`id` = #{query.id}</if>
|
|
<if test="query.payType != null and query.payType != ''"> and `pay_payment_item`.`pay_type` = #{query.payType}</if>
|
|
<if test="query.paymentId != null"> and `pay_payment_item`.`payment_id` = #{query.paymentId}</if>
|
|
<if test="query.supplierId != null"> and `pay_payment_item`.`supplier_id` = #{query.supplierId}</if>
|
|
<if test="query.itemPayAmount != null"> and `pay_payment_item`.`item_pay_amount` = #{query.itemPayAmount}</if>
|
|
<if test="query.verificationId != null"> and `pay_payment_item`.`verification_id` = #{query.verificationId}</if>
|
|
<if test="query.verificationSubjectId != null"> and `pay_payment_item`.`verification_subject_id` = #{query.verificationSubjectId}</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` = #{query.activityCode}</if>
|
|
<if test="query.subjectId != null"> and `pay_payment_item`.`subject_id` = #{query.subjectId}</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.createTime != null"> and `pay_payment_item`.`create_time` = #{query.createTime}</if>
|
|
<if test="query.updateTime != null"> and `pay_payment_item`.`update_time` = #{query.updateTime}</if>
|
|
<if test="query.tenantId != null and query.tenantId != ''"> and `pay_payment_item`.`tenant_id` = #{query.tenantId}</if>
|
|
<if test="query.createBy != null and query.createBy != ''"> and `pay_payment_item`.`create_by` = #{query.createBy}</if>
|
|
<if test="query.updateBy != null and query.updateBy != ''"> and `pay_payment_item`.`update_by` = #{query.updateBy}</if>
|
|
<if test="query.delFlag != null and query.delFlag != ''"> and `pay_payment_item`.`del_flag` = #{query.delFlag}</if>
|
|
<if test="query.policyItemId != null"> and `pay_payment_item`.`policy_item_id` = #{query.policyItemId}</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
|
|
<include refid="payBaseWhere"></include>
|
|
limit {pageInfo.startIndex},{pageInfo.size}
|
|
</select>
|
|
|
|
<select id="countPayItemList" resultType="java.lang.Long">
|
|
|
|
</select>
|
|
<select id="sumPayItemListAmt" resultType="java.math.BigDecimal">
|
|
|
|
</select>
|
|
</mapper>
|
|
|
|
|