TestRefill.php 67 KB

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