TestRefill.php 65 KB

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