|
@@ -9,6 +9,8 @@ define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
|
|
|
require_once(BASE_ROOT_PATH . '/global.php');
|
|
|
require_once(BASE_CORE_PATH . '/lrlz.php');
|
|
|
require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
|
|
|
+
|
|
|
|
|
|
function my_ssh_disconnect($reason, $message, $language) {
|
|
|
printf("Server disconnected with reason code [%d] and message: %s\n",
|
|
@@ -46,12 +48,6 @@ class TestSSH2 extends TestCase
|
|
|
ssh2_disconnect($connection);
|
|
|
}
|
|
|
|
|
|
- public function testAddOrder()
|
|
|
- {
|
|
|
- #卡号|订单号(唯一的)| 状态(只给成功)| 面值 |运营商流水凭证| 手机号| 创建时间|交易成功时间
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
//docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestSSH2::testConnectYFT)( .*)?$/" --test-suffix TestSSH2.php /var/www/html/test
|
|
|
public function testConnectYFT()
|
|
|
{
|
|
@@ -93,6 +89,9 @@ class TestSSH2 extends TestCase
|
|
|
Log::record("$remote_file not exist.", Log::DEBUG);
|
|
|
return false;
|
|
|
}
|
|
|
+ else {
|
|
|
+ Log::record("find file=$remote_file",LOg::DEBUG);
|
|
|
+ }
|
|
|
|
|
|
$local_file = BASE_DATA_PATH . "/log/$name";
|
|
|
|
|
@@ -111,6 +110,71 @@ class TestSSH2 extends TestCase
|
|
|
$cur_time = time();
|
|
|
$a = strftime("%Y%m%d_000110089970029",$cur_time);
|
|
|
Log::record("$a", Log::DEBUG);
|
|
|
+ $start_date = strtotime('20241211164754');
|
|
|
+ Log::record("$start_date", Log::DEBUG);
|
|
|
+ $a = strftime("%Y-%m-%d %H:%M:%S",$start_date);
|
|
|
+
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
+ public function testParase()
|
|
|
+ {
|
|
|
+ #卡号|订单号(唯一的)| 状态(只给成功)| 面值 |运营商流水凭证| 手机号| 创建时间|交易成功时间
|
|
|
+ #5|3456.00
|
|
|
+
|
|
|
+ $text = '9629980601009991|62241211164700945495|成功|938|6200945495|13391703053|20241211164725|20241211164754';
|
|
|
+
|
|
|
+ $matcher = function ($input)
|
|
|
+ {
|
|
|
+ $data = explode('|', $input);
|
|
|
+ $count = count($data);
|
|
|
+ if ($count === 8) {
|
|
|
+ return [
|
|
|
+ 'bank_card' => trim($data[0]),
|
|
|
+ 'mch_order' => trim($data[1]),
|
|
|
+ 'status' => 'SUCCESS',
|
|
|
+ 'amount' => 1,
|
|
|
+ 'org_quality' => 2,
|
|
|
+ 'quantity' => intval(trim($data[3])),
|
|
|
+ 'official_sn' => trim($data[4]),
|
|
|
+ 'card_no' => trim($data[5]),
|
|
|
+ 'order_time' => strtotime(trim($data[6])),
|
|
|
+ 'finish_time' => strtotime(trim($data[7]))
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ elseif($count === 2) {
|
|
|
+ return [
|
|
|
+ 'count' => intval(trim($data[0])),
|
|
|
+ 'total' => intval(trim($data[1]))
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $result = $matcher($text);
|
|
|
+
|
|
|
+ $minfo = $this->mchinfo(1092);
|
|
|
+ $params = array_merge($result,$minfo,['notify_url' => 'https://www.xyzshops.cn/mobile/callback/refill_yifutong.php']);
|
|
|
+ $mch_order = $params['mch_order'];
|
|
|
+ refill\util::write_yifutong_order($mch_order,$params);
|
|
|
+ $val = refill\util::read_yifutong_order($mch_order);
|
|
|
+ refill\util::push_add($params);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGetMchinfo()
|
|
|
+ {
|
|
|
+ $minfo = $this->mchinfo(1092);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private function mchinfo($mchid)
|
|
|
+ {
|
|
|
+ $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
|
|
|
+ if(empty($mchinfo)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ['mchid' =>$mchid, 'buyer_id' => intval($mchinfo['admin_id'])];
|
|
|
+ }
|
|
|
+}
|