placeLogsMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. <!-- 命名,每一个映射对象不一样
  4. namespace:必须与对应的接口全类名一致
  5. -->
  6. <mapper namespace="com.iamberry.wechat.service.mapper.PlaceLogsMapper">
  7. <sql id="logsAllField">
  8. t.LOGS_ID id ,
  9. t.LOGS_PLACE_ID placeId,
  10. t.LOGS_NUM nums,
  11. t.LOGS_TYPE type,
  12. t.LOGS_INTRODUCTION introduction,
  13. t.LOGS_RES_TYPE resType,
  14. t.LOGS_CREATE_DATE createDate
  15. </sql>
  16. <select id="getOnePlaceLogs" parameterType="string" resultType="PlaceLogs">
  17. SELECT
  18. <include refid="logsAllField"/>
  19. FROM tb_iamberry_place_logs t WHERE t.LOGS_ID = #{appid}
  20. </select>
  21. <select id="selectAll" resultType="PlaceLogs" parameterType="PlaceLogs">
  22. SELECT
  23. <include refid="logsAllField"/>,
  24. P.PLACE_NAME DRPNAME,
  25. P.PLACE_ROLE_ID drpType
  26. FROM TB_IAMBERRY_PLACE_LOGS T
  27. LEFT JOIN TB_IAMBERRY_PLACE_INFO P
  28. ON P.PLACE_ID=T.LOGS_PLACE_ID
  29. <where>
  30. <if test="placeId!=null and placeId!=''" >
  31. t.LOGS_PLACE_ID=#{placeId}
  32. </if>
  33. <if test="drpName!=null and drpName!=''" >
  34. and p.place_name like CONCAT('%',#{drpName},'%')
  35. </if>
  36. <if test="type!=null and type!=''" >
  37. and t.LOGS_TYPE =#{type}
  38. </if>
  39. <if test="introduction!=null and introduction!=''" >
  40. and t.LOGS_INTRODUCTION =#{introduction}
  41. </if>
  42. <if test="resType!=null and resType!=''" >
  43. and t.LOGS_RES_TYPE =#{resType}
  44. </if>
  45. <if test="beginDate!=null and beginDate!=''">
  46. and p.PLACE_CREATE_DATE &gt; #{beginDate}
  47. </if>
  48. <if test="endDate!=null and endDate!=''">
  49. and p.PLACE_CREATE_DATE &lt; #{endDate}
  50. </if>
  51. </where>
  52. ORDER BY t.LOGS_ID DESC
  53. <if test="page!=null and page.recordBegin>0 and page.pageSize>0 ">
  54. limit ${page.recordBegin},${page.pageSize}
  55. </if>
  56. <if test="page!=null and page.recordBegin==0 and page.pageSize>0 ">
  57. limit ${page.pageSize}
  58. </if>
  59. </select>
  60. <select id="getAllCount" resultType="integer">
  61. select count(t.LOGS_ID) from tb_iamberry_place_logs t
  62. left join tb_iamberry_place_info p
  63. on p.place_id=t.LOGS_PLACE_ID
  64. <where>
  65. <if test="placeId!=null and placeId!=''" >
  66. t.LOGS_PLACE_ID=#{placeId}
  67. </if>
  68. <if test="drpName!=null and drpName!=''" >
  69. and p.place_name like CONCAT('%',#{drpName},'%')
  70. </if>
  71. <if test="type!=null and type!=''" >
  72. and t.LOGS_TYPE =#{type}
  73. </if>
  74. <if test="introduction!=null and introduction!=''" >
  75. and t.LOGS_INTRODUCTION =#{introduction}
  76. </if>
  77. <if test="resType!=null and resType!=''" >
  78. and t.LOGS_RES_TYPE =#{resType}
  79. </if>
  80. <if test="beginDate!=null and beginDate!=''">
  81. and p.PLACE_CREATE_DATE &gt; #{beginDate}
  82. </if>
  83. <if test="endDate!=null and endDate!=''">
  84. and p.PLACE_CREATE_DATE &lt; #{endDate}
  85. </if>
  86. </where>
  87. </select>
  88. <insert id="insert">
  89. insert into
  90. tb_iamberry_place_logs(
  91. LOGS_PLACE_ID ,
  92. LOGS_NUM ,
  93. LOGS_TYPE ,
  94. LOGS_INTRODUCTION ,
  95. LOGS_RES_TYPE ,
  96. LOGS_CREATE_DATE )
  97. values(
  98. #{placeId},
  99. #{nums},
  100. #{type},
  101. #{introduction},
  102. #{resType},
  103. #{createDate})
  104. </insert>
  105. <!-- 根据返利人id和单号模糊查询返利日志信息 -->
  106. <select id="selectPlaceLogInfo" parameterType="PlaceLogs" resultType="PlaceLogs">
  107. SELECT
  108. <include refid="logsAllField"/>
  109. FROM
  110. TB_IAMBERRY_PLACE_LOGS t
  111. WHERE
  112. t.LOGS_PLACE_ID = #{placeId}
  113. AND
  114. t.LOGS_INTRODUCTION LIKE CONCAT('%',#{introduction},'%')
  115. </select>
  116. <!-- 修改了商户层返利日志表 -->
  117. <update id="updatePlaceLogs" parameterType="PlaceLogs">
  118. update tb_iamberry_place_logs
  119. <set>
  120. <if test="placeId!=null and placeId!=''">
  121. LOGS_PLACE_ID =#{placeId},
  122. </if>
  123. <if test="nums!=null and nums!=''">
  124. LOGS_NUM =(LOGS_NUM + #{nums}),
  125. </if>
  126. <if test="type!=null and type!=''">
  127. LOGS_TYPE =#{type},
  128. </if>
  129. <if test="introduction!=null and introduction!=''">
  130. LOGS_INTRODUCTION =#{introduction},
  131. </if>
  132. <if test="resType!=null and resType!=''">
  133. LOGS_RES_TYPE =#{resType},
  134. </if>
  135. </set>
  136. where LOGS_ID = #{id}
  137. </update>
  138. <update id="update" >
  139. update tb_iamberry_place_logs
  140. <set>
  141. <if test="placeId!=null and placeId!=''">
  142. LOGS_PLACE_ID =#{placeId},
  143. </if>
  144. <if test="nums!=null and nums!=''">
  145. LOGS_NUM =#{nums},
  146. </if>
  147. <if test="type!=null and type!=''">
  148. LOGS_TYPE =#{type},
  149. </if>
  150. <if test="introduction!=null and introduction!=''">
  151. LOGS_INTRODUCTION =#{introduction},
  152. </if>
  153. <if test="resType!=null and resType!=''">
  154. LOGS_RES_TYPE =#{resType},
  155. </if>
  156. </set>
  157. where LOGS_ID = #{id}
  158. </update>
  159. <delete id="delete" parameterType="integer">
  160. delete from tb_iamberry_place_logs
  161. where WHERE LOGS_ID = #{appid}
  162. </delete>
  163. <!-- 获取分销商下的所有用户 -->
  164. <select id="getUnInComeOrderUserTop" parameterType="integer" resultType="java.lang.String" >
  165. select user_openid userOpenid
  166. from TB_IAMBERRY_USER_USERINFO
  167. where USER_DEALER=#{id}
  168. ORDER BY USER_ID DESC
  169. </select>
  170. </mapper>