send_refillex.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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($index)
  17. {
  18. $time = time() * 1000 + $index;
  19. for ($i = 0; $i < 500; $i++)
  20. {
  21. $this->push_order(1092, $time, $i);
  22. }
  23. }
  24. public function sendex()
  25. {
  26. $pThis = $this;
  27. for ($i = 1000;$i < 3000; $i++)
  28. {
  29. go(function () use ($pThis,$i) {
  30. $pThis->send($i);
  31. });
  32. }
  33. }
  34. private function push_order($mchid,$time,$index)
  35. {
  36. $notify_url = "http://test.xyzshops.cn/mobile/callback/bridge_test.php";
  37. $params = [ 'mchid' => $mchid,
  38. 'amount' => 30,
  39. 'order_sn' => "{$time}" . sprintf("%'010d",$index),
  40. 'cardno' => '13911129867',
  41. "act" => "refill",
  42. "op" => "add",
  43. 'notifyurl' => $notify_url
  44. ];
  45. $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80");
  46. $resp = $proxy->send("http://test.xyzshops.cn/mobile/index.php", $params);
  47. }
  48. }
  49. go(function () {
  50. $sender = new RefillSender();
  51. $sender->sendex();
  52. });