MemberReadMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.slodon.b2b2c.dao.read.member.MemberReadMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.member.pojo.Member">
  5. <id column="member_id" property="memberId"/>
  6. <result column="member_name" property="memberName"/>
  7. <result column="member_nick_name" property="memberNickName"/>
  8. <result column="member_true_name" property="memberTrueName"/>
  9. <result column="member_birthday" property="memberBirthday"/>
  10. <result column="member_integral" property="memberIntegral"/>
  11. <result column="integral_frozen" property="integralFrozen"/>
  12. <result column="member_email" property="memberEmail"/>
  13. <result column="member_qq" property="memberQq"/>
  14. <result column="member_mobile" property="memberMobile"/>
  15. <result column="member_avatar" property="memberAvatar"/>
  16. <result column="login_pwd" property="loginPwd"/>
  17. <result column="pay_pwd" property="payPwd"/>
  18. <result column="gender" property="gender"/>
  19. <result column="grade" property="grade"/>
  20. <result column="experience_value" property="experienceValue"/>
  21. <result column="register_time" property="registerTime"/>
  22. <result column="last_login_time" property="lastLoginTime"/>
  23. <result column="last_login_ip" property="lastLoginIp"/>
  24. <result column="login_number" property="loginNumber"/>
  25. <result column="last_payment_code" property="lastPaymentCode"/>
  26. <result column="pay_error_count" property="payErrorCount"/>
  27. <result column="login_error_count" property="loginErrorCount"/>
  28. <result column="register_channel" property="registerChannel"/>
  29. <result column="balance_available" property="balanceAvailable"/>
  30. <result column="balance_frozen" property="balanceFrozen"/>
  31. <result column="state" property="state"/>
  32. <result column="is_email_verify" property="isEmailVerify"/>
  33. <result column="is_mobile_verify" property="isMobileVerify"/>
  34. <result column="is_receive_sms" property="isReceiveSms"/>
  35. <result column="is_receive_email" property="isReceiveEmail"/>
  36. <result column="is_allow_buy" property="isAllowBuy"/>
  37. <result column="is_allow_ask" property="isAllowAsk"/>
  38. <result column="is_allow_comment" property="isAllowComment"/>
  39. <result column="wx_unionid" property="wxUnionid"/>
  40. <result column="wx_avatar_img" property="wxAvatarImg"/>
  41. <result column="update_time" property="updateTime"/>
  42. <result column="is_email_active" property="isEmailActive" />
  43. <result column="gp_uid" property="gpUid" />
  44. <result column="gp_token" property="gpToken" />
  45. <result column="member_company" property="memberCompany" />
  46. <result column="member_main_product" property="memberMainProduct" />
  47. <result column="country" property="country" />
  48. <result column="city" property="city" />
  49. <result column="latitude" property="latitude" />
  50. <result column="longitude" property="longitude" />
  51. <result column="web_site" property="webSite" />
  52. </resultMap>
  53. <!--按照主键值进行操作-->
  54. <sql id="pkWhere">
  55. WHERE `member_id` = #{primaryKey}
  56. </sql>
  57. <!--操作条件-->
  58. <sql id="whereCondition">
  59. <if test="example != null">
  60. <trim prefix="WHERE" prefixOverrides="AND|OR">
  61. <if test="example.memberIdNotEquals != null">
  62. AND `member_id` != #{example.memberIdNotEquals}
  63. </if>
  64. <if test="example.memberIdIn != null">
  65. AND `member_id` in (${example.memberIdIn})
  66. </if>
  67. <if test="example.memberName != null">
  68. AND `member_name` = #{example.memberName}
  69. </if>
  70. <if test="example.memberNameLike != null">
  71. AND `member_name` like concat('%',#{example.memberNameLike},'%')
  72. </if>
  73. <if test="example.memberNickName != null">
  74. AND `member_nick_name` = #{example.memberNickName}
  75. </if>
  76. <if test="example.memberNickNameLike != null">
  77. AND `member_nick_name` like concat('%',#{example.memberNickNameLike},'%')
  78. </if>
  79. <if test="example.memberTrueName != null">
  80. AND `member_true_name` = #{example.memberTrueName}
  81. </if>
  82. <if test="example.memberTrueNameLike != null">
  83. AND `member_true_name` like concat('%',#{example.memberTrueNameLike},'%')
  84. </if>
  85. <if test="example.memberBirthday != null">
  86. AND `member_birthday` = #{example.memberBirthday}
  87. </if>
  88. <if test="example.memberIntegral != null">
  89. AND `member_integral` = #{example.memberIntegral}
  90. </if>
  91. <if test="example.integralFrozen != null">
  92. AND `integral_frozen` = #{example.integralFrozen}
  93. </if>
  94. <if test="example.memberEmail != null">
  95. AND `member_email` = #{example.memberEmail}
  96. </if>
  97. <if test="example.memberQq != null">
  98. AND `member_qq` = #{example.memberQq}
  99. </if>
  100. <if test="example.memberMobile != null">
  101. AND `member_mobile` = #{example.memberMobile}
  102. </if>
  103. <if test="example.memberMobileLike != null">
  104. AND `member_mobile` like concat('%',#{example.memberMobileLike},'%')
  105. </if>
  106. <if test="example.memberAvatar != null">
  107. AND `member_avatar` = #{example.memberAvatar}
  108. </if>
  109. <if test="example.loginPwd != null">
  110. AND `login_pwd` = #{example.loginPwd}
  111. </if>
  112. <if test="example.payPwd != null">
  113. AND `pay_pwd` = #{example.payPwd}
  114. </if>
  115. <if test="example.gender != null">
  116. AND `gender` = #{example.gender}
  117. </if>
  118. <if test="example.grade != null">
  119. AND `grade` = #{example.grade}
  120. </if>
  121. <if test="example.experienceValue != null">
  122. AND `experience_value` = #{example.experienceValue}
  123. </if>
  124. <if test="example.registerTimeAfter != null">
  125. AND `register_time` <![CDATA[ >= ]]> #{example.registerTimeAfter}
  126. </if>
  127. <if test="example.registerTimeBefore != null">
  128. AND `register_time` <![CDATA[ <= ]]> #{example.registerTimeBefore}
  129. </if>
  130. <if test="example.lastLoginTimeAfter != null">
  131. AND `last_login_time` <![CDATA[ >= ]]> #{example.lastLoginTimeAfter}
  132. </if>
  133. <if test="example.lastLoginTimeBefore != null">
  134. AND `last_login_time` <![CDATA[ <= ]]> #{example.lastLoginTimeBefore}
  135. </if>
  136. <if test="example.lastLoginIp != null">
  137. AND `last_login_ip` = #{example.lastLoginIp}
  138. </if>
  139. <if test="example.loginNumber != null">
  140. AND `login_number` = #{example.loginNumber}
  141. </if>
  142. <if test="example.lastPaymentCode != null">
  143. AND `last_payment_code` = #{example.lastPaymentCode}
  144. </if>
  145. <if test="example.payErrorCount != null">
  146. AND `pay_error_count` = #{example.payErrorCount}
  147. </if>
  148. <if test="example.loginErrorCount != null">
  149. AND `login_error_count` = #{example.loginErrorCount}
  150. </if>
  151. <if test="example.registerChannel != null">
  152. AND `register_channel` = #{example.registerChannel}
  153. </if>
  154. <if test="example.balanceAvailable != null">
  155. AND `balance_available` = #{example.balanceAvailable}
  156. </if>
  157. <if test="example.balanceFrozen != null">
  158. AND `balance_frozen` = #{example.balanceFrozen}
  159. </if>
  160. <if test="example.state != null">
  161. AND `state` = #{example.state}
  162. </if>
  163. <if test="example.stateNotEquals != null">
  164. AND `state` != #{example.stateNotEquals}
  165. </if>
  166. <if test="example.isEmailVerify != null">
  167. AND `is_email_verify` = #{example.isEmailVerify}
  168. </if>
  169. <if test="example.isMobileVerify != null">
  170. AND `is_mobile_verify` = #{example.isMobileVerify}
  171. </if>
  172. <if test="example.isReceiveSms != null">
  173. AND `is_receive_sms` = #{example.isReceiveSms}
  174. </if>
  175. <if test="example.isReceiveEmail != null">
  176. AND `is_receive_email` = #{example.isReceiveEmail}
  177. </if>
  178. <if test="example.isAllowBuy != null">
  179. AND `is_allow_buy` = #{example.isAllowBuy}
  180. </if>
  181. <if test="example.isAllowAsk != null">
  182. AND `is_allow_ask` = #{example.isAllowAsk}
  183. </if>
  184. <if test="example.isAllowComment != null">
  185. AND `is_allow_comment` = #{example.isAllowComment}
  186. </if>
  187. <if test="example.wxUnionid != null">
  188. AND `wx_unionid` = #{example.wxUnionid}
  189. </if>
  190. <if test="example.wxAvatarImg != null">
  191. AND `wx_avatar_img` = #{example.wxAvatarImg}
  192. </if>
  193. <if test="example.updateTimeAfter != null">
  194. AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
  195. </if>
  196. <if test="example.updateTimeBefore != null">
  197. AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
  198. </if>
  199. <if test="example.memberNameOrMemberMobile != null">
  200. AND `member_name` = #{example.memberNameOrMemberMobile} or `member_mobile` = #{example.memberNameOrMemberMobile}
  201. </if>
  202. <if test="example.isEmailActive != null">
  203. AND `is_email_active` = #{example.isEmailActive}
  204. </if>
  205. <if test="example.gpUid != null">
  206. AND `gp_uid` = #{example.gpUid}
  207. </if>
  208. <if test="example.gpToken != null">
  209. AND `gp_token` = #{example.gpToken}
  210. </if>
  211. <if test="example.memberCompany != null">
  212. AND `member_company` = #{example.memberCompany}
  213. </if>
  214. <if test="example.webSite != null">
  215. AND `web_site` = #{example.webSite}
  216. </if>
  217. </trim>
  218. </if>
  219. </sql>
  220. <!--排序条件-->
  221. <sql id="orderBy">
  222. ORDER BY `member_id` DESC
  223. </sql>
  224. <sql id="orderByOther">
  225. order by ${example.orderBy}
  226. </sql>
  227. <!--分组条件-->
  228. <sql id="groupBy">
  229. group by ${example.groupBy}
  230. </sql>
  231. <!--分页条件-->
  232. <sql id="limit">
  233. <if test="size != null and size &gt; 0">
  234. limit #{startRow},#{size}
  235. </if>
  236. </sql>
  237. <!--查询符合条件的记录数-->
  238. <select id="countByExample" parameterType="com.slodon.b2b2c.member.example.MemberExample"
  239. resultType="java.lang.Integer">
  240. SELECT
  241. COUNT(*)
  242. FROM `member`
  243. <include refid="whereCondition"/>
  244. </select>
  245. <!--根据主键查询记录-->
  246. <select id="getByPrimaryKey" resultMap="resultMap">
  247. SELECT
  248. *
  249. FROM `member`
  250. <include refid="pkWhere"/>
  251. </select>
  252. <!--查询符合条件的记录(所有字段)-->
  253. <select id="listByExample" resultMap="resultMap">
  254. SELECT
  255. *
  256. FROM `member`
  257. <include refid="whereCondition"/>
  258. <if test="example.groupBy != null">
  259. <include refid="groupBy"/>
  260. </if>
  261. <choose>
  262. <when test="example.orderBy != null">
  263. <include refid="orderByOther"/>
  264. </when>
  265. <otherwise>
  266. <include refid="orderBy"/>
  267. </otherwise>
  268. </choose>
  269. </select>
  270. <!--分页查询符合条件的记录(所有字段)-->
  271. <select id="listPageByExample" resultMap="resultMap">
  272. SELECT
  273. *
  274. FROM `member`
  275. <include refid="whereCondition"/>
  276. <if test="example.groupBy != null">
  277. <include refid="groupBy"/>
  278. </if>
  279. <choose>
  280. <when test="example.orderBy != null">
  281. <include refid="orderByOther"/>
  282. </when>
  283. <otherwise>
  284. <include refid="orderBy"/>
  285. </otherwise>
  286. </choose>
  287. <include refid="limit"/>
  288. </select>
  289. <!--查询符合条件的记录(指定字段)-->
  290. <select id="listFieldsByExample" resultMap="resultMap">
  291. SELECT
  292. ${fields}
  293. FROM `member`
  294. <include refid="whereCondition"/>
  295. <if test="example.groupBy != null">
  296. <include refid="groupBy"/>
  297. </if>
  298. <choose>
  299. <when test="example.orderBy != null">
  300. <include refid="orderByOther"/>
  301. </when>
  302. <otherwise>
  303. <include refid="orderBy"/>
  304. </otherwise>
  305. </choose>
  306. </select>
  307. <!--分页查询符合条件的记录(指定字段)-->
  308. <select id="listFieldsPageByExample" resultMap="resultMap">
  309. SELECT
  310. ${fields}
  311. FROM `member`
  312. <include refid="whereCondition"/>
  313. <if test="example.groupBy != null">
  314. <include refid="groupBy"/>
  315. </if>
  316. <choose>
  317. <when test="example.orderBy != null">
  318. <include refid="orderByOther"/>
  319. </when>
  320. <otherwise>
  321. <include refid="orderBy"/>
  322. </otherwise>
  323. </choose>
  324. <include refid="limit"/>
  325. </select>
  326. <select id="getMemberDistribution" resultType="com.slodon.b2b2c.vo.statistics.ScreenMemberDistribution">
  327. SELECT city,latitude,longitude, COUNT(*) as memberNum
  328. FROM member
  329. WHERE city IS NOT NULL
  330. AND city != ''
  331. AND web_site = #{webSite}
  332. GROUP BY city,latitude,longitude
  333. ORDER BY memberNum DESC
  334. </select>
  335. <select id="getMemberTrend" resultType="com.slodon.b2b2c.vo.statistics.ScreenMemberTrendVO">
  336. WITH RECURSIVE dates AS (
  337. SELECT DATE(#{startTime}) AS day
  338. UNION ALL
  339. SELECT DATE_ADD(day, INTERVAL 1 DAY)
  340. FROM dates
  341. WHERE day &lt; DATE(#{endTime}) -- 优化终止条件,减少一次计算
  342. )
  343. SELECT
  344. d.day,
  345. COALESCE(COUNT(m.member_id), 0) AS newMemberNum
  346. FROM dates d
  347. LEFT JOIN member m
  348. ON DATE(m.register_time) = d.day
  349. AND m.register_time BETWEEN #{startTime} AND #{endTime}
  350. AND m.web_site = #{webSite} -- 将web_site条件移到JOIN中
  351. GROUP BY d.day
  352. ORDER BY d.day;
  353. </select>
  354. </mapper>