processor.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 == 'add_zero') {
  29. $this->mProxy->add_zero($params);
  30. } elseif ($method == 'notify') {
  31. $channel = $params['channel'];
  32. $input = $params['params'];
  33. if (empty($channel) || empty($params))
  34. continue;
  35. $this->mProxy->notify($channel, $input);
  36. } elseif ($method == 'notify_mechant') {
  37. $order_id = intval($params['order_id']);
  38. $manual = $params['manual'] ?? false;
  39. $this->mProxy->notify_merchant($order_id, $manual);
  40. } elseif ($method == 'notify_merchant_success') { //发预回调通知.
  41. $mchid = intval($params['mchid']);
  42. $mch_order = trim($params['mch_order']);
  43. $this->mProxy->notify_merchant_success($mchid, $mch_order);
  44. } elseif ($method == 'query') {
  45. $order_id = intval($params['order_id']);
  46. $this->mProxy->query($order_id);
  47. } elseif ($method == 'query_auto') {
  48. $order_id = intval($params['order_id']);
  49. $query_times = intval($params['query_times']);
  50. $this->mProxy->query_auto($order_id,$query_times);
  51. } elseif ($method == 'query_net') {
  52. $order_id = intval($params['order_id']);
  53. $this->mProxy->query_net($order_id);
  54. } elseif ($method == 'query_timeout') {
  55. $mchid = intval($params['mchid']);
  56. $mch_order = trim($params['mch_order']);
  57. $this->mProxy->query_timeout($mchid,$mch_order);
  58. } elseif ($method == 'manual_success') {
  59. $order_id = intval($params['order_id']);
  60. $this->mProxy->manual_success($order_id);
  61. } elseif ($method == 'manual_cancel') {
  62. $order_id = intval($params['order_id']);
  63. $this->mProxy->manual_cancel($order_id);
  64. } elseif ($method == 'addthird') {
  65. $this->mProxy->addthird($params);
  66. } else {
  67. Log::record("Error Method={$method}", Log::DEBUG);
  68. }
  69. }
  70. catch (Exception $x) {
  71. Log::record("processor::handle ". $x->getMessage(), Log::ERR);
  72. }
  73. }
  74. return $method;
  75. }
  76. }