<?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="org.springblade.modules.guosen.bussiness.mapper.BussinessMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="bussinessResultMap" type="org.springblade.modules.guosen.bussiness.entity.Bussiness">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="name" property="name"/>
        <result column="max_limit" property="maxLimit"/>
        <result column="user_name" property="userName"/>
        <result column="user_password" property="userPassword"/>
        <result column="account_id" property="accountId"/>
        <result column="recall_url" property="recallUrl"/>
        <result column="icon" property="icon"/>
        <result column="secret" property="secret"/>
        <result column="service_rate" property="serviceRate"/>
        <result column="api_file_path" property="apiFilePath"/>
        <result column="remain" property="remain"/>
        <result column="freeze" property="freeze"/>
        <result column="enable" property="enable"/>
        <result column="merchant_no" property="merchantNo"/>
        <result column="register_status" property="registerStatus"/>
        <result column="parent_bussiness_id" property="parentBussinessId"/>
        <result column="bussiness_type" property="bussinessType"/>
        <result column="rate_strategy_id" property="rateStrategyId"/>
        <result column="sub_rate_strategy_id" property="subRateStrategyId"/>
        <result column="micro_rate_strategy_id" property="microRateStrategyId"/>
        <result column="register_notify_url" property="registerNotifyUrl"/>
    </resultMap>


    <select id="selectBussinessPage" resultMap="bussinessResultMap">
        select id,`name`,account_id,user_name,max_limit,recall_url,service_rate,api_file_path,remain, least_price, enable, register_status from cyzh_bussiness where is_deleted = 0
    </select>

    <update id="updateRemain">
        update
            cyzh_bussiness
        set
            remain = #{remain},
            version = ${version+1}
        where
            id = #{id}
            and version = #{version}
    </update>

    <update id="updateFreeze">
        update
            cyzh_bussiness
        set
            freeze = #{freeze}
        where
            id = #{id}
    </update>

    <update id="updateRemainFreeze">
        update
            cyzh_bussiness
        set
            freeze = #{freeze},
            remain = #{remain},
            version = ${version+1}
        where
            id = #{id}
            and version = #{version}
    </update>

</mapper>
