TestRefill.php 66 KB

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