后台服务
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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