| | |
| | | ORDER BY create_time DESC, id DESC |
| | | </select> |
| | | |
| | | <select id="selectExportList" resultType="com.ruoyi.account.api.dto.ChargingCardExcelDTO"> |
| | | SELECT card_no, |
| | | balance, |
| | | status |
| | | FROM t_charging_card |
| | | WHERE del_flag = 0 |
| | | <if test="query.cardNo != null and query.cardNo != ''"> |
| | | AND card_no LIKE CONCAT('%', #{query.cardNo}, '%') |
| | | </if> |
| | | <if test="query.status != null"> |
| | | AND status = #{query.status} |
| | | </if> |
| | | ORDER BY create_time DESC, id DESC |
| | | </select> |
| | | |
| | | <select id="countByCardNo" resultType="int"> |
| | | SELECT COUNT(1) |
| | | FROM t_charging_card |
| | | WHERE card_no = #{cardNo} |
| | | <if test="excludeId != null"> |
| | | AND id != #{excludeId} |
| | | </if> |
| | | </select> |
| | | |
| | | <update id="adjustBalance"> |
| | | UPDATE t_charging_card |
| | | SET balance = balance |
| | | <choose> |
| | | <when test="type == 1">+ #{amount}</when> |
| | | <otherwise>- #{amount}</otherwise> |
| | | </choose>, |
| | | update_time = NOW(), |
| | | update_by = #{updateBy} |
| | | WHERE del_flag = 0 |
| | | AND id IN |
| | | <foreach collection="ids" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | <choose> |
| | | <when test="type == 1"> |
| | | AND balance <= #{maxAmount} - #{amount} |
| | | </when> |
| | | <otherwise> |
| | | AND balance >= #{amount} |
| | | </otherwise> |
| | | </choose> |
| | | </update> |
| | | |
| | | <insert id="insertBalanceRecord"> |
| | | INSERT INTO t_charging_card_balance_record |
| | | (card_id, change_type, amount, remark, create_time, create_by) |
| | | VALUES |
| | | (#{cardId}, #{type}, #{amount}, #{remark}, NOW(), #{createBy}) |
| | | </insert> |
| | | |
| | | </mapper> |