<?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="com.kmall.admin.dao.PinganPayOrderDao">

	<resultMap type="com.kmall.common.utils.pingan.dto.PinganPayOrderDto" id="pinganPayOrderMap">
		<result property="id" column="id"/>
		<result property="outNo" column="out_no"/>
		<result property="pmtName" column="pmt_name"/>
		<result property="pmtTag" column="pmt_tag"/>
		<result property="ordMctId" column="ord_mct_id"/>
		<result property="ordShopId" column="ord_shop_id"/>
		<result property="ordCurrency" column="ord_currency"/>
		<result property="currencySign" column="currency_sign"/>
		<result property="ordNo" column="ord_no"/>
		<result property="ordType" column="ord_type"/>
		<result property="originalAmount" column="original_amount"/>
		<result property="discountAmount" column="discount_amount"/>
		<result property="ignoreAmount" column="ignore_amount"/>
		<result property="tradeAccount" column="trade_account"/>
		<result property="tradeNo" column="trade_no"/>
		<result property="tradeAmount" column="trade_amount"/>
		<result property="tradeQrcode" column="trade_qrcode"/>
		<result property="amount" column="amount"/>
		<result property="tradeTime" column="trade_time"/>
		<result property="tradePayTime" column="trade_pay_time"/>
		<result property="payTime" column="pay_time"/>
		<result property="status" column="status"/>
		<result property="tradeResult" column="trade_result"/>
		<result property="jsapiPayUrl" column="jsapi_pay_url"/>
		<result property="randStr" column="rand_str"/>
		<result property="appid" column="appId"/>
		<result property="timeStamp" column="timeStamp"/>
		<result property="noncestr" column="nonceStr"/>
		<result property="signtype" column="signType"/>
		<result property="prepayId" column="prepay_id"/>
		<result property="paysign" column="paySign"/>
		<result property="createrSn" column="creater_sn"/>
		<result property="createTime" column="create_time"/>
		<result property="moderSn" column="moder_sn"/>
		<result property="modTime" column="mod_time"/>
		<result property="tstm" column="tstm"/>
	</resultMap>

	<select id="queryObject" resultType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		select
			`id`,
			`out_no`,
			`pmt_name`,
			`pmt_tag`,
			`ord_mct_id`,
			`ord_shop_id`,
			`ord_currency`,
			`currency_sign`,
			`ord_no`,
			`ord_type`,
			`original_amount`,
			`discount_amount`,
			`ignore_amount`,
			`trade_account`,
			`trade_no`,
			`trade_amount`,
			`trade_qrcode`,
			`amount`,
			`trade_time`,
			`trade_pay_time`,
			`pay_time`,
			`status`,
			`trade_result`,
			`jsapi_pay_url`,
			`rand_str`,
			`appId`,
			`timeStamp`,
			`nonceStr`,
			`signType`,
			`prepay_id`,
			`paySign`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from pingan_pay_order
		where id = #{id}
	</select>

	<select id="queryByOutNo" resultType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		select
			`id`,
			`out_no`,
			`pmt_name`,
			`pmt_tag`,
			`ord_mct_id`,
			`ord_shop_id`,
			`ord_currency`,
			`currency_sign`,
			`ord_no`,
			`ord_type`,
			`original_amount`,
			`discount_amount`,
			`ignore_amount`,
			`trade_account`,
			`trade_no`,
			`trade_amount`,
			`trade_qrcode`,
			`amount`,
			`trade_time`,
			`trade_pay_time`,
			`pay_time`,
			`status`,
			`trade_result`,
			`jsapi_pay_url`,
			`rand_str`,
			`appId`,
			`timeStamp`,
			`nonceStr`,
			`signType`,
			`prepay_id`,
			`paySign`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`
		from pingan_pay_order
		where out_no = #{outNo}
	</select>

	<select id="queryList" resultType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		select
		`id`,
		`out_no`,
		`pmt_name`,
		`pmt_tag`,
		`ord_mct_id`,
		`ord_shop_id`,
		`ord_currency`,
		`currency_sign`,
		`ord_no`,
		`ord_type`,
		`original_amount`,
		`discount_amount`,
		`ignore_amount`,
		`trade_account`,
		`trade_no`,
		`trade_amount`,
		`trade_qrcode`,
		`amount`,
		`trade_time`,
		`trade_pay_time`,
		`pay_time`,
		`status`,
		`trade_result`,
		`jsapi_pay_url`,
		`rand_str`,
		`appId`,
		`timeStamp`,
		`nonceStr`,
		`signType`,
		`prepay_id`,
		`paySign`,
		`creater_sn`,
		`create_time`,
		`moder_sn`,
		`mod_time`,
		`tstm`
		from pingan_pay_order
		WHERE 1=1
		<if test="name != null and name.trim() != ''">
			AND name LIKE concat('%',#{name},'%')
		</if>
		<choose>
			<when test="sidx != null and sidx.trim() != ''">
				order by ${sidx} ${order}
			</when>
			<otherwise>
				order by id desc
			</otherwise>
		</choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>

	<select id="queryTotal" resultType="int">
		select count(*) from pingan_pay_order
		WHERE 1=1
		<if test="name != null and name.trim() != ''">
			AND name LIKE concat('%',#{name},'%')
		</if>
	</select>

	<insert id="save" parameterType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		insert into pingan_pay_order(
			`id`,
			`out_no`,
			`pmt_name`,
			`pmt_tag`,
			`ord_mct_id`,
			`ord_shop_id`,
			`ord_currency`,
			`currency_sign`,
			`ord_no`,
			`ord_type`,
			`original_amount`,
			`discount_amount`,
			`ignore_amount`,
			`trade_account`,
			`trade_no`,
			`trade_amount`,
			`trade_qrcode`,
			`amount`,
			`trade_time`,
			`trade_pay_time`,
			`pay_time`,
			`status`,
			`trade_result`,
			`jsapi_pay_url`,
			`rand_str`,
			`appId`,
			`timeStamp`,
			`nonceStr`,
			`signType`,
			`prepay_id`,
			`paySign`,
			`creater_sn`,
			`create_time`,
			`moder_sn`,
			`mod_time`,
			`tstm`)
		values(
			#{id},
			#{outNo},
			#{pmtName},
			#{pmtTag},
			#{ordMctId},
			#{ordShopId},
			#{ordCurrency},
			#{currencySign},
			#{ordNo},
			#{ordType},
			#{originalAmount},
			#{discountAmount},
			#{ignoreAmount},
			#{tradeAccount},
			#{tradeNo},
			#{tradeAmount},
			#{tradeQrcode},
			#{amount},
			#{tradeTime},
			#{tradePayTime},
			#{payTime},
			#{status},
			#{tradeResult},
			#{jsapiPayUrl},
			#{randStr},
			#{appid},
			#{timeStamp},
			#{noncestr},
			#{signtype},
			#{prepayId},
			#{paysign},
			#{createrSn},
			#{createTime},
			#{moderSn},
			#{modTime},
			#{tstm})
	</insert>

	<update id="update" parameterType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		update pingan_pay_order
		<set>
			<if test="outNo != null">`out_no` = #{outNo}, </if>
			<if test="pmtName != null">`pmt_name` = #{pmtName}, </if>
			<if test="pmtTag != null">`pmt_tag` = #{pmtTag}, </if>
			<if test="ordMctId != null">`ord_mct_id` = #{ordMctId}, </if>
			<if test="ordShopId != null">`ord_currency` = #{ordShopId}, </if>
			<if test="ordCurrency != null">`ord_shop_id` = #{ordCurrency}, </if>
			<if test="currencySign != null">`currency_sign` = #{currencySign}, </if>
			<if test="ordNo != null">`ord_no` = #{ordNo}, </if>
			<if test="ordType != null">`ord_type` = #{ordType}, </if>
			<if test="originalAmount != null">`original_amount` = #{originalAmount}, </if>
			<if test="discountAmount != null">`discount_amount` = #{discountAmount}, </if>
			<if test="ignoreAmount != null">`ignore_amount` = #{ignoreAmount}, </if>
			<if test="tradeAccount != null">`trade_account` = #{tradeAccount}, </if>
			<if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
			<if test="tradeAmount != null">`trade_amount` = #{tradeAmount}, </if>
			<if test="tradeQrcode != null">`trade_qrcode` = #{tradeQrcode}, </if>
			<if test="amount != null">`amount` = #{amount}, </if>
			<if test="tradeTime != null">`trade_time` = #{tradeTime}, </if>
			<if test="tradePayTime != null">`trade_pay_time` = #{tradePayTime}, </if>
			<if test="payTime != null">`pay_time` = #{payTime}, </if>
			<if test="status != null">`status` = #{status}, </if>
			<if test="tradeResult != null">`trade_result` = #{tradeResult}, </if>
			<if test="jsapiPayUrl != null">`jsapi_pay_url` = #{jsapiPayUrl}, </if>
			<if test="randStr != null">`rand_str` = #{randStr}, </if>
			<if test="appid != null">`appId` = #{appid}, </if>
			<if test="timeStamp != null">`timeStamp` = #{timeStamp}, </if>
			<if test="noncestr != null">`nonceStr` = #{noncestr}, </if>
			<if test="signtype != null">`signType` = #{signtype}, </if>
			<if test="prepayId != null">`prepay_id` = #{prepayId}, </if>
			<if test="paysign != null">`paySign` = #{paysign}, </if>
			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
			<if test="modTime != null">`mod_time` = #{modTime}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where id = #{id}
	</update>

	<update id="updateByOutNo" parameterType="com.kmall.common.utils.pingan.dto.PinganPayOrderDto">
		update pingan_pay_order
		<set>
			<if test="pmtName != null">`pmt_name` = #{pmtName}, </if>
			<if test="pmtTag != null">`pmt_tag` = #{pmtTag}, </if>
			<if test="ordMctId != null">`ord_mct_id` = #{ordMctId}, </if>
			<if test="ordShopId != null">`ord_currency` = #{ordShopId}, </if>
			<if test="ordCurrency != null">`ord_shop_id` = #{ordCurrency}, </if>
			<if test="currencySign != null">`currency_sign` = #{currencySign}, </if>
			<if test="ordNo != null">`ord_no` = #{ordNo}, </if>
			<if test="ordType != null">`ord_type` = #{ordType}, </if>
			<if test="originalAmount != null">`original_amount` = #{originalAmount}, </if>
			<if test="discountAmount != null">`discount_amount` = #{discountAmount}, </if>
			<if test="ignoreAmount != null">`ignore_amount` = #{ignoreAmount}, </if>
			<if test="tradeAccount != null">`trade_account` = #{tradeAccount}, </if>
			<if test="tradeNo != null">`trade_no` = #{tradeNo}, </if>
			<if test="tradeAmount != null">`trade_amount` = #{tradeAmount}, </if>
			<if test="tradeQrcode != null">`trade_qrcode` = #{tradeQrcode}, </if>
			<if test="amount != null">`amount` = #{amount}, </if>
			<if test="tradeTime != null">`trade_time` = #{tradeTime}, </if>
			<if test="tradePayTime != null">`trade_pay_time` = #{tradePayTime}, </if>
			<if test="payTime != null">`pay_time` = #{payTime}, </if>
			<if test="status != null">`status` = #{status}, </if>
			<if test="tradeResult != null">`trade_result` = #{tradeResult}, </if>
			<if test="jsapiPayUrl != null">`jsapi_pay_url` = #{jsapiPayUrl}, </if>
			<if test="randStr != null">`rand_str` = #{randStr}, </if>
			<if test="appid != null">`appId` = #{appid}, </if>
			<if test="timeStamp != null">`timeStamp` = #{timeStamp}, </if>
			<if test="noncestr != null">`nonceStr` = #{noncestr}, </if>
			<if test="signtype != null">`signType` = #{signtype}, </if>
			<if test="prepayId != null">`prepay_id` = #{prepayId}, </if>
			<if test="paysign != null">`paySign` = #{paysign}, </if>
			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
			<if test="createTime != null">`create_time` = #{createTime}, </if>
			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
			<if test="modTime != null">`mod_time` = #{modTime}, </if>
			<if test="tstm != null">`tstm` = #{tstm}</if>
		</set>
		where `out_no` = #{outNo}
	</update>

	<delete id="delete">
		delete from pingan_pay_order where id = #{value}
	</delete>

	<delete id="deleteBatch">
		delete from pingan_pay_order where id in
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>
</mapper>