EventManager.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace refill;
  3. use Log;
  4. class EventManager
  5. {
  6. private static $stInstance = null;
  7. public static function instance()
  8. {
  9. if (self::$stInstance == null) {
  10. self::$stInstance = new EventManager();
  11. }
  12. return self::$stInstance;
  13. }
  14. public function load()
  15. {
  16. }
  17. public static function onBeforeSubmit(order $order)
  18. {
  19. return true;
  20. }
  21. public function onSubmit(order $order)
  22. {
  23. }
  24. public function onBeforeCommit(order $order, $ch_name): bool
  25. {
  26. return true;
  27. }
  28. public function onCommit(order $order, $ch_name)
  29. {
  30. }
  31. public function onNeterror(order $order, $ch_name)
  32. {
  33. }
  34. public function onNotify($refill_info, $order_info, $success)
  35. {
  36. $uid = "{$refill_info['mchid']}-{$refill_info['mch_order']}";
  37. $ch_name = $refill_info['channel_name'];
  38. Log::record("onEvent notify uid=$uid channel=$ch_name success=$success", Log::DEBUG);
  39. }
  40. public function onComplete($refill_info, $order_info, $success)
  41. {
  42. $uid = "{$refill_info['mchid']}-{$refill_info['mch_order']}";
  43. $ch_name = $refill_info['channel_name'];
  44. Log::record("onEvent complete uid=$uid channel=$ch_name success=$success", Log::DEBUG);
  45. }
  46. }