Guest User

Untitled

a guest
Jul 18th, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. <?php
  2. /**
  3. * Decoder
  4. *
  5. * - Bank payment received --> Application insert total amount --> System Reload promised Balance
  6. *
  7. */
  8. class Application_Model_Payments
  9. {
  10.  
  11. /**
  12. * Round follow up: A - G
  13. */
  14. public static function getAdvise($data)
  15. {
  16. /* Round A - TransactionID to User profile grep OK */
  17. $db = Application_Model_Db::db_load();
  18. $sql = "select *from
  19. sh_account
  20. where
  21. transaction_id='{$data->transaction_id}'
  22. ";
  23. $result = $db->fetchAll($sql);
  24. $res = (object) $result[0];
  25.  
  26. /* Round B - Amount received in Bank OK */
  27. $target = $data->amount;
  28.  
  29.  
  30. /* Round C - Residential users 0% VAT OK */
  31. if ($res->signup_group == '2')
  32. {
  33.  
  34. switch($data->from)
  35. {
  36. case 'paypal':
  37.  
  38. /* Round D - Input->Find->Pormised->Discount OK */
  39. $sql = "
  40. select *from sh_payment_discount
  41. where
  42. signup_group = '2' and
  43. paymentmethod = 'paypal' and
  44. inputamount >= {$data->amount}
  45. order by
  46. inputamount asc
  47. limit 1 ";
  48.  
  49. $result = $db->fetchAll($sql);
  50.  
  51. if ( count($result) > 0)
  52. {
  53. $row = (object) $result[0];
  54.  
  55. /* Round E - Mr. Customer i promised 0.95 or 0.93 OK */
  56. $percent = 100 - $result[0]['percent'];
  57. $percent = $percent / 100;
  58.  
  59. /* Round F - Mr. Customer i have handling cost for this OK */
  60. $final_price = ($data->amount - 0.35) / 1.034/$percent;
  61.  
  62. /* Round G - Mr. Customer,
  63. i am trying to remember what i promised ERROR ERROR*/
  64.  
  65. $target = array(
  66.  
  67. 'subtotal' => Zend_Locale_Format::toNumber($final_price,array('number_format' => '##0.00','locale' => 'en')),
  68. 'discount' => $percent,
  69. 'paypal' => 0,
  70. 'vat' => Zend_Locale_Format::toNumber(0,array('number_format' => '##0.00','locale' => 'en')),
  71. 'total' => Zend_Locale_Format::toNumber($data->amount,array('number_format' => '##0.00','locale' => 'en'))
  72.  
  73. );
  74.  
  75. break;
  76. }
  77.  
  78.  
  79. break;
  80.  
  81. case 'wire':
  82. ....
  83. break;
  84.  
  85. case 'payphone':
  86. ....
  87. break;
  88.  
  89. case 'receipt':
  90. ....
  91. break;
  92.  
  93. }
  94. }
  95.  
  96.  
  97. /* Done - with suggestion algorithm - please decide now what requires */
  98. return array(
  99. 'raw' => $reserved,
  100. 'result' => $target,
  101. );
  102.  
  103.  
  104. }
  105.  
  106. ....
Add Comment
Please, Sign In to add comment