processor.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  3. class processor extends queue\ILooper
  4. {
  5. private $mProxy;
  6. public function __construct($comode = false)
  7. {
  8. if ($comode) {
  9. parent::__construct(new queue\CoDispatcherServer());
  10. } else {
  11. parent::__construct(new queue\DispatcherServer());
  12. }
  13. $this->mProxy = new proxy();
  14. }
  15. protected function handle($msg)
  16. {
  17. if (empty($msg)) return '';
  18. $method = '';
  19. foreach ($msg as $key => $params)
  20. {
  21. if (empty($params)) continue;
  22. $method = strtolower($key);
  23. Log::record("processor hanlde method={$method}", Log::DEBUG);
  24. try
  25. {
  26. if ($method == 'add') {
  27. $this->mProxy->add($params);
  28. } elseif ($method == 'notify') {
  29. $channel = $params['channel'];
  30. $input = $params['params'];
  31. if (empty($channel) || empty($params))
  32. continue;
  33. $this->mProxy->notify($channel, $input);
  34. } elseif ($method == 'notify_mechant') {
  35. $order_id = intval($params['order_id']);
  36. $manual = $params['manual'] ?? false;
  37. $this->mProxy->notify_merchant($order_id, $manual);
  38. } elseif ($method == 'query') {
  39. $order_id = intval($params['order_id']);
  40. $this->mProxy->query($order_id);
  41. } elseif ($method == 'query_net') {
  42. $order_id = intval($params['order_id']);
  43. $this->mProxy->query_net($order_id);
  44. } elseif ($method == 'manual_success') {
  45. $order_id = intval($params['order_id']);
  46. $this->mProxy->manual_success($order_id);
  47. } elseif ($method == 'manual_cancel') {
  48. $order_id = intval($params['order_id']);
  49. $this->mProxy->manual_cancel($order_id);
  50. } elseif ($method == 'addthird') {
  51. $this->mProxy->addthird($params);
  52. } else {
  53. Log::record("Error Method={$method}", Log::DEBUG);
  54. }
  55. }
  56. catch (Exception $x) {
  57. Log::record("processor::handle ". $x->getMessage(), Log::ERR);
  58. }
  59. }
  60. return $method;
  61. }
  62. }