agentInfoMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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.iamberry.wechat.service.mapper.AgentInfoMapper">
  4. <sql id="agentConfig">
  5. config_id configId,
  6. agent_id agentId,
  7. color_id colorId,
  8. config_amount configAmount,
  9. config_status configStatus,
  10. config_create_time configCreateTime
  11. </sql>
  12. <sql id="agentInfo">
  13. agent_id agentId,
  14. agent_name agentName,
  15. agent_addr agentAddr,
  16. agent_tel agentTel,
  17. agent_role_id agentRoleId,
  18. agent_create_date agentCreateDate,
  19. agent_status agentStatus,
  20. agent_openid agentOpenid
  21. </sql>
  22. <!-- 查询代理商列表 -->
  23. <select id="listAgentTooth" parameterType="AgentTooth" resultType="AgentTooth">
  24. select <include refid="agentInfo"/> from tb_iamberry_agent_agentinfo where agent_status = #{agentStatus}
  25. </select>
  26. <!-- 查询代理商配置金额集合 -->
  27. <select id="listAgentConfig" parameterType="AgentConfig" resultType="AgentConfig">
  28. select
  29. a.config_id configId,
  30. a.agent_id agentId,
  31. a.color_id colorId,
  32. a.config_amount configAmount,
  33. a.config_status configStatus,
  34. a.config_create_time configCreateTime,
  35. c.color_name colorName,
  36. p.product_name productName,
  37. i.agent_name agentName,
  38. i.agent_tel agentTel
  39. from
  40. tb_iamberry_agent_config a
  41. LEFT JOIN tb_iamberry_agent_agentinfo i ON a.agent_id = i.agent_id
  42. LEFT JOIN tb_iamberry_product_color c ON a.color_id = c.color_id
  43. LEFT JOIN tb_iamberry_product_info p ON c.color_product_id = p.product_id
  44. <where>
  45. <if test="configId != null and configId != ''">
  46. a.config_id = #{configId}
  47. </if>
  48. <if test="agentName != null and agentName != ''">
  49. and i.agent_name like CONCAT('%',#{agentName},'%')
  50. </if>
  51. <if test="agentTel != null and agentTel != ''">
  52. and i.agent_tel like CONCAT('%',#{agentTel},'%')
  53. </if>
  54. <if test="productName != null and productName != ''">
  55. and p.product_name like CONCAT('%',#{productName},'%')
  56. </if>
  57. <if test="colorName != null and colorName != ''">
  58. and c.color_name like CONCAT('%',#{colorName},'%')
  59. </if>
  60. <if test="agentId != null and agentId != ''">
  61. and a.agent_id = #{agentId}
  62. </if>
  63. <if test="configStatus != null">
  64. AND config_status = #{configStatus}
  65. </if>
  66. </where>
  67. ORDER BY a.config_create_time DESC
  68. <if test="page!=null and page.pageSize>0 ">
  69. LIMIT ${page.recordBegin},${page.pageSize}
  70. </if>
  71. </select>
  72. <!-- 查询代理商配置金额数量 -->
  73. <select id="listAgentConfigCount" parameterType="AgentConfig" resultType="Integer">
  74. select
  75. count(a.config_id)
  76. from
  77. tb_iamberry_agent_config a
  78. LEFT JOIN tb_iamberry_agent_agentinfo i ON a.agent_id = i.agent_id
  79. LEFT JOIN tb_iamberry_product_color c ON a.color_id = c.color_id
  80. LEFT JOIN tb_iamberry_product_info p ON c.color_product_id = p.product_id
  81. <where>
  82. <if test="configId != null and configId != ''">
  83. a.config_id = #{configId}
  84. </if>
  85. <if test="agentName != null and agentName != ''">
  86. and i.agent_name like CONCAT('%',#{agentName},'%')
  87. </if>
  88. <if test="agentTel != null and agentTel != ''">
  89. and i.agent_tel like CONCAT('%',#{agentTel},'%')
  90. </if>
  91. <if test="productName != null and productName != ''">
  92. and p.product_name like CONCAT('%',#{productName},'%')
  93. </if>
  94. <if test="colorName != null and colorName != ''">
  95. and c.color_name like CONCAT('%',#{colorName},'%')
  96. </if>
  97. </where>
  98. ORDER BY a.config_create_time DESC
  99. </select>
  100. <!-- 批量新增代理商配置信息 -->
  101. <insert id="addAgentConfigList" parameterType="ArrayList">
  102. <selectKey resultType="int" keyProperty="configId" order="AFTER">
  103. SELECT
  104. LAST_INSERT_ID()
  105. </selectKey>
  106. INSERT INTO tb_iamberry_agent_config
  107. (
  108. agent_id,color_id,config_amount,
  109. config_status,config_create_time
  110. )
  111. VALUES
  112. <foreach collection="list" item="item" index="index" separator="," >
  113. (
  114. #{item.agentId},#{item.colorId},#{item.configAmount},
  115. #{item.configStatus},NOW()
  116. )
  117. </foreach>
  118. </insert>
  119. <!-- 修改代理商优惠价配置信息 -->
  120. <update id="updateAgentConfig" parameterType="AgentConfig">
  121. update
  122. tb_iamberry_agent_config
  123. <set>
  124. <if test="agentId != null and agentId != ''">
  125. agent_id = #{agentId},
  126. </if>
  127. <if test="colorId != null and colorId != ''">
  128. color_id = #{colorId},
  129. </if>
  130. <if test="configAmount != null and configAmount != ''">
  131. config_amount = #{configAmount},
  132. </if>
  133. <if test="configStatus != null and configStatus != ''">
  134. config_status = #{configStatus}
  135. </if>
  136. </set>
  137. <where>
  138. config_id = #{configId}
  139. </where>
  140. </update>
  141. <!-- 查询代理商配置金额 -->
  142. <select id="getAgentConfig" parameterType="AgentConfig" resultType="AgentConfig">
  143. select
  144. <include refid="agentConfig"/>
  145. from
  146. tb_iamberry_agent_config
  147. <where>
  148. <if test="agentId !=null and agentId !=''">
  149. agent_id = #{agentId}
  150. </if>
  151. <if test="colorId !=null and colorId !=''">
  152. AND color_id = #{colorId}
  153. </if>
  154. <if test="configStatus != null">
  155. AND config_status = #{configStatus}
  156. </if>
  157. <if test="configId !=null and configId !=''">
  158. AND config_id = #{configId}
  159. </if>
  160. </where>
  161. </select>
  162. <!-- 查询代理商配置金额 -->
  163. <select id="getAgentTooth" parameterType="AgentTooth" resultType="AgentTooth">
  164. SELECT
  165. <include refid="agentInfo"/>,
  166. user_head agentHead
  167. FROM
  168. tb_iamberry_agent_agentinfo
  169. LEFT JOIN tb_iamberry_user_userinfo ON agent_openid = user_openid
  170. <where>
  171. <if test="agentOpenid !=null and agentOpenid !=''">
  172. agent_openid = #{agentOpenid}
  173. </if>
  174. <if test="agentId !=null and agentId !=''">
  175. AND agent_id = #{agentId}
  176. </if>
  177. <if test="agentTel != null and agentTel != ''">
  178. and agent_tel = #{agentTel}
  179. </if>
  180. <if test="agentStatus != null and agentStatus != ''">
  181. and agent_status = #{agentStatus}
  182. </if>
  183. </where>
  184. </select>
  185. <!-- 修改代理商信息 -->
  186. <update id="updateAgentTooth" parameterType="AgentTooth">
  187. update
  188. tb_iamberry_agent_agentinfo
  189. <set>
  190. <if test="agentName != null and agentName != ''">
  191. agent_name = #{agentName},
  192. </if>
  193. <if test="agentAddr != null and agentAddr != ''">
  194. agent_addr = #{agentAddr},
  195. </if>
  196. <if test="agentTel != null and agentTel != ''">
  197. agent_tel = #{agentTel},
  198. </if>
  199. <if test="agentRoleId != null and agentRoleId != ''">
  200. agent_role_id = #{agentRoleId},
  201. </if>
  202. <if test="agentStatus != null and agentStatus != ''">
  203. agent_status = #{agentStatus},
  204. </if>
  205. <if test="agentStatus != null and agentStatus != ''">
  206. agent_openid = #{agentOpenid}
  207. </if>
  208. </set>
  209. <where>
  210. <if test="agentId != null and agentId != ''">
  211. agent_id = #{agentId}
  212. </if>
  213. <if test="agentTel != null and agentTel != ''">
  214. and agent_tel = #{agentTel}
  215. </if>
  216. </where>
  217. </update>
  218. <!-- 激活代理商 -->
  219. <update id="updateAgentOpenId" parameterType="AgentTooth">
  220. update
  221. tb_iamberry_agent_agentinfo
  222. <set>
  223. <if test="agentOpenid != null and agentOpenid != ''">
  224. agent_openid = #{agentOpenid}
  225. </if>
  226. </set>
  227. <where>
  228. agent_tel = #{agentTel}
  229. </where>
  230. </update>
  231. <!--查询所有代理商 -->
  232. <select id="selectAllAgentinfo" parameterType="AgentTooth" resultType="AgentTooth">
  233. SELECT
  234. <include refid="agentInfo" />
  235. FROM
  236. tb_iamberry_agent_agentinfo
  237. <where>
  238. <if test="agentName != null">
  239. and agent_name = #{agentName}
  240. </if>
  241. <if test="agentTel!=null and agentTel!=''">
  242. and agent_tel = #{agentTel}
  243. </if>
  244. <if test="agentRoleId!=null and agentRoleId!=''">
  245. and agent_role_id = #{agentRoleId}
  246. </if>
  247. <if test="agentStatus!=null and agentStatus!=''">
  248. and agent_status = #{agentStatus}
  249. </if>
  250. </where>
  251. order by agent_create_date desc
  252. <if test="page!=null and page.pageSize>0 ">
  253. LIMIT ${page.recordBegin},${page.pageSize}
  254. </if>
  255. </select>
  256. <!-- 查询所有物流信息(代理商赠送机器记录)总数 -->
  257. <select id="selectAllAgentinfoCount" parameterType="AgentTooth" resultType="Integer">
  258. SELECT
  259. count(*)
  260. FROM
  261. tb_iamberry_agent_agentinfo
  262. <where>
  263. <if test="agentName != null">
  264. and agent_name = #{agentName}
  265. </if>
  266. <if test="agentTel!=null and agentTel!=''">
  267. and agent_tel = #{agentTel}
  268. </if>
  269. <if test="agentRoleId!=null and agentRoleId!=''">
  270. and agent_role_id = #{agentRoleId}
  271. </if>
  272. <if test="agentStatus!=null and agentStatus!=''">
  273. and agent_status = #{agentStatus}
  274. </if>
  275. </where>
  276. </select>
  277. <!--新增代理商 -->
  278. <insert id="addAgentinfo" parameterType="AgentTooth" >
  279. INSERT INTO tb_iamberry_agent_agentinfo(
  280. agent_name,
  281. agent_addr,
  282. agent_tel,
  283. agent_role_id,
  284. agent_create_date,
  285. agent_status,
  286. agent_openid
  287. )
  288. VALUES
  289. (
  290. #{agentName} ,
  291. #{agentAddr},
  292. #{agentTel},
  293. #{agentRoleId},
  294. NOW(),
  295. #{agentStatus},
  296. #{agentOpenid}
  297. )
  298. </insert>
  299. </mapper>