Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

227 linhas
9.3 KiB

  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.iformall.mapper.WxThirdPartyOrdersMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxThirdPartyOrders">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="source_app_id" jdbcType="VARCHAR" property="sourceAppId"/>
  9. <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
  10. <result column="notice_id" jdbcType="VARCHAR" property="noticeId" />
  11. <result column="notice_create_time" jdbcType="TIMESTAMP" property="noticeCreateTime"/>
  12. <result column="notice_event_type" jdbcType="VARCHAR" property="noticeEventType" />
  13. <result column="summary" jdbcType="VARCHAR" property="summary" />
  14. <result column="shop_name" jdbcType="VARCHAR" property="shopName" />
  15. <result column="shop_number" jdbcType="VARCHAR" property="shopNumber" />
  16. <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
  17. <result column="user_number" jdbcType="VARCHAR" property="userNumber" />
  18. <result column="time_end" jdbcType="TIMESTAMP" property="timeEnd"/>
  19. <result column="amount" jdbcType="INTEGER" property="amount"/>
  20. <result column="pay_amount" jdbcType="INTEGER" property="payAmount"/>
  21. <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
  22. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  23. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  24. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  25. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  26. <result column="earn_points" jdbcType="TINYINT" property="earnPoints"/>
  27. <result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/>
  28. <result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/>
  29. <result column="is_refund" jdbcType="TINYINT" property="isRefund"/>
  30. <result column="order_status" jdbcType="TINYINT" property="orderStatus"/>
  31. <result column="refund_id" jdbcType="VARCHAR" property="refundId" />
  32. <result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>
  33. </resultMap>
  34. <sql id="allColumns">
  35. `id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`,`notice_id`, `notice_create_time`, `notice_event_type`,
  36. `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`,
  37. `time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
  38. `merchant_id`, `c_user_id`, `earn_points`, `increased_points`, `points_update_time`,
  39. `is_refund`, `order_status`, `refund_id`, `refund_amount`
  40. </sql>
  41. <sql id="dynamicWhereConditions">
  42. where 1 = 1
  43. <if test=" null != id ">
  44. and `id` = #{id}
  45. </if>
  46. <if test=" null != tenantId and '' != tenantId">
  47. and `tenant_id` = #{tenantId}
  48. </if>
  49. <if test=" null != parentTenantId and '' != parentTenantId">
  50. and `parent_tenant_id` = #{parentTenantId}
  51. </if>
  52. <if test=" null != sourceAppId and '' != sourceAppId">
  53. and `source_app_id` = #{sourceAppId}
  54. </if>
  55. <if test=" null != sourceType and '' != sourceType">
  56. and `source_type` = #{sourceType}
  57. </if>
  58. <if test=" null != shopName ">
  59. and `shop_name` like concat('%', #{shopName},'%')
  60. </if>
  61. <if test=" null != shopNumber and '' != shopNumber">
  62. and `shop_number` = #{shopNumber}
  63. </if>
  64. <if test=" null != userPhone and '' != userPhone">
  65. and `user_phone` = #{userPhone}
  66. </if>
  67. <if test=" null != userNumber and '' != userNumber">
  68. and `user_number` = #{userNumber}
  69. </if>
  70. <if test=" null != noticeId and '' != noticeId">
  71. and `notice_id` = #{noticeId}
  72. </if>
  73. <if test=" null != startTime ">
  74. and `time_end` &gt;= #{startTime}
  75. </if>
  76. <if test=" null != endTime">
  77. and `time_end` &lt; #{endTime}
  78. </if>
  79. <if test=" null != transactionId and '' != transactionId">
  80. and `transaction_id` = #{transactionId}
  81. </if>
  82. <if test=" null != merchantId ">
  83. and `merchant_id` = #{merchantId}
  84. </if>
  85. <if test=" null != cUserId ">
  86. and `c_user_id` = #{cUserId}
  87. </if>
  88. <if test=" null != earnPoints ">
  89. and `earn_points` = #{earnPoints}
  90. </if>
  91. <if test=" null != isRefund ">
  92. and `is_refund` = #{isRefund}
  93. </if>
  94. <if test=" null != orderStatus ">
  95. and `order_status` = #{orderStatus}
  96. </if>
  97. <if test=" null != refundId and '' != refundId">
  98. and `refund_id` = #{refundId}
  99. </if>
  100. <if test=" null != ids ">
  101. and `id` in
  102. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  103. #{idItem}
  104. </foreach>
  105. </if>
  106. <if test=" null != sortColumns">order by ${sortColumns}</if>
  107. </sql>
  108. <select id="findList" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  109. select
  110. <include refid="allColumns"/>
  111. from wx_third_party_orders
  112. <include refid="dynamicWhereConditions"/>
  113. </select>
  114. <select id="getById" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  115. select
  116. <include refid="allColumns"/>
  117. from wx_third_party_orders
  118. where `id` = #{id}
  119. and tenant_id=#{tenantId}
  120. </select>
  121. <select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  122. select
  123. <include refid="allColumns"/>
  124. from wx_third_party_orders
  125. where `is_refund` = 0
  126. and `source_type` = #{sourceType}
  127. and `tenant_id` = #{tenantId}
  128. and `transaction_id` = #{transactionId}
  129. </select>
  130. <select id="getRefundOrderByRefundId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  131. select
  132. <include refid="allColumns"/>
  133. from wx_third_party_orders
  134. where `is_refund` = 1
  135. and `source_type` = #{sourceType}
  136. and tenant_id = #{tenantId}
  137. and `refund_id` = #{refundId}
  138. </select>
  139. <select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  140. select
  141. <include refid="allColumns"/>
  142. from wx_third_party_orders
  143. where `is_refund` = 1
  144. and `source_type` = #{sourceType}
  145. and `tenant_id` = #{tenantId}
  146. and `transaction_id` = #{transactionId}
  147. </select>
  148. <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
  149. INSERT INTO wx_third_party_orders (
  150. `id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
  151. `summary`, `shop_name`, `shop_number`, `user_phone`, `user_number`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
  152. `merchant_id`, `c_user_id`, `earn_points`, `is_refund`
  153. )
  154. VALUES(
  155. #{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
  156. #{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime},
  157. #{merchantId},#{cUserId},0,0
  158. );
  159. </insert>
  160. <update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
  161. update wx_third_party_orders set
  162. `earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime},
  163. `update_time` = #{updateTime}
  164. where `id` = #{id} and `tenant_id` = #{tenantId}
  165. </update>
  166. <insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
  167. INSERT INTO wx_third_party_orders (
  168. `id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
  169. `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `create_time`, `update_time`,
  170. `merchant_id`, `c_user_id`, `earn_points`, `is_refund`, `refund_id`, `refund_amount`
  171. )
  172. VALUES(
  173. #{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
  174. #{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime},
  175. #{merchantId},#{cUserId},0,1,#{refundId},#{refundAmount}
  176. );
  177. </insert>
  178. <update id="updateOrderStatus" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
  179. update wx_third_party_orders set
  180. `order_status` = #{orderStatus},
  181. `update_time` = #{updateTime}
  182. where `id` = #{id} and `tenant_id` = #{tenantId}
  183. </update>
  184. </mapper>