|
@@ -8,25 +8,124 @@ require_once(BASE_CORE_PATH . '/lrlz.php');
|
|
|
require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
|
|
|
|
|
|
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
|
|
|
+
|
|
|
+const LocalTest = 1;
|
|
|
+const NetTest = 2;
|
|
|
+
|
|
|
+const CurrentTest = NetTest;
|
|
|
+
|
|
|
Co::set(['hook_flags' => SWOOLE_HOOK_ALL | SWOOLE_HOOK_NATIVE_CURL ]);
|
|
|
|
|
|
+class acc
|
|
|
+{
|
|
|
+ private $mReqHost;
|
|
|
+ private $mKey;
|
|
|
+ private $mMchid;
|
|
|
+
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ if (CurrentTest == LocalTest) {
|
|
|
+ $this->mReqHost = 'http://host.docker.internal';//BASE_SITE_URL;
|
|
|
+ $this->mMchid = 1;
|
|
|
+ $this->mKey = '1ff02223b771c0414468c8892151c602';
|
|
|
+ } else {
|
|
|
+ $this->mReqHost = 'http://121.89.212.167';
|
|
|
+ $this->mMchid = 1092;
|
|
|
+ $this->mKey = '210fe406954220f56085997d6a4c5b80';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function setUpBeforeClass(): void
|
|
|
+ {
|
|
|
+ Base::run_util();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testAddoil()
|
|
|
+ {
|
|
|
+ $url = $this->mReqHost . "/racc/index.php";
|
|
|
+ for ($i = 0; $i < 1000; $i++)
|
|
|
+ {
|
|
|
+ $params = $this->make_order();
|
|
|
+ $resp = $this->send_md5($url, $params);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function make_order()
|
|
|
+ {
|
|
|
+ $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
|
|
|
+ $params = ['mchid' => $this->mMchid,
|
|
|
+ 'cardno' => '13911129867',
|
|
|
+ 'amount' => "30",
|
|
|
+ "act" => "refill",
|
|
|
+ "op" => "add",
|
|
|
+ 'order_sn' => $this->make_sn(),
|
|
|
+ 'notifyurl' => $notifyurl];
|
|
|
+
|
|
|
+ return $params;
|
|
|
+ }
|
|
|
+ private function send_md5($url, $params)
|
|
|
+ {
|
|
|
+ $body = $this->body($params);
|
|
|
+ $body .= "&key={$this->mKey}";
|
|
|
+ $params['sign'] = md5($body);
|
|
|
+
|
|
|
+ $resp = http_request($url, $params);
|
|
|
+ Log::record("resp:{$resp}", Log::DEBUG);
|
|
|
+
|
|
|
+ return $resp;
|
|
|
+ }
|
|
|
+ private function body($params)
|
|
|
+ {
|
|
|
+ ksort($params);
|
|
|
+ $body = "";
|
|
|
+ $i = 0;
|
|
|
+ foreach ($params as $k => $v) {
|
|
|
+ if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
|
|
|
+ if ($i == 0) {
|
|
|
+ $body .= "{$k}" . "=" . urlencode($v);
|
|
|
+ } else {
|
|
|
+ $body .= "&" . "{$k}" . "=" . urlencode($v);
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $body;
|
|
|
+ }
|
|
|
+ private function checkEmpty($value)
|
|
|
+ {
|
|
|
+ if (!isset($value))
|
|
|
+ return true;
|
|
|
+ if ($value === null)
|
|
|
+ return true;
|
|
|
+ if (trim($value) === "")
|
|
|
+ return true;
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private function make_sn()
|
|
|
+ {
|
|
|
+ return mt_rand(1000, 9999)
|
|
|
+ . sprintf('%010d', time())
|
|
|
+ . sprintf('%06d', (float)microtime() * 1000000);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
go(function ()
|
|
|
{
|
|
|
- $n = 1000;
|
|
|
+ $n = 10;
|
|
|
$i = 0;
|
|
|
Log::record("start {$i}", Log::DEBUG);
|
|
|
|
|
|
+ $acc = new acc();
|
|
|
+
|
|
|
while ($n--) {
|
|
|
- go(function () use ($i) {
|
|
|
- Log::record("start {$i}", Log::DEBUG);
|
|
|
- $resp = http_request('https://www.xyzshops.cn/mobile/index.php?act=index&op=index&client_type=ios');
|
|
|
- Log::record("recv {$i} size=" . strlen($resp), Log::DEBUG);
|
|
|
- $resp = http_request('https://www.xyzshops.cn/mobile/index.php?act=index&op=index&client_type=ios');
|
|
|
- Log::record("recv {$i} size=" . strlen($resp), Log::DEBUG);
|
|
|
- $resp = http_request('https://www.xyzshops.cn/mobile/index.php?act=index&op=index&client_type=ios');
|
|
|
- Log::record("recv {$i} size=" . strlen($resp), Log::DEBUG);
|
|
|
+ go(function () use ($i,$acc) {
|
|
|
+ $acc->testAddoil();
|
|
|
});
|
|
|
$i++;
|
|
|
- Co::sleep(0.0001);
|
|
|
}
|
|
|
});
|