<?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.yunniu.farming.webadmin.dao.CustomerDao"> <resultMap id="BaseResultMap" type="com.yunniu.farming.webadmin.model.Customer"> <id column="id" property="id" jdbcType="INTEGER" /> <result column="spassword" property="spassword" jdbcType="VARCHAR" /> <result column="sphone" property="sphone" jdbcType="VARCHAR" /> <result column="senddate" property="senddate" jdbcType="VARCHAR" /> <result column="isex" property="isex" jdbcType="INTEGER" /> <result column="sprovince" property="sprovince" jdbcType="VARCHAR" /> <result column="scity" property="scity" jdbcType="VARCHAR" /> <result column="sregion" property="sregion" jdbcType="VARCHAR" /> <result column="saccount" property="saccount" jdbcType="VARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="iscomplete" property="iscomplete" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="TIMESTAMP" /> <result column="soverdate" property="soverdate" jdbcType="TIMESTAMP" /> <result column="salipayaccount" property="salipayaccount" jdbcType="VARCHAR" /> <result column="saccount" property="saccount" jdbcType="VARCHAR" /> <result column="sxcxopenid" property="sxcxopenid" jdbcType="VARCHAR" /> <result column="swxnick" property="swxnick" jdbcType="VARCHAR" /> <result column="swximgurl" property="swximgurl" jdbcType="VARCHAR" /> <result column="iroleid" property="iroleid" jdbcType="INTEGER" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> <result column="integral" property="integral" jdbcType="DECIMAL" /> </resultMap> <sql id="Base_Column_List"> id, spassword, sphone, senddate, isex, sprovince, scity, sregion, ilevel, iscomplete, tcreatetime, soverdate, saccount, sxcxopenid,swxnick, swximgurl, iroleid, sdef1, sdef2, sdef3, sdef4, sdef5, idef6, idef7, ddef8, ddef9, ddef10 </sql> <sql id="Full_Column_List"> customer.id, customer.spassword, customer.sphone, customer.senddate, customer.isex, customer.sprovince, customer.scity, customer.sregion, customer.ilevel, customer.iscomplete, customer.tcreatetime, customer.soverdate, customer.saccount, customer.sxcxopenid,customer.swxnick, customer.swximgurl, customer.iroleid, customer.sdef1, customer.sdef2, customer.sdef3, customer.sdef4, customer.sdef5, customer.idef6, customer.idef7, customer.ddef8, customer.ddef9, customer.ddef10 </sql> <!-- 带参数常规查询 Start --> <select id="selectByParam" resultMap="BaseResultMap" parameterType="com.yunniu.farming.webadmin.model.Customer"> SELECT <include refid="Base_Column_List" /> FROM customer <where> <if test="iscomplete != null"> AND customer.iscomplete = #{iscomplete,jdbcType=INTEGER} </if> <if test="ilevel != null"> AND customer.ilevel = #{ilevel,jdbcType=INTEGER} </if> <if test="iroleid != null"> AND customer.iroleid = #{iroleid,jdbcType=INTEGER} </if> <if test="sprovince != null"> AND customer.sprovince = #{sprovince,jdbcType=VARCHAR} </if> <if test="scity != null"> AND customer.scity = #{scity,jdbcType=VARCHAR} </if> <if test="sregion != null"> AND customer.sregion = #{sregion,jdbcType=VARCHAR} </if> <if test="sphone != null"> AND customer.sphone = #{sphone,jdbcType=VARCHAR} </if> <if test="saccount != null"> AND customer.saccount = #{saccount,jdbcType=VARCHAR} </if> <if test="spassword != null"> AND customer.spassword = #{spassword,jdbcType=VARCHAR} </if> </where> GROUP BY customer.id ORDER BY customer.tcreatetime DESC </select> <!-- 带参数常规查询 End --> <!-- 带参数分页查询 Start --> <select id="selectByParamPageList" resultMap="BaseResultMap" parameterType="com.yunniu.farming.webadmin.model.Customer"> select <include refid="Base_Column_List" /> ,(SELECT SUM(IFNULL(dincome,0))-SUM(IFNULL(dexpend,0))AS integral FROM integralrec where customerid = customer.id) AS integral FROM customer <where> <if test="iscomplete != null"> AND customer.iscomplete = #{iscomplete,jdbcType=INTEGER} </if> <if test="ilevel != null"> AND customer.ilevel = #{ilevel,jdbcType=INTEGER} </if> <if test="iroleid != null"> AND customer.iroleid = #{iroleid,jdbcType=INTEGER} </if> <if test="sprovince != null"> AND customer.sprovince = #{sprovince,jdbcType=VARCHAR} </if> <if test="scity != null"> AND customer.scity = #{scity,jdbcType=VARCHAR} </if> <if test="sregion != null"> AND customer.sregion = #{sregion,jdbcType=VARCHAR} </if> <if test="sphone != null"> AND customer.sphone = #{sphone,jdbcType=VARCHAR} </if> <if test="swxnick != null"> AND customer.swxnick LIKE concat(concat('%',#{swxnick}),'%') </if> </where> GROUP BY customer.id ORDER BY customer.tcreatetime DESC </select> <!-- 带参数分页查询 End --> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer"> SELECT <include refid="Base_Column_List" /> FROM customer WHERE customer.id = #{id,jdbcType=INTEGER} </select> <!-- FRICE TODO 用于小程序授权登录 End --> <select id="selectAuthLogin" resultMap="BaseResultMap" parameterType="java.lang.String"> SELECT * from customer WHERE sxcxopenid = #{sxcxopenid,jdbcType=VARCHAR} </select> <!-- FRICE TODO 用于小程序授权登录 End --> </mapper>