后台服务
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

263 satır
11 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="merchant_name" jdbcType="VARCHAR" property="merchantName" />
  26. <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/>
  27. <result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" />
  28. <result column="c_user_phone" jdbcType="VARCHAR" property="cUserPhone" />
  29. <result column="earn_points" jdbcType="TINYINT" property="earnPoints"/>
  30. <result column="increased_points" jdbcType="INTEGER" property="increasedPoints"/>
  31. <result column="points_update_time" jdbcType="TIMESTAMP" property="pointsUpdateTime"/>
  32. <result column="is_refund" jdbcType="TINYINT" property="isRefund"/>
  33. <result column="order_status" jdbcType="TINYINT" property="orderStatus"/>
  34. <result column="refund_id" jdbcType="VARCHAR" property="refundId" />
  35. <result column="refund_amount" jdbcType="INTEGER" property="refundAmount"/>
  36. </resultMap>
  37. <sql id="allColumns">
  38. `id`, `tenant_id`, `parent_tenant_id`, `source_app_id`, `source_type`,`notice_id`, `notice_create_time`, `notice_event_type`,
  39. `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`,
  40. `time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
  41. `merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`,
  42. `earn_points`, `increased_points`, `points_update_time`,
  43. `is_refund`, `order_status`, `refund_id`, `refund_amount`
  44. </sql>
  45. <sql id="dynamicWhereConditions">
  46. where 1 = 1
  47. <if test=" null != id ">
  48. and `id` = #{id}
  49. </if>
  50. <if test=" null != tenantId and '' != tenantId">
  51. and `tenant_id` = #{tenantId}
  52. </if>
  53. <if test=" null != parentTenantId and '' != parentTenantId">
  54. and `parent_tenant_id` = #{parentTenantId}
  55. </if>
  56. <if test=" null != sourceAppId and '' != sourceAppId">
  57. and `source_app_id` = #{sourceAppId}
  58. </if>
  59. <if test=" null != sourceType and '' != sourceType">
  60. and `source_type` = #{sourceType}
  61. </if>
  62. <if test=" null != shopName ">
  63. and `shop_name` like concat('%', #{shopName},'%')
  64. </if>
  65. <if test=" null != shopNumber and '' != shopNumber">
  66. and `shop_number` = #{shopNumber}
  67. </if>
  68. <if test=" null != userPhone and '' != userPhone">
  69. and `user_phone` = #{userPhone}
  70. </if>
  71. <if test=" null != userNumber and '' != userNumber">
  72. and `user_number` = #{userNumber}
  73. </if>
  74. <if test=" null != noticeId and '' != noticeId">
  75. and `notice_id` = #{noticeId}
  76. </if>
  77. <if test=" null != startTime ">
  78. and `time_end` &gt;= #{startTime}
  79. </if>
  80. <if test=" null != endTime">
  81. and `time_end` &lt; #{endTime}
  82. </if>
  83. <if test=" null != transactionId and '' != transactionId">
  84. and `transaction_id` = #{transactionId}
  85. </if>
  86. <if test=" null != merchantId ">
  87. and `merchant_id` = #{merchantId}
  88. </if>
  89. <if test=" null != merchantName and ''!=merchantName">
  90. and `merchant_name` like concat('%', #{merchantName},'%')
  91. </if>
  92. <if test=" null != cUserId ">
  93. and `c_user_id` = #{cUserId}
  94. </if>
  95. <if test=" null != cUserNickName and ''!=cUserNickName">
  96. and `c_user_nick_name` like concat('%', #{cUserNickName},'%')
  97. </if>
  98. <if test=" null != cUserPhone and ''!=cUserPhone">
  99. and `c_user_phone` like concat('%', #{cUserPhone},'%')
  100. </if>
  101. <if test=" null != earnPoints ">
  102. and `earn_points` = #{earnPoints}
  103. </if>
  104. <if test=" null != isRefund ">
  105. and `is_refund` = #{isRefund}
  106. </if>
  107. <if test=" null != orderStatus ">
  108. and `order_status` = #{orderStatus}
  109. </if>
  110. <if test=" null != refundId and '' != refundId">
  111. and `refund_id` = #{refundId}
  112. </if>
  113. <if test=" null != ids ">
  114. and `id` in
  115. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  116. #{idItem}
  117. </foreach>
  118. </if>
  119. </sql>
  120. <select id="findList" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  121. select
  122. <include refid="allColumns"/>
  123. from wx_third_party_orders
  124. <include refid="dynamicWhereConditions"/>
  125. <if test=" null != sortColumns">order by ${sortColumns}</if>
  126. </select>
  127. <select id="findListVo" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultType="com.iformall.domain.vo.WxThirdPartyOrdersVo">
  128. select
  129. <include refid="allColumns"/>
  130. from wx_third_party_orders
  131. <include refid="dynamicWhereConditions"/>
  132. </select>
  133. <select id="getById" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  134. select
  135. <include refid="allColumns"/>
  136. from wx_third_party_orders
  137. where `id` = #{id}
  138. and tenant_id=#{tenantId}
  139. </select>
  140. <select id="getOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  141. select
  142. <include refid="allColumns"/>
  143. from wx_third_party_orders
  144. where `is_refund` = 0
  145. and `source_type` = #{sourceType}
  146. and `tenant_id` = #{tenantId}
  147. and `transaction_id` = #{transactionId}
  148. </select>
  149. <select id="getRefundOrderByRefundId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  150. select
  151. <include refid="allColumns"/>
  152. from wx_third_party_orders
  153. where `is_refund` = 1
  154. and `source_type` = #{sourceType}
  155. and tenant_id = #{tenantId}
  156. and `refund_id` = #{refundId}
  157. </select>
  158. <select id="getRefundOrderByTransactionId" parameterType="com.iformall.domain.po.WxThirdPartyOrders" resultMap="BaseResultMap">
  159. select
  160. <include refid="allColumns"/>
  161. from wx_third_party_orders
  162. where `is_refund` = 1
  163. and `source_type` = #{sourceType}
  164. and `tenant_id` = #{tenantId}
  165. and `transaction_id` = #{transactionId}
  166. </select>
  167. <insert id="insertNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
  168. INSERT INTO wx_third_party_orders (
  169. `id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
  170. `summary`, `shop_name`, `shop_number`, `user_phone`, `user_number`,`time_end`, `amount`, `pay_amount`, `transaction_id`, `create_time`, `update_time`,
  171. `merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund`
  172. )
  173. VALUES(
  174. #{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
  175. #{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime},
  176. #{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,0
  177. );
  178. </insert>
  179. <update id="updatePoints" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
  180. update wx_third_party_orders set
  181. `earn_points` = 1, `increased_points` = #{increasedPoints}, `points_update_time` = #{pointsUpdateTime},
  182. `update_time` = #{updateTime}
  183. where `id` = #{id} and `tenant_id` = #{tenantId}
  184. </update>
  185. <insert id="insertRefundNoticeOrder" parameterType="com.iformall.domain.po.WxThirdPartyOrders" >
  186. INSERT INTO wx_third_party_orders (
  187. `id`, `tenant_id`, `parent_tenant_id`,`source_app_id`, `source_type`, `notice_id`, `notice_create_time`, `notice_event_type`,
  188. `summary`,`shop_name`, `shop_number`, `user_phone`, `user_number`, `time_end`, `amount`,`pay_amount`, `transaction_id`, `create_time`, `update_time`,
  189. `merchant_id`,`merchant_name`, `c_user_id`, `c_user_nick_name`, `c_user_phone`, `earn_points`, `is_refund`, `refund_id`, `refund_amount`
  190. )
  191. VALUES(
  192. #{id},#{tenantId},#{parentTenantId},#{sourceAppId},#{sourceType},#{noticeId},#{noticeCreateTime},#{noticeEventType},
  193. #{summary},#{shopName},#{shopNumber},#{userPhone},#{userNumber},#{timeEnd},#{amount},#{payAmount},#{transactionId},#{createTime},#{updateTime},
  194. #{merchantId},#{merchantName},#{cUserId},#{cUserNickName},#{cUserPhone},0,1,#{refundId},#{refundAmount}
  195. );
  196. </insert>
  197. <update id="updateOrderStatus" parameterType="com.iformall.domain.po.WxThirdPartyOrders">
  198. update wx_third_party_orders set
  199. `order_status` = #{orderStatus},
  200. `update_time` = #{updateTime}
  201. where `id` = #{id} and `tenant_id` = #{tenantId}
  202. </update>
  203. <select id="sumCirclePayment" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer">
  204. select
  205. IFNULL(SUM(`pay_amount`),0) as sum_pay_amount
  206. from wx_third_party_orders
  207. <include refid="dynamicWhereConditions"/>
  208. and is_refund = 0
  209. </select>
  210. <select id="sumCircleRefundAmount" parameterType="com.iformall.domain.po.BusinessCircleBase" resultType="Integer">
  211. select
  212. IFNULL(SUM(`refund_amount`),0) as sum_refund_amount
  213. from wx_third_party_orders
  214. <include refid="dynamicWhereConditions"/>
  215. and is_refund = 1
  216. </select>
  217. </mapper>