DcIntroduceLogMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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.ygj.yuemum.dao.distributionchannel.DcIntroduceLogDao">
  4. <resultMap id="BaseResultMap" type="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  5. <result column="id" property="id" jdbcType="INTEGER"/>
  6. <result column="xul_openid" property="xul_openid" jdbcType="VARCHAR"/>
  7. <result column="xul_phone" property="xul_phone" jdbcType="VARCHAR"/>
  8. <result column="xul_event" property="xul_event" jdbcType="INTEGER"/>
  9. <result column="xul_date" property="xul_date" jdbcType="DATE"/>
  10. <result column="xul_introducer_phone" property="xul_introducer_phone" jdbcType="VARCHAR"/>
  11. <result column="xul_pm_type" property="xul_pm_type" jdbcType="INTEGER"/>
  12. <result column="xul_orderno" property="xul_orderno" jdbcType="VARCHAR"/>
  13. <result column="xul_rebateamount" property="xul_rebateamount" jdbcType="INTEGER"/>
  14. </resultMap>
  15. <!--获取所有数据-->
  16. <select id="checkDcIntroducerLogs" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  17. select
  18. count(1)
  19. from dc_introduce_log
  20. where xul_phone = #{xul_phone,jdbcType=VARCHAR}
  21. and xul_event = #{xul_event,jdbcType=INTEGER}
  22. and xul_openid = #{xul_openid,jdbcType=INTEGER}
  23. order by id desc
  24. </select>
  25. <select id="checkFirstDILogs" resultType="java.lang.Integer" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  26. select
  27. count(1)
  28. from dc_introduce_log
  29. where xul_openid = #{xul_openid,jdbcType=VARCHAR}
  30. and xul_event = 0
  31. and xul_introducer_phone = #{xul_introducer_phone,jdbcType=INTEGER}
  32. order by id desc
  33. </select>
  34. <select id="queryDcIntroduceLogs" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  35. parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  36. SELECT
  37. dc_introduce_log.id,
  38. xul_openid,
  39. xul_phone,
  40. xul_event,
  41. xul_date,
  42. xul_introducer_phone,
  43. xul_pm_type,
  44. xul_orderno,
  45. ys_order.od_order_amount od_order_amount,
  46. xul_rebateamount
  47. FROM
  48. dc_introduce_log LEFT JOIN ys_order ON dc_introduce_log.xul_orderno = ys_order.od_no
  49. where 1=1
  50. <if test="xul_openid != null and xul_openid != ''">
  51. and xul_openid = #{xul_openid,jdbcType=VARCHAR}
  52. </if>
  53. <if test="xul_phone != null and xul_phone != ''">
  54. and xul_phone = #{xul_phone,jdbcType=VARCHAR}
  55. </if>
  56. <if test="xul_event != null and xul_event != ''">
  57. and xul_event = #{xul_event,jdbcType=INTEGER}
  58. </if>
  59. <if test="xul_date != null and xul_date != ''">
  60. and xul_date = #{xul_date,jdbcType=DATE}
  61. </if>
  62. <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
  63. and xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR}
  64. </if>
  65. <if test="xul_pm_type != null and xul_pm_type != ''">
  66. and xul_pm_type = #{xul_pm_type,jdbcType=INTEGER}
  67. </if>
  68. <if test="xul_orderno != null and xul_orderno != ''">
  69. and xul_orderno = #{xul_orderno,jdbcType=VARCHAR}
  70. </if>
  71. order by xul_event desc, id desc , xul_pm_type asc
  72. </select>
  73. <select id="queryDcILbyrebate" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  74. parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  75. SELECT
  76. ta.id,
  77. xul_openid,
  78. xul_phone,
  79. xul_event,
  80. xul_date,
  81. xul_introducer_phone,
  82. xul_pm_type,
  83. xul_orderno,
  84. tb.od_order_amount,
  85. ifnull(tb.od_rebate_amount,0) od_rebate_amount
  86. FROM
  87. dc_introduce_log ta
  88. LEFT JOIN ys_order tb ON ta.xul_orderno = tb.od_no
  89. where 1=1
  90. <if test="xul_openid != null and xul_openid != ''">
  91. and xul_openid = #{xul_openid,jdbcType=VARCHAR}
  92. </if>
  93. <if test="xul_phone != null and xul_phone != ''">
  94. and xul_phone = #{xul_phone,jdbcType=VARCHAR}
  95. </if>
  96. <if test="xul_event != null and xul_event != ''">
  97. and xul_event = #{xul_event,jdbcType=INTEGER}
  98. </if>
  99. <if test="xul_date != null and xul_date != ''">
  100. and xul_date = #{xul_date,jdbcType=DATE}
  101. </if>
  102. <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
  103. and xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR}
  104. </if>
  105. <if test="xul_pm_type != null and xul_pm_type != ''">
  106. and xul_pm_type = #{xul_pm_type,jdbcType=INTEGER}
  107. </if>
  108. <if test="xul_orderno != null and xul_orderno != ''">
  109. and xul_orderno = #{xul_orderno,jdbcType=VARCHAR}
  110. </if>
  111. order by xul_event desc, id desc , xul_pm_type asc
  112. </select>
  113. <select id="getDcIntroduceLogs" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  114. parameterType="java.lang.String">
  115. select xul_phone,max(xul_event) xul_event from dc_introduce_log
  116. where xul_introducer_phone = #{phone,jdbcType=VARCHAR}
  117. and xul_event >= 2
  118. group by xul_phone
  119. </select>
  120. <select id="getDcIntroduceLogFive" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  121. parameterType="java.lang.String">
  122. SELECT
  123. xul_phone,
  124. DATE_FORMAT(min(xul_date), '%Y-%m-%d') xul_date,
  125. max(xul_event) xul_event,
  126. max(xul_pm_type) xul_pm_type,
  127. max(xul_rebateamount) xul_rebateamount
  128. FROM
  129. dc_introduce_log
  130. WHERE
  131. xul_phone = #{phone,jdbcType=VARCHAR}
  132. AND xul_event >= 5
  133. GROUP BY
  134. xul_orderno,xul_phone,xul_date
  135. </select>
  136. <select id="getDcIntroduceLogTwo" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  137. parameterType="java.lang.String">
  138. SELECT
  139. xul_phone,
  140. DATE_FORMAT(xul_date, '%Y-%m-%d') xul_date,
  141. xul_event,
  142. xul_pm_type,
  143. xul_rebateamount
  144. FROM
  145. dc_introduce_log
  146. WHERE
  147. xul_phone = #{phone,jdbcType=VARCHAR}
  148. AND xul_event = 2
  149. GROUP BY
  150. xul_orderno,xul_phone,xul_date,xul_event,xul_pm_type,xul_rebateamount
  151. </select>
  152. <select id="getDcReport" resultType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog"
  153. parameterType="com.ygj.yuemum.domain.distributionchannel.DcQueryReport">
  154. SELECT DISTINCT
  155. (ta.xul_phone) xul_phone,
  156. ta.xul_introducer_phone,
  157. ta.xul_date,
  158. ta.xul_orderno,
  159. ifnull(fgetorder_amount(ta.xul_orderno),0) od_order_amount,
  160. ifnull(ta.xul_rebateamount,0) od_rebate_amount,
  161. count(tb.xul_introducer_phone)
  162. FROM
  163. dc_introduce_log ta
  164. LEFT JOIN dc_introduce_log tb ON ta.xul_introducer_phone = tb.xul_introducer_phone
  165. WHERE
  166. ta.xul_introducer_phone != ''
  167. and ta.xul_event = #{xul_event,jdbcType=INTEGER}
  168. AND tb.xul_event = #{xul_event,jdbcType=INTEGER}
  169. <if test="start_date != null and start_date != ''">
  170. and ta.xul_date &gt;= #{start_date,jdbcType=DATE}
  171. </if>
  172. <if test="xul_phone != null and xul_phone != ''">
  173. and ta.xul_phone like "%"#{xul_phone,jdbcType=VARCHAR}"%"
  174. </if>
  175. <if test="xul_introducer_phone != null and xul_introducer_phone != ''">
  176. and ta.xul_introducer_phone like "%"#{xul_introducer_phone,jdbcType=VARCHAR}"%"
  177. </if>
  178. <if test="end_date != null and end_date != ''">
  179. and ta.xul_date &lt;= #{end_date,jdbcType=DATE}
  180. </if>
  181. GROUP BY
  182. ta.xul_phone,ta.xul_introducer_phone,ta.xul_date,ta.xul_orderno,ta.xul_rebateamount
  183. ORDER BY
  184. count(tb.xul_introducer_phone) DESC, ta.xul_introducer_phone asc
  185. </select>
  186. <insert id="insertDcIntroduceLog" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog">
  187. insert into dc_introduce_log
  188. <trim prefix="(" suffix=")" suffixOverrides=",">
  189. <if test="xul_openid != null">
  190. xul_openid,
  191. </if>
  192. <if test="xul_phone != null">
  193. xul_phone,
  194. </if>
  195. <if test="xul_event != null">
  196. xul_event,
  197. </if>
  198. <if test="xul_date != null">
  199. xul_date,
  200. </if>
  201. <if test="xul_introducer_phone != null">
  202. xul_introducer_phone,
  203. </if>
  204. <if test="xul_pm_type != null">
  205. xul_pm_type,
  206. </if>
  207. <if test="xul_orderno != null">
  208. xul_orderno,
  209. </if>
  210. <if test="xul_rebateamount != null">
  211. xul_rebateamount
  212. </if>
  213. </trim>
  214. <trim prefix="values (" suffix=")" suffixOverrides=",">
  215. <if test="xul_openid != null">
  216. #{xul_openid,jdbcType=VARCHAR},
  217. </if>
  218. <if test="xul_phone != null">
  219. #{xul_phone,jdbcType=VARCHAR},
  220. </if>
  221. <if test="xul_event != null">
  222. #{xul_event,jdbcType=INTEGER},
  223. </if>
  224. <if test="xul_date != null">
  225. #{xul_date,jdbcType=DATE},
  226. </if>
  227. <if test="xul_introducer_phone != null">
  228. #{xul_introducer_phone,jdbcType=VARCHAR},
  229. </if>
  230. <if test="xul_pm_type != null">
  231. #{xul_pm_type,jdbcType=INTEGER},
  232. </if>
  233. <if test="xul_orderno != null">
  234. #{xul_orderno,jdbcType=VARCHAR},
  235. </if>
  236. <if test="xul_rebateamount != null">
  237. #{xul_rebateamount,jdbcType=INTEGER}
  238. </if>
  239. </trim>
  240. </insert>
  241. <update id="updateDcIntroduceLogByPhone" parameterType="com.ygj.yuemum.domain.distributionchannel.DcIntroduceLog" >
  242. update dc_introduce_log
  243. <set >
  244. <if test="xul_introducer_phone != null" >
  245. xul_introducer_phone = #{xul_introducer_phone,jdbcType=VARCHAR},
  246. </if>
  247. </set>
  248. where xul_introducer_phone = #{xul_introducer_phoneOld,jdbcType=VARCHAR}
  249. </update>
  250. </mapper>