send_refill.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. declare(strict_types=0);
  3. define('MOBILE_SERVER',true);
  4. define('USE_COROUTINE',true);
  5. define('SUPPORT_PTHREAD',false);
  6. define('APP_ID', 'sender');
  7. define('BASE_ROOT_PATH',str_replace('/server','',dirname(__FILE__)));
  8. define('BASE_PATH',BASE_ROOT_PATH . '/server');
  9. require_once(BASE_ROOT_PATH . '/global.php');
  10. require_once(BASE_ROOT_PATH . '/fooder.php');
  11. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  12. require_once(BASE_HELPER_PATH . '/refill_proxy.php');
  13. Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL|SWOOLE_HOOK_SLEEP]);
  14. class RefillSender
  15. {
  16. public function send()
  17. {
  18. $time = time();
  19. for ($i = 0; $i < 10000; $i++)
  20. {
  21. $pThis = $this;
  22. go(function () use($time, $i,$pThis) {
  23. $pThis->push_order(1092, $time, $i);
  24. });
  25. }
  26. }
  27. private function push_order($mchid,$time,$index)
  28. {
  29. $notify_url = "https://test.xyzshops.cn/mobile/callback/bridge_test.php";
  30. $params = [ 'mchid' => $mchid,
  31. 'amount' => 30,
  32. 'order_sn' => "{$time}" . sprintf("%'010d",$index),
  33. 'cardno' => '13911129867',
  34. "act" => "refill",
  35. "op" => "add",
  36. 'notifyurl' => $notify_url
  37. ];
  38. $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80");
  39. $resp = $proxy->send("https://test.xyzshops.cn/mobile/index.php", $params);
  40. $resp = json_encode($resp);
  41. Log::record("resp={$resp}",Log::DEBUG);
  42. }
  43. }
  44. Log::record("send message start",Log::DEBUG);
  45. go(function () {
  46. $sender = new RefillSender();
  47. $sender->send();
  48. });
  49. Log::record("send message end",Log::DEBUG);