SELECT
order_serial,
trade_serial,
trade_type,
income_expend_type,
pay_total,
pay_time,
TRUNCATE( balance,2) balance
FROM (
SELECT tabletem.*,(@balance :=
CASE
WHEN income_expend_type = 1
THEN @balance + pay_total
ELSE @balance - pay_total
END
) balance
FROM
(
SELECT
order_serial,
trade_serial,
trade_type,
income_expend_type,
pay_total,
pay_time
FROM
aflc_order_payment
WHERE user_id = #{vo.userId,jdbcType=VARCHAR}
AND pay_way='AF0041801'
UNION ALL
SELECT
order_serial,
trade_serial,
trade_type,
income_expend_type,
pay_total,
pay_time
FROM
aflc_order_payment
WHERE user_id = #{vo.userId,jdbcType=VARCHAR}
AND trade_type IN ('AF109010106','AF01546')
UNION ALL
SELECT
'' AS order_serial,
trade_serial AS trade_serial,
'AF01518' trade_type,
'1' income_expend_type,
reward_amount AS pay_total,
trade_time AS pay_time
FROM aflc_driver_ordernum_detail WHERE driver_id=#{vo.userId,jdbcType=VARCHAR}
) tabletem,
(SELECT @balance := 0.0) AS tbIndex
ORDER BY pay_time ASC
)temtable
WHERE 1 = 1
<include refid="findShipperMywalletDetailPageListBySQLWhere"></include>
<if test="currentPage==1">
limit 0, #{pageSize,jdbcType=INTEGER}
</if>
<if test="currentPage>1">
limit ${(currentPage-1)*pageSize},${pageSize}
</if>
用变量 := 赋值
最新推荐文章于 2021-08-15 21:32:51 发布