优化账单修复sql

master
yixian 4 years ago
parent 176a11bf6f
commit 3f8cff5a80

@ -45,8 +45,6 @@ public interface RefundMapper {
@AutoSql(SqlType.SELECT)
JSONObject findByOutRefundId(@Param("out_refund_id") String outRefundNo);
@AutoSql(SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "status=4 and confirm_time is not null and refund_id not in (select refund_id from pmt_transactions where refund_id is not null)")
List<JSONObject> listConfirmedRefundsWithNoTransactions();
JSONObject findRefundInfoByDay(@Param("begin") Date begin, @Param("end") Date end);

@ -758,20 +758,12 @@
</select>
<select id="listOrdersWithNoTransactions" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
o.order_id,
o.channel
FROM pmt_orders o
WHERE o.order_id NOT IN (
SELECT DISTINCT order_id
FROM pmt_transactions
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
SELECT
o.order_id,
o.channel
FROM pmt_orders o
left join pmt_transactions t on t.order_id=t.order_id and t.transaction_type='Credit'
where t.order_id=null and o.status >= 5 AND o.customer_payment_amount > 0
]]>
</select>

@ -128,4 +128,8 @@
</where>
order by create_time desc
</select>
<select id="listConfirmedRefundsWithNoTransactions" resultType="com.alibaba.fastjson.JSONObject">
select r.refund_id,r.order_id from pmt_refunds r left join pmt_transactions t on t.refund_id=r.refund_id
where r.status=4 and confirm_time is not null and t.refund_id is null
</select>
</mapper>
Loading…
Cancel
Save