OrderPayApplyMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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.hcloud.microserver.h5.dao.OrderPayApplyMapper">
  4. <resultMap id="BaseResultMap" type="com.hcloud.microserver.facade.carbon.entity.OrderPayApply">
  5. <id column="guid" jdbcType="CHAR" property="guid"/>
  6. <result column="fk_customer_id" jdbcType="CHAR" property="fkCustomerId"/>
  7. <result column="fk_order_id" jdbcType="CHAR" property="fkOrderId"/>
  8. <result column="apply_user_name" jdbcType="VARCHAR" property="applyUserName"/>
  9. <result column="pay_amount" jdbcType="DECIMAL" property="payAmount"/>
  10. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  11. <result column="apply_status" jdbcType="INTEGER" property="applyStatus"/>
  12. <result column="state" jdbcType="INTEGER" property="state"/>
  13. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  14. <result column="modified_time" jdbcType="TIMESTAMP" property="modifiedTime"/>
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. guid, fk_customer_id, fk_order_id, apply_user_name, pay_amount, remark, apply_status,
  18. state, create_time, modified_time
  19. </sql>
  20. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  21. select
  22. <include refid="Base_Column_List"/>
  23. from t_order_pay_apply
  24. where guid = #{guid,jdbcType=CHAR}
  25. </select>
  26. <select id="searchPayApplyInfoByPage" parameterType="com.hcloud.microserver.commoncore.base.PageBean"
  27. resultType="com.hcloud.microserver.h5.bo.PayApplyInfoBO">
  28. SELECT
  29. aa.guid,
  30. aa.fk_order_id AS orderId,
  31. cc.order_no AS orderNo,
  32. bb.account,
  33. aa.apply_user_name AS applyUserName,
  34. aa.pay_amount AS payAmount,
  35. cc.order_carbon_amount AS orderCarbonAmount,
  36. cc.order_status AS orderStatus,
  37. cc.create_time AS orderTime,
  38. ee.goods_name AS goodsName
  39. FROM
  40. t_order_pay_apply aa
  41. LEFT JOIN t_customer_info bb ON aa.fk_customer_id = bb.guid
  42. LEFT JOIN t_goods_order_info cc ON aa.fk_order_id = cc.guid
  43. LEFT JOIN t_goods_order_detail dd ON dd.fk_order_guid = cc.guid
  44. LEFT JOIN t_goods_info ee ON ee.guid = dd.fk_goods_guid
  45. WHERE
  46. cc.order_status = 2 and aa.state=1
  47. <if test="data.beginTime!=null and data.beginTime!=''">
  48. AND cc.create_time >= concat(#{data.beginTime},' 00:00:00')
  49. </if>
  50. <if test="data.endTime!=null and data.endTime!=''">
  51. <![CDATA[
  52. AND cc.create_time <= concat(#{data.endTime},' 23:59:59')
  53. ]]>
  54. </if>
  55. <if test="data.orderStatus!=null">
  56. AND cc.order_status=#{data.orderStatus}
  57. </if>
  58. <if test="data.account!=null and data.account!=''">
  59. AND bb.account=#{data.account}
  60. </if>
  61. <if test="data.orderNo!=null and data.orderNo!=''">
  62. AND cc.orderNo=#{data.orderNo}
  63. </if>
  64. </select>
  65. <select id="getPayApplyInfoByOrderId" parameterType="java.lang.String" resultMap="BaseResultMap">
  66. select
  67. <include refid="Base_Column_List"/>
  68. from t_order_pay_apply
  69. where
  70. state=1 and apply_status in (1,2)
  71. and fk_order_id = #{orderId,jdbcType=CHAR}
  72. </select>
  73. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  74. delete from t_order_pay_apply
  75. where guid = #{guid,jdbcType=CHAR}
  76. </delete>
  77. <insert id="insert" parameterType="com.hcloud.microserver.facade.carbon.entity.OrderPayApply">
  78. insert into t_order_pay_apply (guid, fk_customer_id, fk_order_id,
  79. apply_user_name, pay_amount, remark,
  80. apply_status, state, create_time,
  81. modified_time)
  82. values (#{guid,jdbcType=CHAR}, #{fkCustomerId,jdbcType=CHAR}, #{fkOrderId,jdbcType=CHAR},
  83. #{applyUserName,jdbcType=VARCHAR}, #{payAmount,jdbcType=DECIMAL}, #{remark,jdbcType=VARCHAR},
  84. #{applyStatus,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
  85. #{modifiedTime,jdbcType=TIMESTAMP})
  86. </insert>
  87. <insert id="insertSelective" parameterType="com.hcloud.microserver.facade.carbon.entity.OrderPayApply">
  88. insert into t_order_pay_apply
  89. <trim prefix="(" suffix=")" suffixOverrides=",">
  90. <if test="guid != null">
  91. guid,
  92. </if>
  93. <if test="fkCustomerId != null">
  94. fk_customer_id,
  95. </if>
  96. <if test="fkOrderId != null">
  97. fk_order_id,
  98. </if>
  99. <if test="applyUserName != null">
  100. apply_user_name,
  101. </if>
  102. <if test="payAmount != null">
  103. pay_amount,
  104. </if>
  105. <if test="remark != null">
  106. remark,
  107. </if>
  108. <if test="applyStatus != null">
  109. apply_status,
  110. </if>
  111. <if test="state != null">
  112. state,
  113. </if>
  114. <if test="createTime != null">
  115. create_time,
  116. </if>
  117. <if test="modifiedTime != null">
  118. modified_time,
  119. </if>
  120. </trim>
  121. <trim prefix="values (" suffix=")" suffixOverrides=",">
  122. <if test="guid != null">
  123. #{guid,jdbcType=CHAR},
  124. </if>
  125. <if test="fkCustomerId != null">
  126. #{fkCustomerId,jdbcType=CHAR},
  127. </if>
  128. <if test="fkOrderId != null">
  129. #{fkOrderId,jdbcType=CHAR},
  130. </if>
  131. <if test="applyUserName != null">
  132. #{applyUserName,jdbcType=VARCHAR},
  133. </if>
  134. <if test="payAmount != null">
  135. #{payAmount,jdbcType=DECIMAL},
  136. </if>
  137. <if test="remark != null">
  138. #{remark,jdbcType=VARCHAR},
  139. </if>
  140. <if test="applyStatus != null">
  141. #{applyStatus,jdbcType=INTEGER},
  142. </if>
  143. <if test="state != null">
  144. #{state,jdbcType=INTEGER},
  145. </if>
  146. <if test="createTime != null">
  147. #{createTime,jdbcType=TIMESTAMP},
  148. </if>
  149. <if test="modifiedTime != null">
  150. #{modifiedTime,jdbcType=TIMESTAMP},
  151. </if>
  152. </trim>
  153. </insert>
  154. <update id="updateByPrimaryKeySelective" parameterType="com.hcloud.microserver.facade.carbon.entity.OrderPayApply">
  155. update t_order_pay_apply
  156. <set>
  157. <if test="fkCustomerId != null">
  158. fk_customer_id = #{fkCustomerId,jdbcType=CHAR},
  159. </if>
  160. <if test="fkOrderId != null">
  161. fk_order_id = #{fkOrderId,jdbcType=CHAR},
  162. </if>
  163. <if test="applyUserName != null">
  164. apply_user_name = #{applyUserName,jdbcType=VARCHAR},
  165. </if>
  166. <if test="payAmount != null">
  167. pay_amount = #{payAmount,jdbcType=DECIMAL},
  168. </if>
  169. <if test="remark != null">
  170. remark = #{remark,jdbcType=VARCHAR},
  171. </if>
  172. <if test="applyStatus != null">
  173. apply_status = #{applyStatus,jdbcType=INTEGER},
  174. </if>
  175. <if test="state != null">
  176. state = #{state,jdbcType=INTEGER},
  177. </if>
  178. <if test="createTime != null">
  179. create_time = #{createTime,jdbcType=TIMESTAMP},
  180. </if>
  181. <if test="modifiedTime != null">
  182. modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
  183. </if>
  184. </set>
  185. where guid = #{guid,jdbcType=CHAR}
  186. </update>
  187. <update id="updateByPrimaryKey" parameterType="com.hcloud.microserver.facade.carbon.entity.OrderPayApply">
  188. update t_order_pay_apply
  189. set fk_customer_id = #{fkCustomerId,jdbcType=CHAR},
  190. fk_order_id = #{fkOrderId,jdbcType=CHAR},
  191. apply_user_name = #{applyUserName,jdbcType=VARCHAR},
  192. pay_amount = #{payAmount,jdbcType=DECIMAL},
  193. remark = #{remark,jdbcType=VARCHAR},
  194. apply_status = #{applyStatus,jdbcType=INTEGER},
  195. state = #{state,jdbcType=INTEGER},
  196. create_time = #{createTime,jdbcType=TIMESTAMP},
  197. modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
  198. where guid = #{guid,jdbcType=CHAR}
  199. </update>
  200. <update id="updateOrderPayApplyBelongInfo">
  201. update t_order_pay_apply
  202. set fk_customer_id = #{newId}
  203. where fk_customer_id = #{oldId}
  204. </update>
  205. <select id="selectListByPage" parameterType="com.hcloud.microserver.facade.carbon.forms.OrderPayApplyForm"
  206. resultType="com.hcloud.microserver.h5.bo.OrderPayApplyBO">
  207. select
  208. apply.guid as guid,
  209. apply.fk_order_id as orderGuid,
  210. orderInfo.order_no as orderNo,
  211. goods.goods_name as goodsName,
  212. customer.account as account,
  213. customer.customer_name as customerName,
  214. apply.pay_amount as payAmount,
  215. goods.carbon_val as carbonVal,
  216. orderInfo.create_time as orderTime,
  217. orderInfo.order_status as orderStatus,
  218. case orderInfo.order_status
  219. when 1 then '待支付'
  220. when 2 then '已支付'
  221. when 3 then '待审核'
  222. when 4 then '已审核'
  223. when 5 then '已确认' end as orderStatusName
  224. from t_order_pay_apply apply
  225. left join t_goods_order_info orderInfo on apply.fk_order_id = orderInfo.guid
  226. left join t_customer_info customer on apply.fk_customer_id = customer.guid
  227. left join t_goods_order_detail detail on detail.fk_order_guid = orderInfo.guid
  228. left join t_goods_info goods on goods.guid = detail.fk_goods_guid
  229. left join t_goods_pay_order payOrder on payOrder.fk_order_id = orderInfo.guid
  230. <where>
  231. payOrder.state = 1
  232. and payOrder.pay_channel = 4
  233. and apply.state = 1
  234. and orderInfo.state = 1
  235. and customer.state = 1
  236. and detail.state = 1
  237. and goods.state = 1
  238. <if test="beginTime != null and beginTime != ''">
  239. <![CDATA[
  240. AND orderInfo.create_time >= concat(#{beginTime}, ' 00:00:00')
  241. ]]>
  242. </if>
  243. <if test="endTime != null and endTime != ''">
  244. <![CDATA[
  245. AND orderInfo.create_time <= concat(#{endTime},' 23:59:59')
  246. ]]>
  247. </if>
  248. <if test="orderStatus != null">
  249. AND orderInfo.order_status = #{orderStatus,jdbcType=INTEGER}
  250. </if>
  251. <if test="account != null and account != ''">
  252. AND customer.account = #{account,jdbcType=VARCHAR}
  253. </if>
  254. <if test="orderNo != null and orderNo != ''">
  255. AND orderInfo.orderNo = #{orderNo,jdbcType=VARCHAR}
  256. </if>
  257. </where>
  258. order by apply.modified_time desc
  259. </select>
  260. </mapper>