CmPayShopMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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.caimei.modules.order.dao.CmPayShopDao">
  4. <sql id="cmPayShopColumns">
  5. a.id AS "id",
  6. a.shopID AS "shopID",
  7. a.name AS "name",
  8. a.bankAccountName AS "bankAccountName",
  9. a.bankAccount AS "bankAccount",
  10. a.bankName AS "bankName",
  11. a.type AS "type",
  12. a.totalAmount AS "totalAmount",
  13. a.balancePayFee AS "balancePayFee",
  14. a.transferPayFee AS "transferPayFee",
  15. a.payType AS "payType",
  16. a.wipePayment AS "wipePayment",
  17. a.wipeRemarks AS "wipeRemarks",
  18. a.wipeRemarkImages AS "wipeRemarkImages",
  19. a.applicant AS "applicant",
  20. a.applyTime AS "applyTime",
  21. a.wipeTime AS "wipeTime",
  22. a.reviewer AS "reviewer",
  23. a.reviewTime AS "reviewTime",
  24. a.payTime AS "payTime",
  25. a.status AS "status",
  26. a.reason AS "reason",
  27. a.delFlag AS "delFlag"
  28. </sql>
  29. <sql id="cmPayShopJoins">
  30. </sql>
  31. <select id="get" resultType="CmPayShop">
  32. SELECT
  33. <include refid="cmPayShopColumns"/>,
  34. u1.name AS applicantName,
  35. u2.name AS reviewerName,
  36. s.name AS shopName,
  37. s.ableRebateAmount AS ableRebateAmount,
  38. s.rebateAmount AS rebateAmount,
  39. (SELECT paymentType FROM cm_pay_shop_record WHERE payShopID = a.id LIMIT 1) AS paymentType
  40. FROM cm_pay_shop a
  41. <include refid="cmPayShopJoins"/>
  42. left join shop s on s.shopID = a.shopID
  43. left join sys_user u1 on u1.id = a.applicant
  44. left join sys_user u2 on u2.id = a.reviewer
  45. WHERE a.id = #{id}
  46. </select>
  47. <select id="getPayShopByShopOrderId" resultType="com.caimei.modules.order.entity.CmPayShop">
  48. SELECT
  49. <include refid="cmPayShopColumns"/>
  50. FROM cm_pay_shop a
  51. left join cm_pay_shop_record cpsr on a.id = cpsr.payShopID
  52. <include refid="cmPayShopJoins"/>
  53. left join shop s on s.shopID = a.shopID
  54. left join sys_user u1 on u1.id = a.applicant
  55. left join sys_user u2 on u2.id = a.reviewer
  56. where cpsr.shopOrderID=#{shopOrderID}
  57. and a.delFlag = '0'
  58. order by a.id desc
  59. limit 1
  60. </select>
  61. <select id="findList" resultType="CmPayShop">
  62. SELECT
  63. <include refid="cmPayShopColumns"/>,
  64. u1.name AS applicantName,
  65. u2.name AS reviewerName,
  66. s.name AS shopName,
  67. (SELECT paymentType FROM cm_pay_shop_record WHERE payShopID = a.id LIMIT 1) AS paymentType
  68. FROM cm_pay_shop a
  69. left join sys_user u1 on u1.id = a.applicant
  70. left join sys_user u2 on u2.id = a.reviewer
  71. left join shop s on s.shopID = a.shopID
  72. <where>
  73. <if test="id != null and id != ''">
  74. and a.id = #{id}
  75. </if>
  76. <if test="shopName != null and shopName != ''">
  77. and s.name like concat('%', #{shopName}, '%')
  78. </if>
  79. <if test="name != null and name != ''">
  80. AND a.name LIKE
  81. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  82. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  83. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  84. </if>
  85. <if test="startTime != null and startTime != ''">
  86. AND a.applyTime <![CDATA[ >= ]]> #{startTime}
  87. </if>
  88. <if test="endTime != null and endTime != ''">
  89. AND a.applyTime <![CDATA[ <= ]]> #{endTime}
  90. </if>
  91. <if test="status != null and status != ''">
  92. AND a.status = #{status}
  93. </if>
  94. <if test="shopOrderNo != null and shopOrderNo != ''">
  95. AND a.id in (select cpsr.payShopID from cm_pay_shop_record cpsr where cpsr.shopOrderNo like concat('%',#{shopOrderNo},'%'))
  96. </if>
  97. <if test="shopOrderID != null and shopOrderID != ''">
  98. AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr WHERE cpsr.shopOrderID=#{shopOrderID})
  99. </if>
  100. <if test="orderID != null and orderID != ''">
  101. AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderID=#{orderID})
  102. </if>
  103. <if test='organizeID != null and organizeID != "" and organizeID != "9999"'>
  104. AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.organizeID = #{organizeID})
  105. </if>
  106. <if test='organizeID == "9999"'>
  107. AND a.id IN (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderType = 2)
  108. </if>
  109. <if test="orderNo != null and orderNo != ''">
  110. AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderNo LIKE CONCAT('%',#{orderNo},'%'))
  111. </if>
  112. <if test="paymentType != null">
  113. AND a.id IN(SELECT payShopID FROM cm_pay_shop_record WHERE paymentType = #{paymentType} AND delFlag = 0)
  114. </if>
  115. and a.delFlag = '0'
  116. and a.shopID != 998
  117. </where>
  118. <choose>
  119. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  120. ORDER BY ${page.orderBy}
  121. </when>
  122. <otherwise>
  123. ORDER BY a.id desc
  124. </otherwise>
  125. </choose>
  126. </select>
  127. <select id="findAllList" resultType="CmPayShop">
  128. SELECT
  129. <include refid="cmPayShopColumns"/>
  130. FROM cm_pay_shop a
  131. <include refid="cmPayShopJoins"/>
  132. <where>
  133. </where>
  134. <choose>
  135. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  136. ORDER BY ${page.orderBy}
  137. </when>
  138. <otherwise>
  139. </otherwise>
  140. </choose>
  141. </select>
  142. <insert id="insert" parameterType="CmPayShop" keyProperty="id" useGeneratedKeys="true">
  143. INSERT INTO cm_pay_shop(
  144. shopID,
  145. name,
  146. bankAccountName,
  147. bankAccount,
  148. bankName,
  149. type,
  150. totalAmount,
  151. balancePayFee,
  152. transferPayFee,
  153. payType,
  154. wipePayment,
  155. wipeRemarks,
  156. wipeRemarkImages,
  157. wipeTime,
  158. applicant,
  159. applyTime,
  160. reviewer,
  161. reviewTime,
  162. payTime,
  163. status,
  164. reason,
  165. delFlag
  166. ) VALUES (
  167. #{shopID},
  168. #{name},
  169. #{bankAccountName},
  170. #{bankAccount},
  171. #{bankName},
  172. #{type},
  173. #{totalAmount},
  174. #{balancePayFee},
  175. #{transferPayFee},
  176. #{payType},
  177. #{wipePayment},
  178. #{wipeRemarks},
  179. #{wipeRemarkImages},
  180. #{wipeTime},
  181. #{applicant},
  182. #{applyTime},
  183. #{reviewer},
  184. #{reviewTime},
  185. #{payTime},
  186. #{status},
  187. #{reason},
  188. #{delFlag}
  189. )
  190. </insert>
  191. <update id="update">
  192. UPDATE cm_pay_shop SET
  193. shopID = #{shopID},
  194. name = #{name},
  195. bankAccountName = #{bankAccountName},
  196. bankAccount = #{bankAccount},
  197. bankName = #{bankName},
  198. type = #{type},
  199. totalAmount = #{totalAmount},
  200. balancePayFee = #{balancePayFee},
  201. transferPayFee = #{transferPayFee},
  202. payType = #{payType},
  203. wipePayment = #{wipePayment},
  204. wipeRemarks = #{wipeRemarks},
  205. wipeRemarkImages = #{wipeRemarkImages},
  206. wipeTime = #{wipeTime},
  207. applicant = #{applicant},
  208. applyTime = #{applyTime},
  209. reviewer = #{reviewer},
  210. reviewTime = #{reviewTime},
  211. payTime = #{payTime},
  212. status = #{status},
  213. reason = #{reason},
  214. delFlag = #{delFlag}
  215. WHERE id = #{id}
  216. </update>
  217. <delete id="delete">
  218. DELETE FROM cm_pay_shop
  219. WHERE id = #{id}
  220. </delete>
  221. <select id="orderList" parameterType="string" resultType="com.caimei.modules.order.entity.NewShopOrder">
  222. SELECT DISTINCT so.shopOrderID, so.shopOrderNo, so.orderNo, so.orderID, bou.name AS buyer ,so.organizeID,c.name AS clubName
  223. FROM `cm_pay_shop_record` psr
  224. LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
  225. LEFT JOIN bp_order_userinfo bou ON so.orderId = bou.orderId
  226. LEFT JOIN club c ON c.userID = so.userID
  227. WHERE psr.payShopID = #{id}
  228. AND psr.delFlag = '0'
  229. </select>
  230. <select id="hasReapply" resultType="integer">
  231. select id from cm_pay_shop_record where shopOrderID in
  232. <foreach collection="shopOrderIds" open="(" close=")" item="shopOrderId" separator=",">
  233. #{shopOrderId}
  234. </foreach>
  235. and payShopID > #{id}
  236. </select>
  237. <select id="findPayOnlineStatus" resultType="java.lang.Integer">
  238. select status from cm_pay_online_switch where id=1
  239. </select>
  240. <select id="getShopOrderIdsList" resultType="java.lang.Integer">
  241. SELECT DISTINCT shopOrderID FROM cm_pay_shop_record WHERE payShopID = #{payShopID} AND delFlag = '0'
  242. </select>
  243. <update id="savePayOnlineStatus">
  244. update cm_pay_online_switch set
  245. status=#{status},
  246. sysUserId=#{userId},
  247. updateTime=NOW()
  248. where id=1
  249. </update>
  250. <select id="getDiscernReceipts" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
  251. SELECT
  252. cdr.id,
  253. cdr.payType,
  254. cdr.receiptType,
  255. cdr.receiptAmount,
  256. cdr.receiptDate
  257. FROM
  258. cm_discern_receipt cdr
  259. LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptID
  260. WHERE
  261. cror.relationType = 1
  262. AND cror.delFlag = 0
  263. AND cror.orderID = #{shopOrderId}
  264. AND cdr.receiptType = 5
  265. AND cdr.receiptStatus = 2
  266. ORDER BY
  267. receiptDate DESC
  268. </select>
  269. </mapper>