order.sql.xml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <das-client>
  3. <Sqls>
  4. <Sql name='O_QueryOrderListView'><![CDATA[
  5. select @a from o_order_view where 1=1 @b
  6. ]]></Sql>
  7. <Sql name='RF_QueryZdtfcx'><![CDATA[
  8. select t.orderid,
  9. t.updatekey,
  10. date_format(t.begin,'%Y-%m-%d') operatetime,
  11. t.price,
  12. t.serviceid,
  13. t.cardno,
  14. t.channelid
  15. from o_order_view t,YY_WATER y where 1=1 and orderstate=4 and t.orderid=y.yyorderid
  16. and y.state='5' @a order by t.begin desc
  17. ]]></Sql>
  18. <Sql name='RF_QueryCountZdtfcx'><![CDATA[
  19. select count(*) from o_order_view t where 1=1 @a
  20. ]]></Sql>
  21. <Sql name='O_QueryOrderDetail'><![CDATA[
  22. select
  23. @a
  24. from (
  25. select
  26. b.OPERATORNAME as channel,a.orderno,a.businessorderid,b.cardno,a.transactions,
  27. b.price*0.01 as price,
  28. (select sum(q.transactions) from P_BILL q where q.businessorderid=a.businessorderid and q.ordertype=a.ordertype group by q.businessorderid,q.ordertype) as transSum,
  29. a.ordertype,
  30. case when a.ordertype=1 and c.paystate is not null then '1' when a.ordertype=2 and d.paystate is not null then '2' else '' end payFlag,
  31. case when a.ordertype=1 then c.paystate when a.ordertype=2 then d.paystate else '0' end state,
  32. date_format(a.transtime,'%Y-%m-%d %H:%i:%S') transTime,date_format(b.begin,'%Y-%m-%d %H:%i:%S') beginDate,a.orderstatus,
  33. c.paystate,d.paystate paystate1
  34. from P_BILL a
  35. left join O_ORDER b on a.businessorderid=b.orderid
  36. left join O_PAYORDER c on a.businessorderid=c.orderid
  37. left join O_CANCELORDER d on a.businessorderid=d.orderid
  38. where @b
  39. order by a.businessorderid,a.ordertype ) tt
  40. ]]></Sql>
  41. <Sql name='O_OrderDetailUpdateDealState'><![CDATA[
  42. update P_BILL set orderstatus = ? where businessorderid = ?
  43. ]]></Sql>
  44. <Sql name='O_QueryOrderByDate'><![CDATA[
  45. select @a from O_ORDER_DATE t where @b
  46. ]]></Sql>
  47. <Sql name='O_QueryOrderByDateTotal'><![CDATA[
  48. select @a from O_ORDER_DATE t where @b union select @c from O_ORDER_DATE t where @d
  49. ]]></Sql>
  50. <Sql name='O_OrderDetailUpdateCheckState'><![CDATA[
  51. update O_ORDER_DATE set checkstate = ? where day = ?
  52. ]]></Sql>
  53. <Sql name='O_HasOrderYesterdayCount'><![CDATA[
  54. select @a from O_ORDER_DATE where @b
  55. ]]></Sql>
  56. <Sql name='O_DeleteOrderYesterday'><![CDATA[
  57. delete from O_ORDER_DATE where day = ?
  58. ]]></Sql>
  59. <Sql name='O_InsertIntoOrderBySelect'><![CDATA[
  60. insert into O_ORDER_DATE
  61. select
  62. r.day,r.hispaynum,r.channelpaynuym,r.hiscancelpaynum,r.channelcancelpaynum,
  63. FORMAT(r.hispay, 2) hispay,
  64. FORMAT(r.channelpay, 2) channelpay,
  65. FORMAT(r.hiscancelpay, 2) hiscancelpay,
  66. FORMAT(r.channelcancelpay, 2) channelcancelpay,
  67. case when r.hispaynum=r.channelpaynuym and r.hiscancelpaynum=r.channelcancelpaynum and r.hispay=r.channelpay
  68. and r.hiscancelpay=r.channelcancelpay then 1 else 2 end syscheckstate, 0 checkstate ,hosid
  69. from
  70. ( select
  71. date_format(s.transtime,'%Y-%m-%d') as day,
  72. sum(hispstate) hispaynum,
  73. sum(channelpstate) channelpaynuym,
  74. sum(hiscstate) hiscancelpaynum,
  75. sum(channelcstate) channelcancelpaynum,
  76. sum(hisprice) hispay,
  77. sum(channelprice) channelpay,
  78. sum(hiscanprice) hiscancelpay,
  79. sum(channelcanprice) channelcancelpay,
  80. hosid
  81. from(
  82. select
  83. a.transtime,c.paystate,d.paystate d_paystate,a.ordertype,b.hosid,
  84. case when a.ordertype =1 and c.paystate=2 then 1 else 0 end as hispstate,
  85. case when a.ordertype =1 then 1 else 0 end as channelpstate,
  86. case when a.ordertype =2 and d.paystate=4 then 1 else 0 end as hiscstate,
  87. case when a.ordertype =2 then 1 else 0 end as channelcstate,
  88. case when a.ordertype =1 and c.paystate=2 then b.price*0.01 else 0 end as hisprice,
  89. case when a.ordertype =1 then a.transactions else 0 end as channelprice,
  90. case when a.ordertype =2 and d.paystate=4 then b.price*0.01 else 0 end as hiscanprice,
  91. case when a.ordertype =2 then a.transactions else 0 end as channelcanprice
  92. from (
  93. select
  94. businessorderid orderid,ordertype,sum(transactions) as transactions,max(transtime) as transtime
  95. from P_BILL group by businessorderid,ordertype
  96. ) a left join O_ORDER b on a.orderid=b.orderid
  97. left join O_PAYORDER c on a.orderid=c.orderid and c.paystate<>1
  98. left join O_CANCELORDER d on a.orderid=d.orderid and d.paystate<>3
  99. where 1=1 @b
  100. ) s group by date_format(s.transtime,'%Y-%m-%d')
  101. ) r
  102. ]]></Sql>
  103. <Sql name='O_CountOrderBySelect'><![CDATA[
  104. select @a from o_order_view t,P_BILL p where @b
  105. ]]></Sql>
  106. <Sql name='O_GetCompareBillFormsList'><![CDATA[
  107. select
  108. channel,orderno,orderid,cardno,transactions,price,
  109. case when transSum=price then '1' else '2' end as checkThrough,
  110. ordertype,payFlag,state,transTime,beginDate,
  111. case when orderstatus<>0 then orderstatus when orderstatus=0 and transSum<>price then 0 else 1 end as dealState
  112. from (
  113. select
  114. b.OPERATORNAME as channel,a.orderno,a.orderid,b.cardno,a.transactions,
  115. b.price*0.01 as price,
  116. (select sum(q.transactions) from P_BILL q where q.orderid=a.orderid and q.ordertype=a.ordertype group by q.orderid,q.ordertype) as transSum,
  117. a.ordertype,
  118. case when a.ordertype=1 and c.paystate is not null then '1' when a.ordertype=2 and d.paystate is not null then '2' else '' end payFlag,
  119. case when a.ordertype=1 then to_char(c.paystate) when a.ordertype=2 then to_char(d.paystate) else '0' end state,
  120. to_char(a.transtime,'yyyy-mm-dd hh:mm:ss') transTime,to_char(b.begin,'yyyy-mm-dd hh:mm:ss') beginDate,a.orderstatus,
  121. c.paystate,d.paystate
  122. from P_BILL a
  123. left join O_ORDER b on a.orderid=b.orderid
  124. left join O_PAYORDER c on a.orderid=c.orderid
  125. left join O_CANCELORDER d on a.orderid=d.orderid
  126. where 1=1 @p
  127. order by a.orderid,a.ordertype ) tt where 1=1 @d
  128. ]]></Sql>
  129. <Sql name='O_GetCompareBillFormsCount'><![CDATA[
  130. select count(1) from (
  131. select
  132. b.OPERATORNAME as channel,a.orderno,a.orderid,b.cardno,a.transactions,
  133. b.price*0.01 as price,
  134. (select sum(q.transactions) from p_bill q where q.orderid=a.orderid and q.ordertype=a.ordertype group by q.orderid,q.ordertype) as transSum,
  135. a.ordertype,
  136. case when a.ordertype=1 and c.paystate is not null then '1' when a.ordertype=2 and d.paystate is not null then '2' else '' end payFlag,
  137. case when a.ordertype=1 then to_char(c.paystate) when a.ordertype=2 then to_char(d.paystate) else '0' end state,
  138. to_char(a.transtime,'yyyy-mm-dd hh:mm:ss') transTime,to_char(b.begin,'yyyy-mm-dd hh:mm:ss') beginDate,a.orderstatus,
  139. c.paystate,d.paystate
  140. from P_BILL a
  141. left join O_ORDER b on a.orderid=b.orderid
  142. left join O_PAYORDER c on a.orderid=c.orderid
  143. left join O_CANCELORDER d on a.orderid=d.orderid
  144. where 1=1 @p
  145. ) tt where 1=1 @d
  146. ]]></Sql>
  147. </Sqls>
  148. </das-client>