stanley-king 3 yıl önce
ebeveyn
işleme
f208659de1
1 değiştirilmiş dosya ile 20 ekleme ve 8 silme
  1. 20 8
      server/send_refill.php

+ 20 - 8
server/send_refill.php

@@ -2,6 +2,10 @@
 
 declare(strict_types=0);
 
+define('MOBILE_SERVER',true);
+define('USE_COROUTINE',true);
+define('SUPPORT_PTHREAD',false);
+
 define('APP_ID', 'sender');
 define('BASE_ROOT_PATH',str_replace('/server','',dirname(__FILE__)));
 define('BASE_PATH',BASE_ROOT_PATH . '/server');
@@ -11,20 +15,23 @@ require_once(BASE_ROOT_PATH . '/fooder.php');
 require_once(BASE_CORE_PATH . '/framework/function/http.php');
 require_once(BASE_HELPER_PATH . '/refill_proxy.php');
 
-//Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL|SWOOLE_HOOK_SLEEP]);
+Co::set(['hook_flags' => SWOOLE_HOOK_NATIVE_CURL|SWOOLE_HOOK_SLEEP]);
 
 class RefillSender
 {
     public function send()
     {
         $time = time();
-        Log::record("push message start:{$time}",Log::DEBUG);
+        Log::record("send message start:{$time}",Log::DEBUG);
 
-        for ($i = 0; $i < 100000; $i++)
+        for ($i = 0; $i < 10000; $i++)
         {
-            $this->push_order(1092,$time,$i);
+            $pThis = $this;
+            go(function () use($time, $i,$pThis) {
+                $pThis->push_order(1092, $time, $i);
+            });
         }
-        Log::record("push message end",Log::DEBUG);
+        Log::record("send message end",Log::DEBUG);
     }
 
     private function push_order($mchid,$time,$index)
@@ -33,7 +40,7 @@ class RefillSender
         $params = [ 'mchid' => $mchid,
             'amount' => 30,
             'order_sn' => "{$time}" . sprintf("%'010d",$index),
-            'card_no' => '13911129867',
+            'cardno' => '13911129867',
             "act" => "refill",
             "op" => "add",
             'notifyurl' => $notify_url
@@ -41,11 +48,16 @@ class RefillSender
 
         $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80");
         $resp = $proxy->send("http://test.xyzshops.cn/mobile/index.php", $params);
+        Log::record("resp={$resp}",Log::DEBUG);
     }
 }
 
-$sender = new RefillSender();
-$sender->send();
+go(function () {
+    $sender = new RefillSender();
+    $sender->send();
+});
+
+