123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- <?php
- define('APP_ID', 'test');
- define('BASE_ROOT_PATH', str_replace('/test/mh', '', 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/XYZRefillFactory.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
- require_once(BASE_CORE_PATH . '/framework/function/http.php');
- use PHPUnit\Framework\TestCase;
- class TestRefill extends TestCase
- {
- public static function setUpBeforeClass() : void
- {
- Base::run_util();
- }
- public function testStart()
- {
- $x = 19;
- }
- public function testDixin()
- {
- $provider = $this->getProvider('dixin_normal');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13911129867, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testDixinCB()
- {
- $content = '{"order_no":"OD40636475187360296","merchant_no":"0059570753462761433314","recharge_account":"13911129867","recharge_status":4,"complete_time":"2023-11-16 15:12:42","settlement_price":"47.30","total_amount":"50.00","actual_amount":"0.00","create_time":"2023-11-16 15:12:41","custom_tag":"123456","sign":"49b7f9f32a34f1c83dcb0d976f28d061"}';
- $provider = $this->getProvider('dixin_normal','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testSuhu()
- {
- $provider = $this->getProvider('suhu_normal');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13167599238, 5, 100, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testSuhuCB()
- {
- $content = '{"order_no":"OD40636475187360296","merchant_no":"0059570753462761433314","recharge_account":"13911129867","recharge_status":4,"complete_time":"2023-11-16 15:12:42","settlement_price":"47.30","total_amount":"50.00","actual_amount":"0.00","create_time":"2023-11-16 15:12:41","custom_tag":"123456","sign":"49b7f9f32a34f1c83dcb0d976f28d061"}';
- $provider = $this->getProvider('suhu_normal','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testSuhuWozhifu()
- {
- $provider = $this->getProvider('suhu_wozhifu');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13911129867, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testSuhuWozhifuCB()
- {
- $content = '{"order_no":"OD40636475187360296","merchant_no":"0059570753462761433314","recharge_account":"13911129867","recharge_status":4,"complete_time":"2023-11-16 15:12:42","settlement_price":"47.30","total_amount":"50.00","actual_amount":"0.00","create_time":"2023-11-16 15:12:41","custom_tag":"123456","sign":"49b7f9f32a34f1c83dcb0d976f28d061"}';
- $provider = $this->getProvider('suhu_wozhifu','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testYushang()
- {
- $provider = $this->getProvider('yushang_normal');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13911129867, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testYushangCB()
- {
- $_POST= '{"ChargeAccount":"13911129867","ProductCode":"PLM100068","BuyCount":"1","MOrderID":"85661700722959070814","OrderID":"231123150239738000","State":"2","AppKey":"211394653","TimesTamp":"1700723025672","Sign":"86004EF5A40B8D8B30D7454246763DF4","ExtendParam":"{\"OfficialDes\":\"\u624b\u652f\u6e20\u9053\",\"OfficialOrderID\":\"OfficialOrderID001\",\"SellPrice\":16000}","ChargeMsg":""}';
- $content = json_decode($_POST,true);
- $provider = $this->getProvider('yushang_normal','RefillCallBack');
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testLifang()
- {
- $provider = $this->getProvider('lifang_normal');
- $order_sn = $this->make_sn();
- // $resp = $provider->add(15652921127, 5, 30, ['order_sn' => $order_sn, 'regin_no' => 1]);
- // $resp = $provider->query(['order_sn' => $order_sn]);
- // $resp = $provider->balance();
- }
- public function testLifangCB()
- {
- $_POST='{"orderId":"S23112800025098","outOrderId":"60201701159853851187","requestDate":"20231128164156","sign":"E172D40D040D26C8226E237ACED8C861","accessToken":"beaf87f8-7c6b-cb8a-98b8-53c207ca9aef","status":"1"}';
- $content = json_decode($_POST,true);
- $provider = $this->getProvider('lifang_normal','RefillCallBack');
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testWeisanhuo()
- {
- $provider = $this->getProvider('weisanhuo_normal');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13911220681, 4, 1, ['order_sn' => $order_sn, 'regin_no' => 1]);//30为测试产品
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testWeisanhuoCB()
- {
- $post = '{"operatorTradeNo":"202312198256229371","statusDesc":"交易成功","phone":"13911220681","outTradeNo":"91791702973663689415","sign":"c81575ceb8d2b28cd37e33c65141361c","inTradeNo":"20231219161425561173378018037","status":"success","reportTime":"1702974060008"}';
- $data = json_decode($post, true);
- $provider = $this->getProvider('weisanhuo_normal', 'RefillCallBack');
- $ret = $provider->verify($data);
- $resp = $provider->notify($data);
- }
- public function testSohanFast()
- {
- $provider = $this->getProvider('kefei_fast');
- $order_sn = $this->make_sn();
- $resp = $provider->add(13911129867, 4, 1, ['order_sn' => $order_sn, 'regin_no' => 1]);//30为测试产品
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testMifengFast()
- {
- $provider = $this->getProvider('mifeng_fast');
- $order_sn = $this->make_sn();
- $commit_time = time();
- $resp = $provider->add(13911129867, 4, 1, ['order_sn' => $order_sn, 'regin_no' => 1]);//30为测试产品
- $resp = $provider->query(['order_sn' => $order_sn,'commit_time' => $commit_time]);
- $resp = $provider->balance();
- }
- public function testMifengCB()
- {
- $post = [
- 'biz_no'=> '',
- 'order_id'=> '24012700374791',
- 'third_id'=> '63171706324493482078',
- 'real_amount'=> '0',
- 'state'=> '4',
- 'info'=> '【商务配置问题】sku面值模板101117无价格配置,请反馈我司商务【吴坤明18036272205】',
- 'time'=> '1706324495',
- 'voucher'=> '',
- 'card_no'=> '',
- 'error_code'=> '1',
- 'cost'=> '0',
- 'sign'=> 'b566ea9a067d5366312927741ec90943'
- ];
- $provider = $this->getProvider('mifeng_fast', 'RefillCallBack');
- $ret = $provider->verify($post);
- $resp = $provider->notify($post);
- }
- public function testSohanFastCB()
- {
- $post = [
- 'Action' => 'CX',
- 'AgentAccount' => 'api_test',
- 'Agentbalance' => '-400.000',
- 'Orderid' => '40661703685798184367',
- 'Chargeid' => '3386490685',
- 'Orderstatu_int' => '20',
- 'TransCash' => '1.000',
- 'OrderPayment' => '1.000',
- 'Errorcode' => '0000',
- 'Errormsg' => '',
- 'Sign' => '2fee99fc128de20c150d8d55ea8bb008'
- ];
- $provider = $this->getProvider('kefei_fast', 'RefillCallBack');
- $ret = $provider->verify($post);
- $resp = $provider->notify($post);
- }
- public function testGetOSN()
- {
- $get_osn = function($str)
- {
- $ret = preg_match("/[\s]+(?P<osn>[0-9a-zA-Z]*)/i",$str,$arr);
- if($ret > 0) {
- return $arr['osn'];
- } else {
- return "";
- }
- };
- $str = "缴费成功 8940247595202312075787697476";
- $osn = $get_osn($str);
- // $ret = preg_match('/[\w\W]+UPDATE[\w\W]+available_predeposit=available_predeposit(?P<oper>[-+]+)(?P<amount>[.\d]+)/i', $line, $matches);
- $val = json_encode(['account' => '13911129867']);
- }
- private function getProvider($name, $type = 'RefillPhone')
- {
- $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php";
- if(!file_exists($file)){
- Log::record("provider api file=$file not exist.",Log::DEBUG);
- return false;
- } else {
- require_once($file);
- Log::record("file=$file load success.",Log::DEBUG);
- }
- $class_name = "refill\\{$name}\\{$type}";
- if (class_exists($class_name, false)) {
- $caller = new $class_name([]);
- return $caller;
- } else {
- $error = "Base Error: class {$class_name} isn't exists!";
- Log::record($error, Log::ERR);
- return false;
- }
- }
- private function make_sn()
- {
- return mt_rand(1000, 9999)
- . sprintf('%010d', time())
- . sprintf('%06d', (float)microtime() * 1000000);
- }
- public function testMillsec()
- {
- $microtime = intval(microtime(true) * 1000);
- }
- public function testLast()
- {
- echo date("Y-m-d H:i:s",time());
- }
- public function testSeven()
- {
- $provider = $this->getProvider('seven_kami');
- $order_sn = $this->make_sn();
- $resp = $provider->add(15652921127, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testSevenCB()
- {
- $content = '{"szAgentId":"OD40636475187360296","szOrderId":"0059570753462761433314","szPhoneNum":"13911129867","nDemo":"50.00","fSalePrice":"47.30","nFlag":2,"szVerifyString":"49b7f9f32a34f1c83dcb0d976f28d061"}';
- $provider = $this->getProvider('seven_kami','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testGY()
- {
- $provider = $this->getProvider('gy_normal');
- $order_sn = $this->make_sn();
- $resp = $provider->add(15652921127, 5, 50, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testGYCB()
- {
- $content = '{"szAgentId":"OD40636475187360296","szOrderId":"0059570753462761433314","szPhoneNum":"13911129867","nDemo":"50.00","fSalePrice":"47.30","nFlag":2,"szVerifyString":"49b7f9f32a34f1c83dcb0d976f28d061"}';
- $provider = $this->getProvider('gy_normal','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testGetOSNEx()
- {
- $get_osn = function ($str)
- {
- // if(preg_match('/[^\x00-\x80]/',$str)){
- // $str =iconv("UTF-8","gb2312",$str);
- // }
- // $ret = preg_match("/[\s]+(?P<osn>[0-9a-zA-Z]*)/ui",$str,$arr);
- $ret = preg_match("/[\x{4e00}-\x{9fa5}\p{P}]+(?P<osn>[0-9a-zA-Z]*)/ui", $str, $arr);
- if ($ret > 0) {
- return $arr['osn'];
- } else {
- return "";
- }
- };
- $sn = $get_osn('充值成功:22934014758535263');
- }
- public function testZX()
- {
- $provider = $this->getProvider('zhixin_fast');
- $order_sn = $this->make_sn();
- $resp = $provider->add(15652921127, 5, 10, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- public function testZXCB()
- {
- $content = '{"client_order_no":"17741706252802986862","up_order_no":"20240126150648323856096","product_type":"1","phone_no":"15652921127","deduction_amount":"1007.0000","recharge_status":"2","elecardID":"110101101232401261506580165004","sign":"68121ec19d480e96d3c1a9828c3f65b5","channel_type":"other"}';
- $provider = $this->getProvider('zhixin_fast','RefillCallBack');
- $content = json_decode($content,true);
- $provider->verify($content);
- $provider->notify($content);
- }
- public function testGuitong()
- {
- $provider = $this->getProvider('guitong_fast');
- // $resp = $provider->balance();
- // $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
- // $resp = $provider->query(['order_sn' => '15551649669272272125']);
- $body = '{"szOrderId":"15551649669272272125","fSalePrice":"28.62","szAgentId":"200062","nFlag":"3","szVerifyString":"62e5b8a71935a36acf563f232b75210e","szPhoneNum":"18500608333","szRtnMsg":"","nDemo":"30"}';
- $params = json_decode($body, true);
- $provider = $this->getProvider('guitong_fast','RefillCallBack');
- $resp = $provider->verify($params);
- $resp = $provider->notify($params);
- }
- public function testBee()
- {
- $provider = $this->getProvider('mifeng_fast');
- $order_sn = "61131706607286935980";//$this->make_sn();
- //$resp = $provider->add(15652921127, 5, 10, ['order_sn' => $order_sn, 'regin_no' => 1]);
- $resp = $provider->query(['order_sn' => $order_sn]);
- $resp = $provider->balance();
- }
- }
|