CenterServiceDAOImplMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="centerServiceDAOImpl">
  6. <!-- 查询订单信息 -->
  7. <select id="getOrder" resultType="Map" parameterType="Map">
  8. SELECT `o_id` oId, `app_id` appId, `ext_transaction_id` extTransactionId, `user_id` userId, `request_time`
  9. requestTime,
  10. `create_time` createTime,`order_type_cd` orderTypeCd, `finish_time` finishTime, `remark`,t.status_cd statusCd
  11. from c_orders t
  12. where 1=1
  13. <if test="oId != null and oId != ''">
  14. and t.o_id = #{oId}
  15. </if>
  16. <if test="extTransactionId != null and extTransactionId != ''">
  17. and t.ext_transaction_id = #{extTransactionId}
  18. </if>
  19. <if test="appId != null and appId != ''">
  20. and t.app_id = #{appId}
  21. </if>
  22. </select>
  23. <!-- 查询订单项信息 -->
  24. <select id="getOrderItems" resultType="Map" parameterType="Map">
  25. select t.b_id bId,t.o_id oId,t.create_time createTime,t.action,t.action_obj actionObj,
  26. t.finish_time finishTime,t.remark,ul.service_name serviceName,ul.log_text logText
  27. from c_order_item t
  28. LEFT JOIN unitem_log ul on t.b_id = ul.b_id and t.o_id = ul.o_id and ul.status_cd = '0'
  29. where 1=1
  30. <if test="oId != null and oId != ''">
  31. and t.o_id = #{oId}
  32. </if>
  33. <if test="bId != null and bId != ''">
  34. and t.b_id = #{bId}
  35. </if>
  36. </select>
  37. <!--保存订单信息 c_orders 中 -->
  38. <insert id="saveOrder" parameterType="Map">
  39. <![CDATA[
  40. insert into c_orders(o_id,app_id,ext_transaction_id,user_id,request_time,order_type_cd,remark,status_cd)
  41. values(#{oId},#{appId},#{extTransactionId},#{userId},#{requestTime},#{orderTypeCd},#{remark},'S')
  42. ]]>
  43. </insert>
  44. <!-- 保存属性信息c_orders_attrs 中-->
  45. <insert id="saveOrderAttrs" parameterType="Map">
  46. <![CDATA[
  47. insert into c_orders_attrs(o_id,attr_id,spec_cd,value)
  48. values(#{oId},#{attrId},#{specCd},#{value})
  49. ]]>
  50. </insert>
  51. <!--保存订单信息 c_order_item 中 -->
  52. <insert id="saveOrderItem" parameterType="Map">
  53. INSERT INTO `c_order_item` (`b_id`, `o_id`, `action`, `action_obj`, `finish_time`, `remark`,status_cd)
  54. VALUES (#{bId}, #{oId}, #{action}, #{actionObj}, #{finishTime}, #{remark},'S')
  55. </insert>
  56. <!--保存订单信息 unitem_log 中 -->
  57. <insert id="saveUnItemLog" parameterType="Map">
  58. INSERT INTO `unitem_log` (`b_id`, `o_id`, `service_name`, `log_text`,status_cd)
  59. VALUES (#{bId}, #{oId}, #{serviceName}, #{logText},'0')
  60. </insert>
  61. <!-- 修改订单项信息 -->
  62. <update id="updateOrderItem" parameterType="Map">
  63. update c_order_item t
  64. set t.finish_time = #{finishTime},
  65. t.status_cd = #{statusCd}
  66. where t.o_id = #{oId}
  67. <if test="bId !=null and bId != ''">
  68. and t.b_id = #{bId}
  69. </if>
  70. </update>
  71. <!-- 删除事务日志 -->
  72. <update id="deleteUnItemLog" parameterType="Map">
  73. delete from unitem_log where o_id = #{oId}
  74. <if test="bId !=null and bId != ''">
  75. and t.b_id = #{bId}
  76. </if>
  77. </update>
  78. <!-- 保存订单项信息 c_business -->
  79. <insert id="saveBusiness" parameterType="Map">
  80. <![CDATA[
  81. insert into c_business(b_id,o_id,business_type_cd,remark,status_cd)
  82. values(#{bId},#{oId},#{businessTypeCd},#{remark},#{statusCd})
  83. ]]>
  84. </insert>
  85. <!-- 保存属性信息 c_business_attrs -->
  86. <insert id="saveBusinessAttrs" parameterType="Map">
  87. <![CDATA[
  88. insert into c_business_attrs(b_id,attr_id,spec_cd,value)
  89. values(#{bId},#{attrId},#{specCd},#{value})
  90. ]]>
  91. </insert>
  92. <!-- 更新订单信息(一般就更新订单状态) -->
  93. <update id="updateOrder" parameterType="Map">
  94. <![CDATA[
  95. update c_orders co set
  96. co.status_cd=#{statusCd},
  97. co.finish_time=#{finishTime}
  98. where co.o_id=#{oId}
  99. ]]>
  100. </update>
  101. <!-- 更新订单项信息(一般就更新订单项状态)-->
  102. <update id="updateBusiness" parameterType="Map">
  103. update c_business cb set
  104. cb.status_cd=#{statusCd},
  105. cb.finish_time=#{finishTime}
  106. where cb.o_id=#{oId}
  107. </update>
  108. <!--根据bId 修改业务项信息-->
  109. <update id="updateBusinessByBId" parameterType="Map">
  110. <![CDATA[
  111. update c_business cb set
  112. cb.status_cd=#{statusCd},
  113. cb.finish_time=#{finishTime}
  114. where cb.b_id in (#{bId})
  115. and cb.status_cd not in ('E')
  116. ]]>
  117. </update>
  118. <!-- 当所有业务动作是否都是C,将订单信息改为 C-->
  119. <update id="completeOrderByBId" parameterType="String">
  120. <![CDATA[
  121. update c_orders co set co.status_cd = 'C' where co.status_cd='S'
  122. and not exists(
  123. select 1 from c_business cb where cb.status_cd <> 'C'
  124. and cb.o_id = co.o_id
  125. and cb.b_id in (#{bId})
  126. )
  127. ]]>
  128. </update>
  129. <!-- 当所有业务动作是否都是C,将订单信息改为 C-->
  130. <update id="completeOrderByOId" parameterType="String">
  131. <![CDATA[
  132. update c_orders co set co.status_cd = 'C' where co.status_cd='S'
  133. and co.o_id = #{oId}
  134. and not exists(
  135. select 1 from c_business cb where cb.status_cd <> 'C'
  136. and cb.o_id = co.o_id
  137. )
  138. ]]>
  139. </update>
  140. <select id="getOrderInfoByBId" parameterType="String" resultType="Map">
  141. <![CDATA[
  142. select co.* from c_orders co where 1 = 1 and exists
  143. (
  144. select 1 from c_business cb where cb.o_id = co.o_id
  145. and cb.b_id = #{bId}
  146. )
  147. ]]>
  148. </select>
  149. <select id="queryOrderByBId" parameterType="Map" resultType="Map">
  150. select distinct co.app_id appId,co.o_id oId,co.create_time createTime,
  151. co.ext_transaction_id extTransactionId,co.user_id userId,cb.b_id bId
  152. from c_orders co
  153. INNER JOIN c_business cb on co.o_id = cb.o_id
  154. where 1=1
  155. <if test="bId != null and bId != ''">
  156. cb.b_id = #{bId}
  157. </if>
  158. <if test="bIds !=null">
  159. and cb.b_id in
  160. <foreach collection="bIds" item="item" index="index" open="(" close=")" separator=",">
  161. #{item}
  162. </foreach>
  163. </if>
  164. </select>
  165. <!-- 根据 OID 查询 business -->
  166. <select id="getBusinessByOId" parameterType="map" resultType="map">
  167. SELECT co.`o_id`,co.`app_id`,co.`order_type_cd`,co.`user_id`,cb.`business_type_cd`,cb.`b_id`,cb.`status_cd`
  168. FROM c_orders co,c_business cb
  169. WHERE co.`o_id` = cb.`o_id`
  170. AND cb.`business_type_cd` NOT IN ('DO')
  171. <if test="statusCd != null and statusCd != ''">
  172. AND cb.`status_cd` = #{statusCd}
  173. </if>
  174. <if test="oId != null and oId != ''">
  175. AND co.`o_id` = #{oId}
  176. </if>
  177. </select>
  178. <select id="getDeleteOrderBusinessByOId" parameterType="String" resultType="Map">
  179. <![CDATA[
  180. select cb.b_id,cb.o_id,cb.business_type_cd,cb.status_cd from c_orders co,c_business cb where co.o_id = cb.o_id and cb.business_type_cd = 'DO' and cb.status_cd = 'DO'
  181. and co.o_id = #{oId}
  182. ]]>
  183. </select>
  184. <!-- 获取同个订单中已经完成的订单项-->
  185. <select id="getCommonOrderCompledBusinessByBId" parameterType="String" resultType="Map">
  186. <![CDATA[
  187. select * from c_business cb where cb.finish_time is not null
  188. and cb.o_id in (
  189. select cb1.o_id from c_business cb1 where cb1.b_id = #{bId}
  190. )
  191. ]]>
  192. </select>
  193. <!--查询 所有有效 app信息-->
  194. <select id="getAppRouteAndServiceInfoAll" resultType="Map">
  195. <![CDATA[
  196. SELECT ca.app_id,ca.name,ca.security_code,ca.while_list_ip,ca.black_list_ip,cr.invoke_limit_times,
  197. cr.order_type_cd,cs.service_id,cs.business_type_cd,cr.invoke_model,cs.is_instance,
  198. cs.messageQueueName,cs.method,cs.name,cs.provide_app_id,cs.retry_count,cs.seq,cs.service_code,
  199. cs.timeout,cs.url FROM c_app ca,c_route cr,c_service cs
  200. WHERE ca.status_cd = '0'
  201. AND ca.app_id = cr.app_id
  202. AND cr.status_cd = '0'
  203. AND cr.service_id = cs.service_id
  204. AND cs.status_cd = '0'
  205. ]]>
  206. </select>
  207. <select id="getMappingInfoAll" resultType="com.java110.entity.mapping.Mapping">
  208. <![CDATA[
  209. SELECT cm.domain,cm.name,cm.key,cm.value,cm.remark from c_mapping cm where cm.status_cd = '0'
  210. ]]>
  211. </select>
  212. <select id="getPrivilegeAll" resultType="com.java110.dto.basePrivilege.BasePrivilegeDto">
  213. <![CDATA[
  214. select t.p_id pId,t.name,t.domain,t.resource,t.description,t.create_time createTime from p_privilege t where t.status_cd = '0'
  215. ]]>
  216. </select>
  217. <select id="getDatabusAll" resultType="com.java110.dto.businessDatabus.BusinessDatabusDto">
  218. <![CDATA[
  219. SELECT
  220. t.databus_id databusId,
  221. t.databus_name databusName,
  222. t.business_type_cd businessTypeCd,
  223. t.bean_name beanName,
  224. t.seq
  225. FROM
  226. c_business_databus t
  227. WHERE
  228. t.status_cd = '0'
  229. AND t.state = '1001'
  230. ]]>
  231. </select>
  232. <select id="judgeAllBusinessCompleted" parameterType="map" resultType="map">
  233. SELECT co.* FROM c_orders co WHERE co.`o_id` = #{oId} and not exists (
  234. SELECT 1 FROM c_business cb WHERE cb.`o_id` = co.`o_id`
  235. AND cb.`status_cd` NOT IN (#{statusCd})
  236. )
  237. AND NOT EXISTS (
  238. SELECT 1 FROM c_business cbs WHERE cbs.`o_id` =co.`o_id`
  239. AND cbs.`business_type_cd` = 'DO'
  240. )
  241. AND co.`status_cd` NOT IN ('D','C','E')
  242. </select>
  243. <select id="judgeAllBusinessDeleteOrder" parameterType="map" resultType="map">
  244. SELECT co.* FROM c_orders co WHERE co.`o_id` = #{oId} and not exists (
  245. SELECT 1 FROM c_business cb WHERE cb.`o_id` = co.`o_id`
  246. AND cb.`status_cd` NOT IN (#{statusCd})
  247. )
  248. AND EXISTS (
  249. SELECT 1 FROM c_business cbs WHERE cbs.`o_id` =co.`o_id`
  250. AND cbs.`business_type_cd` = 'DO'
  251. )
  252. AND co.`status_cd` NOT IN ('C')
  253. </select>
  254. <!---->
  255. <select id="queryOwenrOrders" parameterType="map" resultType="map">
  256. <![CDATA[
  257. select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd from c_orders co,c_business cb where co.o_id = cb.o_id
  258. and cb.business_type_cd in ('110100030001','110100040001','110100050001','111100030001','111100050001')
  259. and cb.status_cd = 'C'
  260. ]]>
  261. </select>
  262. <select id="queryManchineOrders" parameterType="map" resultType="map">
  263. <![CDATA[
  264. select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd from c_orders co,c_business cb where co.o_id = cb.o_id
  265. and cb.business_type_cd in ('200200030001','200200040001','200200050001')
  266. and cb.status_cd = 'C'
  267. ]]>
  268. </select>
  269. <!-- 240200030001', -->
  270. <select id="queryApplicationKeyOrders" parameterType="map" resultType="map">
  271. <![CDATA[
  272. select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd from c_orders co,c_business cb where co.o_id = cb.o_id
  273. and cb.business_type_cd in ('240200040001','240200050001')
  274. and cb.status_cd = 'C'
  275. ]]>
  276. </select>
  277. <select id="queryOrderByBusinessType" parameterType="map" resultType="map">
  278. select cb.b_id bId,co.o_id oId,cb.business_type_cd businessTypeCd
  279. from c_orders co,c_business cb
  280. where co.o_id = cb.o_id
  281. and cb.status_cd = 'C'
  282. <if test="businessTypeCds !=null">
  283. and cb.business_type_cd in
  284. <foreach collection="businessTypeCds" item="item" index="index" open="(" close=")" separator=",">
  285. #{item}
  286. </foreach>
  287. </if>
  288. </select>
  289. <update id="updateBusinessStatusCd" parameterType="Map">
  290. update c_business cb set cb.status_cd = 'C1'
  291. where cb.b_id = #{bId}
  292. </update>
  293. <!-- querySameOrderBusiness 查询同订单 订单项 -->
  294. <select id="querySameOrderBusiness" parameterType="map" resultType="map">
  295. SELECT
  296. cb1.b_id bId,
  297. cb1.o_id oId,
  298. cb1.create_time createTime,
  299. cb1.business_type_cd businessTypeCd,
  300. cb1.finish_time finishTime,
  301. cb1.status_cd statusCd
  302. FROM
  303. c_business cb1
  304. <if test="bId != null and bId != ''">
  305. ,c_business cb2
  306. </if>
  307. WHERE
  308. 1=1
  309. <if test="bId != null and bId != ''">
  310. and cb1.o_id = cb2.o_id
  311. AND cb2.b_id = #{bId}
  312. </if>
  313. <if test="oId != null and oId != ''">
  314. and cb1.o_id = #{oId}
  315. </if>
  316. <if test="businessTypeCd != null and businessTypeCd != ''">
  317. and cb1.business_type_cd = #{businessTypeCd}
  318. </if>
  319. </select>
  320. </mapper>