refund('8000000000638201',$err); } public function testOrderHelper() { $helper = new refund_helper(36490); $helper->refund('8000000000638201',$err); } public function testReturnInfo() { $helper = new refund_helper(36490); $helper->return_info('8000000000651001',10100,$err); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefund::testByOnline)( .*)?$/" --test-suffix TestRefund.php /var/www/html/test public function testByOnline() { $getProvider = function ($name, $type = 'RefillPhone') { $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php"; if (!file_exists($file)) { Log::record("provider api file=$file not exist.", Log::DEBUG); return false; } else { require_once($file); Log::record("file={$file} load success.", Log::DEBUG); } $class_name = "refill\\{$name}\\{$type}"; if (class_exists($class_name, false)) { $caller = new $class_name([]); return $caller; } else { $error = "Base Error: class {$class_name} isn't exists!"; Log::record($error, Log::ERR); return false; } }; $snmaker = function () { return mt_rand(1000, 9999) . sprintf('%010d', time()) . sprintf('%06d', (float)microtime() * 1000000); }; $provider = $getProvider('by_online'); $order_sn = $snmaker(); Log::record("order_sn=$order_sn",Log::DEBUG); $file = fopen(BASE_DATA_PATH . "/log/{$order_sn}.log",'a+'); // [$succ_add, $msg, $nerr] = $provider->add(18810246909, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); [$succ_add, $msg, $nerr] = $provider->add(13911129867, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); // [$succ_add, $msg, $nerr] = $provider->add(13925782928, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); // [$succ_add, $msg, $nerr] = $provider->add(15120035568, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); // [$succ_add, $msg, $nerr] = $provider->add(17801048874, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); // [$succ_add, $msg, $nerr] = $provider->add(15951343795, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); // [$succ_add, $msg, $nerr] = $provider->add(15064807655, 4, 1, ['regin_no' => 1, 'order_sn' => $order_sn]); $last_tag = ''; $count = 0; $commit_time = time(); while ($succ_add) { [$succ,$resp] = $provider->query(['order_sn' => $order_sn,'official_sn' => $nerr,'commit_time' => $commit_time]); if($succ) { $tag = md5($resp); if($tag != $last_tag) { fwrite($file,"md5=$tag\r\n"); fwrite($file,$resp); fwrite($file,"\r\n"); fflush($file); $last_tag = $tag; } else { fwrite($file,"count=$count\r\n"); fflush($file); $count += 1; } } sleep(1); } fclose($file); } private function getProvider($name, $type = 'RefillPhone') { $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php"; if (!file_exists($file)) { Log::record("provider api file=$file not exist.", Log::DEBUG); return false; } else { require_once($file); Log::record("file={$file} load success.", Log::DEBUG); } $class_name = "refill\\{$name}\\{$type}"; if (class_exists($class_name, false)) { $caller = new $class_name([]); return $caller; } else { $error = "Base Error: class {$class_name} isn't exists!"; Log::record($error, Log::ERR); return false; } } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefund::testByQuery)( .*)?$/" --test-suffix TestRefund.php /var/www/html/test public function testByQuery() { $orders = $this->getOrders(); $mod_refill = Model('refill_order'); foreach ($orders as $order_sn) { $refill_info = $mod_refill->getOrderInfo(['order_sn' => $order_sn]); if(!empty($refill_info)) { $chname = $refill_info['channel_name']; $provider = $this->getProvider($chname); [$status, $order_state, $charge_id] = $provider->query($refill_info); if($status) { Log::record("order_sn=$order_sn order_state=$order_state",Log::DEBUG); } else { Log::record("order_sn=$order_sn msg=$order_state",Log::DEBUG); } } else { Log::record("order_sn=$order_sn empty",Log::DEBUG); } } } private function getOrders() { return [ '7749990739497208755104', '4241640739497214477247', '3409590739497235409931', '3441260739497239066452', '1434360739497573663949', '3359180739497588027168', '33841685199232623212', '28471685199597405220', '57171685202698387113', '89491685204072019563', '54821685230140381770', '94021685232830341599', '3141710739497207880429', '1343340739497214781295', '5905900739497214862174', '1955480739497240001384', '2344270739497387804732', '5649180739497388386881', '7799780739497388683087', '9389810739497404696612', '6035530739497543907708', '2069310739497546200263', '2986790739497573078875', '2996950739497573184793', '5746870739323892570502', '7776210739324342537968', '1651790739324578300572', '2089700739324697035601', '1046530739324701858673', '3588350739324790951598', '02031910738486333430245', '42041685144164497475', '13731685144277889026', '89841685144485116642', '86911685176628006840', '75071685198614860230', '75811685201242132173', '55051685203269595963', '19821685205286104990', '9704550739323836502970', '8853970739324578150798', '8266910739324696844607', '1909980739324696852263', '4242700739497207277597', '7315300739497207416673', '6027840739497213695911', '6664270739497214380016', '3697580739497224283328', '1527960739497224461069', '5845540739497224677983', '9158010739497239807777', '0725700739497405115820', '5647410739497407395639', '8484290739497572819121', '7522330739497578980959', '3148900739497588515397', '44641685144571093667', '11331685200447945941', '83701685230393513621', '0999230739324323447175', '2099360739324342437099', '1345740739324456585903', '3436600739324517966370', '7931230739324697254624', '8439720739324795372416' ]; } public function testOneOrder() { $provider = $this->getProvider('by_online'); $params = [ '8013920739815620475078' => '1123061172453041', '0375610739886119616188' => '1123061272466229', ]; foreach ($params as $order_sn => $official_sn) { [$succ, $resp] = $provider->query(['order_sn' => $order_sn, 'official_sn' => $official_sn]); } } private function check_order($cond) { $fsucc = fopen(BASE_DATA_PATH . "/log/succ.log",'a+'); $fcancel = fopen(BASE_DATA_PATH . "/log/cancel.log",'a+'); $ferr = fopen(BASE_DATA_PATH . "/log/nerr.log",'a+'); fwrite($fsucc,"移动成功,我们系统失败\r\n"); fwrite($fcancel,"移动失败,我们系统成功\r\n"); fwrite($ferr,"网络错误,系统请求失败\r\n"); $reader = new statistics\order_reader(); $gen = $reader->refill_vr_reader($cond); $count = 0; foreach ($gen as $item) { Log::record("order_sn={$item['order_sn']}", Log::DEBUG); $count += 1; $chname = $item['channel_name']; $provider = $this->getProvider($chname); [$status, $order_state, $charge_id] = $provider->query($item); if($status) { $db_state = intval($item['order_state']); if($order_state !== $db_state) { if ($order_state == ORDER_STATE_SUCCESS) { fwrite($fsucc, "{$item['order_sn']} {$order_state} {$db_state}\r\n"); } else { fwrite($fcancel, "{$item['order_sn']} {$order_state} {$db_state}\r\n"); } } } else { fwrite($ferr, "{$item['order_sn']}\r\n"); } } Log::record("all item is $count",Log::DEBUG); fclose($fsucc); fclose($fcancel); fclose($ferr); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefund::testCheckZY)( .*)?$/" --test-suffix TestRefund.php /var/www/html/test public function testCheckZY() { $cond['refill_order.order_time'] = [['egt', strtotime('2023-06-01')], ['lt', strtotime('2023-06-09')], 'and']; $cond['vr_order.add_time'] = [['egt', strtotime('2023-06-01')], ['lt', strtotime('2023-06-09')], 'and']; $cond['inner_status'] = 0; $cond['vr_order.order_state'] = 0; $cond['vr_order.store_id'] = ['in',[33,45]]; $this->check_order($cond); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefund::testCheckYZ)( .*)?$/" --test-suffix TestRefund.php /var/www/html/test public function testCheckYZ() { $cond['refill_order.order_time'] = [['egt', strtotime('2023-05-01')], ['lt', strtotime('2023-06-01')], 'and']; $cond['vr_order.add_time'] = [['egt', strtotime('2023-05-01')], ['lt', strtotime('2023-06-02')], 'and']; $cond['inner_status'] = 0; $cond['vr_order.store_id'] = ['in',[319,327]]; $this->check_order($cond); } }