后台服务
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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