<?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.yami.shop.dao.EnterprisePayMapper">

    <resultMap id="enterprisePayMap" type="com.yami.shop.bean.model.EnterprisePay">
        <id column="ent_pay_id" property="entPayId"/>
        <result column="status" property="status"/>
        <result column="user_id" property="userId"/>
        <result column="open_id" property="openId"/>
        <result column="ent_pay_order_no" property="entPayOrderNo"/>
        <result column="amount" property="amount"/>
        <result column="type" property="type"/>
        <result column="biz_id" property="bizId"/>
        <result column="version" property="version"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <select id="listApplyEnterprisePay" resultType="com.yami.shop.bean.model.EnterprisePay">
        SELECT ep.* FROM tz_enterprise_pay ep WHERE ep.status = 1
    </select>

    <update id="paySuccess">
        UPDATE tz_enterprise_pay ep SET ep.status = 2,ep.update_time = now(),ep.version = ep.version + 1 WHERE ep.ent_pay_order_no =#{entPayOrderNo} AND ep.version=#{version}
    </update>

    <update id="payFailed">
        UPDATE tz_enterprise_pay ep SET ep.status = -1,ep.update_time = now(),ep.version = ep.version + 1 WHERE ep.ent_pay_order_no =#{entPayOrderNo} AND ep.version=#{version}
    </update>
</mapper>
