TestRefill.php 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453
  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(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  262. // $resp = $providers->query(['order_sn' => '59031616396534854303']);
  263. // $body = '{"userid":"8177b4b1d0254c0699bc","ordernum":"59031616396534854303","mobile":"18500608333","timestamp":"20210322150437","state":"3","desc":"%E5%A4%B1%E8%B4%A5%3A%E5%A4%B1%E8%B4%A5","sign":"1d412f956c041bf4454357b209c93df6"}';
  264. // $params = json_decode($body , true);
  265. // refill\RefillFactory::instance()->notify('weiyi',$params);
  266. }
  267. public function testTongluPhone()
  268. {
  269. $providers = new refill\tonglu\RefillPhone([]);
  270. // $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  271. $resp = $providers->query(['order_sn' => '22961616468561936356']);
  272. // $body = '{"order_no":"22961616468561936356","order_status":"5","phone_no":"18500608333","amount":5000,"time_paid":1616468856287,"order_cert_no":"","paid":false,"order_id":"20210323966497008"}';
  273. // $sign = '9E41F52F612D60EBB654B3A5D1E2F1E5';
  274. // $params = json_decode($body , true);
  275. // $params['sign'] = $sign;
  276. // refill\RefillFactory::instance()->notify('tonglu',$params);
  277. }
  278. public function testAmingjd()
  279. {
  280. // $providers = new refill\amingjd\RefillPhone([]);
  281. // $resp = $providers->add(13699279618, 5, 30, ['order_sn' => $this->make_sn()]);
  282. // $resp = $providers->query(['order_sn' => '42301616475989518588']);
  283. $body = '{"order_id":"83321616478215494884","mchid":"10003","tel":"13699279618","price":"30.00","sign":"01c49620c155a80bc43cecc2b1651868","status":"0","out_order_id":"0"}';
  284. $params = json_decode($body, true);
  285. refill\RefillFactory::instance()->notify('amingjd', $params);
  286. }
  287. public function testPrice()
  288. {
  289. $amounts = [10, 20, 30, 50, 100, 200, 300, 500];
  290. $rate = 0.94;
  291. foreach ($amounts as $amount) {
  292. $price[] = $amount * $rate;
  293. }
  294. }
  295. public function testWeisPhone()
  296. {
  297. $providers = new refill\weisyd\RefillPhone([]);
  298. $resp = $providers->add(17801048874, 4, 10, ['order_sn' => $this->make_sn()]);
  299. }
  300. public function testXcPhone()
  301. {
  302. $providers = new refill\xc\RefillPhone([]);
  303. $resp = $providers->add(13699279618, 5, 100, ['order_sn' => $this->make_sn()]);
  304. // $resp = $providers->query(['order_sn' => '87961616926444043617']);
  305. $params['pay_orderid'] = '87961616926444043617';
  306. $params['pay_iphone'] = '18500608333';
  307. $params['pay_money'] = '100';
  308. $params['wt_orderid'] = '202103281816121070';
  309. $params['status'] = '1';
  310. $params['sign'] = 'f7be2e859a5a6dc7b1a8273361617752';
  311. // refill\RefillFactory::instance()->notify('xc',$params);
  312. }
  313. public function testAfandPhone()
  314. {
  315. $providers = new refill\afand\RefillPhone([]);
  316. // for ($i = 3; $i > 0; --$i) {
  317. $resp = $providers->query(['order_sn' => '540668612768904780']);
  318. // }
  319. }
  320. public function testAfandengPhone()
  321. {
  322. $providers = new refill\afandeng\RefillPhone([]);
  323. // for ($i = 5; $i > 0; --$i) {
  324. $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  325. // }
  326. // $resp = $providers->query(['order_sn' => '20941616115610023539']);
  327. // $params['usr'] = 'afandeng';
  328. // $params['ord'] = '20941616115610023539';
  329. // $params['state'] = '2';
  330. // $params['bz'] = '';
  331. // $params['sgn'] = 'BA2C9D379C3EB648A0B7AAB3A21A3F6A';
  332. // refill\RefillFactory::instance()->notify('afandeng',$params);
  333. }
  334. public function testWantongPhone()
  335. {
  336. $providers = new refill\wantong\RefillPhone([]);
  337. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  338. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  339. $resp = $providers->query(['order_sn' => '26061618988575301841']);
  340. $data = '{"uid":"97396885","order_no":"26061618988575301841","mobile_order_no":"","phone_number":"13699279618","face_value":"3000","status":"9","sign":"1a019202656cf4feffe715025fab01bf"}';
  341. $input = json_decode($data, true);
  342. // refill\RefillFactory::instance()->notify('wantong',$input);
  343. }
  344. public function testXunyinPhone()
  345. {
  346. $providers = new refill\xunyin\RefillPhone([]);
  347. // $resp = $providers->add(17703711950, 6, 30, ['order_sn' => $this->make_sn()]);
  348. $resp = $providers->query(['order_sn' => '76831617176125893158']);
  349. $xml = '<Order><cpid>8417</cpid><orderid>40591617173295524057</orderid><order_no>14784226</order_no><msg>充值中</msg><Code>0000</Code><Cards/></Order>';
  350. $resp = $providers->xmlToArray($xml);
  351. if ($resp['Code'] === '0000') {
  352. return [true, $resp['order_no'], false];
  353. } else {
  354. return [false, $resp['msg'], false];
  355. }
  356. // $params['ext'] = '';
  357. // $params['code'] = '8888';
  358. // $params['sign'] = '428ac223cf3a1f6f3d382aac754e8e17';
  359. // $params['statemes'] = '成功';
  360. // $params['id'] = '76831617176125893158';
  361. // $params['userid'] = '8417';
  362. // $params['operatorid'] = '1000000083421033115583773201';
  363. // $params['status'] = 'SUCCESS';
  364. // refill\RefillFactory::instance()->notify('xunyin',$params);
  365. }
  366. public function testFenshengPhone()
  367. {
  368. $providers = new refill\fensheng\RefillPhone([]);
  369. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  370. $resp = $providers->query(['order_sn' => '27511617764278021035']);
  371. // $datas = '[{"orderNo":"F2104071058069438461","status":"001","consumerNo":"27511617764278021035","voucherNo":"510490688023364042","mobile":"13699279618"}]';
  372. // $datas = json_decode($datas,true);
  373. // foreach ($datas as $data) {
  374. // refill\RefillFactory::instance()->notify('fensheng',$data);
  375. // }
  376. }
  377. public function testRiyingPhone()
  378. {
  379. $providers = new refill\riying\RefillPhone([]);
  380. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  381. $resp = $providers->query(['ch_trade_no' => '2021041311120213187423105022']);
  382. $data = '{"UserId":"10050","SysOrderId":"2021041311120213187423105022","OrderId":"15641618283518423567","State":"4","Timestamp":"1618283565746","VoucherType":"1","VoucherContent":"511009928000087852","Sign":"a6ec70a3ea42baae941528398c6d0a43"}';
  383. $input = json_decode($data, true);
  384. // refill\RefillFactory::instance()->notify('riying',$input);
  385. }
  386. public function testWeishengyPhone()
  387. {
  388. $providers = new refill\weishengy\RefillPhone([]);
  389. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  390. // $resp = $providers->query(['order_sn' => '15551618590601301527']);
  391. $data = '{"masId":"699270071532654592","oids":"158877719094,166090529155,158887187476","orderNo":"62411618635377880788","orderPrice":"150.00","phone":"18500608333","sign":"3EC10A32FC4CCC976048E1164D0FCBF6","status":"1","time":"1618643281063","type":"2"}';
  392. $input = json_decode($data, true);
  393. refill\RefillFactory::instance()->notify('weishengy',$input);
  394. }
  395. public function testWailingPhone()
  396. {
  397. $providers = new refill\wailing\RefillPhone([]);
  398. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  399. $resp = $providers->query(['order_sn' => '73241618543784045618']);
  400. $data = '{"order_id":"73241618543784045618","mchid":"10045","tel":"13699279618","price":"30.00","sign":"4991de3e40f14c198b8c194455ea021b","status":"0","out_order_id":"0"}';
  401. $input = json_decode($data, true);
  402. // refill\RefillFactory::instance()->notify('wailing',$input);
  403. }
  404. public function testShengyingPhone()
  405. {
  406. $providers = new refill\shengying\RefillPhone([]);
  407. // $resp = $providers->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  408. $resp = $providers->query(['order_sn' => '37571618805115582483']);
  409. $data = '{"TaskID":"129636","Mobile":"13699279618","Status":"4","ReportTime":"2021-04-19T12:06:16.050","ReportCode":"1:511531522026586295","OutTradeNo":"37571618805115582483","ReceiptNum":"511531522026586295","Sign":"a7f46a988bc8483091d94130804e5078"}';
  410. $input = json_decode($data, true);
  411. // refill\RefillFactory::instance()->notify('shengying',$input);
  412. }
  413. public function testYunlingPhone()
  414. {
  415. $providers = new refill\yunling\RefillPhone([]);
  416. $resp = $providers->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
  417. // $resp = $providers->query(['order_sn' => '40241617777847227476']);
  418. // $data = '{"userid":"10073505","sporderid":"7761230671186470456129","orderid":"8BE7B813A399AD2173505","resultno":"1","merchantsubmittime":"20210408084145","ordermoney":"28.68","verifystring":"28711bba302fadf95387b1d863d47a98","sign":"2e49e034ead64880f4fd605e378dd42b","supnumber":"510568880044465061"}';
  419. // $input = json_decode($data, true);
  420. // refill\RefillFactory::instance()->notify('yunling',$input);
  421. }
  422. public function testZhongstPhone()
  423. {
  424. $providers = new refill\zhongst\RefillPhone([]);
  425. // $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  426. // $resp = $providers->query(['order_sn' => '48941618981770389271']);
  427. $data = ' {"szOrderId":"66571619060147539784","fSalePrice":"46.5","szAgentId":"200030","nFlag":"2","szVerifyString":"c1e88701b89a4887996822d708bed5f5","szPhoneNum":"13699279618","szRtnMsg":"161122673971","nDemo":"50"}';
  428. $input = json_decode($data, true);
  429. refill\RefillFactory::instance()->notify('zhongst',$input);
  430. }
  431. public function testXunaoPhone()
  432. {
  433. $providers = new refill\xunao\RefillPhone([]);
  434. // $resp = $providers->add(18074608795, 6, 10, ['order_sn' => $this->make_sn()]);
  435. // $resp = $providers->query(['order_sn' => '40021619431386253803', 'card_no' => 18074608795, 'card_type' => 6]);
  436. $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"}';
  437. $input = json_decode($data, true);
  438. refill\RefillFactory::instance()->notify('xunao',$input);
  439. }
  440. public function testLuqianPhone()
  441. {
  442. $providers = new refill\luqian\RefillPhone([]);
  443. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  444. $resp = $providers->query(['order_sn' => '2829660672500596314764']);
  445. $data = '{"amount":"100","charge_type":"0","code":"1","partner_id":"38","phone":"18500608333","sign":"c2c86cccc73fa991a63c369e683c91f2","partner_order_no":"34101618897099329575","official_order_id":"110103308072104201338340278420"}';
  446. $input = json_decode($data, true);
  447. // refill\RefillFactory::instance()->notify('luqian',$input);
  448. }
  449. public function testAfandfsPhone()
  450. {
  451. $providers = new refill\afandfs\RefillPhone([]);
  452. // $resp = $providers->add(15139608757, 4, 30, ['order_sn' => $this->make_sn()]);
  453. $resp = $providers->query(['order_sn' => '65101618975926761630']);
  454. $data = '{"amount":"30","charge_type":"2","code":"1","partner_id":"52","phone":"15139608757","sign":"a7f54c1ac3e1af72f9fc849086cc4bec","partner_order_no":"65101618975926761630","official_order_id":"20210421113256628350"}';
  455. $input = json_decode($data, true);
  456. // refill\RefillFactory::instance()->notify('afandfs',$input);
  457. }
  458. public function testYunlingfsPhone()
  459. {
  460. $providers = new refill\yunlingfs\RefillPhone([]);
  461. // $resp = $providers->add(18500608333, 4, 30, ['order_sn' => $this->make_sn()]);
  462. $resp = $providers->query(['order_sn' => '72761619399048607916']);
  463. $data = '{"userid":"10073527","sporderid":"89451618975609262234","orderid":"02D8A7D2ADD7F4DC73527","resultno":"1","merchantsubmittime":"20210421112737","ordermoney":"28.68","verifystring":"95e3fe834a25cc8c524e09480354d9ba","sign":"b4fb11138a9f883749be320772965add","supnumber":"20210421112716840298"}';
  464. $input = json_decode($data, true);
  465. // refill\RefillFactory::instance()->notify('yunlingfs',$input);
  466. }
  467. public function testTianchengPhone()
  468. {
  469. $providers = new refill\tiancheng\RefillPhone([]);
  470. $resp = $providers->add(18074608795, 6, 30, ['order_sn' => $this->make_sn()]);
  471. // $resp = $providers->query(['order_sn' => '15301619399212504464']);
  472. $data = ' {"result":"fail","msg":"0","order":"null","phone_no":"13699279618","amount":"10","op_no":"84801619340283980506","settle":"0","sign":"D64039ED791920B08BDA9DD95700C0E6"}';
  473. $input = json_decode($data, true);
  474. // refill\RefillFactory::instance()->notify('tiancheng',$input);
  475. }
  476. public function testLingzhPhone()
  477. {
  478. $providers = new refill\lingzh\RefillPhone([]);
  479. // $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  480. // $resp = $providers->query(['order_sn' => '59911615124025101286']);
  481. $resp = $providers->balance();
  482. // $input['usr'] = 1;
  483. // $input['ord'] = '52741615119546453690';
  484. // $input['bz'] = '';
  485. // $input['state'] = 2;
  486. // $input['sgn'] = 'FFCBB75C307154DD306F4EC75BB69A6D';
  487. // refill\RefillFactory::instance()->notify('lingzh',$input);
  488. }
  489. public function testAfandnewPhone()
  490. {
  491. $providers = new refill\afandnew\RefillPhone([]);
  492. // $resp = $providers->add(18500608333, 5, 100, ['order_sn' => $this->make_sn()]);
  493. // $resp = $providers->query(['order_sn' => '45371617101073876975', 'ch_trade_no' => '33018443659736309']);
  494. $params = '{"amount":"100","carrierOrderNo":null,"mobile":"18500608333","orderNo":"45371617101073876975","orderStatus":3,"sign":"8DE392AD6B4730AD9EE0FC2B95BBDF17","tradeNo":"33018443659736309"}';
  495. $input = json_decode($params, true);
  496. refill\RefillFactory::instance()->notify('afandnew', $input);
  497. }
  498. public function testYifaPhone()
  499. {
  500. $providers = new refill\yifa\RefillPhone([]);
  501. $resp = $providers->add(15120035568, 5, 50, ['order_sn' => $this->make_sn()]);
  502. }
  503. public function testTianjtOil()
  504. {
  505. $cardno = 1000111100021211884;
  506. $providers = new refill\tianjt\RefillOil([]);
  507. $resp = $providers->add($cardno, 2, 500, ['order_sn' => $this->make_sn()]);
  508. }
  509. public function testWeitPhone()
  510. {
  511. $providers = new refill\weit\RefillPhone([]);
  512. for ($i = 0; $i <= 10; $i++) {
  513. $resp = $providers->add(18500608333, 5, 10, ['order_sn' => $this->make_sn()]);
  514. }
  515. }
  516. public function testWeitCB()
  517. {
  518. $params['sign'] = 'af820c33472f4b571fa0c48483dfb975';
  519. $params['status'] = 0;
  520. $params['price'] = 30;
  521. $params['op_order_id'] = '';
  522. $params['mch_order_id'] = '900664281823957221';
  523. $params['pt_order_id'] = '2021011802434412825405218901';
  524. $params['pay_type'] = '';
  525. $params['tel'] = 18500608333;
  526. $params['mchid'] = 10014;
  527. $resp = http_request($this->mReqHost . "/mobile/refill_weit.php", $params, 'POST');
  528. }
  529. public function testYifaCB()
  530. {
  531. $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"}';
  532. $input = json_decode($body, true);
  533. refill\RefillFactory::instance()->notify('yifa', $input);
  534. }
  535. public function testBjbQuery()
  536. {
  537. $providers = new refill\bjb\RefillPhone([]);
  538. $refill_info = ['order_sn' => 110667993758599771, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  539. $resp = $providers->query($refill_info);
  540. }
  541. public function testXcQuery()
  542. {
  543. $providers = new refill\xc\RefillPhone([]);
  544. $refill_info = ['order_sn' => 950663423236726632, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  545. $resp = $providers->query($refill_info);
  546. }
  547. public function testTianjtQuery()
  548. {
  549. $providers = new refill\tianjt\RefillOil([]);
  550. $refill_info = ['order_sn' => 680665862267622221, 'ch_trade_no' => 499, 'card_no' => 1000111200005252927];
  551. $resp = $providers->query($refill_info);
  552. }
  553. public function testSaihuOil()
  554. {
  555. $providers = new refill\saihu\RefillOil([]);
  556. $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => $this->make_sn()]);
  557. }
  558. public function testBdtOil()
  559. {
  560. $providers = new refill\bdt\RefillOil([]);
  561. $resp = $providers->add(1000111100021211884, 2, 100, ['order_sn' => '200229600556618886']);
  562. }
  563. public function testGFTDOil()
  564. {
  565. $providers = new refill\gftd\RefillOil([]);
  566. $resp = $providers->add(1000111100020445281, mtopcard\SinopecCard, 100, ['order_sn' => $this->make_sn()]);
  567. }
  568. public function testGFTDCB()
  569. {
  570. $data = '{"channelOrderNumber":"79091610959059372019","orderNumber":"GYFL1610959060397001","message":"充值成功","storage":"881036222bd8f067ff47d248c75f4c8d","voucher":"","status":101}';
  571. $url = "http://192.168.1.220/mobile/refill_gftd.php?" . $data;
  572. $resp = http_post_data($url, $data, ['Content-Type: application/json;charset=UTF-8;', 'Accept:application/json;charset=UTF-8;']);
  573. }
  574. public function testJiecPhone()
  575. {
  576. $providers = new refill\jiec\RefillPhone([]);
  577. $resp = $providers->add('18500608333', 5, 30, ['order_sn' => $this->make_sn()]);
  578. }
  579. public function testBxtwtCB()
  580. {
  581. $data = '{"order_number":18219726,"shipping_status":4,"shipping_status_desc":"发货失败","shipping_status_message":"","sign":"863b4d972f2a4d39a9af7396879116c4","voucher":"","vouchertype":"","voucherurl":"","tradeNo":"100662475851197741"}';
  582. }
  583. public function testTianjtJDVerify()
  584. {
  585. $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';
  586. $url = "http://192.168.1.220/mobile/refill_tianjt.php?" . $data;
  587. $resp = http_request($url);
  588. }
  589. public function testSuhcPDD()
  590. {
  591. $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';
  592. $url = "https://www.xyzshops.cn/mobile/refill_suhcpdd.php?" . $data;
  593. $resp = http_request($url);
  594. }
  595. public function testSuhcTMVerify()
  596. {
  597. $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';
  598. $url = "https://www.xyzshops.cn/mobile/refill_suhctm.php?" . $data;
  599. $resp = http_request($url);
  600. }
  601. public function testBeixtVerify()
  602. {
  603. $data = '{"order_number":18219726,"shipping_status":4,"shipping_status_desc":"发货失败","shipping_status_message":"","sign":"863b4d972f2a4d39a9af7396879116c4","voucher":"","vouchertype":"","voucherurl":"","tradeNo":"100662475851197741"}';
  604. $url = "https://www.xyzshops.cn/mobile/refill_bxtwt.php";
  605. $headers = ['Content-Type: application/json'];
  606. $resp = http_post_data($url, $data, $headers);
  607. }
  608. public function testInput()
  609. {
  610. $input = fopen("php://input", "rw");
  611. file_put_contents($input, 'xxxx');
  612. $content = file_get_contents('php://input');
  613. }
  614. public function testUrl()
  615. {
  616. $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';
  617. $params = preg_split('/&/', $data);
  618. foreach ($params as $pair) {
  619. $kv = explode('=', $pair);
  620. $count = count($kv);
  621. if ($count === 1) {
  622. $key = $kv[0];
  623. $val = "";
  624. } elseif ($count === 2) {
  625. $key = $kv[0];
  626. $val = $kv[1];
  627. } else {
  628. continue;
  629. }
  630. Log::record("{$key}:{$val}", Log::DEBUG);
  631. }
  632. }
  633. public function testAddoil()
  634. {
  635. $url = $this->mReqHost . "/mobile/index.php";
  636. $notifyurl = 'http://121.89.196.45/mobile/signature.php';
  637. $params = ['mchid' => $this->mMchid,
  638. 'cardno' => '1000111100020445281',
  639. 'amount' => "100",
  640. "act" => "refill",
  641. "op" => "add",
  642. 'order_sn' => $this->make_sn(),
  643. 'notifyurl' => $notifyurl];
  644. $resp = $this->send_md5($url, $params);
  645. Log::record($resp, Log::DEBUG);
  646. }
  647. public function testBalance()
  648. {
  649. $url = $this->mReqHost . "/mobile/index.php";
  650. $params = ['mchid' => 1092,
  651. "act" => "refill",
  652. "op" => "balance"];
  653. $resp = $this->send_md5($url, $params);
  654. Log::record($resp, Log::DEBUG);
  655. }
  656. public function testAddPhoe()
  657. {
  658. $phones = [//13911129867,
  659. 18500608333,
  660. 18510683168,
  661. 18513846008,
  662. 18518237398];
  663. $amount = 10;
  664. for ($i = 0; $i < 3; $i++) {
  665. foreach ($phones as $phone) {
  666. $url = $this->mReqHost . "/mobile/index.php";
  667. $params = ['mchid' => 1092,
  668. 'cardno' => $phone,
  669. 'amount' => $amount,
  670. "act" => "refill",
  671. "op" => "add",
  672. 'order_sn' => $this->make_sn(),
  673. 'notifyurl' => $this->mReqHost . "/mobile/refill_xyz.php"];
  674. $resp = $this->send_md5($url, $params);
  675. Log::record($resp, Log::DEBUG);
  676. }
  677. }
  678. }
  679. public function testProxyHelper()
  680. {
  681. $phone = '13911129867';
  682. $amount = 100;
  683. $url = $this->mReqHost . "/mobile/index.php";
  684. $params = ['mchid' => 1090,
  685. 'cardno' => $phone,
  686. 'amount' => $amount,
  687. "act" => "refill",
  688. "op" => "add",
  689. 'order_sn' => $this->make_sn(),
  690. 'notifyurl' => "https://xxx"];
  691. $proxy = new refill_proxy("xxx");
  692. $resp = $proxy->send($url, $params);
  693. }
  694. public function testGoods()
  695. {
  696. $req_url = $this->mReqHost . '/mobile/index.php';
  697. $params = ['mchid' => $this->mMchid,
  698. "act" => "refill",
  699. "op" => "goods"];
  700. $resp = $this->send_md5($req_url, $params);
  701. }
  702. public function testQueryFactory()
  703. {
  704. refill\RefillFactory::instance()->query(295);
  705. }
  706. public function testQuery()
  707. {
  708. //$req_url = 'https://www.xyzshops.cn/mobile/index.php';
  709. // $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
  710. $req_url = BASE_SITE_URL . '/mobile/index.php';
  711. $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
  712. $params = ['mchid' => 1,
  713. "act" => "refill",
  714. "op" => "query",
  715. 'order_sn' => "13281476"];
  716. $resp = $this->send_md5($req_url, $params);
  717. }
  718. public function testRemoveSession()
  719. {
  720. $resp = http_request(BASE_SITE_URL . "/mobile/signature.php", [], 'POST');
  721. }
  722. public function testTianjtCB()
  723. {
  724. // $notifyurl = BASE_SITE_URL . "/mobile/refill_tianjt.php";
  725. $notifyurl = "https://www.xyzshops.cn/mobile/refill_tianjt.php";
  726. // $notifyurl = "https%3A%2F%2Fwww.xyzshops.cn%2Fmobile%2Frefill_tianjt.php";
  727. $params = ['onlystr' => '690665858589475818',
  728. 'amt' => 1000,
  729. 'jdno' => '',
  730. 'notifyurl' => $notifyurl,
  731. 'cardtype' => 'Sinoepc',
  732. 'batchid' => 30589,
  733. 'cardno' => '1000113300007993287',
  734. 'orgid' => '1590993600',
  735. 'status' => 3];
  736. $sign = $this->md5_sign($params);
  737. $params['sign'] = $sign;
  738. $resp = http_request($notifyurl, $params, 'POST');
  739. Log::record($resp, Log::DEBUG);
  740. }
  741. public function testBJBCB()
  742. {
  743. $params = [
  744. 'usr' => '13699279618',
  745. 'ord' => '710662733975412771',
  746. 'state' => '2',
  747. 'bz' => '',
  748. 'sgn' => 'AC9AFD254DE682D8440A97CA68B992DA'
  749. ];
  750. $resp = http_request("https://www.xyzshops.cn/mobile/refill_bjb.php", $params, 'POST');
  751. }
  752. public function testJiecCB()
  753. {
  754. $params['result'] = 'fail';
  755. $params['msg'] = '0';
  756. $params['order'] = 'null';
  757. $params['phone_no'] = '18500608333';
  758. $params['amount'] = '30.00';
  759. $params['op_no'] = '800663597981819221';
  760. $params['sign'] = '2510046895e8e12322c8a32547905ee9';
  761. $resp = http_request($this->mReqHost . "/mobile/refill_jiec.php", $params, 'POST');
  762. }
  763. public function testZFKJ()
  764. {
  765. //带签名参数:mchid=1090&act=refill&op=add&cardno=100112121212212133
  766. //&amount=10&order_sn=PH2012261356569433&
  767. //notifyurl=https%3A%2F%2Fqzcz.edusahoo.com.cn%2Findex%2Findex%2Fcallback
  768. //&sign=4a3ac5f9706e64aa70c6cab0fc5839d3
  769. $params = ['mchid' => 1090,
  770. 'cardno' => '100112121212212133',
  771. 'amount' => '10',
  772. "act" => "refill",
  773. "op" => "add",
  774. 'order_sn' => 'PH2012261356569433',
  775. 'notifyurl' => 'https://qzcz.edusahoo.com.cn/index/index/callback'];
  776. $resp = $this->send_md5(BASE_SITE_URL . '/mobile/index.php', $params);
  777. }
  778. protected function check_empty($value)
  779. {
  780. if (!isset($value))
  781. return true;
  782. if ($value === null)
  783. return true;
  784. if (trim($value) === "")
  785. return true;
  786. return false;
  787. }
  788. public function testcreateSign()
  789. {
  790. $params['act'] = 'refill';
  791. $params['amount'] = '100';
  792. $params['cardno'] = '1000111200006005872';
  793. $params['mchid'] = '1092';
  794. $params['notifyurl'] = 'http://202.85.213.156:8080//YeZiYKCallBackOrderServlet';
  795. $params['op'] = 'balance';
  796. $params['order_sn'] = 'jftest0000123';
  797. $sign = $this->md5_sign($params);
  798. }
  799. public function testCheckphone()
  800. {
  801. $check = function ($phone) {
  802. $url = 'https://mobileempty.shumaidata.com/mobileempty';
  803. $params['mobile'] = $phone;
  804. $headers = array();
  805. array_push($headers, "Authorization:APPCODE " . '8f92d951293f4d2ea48ff86d5a70c537');
  806. $resp = http_request($url, $params, 'GET', false, $headers);
  807. $resp = json_decode($resp, true);
  808. if ($resp['success'] == true && $resp['code'] == 200) {
  809. Log::record("data phone:{$phone} , status : {$resp['data']['status']}", Log::DEBUG);
  810. if (in_array($resp['data']['status'], [0, 3, 4, 5])) {
  811. return false;
  812. }
  813. } else {
  814. Log::record("data phone:{$phone} , 不支持的号段", Log::DEBUG);
  815. }
  816. };
  817. $check(17801048874);
  818. }
  819. public function testCtSign()
  820. {
  821. $params['act'] = 'refill';
  822. $params['mchid'] = 12345;
  823. $params['op'] = 'goods';
  824. $sign = $this->md5_sign($params);
  825. }
  826. private function md5_sign($params)
  827. {
  828. ksort($params);
  829. $body = "";
  830. $i = 0;
  831. foreach ($params as $k => $v) {
  832. if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) {
  833. if ($i == 0) {
  834. $body .= "{$k}" . "=" . urlencode($v);
  835. } else {
  836. $body .= "&" . "{$k}" . "=" . urlencode($v);
  837. }
  838. $i++;
  839. }
  840. }
  841. $body .= "&key=12345";
  842. return md5($body);
  843. }
  844. public function testCallMech()
  845. {
  846. $logic = Logic('queue');
  847. $logic->NotifyMerchantComplete(['order_id' => 18171, 'manual' => true]);
  848. }
  849. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCallMech)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
  850. private function send($url, $params)
  851. {
  852. $mchid = $params['mchid'];
  853. $pri_key = BASE_DATA_PATH . "/api/merchant/key/{$mchid}_pri.pem";
  854. $key = file_get_contents($pri_key);
  855. $pri = openssl_get_privatekey($key);
  856. $body = $this->body($params);
  857. openssl_sign($body, $signed, $pri);
  858. $sign = base64_encode($signed);
  859. $params['sign'] = $sign;
  860. $resp = http_request($url, $params, 'POST');
  861. Log::record("resp:{$resp}", Log::DEBUG);
  862. }
  863. private function send_md5($url, $params)
  864. {
  865. $body = $this->body($params);
  866. $body .= "&key={$this->mKey}";
  867. $params['sign'] = md5($body);
  868. $resp = http_request($url, $params, 'POST');
  869. Log::record("resp:{$resp}", Log::DEBUG);
  870. return $resp;
  871. }
  872. public function testCardType()
  873. {
  874. $cardno = '1000111100021211884';
  875. $ret = preg_match('/^1[0-9]{18}$/', $cardno, $matches);
  876. }
  877. public function testMtrand()
  878. {
  879. }
  880. public function testHttpRefill()
  881. {
  882. $mchid = '000001';
  883. $pri_key = BASE_DATA_PATH . "/api/merchant/key/{$mchid}_pri.pem";
  884. $key = file_get_contents($pri_key);
  885. $pri = openssl_get_privatekey($key);
  886. $params = ['MCHID' => $mchid, 'cardno' => '1000111100021211884', 'amt' => "100", "act" => "refill", "op" => "addoil"];
  887. $body = $this->body($params);
  888. openssl_sign($body, $signed, $pri);
  889. $sign = base64_encode($signed);
  890. $params['sign'] = $sign;
  891. $resp = http_request(BASE_SITE_URL . "/mobile/index.php", $params, 'POST');
  892. }
  893. private function body($params)
  894. {
  895. ksort($params);
  896. $body = "";
  897. $i = 0;
  898. foreach ($params as $k => $v) {
  899. if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) {
  900. if ($i == 0) {
  901. $body .= "{$k}" . "=" . urlencode($v);
  902. } else {
  903. $body .= "&" . "{$k}" . "=" . urlencode($v);
  904. }
  905. $i++;
  906. }
  907. }
  908. return $body;
  909. }
  910. private function checkEmpty($value)
  911. {
  912. if (!isset($value))
  913. return true;
  914. if ($value === null)
  915. return true;
  916. if (trim($value) === "")
  917. return true;
  918. return false;
  919. }
  920. public function testKsort()
  921. {
  922. $age = ["Peter" => "35", "Ben" => "37", "Joe" => "43"];
  923. ksort($age);
  924. foreach ($age as $x => $x_value) {
  925. echo "Key=" . $x . ", Value=" . $x_value;
  926. echo "<br>";
  927. }
  928. }
  929. public function testip()
  930. {
  931. $model_merchant = Model('merchant');
  932. $merchant_info = $model_merchant->getMerchantInfo(['mchid' => 1]);
  933. $ipwhitelist = unserialize($merchant_info['ip_white_list']);
  934. $res = json_encode($ipwhitelist);
  935. }
  936. //测试向内部店提交订单,可先屏蔽其它充值通道
  937. public function testAddoilToInnerStore()
  938. {
  939. $url = $this->mReqHost . "/mobile/index.php";
  940. $notifyurl = BASE_SITE_URL . '/mobile/signature.php';
  941. $params = ['mchid' => 1,
  942. 'cardno' => '1000111100020445281',
  943. 'amount' => "1000",
  944. "act" => "refill",
  945. "op" => "add",
  946. 'order_sn' => $this->make_sn(),
  947. 'notifyurl' => $notifyurl];
  948. $resp = $this->send_md5($url, $params);
  949. Log::record($resp, Log::DEBUG);
  950. }
  951. public function testRefillInnerCB()
  952. {
  953. $params = ['state_type' => 'order_cancel', 'order_id' => 311, 'channel_name' => 'lx'];
  954. $resp = http_request(BASE_SITE_URL . '/mobile/refill_inner.php', $params, 'POST');
  955. }
  956. public function testArgs()
  957. {
  958. Log::record($_SERVER['argv'], Log::DEBUG);
  959. }
  960. public function testCall()
  961. {
  962. $order_id = 14974;
  963. QueueClient::async_push("NotifyMerchantComplete", ['order_id' => $order_id, 'manual' => true], 10);
  964. }
  965. public function testSyncconfig()
  966. {
  967. $name_val_cfg = function ($items) {
  968. $result = [];
  969. foreach ($items as $item) {
  970. $name = $item->name();
  971. $result[$name] = $item;
  972. }
  973. return $result;
  974. };
  975. $name_val_row = function ($items) {
  976. $result = [];
  977. foreach ($items as $item) {
  978. $name = $item['name'];
  979. $result[$name] = $item;
  980. }
  981. return $result;
  982. };
  983. $match = function ($all, $cur) {
  984. $insert = [];
  985. foreach ($all as $key => $value) {
  986. if (!array_key_exists($key, $cur)) {
  987. $insert[] = $key;
  988. }
  989. }
  990. return $insert;
  991. };
  992. $inserter = function ($mod, $type, $names) {
  993. foreach ($names as $name) {
  994. $data = ['name' => $name, 'type' => $type];
  995. $mod->insert($data);
  996. }
  997. };
  998. $providers = refill\RefillFactory::instance()->providers();
  999. $oils = $name_val_cfg($providers['oil']);
  1000. $phones = $name_val_cfg($providers['phone']);
  1001. $mod_prov = Model('refill_provider');
  1002. $oil_items = $mod_prov->getProviderList(['type' => 1]);
  1003. $oil_items = $name_val_row($oil_items);
  1004. $oil_inserts = $match($oils, $oil_items);
  1005. $phone_items = $mod_prov->getProviderList(['type' => 2]);
  1006. $phone_items = $name_val_row($phone_items);
  1007. $phone_inserts = $match($phones, $phone_items);
  1008. $inserter($mod_prov, 1, $oil_inserts);
  1009. $inserter($mod_prov, 2, $phone_inserts);
  1010. }
  1011. public function testStat()
  1012. {
  1013. $model_refill_order = Model('refill_order');
  1014. $stat = Model('')->table('refill_order,vr_order')->join('inner')
  1015. ->on('refill_order.order_id=vr_order.order_id')
  1016. ->field('sum(refill_amount) as refill_amounts , sum(channel_amount) as channel_amounts , sum(mch_amount) as mch_amounts')
  1017. ->where([])->select();
  1018. }
  1019. public function testRefillGoods()
  1020. {
  1021. $goods = refill\RefillFactory::instance()->goods();
  1022. }
  1023. private function make_mobile()
  1024. {
  1025. $no = "1" . mt_rand(3000000000, 3999999999);
  1026. return $no;
  1027. }
  1028. private function refill_info($card_no, $card_type)
  1029. {
  1030. $data = rcache($card_no, 'cardrefill-');
  1031. if (empty($data)) {
  1032. $mod_topcard = Model('topcard');
  1033. $ret = $mod_topcard->get_card($card_no);
  1034. if (empty($ret)) {
  1035. $bind_phone = $this->make_mobile();
  1036. $mod_topcard->add($card_no, $card_type, time(), $bind_phone);
  1037. $data['bind_phone'] = $bind_phone;
  1038. $data['refill_time'] = time();
  1039. $data['times'] = 0;
  1040. wcache($card_no, $data, 'cardrefill-');
  1041. } else {
  1042. $val = $ret[0];
  1043. $data['bind_phone'] = $val['bind_phone'];
  1044. $data['refill_time'] = time();
  1045. $data['times'] = 0;
  1046. }
  1047. }
  1048. return $data;
  1049. }
  1050. public function testGetMobile()
  1051. {
  1052. $card_no = '1000119000001679247';
  1053. $card_type = 1;
  1054. $info = $this->refill_info($card_no, $card_type);
  1055. }
  1056. private function check_mchorder($mchid, $mch_order)
  1057. {
  1058. if (empty($mch_order)) {
  1059. return true;
  1060. } else {
  1061. $refill_order = Model('refill_order');
  1062. $ret = $refill_order->getOrderInfo(['mchid' => $mchid, 'mch_order' => $mch_order]);
  1063. return empty($ret);
  1064. }
  1065. }
  1066. public function testCheckMchorder()
  1067. {
  1068. $ret = $this->check_mchorder(1, '13281475');
  1069. }
  1070. public function testMakemobile()
  1071. {
  1072. $mobile = refill\util::make_mobile();
  1073. $ret = refill\util::set_black('1000111100020445281');
  1074. }
  1075. public function testLoadBlack()
  1076. {
  1077. $path = BASE_DATA_PATH . "/log";
  1078. $names = ['20210119-mobile.log',
  1079. '20210120-mobile.log', '20210121-mobile.log', '20210122-mobile.log', '20210123-mobile.log',
  1080. '20210124-mobile.log', '20210125-mobile.log'];
  1081. foreach ($names as $name) {
  1082. $file_name = $path . "/" . $name;
  1083. refill\util::black_from_log($file_name);
  1084. }
  1085. }
  1086. public function testStats()
  1087. {
  1088. $date = date('Y-m-d', time());
  1089. $today = strtotime("{$date}");
  1090. $times_begin = function ($start) {
  1091. $times = [];
  1092. $begin = $start;
  1093. for ($i = 0; $i < 7; $i++) {
  1094. $times[] = $begin;
  1095. $begin -= 86400;
  1096. }
  1097. return $times;
  1098. };
  1099. $reader = function ($mchid, $time) {
  1100. $cond['mchid'] = $mchid;
  1101. $cond['inner_status'] = 0;
  1102. $cond['refill_order.order_time'] = ['between', [$time, $time + 86400 - 1]];
  1103. $items = Model('')->table('refill_order,vr_order')->join('inner')
  1104. ->on('refill_order.order_id=vr_order.order_id')
  1105. ->field('count(*) as order_count, vr_order.order_state, sum(mch_amount) as mch_amounts')
  1106. ->group('vr_order.order_state')
  1107. ->where($cond)->select();
  1108. return $items;
  1109. };
  1110. $begins = $times_begin($today);
  1111. $mchid = 10096;
  1112. // $states = rcache($this->mchid() , 'refillstat-');
  1113. $states = unserialize($states ?? "");
  1114. if (empty($states)) $states = [];
  1115. $result = [];
  1116. $cache = [];
  1117. foreach ($begins as $begin) {
  1118. if (array_key_exists($begin, $states)) {
  1119. $item = $states[$begin];
  1120. } else {
  1121. $item = $reader($mchid, $begin);
  1122. }
  1123. $result[$begin] = $item;
  1124. //判断item 中充值中的状态是否为0,为0的情况下放进cache
  1125. $cache = $item;
  1126. }
  1127. wcache($this->mchid(), $cache, 'refillstat-');
  1128. return $result;
  1129. }
  1130. public function testNotifyx()
  1131. {
  1132. $mch_cache = rcache("merchant-notify", 'refill-');
  1133. $caches = empty($mch_cache['data']) ? [] : unserialize($mch_cache['data']);
  1134. $new_caches = [];
  1135. $merchants = Model('merchant')->getMerchantList([], '', '', 'merchant.*,member.available_predeposit', "0,1000");
  1136. foreach ($merchants as $merchant) {
  1137. $mchid = $merchant['mchid'];
  1138. $phone = $merchant['contact_phone'] ?? "";
  1139. $available_pd = intval($merchant['available_predeposit']);
  1140. $alarm_pd = intval($merchant['alarm_amount']) < 10000 ? 10000 : intval($merchant['alarm_amount']);
  1141. if (array_key_exists($mchid, $caches)) {
  1142. $mch_cache = $caches[$mchid];
  1143. } else {
  1144. $mch_cache = ['last_time' => 0, 'send_count' => 0];
  1145. }
  1146. if (!empty($phone) && ($available_pd < $alarm_pd)) {
  1147. $counts = $mch_cache['send_count'];
  1148. if (($mch_cache['last_time'] + 300 < time()) && $counts < 5) {
  1149. $mch_cache = ['last_time' => time(), 'send_count' => $counts + 1];
  1150. QueueClient::push('sendSMS', ['mobile' => $merchant['contact_phone'],
  1151. 'type' => 'balance_warning', 'datas' => [date("m月d日H时"), $merchant['available_predeposit']]]);
  1152. }
  1153. } else {
  1154. $mch_cache = ['last_time' => 0, 'send_count' => 0];
  1155. }
  1156. $new_caches[$mchid] = $mch_cache;
  1157. }
  1158. wcache("merchant-notify", ['data' => serialize($new_caches)], 'refill-');
  1159. }
  1160. public function testReadChannel()
  1161. {
  1162. refill\RefillFactory::instance()->read_channel();
  1163. }
  1164. public function testAllow()
  1165. {
  1166. $allow = refill\RefillFactory::instance()->allow(10096, 1, 100);
  1167. }
  1168. public function testCheckData()
  1169. {
  1170. $str = '|2|110667993758599771-充值失败|';
  1171. // $str = '0|提交成功|-36557.7400';
  1172. // if(preg_match( '/^-*[0-9]{1,3}\|[\x{4e00}-\x{9fa5}]+\|-*[0-9]+\.*[0-9]+$/u',$str,$matches)) {
  1173. // return true;
  1174. // }
  1175. // if(preg_match('/^[0-3]\|[0-9]+-*[\x{4e00}-\x{9fa5}]+\|[0-9]*$/u',$str,$matches)){
  1176. // return true;
  1177. // }
  1178. // return false;
  1179. $resp = ltrim($str, '|');
  1180. $resp = explode('|', $resp);
  1181. if (count($resp) != 3) {
  1182. return [false, '返回值错误'];
  1183. }
  1184. }
  1185. public function testErrre()
  1186. {
  1187. $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}';
  1188. $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);
  1189. }
  1190. public function testLog()
  1191. {
  1192. // $line = './LOG/20210203-mobile.log:[15 2021-02-03 10:41:17] SQL: UPDATE `lrlz_member` SET available_predeposit=available_predeposit+975 WHERE ( member_id = \'65818\' ) [ RunTime:0.000297s ]';
  1193. $fn = fopen(BASE_ROOT_PATH . "/10096.log", "r");
  1194. $mod = Model();
  1195. $mod->table('tfloat')->where(['member_id' => 65818])->update(['pdamount' => 0]);
  1196. $total_amount = ncPriceFormat(0.00);
  1197. $i = 0;
  1198. while (!feof($fn)) {
  1199. $i++;
  1200. $line = trim(fgets($fn));
  1201. $ret = preg_match('/[\w\W]+UPDATE[\w\W]+available_predeposit=available_predeposit(?P<oper>[-+]+)(?P<amount>[.\d]+)/i', $line, $matches);
  1202. if ($ret) {
  1203. $oper = $matches['oper'];
  1204. $amount = $matches['amount'];
  1205. if ($oper == '-') {
  1206. $total_amount = ncPriceFormat($total_amount) - ncPriceFormat($amount);
  1207. // $mod->table('tfloat')->where(['member_id' => 65818])->update( ['pdamount'=>['exp','pdamount-'.$amount]]);
  1208. } else {
  1209. $total_amount = ncPriceFormat($total_amount) + ncPriceFormat($amount);
  1210. // $mod->table('tfloat')->where(['member_id' => 65818])->update( ['pdamount'=>['exp','pdamount+'.$amount]]);
  1211. }
  1212. Log::record("index = {$i} {$total_amount} = {$total_amount} {$oper} {$amount}", Log::DEBUG);
  1213. }
  1214. }
  1215. Log::record("total_amount:{$total_amount}", Log::DEBUG);
  1216. fclose($fn);
  1217. }
  1218. public function testMchctl()
  1219. {
  1220. $ctl = new refill\mchctl();
  1221. }
  1222. public function testAsyncadd()
  1223. {
  1224. $x = \refill\util::async_add(['xxxx' => 1],4);
  1225. }
  1226. }
  1227. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
  1228. //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