placeLogsMapper.xml 5.3 KB

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