Rev 8899 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="in.shop2020.payment.persistence.PaymentMapper"><resultMap type="payment" id="paymentResult"><id property="id" column="id"/><collection property="attributes" javaType="ArrayList" column="id" ofType="paymentAttribute" select="getAttributesForPayment"/></resultMap><insert id="insertPayment" parameterType="payment" useGeneratedKeys="true" keyProperty="id">INSERT INTO payment(gatewayId, userId, merchantTxnId, amount, status, initTimestamp, isDigital)VALUES(#{gatewayId}, #{userId}, #{merchantTxnId}, #{amount}, #{status}, now(), #{isDigital})</insert><insert id="insertPaymentAttribute" parameterType="map">INSERT INTO paymentattribute(payment_id, name, value)VALUES(#{paymentId}, #{name}, #{value})ON DUPLICATE KEY UPDATE value=values(value);</insert><update id="updatePayment" parameterType="payment">UPDATE paymentSET<if test="gatewayPaymentId != null">gatewayPaymentId = #{gatewayPaymentId},</if><if test="sessionId != null">sessionId = #{sessionId},</if><if test="gatewayTxnStatus != null">gatewayTxnStatus = #{gatewayTxnStatus},</if><if test="description != null">description = #{description},</if><if test="gatewayTxnId != null">gatewayTxnId = #{gatewayTxnId},</if><if test="authCode != null">authCode = #{authCode},</if><if test="referenceCode != null">referenceCode = #{referenceCode},</if><if test="gatewayTxnDate != null">gatewayTxnDate = #{gatewayTxnDate},</if><if test="status != null">status = #{status},</if><if test="refundAmount != null">refundAmount = #{refundAmount},</if>errorCode = #{errorCode},successTimestamp = #{successTimestamp},errorTimestamp = #{errorTimestamp},provisionalCaptureTimestamp = #{provisionalCaptureTimestamp}WHERE id=#{id}</update><sql id="selectAllPaymentFields">SELECT * FROM payment</sql><select id="getPayment" parameterType="int" resultMap="paymentResult"><include refid="selectAllPaymentFields"/>WHERE id=#{id}</select><select id="getPaymentForTxn" parameterType="int" resultMap="paymentResult">SELECT * FROM paymentWHERE merchantTxnId=#{merchantTxnId}AND isDigital = 0ORDER BY id DESC</select><select id="getPaymentForRechargeTxn" parameterType="int" resultMap="paymentResult">SELECT * FROM paymentWHERE merchantTxnId=#{merchantTxnId}AND isDigital = 1ORDER BY id DESC</select><sql id="getPaymentsWhereClause"><if test="fromTime != ''">initTimestamp >= #{fromTime}</if><if test="toTime != ''">AND initTimestamp <= #{toTime}</if><!--<if test="toTime != '' && status == 0">AND initTimestamp <= #{toTime}</if><if test="toTime != '' && status != 0">AND (errorTimestamp <= #{toTime} OR successTimestamp <= #{toTime})</if>--><if test="status != -1">AND status=#{status}</if><if test="gatewayId != 0">AND gatewayId = #{gatewayId}</if></sql><select id="getPayments" parameterType="map" resultMap="paymentResult">SELECT * FROM payment<where><include refid="getPaymentsWhereClause"/></where>ORDER BY id</select><select id="getPaymentsByCapturedDate" parameterType="map" resultMap="paymentResult">SELECT * FROM payment<where>status = #{status}<if test="fromTime != ''">AND successTimestamp >= #{fromTime}</if><if test="toTime != ''">AND successTimestamp <= #{toTime}</if><if test="gatewayId != 0">AND gatewayId = #{gatewayId}</if></where>ORDER BY id</select><select id="getPaymentsForUser" parameterType="map" resultMap="paymentResult">SELECT * FROM payment<where><include refid="getPaymentsWhereClause"/>AND userId=#{userId}</where>ORDER BY id</select><select id="getMinMaxPaymentAmount" resultType="hashmap">SELECT MIN(AMOUNT) MIN, MAX(AMOUNT) MAX from payment WHERE status = 2</select><select id="getAttributesForPayment" parameterType="int" resultType="paymentAttribute">SELECT * FROM paymentattribute where payment_id = #{id}</select></mapper>