CustomerElectronicCardMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.yijia.customer.mapper.CustomerElectronicCardMapper">
  6. <resultMap type="CustomerElectronicCard" id="CustomerElectronicCardResult">
  7. <result property="id" column="id" />
  8. <result property="unionId" column="union_id" />
  9. <result property="customerNo" column="customer_no" />
  10. <result property="customerName" column="customer_name" />
  11. <result property="mobilePhone" column="mobile_phone" />
  12. <result property="amt" column="amt" />
  13. <result property="cardOilsType" column="card_oils_type" />
  14. <result property="stationId" column="station_id" />
  15. <result property="stationName" column="station_name" />
  16. <result property="createTime" column="create_time" />
  17. <result property="recentlyTime" column="recently_time" />
  18. <result property="num" column="num" />
  19. <result property="czamt" column="czamt" />
  20. <result property="xfamt" column="xfamt" />
  21. <result property="cardnum" column="cardnum" />
  22. <result property="cumamt" column="cumamt" />
  23. <result property="cumnum" column="cumnum" />
  24. </resultMap>
  25. <sql id="selectCustomerElectronicCardVo">
  26. select c.id, c.union_id,c.customer_no,c.customer_name, c.mobile_phone, c.amt, c.card_oils_type,
  27. c.station_id,d.dept_name as station_name, c.create_time, c.recently_time
  28. from customer_electronic_card c join sys_dept d on c.station_id =d.dept_id
  29. </sql>
  30. <select id="selectCustomerElectronicCardList" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  31. <include refid="selectCustomerElectronicCardVo"/>
  32. <where>
  33. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  34. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  35. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  36. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  37. <if test="amt != null "> and amt = #{amt}</if>
  38. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  39. <if test="stationId != null "> and station_id = #{stationId}</if>
  40. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  41. <if test="stationIdList != null ">
  42. and station_id in
  43. <foreach item="item" index="index" collection="stationIdList"
  44. open="(" separator="," close=")">
  45. #{item}
  46. </foreach>
  47. </if>
  48. </where>
  49. </select>
  50. <select id="selectCustomerElectronicCardById" parameterType="Long" resultMap="CustomerElectronicCardResult">
  51. <include refid="selectCustomerElectronicCardVo"/>
  52. where id = #{id}
  53. </select>
  54. <insert id="insertCustomerElectronicCard" parameterType="CustomerElectronicCard" useGeneratedKeys="true" keyProperty="id">
  55. insert into customer_electronic_card
  56. <trim prefix="(" suffix=")" suffixOverrides=",">
  57. <if test="unionId != null">union_id,</if>
  58. <if test="customerNo != null">customer_no,</if>
  59. <if test="customerName != null">customer_name,</if>
  60. <if test="mobilePhone != null">mobile_phone,</if>
  61. <if test="amt != null">amt,</if>
  62. <if test="cardOilsType != null">card_oils_type,</if>
  63. <if test="stationId != null">station_id,</if>
  64. <if test="createTime != null">create_time,</if>
  65. <if test="recentlyTime != null">recently_time,</if>
  66. </trim>
  67. <trim prefix="values (" suffix=")" suffixOverrides=",">
  68. <if test="unionId != null">#{unionId},</if>
  69. <if test="customerNo != null">#{customerNo},</if>
  70. <if test="customerName != null">#{customerName},</if>
  71. <if test="mobilePhone != null">#{mobilePhone},</if>
  72. <if test="amt != null">#{amt},</if>
  73. <if test="cardOilsType != null">#{cardOilsType},</if>
  74. <if test="stationId != null">#{stationId},</if>
  75. <if test="createTime != null">#{createTime},</if>
  76. <if test="recentlyTime != null">#{recentlyTime},</if>
  77. </trim>
  78. </insert>
  79. <update id="updateCustomerElectronicCard" parameterType="CustomerElectronicCard">
  80. update customer_electronic_card
  81. <trim prefix="SET" suffixOverrides=",">
  82. <if test="unionId != null">union_id = #{unionId},</if>
  83. <if test="customerNo != null">customer_no = #{customerNo},</if>
  84. <if test="customerName != null">customer_name = #{customerName},</if>
  85. <if test="mobilePhone != null">mobile_phone = #{mobilePhone},</if>
  86. <if test="amt != null">amt = #{amt},</if>
  87. <if test="cardOilsType != null">card_oils_type = #{cardOilsType},</if>
  88. <if test="stationId != null">station_id = #{stationId},</if>
  89. <if test="createTime != null">create_time = #{createTime},</if>
  90. <if test="recentlyTime != null">recently_time = #{recentlyTime},</if>
  91. </trim>
  92. where id = #{id}
  93. </update>
  94. <delete id="deleteCustomerElectronicCardById" parameterType="Long">
  95. delete from customer_electronic_card where id = #{id}
  96. </delete>
  97. <delete id="deleteCustomerElectronicCardByIds" parameterType="String">
  98. delete from customer_electronic_card where id in
  99. <foreach item="id" collection="array" open="(" separator="," close=")">
  100. #{id}
  101. </foreach>
  102. </delete>
  103. <select id="listSum" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  104. SELECT sum(a.num) as num,sum(a.amt) as amt
  105. from (
  106. SELECT count(DISTINCT union_id) as num,sum(amt) as amt
  107. from customer_electronic_card
  108. <where>
  109. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  110. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  111. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  112. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  113. <if test="amt != null "> and amt = #{amt}</if>
  114. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  115. <if test="stationId != null "> and station_id = #{stationId}</if>
  116. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  117. <if test="stationIdList != null ">
  118. and station_id in
  119. <foreach item="item" index="index" collection="stationIdList"
  120. open="(" separator="," close=")">
  121. #{item}
  122. </foreach>
  123. </if>
  124. </where>
  125. GROUP BY station_id ) a
  126. </select>
  127. <select id="listHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  128. SELECT sum(amt) as amt,count(DISTINCT union_id ) as num
  129. from customer_electronic_card
  130. <where>
  131. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  132. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  133. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  134. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  135. <if test="amt != null "> and amt = #{amt}</if>
  136. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  137. <if test="stationId != null "> and station_id = #{stationId}</if>
  138. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  139. <if test="stationIdList != null ">
  140. and station_id in
  141. <foreach item="item" index="index" collection="stationIdList"
  142. open="(" separator="," close=")">
  143. #{item}
  144. </foreach>
  145. </if>
  146. </where>
  147. </select>
  148. <select id="listAllHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  149. SELECT sum(amt) as amt,count(DISTINCT union_id ) as num
  150. from customer_electronic_card
  151. <where>
  152. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  153. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  154. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  155. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  156. <if test="amt != null "> and amt = #{amt}</if>
  157. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  158. <if test="stationId != null "> and station_id = #{stationId}</if>
  159. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  160. <if test="stationIdList != null ">
  161. and station_id in
  162. <foreach item="item" index="index" collection="stationIdList"
  163. open="(" separator="," close=")">
  164. #{item}
  165. </foreach>
  166. </if>
  167. </where>
  168. </select>
  169. <select id="listJRHYData" parameterType="CustomerElectronicCard" resultMap="CustomerElectronicCardResult">
  170. SELECT count(DISTINCT union_id ) as num from customer_electronic_card
  171. <where>
  172. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  173. <if test="customerNo != null and customerNo != ''"> and customer_no = #{customerNo}</if>
  174. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  175. <if test="mobilePhone != null and mobilePhone != ''"> and mobile_phone = #{mobilePhone}</if>
  176. <if test="amt != null "> and amt = #{amt}</if>
  177. <if test="cardOilsType != null and cardOilsType != ''"> and card_oils_type = #{cardOilsType}</if>
  178. <if test="stationId != null "> and station_id = #{stationId}</if>
  179. <if test="recentlyTime != null "> and recently_time = #{recentlyTime}</if>
  180. <if test="stationIdList != null ">
  181. and station_id in
  182. <foreach item="item" index="index" collection="stationIdList"
  183. open="(" separator="," close=")">
  184. #{item}
  185. </foreach>
  186. </if>
  187. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  188. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%s')
  189. </if>
  190. <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
  191. AND date_format(create_time,'%Y-%m-%d %H:%i:%s') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%s')
  192. </if>
  193. </where>
  194. </select>
  195. <!--存储过程
  196. CALL selectCard();
  197. CALL selectCard(#{pageNo,mode=IN},#{pageSetting,mode=IN});-->
  198. <select id="selectCard" parameterType="CustomerElectronicCard" statementType="CALLABLE" resultMap="CustomerElectronicCardResult">
  199. CALL selectCard(#{strSql,mode=IN},#{pageNo,mode=IN},#{pageSetting,mode=IN});
  200. </select>
  201. <!--存储过程-->
  202. <select id="selectCardPage" parameterType="CustomerElectronicCard" statementType="CALLABLE" resultMap="CustomerElectronicCardResult">
  203. CALL selectCardPage(#{strSql,mode=IN});
  204. </select>
  205. </mapper>