agentPurchaseOrderMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC
  4. "-//mybatis.org//DTD Mapper 3.0//EN"
  5. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  6. <!-- 命名,每一个映射对象不一样
  7. namespace:必须与对应的接口全类名一致
  8. -->
  9. <mapper namespace="com.iamberry.wechat.service.mapper.AgentPurchaseOrderMapper">
  10. <sql id="agentOrderItem">
  11. item_id itemId,
  12. agent_orderid agentOrderid,
  13. product_id productId,
  14. color_id colorId,
  15. product_type productType,
  16. product_rent_type productRentType,
  17. item_num itemNum,
  18. item_total itemTotal,
  19. item_create_date itemCreateDate,
  20. item_product_name itemProductName,
  21. item_color_name itemColorName,
  22. item_product_discount itemProductDiscount,
  23. item_product_price itemProductPrice,
  24. item_product_pic itemProductPic
  25. </sql>
  26. <insert id="addAgentOrder" parameterType="AgentOrder">
  27. insert into tb_iamberry_agent_order (`agent_orderid` ,`agent_id` ,`agent_yet_amount` ,`agent_amount` ,`agent_create_date`,`agent_status` ,`agent_address_info` ,`agent_address_postnum` ,`agent_address_tel` ,`agent_address_name` ,`agent_admin_remark` )
  28. values (#{agentOrderid},#{agentId},#{agentYetAmount},#{agentAmount},#{agentCreateDate},#{agentStatus},#{agentAddressInfo},#{agentAddressPostnum},#{agentAddressTel},#{agentAddressName},#{agentAdminRemark})
  29. </insert>
  30. <insert id="addAgentOrderItemList" parameterType="AgentOrderItem" useGeneratedKeys="true">
  31. insert into tb_iamberry_agent_order_item (`agent_orderid` ,`product_id` ,`color_id` ,`product_type`
  32. ,`product_rent_type` ,`item_num` ,`item_total` ,`item_product_name` ,`item_color_name` ,`item_product_discount`
  33. ,`item_product_price` ,`item_product_pic` )
  34. values
  35. <foreach collection="list" item="item" index="index" separator="," open="" close="">
  36. (#{item.agentOrderid},#{item.productId},#{item.colorId},#{item.productType},#{item.productRentType},#{item.itemNum},#{item.itemTotal},#{item.itemProductName},#{item.itemColorName},#{item.itemProductDiscount},#{item.itemProductPrice},#{item.itemProductPic})
  37. </foreach>
  38. </insert>
  39. <select id="listAgentOrderItem" parameterType="AgentOrderItem" resultType="AgentOrderItem">
  40. SELECT
  41. <include refid="agentOrderItem"></include>
  42. FROM
  43. tb_iamberry_agent_order_item
  44. WHERE
  45. agent_orderid = #{agentOrderid}
  46. ORDER BY item_id DESC
  47. </select>
  48. <update id="updateAgentPurchaseOrder" parameterType="AgentOrder" >
  49. update
  50. tb_iamberry_agent_order
  51. <set>
  52. <if test="agentPostNum !=null and agentPostNum !=''">
  53. agent_post_num = #{agentPostNum},
  54. </if>
  55. <if test="agentPostFirm !=null and agentPostFirm !=''">
  56. agent_post_firm = #{agentPostFirm},
  57. </if>
  58. <if test="agentStatus !=null and agentStatus !=''">
  59. agent_status = #{agentStatus},
  60. </if>
  61. <if test="agentSendDate !=null and agentSendDate !=''">
  62. agent_send_date = #{agentSendDate},
  63. </if>
  64. <if test="agentAddressInfo !=null and agentAddressInfo !=''">
  65. agent_address_info = #{agentAddressInfo},
  66. </if>
  67. <if test="agentAddressPostnum !=null and agentAddressPostnum !=''">
  68. agent_address_postnum = #{agentAddressPostnum},
  69. </if>
  70. <if test="agentAddressTel !=null and agentAddressTel !=''">
  71. agent_address_tel = #{agentAddressTel},
  72. </if>
  73. <if test="agentAddressName !=null and agentAddressName !=''">
  74. agent_address_name = #{agentAddressName},
  75. </if>
  76. <if test="agentAdminRemark !=null and agentAdminRemark !=''">
  77. agent_admin_remark = #{agentAdminRemark},
  78. </if>
  79. <if test="agentTransactionId !=null and agentTransactionId !=''">
  80. agent_transaction_id = #{agentTransactionId},
  81. </if>
  82. <if test="agentTransactionDate !=null and agentTransactionDate !=''">
  83. agent_transaction_date = #{agentTransactionDate},
  84. </if>
  85. </set>
  86. where
  87. agent_orderid = #{agentOrderid}
  88. </update>
  89. <!-- 修改备注信息 -->
  90. <update id="updateRemark" parameterType="AgentOrder">
  91. update
  92. tb_iamberry_agent_order
  93. SET
  94. agent_admin_remark = #{agentAdminRemark}
  95. WHERE
  96. agent_orderid = #{agentOrderid}
  97. </update>
  98. <!-- 查询代理商订单列表 不分页 -->
  99. <select id="listSelectAgentOrder" parameterType="AgentOrder" resultType="AgentOrder">
  100. select
  101. o.agent_orderid agentOrderid,
  102. o.agent_id agentId,
  103. o.agent_yet_amount agentYetAmount,
  104. o.agent_amount agentAmount,
  105. o.agent_create_date agentCreateDate,
  106. o.agent_post_num agentPostNum,
  107. o.agent_post_firm agentPostFirm,
  108. o.agent_status agentStatus,
  109. o.agent_send_date agentSendDate,
  110. o.agent_address_info agentAddressInfo,
  111. o.agent_address_postnum agentAddressPostnum,
  112. o.agent_address_tel agentAddressTel,
  113. o.agent_address_name agentAddressName,
  114. o.agent_admin_remark agentAdminRemark,
  115. o.agent_transaction_id agentTransactionId,
  116. o.agent_transaction_date agentTransactionDate,
  117. a.agent_name agentName,
  118. a.agent_tel agentTel,
  119. a.agent_openid agentOpenId
  120. from
  121. tb_iamberry_agent_order o
  122. LEFT JOIN tb_iamberry_agent_agentinfo a ON o.agent_id = a.agent_id
  123. <where>
  124. <if test="agentOrderid != null and agentOrderid != ''">
  125. o.agent_orderid = #{agentOrderid}
  126. </if>
  127. </where>
  128. </select>
  129. <!-- 查询代理商订单信息,可分页 -->
  130. <select id="listAgentOrder" parameterType="AgentOrder" resultMap="agentOrderMap">
  131. select
  132. o.agent_orderid,
  133. o.agent_id,
  134. o.agent_yet_amount,
  135. o.agent_amount,
  136. o.agent_create_date,
  137. o.agent_post_num,
  138. o.agent_post_firm,
  139. o.agent_status,
  140. o.agent_send_date,
  141. o.agent_address_info,
  142. o.agent_address_postnum,
  143. o.agent_address_tel,
  144. o.agent_address_name,
  145. o.agent_admin_remark,
  146. o.agent_transaction_id,
  147. o.agent_transaction_date,
  148. a.agent_name agentName,
  149. a.agent_tel agentTel
  150. from
  151. tb_iamberry_agent_order o
  152. LEFT JOIN tb_iamberry_agent_agentinfo a ON o.agent_id = a.agent_id
  153. <where>
  154. <if test="agentOrderid != null and agentOrderid != ''">
  155. o.agent_orderid = #{agentOrderid}
  156. </if>
  157. <if test="agentId != null and agentId != ''">
  158. and a.agent_id = #{agentId}
  159. </if>
  160. <if test="agentName != null and agentName != ''">
  161. and a.agent_name like CONCAT('%',#{agentName},'%')
  162. </if>
  163. <if test="agentTel != null and agentTel != ''">
  164. and a.agent_tel like CONCAT('%',#{agentTel},'%')
  165. </if>
  166. <if test="agentAddressName != null and agentAddressName != ''">
  167. and o.agent_address_name like CONCAT('%',#{agentAddressName},'%')
  168. </if>
  169. <if test="agentAddressTel != null and agentAddressTel != ''">
  170. and o.agent_address_tel like CONCAT('%',#{agentAddressTel},'%')
  171. </if>
  172. <if test="agentStatus != null and agentStatus != -1">
  173. and o.agent_status = #{agentStatus}
  174. </if>
  175. <if test="beginDate != null">
  176. AND DATE_FORMAT(o.agent_create_date, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{beginDate},'%Y-%m-%d')
  177. </if>
  178. <if test="endDate != null">
  179. AND DATE_FORMAT(o.agent_create_date, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},'%Y-%m-%d')
  180. </if>
  181. </where>
  182. ORDER BY agent_create_date DESC
  183. <if test="page!=null and page.pageSize>0 ">
  184. LIMIT ${page.recordBegin},${page.pageSize}
  185. </if>
  186. </select>
  187. <resultMap type="com.iamberry.wechat.core.entity.agentInfo.AgentOrder" id="agentOrderMap">
  188. <id column="agent_orderid" property="agentOrderid"/>
  189. <result column="agent_id" property="agentId"/>
  190. <result column="agent_yet_amount" property="agentYetAmount"/>
  191. <result column="agent_amount" property="agentAmount"/>
  192. <result column="agent_create_date" property="agentCreateDate"/>
  193. <result column="agent_post_num" property="agentPostNum"/>
  194. <result column="agent_post_firm" property="agentPostFirm"/>
  195. <result column="agent_status" property="agentStatus"/>
  196. <result column="agent_send_date" property="agentSendDate"/>
  197. <result column="agent_address_info" property="agentAddressInfo"/>
  198. <result column="agent_address_postnum" property="agentAddressPostnum"/>
  199. <result column="agent_address_tel" property="agentAddressTel"/>
  200. <result column="agent_address_name" property="agentAddressName"/>
  201. <result column="agent_admin_remark" property="agentAdminRemark"/>
  202. <result column="agent_transaction_id" property="agentTransactionId"/>
  203. <result column="agent_transaction_date" property="agentTransactionDate"/>
  204. <collection property="itemList" column="agent_orderid" ofType="com.iamberry.wechat.core.entity.agentInfo.AgentOrderItem" select="listAgentItem"/>
  205. </resultMap>
  206. <select id="listAgentItem" parameterType="String" resultType="AgentOrderItem">
  207. SELECT
  208. i.item_id itemId,
  209. i.agent_orderid agentOrderid,
  210. i.product_id productId,
  211. i.color_id colorId,
  212. i.product_type productType,
  213. i.product_rent_type productRentType,
  214. i.item_num itemNum,
  215. i.item_total itemTotal,
  216. i.item_create_date itemCreateDate,
  217. i.item_product_name itemProductName,
  218. i.item_color_name itemColorName,
  219. i.item_product_discount itemProductDiscount,
  220. i.item_product_price itemProductPrice,
  221. i.item_product_pic itemProductPic,
  222. c.color_69code itemProductSKU
  223. FROM
  224. tb_iamberry_agent_order_item i
  225. LEFT JOIN tb_iamberry_product_color c ON i.color_id = c.color_id
  226. WHERE
  227. agent_orderid = #{agentOrderid}
  228. ORDER BY item_id DESC
  229. </select>
  230. <select id="listAgentOrderCount" parameterType="AgentOrder" resultType="Integer">
  231. select
  232. count(o.agent_orderid)
  233. from
  234. tb_iamberry_agent_order o
  235. LEFT JOIN tb_iamberry_agent_agentinfo a ON o.agent_id = a.agent_id
  236. <where>
  237. <if test="agentOrderid != null and agentOrderid != ''">
  238. o.agent_orderid = #{agentOrderid}
  239. </if>
  240. <if test="agentId != null and agentId != ''">
  241. and a.agent_id = #{agentId}
  242. </if>
  243. <if test="agentName != null and agentName != ''">
  244. and a.agent_name like CONCAT('%',#{agentName},'%')
  245. </if>
  246. <if test="agentTel != null and agentTel != ''">
  247. and a.agent_tel like CONCAT('%',#{agentTel},'%')
  248. </if>
  249. <if test="agentAddressName != null and agentAddressName != ''">
  250. and o.agent_address_name like CONCAT('%',#{agentAddressName},'%')
  251. </if>
  252. <if test="agentAddressTel != null and agentAddressTel != ''">
  253. and o.agent_address_tel like CONCAT('%',#{agentAddressTel},'%')
  254. </if>
  255. <if test="agentStatus != null and agentStatus != -1">
  256. and o.agent_status = #{agentStatus}
  257. </if>
  258. <if test="beginDate != null">
  259. AND DATE_FORMAT(o.agent_create_date, '%Y-%m-%d') <![CDATA[ >= ]]> DATE_FORMAT(#{beginDate},'%Y-%m-%d')
  260. </if>
  261. <if test="endDate != null">
  262. AND DATE_FORMAT(o.agent_create_date, '%Y-%m-%d') <![CDATA[ <= ]]> DATE_FORMAT(#{endDate},'%Y-%m-%d')
  263. </if>
  264. </where>
  265. </select>
  266. <!-- 批量查询需要更换刷头的订单 -->
  267. <select id="listOrderHint" parameterType="OrderHint" resultType="OrderHint">
  268. select
  269. *
  270. from
  271. tb_iamberry_order_hint
  272. <where>
  273. <if test="hintTime != null and hintTime != ''">
  274. date_format(hint_time, '%Y-%m-%d') <![CDATA[ <= ]]> date_format(#{hintTime}, '%Y-%m-%d')
  275. </if>
  276. <if test="hintStatus != null and hintStatus != ''">
  277. and hint_status = #{hintStatus}
  278. </if>
  279. <if test="orderId != null and orderId != ''">
  280. and order_id = #{orderId}
  281. </if>
  282. <if test="userOpenId != null and userOpenId != ''">
  283. and user_open_id = #{userOpenId}
  284. </if>
  285. <if test="hintId != null and hintId != ''">
  286. and hint_id = #{hintId}
  287. </if>
  288. </where>
  289. </select>
  290. <!-- 批量修改更换刷头信息 -->
  291. <update id="updateOrderHintList" parameterType="java.util.List">
  292. <foreach collection="list" item="item" index="index" separator=";" open="" close="">
  293. update
  294. tb_iamberry_order_hint
  295. <set>
  296. <if test="item.hintTime != null and item.hintTime != ''">
  297. hint_time = #{item.hintTime},
  298. </if>
  299. <if test="item.hintStatus != null and item.hintStatus != ''">
  300. hint_status = #{item.hintStatus}
  301. </if>
  302. <if test="item.hintNum != null and item.hintNum != ''">
  303. hint_num = (hint_num + 1)
  304. </if>
  305. </set>
  306. <where>
  307. hint_id = #{item.hintId}
  308. </where>
  309. </foreach>
  310. </update>
  311. <!-- 添加更换刷头信息 -->
  312. <insert id="addOrderHint" parameterType="OrderHint"
  313. useGeneratedKeys="true" keyProperty="hintId">
  314. insert into tb_iamberry_order_hint
  315. (
  316. order_id,user_open_id,hint_num,hint_time,
  317. hint_status,hint_create_time
  318. )
  319. values
  320. (
  321. #{orderId},#{userOpenId},#{hintNum},#{hintTime},
  322. #{hintStatus},NOW()
  323. )
  324. </insert>
  325. </mapper>