<?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.qnfhq.modules.c2c.dao.C2cOrderDao">

    <resultMap type="com.qnfhq.modules.c2c.entity.C2cOrderEntity" id="c2cOrderMap">
        <result property="id" column="id"/>
        <result property="orderNo" column="order_no"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="direction" column="direction"/>
        <result property="legalCoin" column="legal_coin"/>
        <result property="symbol" column="symbol"/>
        <result property="c2cAdId" column="c2c_ad_id"/>
        <result property="tranUserId" column="tran_user_id"/>
        <result property="tranUserName" column="tran_user_name"/>
        <result property="tranPrice" column="tran_price"/>
        <result property="symbolNum" column="symbol_num"/>
        <result property="tranAmount" column="tran_amount"/>
        <result property="payType" column="pay_type"/>
        <result property="payTime" column="pay_time"/>
        <result property="flow" column="flow"/>
        <result property="status" column="status"/>
        <result property="remark" column="remark"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="payExpireTime" column="pay_expire_time"/>
        <result property="finishTime" column="finish_time"/>
        <result property="closeTime" column="close_time"/>
    </resultMap>

    <insert id="insertC2cOrder" parameterType="com.qnfhq.modules.c2c.entity.C2cOrderEntity" useGeneratedKeys="true" keyProperty="id">
        insert into c2c_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">order_no,</if>
            <if test="userId != null">user_id,</if>
            <if test="userName != null">user_name,</if>
            <if test="direction != null">direction,</if>
            <if test="legalCoin != null">legal_coin,</if>
            <if test="symbol != null">symbol,</if>
            <if test="c2cAdId != null">c2c_ad_id,</if>
            <if test="tranUserId != null">tran_user_id,</if>
            <if test="tranUserName != null">tran_user_name,</if>
            <if test="tranPrice != null">tran_price,</if>
            <if test="symbolNum != null">symbol_num,</if>
            <if test="tranAmount != null">tran_amount,</if>
            <if test="payType != null">pay_type,</if>
            <if test="flow != null">flow,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            pay_expire_time,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderNo != null">#{orderNo},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="direction != null">#{direction},</if>
            <if test="legalCoin != null">#{legalCoin},</if>
            <if test="symbol != null">#{symbol},</if>
            <if test="c2cAdId != null">#{c2cAdId},</if>
            <if test="tranUserId != null">#{tranUserId},</if>
            <if test="tranUserName != null">#{tranUserName},</if>
            <if test="tranPrice != null">#{tranPrice},</if>
            <if test="symbolNum != null">#{symbolNum},</if>
            <if test="tranAmount != null">#{tranAmount},</if>
            <if test="payType != null">#{payType},</if>
            <if test="flow != null">#{flow},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">NOW(),</if>
            <if test="updateTime != null">NOW(),</if>
             DATE_ADD(NOW(), INTERVAL 30 MINUTE)
        </trim>
    </insert>
</mapper>