GoodsOrderInfoMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="GoodsOrderInfoMapper">
  4. <resultMap id="BaseResultMap" type="GoodsOrderInfo">
  5. <id column="guid" jdbcType="CHAR" property="guid" />
  6. <result column="fk_customer_guid" jdbcType="CHAR" property="fkCustomerGuid" />
  7. <result column="order_no" jdbcType="CHAR" property="orderNo" />
  8. <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  9. <result column="customer_type" jdbcType="VARCHAR" property="customerType" />
  10. <result column="order_amount" jdbcType="DECIMAL" property="orderAmount" />
  11. <result column="order_carbon_amount" jdbcType="DECIMAL" property="orderCarbonAmount" />
  12. <result column="order_status" jdbcType="INTEGER" property="orderStatus" />
  13. <result column="state" jdbcType="INTEGER" property="state" />
  14. <result column="create_user" jdbcType="CHAR" property="createUser" />
  15. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  16. <result column="modified_user" jdbcType="CHAR" property="modifiedUser" />
  17. <result column="modified_time" jdbcType="TIMESTAMP" property="modifiedTime" />
  18. <result column="pay_no" jdbcType="VARCHAR" property="payNo" />
  19. </resultMap>
  20. <sql id="Base_Column_List">
  21. guid, fk_customer_guid, order_no,customer_name,customer_type, order_amount,
  22. order_carbon_amount, order_status,state, create_user, create_time, modified_user,
  23. modified_time,pay_no
  24. </sql>
  25. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  26. select
  27. <include refid="Base_Column_List" />
  28. from t_goods_order_info
  29. where guid = #{guid,jdbcType=CHAR}
  30. </select>
  31. <select id="searchOrderInfoByPage" parameterType="com.hcloud.microserver.commoncore.base.PageBean"
  32. resultType="OrderInfoBO">
  33. SELECT
  34. aa.guid,
  35. aa.order_no AS orderNo,
  36. bb.account AS account,
  37. bb.phone AS phone,
  38. case bb.customer_type when 1 then '自然人' when 2 then '履约企业' when 3 then '非履约企业' end as customerTypeName,
  39. aa.customer_name AS customerName,
  40. CASE cc.pay_channel
  41. WHEN 1 THEN
  42. '微信支付'
  43. WHEN 2 THEN
  44. '支付宝'
  45. WHEN 3 THEN
  46. '银联支付'
  47. ELSE
  48. '线下支付'
  49. END AS payChannel,
  50. aa.order_amount AS payAmount,
  51. aa.order_carbon_amount AS orderCarbonAmount,
  52. CASE aa.order_status
  53. WHEN 1 THEN
  54. '待支付'
  55. WHEN 2 THEN
  56. '已支付'
  57. WHEN 3 THEN
  58. '已审核'
  59. WHEN 4 THEN
  60. '已打款'
  61. ELSE
  62. '已作废'
  63. END AS orderStatus,
  64. aa.create_time AS createTime,
  65. dd.credential_no AS credentialNo
  66. FROM
  67. t_goods_order_info aa
  68. LEFT JOIN t_customer_info bb ON aa.fk_customer_guid = bb.guid
  69. AND bb.is_enable = 1
  70. AND bb.state = 1
  71. LEFT JOIN t_goods_pay_order cc ON cc.fk_order_id = aa.guid
  72. /*AND cc.state = 1
  73. AND cc.pay_no = aa.pay_no*/
  74. LEFT JOIN t_goods_credential_info dd ON dd.fk_order_id = aa.guid
  75. AND dd.state = 1
  76. WHERE
  77. aa.state=1
  78. <if test="data.beginDate!=null and data.beginDate!=''">
  79. AND aa.create_time >= concat(#{data.beginDate},' 00:00:00')
  80. </if>
  81. <if test="data.endDate!=null and data.endDate!=''">
  82. <![CDATA[
  83. AND aa.create_time <= concat(#{data.endDate},' 23:59:59')
  84. ]]>
  85. </if>
  86. <if test="data.payChannel!=null and data.payChannel != ''">
  87. AND cc.pay_channel = #{data.payChannel}
  88. </if>
  89. <if test="data.orderStatus!=null and data.orderStatus != ''">
  90. AND aa.order_status = #{data.orderStatus}
  91. </if>
  92. <if test="data.account!=null and data.account!=''">
  93. AND bb.account = #{data.account}
  94. </if>
  95. <if test="data.orderNo!=null and data.orderNo != ''">
  96. AND aa.order_no = #{data.orderNo}
  97. </if>
  98. order by aa.create_time desc
  99. </select>
  100. <select id="searchOrderInfoByCustomerId" resultType="OrderInfoBO">
  101. SELECT
  102. aa.guid,
  103. aa.order_no AS orderNo,
  104. aa.create_time AS createTime,
  105. aa.order_status AS orderStatus,
  106. aa.order_amount AS orderAmount,
  107. aa.order_carbon_amount AS orderCarbonAmount,
  108. aa.pay_no AS payNo
  109. FROM
  110. t_goods_order_info aa
  111. WHERE
  112. aa.state = 1
  113. AND aa.fk_customer_guid = #{custId}
  114. <if test="orderStatus!=null and orderStatus!=-1">
  115. AND aa.order_status=#{orderStatus}
  116. </if>
  117. order by aa.create_time desc
  118. </select>
  119. <select id="getOrderInfoByNo" parameterType="java.lang.String" resultMap="BaseResultMap">
  120. select
  121. <include refid="Base_Column_List" />
  122. from t_goods_order_info
  123. where
  124. order_status =1 and state=1
  125. and order_no = #{orderNo}
  126. </select>
  127. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  128. delete from t_goods_order_info
  129. where guid = #{guid,jdbcType=CHAR}
  130. </delete>
  131. <insert id="insert" parameterType="GoodsOrderInfo">
  132. insert into t_goods_order_info (guid, fk_customer_guid, order_no,
  133. customer_name,customer_type,order_amount, order_carbon_amount, order_status,
  134. state, create_user, create_time,
  135. modified_user, modified_time,pay_no)
  136. values (#{guid,jdbcType=CHAR}, #{fkCustomerGuid,jdbcType=CHAR}, #{orderNo,jdbcType=CHAR},
  137. #{customerName,jdbcType=VARCHAR},#{customerType,jdbcType=VARCHAR},#{orderAmount,jdbcType=DECIMAL},
  138. #{orderCarbonAmount,jdbcType=DECIMAL}, #{orderStatus,jdbcType=INTEGER},
  139. #{state,jdbcType=INTEGER}, #{createUser,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP},
  140. #{modifiedUser,jdbcType=CHAR}, #{modifiedTime,jdbcType=TIMESTAMP},#{payNo,jdbcType=VARCHAR})
  141. </insert>
  142. <insert id="insertSelective" parameterType="GoodsOrderInfo">
  143. insert into t_goods_order_info
  144. <trim prefix="(" suffix=")" suffixOverrides=",">
  145. <if test="guid != null">
  146. guid,
  147. </if>
  148. <if test="fkCustomerGuid != null">
  149. fk_customer_guid,
  150. </if>
  151. <if test="orderNo != null">
  152. order_no,
  153. </if>
  154. <if test="customerName != null">
  155. customer_name,
  156. </if>
  157. <if test="customerType != null">
  158. customer_type,
  159. </if>
  160. <if test="orderAmount != null">
  161. order_amount,
  162. </if>
  163. <if test="orderCarbonAmount != null">
  164. order_carbon_amount,
  165. </if>
  166. <if test="orderStatus != null">
  167. order_status,
  168. </if>
  169. <if test="state != null">
  170. state,
  171. </if>
  172. <if test="createUser != null">
  173. create_user,
  174. </if>
  175. <if test="createTime != null">
  176. create_time,
  177. </if>
  178. <if test="modifiedUser != null">
  179. modified_user,
  180. </if>
  181. <if test="modifiedTime != null">
  182. modified_time,
  183. </if>
  184. <if test="payNo != null">
  185. pay_no,
  186. </if>
  187. </trim>
  188. <trim prefix="values (" suffix=")" suffixOverrides=",">
  189. <if test="guid != null">
  190. #{guid,jdbcType=CHAR},
  191. </if>
  192. <if test="fkCustomerGuid != null">
  193. #{fkCustomerGuid,jdbcType=CHAR},
  194. </if>
  195. <if test="orderNo != null">
  196. #{orderNo,jdbcType=CHAR},
  197. </if>
  198. <if test="customerName != null">
  199. #{customerName,jdbcType=VARCHAR},
  200. </if>
  201. <if test="customerType != null">
  202. #{customerType,jdbcType=VARCHAR},
  203. </if>
  204. <if test="orderAmount != null">
  205. #{orderAmount,jdbcType=DECIMAL},
  206. </if>
  207. <if test="orderCarbonAmount != null">
  208. #{orderCarbonAmount,jdbcType=DECIMAL},
  209. </if>
  210. <if test="orderStatus != null">
  211. #{orderStatus,jdbcType=INTEGER},
  212. </if>
  213. <if test="state != null">
  214. #{state,jdbcType=INTEGER},
  215. </if>
  216. <if test="createUser != null">
  217. #{createUser,jdbcType=CHAR},
  218. </if>
  219. <if test="createTime != null">
  220. #{createTime,jdbcType=TIMESTAMP},
  221. </if>
  222. <if test="modifiedUser != null">
  223. #{modifiedUser,jdbcType=CHAR},
  224. </if>
  225. <if test="modifiedTime != null">
  226. #{modifiedTime,jdbcType=TIMESTAMP},
  227. </if>
  228. <if test="payNo != null">
  229. #{payNo,jdbcType=VARCHAR},
  230. </if>
  231. </trim>
  232. </insert>
  233. <update id="updateByPrimaryKeySelective" parameterType="GoodsOrderInfo">
  234. update t_goods_order_info
  235. <set>
  236. <if test="fkCustomerGuid != null">
  237. fk_customer_guid = #{fkCustomerGuid,jdbcType=CHAR},
  238. </if>
  239. <if test="orderNo != null">
  240. order_no = #{orderNo,jdbcType=CHAR},
  241. </if>
  242. <if test="customerName != null">
  243. customer_name = #{customerName,jdbcType=VARCHAR},
  244. </if>
  245. <if test="customerType != null">
  246. customer_type = #{customerType,jdbcType=VARCHAR},
  247. </if>
  248. <if test="orderAmount != null">
  249. order_amount = #{orderAmount,jdbcType=DECIMAL},
  250. </if>
  251. <if test="orderCarbonAmount != null">
  252. order_carbon_amount = #{orderCarbonAmount,jdbcType=DECIMAL},
  253. </if>
  254. <if test="orderStatus != null">
  255. order_status = #{orderStatus,jdbcType=INTEGER},
  256. </if>
  257. <if test="state != null">
  258. state = #{state,jdbcType=INTEGER},
  259. </if>
  260. <if test="createUser != null">
  261. create_user = #{createUser,jdbcType=CHAR},
  262. </if>
  263. <if test="createTime != null">
  264. create_time = #{createTime,jdbcType=TIMESTAMP},
  265. </if>
  266. <if test="modifiedUser != null">
  267. modified_user = #{modifiedUser,jdbcType=CHAR},
  268. </if>
  269. <if test="modifiedTime != null">
  270. modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
  271. </if>
  272. <if test="payNo != null">
  273. pay_no = #{payNo,jdbcType=VARCHAR},
  274. </if>
  275. </set>
  276. where guid = #{guid,jdbcType=CHAR}
  277. </update>
  278. <update id="updateByPrimaryKey" parameterType="GoodsOrderInfo">
  279. update t_goods_order_info
  280. set fk_customer_guid = #{fkCustomerGuid,jdbcType=CHAR},
  281. order_no = #{orderNo,jdbcType=CHAR},
  282. customer_name = #{customerName,jdbcType=VARCHAR},
  283. customer_type = #{customerType,jdbcType=VARCHAR},
  284. order_amount = #{orderAmount,jdbcType=DECIMAL},
  285. order_carbon_amount = #{orderCarbonAmount,jdbcType=DECIMAL},
  286. order_status = #{orderStatus,jdbcType=INTEGER},
  287. state = #{state,jdbcType=INTEGER},
  288. create_user = #{createUser,jdbcType=CHAR},
  289. create_time = #{createTime,jdbcType=TIMESTAMP},
  290. modified_user = #{modifiedUser,jdbcType=CHAR},
  291. modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
  292. pay_no = #{payNo,jdbcType=VARCHAR}
  293. where guid = #{guid,jdbcType=CHAR}
  294. </update>
  295. <update id="updateOrderBelongInfo">
  296. update t_goods_order_info
  297. set fk_customer_guid = #{newId}
  298. where fk_customer_guid = #{oldId}
  299. </update>
  300. </mapper>