Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.98 KB | None | 0 0
  1. select
  2. temp.Campus,
  3. temp.shop_name,
  4. temp.shop_id,
  5. temp.state,
  6. temp.state_reason,
  7. -- c.class,
  8. -- temp2.Errors as Campus_errors,
  9. temp.Errors as "Local Errors",
  10. CONCAT(TRUNCATE(temp.Errors/(temp2.Errors)*100,2),'%%') as "Local Errors %%",
  11. temp2.Errors as "Campus Errors",
  12. CONCAT(TRUNCATE(temp2.Errors/(temp2.Errors+oo.orders)*100,2),'%%') as "Campus Errors %%"
  13.  
  14. From (
  15. SELECT aa. name as "Campus",
  16. aa.id,
  17. aa.shop_name ,
  18. aa.shop_id,
  19. aa.state,
  20. aa.state_reason,
  21. count(aa.Error) as "Errors"
  22.  
  23. FROM (
  24. SELECT bo.name,
  25. bo.id,
  26. oo.owner_id,
  27. ee.name as shop_name,
  28. oo.shop_id,
  29. state,
  30. state_reason,
  31. count(*) AS Error
  32.  
  33. FROM orders_order oo
  34. INNER JOIN billi_organization bo ON bo.id = oo.organization_id
  35. INNER JOIN entities_entity ee ON ee.id = oo.shop_id
  36. WHERE bo.creation_time > '2012-6-1'
  37. AND state LIKE '%%ERROR%%'
  38.  
  39. AND (oo.merchant_creation_time-interval '5' hour) between '%(from)s' and '%(to)s'
  40.  
  41. GROUP BY oo.shop_id, state_reason, oo.owner_id) aa
  42. WHERE (aa.state_reason != "Exception occured (503, u'Service Unavailable')" OR
  43. aa.state_reason != "Card Suspended The card is suspended." OR
  44. aa.state_reason not like "%% not approved" OR
  45. aa.state_reason != "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." OR
  46. aa.state_reason != "Plan Expired All other abnormal error conditions." OR
  47. aa.state_reason != "INVALID CARD" OR
  48. aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus support during business hours 8a-5p mon-fri (928)523-0081" OR
  49. aa.state_reason != "Privilege Suspended" OR
  50. aa.state_reason != "CARD IS LOST" OR
  51. aa.state_reason != "Internal Error" OR
  52. aa.state_reason != "id: 98065L not approved" OR
  53. aa.state_reason != "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open." OR
  54. aa.state_reason != "Could not print! Printer is offline. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." OR
  55. aa.state_reason != "SERVICE_TYPE_NOT_SUPPORTED" OR
  56. aa.state_reason != "Card Invalid-L/S" OR
  57. aa.state_reason != "Invalid request parameter: amount must be greater than zero" OR
  58. aa.state_reason != "FAILED" OR
  59. aa.state_reason != "Account tilghmantuebner@gmail.com is restricted" OR
  60. aa.state_reason != "An error occurred during processing. Please try again." OR
  61. aa.state_reason != "id: 10672L not approved" OR
  62. aa.state_reason != "id: 107307L not approved" OR
  63. aa.state_reason != "id: 89650L not approved" OR
  64. aa.state_reason != "NO+MEAL+PLAN" OR
  65. aa.state_reason != "You do not have permission to use the preapproval key" OR
  66. aa.state_reason != "The email address mpowers831@aim.com is invalid. It may not be registered in PayPal's system yet" OR
  67. aa.state_reason != "Plan Expired" OR
  68. aa.state_reason != "MISSING_HANDLER" OR
  69. aa.state_reason != "Exception" OR
  70. aa.state_reason != "Unknown" OR
  71. aa.state_reason != "" OR
  72. aa.state_reason != "Account lilimartinez9348@yahoo.com is restricted" OR
  73. aa.state_reason != "Account tilghmantuebner@gmail.com is restricted" OR
  74. aa.state_reason != "Card Deleted" OR
  75. aa.state_reason != "Card Expired" OR
  76. aa.state_reason != "Card Expired The card is expired." OR
  77. aa.state_reason != "Card Invalid -L/S" OR
  78. aa.state_reason != "Card Invalid-L/S" OR aa.state_reason != "CARD IS LOST" OR aa.state_reason != "Card Not In System" OR aa.state_reason != "Card Not In System The card is not entered in the system." OR aa.state_reason != "Card On Hold" OR aa.state_reason != "Card On Hold Use of card denied until the hold expires." OR aa.state_reason != "Card Suspended" OR aa.state_reason != "Card Suspended The card is suspended." OR aa.state_reason != "CREDIT CARD EXPIRATION DATE IS INVALID." OR aa.state_reason != "Exception" OR aa.state_reason != "Exception occured (503, u'Service Unavailable')" OR aa.state_reason != "FAILED" OR aa.state_reason != "FRAUDULENT USER" OR aa.state_reason != "id: %% not approved" OR aa.state_reason != "id: 10672L not approved" OR aa.state_reason != "id: 107307L not approved" OR aa.state_reason != "id: 89650L not approved" OR aa.state_reason != "id: 98065L not approved" OR aa.state_reason != "INSUFFICIENT BALANCE" OR aa.state_reason != "Insufficient Funds The card account has an insufficient balance or credit to cover the purchase." OR aa.state_reason != "INSUFFICIENT_BALANCE" OR aa.state_reason != "INVALID CARD" OR aa.state_reason != "MISSING_HANDLER" OR aa.state_reason != "No credit card for tapingo delivery fee!" OR aa.state_reason != "PATRON+NOT+FOUND" OR aa.state_reason != "PAYMENT_SERVER_UNREACHABLE" OR aa.state_reason != "Period Excluded The privilege plan rules deny the use of the privilege during the time interval in effect." OR aa.state_reason != "Period Used The privilege used at a previous time period during the day." OR aa.state_reason != "Period Used The privilege used at a previous time period during the day. [charged meal plan points]" OR aa.state_reason != "Plan Expired" OR aa.state_reason != "Plan Expired All other abnormal error conditions." OR aa.state_reason != "Plan Expired The cardholder's privilege plan has expired." OR aa.state_reason != "SERVICE_TYPE_NOT_SUPPORTED" OR aa.state_reason != "SHOP_IS_COMING_SOON" OR aa.state_reason != "SHOP_IS_NOT_ACTIVE" OR aa.state_reason != "SHOP_IS_NOT_OPEN" OR aa.state_reason != "SHOP_IS_UNDER_MAINTENANCE" OR aa.state_reason != "THE CREDIT CARD HAS EXPIRED." OR aa.state_reason != "THE CREDIT CARD NUMBER IS INVALID." OR aa.state_reason != "The email address mpowers831@aim.com is invalid. It may not be registered in PayPal's system yet" OR aa.state_reason != "The payment can not be processed because no payment source is available" OR aa.state_reason != "The preapproval key can't be used before the start date or after the end date" OR aa.state_reason != "The preapproval key hasn't been authorized yet" OR aa.state_reason != "THE TRANSACTION HAS BEEN DECLINED BECAUSE OF AN AVS MISMATCH. THE ADDRESS PROVIDED DOES NOT MATCH BILLING ADDRESS OF CARDHOLDER." OR aa.state_reason != "THIS TRANSACTION HAS BEEN DECLINED." OR aa.state_reason != "USER NOT SUBSCRIBED" OR aa.state_reason != "USER WAS NOTIFIED" OR aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus" OR aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus support during business hours 8a-5p mon-fri (928)523-0081" OR
  79. aa.state_reason != "You do not have permission to use the preapproval key")
  80.  
  81. GROUP BY aa.shop_id, aa.state_reason
  82. ) temp
  83.  
  84. join (
  85. SELECT
  86. aa. name as "Campus",
  87. aa.id,
  88. count(aa.Error) as "Errors"
  89. FROM
  90. (
  91. SELECT
  92. bo.name,
  93. bo.id,
  94. oo.owner_id,
  95. ee.name as shop_name,
  96. oo.shop_id,
  97. state,
  98. state_reason,
  99. count(*) AS Error
  100.  
  101. FROM
  102. orders_order oo
  103. INNER JOIN billi_organization bo ON bo.id = oo.organization_id
  104. INNER JOIN entities_entity ee ON ee.id = oo.shop_id
  105. WHERE
  106. bo.creation_time > '2012-6-1'
  107. AND state LIKE 'ERROR%%'
  108. AND (oo.merchant_creation_time-interval '5' hour) between '%(from)s' and '%(to)s'
  109. GROUP BY
  110. oo.shop_id,
  111. state_reason,
  112. oo.owner_id
  113. ) aa
  114. WHERE
  115. (aa.state_reason != "Exception occured (503, u'Service Unavailable')" OR aa.state_reason != "Card Suspended The card is suspended." OR aa.state_reason != "%% not approved" OR aa.state_reason != "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." OR aa.state_reason != "Plan Expired All other abnormal error conditions." OR aa.state_reason != "INVALID CARD" OR aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus support during business hours 8a-5p mon-fri (928)523-0081" OR aa.state_reason != "Privilege Suspended" OR aa.state_reason != "CARD IS LOST" OR aa.state_reason != "Internal Error" OR aa.state_reason != "id: 98065L not approved" OR aa.state_reason != "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open." OR aa.state_reason != "Could not print! Printer is offline. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." OR aa.state_reason != "SERVICE_TYPE_NOT_SUPPORTED" OR aa.state_reason != "Card Invalid-L/S" OR aa.state_reason != "Invalid request parameter: amount must be greater than zero" OR aa.state_reason != "FAILED" OR aa.state_reason != "Account tilghmantuebner@gmail.com is restricted" OR aa.state_reason != "An error occurred during processing. Please try again." OR aa.state_reason != "id: 10672L not approved" OR aa.state_reason != "id: 107307L not approved" OR aa.state_reason != "id: 89650L not approved" OR aa.state_reason != "NO+MEAL+PLAN" OR aa.state_reason != "You do not have permission to use the preapproval key" OR aa.state_reason != "The email address mpowers831@aim.com is invalid. It may not be registered in PayPal's system yet" OR aa.state_reason != "Plan Expired" OR aa.state_reason != "MISSING_HANDLER" OR aa.state_reason != "Exception" OR aa.state_reason != "Unknown" OR aa.state_reason != "" OR aa.state_reason != "Account lilimartinez9348@yahoo.com is restricted" OR aa.state_reason != "Account tilghmantuebner@gmail.com is restricted" OR aa.state_reason != "Card Deleted" OR aa.state_reason != "Card Expired" OR aa.state_reason != "Card Expired The card is expired." OR aa.state_reason != "Card Invalid -L/S" OR aa.state_reason != "Card Invalid-L/S" OR aa.state_reason != "CARD IS LOST" OR aa.state_reason != "Card Not In System" OR aa.state_reason != "Card Not In System The card is not entered in the system." OR aa.state_reason != "Card On Hold" OR aa.state_reason != "Card On Hold Use of card denied until the hold expires." OR aa.state_reason != "Card Suspended" OR aa.state_reason != "Card Suspended The card is suspended." OR aa.state_reason != "CREDIT CARD EXPIRATION DATE IS INVALID." OR aa.state_reason != "Exception" OR aa.state_reason != "Exception occured (503, u'Service Unavailable')" OR aa.state_reason != "FAILED" OR aa.state_reason != "FRAUDULENT USER" OR aa.state_reason != "%% not approved" OR aa.state_reason != "id: 10672L not approved" OR aa.state_reason != "id: 107307L not approved" OR aa.state_reason != "id: 89650L not approved" OR aa.state_reason != "id: 98065L not approved" OR aa.state_reason != "INSUFFICIENT BALANCE" OR aa.state_reason != "Insufficient Funds The card account has an insufficient balance or credit to cover the purchase." OR aa.state_reason != "INSUFFICIENT_BALANCE" OR aa.state_reason != "INVALID CARD" OR aa.state_reason != "MISSING_HANDLER" OR aa.state_reason != "No credit card for tapingo delivery fee!" OR aa.state_reason != "PATRON+NOT+FOUND" OR aa.state_reason != "PAYMENT_SERVER_UNREACHABLE" OR aa.state_reason != "Period Excluded The privilege plan rules deny the use of the privilege during the time interval in effect." OR aa.state_reason != "Period Used The privilege used at a previous time period during the day." OR aa.state_reason != "Period Used The privilege used at a previous time period during the day. [charged meal plan points]" OR aa.state_reason != "Plan Expired" OR aa.state_reason != "Plan Expired All other abnormal error conditions." OR aa.state_reason != "Plan Expired The cardholder's privilege plan has expired." OR aa.state_reason != "SERVICE_TYPE_NOT_SUPPORTED" OR aa.state_reason != "SHOP_IS_COMING_SOON" OR aa.state_reason != "SHOP_IS_NOT_ACTIVE" OR aa.state_reason != "SHOP_IS_NOT_OPEN" OR aa.state_reason != "SHOP_IS_UNDER_MAINTENANCE" OR aa.state_reason != "THE CREDIT CARD HAS EXPIRED." OR aa.state_reason != "THE CREDIT CARD NUMBER IS INVALID." OR aa.state_reason != "The email address mpowers831@aim.com is invalid. It may not be registered in PayPal's system yet" OR aa.state_reason != "The payment can not be processed because no payment source is available" OR aa.state_reason != "The preapproval key can't be used before the start date or after the end date" OR aa.state_reason != "The preapproval key hasn't been authorized yet" OR aa.state_reason != "THE TRANSACTION HAS BEEN DECLINED BECAUSE OF AN AVS MISMATCH. THE ADDRESS PROVIDED DOES NOT MATCH BILLING ADDRESS OF CARDHOLDER." OR aa.state_reason != "THIS TRANSACTION HAS BEEN DECLINED." OR aa.state_reason != "USER NOT SUBSCRIBED" OR aa.state_reason != "USER WAS NOTIFIED" OR aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus" OR aa.state_reason != "We are sorry, your NAU email address could not be found. Verify your email address or contact campus support during business hours 8a-5p mon-fri (928)523-0081" OR aa.state_reason != "You do not have permission to use the preapproval key")
  116.  
  117. GROUP BY
  118. aa.id
  119. ) temp2 on temp2.id = temp.id
  120.  
  121. left join
  122. (
  123. select
  124. count(oo.id) as orders,
  125. oo.organization_id
  126. From
  127. orders_order oo
  128. where
  129. oo.is_valid_for_billing = 1
  130. and oo.is_valid_for_reporting = 1
  131. and oo.state = "COMPLETED"
  132. and oo.amount_from_user >0
  133. AND (oo.merchant_creation_time-interval '5' hour) between '%(from)s' and '%(to)s'
  134.  
  135. group by
  136. oo.organization_id
  137. ) oo on oo.organization_id = temp.id
  138.  
  139. left join
  140. (
  141. select "INSUFFICIENT_BALANCE" as reason ,"User" as class union all select "Period Used The privilege used at a previous time period during the day." ,"Validation" union all select "SHOP_IS_UNDER_MAINTENANCE" ,"Validation" union all select "Card On Hold Use of card denied until the hold expires." ,"Payment Server" union all select "Insufficient Funds" ,"User" union all select "THIS TRANSACTION HAS BEEN DECLINED." ,"Payment Server" union all select "ORDER_DELIVERY_INVALID_ADDRESS_NOT_IN_ZONE" ,"Validation" union all select "Card Expired The card is expired." ,"User" union all select "Card Expired" ,"User" union all select "THE CREDIT CARD NUMBER IS INVALID." ,"User" union all select "Could not print! Printer is off! (timed out)" ,"POS" union all select "Privilege Unassigned" ,"Unknown" union all select "Could not print! Printer is off! (actively refused)" ,"POS" union all select "Card Not In System" ,"Payment Server" union all select "SHOP_IS_COMING_SOON" ,"Validation" union all select "SHOP_IS_NOT_OPEN" ,"Validation" union all select "Card Not In System The card is not entered in the system." ,"Payment Server" union all select "Card On Hold" ,"Validation" union all select "Invalid Location The Location is unavailable in privilege plan rules." ,"Validation" union all select "ORDER_DID_NOT_REACH_MINIMUM" ,"Validation" union all select "Could not print! Printer is offline. The cover is open. Paper has ended." ,"POS" union all select "Card Invalid -L/S" ,"Payment Server" union all select "Could not print! Printer is offline. Paper has ended." ,"POS" union all select "Privilege Unassigned The cardholder attempts a non-assigned privilege." ,"Payment Server" union all select "Insufficient Funds The card account has an insufficient balance or credit to cover the purchase." ,"User" union all select "Invalid value or type" ,"Gateway" union all select "THE CREDIT CARD HAS EXPIRED." ,"Validation" union all select "USER NOT SUBSCRIBED" ,"Payment Server" union all select "BlackBoard timeout!" ,"Payment Server" union all select "Card Deleted" ,"Payment Server" union all select "PAYMENT_SERVER_UNREACHABLE" ,"Payment Server" union all select "Meal Plan order with zero amount!" ,"Validation" union all select "Unknown error!" ,"Unknown" union all select "Plan Expired The cardholder's privilege plan has expired." ,"Validation" union all select "" ,"Unknown" union all select "SHOP_IS_NOT_ACTIVE" ,"Validation" union all select "TENDER NOT ALLOWED IN SHOP" ,"Validation" union all select "THE TRANSACTION HAS BEEN DECLINED BECAUSE OF AN AVS MISMATCH. THE ADDRESS PROVIDED DOES NOT MATCH BILLING ADDRESS OF CARDHOLDER." ,"Payment Server" union all select "Undefined Error All other abnormal error conditions." ,"Unknown" union all select "MISSING_HANDLER" ,"Other" union all select "Exception" ,"Unknown" union all select "The preapproval key can't be used before the start date or after the end date" ,"Unknown" union all select "CREDIT CARD EXPIRATION DATE IS INVALID." ,"User" union all select "Meal Plan order with amount > 1!" ,"Validation" union all select "Invalid Time The privilege plan rules deny the use of the privilege during the time interval in effect." ,"Validation" union all select "TOO_MANY_COUNT_TRANSACTIONS" ,"Unknown" union all select "We are sorry, your NAU email address could not be found. Verify your email address or contact campus" ,"Other" union all select "The preapproval key hasn't been authorized yet" ,"Unknown" union all select "Tender # Not Valid" ,"Validation" union all select "Unknown" ,"Unknown" union all select "Invalid value or type Encryption/error checking of '0' and a defined encryption key in the configu" ,"POS" union all select "USER WAS NOTIFIED" ,"Other" union all select "Period Used The privilege used at a previous time period during the day. [charged meal plan points]" ,"Validation" union all select "PATRON+NOT+FOUND" ,"Other" union all select "Could not print! No such host is known" ,"pos" union all select "Undefined Error" ,"Unknown" union all select "AUTO_SELECT_FAILED" ,"Validation" union all select "NON MEAL PLAN TENDER IN MEAL PLAN SHOP" ,"User" union all select "Could not reach spooler." ,"POS" union all select "Card Suspended" ,"Validation" union all select "Could not print! Printer is offline. The cover is open." ,"POS" union all select "Could not reach spooler server!" ,"POS" union all select "Could not print! Printer is offline. Paper has ended., Could not print! Printer is offline. Paper has ended." ,"POS" union all select "Virtual tender does not have two sub tenders!" ,"Validation" union all select "The payment can not be processed because no payment source is available" ,"User" union all select "Could not print! Printer is offline. A non recoverable error has occurred. An auto-cutter error has occurred." ,"POS" union all select "Invalid value or type ID number or Track 2 card data ID does not match the card definition encoding." ,"POS" union all select "Could not print! Printer is off! (timed out), Could not print! Printer is off! (timed out)" ,"POS" union all select "need more than 0 values to unpack" ,"Unknown" union all select "FRAUDULENT USER" ,"User" union all select "Invalid sub tenders for virtual tender!" ,"Validation" union all select "AN ERROR OCCURRED DURING PROCESSING. PLEASE TRY AGAIN." ,"Unknown" union all select "Invalid value or type Terminal Number '0' or > '99999999' or not numeric type." ,"POS" union all select "Period Excluded The privilege plan rules deny the use of the privilege during the time interval in effect." ,"Validation" union all select "Exception occured (503, u'Service Unavailable')" ,"Unknown" union all select "Card Suspended The card is suspended." ,"Validation" union all select "%% not approved" ,"Other" union all select "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." ,"POS" union all select "INSUFFICIENT BALANCE" ,"Validation" union all select "Plan Expired All other abnormal error conditions." ,"Other" union all select "TIMEOUT" ,"POS" union all select "INVALID CARD" ,"Validation" union all select "No credit card for tapingo delivery fee!" ,"User" union all select "We are sorry, your NAU email address could not be found. Verify your email address or contact campus support during business hours 8a-5p mon-fri (928)523-0081" ,"User" union all select "Privilege Suspended" ,"Other" union all select "CARD IS LOST" ,"Validation" union all select "Internal Error" ,"Other" union all select "id: 98065L not approved" ,"Other" union all select "Could not print! Printer is offline. The cover is open. Paper has ended., Could not print! Printer is offline. The cover is open." ,"POS" union all select "Could not print! Printer is offline. Paper has ended., Could not print! Printer is offline. The cover is open. Paper has ended." ,"POS" union all select "SERVICE_TYPE_NOT_SUPPORTED" ,"Other" union all select "Card Invalid-L/S" ,"Validation" union all select "Invalid request parameter: amount must be greater than zero" ,"User" union all select "Account lilimartinez9348@yahoo.com is restricted" ,"Other" union all select "FAILED" ,"Unknown" union all select "Account tilghmantuebner@gmail.com is restricted" ,"User" union all select "An error occurred during processing. Please try again." ,"Unknown" union all select "id: 10672L not approved" ,"Other" union all select "id: 107307L not approved" ,"Other" union all select "id: 89650L not approved" ,"Other" union all select "NO+MEAL+PLAN" ,"user" union all select "You do not have permission to use the preapproval key" ,"Other" union all select "The email address mpowers831@aim.com is invalid. It may not be registered in PayPal's system yet" ,"User" union all select "Plan Expired" ,"Validation" union all select "No meal equivalence for shop!" ,"User" union all select "NO PLAN WITH SUFFICIENT BALANCE FOUND" ,"Validation" union all select "Exception occured Server raised fault: 'Server was unable to process request. ---> Unable to cast ob" ,"Validation" union all select "INSUFICCIENT_BALANCE" ,"User" union all select "Exception occured Incorrect padding" ,"Validation" union all select "" ,"Other" union all select "SHOP IS NOT OPEN IN SLOT TIME" ,"Validation" union all select "ERR -43" ,"Unknown" union all select "contact venue to make sure order was received" ,"POS" union all select "" ,"Other" union all select "" ,"Other" union all select "INVALID PLAN" ,"Validation"
  142. ) c on c.reason = temp.state_reason
  143. ,
  144. (
  145. select
  146. count(oo.id) as orders
  147. From
  148. orders_order oo
  149. where
  150. oo.is_valid_for_billing = 1
  151. and oo.is_valid_for_reporting = 1
  152. and oo.state = "COMPLETED"
  153. and oo.amount_from_user >0
  154. AND (oo.merchant_creation_time-interval '5' hour) between '%(from)s' and '%(to)s'
  155.  
  156. ) tapingo_orders
  157. where
  158. temp.id != 69
  159. group by
  160. temp.Campus,
  161. temp.shop_name,
  162. temp.shop_id,
  163. temp.state,
  164. temp.state_reason
  165. order by
  166. temp.Campus,
  167. temp.Errors desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement