| <?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.xzx.gc.user.mapper.PartnerAccountMapper">  | 
|   <resultMap id="BaseResultMap" type="com.xzx.gc.entity.PartnerAccount">  | 
|     <!--  | 
|       WARNING - @mbg.generated  | 
|     -->  | 
|     <id column="id" jdbcType="INTEGER" property="id" />  | 
|     <result column="user_id" jdbcType="VARCHAR" property="userId" />  | 
|     <result column="account" jdbcType="VARCHAR" property="account" />  | 
|     <result column="hbb" jdbcType="VARCHAR" property="hbb" />  | 
|     <result column="del_flag"  property="delFlag" />  | 
|     <result column="update_time" jdbcType="VARCHAR" property="updateTime" />  | 
|     <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />  | 
|   </resultMap>  | 
|   | 
|     <update id="updateAddMoneyByPartnerId">  | 
|         update xzx_partner_account set hbb=cast(hbb as decimal(9,2))+#{money}  | 
|         where  partner_id=#{partnerId} and del_flag=0  | 
|     </update>  | 
|   | 
|   <select id="getPartnerAccountByUserId" resultType="com.xzx.gc.model.admin.PartnerAccountModel">  | 
|     select *  | 
|     from xzx_partner_account  | 
|     where user_id = #{userId} and del_flag = 0  | 
|   </select>  | 
|   | 
|     <insert id="addPartnerAccountLog">  | 
|         INSERT INTO `xzx_partner_account_log` (`account_id`, `flow_no`, `type`, `create_time`,  | 
|                                                `money`, `account_money`, `hbb`, `user_name`, `user_phone`, `role_name`, `approver_status`, `del_flag`, `old_limit`, `manage_limit`, `new_limit`, `old_limit_fix`, `manage_limit_fix`, `new_limit_fix`)  | 
|         VALUES (#{accountId}, #{flowNo}, #{type}, #{createTime}, #{money},  | 
|                               #{accountMoney}, #{hbb}, #{userName}, #{userPhone}, #{roleName}, #{approverStatus},  | 
|                 #{delFlag}, #{oldLimit}, #{manageLimit}, #{newLimit}, #{oldLimitFix}, #{manageLimitFix}, #{newLimitFix})  | 
|     </insert>  | 
|   | 
|     <update id="updatePartnerAccount">  | 
|         update xzx_partner_account set  | 
|         hbb=#{hbb}  | 
|         <if test="overdraftLimit != null and overdraftLimit != ''">  | 
|             , overdraft_limit=#{overdraftLimit}  | 
|         </if>  | 
|         where user_id=#{userId}  | 
|     </update>  | 
|   | 
|     <delete id="deletePartnerAccount">  | 
|         update xzx_partner_account  | 
|         set del_flag = #{delFlag}  | 
|         where user_id = #{userId} and del_flag = 0  | 
|     </delete>  | 
|   | 
|     <select id="queryAccountIdByUserId" resultType="com.xzx.gc.model.admin.PartnerAccountModel">  | 
|         select *  | 
|         from xzx_partner_account  | 
|         where user_id = #{userId} and del_flag = 0  | 
|         limit 1  | 
|     </select>  | 
|   | 
|   | 
|     <update id="updatePackageAccount">  | 
|         update xzx_partner_account  | 
|         set overdraft_limit = #{overdraftLimit}, fixed_limit = #{fixedLimit}  | 
|         where user_id = #{userId}  | 
|     </update>  | 
|   | 
|     <select id="queryPartnerByAccountId" resultType="com.xzx.gc.model.admin.AccountMoneyModel">  | 
|         select * from  xzx_partner_account where account=#{accountId}  | 
|     </select>  | 
|   | 
|     <update id="updateParterAccount">  | 
|         UPDATE xzx_partner_account  | 
|         SET  | 
|             hbb = #{money}  | 
|         WHERE account = #{accountId}  | 
|     </update>  | 
|   | 
|     <select id="queryAccountIdByAccountId" resultType="com.xzx.gc.model.admin.PartnerAccountModel">  | 
|         select * from xzx_partner_account where account=#{account} and del_flag=0 limit 1  | 
|     </select>  | 
|   | 
|     <insert id="addPartnerAccount">  | 
|         INSERT INTO xzx_partner_account (`user_id`, `account`, `hbb`, `del_flag`, `update_time`, `partner_id`, `overdraft_limit`, `fixed_limit`, `type`)  | 
|         VALUES (#{userId}, #{account}, '0', '0', #{updateTime}, #{partnerId}, '0', '0', #{type})  | 
|     </insert>  | 
|   | 
|     <update id="updateAddMoneyLimitByAccountId">  | 
|         update xzx_partner_account  | 
|         <trim prefix="set" suffixOverrides=",">  | 
|             <if test="money != null">  | 
|                 hbb=cast(hbb as decimal(9,2))+#{money},  | 
|             </if>  | 
|             <if test="overdraftLimit != null">  | 
|                 overdraft_limit=cast(overdraft_limit as decimal(9,2))+#{overdraftLimit},  | 
|             </if>  | 
|         </trim>  | 
|         where  account=#{accountId} and del_flag=0  | 
|     </update>  | 
|   | 
|     <update id="updateAddMoneyResetFixLimitByAccountId">  | 
|         update xzx_partner_account set overdraft_limit=#{overdraftLimit}  | 
|         <if test="money != null">  | 
|             ,hbb=cast(hbb as decimal(9,2))+#{money}  | 
|         </if>  | 
|         where  account=#{accountId} and del_flag=0  | 
|     </update>  | 
|   | 
|     <update id="updateReduceMoneyLimitByAccountId">  | 
|         update xzx_partner_account  | 
|         <trim prefix="set" suffixOverrides=",">  | 
|             <if test="money != null">  | 
|                 hbb=cast(hbb as decimal(9,2))-#{money},  | 
|             </if>  | 
|             <if test="overdraftLimit != null">  | 
|                 overdraft_limit=cast(overdraft_limit as decimal(9,2))-#{overdraftLimit} ,  | 
|             </if>  | 
|         </trim>  | 
|         where  account=#{accountId} and del_flag=0  | 
|     </update>  | 
|   | 
|     <update id="updateReduceMoneyResetLimitByAccountId">  | 
|         update xzx_partner_account set overdraft_limit='0.00'  | 
|         <if test="money != null">  | 
|             ,hbb=cast(hbb as decimal(9,2))-#{money}  | 
|         </if>  | 
|         where  account=#{accountId} and del_flag=0  | 
|     </update>  | 
| </mapper> |