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
and pay.verification_id in
#{selectId}
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
and vtb.id in
#{selectId}
and vtb.create_time >= #{query.queryStartCheckTime}
and vtb.create_time <= #{query.queryEndCheckTime}
and vtb.finished_time >= #{query.queryStartFinishCheckTime}
and vtb.finished_time <= #{query.queryEndFinishCheckTime}
and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')
and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')
and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')
and `vtb`.`user_code` like concat('%',#{query.userCode},'%')
and `vtb`.`user_name` like concat('%',#{query.userName},'%')
and `vtb`.`way_title` = #{query.wayTitle}
and `cost`.`code` like concat('%',#{query.costApplyCode},'%')
and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')
and `act`.`activity_code` like concat('%',#{query.activityCode},'%')
and `act`.`act_title` like concat('%',#{query.actTitle},'%')
and `sup`.`stop_flag` = #{query.stopSupplierFlag}
limit #{query.startRow},#{query.pageSize}
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
and vtb.id in
#{selectId}
and vtb.create_time >= #{query.queryStartCheckTime}
and vtb.create_time <= #{query.queryEndCheckTime}
and vtb.finished_time >= #{query.queryStartFinishCheckTime}
and vtb.finished_time <= #{query.queryEndFinishCheckTime}
and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')
and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')
and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')
and `vtb`.`user_code` like concat('%',#{query.userCode},'%')
and `vtb`.`user_name` like concat('%',#{query.userName},'%')
and `vtb`.`way_title` = #{query.wayTitle}
and `vtb`.`way_title` = #{query.centerType}
and `cost`.`code` like concat('%',#{query.costApplyCode},'%')
and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')
and `act`.`activity_code` like concat('%',#{query.activityCode},'%')
and `act`.`act_title` like concat('%',#{query.actTitle},'%')
and `sup`.`stop_flag` = #{query.stopSupplierFlag}
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
and vtb.id in
#{selectId}
and vtb.create_time >= #{query.queryStartCheckTime}
and vtb.create_time <= #{query.queryEndCheckTime}
and vtb.finished_time >= #{query.queryStartFinishCheckTime}
and vtb.finished_time <= #{query.queryEndFinishCheckTime}
and `vtb`.`verification_code` like concat('%',#{query.verificationCode},'%')
and `vtb`.`supplier_code` like concat('%',#{query.supplierCode},'%')
and `vtb`.`supplier_name` like concat('%',#{query.supplierName},'%')
and `vtb`.`user_code` like concat('%',#{query.userCode},'%')
and `vtb`.`user_name` like concat('%',#{query.userName},'%')
and `vtb`.`way_title` = #{query.wayTitle}
and `cost`.`code` like concat('%',#{query.costApplyCode},'%')
and `cost`.`charge_theme` like concat('%',#{query.chargeTheme},'%')
and `act`.`activity_code` like concat('%',#{query.activityCode},'%')
and `act`.`act_title` like concat('%',#{query.actTitle},'%')
and `sup`.`stop_flag` = #{query.stopSupplierFlag}
limit #{query.startRow},#{query.pageSize}
pay_payment_item.`id`,
pay_payment_item.`verification_main_code`,
pay_payment_item.`verification_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`
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
and `pay_payment_item`.`pay_type` = #{query.payType}
and `pay_payment_item`.`payment_id` = #{query.paymentId}
and `cost`.`code` like concat('%',#{query.costApplyCode},'%')
and `cost`.`charge_theme` like concat('%',#{query.costApplyTitle},'%')
and `act`.`act_title` like concat('%',#{query.activityTitle},'%')
and `pay_payment_item`.`supplier_id` = #{query.supplierId}
and `pay_payment_item`.`cost_apply_id` = #{query.costApplyId}
and `pay_payment_item`.`activity_id` = #{query.activityId}
and `pay_payment_item`.`activity_code` like concat('%',#{query.activityCode},'%')
and `pay_payment_item`.`subject_code` = #{query.subjectCode}
and `pay_payment_item`.`subject_name` = #{query.subjectName}
and `pay_payment_item`.`policy_item_code` = #{query.policyItemCode}
and `pay_payment_item`.`cost_apply_id` in
#{selectId}
SELECT
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
limit #{pageInfo.startIndex},#{pageInfo.size}
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
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