1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- require_once(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
- require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
- class refill_successfulControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function provider_successfulOp()
- {
- $days = $this->successful_where();
- Tpl::output('days', $days);
- Tpl::showpage('provider.successful');
- }
- private function successful_where() {
- $url = BASE_SITE_URL . '/plot/days';
- Log::record("successful get timestamp url : {$url}", Log::DEBUG);
- $data = http_request($url);
- if(empty($data)) return [];
- preg_match_all('/\d{10}/', $data, $matches);
- $days = $matches[0];
- if(empty($days)) return [];
- $result = [];
- foreach ($days as $day) {
- $result[$day] = date("Y-m-d",$day);
- }
- return $result;
- }
- public function successful_time_get_whereOp(){
- $url = BASE_SITE_URL . '/plot/paths?time_stamp='.$_GET['timestamp'];
- Log::record("successful get where url : {$url}", Log::DEBUG);
- $data = http_request($url);
- if(empty($data)) {
- echo(json_encode(''));
- exit;
- }
- preg_match_all('/\d{10}\/[a-z]+\/\d{1,2}\/\d\/\d{2,4}/', $data, $matches);
- $conds = $matches[0];
- if(empty($conds)) {
- echo(json_encode(''));
- exit;
- }
- foreach ($conds as $cond) {
- $arr = explode('/',$cond);
- $chname[] = $arr[1];
- $qualitys[] = $arr[2];
- $card_types[] = $arr[3];
- $amount[] = intval($arr[4]);
- }
- $chnameData = array_unique($chname);
- sort($chnameData);
- $result['chname'] = $chnameData;
- $amountData = array_unique($amount);
- sort($amountData);
- $result['amount'] = $amountData;
- foreach (array_unique($card_types) as $card_type) {
- $card_typeData[$card_type] = $this->scard_type($card_type);
- }
- ksort($card_typeData);
- $result['card_type'] = $card_typeData;
- $quality_txt = [1=>'普充', 2=>'快充', 3=>'卡密', 4=>'三方', 5=>'慢充'];
- foreach (array_unique($qualitys) as $quality) {
- $qualityData[$quality] = $quality_txt[$quality];
- }
- ksort($qualityData);
- $result['quality'] = $qualityData;
- echo(json_encode($result));
- exit;
- }
- private function scard_type(int $card_type)
- {
- if ($card_type == 1) { //中石油
- return '中石油';
- } elseif ($card_type == 2) { //中石化
- return '中石化';
- } elseif ($card_type == 4) { //中国移动
- return '中国移动';
- } elseif ($card_type == 5) { //中国联通
- return '中国联通';
- } elseif ($card_type == 6) { //中国电信
- return '中国电信';
- } else {
- return 'unknown';
- }
- }
- }
|