stanley-king il y a 3 ans
Parent
commit
829cfc5a26
2 fichiers modifiés avec 88 ajouts et 0 suppressions
  1. 15 0
      docker/compose/xyzt-sender/docker-compose.yml
  2. 73 0
      server/send_refillex.php

+ 15 - 0
docker/compose/xyzt-sender/docker-compose.yml

@@ -14,4 +14,19 @@ services:
     deploy:
       resources:
         limits:
+          cpus: '8'
+
+  sendexsrv:
+    image: php-swool-redis:latest
+    volumes:
+      - ../../conf/etc/localtime:/etc/localtime:ro
+      - ../../../:/var/www/html
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/testlog:/var/www/html/data/log
+      - ../../conf/php/xyzt-php-swoole.ini:/usr/local/etc/php/php.ini
+    container_name: "worker-senderex"
+    command: [php,"/var/www/html/server/send_refillex.php"]
+    deploy:
+      resources:
+        limits:
           cpus: '8'

+ 73 - 0
server/send_refillex.php

@@ -0,0 +1,73 @@
+<?php
+
+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');
+
+require_once(BASE_ROOT_PATH . '/global.php');
+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]);
+
+class RefillSender
+{
+    public function send($index)
+    {
+        $time = time() * 1000 + $index;
+
+        for ($i = 0; $i < 1000; $i++)
+        {
+            $pThis = $this;
+            go(function () use($time, $i,$pThis) {
+                $pThis->push_order(1092, $time, $i);
+            });
+        }
+    }
+
+    public function sendex()
+    {
+        $pThis = $this;
+        for ($i = 1000;$i < 2000; $i++)
+        {
+            go(function () use ($pThis,$i) {
+                $pThis->send($i);
+            });
+        }
+    }
+
+    private function push_order($mchid,$time,$index)
+    {
+        $notify_url = "http://test.xyzshops.cn/mobile/callback/bridge_test.php";
+        $params = [ 'mchid' => $mchid,
+            'amount' => 30,
+            'order_sn' => "{$time}" . sprintf("%'010d",$index),
+            'cardno' => '13911129867',
+            "act" => "refill",
+            "op" => "add",
+            'notifyurl' => $notify_url
+        ];
+
+        $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80");
+        $resp = $proxy->send("http://test.xyzshops.cn/mobile/index.php", $params);
+        $resp = json_encode($resp);
+        Log::record("resp={$resp}",Log::DEBUG);
+    }
+}
+
+go(function () {
+    $sender = new RefillSender();
+    $sender->send();
+});
+
+
+
+
+