TestRefill.php 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. use function mtopcard\formatProvince;
  4. use const mtopcard\ProvinceList;
  5. define('APP_ID', 'test');
  6. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  7. require_once(BASE_ROOT_PATH . '/global.php');
  8. require_once(BASE_CORE_PATH . '/lrlz.php');
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  11. require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
  12. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  13. const LocalTest = 1;
  14. const NetTest = 2;
  15. const CurrentTest = LocalTest;
  16. class TestRefill extends TestCase
  17. {
  18. private $mReqHost;
  19. private $mKey;
  20. private $mMchid;
  21. public function __construct(?string $name = null, array $data = [], $dataName = '')
  22. {
  23. parent::__construct($name, $data, $dataName);
  24. if (CurrentTest == LocalTest) {
  25. $this->mReqHost = BASE_SITE_URL;
  26. $this->mMchid = 1;
  27. $this->mKey = '1ff02223b771c0414468c8892151c602';
  28. } else {
  29. // $this->mReqHost = 'https://www.xyzshops.cn';
  30. $this->mReqHost = 'http://121.89.196.45';
  31. $this->mMchid = 1092;
  32. $this->mKey = '210fe406954220f56085997d6a4c5b80';
  33. }
  34. }
  35. public static function setUpBeforeClass(): void
  36. {
  37. Base::run_util();
  38. refill\RefillFactory::instance();
  39. }
  40. public function testMerchantPrice()
  41. {
  42. $price = new refill\merchant_price();
  43. }
  44. public function testCallBack()
  45. {
  46. }
  47. public function testFactory()
  48. {
  49. $providers = refill\RefillFactory::instance();
  50. }
  51. private function make_sn()
  52. {
  53. return mt_rand(1000, 9999)
  54. . sprintf('%010d', time())
  55. . sprintf('%06d', (float)microtime() * 1000000);
  56. }
  57. public function testRandomMobile()
  58. {
  59. $no = "1" . mt_rand(1, 9999999999);
  60. Log::record("phone no={$no}", Log::DEBUG);
  61. }
  62. public function testBJBAddPhone()
  63. {
  64. $providers = new refill\bjb\RefillPhone([]);
  65. for ($i = 3; $i > 0; --$i) {
  66. $resp = $providers->add(13911129867, 4, 10, ['order_sn' => $this->make_sn()]);
  67. $resp = $providers->add(18500608333, 4, 10, ['order_sn' => $this->make_sn()]);
  68. $resp = $providers->add(18510683168, 4, 10, ['order_sn' => $this->make_sn()]);
  69. $resp = $providers->add(18513846008, 4, 10, ['order_sn' => $this->make_sn()]);
  70. $resp = $providers->add(18518237398, 4, 10, ['order_sn' => $this->make_sn()]);
  71. }
  72. }
  73. public function testOilticket()
  74. {
  75. $providers = new refill\bjb\RefillPhone([]);
  76. }
  77. public function testBjbRet()
  78. {
  79. $resp = '0|提交成功|14936.8600';
  80. $resp = explode('|', $resp);
  81. }
  82. public function testIpWhiteList()
  83. {
  84. $x = serialize(['47.99.57.105']);
  85. $ips = unserialize('a:1:{i:0;s:12:"47.99.57.105";}');
  86. if (!empty($ips)) {
  87. $addr = '47.99.57.105';
  88. Log::record("request ip:{$addr}", Log::DEBUG);
  89. if (!in_array($addr, $ips)) {
  90. throw new Exception("请求地址不在白名单中");
  91. }
  92. }
  93. }
  94. public function testBaizePhone()
  95. {
  96. $providers = new refill\baizeyd\RefillPhone([]);
  97. // $resp = $providers->add(17801048874, 5, 10, ['order_sn' => $this->make_sn()]);
  98. $resp = $providers->query(['order_sn' => '930668700375312006']);
  99. // $str = 'amount=10.00&orderId=720668384771999671&phone=13911129867&payTime=2021-03-06+22%3A26%3A12&sign=94dfe83221f7768650e70cce08879b60&appKey=uECmTOFAY6RPCTtI&payUrl=&statusDes=%E6%94%AF%E4%BB%98%E5%A4%B1%E8%B4%A5&status=7';
  100. // $input = $this->parse_request($str);
  101. // $input['amount'] = 10.00;
  102. // $input['orderId'] = '92391614943913061206';
  103. // $input['phone'] = 17801048874;
  104. // $input['payTime'] = '2021-03-05 19:31:55';
  105. // $input['sign'] = 'bef6ae50319fb1e8cb3f21302f0abef8';
  106. // $input['appKey'] = 'uECmTOFAY6RPCTtI';
  107. // $input['payUrl'] = '';
  108. // $input['statusDes'] = '支付失败';
  109. // $input['status'] = 7;
  110. // refill\RefillFactory::instance()->notify('baizeyd',$input);
  111. }
  112. private function parse_request($squery)
  113. {
  114. if (empty($squery)) return [];
  115. $result = [];
  116. $params = preg_split('/&/', $squery);
  117. foreach ($params as $pair) {
  118. if (empty($pair)) continue;
  119. $kv = explode('=', $pair);
  120. $count = count($kv);
  121. if ($count === 1) {
  122. $key = $kv[0];
  123. $val = "";
  124. } elseif ($count === 2) {
  125. $key = $kv[0];
  126. $val = urldecode($kv[1]);
  127. } else {
  128. continue;
  129. }
  130. if (!empty($key)) {
  131. $result[$key] = $val;
  132. }
  133. }
  134. return $result;
  135. }
  136. public function testAmPhone()
  137. {
  138. // $providers = new refill\aming\RefillPhone([]);
  139. // $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  140. $input['result'] = 'fail';
  141. $input['msg'] = 0;
  142. $input['order'] = 'null';
  143. $input['phone_no'] = 18500608333;
  144. $input['sign'] = 'c925ad19c63c3eb36ffc52d938e24604';
  145. $input['amount'] = '10.00';
  146. $input['op_no'] = '42601615096072517841';
  147. refill\RefillFactory::instance()->notify('aming', $input);
  148. }
  149. public function testBhcPhone()
  150. {
  151. $providers = new refill\binghc\RefillPhone([]);
  152. $resp = $providers->query(['order_sn' => 250668618955902006]);
  153. // $input['result'] = 'fail';
  154. // $input['msg'] = 0;
  155. // $input['order'] = 'null';
  156. // $input['phone_no'] = 18500608333;
  157. // $input['sign'] = 'c3aa38ee07cd1b69bfd5ead56f6da8d6';
  158. // $input['amount'] = '10.00';
  159. // $input['op_no'] = '24061615096361999002';
  160. // refill\RefillFactory::instance()->notify('binghc',$input);
  161. }
  162. public function testRuishunPhone()
  163. {
  164. // $providers = new refill\ruishun\RefillPhone([]);
  165. // $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  166. $input['result'] = 'fail';
  167. $input['msg'] = 0;
  168. $input['order'] = null;
  169. $input['phone_no'] = 18500608333;
  170. $input['sign'] = 'e234f7d1c0458ca236f53a0008436b46';
  171. $input['amount'] = "10.00";
  172. $input['op_no'] = '76361615095403188513';
  173. refill\RefillFactory::instance()->notify('ruishun', $input);
  174. }
  175. public function testWuchenPhone()
  176. {
  177. $providers = new refill\wuchen\RefillPhone([]);
  178. // $resp = $providers->add('13699279618', 5, 30, ['order_sn' => $this->make_sn()]);
  179. $resp = $providers->query(['order_sn' => '790668630498425006']);
  180. // $input['app_id'] = '70016';
  181. // $input['message'] = 'fail';
  182. // $input['order_sn'] = '43101615277293035501';
  183. // $input['platform_order_id'] = '';
  184. // $input['sign'] = '5ea59f8ac51a518f2c622824d7db2a04';
  185. // $input['state'] = "fail";
  186. // $input['sys_sn'] = '202103091608231836913889';
  187. // $input['timestamp'] = '1615277361';
  188. // refill\RefillFactory::instance()->notify('wuchen',$input);
  189. }
  190. public function testYibaoPhone()
  191. {
  192. $providers = new refill\yibao\RefillPhone([]);
  193. // $resp = $providers->add('13699279618', 5, 30, ['order_sn' => $this->make_sn()]);
  194. $resp = $providers->query(['ch_trade_no' => '31215002972142736']);
  195. // $str = '{"amount":"30","carrierOrderNo":null,"mobile":"13699279618","orderNo":"27961615532426088043","orderStatus":3,"sign":"012BA0B093A0473D7DD1634A8356DCB1","tradeNo":"31215002972142736"}';
  196. // $data = json_decode($str,true);
  197. // refill\RefillFactory::instance()->notify('yibao',$data);
  198. }
  199. public function testAmingydPhone()
  200. {
  201. $providers = new refill\amingyd\RefillPhone([]);
  202. // $resp = $providers->add('13699279618', 5, 30, ['order_sn' => $this->make_sn()]);
  203. $resp = $providers->query(['order_sn' => '15421615627436792938']);
  204. // $str = '{"orderId":"15421615627436792938","amount":3000,"appKey":"40695059","timestamp":1615627503,"status":3,"operatorId":"508353854027968617","sign":"2A0562319ED4845AB9E3812A58F0B425"}';
  205. // $data = json_decode($str,true);
  206. // refill\RefillFactory::instance()->notify('amingyd',$data);
  207. }
  208. public function testChukaPhone()
  209. {
  210. $providers = new refill\chuka\RefillPhone([]);
  211. // $resp = $providers->add('18500608333', 5, 20, ['order_sn' => $this->make_sn()]);
  212. // $resp = $providers->query(['order_sn' => '92161616314884175179']);
  213. $params['customerId'] = '101787';
  214. $params['orderno'] = 'C1616314888506705492';
  215. $params['tmporder'] = '92161616314884175179';
  216. $params['code'] = '1';
  217. $params['number'] = '18500608333';
  218. $params['money'] = '20';
  219. $params['amount'] = '0';
  220. refill\RefillFactory::instance()->notify('chuka', $params);
  221. }
  222. public function testLegouPhone()
  223. {
  224. $providers = new refill\legou\RefillPhone([]);
  225. // $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '200649600557718881' , 'order_id' => 247 , 'buyer_id' => 52667]);
  226. $resp = $providers->query(['order_sn' => '200649600557718881', 'order_id' => 247]);
  227. $params['username'] = 'lzdc';
  228. $params['orderNumber'] = '690653407667699667';
  229. $params['cardNumber'] = '18500608333';
  230. $params['orderMoney'] = '30.0';
  231. $params['orderPay'] = '1.0';
  232. $params['resultCode'] = '2';
  233. $params['rechargeDesc'] = '{"rechargeStatus":600200,"rechargeDesc":"充值成功"}';
  234. $params['rechargeVoucher'] = '100407307092103291444050244599';
  235. $params['sign'] = 'c054884422a8c3749cbfda0e82b9af70';
  236. // refill\RefillFactory::instance()->notify('legou',$params);
  237. }
  238. public function testFeiniaoPhone()
  239. {
  240. $providers = new refill\feiniao\RefillPhone([]);
  241. // $order_sn = $this->make_sn();
  242. // Log::record($order_sn, Log::DEBUG);
  243. // $resp = $providers->add('13699279618', 4, 50, ['order_sn' => $order_sn]);
  244. $resp = $providers->query(['order_sn' => '28641617178590981824']);
  245. $params['result'] = 'fail';
  246. $params['msg'] = '0';
  247. $params['order'] = 'null';
  248. $params['phone_no'] = '18500608333';
  249. $params['amount'] = '100.00';
  250. $params['op_no'] = '64591617090761169983';
  251. $params['settle'] = '0';
  252. $params['sign'] = '907d2640f96e8d78d59202d090ddb470';
  253. // refill\RefillFactory::instance()->notify('feiniao',$params);
  254. }
  255. public function testTongyPhone()
  256. {
  257. $providers = new refill\tongy\RefillPhone([]);
  258. $resp = $providers->add('18500608333', 5, 30, ['order_sn' => '690653407667699667', 'order_id' => 248, 'buyer_id' => 52667]);
  259. }
  260. public function testWeiyiPhone()
  261. {
  262. $providers = new refill\weiyi\RefillPhone([]);
  263. // $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  264. // $resp = $providers->query(['order_sn' => '90401621489214002876']);
  265. $body = '{"userid":"1f68bb3452134a6cbaa4","ordernum":"90401621489214002876","mobile":"13699279618","timestamp":"20210520134039","state":"2","desc":"%E5%85%85%E5%80%BC%E6%88%90%E5%8A%9F","sign":"865e8d886b92e019df1d039fccf8df46"}';
  266. $params = json_decode($body , true);
  267. refill\RefillFactory::instance()->notify('weiyi',$params);
  268. }
  269. public function testWeiyimanPhone()
  270. {
  271. $providers = new refill\weiyiman\RefillPhone([]);
  272. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  273. // $resp = $providers->query(['order_sn' => '47591620898269370373']);
  274. $data = '{"userid":"46dbb0c992644da881d0","ordernum":"47591620898269370373","mobile":"18500608333","timestamp":"20210513211050","state":"2","desc":"%E5%85%85%E5%80%BC%E6%88%90%E5%8A%9F","serialno":"173313182872","sign":"e9d2ea85b43808d1587793ae329cdb0b"}';
  275. $params = json_decode($data , true);
  276. refill\RefillFactory::instance()->notify('weiyiman',$params);
  277. }
  278. public function testWeiyiWtPhone()
  279. {
  280. $providers = new refill\weiyiwt\RefillPhone([]);
  281. // $resp = $providers->add(18074608795, 6, 50, ['order_sn' => $this->make_sn()]);
  282. // $resp = $providers->query(['order_sn' => '38451621924366009924']);
  283. $body = '{"szOrderId":"38451621924366009924","fSalePrice":"47.25","szAgentId":"200016","nFlag":"2","szVerifyString":"a0b5bfc0bbf6c121a4cd74d9ecb2427d","szPhoneNum":"18074608795","szRtnMsg":"1000000083421052514441119833","nDemo":"50"}';
  284. $params = json_decode($body , true);
  285. refill\RefillFactory::instance()->notify('weiyiwt',$params);
  286. }
  287. public function testXiaochuangPhone()
  288. {
  289. $providers = new refill\xiaochuang\RefillPhone([]);
  290. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  291. // $resp = $providers->query(['order_sn' => '84891623028826872085']);
  292. $body = '{"fail_msg":"","order_sn":"84891623028826872085","order_status":"4","p_order_sn":"2021060709203558011797441162","sign":"E842203C3CA48E924D60B1B56AB93C3B"}';
  293. $params = json_decode($body , true);
  294. refill\RefillFactory::instance()->notify('xiaochuang',$params);
  295. }
  296. public function testYintengPhone()
  297. {
  298. $providers = new refill\yinteng\RefillPhone([]);
  299. // $resp = $providers->add(18074608795, 6, 50, ['order_sn' => $this->make_sn()]);
  300. // $resp = $providers->query(['order_sn' => '49631623737966351874']);
  301. $data = '{"szOrderId":"49631623737966351874","fSalePrice":"47.35","szAgentId":"200009","nFlag":"2","szVerifyString":"01c5fafb1d67175f0533b69a762286e8","szPhoneNum":"18074608795","szRtnMsg":"1000000083421061514495400262","nDemo":"50"}';
  302. $params = json_decode($data , true);
  303. refill\RefillFactory::instance()->notify('yinteng',$params);
  304. }
  305. public function testMoxjPhone()
  306. {
  307. $providers = new refill\moxj\RefillPhone([]);
  308. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  309. $resp = $providers->query(['order_sn' => '91131623906171663147']);
  310. $data = '{"result":"fail","msg":"0","order":"null","phone_no":"18500608333","amount":"50.0","op_no":"84901623900668776864","sign":"896b54914a07b814573d7f6cc403848a"}';
  311. $params = json_decode($data , true);
  312. // refill\RefillFactory::instance()->notify('moxj',$params);
  313. }
  314. public function testMoxj_fsPhone()
  315. {
  316. $providers = new refill\moxj_fs\RefillPhone([]);
  317. // $resp = $providers->add(15139608757, 4, 100, ['order_sn' => $this->make_sn()]);
  318. $resp = $providers->query(['order_sn' => '42741624242693157165']);
  319. $data = '{"amount":"100","charge_type":"2","code":"1","partner_id":"58","phone":"15139608757","sign":"30d193dba4101e50851ed0efabb75fb1","partner_order_no":"42741624242693157165","official_order_id":"20210621103211948830"}';
  320. $params = json_decode($data , true);
  321. // refill\RefillFactory::instance()->notify('moxj_fs',$params);
  322. }
  323. public function testZanzanquickPhone()
  324. {
  325. $providers = new refill\zanzanquick\RefillPhone([]);
  326. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  327. // $resp = $providers->query(['order_sn' => '90831623925322675223']);
  328. $data = '{"userid":"d845a4635f7e47668f5e","ordernum":"90831623925322675223","mobile":"18500608333","timestamp":"20210617182545","state":"2","desc":"%E5%85%85%E5%80%BC%E6%88%90%E5%8A%9F","serialno":"110103307232106171824530567108","sign":"0152c723f25be19f21d723e24b2c8987"}';
  329. $params = json_decode($data , true);
  330. refill\RefillFactory::instance()->notify('zanzanquick',$params);
  331. }
  332. public function testFengyemanPhone()
  333. {
  334. $providers = new refill\fengyeman\RefillPhone([]);
  335. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  336. // $resp = $providers->query(['order_sn' => '46221624265179185139']);
  337. $data = '{"order_id":"46221624265179185139","mchid":"HF67a65_10008","tel":"18500608333","price":"50.00","sign":"2bb4ed5edc97ba7f60cf3848aab82cf4","out_order_id":"206877995456","status":"1"}';
  338. $params = json_decode($data , true);
  339. refill\RefillFactory::instance()->notify('fengyeman',$params);
  340. }
  341. public function testMoxj_ydPhone()
  342. {
  343. $providers = new refill\moxj_yd\RefillPhone([]);
  344. $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  345. // $resp = $providers->query(['order_sn' => '52101624413125875436']);
  346. $data = '{"customer_order_no":"47651624412877257722","status":1,"merchant_id":"76505818","sign":"c185a0f2152b3ac3ee3f29009dec5a6b"}';
  347. $params = json_decode($data , true);
  348. // refill\RefillFactory::instance()->notify('moxj_yd',$params);
  349. }
  350. public function testTongluPhone()
  351. {
  352. $providers = new refill\tonglu\RefillPhone([]);
  353. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  354. $resp = $providers->query(['order_sn' => '22961616468561936356']);
  355. // $body = '{"order_no":"22961616468561936356","order_status":"5","phone_no":"18500608333","amount":5000,"time_paid":1616468856287,"order_cert_no":"","paid":false,"order_id":"20210323966497008"}';
  356. // $sign = '9E41F52F612D60EBB654B3A5D1E2F1E5';
  357. // $params = json_decode($body , true);
  358. // $params['sign'] = $sign;
  359. // refill\RefillFactory::instance()->notify('tonglu',$params);
  360. }
  361. public function testAmingjd()
  362. {
  363. // $providers = new refill\amingjd\RefillPhone([]);
  364. // $resp = $providers->add(13699279618, 5, 30, ['order_sn' => $this->make_sn()]);
  365. // $resp = $providers->query(['order_sn' => '42301616475989518588']);
  366. $body = '{"order_id":"83321616478215494884","mchid":"10003","tel":"13699279618","price":"30.00","sign":"01c49620c155a80bc43cecc2b1651868","status":"0","out_order_id":"0"}';
  367. $params = json_decode($body, true);
  368. refill\RefillFactory::instance()->notify('amingjd', $params);
  369. }
  370. public function testAmingjdmanPhone()
  371. {
  372. $providers = new refill\amingjdman\RefillPhone([]);
  373. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  374. // $resp = $providers->query(['order_sn' => '82741619577673758623']);
  375. $body = '{"order_id":"82741619577673758623","mchid":"10045","tel":"13699279618","price":"30.00","sign":"2fe55fb4d4b2acc2e98137adb82fa57e","status":"0","out_order_id":"0"}';
  376. $params = json_decode($body, true);
  377. refill\RefillFactory::instance()->notify('amingjdman', $params);
  378. }
  379. public function testWeishengyWtPhone()
  380. {
  381. $providers = new refill\weishengywt\RefillPhone([]);
  382. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  383. // $resp = $providers->query(['order_sn' => '27681620538125370652']);
  384. $data = '{"szOrderId":"27681620538125370652","fSalePrice":"47.5","szAgentId":"200045","nFlag":"2","szVerifyString":"92fafec121b77518d539ed9f5005fdf9","szPhoneNum":"18500608333","szRtnMsg":"110103308032105091328520502948","nDemo":"50"}';
  385. $params = json_decode($data, true);
  386. refill\RefillFactory::instance()->notify('weishengywt', $params);
  387. }
  388. public function testWeishengyJDPhone()
  389. {
  390. $providers = new refill\weishengyjd\RefillPhone([]);
  391. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  392. // $resp = $providers->query(['order_sn' => '14261620887423822879']);
  393. $data = '{"szOrderId":"14261620887423822879","fSalePrice":"44.0","szAgentId":"200050","nFlag":"3","szVerifyString":"3cceef390602058e1d2fdde2e07636a4","szPhoneNum":"18500608333","szRtnMsg":"","nDemo":"50"}';
  394. $params = json_decode($data, true);
  395. refill\RefillFactory::instance()->notify('weishengyjd', $params);
  396. }
  397. public function testYeziPhone()
  398. {
  399. $providers = new refill\yezi\RefillPhone([]);
  400. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  401. // $resp = $providers->query(['order_sn' => '35261620988265145105']);
  402. $data = '{"mchid":"10147","order_sn":"35261620988265145105","amount":"50.00","cardno":"18500608333","trade_no":"6363570674332280422825","idcard":"","card_name":"","official_sn":"","message":"","state":"CANCEL","sign":"b79f2ddbb5b7eef98f414585a5bd2cde"}';
  403. $params = json_decode($data, true);
  404. refill\RefillFactory::instance()->notify('yezi', $params);
  405. }
  406. public function testHaohaoOil()
  407. {
  408. $providers = new refill\haohao\RefillOil([]);
  409. // $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
  410. $data['amount'] = 20000;
  411. $data['mchId'] = 467253;
  412. $data['mchOrderNo'] = '5514850674656058146707';
  413. $data['mobile'] = '';
  414. $data['sign'] = 'F282D68972A437F3CEB3516BB2FDD19A';
  415. $data['operator'] = 4;
  416. $data['number'] = '1000113200020348885';
  417. $data['thirdOrderNo'] = '2317184088901537792';
  418. $data['directStatus'] = 5;
  419. // $input = json_decode($data, true);
  420. refill\RefillFactory::instance()->notify('haohao',$data);
  421. }
  422. public function testJuzhuoOil()
  423. {
  424. $providers = new refill\juzhuo\RefillOil([]);
  425. // $resp = $providers->add(1000111100021211884, 2, 200, ['order_sn' => $this->make_sn()]);
  426. // $resp = $providers->query(['order_sn' => '20121621578185774451']);
  427. // $data = '{"channelsort":"OIL_CARD","channelno":"185176855832","onlystr":"20121621578185774451","channel":"JD","sign":"34dce9329fef7997c134987247ac6ee1","amt":"200","notifyurl":"https:\/\/www.xyzshops.cn\/mobile\/signature.php","cardtype":"Sinoepc","cardno":"1000111100021211884","orgid":"6095171500","account":"","status":"2"}';
  428. // $input = json_decode($data, true);
  429. $data['channelsort'] = 'OIL_CARD';
  430. $data['channelno'] = '';
  431. $data['onlystr'] = '0772770675248490450497';
  432. $data['channel'] = 'JD';
  433. $data['sign'] = '4a9f113bfa4aa2d155de7136ca0afe2d';
  434. $data['amt'] = '100';
  435. $data['notifyurl'] = 'http://121.89.212.167/racc/callback/lingzh/juzhuo.php';
  436. $data['cardtype'] = 'Sinoepc';
  437. $data['cardno'] = '1000113200029532754';
  438. $data['orgid'] = '6095171500';
  439. $data['account'] = '';
  440. $data['status'] = '3';
  441. refill\RefillFactory::instance()->notify('juzhuo',$data);
  442. }
  443. public function testZeheng()
  444. {
  445. $providers = new refill\zeheng\RefillOil([]);
  446. // $resp = $providers->add(1000111100021211884, mtopcard\SinopecCard, 100, ['order_sn' => $this->make_sn()]);
  447. // $resp = $providers->query(['order_sn' => '45951620814813332604']);
  448. $data = '{"extOrderId":"45951620814813332604","orderId":"R2021051218240000192928","salePrice":"96.8000","sign":"0d6b9641eaf8d36ecba82cfefc6aa307","state":"4"}';
  449. $input = json_decode($data, true);
  450. refill\RefillFactory::instance()->notify('zeheng',$input);
  451. }
  452. public function testPrice()
  453. {
  454. $amounts = [10, 20, 30, 50, 100, 200, 300, 500];
  455. $rate = 0.994;
  456. foreach ($amounts as $amount) {
  457. $price[] = $amount * $rate;
  458. }
  459. }
  460. public function testCallbackDir()
  461. {
  462. $path = "/callback";
  463. $file = "/mobile/callback/refill_call.php";
  464. $basename = basename($file);
  465. $tmp = "{$path}/{$basename}.php";
  466. return file_exists($tmp);
  467. }
  468. public function testWeisPhone()
  469. {
  470. $providers = new refill\weisyd\RefillPhone([]);
  471. $resp = $providers->add(17801048874, 4, 10, ['order_sn' => $this->make_sn()]);
  472. }
  473. public function testXcPhone()
  474. {
  475. $providers = new refill\xc\RefillPhone([]);
  476. $resp = $providers->add(13699279618, 5, 100, ['order_sn' => $this->make_sn()]);
  477. // $resp = $providers->query(['order_sn' => '87961616926444043617']);
  478. $params['pay_orderid'] = '87961616926444043617';
  479. $params['pay_iphone'] = '18500608333';
  480. $params['pay_money'] = '100';
  481. $params['wt_orderid'] = '202103281816121070';
  482. $params['status'] = '1';
  483. $params['sign'] = 'f7be2e859a5a6dc7b1a8273361617752';
  484. // refill\RefillFactory::instance()->notify('xc',$params);
  485. }
  486. public function testAfandPhone()
  487. {
  488. $providers = new refill\afand\RefillPhone([]);
  489. // for ($i = 3; $i > 0; --$i) {
  490. $resp = $providers->query(['order_sn' => '540668612768904780']);
  491. // }
  492. }
  493. public function testAfandengPhone()
  494. {
  495. $providers = new refill\afandeng\RefillPhone([]);
  496. // for ($i = 5; $i > 0; --$i) {
  497. $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  498. // }
  499. // $resp = $providers->query(['order_sn' => '20941616115610023539']);
  500. // $params['usr'] = 'afandeng';
  501. // $params['ord'] = '20941616115610023539';
  502. // $params['state'] = '2';
  503. // $params['bz'] = '';
  504. // $params['sgn'] = 'BA2C9D379C3EB648A0B7AAB3A21A3F6A';
  505. // refill\RefillFactory::instance()->notify('afandeng',$params);
  506. }
  507. public function testWantongPhone()
  508. {
  509. $providers = new refill\wantong\RefillPhone([]);
  510. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  511. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  512. $resp = $providers->query(['order_sn' => '26061618988575301841']);
  513. $data = '{"uid":"97396885","order_no":"26061618988575301841","mobile_order_no":"","phone_number":"13699279618","face_value":"3000","status":"9","sign":"1a019202656cf4feffe715025fab01bf"}';
  514. $input = json_decode($data, true);
  515. // refill\RefillFactory::instance()->notify('wantong',$input);
  516. }
  517. public function testXunyinPhone()
  518. {
  519. $providers = new refill\xunyin\RefillPhone([]);
  520. // $resp = $providers->add(17703711950, 6, 30, ['order_sn' => $this->make_sn()]);
  521. $resp = $providers->query(['order_sn' => '76831617176125893158']);
  522. $xml = '<Order><cpid>8417</cpid><orderid>40591617173295524057</orderid><order_no>14784226</order_no><msg>充值中</msg><Code>0000</Code><Cards/></Order>';
  523. $resp = $providers->xmlToArray($xml);
  524. if ($resp['Code'] === '0000') {
  525. return [true, $resp['order_no'], false];
  526. } else {
  527. return [false, $resp['msg'], false];
  528. }
  529. // $params['ext'] = '';
  530. // $params['code'] = '8888';
  531. // $params['sign'] = '428ac223cf3a1f6f3d382aac754e8e17';
  532. // $params['statemes'] = '成功';
  533. // $params['id'] = '76831617176125893158';
  534. // $params['userid'] = '8417';
  535. // $params['operatorid'] = '1000000083421033115583773201';
  536. // $params['status'] = 'SUCCESS';
  537. // refill\RefillFactory::instance()->notify('xunyin',$params);
  538. }
  539. public function testFenshengPhone()
  540. {
  541. $file = BASE_HELPER_RAPI_PATH . "/qianqian/RefillPhone.php";
  542. if(!file_exists($file)){
  543. Log::record("provider api file={$file} not exist.",Log::DEBUG);
  544. return false;
  545. } else {
  546. require_once($file);
  547. Log::record("file={$file} load success.",Log::DEBUG);
  548. }
  549. $providers = new refill\qianqian\RefillPhone([]);
  550. $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  551. // $resp = $providers->query(['order_sn' => '27511617764278021035']);
  552. // $datas = '[{"orderNo":"F2104071058069438461","status":"001","consumerNo":"27511617764278021035","voucherNo":"510490688023364042","mobile":"13699279618"}]';
  553. // $datas = json_decode($datas,true);
  554. // foreach ($datas as $data) {
  555. // refill\RefillFactory::instance()->notify('fensheng',$data);
  556. // }
  557. }
  558. public function testQianqianPhone()
  559. {
  560. $providers = new refill\fensheng\RefillPhone([]);
  561. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  562. $resp = $providers->query(['order_sn' => '27511617764278021035']);
  563. // $datas = '[{"orderNo":"F2104071058069438461","status":"001","consumerNo":"27511617764278021035","voucherNo":"510490688023364042","mobile":"13699279618"}]';
  564. // $datas = json_decode($datas,true);
  565. // foreach ($datas as $data) {
  566. // refill\RefillFactory::instance()->notify('fensheng',$data);
  567. // }
  568. }
  569. public function testQianqianmanPhone()
  570. {
  571. $providers = new refill\qianqianman\RefillPhone([]);
  572. // $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  573. // $resp = $providers->query(['order_sn' => '72011621236975003462']);
  574. $data = '{"orderNo":"F2105171538062539442","status":"019","consumerNo":"72011621236975003462","voucherNo":null,"mobile":"13699279618"}';
  575. $input = json_decode($data, true);
  576. refill\RefillFactory::instance()->notify('qianqianman',$input);
  577. }
  578. public function testRiyingPhone()
  579. {
  580. $providers = new refill\riying\RefillPhone([]);
  581. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  582. $resp = $providers->query(['ch_trade_no' => '2021041311120213187423105022']);
  583. $data = '{"UserId":"10050","SysOrderId":"2021041311120213187423105022","OrderId":"15641618283518423567","State":"4","Timestamp":"1618283565746","VoucherType":"1","VoucherContent":"511009928000087852","Sign":"a6ec70a3ea42baae941528398c6d0a43"}';
  584. $input = json_decode($data, true);
  585. // refill\RefillFactory::instance()->notify('riying',$input);
  586. }
  587. public function testWeishengyPhone()
  588. {
  589. $providers = new refill\weishengy\RefillPhone([]);
  590. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  591. // $resp = $providers->query(['order_sn' => '15551618590601301527']);
  592. $data = '{"masId":"699270071532654592","oids":"158877719094,166090529155,158887187476","orderNo":"62411618635377880788","orderPrice":"150.00","phone":"18500608333","sign":"3EC10A32FC4CCC976048E1164D0FCBF6","status":"1","time":"1618643281063","type":"2"}';
  593. $input = json_decode($data, true);
  594. refill\RefillFactory::instance()->notify('weishengy',$input);
  595. }
  596. public function testWailingPhone()
  597. {
  598. $providers = new refill\wailing\RefillPhone([]);
  599. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  600. $resp = $providers->query(['order_sn' => '73241618543784045618']);
  601. $data = '{"order_id":"73241618543784045618","mchid":"10045","tel":"13699279618","price":"30.00","sign":"4991de3e40f14c198b8c194455ea021b","status":"0","out_order_id":"0"}';
  602. $input = json_decode($data, true);
  603. // refill\RefillFactory::instance()->notify('wailing',$input);
  604. }
  605. public function testShengyingPhone()
  606. {
  607. $providers = new refill\shengying\RefillPhone([]);
  608. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  609. $resp = $providers->query(['order_sn' => '37571618805115582483']);
  610. $data = '{"TaskID":"129636","Mobile":"13699279618","Status":"4","ReportTime":"2021-04-19T12:06:16.050","ReportCode":"1:511531522026586295","OutTradeNo":"37571618805115582483","ReceiptNum":"511531522026586295","Sign":"a7f46a988bc8483091d94130804e5078"}';
  611. $input = json_decode($data, true);
  612. // refill\RefillFactory::instance()->notify('shengying',$input);
  613. }
  614. public function testYunlingPhone()
  615. {
  616. $providers = new refill\yunling\RefillPhone([]);
  617. // $resp = $providers->add(18074608795, 6, 30, ['order_sn' => $this->make_sn()]);
  618. // $resp = $providers->query(['order_sn' => '73791623147517199719']);
  619. $data = '{"orderid":"EAF21060818183032772","sporderid":"73791623147517199719","userid":"10002504","merchantsubmittime":"20210608181912","resultno":"1","parvalue":"30","remark1":"1000000083421060818483137636","payno":"1000000083421060818483137636","fundbalance":"-28.59","sign":"8D77517AC3905ED88BF79EE789A5FA86"}';
  620. $input = json_decode($data, true);
  621. refill\RefillFactory::instance()->notify('yunling',$input);
  622. }
  623. public function testZhongstPhone()
  624. {
  625. $providers = new refill\zhongst\RefillPhone([]);
  626. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  627. // $resp = $providers->query(['order_sn' => '48941618981770389271']);
  628. $data = ' {"szOrderId":"66571619060147539784","fSalePrice":"46.5","szAgentId":"200030","nFlag":"2","szVerifyString":"c1e88701b89a4887996822d708bed5f5","szPhoneNum":"13699279618","szRtnMsg":"161122673971","nDemo":"50"}';
  629. $input = json_decode($data, true);
  630. refill\RefillFactory::instance()->notify('zhongst',$input);
  631. }
  632. public function testXunaoPhone()
  633. {
  634. $providers = new refill\xunao\RefillPhone([]);
  635. // $resp = $providers->add(18074608795, 6, 10, ['order_sn' => $this->make_sn()]);
  636. // $resp = $providers->query(['order_sn' => '40021619431386253803', 'card_no' => 18074608795, 'card_type' => 6]);
  637. $data = '{"amount":"10.00","orderNo":"40021619431386253803","supplierId":"10","orderId":"S20210426180311761051424910","notifyTime":"1619431456411","sign":"c4eef22091831104be7ae95a0292c703","discountAmount":"0.50","phoneNo":"18074608795","queryUrl":"https:\/\/www.189.cn\/client\/wap\/wapproject\/wapclient\/feecharge\/feecharge_result.html?sessionid=f633d8a270aa4e5892d0f7ca6f09e95e","payType":"alipay","ticketNo":"1000000083421042618356072935","company":"dx","status":"2"}';
  638. $input = json_decode($data, true);
  639. refill\RefillFactory::instance()->notify('xunao',$input);
  640. }
  641. public function testYonghePhone()
  642. {
  643. $providers = new refill\yonghe\RefillPhone([]);
  644. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  645. // $resp = $providers->query(['order_sn' => '20461619597297972685']);
  646. $data = '{"szOrderId":"20461619597297972685","fSalePrice":"29.955","szAgentId":"200115","nFlag":"2","szVerifyString":"b5c292a13c5e67a9b850eb37239682ae","szPhoneNum":"13699279618","szRtnMsg":"2021042822001139701437383521","nDemo":"30"}';
  647. $input = json_decode($data, true);
  648. refill\RefillFactory::instance()->notify('yonghe',$input);
  649. }
  650. public function testJumiPhone()
  651. {
  652. $providers = new refill\jumi\RefillPhone([]);
  653. // $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  654. // $resp = $providers->query(['order_sn' => '12161619768293529384']);
  655. $data = '{"order_no":"12161619768293529384","channel_order_no":"C2104300338227862125","status":1,"money":"50.00","cost_money":"48.60","mch_no":210303112631,"account":"13699279618","official_sn":"","sign":"efa99b969f318ef934d8120ccfc77c3e"}';
  656. $input = json_decode($data, true);
  657. refill\RefillFactory::instance()->notify('jumi',$input);
  658. }
  659. public function testJumiOil()
  660. {
  661. $providers = new refill\jumi\RefillOil([]);
  662. // $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
  663. // $resp = $providers->query(['order_sn' => '29021620617872685187']);
  664. $data = '{"order_no":"29021620617872685187","channel_order_no":"C2105101138061082025","status":1,"money":"100.00","cost_money":"98.00","mch_no":210303112631,"account":"1000111100021211884","official_sn":"","sign":"0914807052a04282aeb855f459fcc7b7"}';
  665. $input = json_decode($data, true);
  666. refill\RefillFactory::instance()->notify('jumi',$input);
  667. }
  668. public function testFengyePhone()
  669. {
  670. $providers = new refill\fengye\RefillPhone([]);
  671. // $resp = $providers->add(18074608795, 6, 50, ['order_sn' => $this->make_sn()]);
  672. // $resp = $providers->query(['order_sn' => '53511620355988978053', 'card_no' => 18074608795, 'card_type' => 6]);
  673. $data = '{"amount":"50.00","orderNo":"53511620355988978053","supplierId":"13","orderId":"S20210507105309202749918513","notifyTime":"1620356062365","sign":"371260b007f2e64d86873ce3ede67fa3","discountAmount":"2.50","phoneNo":"18074608795","queryUrl":"https:\/\/www.189.cn\/client\/wap\/wapproject\/wapclient\/feecharge\/feecharge_result.html?sessionid=e896e66c2e134ba3b469b26df34d12d1","payType":"wechat","ticketNo":"1000000083421050710397228882","company":"dx","status":"2"}';
  674. $input = json_decode($data, true);
  675. refill\RefillFactory::instance()->notify('fengye',$input);
  676. }
  677. public function testYunsuoyaoPhone()
  678. {
  679. $providers = new refill\yunsuoyao\RefillPhone([]);
  680. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  681. $resp = $providers->query(['order_sn' => '20431621331092296201']);
  682. $data = '{"orderid":"RLU21051817441937847","sporderid":"20431621331092296201","userid":"10002501","merchantsubmittime":"20210518174858","resultno":"9","parvalue":"30","remark1":"","payno":"","fundbalance":"-28.74","sign":"426EAC103B79505BAE7AB3F16886F1A8"}';
  683. $input = json_decode($data, true);
  684. // refill\RefillFactory::instance()->notify('yunsuoyao',$input);
  685. }
  686. public function testAfdPhone()
  687. {
  688. $providers = new refill\afd\RefillPhone([]);
  689. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  690. // $resp = $providers->query(['order_sn' => '71001621233525947994']);
  691. $data = '{"code":"000","merchantorderId":"71001621233525947994","platformorderid":"aab01693204b95c4df1268313","orderid":"经度110103308082105171438580570638","rechargeno":"18500608333","amount":"50.00","payamount":"47.40000","rechargestate":"99","createtime":"2021-05-17 14:38:29","sign":"62d9af5833e1bf489998a0425107573f"}';
  692. $input = json_decode($data, true);
  693. refill\RefillFactory::instance()->notify('afd',$input);
  694. }
  695. public function testLuqianPhone()
  696. {
  697. $providers = new refill\luqian\RefillPhone([]);
  698. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  699. $resp = $providers->query(['order_sn' => '2829660672500596314764']);
  700. $data = '{"amount":"100","charge_type":"0","code":"1","partner_id":"38","phone":"18500608333","sign":"c2c86cccc73fa991a63c369e683c91f2","partner_order_no":"34101618897099329575","official_order_id":"110103308072104201338340278420"}';
  701. $input = json_decode($data, true);
  702. // refill\RefillFactory::instance()->notify('luqian',$input);
  703. }
  704. public function testAfandfsPhone()
  705. {
  706. $providers = new refill\afandfs\RefillPhone([]);
  707. // $resp = $providers->add(15139608757, 4, 30, ['order_sn' => $this->make_sn()]);
  708. $resp = $providers->query(['order_sn' => '65101618975926761630']);
  709. $data = '{"amount":"30","charge_type":"2","code":"1","partner_id":"52","phone":"15139608757","sign":"a7f54c1ac3e1af72f9fc849086cc4bec","partner_order_no":"65101618975926761630","official_order_id":"20210421113256628350"}';
  710. $input = json_decode($data, true);
  711. // refill\RefillFactory::instance()->notify('afandfs',$input);
  712. }
  713. public function testYunlingfsPhone()
  714. {
  715. $providers = new refill\yunlingfs\RefillPhone([]);
  716. // $resp = $providers->add(15139608757, 4, 50, ['order_sn' => $this->make_sn()]);
  717. $resp = $providers->query(['order_sn' => '79251623739433607563']);
  718. $data = '{"orderid":"BGC21061514434393910","sporderid":"79251623739433607563","userid":"10002543","merchantsubmittime":"20210615144434","resultno":"1","parvalue":"50","remark1":"20210615144420321813","payno":"20210615144420321813","fundbalance":"-47.65","sign":"6B9B7C15A3F9CBC773562327B6744B1E"}';
  719. $input = json_decode($data, true);
  720. // refill\RefillFactory::instance()->notify('yunlingfs',$input);
  721. }
  722. public function testTianchengPhone()
  723. {
  724. $providers = new refill\tiancheng\RefillPhone([]);
  725. $resp = $providers->add(18074608795, 6, 30, ['order_sn' => $this->make_sn()]);
  726. // $resp = $providers->query(['order_sn' => '15301619399212504464']);
  727. $data = ' {"result":"fail","msg":"0","order":"null","phone_no":"13699279618","amount":"10","op_no":"84801619340283980506","settle":"0","sign":"D64039ED791920B08BDA9DD95700C0E6"}';
  728. $input = json_decode($data, true);
  729. // refill\RefillFactory::instance()->notify('tiancheng',$input);
  730. }
  731. public function testLingzhPhone()
  732. {
  733. $providers = new refill\lingzh\RefillPhone([]);
  734. // $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  735. // $resp = $providers->query(['order_sn' => '59911615124025101286']);
  736. $resp = $providers->balance();
  737. // $input['usr'] = 1;
  738. // $input['ord'] = '52741615119546453690';
  739. // $input['bz'] = '';
  740. // $input['state'] = 2;
  741. // $input['sgn'] = 'FFCBB75C307154DD306F4EC75BB69A6D';
  742. // refill\RefillFactory::instance()->notify('lingzh',$input);
  743. }
  744. public function testAfandnewPhone()
  745. {
  746. $providers = new refill\afandnew\RefillPhone([]);
  747. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  748. // $resp = $providers->query(['order_sn' => '45371617101073876975', 'ch_trade_no' => '33018443659736309']);
  749. $params = '{"amount":"100","carrierOrderNo":null,"mobile":"18500608333","orderNo":"45371617101073876975","orderStatus":3,"sign":"8DE392AD6B4730AD9EE0FC2B95BBDF17","tradeNo":"33018443659736309"}';
  750. $input = json_decode($params, true);
  751. refill\RefillFactory::instance()->notify('afandnew', $input);
  752. }
  753. public function testYifaPhone()
  754. {
  755. $providers = new refill\yifa\RefillPhone([]);
  756. $resp = $providers->add(15120035568, 5, 50, ['order_sn' => $this->make_sn()]);
  757. }
  758. public function testTianjtOil()
  759. {
  760. $cardno = 1000111100021211884;
  761. $providers = new refill\tianjt\RefillOil([]);
  762. $resp = $providers->add($cardno, 2, 500, ['order_sn' => $this->make_sn()]);
  763. }
  764. public function testWeitPhone()
  765. {
  766. $providers = new refill\weit\RefillPhone([]);
  767. for ($i = 0; $i <= 10; $i++) {
  768. $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  769. }
  770. }
  771. public function testWeitCB()
  772. {
  773. $params['sign'] = 'af820c33472f4b571fa0c48483dfb975';
  774. $params['status'] = 0;
  775. $params['price'] = 30;
  776. $params['op_order_id'] = '';
  777. $params['mch_order_id'] = '900664281823957221';
  778. $params['pt_order_id'] = '2021011802434412825405218901';
  779. $params['pay_type'] = '';
  780. $params['tel'] = 18500608333;
  781. $params['mchid'] = 10014;
  782. $resp = http_request($this->mReqHost . "/mobile/refill_weit.php", $params, 'POST');
  783. }
  784. public function testYifaCB()
  785. {
  786. $body = '{"app_id":"e4a61b2acf1119c72c1ed9b61781494e","nonce_str":"OQMEBRQWJGPKOWYUXDVPTNMLEQJHXFWG","timestamp":1610275083,"order_sn":"161027325773032634","coder_order_sn":"60641610273255214687","isp_order_sn":null,"phone":"15120035568","amount":"94.000","discount":"0.9400","create_time":"2021-01-10 18:07:42","recharge_time":"","status":"fail","channel_id":3,"sign":"47278AD74EFA7F5FC8DE3A6D362C409B"}';
  787. $input = json_decode($body, true);
  788. refill\RefillFactory::instance()->notify('yifa', $input);
  789. }
  790. public function testBjbQuery()
  791. {
  792. $providers = new refill\bjb\RefillPhone([]);
  793. $refill_info = ['order_sn' => 110667993758599771, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  794. $resp = $providers->query($refill_info);
  795. }
  796. public function testXcQuery()
  797. {
  798. $providers = new refill\xc\RefillPhone([]);
  799. $refill_info = ['order_sn' => 950663423236726632, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  800. $resp = $providers->query($refill_info);
  801. }
  802. public function testTianjtQuery()
  803. {
  804. $providers = new refill\tianjt\RefillOil([]);
  805. $refill_info = ['order_sn' => 680665862267622221, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  806. $resp = $providers->query($refill_info);
  807. }
  808. public function testSaihuOil()
  809. {
  810. $providers = new refill\saihu\RefillOil([]);
  811. $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
  812. }
  813. public function testBdtOil()
  814. {
  815. $providers = new refill\bdt\RefillOil([]);
  816. $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => '200229600556618886']);
  817. }
  818. public function testGFTDOil()
  819. {
  820. $providers = new refill\gftd\RefillOil([]);
  821. $resp = $providers->add(1000111100020445281, mtopcard\SinopecCard, 100, ['order_sn' => $this->make_sn()]);
  822. }
  823. public function testYichangtOil()
  824. {
  825. $providers = new refill\yichangt\RefillOil([]);
  826. $resp = $providers->add(1000111100021211884, mtopcard\SinopecCard, 200, ['order_sn' => $this->make_sn()]);
  827. // $resp = $providers->query(['order_sn' => '87591620379260314044']);
  828. $data = '{"appid":"app570259129507","order_id":"M202105077888184428723706","merchant_order_id":"82231620378877155624","status":"3","cash":"100","time":"1620378961450","nonce":"2fad56d59a9f46d896c15b0cff74bc","signature":"57a6d24ec376b58bb433cfcf8528d53cb276eac8"}';
  829. $input = json_decode($data, true);
  830. // refill\RefillFactory::instance()->notify('yichangt',$input);
  831. }
  832. public function testGFTDCB()
  833. {
  834. $data = '{"channelOrderNumber":"79091610959059372019","orderNumber":"GYFL1610959060397001","message":"充值成功","storage":"881036222bd8f067ff47d248c75f4c8d","voucher":"","status":101}';
  835. $url = "http://192.168.1.220/mobile/refill_gftd.php?" . $data;
  836. $resp = http_post_data($url, $data, ['Content-Type: application/json;charset=UTF-8;', 'Accept:application/json;charset=UTF-8;']);
  837. }
  838. public function testJiecPhone()
  839. {
  840. $providers = new refill\jiec\RefillPhone([]);
  841. $resp = $providers->add('18500608333', 5, 30, ['order_sn' => $this->make_sn()]);
  842. }
  843. public function testBxtwtCB()
  844. {
  845. $data = '{"order_number":18219726,"shipping_status":4,"shipping_status_desc":"发货失败","shipping_status_message":"","sign":"863b4d972f2a4d39a9af7396879116c4","voucher":"","vouchertype":"","voucherurl":"","tradeNo":"100662475851197741"}';
  846. }
  847. public function testTianjtJDVerify()
  848. {
  849. $data = 'onlystr=920661883198026632&sign=533151e3f0dff5f507786aabc37b18f7&amt=100&notifyurl=https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_tianjt.php&jdno&cardtype=Sinoepc&batchid=26106&cardno=1000111100020654226&orgid=1590993600&status=3';
  850. $url = "http://192.168.1.220/mobile/refill_tianjt.php?" . $data;
  851. $resp = http_request($url);
  852. }
  853. public function testSuhcPDD()
  854. {
  855. $data = 'onlystr=820663525320005221&pddno&sign=4b1e8645f7541ced34855779448d9d52&amt=100&notifyurl=https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_suhcpdd.php&cardtype=Sinoepc&batchid=3&cardno=1000111100020445281&orgid=1590993600&status=2';
  856. $url = "https://www.xyzshops.cn/mobile/refill_suhcpdd.php?" . $data;
  857. $resp = http_request($url);
  858. }
  859. public function testSuhcTMVerify()
  860. {
  861. $data = 'onlystr=180662473867058221&sign=5ff5f95d54a89e78dbb49923f6b20c08&amt=100&notifyurl=https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_suhctm.php&cardtype=Sinoepc&batchid=3&cardno=1000111100020445281&orgid=1590993600&status=3';
  862. $url = "https://www.xyzshops.cn/mobile/refill_suhctm.php?" . $data;
  863. $resp = http_request($url);
  864. }
  865. public function testBeixtVerify()
  866. {
  867. $data = '{"order_number":18219726,"shipping_status":4,"shipping_status_desc":"发货失败","shipping_status_message":"","sign":"863b4d972f2a4d39a9af7396879116c4","voucher":"","vouchertype":"","voucherurl":"","tradeNo":"100662475851197741"}';
  868. $url = "https://www.xyzshops.cn/mobile/refill_bxtwt.php";
  869. $headers = ['Content-Type: application/json'];
  870. $resp = http_post_data($url, $data, $headers);
  871. }
  872. public function testInput()
  873. {
  874. $input = fopen("php://input", "rw");
  875. file_put_contents($input, 'xxxx');
  876. $content = file_get_contents('php://input');
  877. }
  878. public function testUrl()
  879. {
  880. $data = 'onlystr=190661874318128632&sign=9eb60765c356341fd41c9bec6526f46a&amt=1000&notifyurl=https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_suhc.php&jdno&cardtype=Sinoepc&batchid=25940&cardno=1000111100012304048&orgid=1590993600&status=2';
  881. $params = preg_split('/&/', $data);
  882. foreach ($params as $pair) {
  883. $kv = explode('=', $pair);
  884. $count = count($kv);
  885. if ($count === 1) {
  886. $key = $kv[0];
  887. $val = "";
  888. } elseif ($count === 2) {
  889. $key = $kv[0];
  890. $val = $kv[1];
  891. } else {
  892. continue;
  893. }
  894. Log::record("{$key}:{$val}", Log::DEBUG);
  895. }
  896. }
  897. public function testAddoil()
  898. {
  899. $url = $this->mReqHost . "/mobile/index.php";
  900. $notifyurl = 'http://121.89.196.45/mobile/signature.php';
  901. $params = ['mchid' => $this->mMchid,
  902. 'cardno' => '1000111100020445281',
  903. 'amount' => "100",
  904. "act" => "refill",
  905. "op" => "add",
  906. 'order_sn' => $this->make_sn(),
  907. 'notifyurl' => $notifyurl];
  908. $resp = $this->send_md5($url, $params);
  909. Log::record($resp, Log::DEBUG);
  910. }
  911. public function testBalance()
  912. {
  913. $url = $this->mReqHost . "/mobile/index.php";
  914. $params = ['mchid' => 1092,
  915. "act" => "refill",
  916. "op" => "balance"];
  917. $resp = $this->send_md5($url, $params);
  918. Log::record($resp, Log::DEBUG);
  919. }
  920. public function testAddPhoe()
  921. {
  922. $phones = [//13911129867,
  923. 18500608333,
  924. 18510683168,
  925. 18513846008,
  926. 18518237398];
  927. $amount = 10;
  928. for ($i = 0; $i < 3; $i++) {
  929. foreach ($phones as $phone) {
  930. $url = $this->mReqHost . "/mobile/index.php";
  931. $params = ['mchid' => 1092,
  932. 'cardno' => $phone,
  933. 'amount' => $amount,
  934. "act" => "refill",
  935. "op" => "add",
  936. 'order_sn' => $this->make_sn(),
  937. 'notifyurl' => $this->mReqHost . "/mobile/refill_xyz.php"];
  938. $resp = $this->send_md5($url, $params);
  939. Log::record($resp, Log::DEBUG);
  940. }
  941. }
  942. }
  943. public function testProxyHelper()
  944. {
  945. $phone = '13911129867';
  946. $amount = 100;
  947. $url = $this->mReqHost . "/mobile/index.php";
  948. $params = ['mchid' => 1090,
  949. 'cardno' => $phone,
  950. 'amount' => $amount,
  951. "act" => "refill",
  952. "op" => "add",
  953. 'order_sn' => $this->make_sn(),
  954. 'notifyurl' => "https://xxx"];
  955. $proxy = new refill_proxy("xxx");
  956. $resp = $proxy->send($url, $params);
  957. }
  958. public function testGoods()
  959. {
  960. $req_url = $this->mReqHost . '/mobile/index.php';
  961. $params = ['mchid' => $this->mMchid,
  962. "act" => "refill",
  963. "op" => "goods"];
  964. $resp = $this->send_md5($req_url, $params);
  965. }
  966. public function testQueryFactory()
  967. {
  968. refill\RefillFactory::instance()->query(295);
  969. }
  970. public function testQuery()
  971. {
  972. //$req_url = 'https://www.xyzshops.cn/mobile/index.php';
  973. // $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
  974. $req_url = BASE_SITE_URL . '/mobile/index.php';
  975. $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
  976. $params = ['mchid' => 1,
  977. "act" => "refill",
  978. "op" => "query",
  979. 'order_sn' => "13281476"];
  980. $resp = $this->send_md5($req_url, $params);
  981. }
  982. public function testRemoveSession()
  983. {
  984. $resp = http_request(BASE_SITE_URL . "/mobile/signature.php", [], 'POST');
  985. }
  986. public function testTianjtCB()
  987. {
  988. // $notifyurl = BASE_SITE_URL . "/mobile/refill_tianjt.php";
  989. $notifyurl = "https://www.xyzshops.cn/mobile/refill_tianjt.php";
  990. // $notifyurl = "https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_tianjt.php";
  991. $params = ['onlystr' => '690665858589475818',
  992. 'amt' => 1000,
  993. 'jdno' => '',
  994. 'notifyurl' => $notifyurl,
  995. 'cardtype' => 'Sinoepc',
  996. 'batchid' => 30589,
  997. 'cardno' => '1000113300007993287',
  998. 'orgid' => '1590993600',
  999. 'status' => 3];
  1000. $sign = $this->md5_sign($params);
  1001. $params['sign'] = $sign;
  1002. $resp = http_request($notifyurl, $params, 'POST');
  1003. Log::record($resp, Log::DEBUG);
  1004. }
  1005. public function testBJBCB()
  1006. {
  1007. $params = [
  1008. 'usr' => '13699279618',
  1009. 'ord' => '710662733975412771',
  1010. 'state' => '2',
  1011. 'bz' => '',
  1012. 'sgn' => 'AC9AFD254DE682D8440A97CA68B992DA'
  1013. ];
  1014. $resp = http_request("https://www.xyzshops.cn/mobile/refill_bjb.php", $params, 'POST');
  1015. }
  1016. public function testJiecCB()
  1017. {
  1018. $params['result'] = 'fail';
  1019. $params['msg'] = '0';
  1020. $params['order'] = 'null';
  1021. $params['phone_no'] = '18500608333';
  1022. $params['amount'] = '30.00';
  1023. $params['op_no'] = '800663597981819221';
  1024. $params['sign'] = '2510046895e8e12322c8a32547905ee9';
  1025. $resp = http_request($this->mReqHost . "/mobile/refill_jiec.php", $params, 'POST');
  1026. }
  1027. public function testZFKJ()
  1028. {
  1029. //带签名参数:mchid=1090&act=refill&op=add&cardno=100112121212212133
  1030. //&amount=10&order_sn=PH2012261356569433&
  1031. //notifyurl=https%3A%2F%2Fqzcz.edusahoo.com.cn%2Findex%2Findex%2Fcallback
  1032. //&sign=4a3ac5f9706e64aa70c6cab0fc5839d3
  1033. $params = ['mchid' => 1090,
  1034. 'cardno' => '100112121212212133',
  1035. 'amount' => '10',
  1036. "act" => "refill",
  1037. "op" => "add",
  1038. 'order_sn' => 'PH2012261356569433',
  1039. 'notifyurl' => 'https://qzcz.edusahoo.com.cn/index/index/callback'];
  1040. $resp = $this->send_md5(BASE_SITE_URL . '/mobile/index.php', $params);
  1041. }
  1042. protected function check_empty($value)
  1043. {
  1044. if (!isset($value))
  1045. return true;
  1046. if ($value === null)
  1047. return true;
  1048. if (trim($value) === "")
  1049. return true;
  1050. return false;
  1051. }
  1052. public function testcreateSign()
  1053. {
  1054. $params['act'] = 'refill';
  1055. $params['amount'] = '50';
  1056. $params['cardno'] = '18276257399';
  1057. $params['mchid'] = '10162';
  1058. $params['notifyurl'] = 'http://www.baidu.com';
  1059. $params['op'] = 'add';
  1060. $params['order_sn'] = 'a814ebeb4ee883d01d98';
  1061. $params['quality'] = 2;
  1062. $sign = $this->md5_sign($params);
  1063. }
  1064. public function testCheckphone()
  1065. {
  1066. $check = function ($phone) {
  1067. $url = 'https://mobileempty.shumaidata.com/mobileempty';
  1068. $params['mobile'] = $phone;
  1069. $headers = array();
  1070. array_push($headers, "Authorization:APPCODE " . '8f92d951293f4d2ea48ff86d5a70c537');
  1071. $resp = http_request($url, $params, 'GET', false, $headers);
  1072. $resp = json_decode($resp, true);
  1073. if ($resp['success'] == true && $resp['code'] == 200) {
  1074. Log::record("data phone:{$phone} , status : {$resp['data']['status']}", Log::DEBUG);
  1075. if (in_array($resp['data']['status'], [0, 3, 4, 5])) {
  1076. return false;
  1077. }
  1078. } else {
  1079. Log::record("data phone:{$phone} , 不支持的号段", Log::DEBUG);
  1080. }
  1081. };
  1082. $check(17801048874);
  1083. }
  1084. public function testCtSign()
  1085. {
  1086. $params['act'] = 'refill';
  1087. $params['amount'] = 1;
  1088. $params['cardno'] = 18888888888;
  1089. $params['mchid'] = 1101;
  1090. $params['op'] = 'add';
  1091. $params['notifyurl'] = '';
  1092. $params['order_sn'] = '1231212';
  1093. $sign = $this->md5_sign($params);
  1094. }
  1095. private function md5_sign($params)
  1096. {
  1097. ksort($params);
  1098. $body = "";
  1099. $i = 0;
  1100. foreach ($params as $k => $v) {
  1101. if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
  1102. if ($i == 0) {
  1103. $body .= "{$k}" . "=" . urlencode($v);
  1104. } else {
  1105. $body .= "&" . "{$k}" . "=" . urlencode($v);
  1106. }
  1107. $i++;
  1108. }
  1109. }
  1110. $body .= "&key=CEFA8CCC89FE4916BA215306AABE2206";
  1111. return md5($body);
  1112. }
  1113. public function testCallMech()
  1114. {
  1115. $logic = Logic('queue');
  1116. $logic->NotifyMerchantComplete(['order_id' => 18171, 'manual' => true]);
  1117. }
  1118. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCallMech)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
  1119. private function send($url, $params)
  1120. {
  1121. $mchid = $params['mchid'];
  1122. $pri_key = BASE_DATA_PATH . "/api/merchant/key/{$mchid}_pri.pem";
  1123. $key = file_get_contents($pri_key);
  1124. $pri = openssl_get_privatekey($key);
  1125. $body = $this->body($params);
  1126. openssl_sign($body, $signed, $pri);
  1127. $sign = base64_encode($signed);
  1128. $params['sign'] = $sign;
  1129. $resp = http_request($url, $params, 'POST');
  1130. Log::record("resp:{$resp}", Log::DEBUG);
  1131. }
  1132. private function send_md5($url, $params)
  1133. {
  1134. $body = $this->body($params);
  1135. $body .= "&key={$this->mKey}";
  1136. $params['sign'] = md5($body);
  1137. $resp = http_request($url, $params, 'POST');
  1138. Log::record("resp:{$resp}", Log::DEBUG);
  1139. return $resp;
  1140. }
  1141. public function testCardType()
  1142. {
  1143. $cardno = '1000111100021211884';
  1144. $ret = preg_match('/^1[0-9]{18}$/', $cardno, $matches);
  1145. }
  1146. public function testMtrand()
  1147. {
  1148. }
  1149. public function testHttpRefill()
  1150. {
  1151. $mchid = '000001';
  1152. $pri_key = BASE_DATA_PATH . "/api/merchant/key/{$mchid}_pri.pem";
  1153. $key = file_get_contents($pri_key);
  1154. $pri = openssl_get_privatekey($key);
  1155. $params = ['MCHID' => $mchid, 'cardno' => '1000111100021211884', 'amt' => "100", "act" => "refill", "op" => "addoil"];
  1156. $body = $this->body($params);
  1157. openssl_sign($body, $signed, $pri);
  1158. $sign = base64_encode($signed);
  1159. $params['sign'] = $sign;
  1160. $resp = http_request(BASE_SITE_URL . "/mobile/index.php", $params, 'POST');
  1161. }
  1162. private function body($params)
  1163. {
  1164. ksort($params);
  1165. $body = "";
  1166. $i = 0;
  1167. foreach ($params as $k => $v) {
  1168. if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
  1169. if ($i == 0) {
  1170. $body .= "{$k}" . "=" . urlencode($v);
  1171. } else {
  1172. $body .= "&" . "{$k}" . "=" . urlencode($v);
  1173. }
  1174. $i++;
  1175. }
  1176. }
  1177. return $body;
  1178. }
  1179. private function checkEmpty($value)
  1180. {
  1181. if (!isset($value))
  1182. return true;
  1183. if ($value === null)
  1184. return true;
  1185. if (trim($value) === "")
  1186. return true;
  1187. return false;
  1188. }
  1189. public function testKsort()
  1190. {
  1191. $age = ["Peter" => "35", "Ben" => "37", "Joe" => "43"];
  1192. ksort($age);
  1193. foreach ($age as $x => $x_value) {
  1194. echo "Key=" . $x . ", Value=" . $x_value;
  1195. echo "<br>";
  1196. }
  1197. }
  1198. public function testip()
  1199. {
  1200. $model_merchant = Model('merchant');
  1201. $merchant_info = $model_merchant->getMerchantInfo(['mchid' => 1]);
  1202. $ipwhitelist = unserialize($merchant_info['ip_white_list']);
  1203. $res = json_encode($ipwhitelist);
  1204. }
  1205. //测试向内部店提交订单,可先屏蔽其它充值通道
  1206. public function testAddoilToInnerStore()
  1207. {
  1208. $url = $this->mReqHost . "/mobile/index.php";
  1209. $notifyurl = BASE_SITE_URL . '/mobile/signature.php';
  1210. $params = ['mchid' => 1,
  1211. 'cardno' => '1000111100020445281',
  1212. 'amount' => "1000",
  1213. "act" => "refill",
  1214. "op" => "add",
  1215. 'order_sn' => $this->make_sn(),
  1216. 'notifyurl' => $notifyurl];
  1217. $resp = $this->send_md5($url, $params);
  1218. Log::record($resp, Log::DEBUG);
  1219. }
  1220. public function testRefillInnerCB()
  1221. {
  1222. $params = ['state_type' => 'order_cancel', 'order_id' => 311, 'channel_name' => 'lx'];
  1223. $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php', $params, 'POST');
  1224. }
  1225. public function testArgs()
  1226. {
  1227. Log::record($_SERVER['argv'], Log::DEBUG);
  1228. }
  1229. public function testCall()
  1230. {
  1231. $order_id = 14974;
  1232. QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true], 10);
  1233. }
  1234. public function testSyncconfig()
  1235. {
  1236. $name_val_cfg = function ($items) {
  1237. $result = [];
  1238. foreach ($items as $item) {
  1239. $name = $item->name();
  1240. $result[$name] = $item;
  1241. }
  1242. return $result;
  1243. };
  1244. $name_val_row = function ($items) {
  1245. $result = [];
  1246. foreach ($items as $item) {
  1247. $name = $item['name'];
  1248. $result[$name] = $item;
  1249. }
  1250. return $result;
  1251. };
  1252. $match = function ($all, $cur) {
  1253. $insert = [];
  1254. foreach ($all as $key => $value) {
  1255. if (!array_key_exists($key, $cur)) {
  1256. $insert[] = $key;
  1257. }
  1258. }
  1259. return $insert;
  1260. };
  1261. $inserter = function ($mod, $type, $names) {
  1262. foreach ($names as $name) {
  1263. $data = ['name' => $name, 'type' => $type];
  1264. $mod->insert($data);
  1265. }
  1266. };
  1267. $providers = refill\RefillFactory::instance()->providers();
  1268. $oils = $name_val_cfg($providers['oil']);
  1269. $phones = $name_val_cfg($providers['phone']);
  1270. $mod_prov = Model('refill_provider');
  1271. $oil_items = $mod_prov->getProviderList(['type' => 1]);
  1272. $oil_items = $name_val_row($oil_items);
  1273. $oil_inserts = $match($oils, $oil_items);
  1274. $phone_items = $mod_prov->getProviderList(['type' => 2]);
  1275. $phone_items = $name_val_row($phone_items);
  1276. $phone_inserts = $match($phones, $phone_items);
  1277. $inserter($mod_prov, 1, $oil_inserts);
  1278. $inserter($mod_prov, 2, $phone_inserts);
  1279. }
  1280. public function testStat()
  1281. {
  1282. $model_refill_order = Model('refill_order');
  1283. $stat = Model('')->table('refill_order,vr_order')->join('inner')
  1284. ->on('refill_order.order_id=vr_order.order_id')
  1285. ->field('sum(refill_amount) as refill_amounts , sum(channel_amount) as channel_amounts , sum(mch_amount) as mch_amounts')
  1286. ->where([])->select();
  1287. }
  1288. public function testRefillGoods()
  1289. {
  1290. $goods = refill\RefillFactory::instance()->goods();
  1291. }
  1292. private function make_mobile()
  1293. {
  1294. $no = "1" . mt_rand(3000000000, 3999999999);
  1295. return $no;
  1296. }
  1297. private function refill_info($card_no, $card_type)
  1298. {
  1299. $data = rcache($card_no, 'cardrefill-');
  1300. if (empty($data)) {
  1301. $mod_topcard = Model('topcard');
  1302. $ret = $mod_topcard->get_card($card_no);
  1303. if (empty($ret)) {
  1304. $bind_phone = $this->make_mobile();
  1305. $mod_topcard->add($card_no, $card_type, time(), $bind_phone);
  1306. $data['bind_phone'] = $bind_phone;
  1307. $data['refill_time'] = time();
  1308. $data['times'] = 0;
  1309. wcache($card_no, $data, 'cardrefill-');
  1310. } else {
  1311. $val = $ret[0];
  1312. $data['bind_phone'] = $val['bind_phone'];
  1313. $data['refill_time'] = time();
  1314. $data['times'] = 0;
  1315. }
  1316. }
  1317. return $data;
  1318. }
  1319. public function testGetMobile()
  1320. {
  1321. $card_no = '1000119000001679247';
  1322. $card_type = 1;
  1323. $info = $this->refill_info($card_no, $card_type);
  1324. }
  1325. private function check_mchorder($mchid, $mch_order)
  1326. {
  1327. if (empty($mch_order)) {
  1328. return true;
  1329. } else {
  1330. $refill_order = Model('refill_order');
  1331. $ret = $refill_order->getOrderInfo(['mchid' => $mchid, 'mch_order' => $mch_order]);
  1332. return empty($ret);
  1333. }
  1334. }
  1335. public function testCheckMchorder()
  1336. {
  1337. $ret = $this->check_mchorder(1, '13281475');
  1338. }
  1339. public function testMakemobile()
  1340. {
  1341. $mobile = refill\util::make_mobile();
  1342. $ret = refill\util::set_black('1000111100020445281');
  1343. }
  1344. public function testLoadBlack()
  1345. {
  1346. $path = BASE_DATA_PATH . "/log";
  1347. $names = ['20210119-mobile.log',
  1348. '20210120-mobile.log', '20210121-mobile.log', '20210122-mobile.log', '20210123-mobile.log',
  1349. '20210124-mobile.log', '20210125-mobile.log'];
  1350. foreach ($names as $name) {
  1351. $file_name = $path . "/" . $name;
  1352. refill\util::black_from_log($file_name);
  1353. }
  1354. }
  1355. public function testStats()
  1356. {
  1357. $date = date('Y-m-d', time());
  1358. $today = strtotime("{$date}");
  1359. $times_begin = function ($start) {
  1360. $times = [];
  1361. $begin = $start;
  1362. for ($i = 0; $i < 7; $i++) {
  1363. $times[] = $begin;
  1364. $begin -= 86400;
  1365. }
  1366. return $times;
  1367. };
  1368. $reader = function ($mchid, $time) {
  1369. $cond['mchid'] = $mchid;
  1370. $cond['inner_status'] = 0;
  1371. $cond['refill_order.order_time'] = ['between', [$time, $time + 86400 - 1]];
  1372. $items = Model('')->table('refill_order,vr_order')->join('inner')
  1373. ->on('refill_order.order_id=vr_order.order_id')
  1374. ->field('count(*) as order_count, vr_order.order_state, sum(mch_amount) as mch_amounts')
  1375. ->group('vr_order.order_state')
  1376. ->where($cond)->select();
  1377. return $items;
  1378. };
  1379. $begins = $times_begin($today);
  1380. $mchid = 10096;
  1381. // $states = rcache($this->mchid() , 'refillstat-');
  1382. $states = unserialize($states ?? "");
  1383. if (empty($states)) $states = [];
  1384. $result = [];
  1385. $cache = [];
  1386. foreach ($begins as $begin) {
  1387. if (array_key_exists($begin, $states)) {
  1388. $item = $states[$begin];
  1389. } else {
  1390. $item = $reader($mchid, $begin);
  1391. }
  1392. $result[$begin] = $item;
  1393. //判断item 中充值中的状态是否为0,为0的情况下放进cache
  1394. $cache = $item;
  1395. }
  1396. wcache($this->mchid(), $cache, 'refillstat-');
  1397. return $result;
  1398. }
  1399. public function testNotifyx()
  1400. {
  1401. $mch_cache = rcache("merchant-notify", 'refill-');
  1402. $caches = empty($mch_cache['data']) ? [] : unserialize($mch_cache['data']);
  1403. $new_caches = [];
  1404. $merchants = Model('merchant')->getMerchantList([], '', '', 'merchant.*,member.available_predeposit', "0,1000");
  1405. foreach ($merchants as $merchant) {
  1406. $mchid = $merchant['mchid'];
  1407. $phone = $merchant['contact_phone'] ?? "";
  1408. $available_pd = intval($merchant['available_predeposit']);
  1409. $alarm_pd = intval($merchant['alarm_amount']) < 10000 ? 10000 : intval($merchant['alarm_amount']);
  1410. if (array_key_exists($mchid, $caches)) {
  1411. $mch_cache = $caches[$mchid];
  1412. } else {
  1413. $mch_cache = ['last_time' => 0, 'send_count' => 0];
  1414. }
  1415. if (!empty($phone) && ($available_pd < $alarm_pd)) {
  1416. $counts = $mch_cache['send_count'];
  1417. if (($mch_cache['last_time'] + 300 < time()) && $counts < 5) {
  1418. $mch_cache = ['last_time' => time(), 'send_count' => $counts + 1];
  1419. QueueClient::push('sendSMS', ['mobile' => $merchant['contact_phone'],
  1420. 'type' => 'balance_warning', 'datas' => [date("m月d日H时"), $merchant['available_predeposit']]]);
  1421. }
  1422. } else {
  1423. $mch_cache = ['last_time' => 0, 'send_count' => 0];
  1424. }
  1425. $new_caches[$mchid] = $mch_cache;
  1426. }
  1427. wcache("merchant-notify", ['data' => serialize($new_caches)], 'refill-');
  1428. }
  1429. public function testReadChannel()
  1430. {
  1431. refill\RefillFactory::instance()->read_channel();
  1432. }
  1433. public function testAllow()
  1434. {
  1435. $allow = refill\RefillFactory::instance()->allow(10096, 1, 100);
  1436. }
  1437. public function testCheckData()
  1438. {
  1439. $str = '|2|110667993758599771-充值失败|';
  1440. // $str = '0|提交成功|-36557.7400';
  1441. // if(preg_match( '/^-*[0-9]{1,3}\|[\x{4e00}-\x{9fa5}]+\|-*[0-9]+\.*[0-9]+$/u',$str,$matches)) {
  1442. // return true;
  1443. // }
  1444. // if(preg_match('/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]*$/u',$str,$matches)){
  1445. // return true;
  1446. // }
  1447. // return false;
  1448. $resp = ltrim($str, '|');
  1449. $resp = explode('|', $resp);
  1450. if (count($resp) != 3) {
  1451. return [false, '返回值错误'];
  1452. }
  1453. }
  1454. public function testErrre()
  1455. {
  1456. $line = '[13 2021-01-24 16:07:03] DEBUG: type = application/json;charset=utf-8, content={"channelOrderNumber":"610664819621371793","orderNumber":"GYFL1611475621525437","message":"充值失败","signature":"6c28c15b9ce2b2243742ecebbd929ac5","status":109}';
  1457. $ret = preg_match('/[\w\W]+"channelOrderNumber":"(?P<order_sn>[^"]+)"[\w\W]+"message":"(?P<message>[\x{4e00}-\x{9fa5}]+)"[\w\W]+"status":109/u', $line, $matches);
  1458. }
  1459. public function testMchctl()
  1460. {
  1461. $ctl = new refill\mchctl();
  1462. }
  1463. public function testAsyncadd()
  1464. {
  1465. $x = \refill\util::async_add(['xxxx' => 1],4);
  1466. }
  1467. }
  1468. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
  1469. //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test