|
@@ -209,5 +209,65 @@
|
|
|
LEFT JOIN bytesailing_account.account_management am ON arw.account_management_id = am.id
|
|
|
WHERE c.id = #{contractId}
|
|
|
</select>
|
|
|
+ <select id="getContractAndSamplePagez" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
|
|
|
+ SELECT
|
|
|
+ t1.id,
|
|
|
+ t1.sell_corporation_id,
|
|
|
+ t1.contract_type,
|
|
|
+ t1.`code`,
|
|
|
+ t1.buy_corporation_id,
|
|
|
+ t1.version,
|
|
|
+ t1.amount,
|
|
|
+ t1.create_user,
|
|
|
+ t1.create_time,
|
|
|
+ t1.refund_status,
|
|
|
+ t1.`status`,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ IFNULL( SUM( IFNULL( cc.money, 0 ) * IFNULL( arw.rate, 1 )), 0 )
|
|
|
+ FROM
|
|
|
+ claim_contract cc
|
|
|
+ LEFT JOIN claim c ON cc.claim_id = c.id
|
|
|
+ LEFT JOIN bytesailing_account.account_running_water arw ON c.business_id = arw.id
|
|
|
+ WHERE
|
|
|
+ cc.contract_id = t1.id
|
|
|
+ ) AS sumClaimMoney
|
|
|
+ FROM
|
|
|
+ contract t1
|
|
|
+ ${ew.customSqlSegment}
|
|
|
+ UNION
|
|
|
+ SELECT
|
|
|
+ t1.id,
|
|
|
+ t1.sell_corporation_id,
|
|
|
+ 3 AS contract_type,
|
|
|
+ t1.`code`,
|
|
|
+ t1.buy_corporation_id,
|
|
|
+ t1.versions AS version,
|
|
|
+ t1.amount,
|
|
|
+ t1.sumClaimMoney,
|
|
|
+ t1.create_user,
|
|
|
+ t1.create_time,
|
|
|
+ t1.`status`,
|
|
|
+ IF
|
|
|
+ ( sumClaimMoney >= t1.amount, 20, IF ( sumClaimMoney != 0, 10, 0 ) ) AS refund_status
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ t1.*,
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ IFNULL( SUM( IFNULL( cc.money, 0 ) * IFNULL( arw.rate, 1 )), 0 )
|
|
|
+ FROM
|
|
|
+ claim_contract cc
|
|
|
+ LEFT JOIN claim c ON cc.claim_id = c.id
|
|
|
+ LEFT JOIN bytesailing_account.account_running_water arw ON c.business_id = arw.id
|
|
|
+ WHERE
|
|
|
+ cc.contract_id = t1.id
|
|
|
+ ) AS sumClaimMoney
|
|
|
+ FROM
|
|
|
+ sample t1
|
|
|
+ ) AS t1
|
|
|
+ ${ew.customSqlSegment}
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|