|
@@ -1,173 +1,190 @@
|
|
-<?php
|
|
|
|
-include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
|
|
|
|
-require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
|
|
|
|
-class refill_successfulControl extends SystemControl
|
|
|
|
-{
|
|
|
|
- private $SUCCESSFUL_URL = BASE_SITE_URL;
|
|
|
|
-
|
|
|
|
- public function __construct()
|
|
|
|
- {
|
|
|
|
- parent::__construct();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function indexOp()
|
|
|
|
- {
|
|
|
|
- $type = $_GET['type'] ?? 'provider';
|
|
|
|
- $page = "successful.{$type}";
|
|
|
|
- $days = $this->successful_where($type);
|
|
|
|
- Tpl::output('days', $days);
|
|
|
|
- Tpl::showpage($page);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function successful_where($type) {
|
|
|
|
- if ($type == 'system') {
|
|
|
|
- $url = $this->SUCCESSFUL_URL . '/plot/mchdays';
|
|
|
|
- } elseif($type == 'provider') {
|
|
|
|
- $url = $this->SUCCESSFUL_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(){
|
|
|
|
- $type = $_GET['type'] ?? 'provider';
|
|
|
|
- if ($type == 'system') {
|
|
|
|
- $url = $this->SUCCESSFUL_URL . '/plot/mchpaths?time_stamp='.$_GET['timestamp'];
|
|
|
|
- $pattern = '/\d{10}\/\d+\/\d{1,2}\/\d\/\d{2,4}/';
|
|
|
|
- } elseif($type == 'provider') {
|
|
|
|
- $pattern = '/\d{10}\/[a-z]+_*[a-z]*\/\d{1,2}\/\d\/\d{2,4}/';
|
|
|
|
- $url = $this->SUCCESSFUL_URL . '/plot/paths?time_stamp='.$_GET['timestamp'];
|
|
|
|
- }
|
|
|
|
- Log::record("successful get where url : {$url}", Log::DEBUG);
|
|
|
|
- $data = http_request($url);
|
|
|
|
- if(empty($data) || empty($pattern)) {
|
|
|
|
- echo(json_encode(''));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- preg_match_all($pattern, $data, $matches);
|
|
|
|
- $conds = $matches[0];
|
|
|
|
- if(empty($conds)) {
|
|
|
|
- echo(json_encode(''));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
- if ($type == 'system') {
|
|
|
|
- $merchants = [];
|
|
|
|
- $merchant_list = Model('')->table('merchant')->limit(1000)->field('mchid,name,company_name,time_out')->select();
|
|
|
|
- foreach ($merchant_list as $merchant) {
|
|
|
|
- $merchants[$merchant['mchid']] = $merchant;
|
|
|
|
- }
|
|
|
|
- foreach ($chnameData as $mchid) {
|
|
|
|
- $merchant_name = $merchants[$mchid]['company_name'] == '' ? $merchants[$mchid]['name'] : $merchants[$mchid]['company_name'];
|
|
|
|
- $mchname[$mchid] = "{$mchid}-{$merchant_name}-{$merchants[$mchid]['time_out']}";
|
|
|
|
- }
|
|
|
|
- asort($mchname);
|
|
|
|
- $result['chname'] = $mchname;
|
|
|
|
- } elseif($type == 'provider') {
|
|
|
|
- $providers = [];
|
|
|
|
- $provider_list = $this->providers();
|
|
|
|
- foreach ($provider_list as $provider) {
|
|
|
|
- $providers[$provider['name']] = $provider;
|
|
|
|
- }
|
|
|
|
- foreach ($chnameData as $provider_name) {
|
|
|
|
- $store_names[$provider_name] = $providers[$provider_name]['store_name'];
|
|
|
|
- }
|
|
|
|
- $result['chname'] = $store_names;
|
|
|
|
- }
|
|
|
|
- $amountData = array_unique($amount);
|
|
|
|
- sort($amountData);
|
|
|
|
- $result['amount'] = $amountData;
|
|
|
|
-
|
|
|
|
- foreach (array_unique($card_types) as $card_type) {
|
|
|
|
- $card_type_text = $this->scard_type($card_type);
|
|
|
|
- if($card_type_text != 'unknown') {
|
|
|
|
- $card_typeData[$card_type] = $card_type_text;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ksort($card_typeData);
|
|
|
|
- $result['card_type'] = $card_typeData;
|
|
|
|
-
|
|
|
|
- $quality_txt = [refill\Quality::Normal=>'普充', refill\Quality::Quick=>'快充', refill\Quality::CardKey=>'卡密',
|
|
|
|
- refill\Quality::ThirdShop=>'三方', refill\Quality::SlowTwentyFour=>'慢24', refill\Quality::SlowSix=>'慢6', refill\Quality::SlowTwo=>'慢2'];
|
|
|
|
- foreach (array_unique($qualitys) as $quality) {
|
|
|
|
- if(array_key_exists($quality, $quality_txt)) {
|
|
|
|
- $qualityData[$quality] = $quality_txt[$quality];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- ksort($qualityData);
|
|
|
|
- $result['quality'] = $qualityData;
|
|
|
|
- echo(json_encode($result));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function merchant_ratiosOp()
|
|
|
|
- {
|
|
|
|
- //0:成功单,1:失败单,2:成功率
|
|
|
|
- $ins = Cache::getInstance('cacheredis');
|
|
|
|
- $json = $ins->get_org('merchant_card_type_ratios');
|
|
|
|
- $data = json_decode($json);
|
|
|
|
- $data = $this->object_array($data);
|
|
|
|
- $result = [];
|
|
|
|
- $stats = [];
|
|
|
|
- $card_types = ['YD', 'LT', 'DX'];
|
|
|
|
- if(!empty($data)) {
|
|
|
|
- $merchant_list = $this->merchants();
|
|
|
|
-
|
|
|
|
- foreach ($merchant_list as $value) {
|
|
|
|
- $mchid = $value['mchid'];
|
|
|
|
- if(array_key_exists($mchid, $data) && is_array($data[$mchid])) {
|
|
|
|
- $result[$mchid]['ratio'] = $data[$mchid];
|
|
|
|
- $result[$mchid]['company_name'] = $value['company_name'];
|
|
|
|
- $result[$mchid]['time_out'] = $this->elapse_time($value['time_out']);
|
|
|
|
-
|
|
|
|
- foreach ($card_types as $type) {
|
|
|
|
- if($data[$mchid][$type][3600][0] + $data[$mchid][$type][3600][1] > 0) {
|
|
|
|
- $stats[$type]['success'] += $data[$mchid][$type][3600][0];
|
|
|
|
- $stats[$type]['ratio'] += $data[$mchid][$type][3600][2];
|
|
|
|
- $stats[$type]['count'] += 1;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Tpl::output('stats', $stats);
|
|
|
|
- Tpl::output('count', count($result));
|
|
|
|
- }
|
|
|
|
- Tpl::output('list', $result);
|
|
|
|
- Tpl::showpage('merchant.ratios');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private function object_array($array)
|
|
|
|
- {
|
|
|
|
- if(is_object($array))
|
|
|
|
- {
|
|
|
|
- $array = (array)$array;
|
|
|
|
- }
|
|
|
|
- if(is_array($array))
|
|
|
|
- {
|
|
|
|
- foreach($array as $key=>$value)
|
|
|
|
- {
|
|
|
|
- $array[$key] = $this->object_array($value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return $array;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+<?php
|
|
|
|
+include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
|
|
|
|
+require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
|
|
|
|
+class refill_analysisControl extends SystemControl
|
|
|
|
+{
|
|
|
|
+ private $ANALYSIS_URL = BASE_SITE_URL;
|
|
|
|
+
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function indexOp()
|
|
|
|
+ {
|
|
|
|
+ $type = $_GET['type'] ?? 'provider';
|
|
|
|
+ $page = "analysis.{$type}";
|
|
|
|
+ $days = $this->analysis_where($type);
|
|
|
|
+ Tpl::output('days', $days);
|
|
|
|
+ Tpl::showpage($page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function analysis_where($type) {
|
|
|
|
+ if ($type == 'system') {
|
|
|
|
+ $url = $this->ANALYSIS_URL . '/plot/mchdays';
|
|
|
|
+ } elseif($type == 'provider') {
|
|
|
|
+ $url = $this->ANALYSIS_URL . '/plot/days';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Log::record("analysis 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 analysis_time_get_whereOp(){
|
|
|
|
+ $type = $_GET['type'] ?? 'provider';
|
|
|
|
+ if ($type == 'system') {
|
|
|
|
+ $url = $this->ANALYSIS_URL . '/plot/mchpaths?time_stamp='.$_GET['timestamp'];
|
|
|
|
+ $pattern = '/\d{10}\/\d+\/\d{1,2}\/\d\/\d{2,4}/';
|
|
|
|
+ } elseif($type == 'provider') {
|
|
|
|
+ $pattern = '/\d{10}\/[a-z]+_*[a-z]*\/\d{1,2}\/\d\/\d{2,4}/';
|
|
|
|
+ $url = $this->ANALYSIS_URL . '/plot/paths?time_stamp='.$_GET['timestamp'];
|
|
|
|
+ }
|
|
|
|
+ Log::record("analysis get where url : {$url}", Log::DEBUG);
|
|
|
|
+ $data = http_request($url);
|
|
|
|
+ if(empty($data) || empty($pattern)) {
|
|
|
|
+ echo(json_encode(''));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ preg_match_all($pattern, $data, $matches);
|
|
|
|
+ $conds = $matches[0];
|
|
|
|
+ if(empty($conds)) {
|
|
|
|
+ echo(json_encode(''));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ if ($type == 'system') {
|
|
|
|
+ $merchants = [];
|
|
|
|
+ $merchant_list = Model('')->table('merchant')->limit(1000)->field('mchid,name,company_name,time_out')->select();
|
|
|
|
+ foreach ($merchant_list as $merchant) {
|
|
|
|
+ $merchants[$merchant['mchid']] = $merchant;
|
|
|
|
+ }
|
|
|
|
+ foreach ($chnameData as $mchid) {
|
|
|
|
+ $merchant_name = $merchants[$mchid]['company_name'] == '' ? $merchants[$mchid]['name'] : $merchants[$mchid]['company_name'];
|
|
|
|
+ $mchname[$mchid] = "{$mchid}-{$merchant_name}-{$merchants[$mchid]['time_out']}";
|
|
|
|
+ }
|
|
|
|
+ asort($mchname);
|
|
|
|
+ $result['chname'] = $mchname;
|
|
|
|
+ } elseif($type == 'provider') {
|
|
|
|
+ $providers = [];
|
|
|
|
+ $provider_list = $this->providers();
|
|
|
|
+ foreach ($provider_list as $provider) {
|
|
|
|
+ $providers[$provider['name']] = $provider;
|
|
|
|
+ }
|
|
|
|
+ foreach ($chnameData as $provider_name) {
|
|
|
|
+ $store_names[$provider_name] = $providers[$provider_name]['store_name'];
|
|
|
|
+ }
|
|
|
|
+ $result['chname'] = $store_names;
|
|
|
|
+ }
|
|
|
|
+ $amountData = array_unique($amount);
|
|
|
|
+ sort($amountData);
|
|
|
|
+ $result['amount'] = $amountData;
|
|
|
|
+
|
|
|
|
+ foreach (array_unique($card_types) as $card_type) {
|
|
|
|
+ $card_type_text = $this->scard_type($card_type);
|
|
|
|
+ if($card_type_text != 'unknown') {
|
|
|
|
+ $card_typeData[$card_type] = $card_type_text;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ksort($card_typeData);
|
|
|
|
+ $result['card_type'] = $card_typeData;
|
|
|
|
+
|
|
|
|
+ $quality_txt = [refill\Quality::Normal=>'普充', refill\Quality::Quick=>'快充', refill\Quality::CardKey=>'卡密',
|
|
|
|
+ refill\Quality::ThirdShop=>'三方', refill\Quality::SlowTwentyFour=>'慢24', refill\Quality::SlowSix=>'慢6', refill\Quality::SlowTwo=>'慢2'];
|
|
|
|
+ foreach (array_unique($qualitys) as $quality) {
|
|
|
|
+ if(array_key_exists($quality, $quality_txt)) {
|
|
|
|
+ $qualityData[$quality] = $quality_txt[$quality];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ksort($qualityData);
|
|
|
|
+ $result['quality'] = $qualityData;
|
|
|
|
+ echo(json_encode($result));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function merchant_ratiosOp()
|
|
|
|
+ {
|
|
|
|
+ //0:成功单,1:失败单,2:成功率
|
|
|
|
+ $ins = Cache::getInstance('cacheredis');
|
|
|
|
+ $json = $ins->get_org('merchant_card_type_ratios');
|
|
|
|
+ $data = json_decode($json);
|
|
|
|
+ $data = $this->object_array($data);
|
|
|
|
+ $result = [];
|
|
|
|
+ $stats = [];
|
|
|
|
+ $card_types = ['YD', 'LT', 'DX'];
|
|
|
|
+ if(!empty($data)) {
|
|
|
|
+ $merchant_list = $this->merchants();
|
|
|
|
+
|
|
|
|
+ foreach ($merchant_list as $value) {
|
|
|
|
+ $mchid = $value['mchid'];
|
|
|
|
+ if(array_key_exists($mchid, $data) && is_array($data[$mchid])) {
|
|
|
|
+ $result[$mchid]['ratio'] = $data[$mchid];
|
|
|
|
+ $result[$mchid]['company_name'] = $value['company_name'];
|
|
|
|
+ $result[$mchid]['time_out'] = $this->elapse_time($value['time_out']);
|
|
|
|
+
|
|
|
|
+ foreach ($card_types as $type) {
|
|
|
|
+ if($data[$mchid][$type][3600][0] + $data[$mchid][$type][3600][1] > 0) {
|
|
|
|
+ $stats[$type]['success'] += $data[$mchid][$type][3600][0];
|
|
|
|
+ $stats[$type]['ratio'] += $data[$mchid][$type][3600][2];
|
|
|
|
+ $stats[$type]['count'] += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Tpl::output('stats', $stats);
|
|
|
|
+ Tpl::output('count', count($result));
|
|
|
|
+ }
|
|
|
|
+ Tpl::output('list', $result);
|
|
|
|
+ Tpl::showpage('merchant.ratios');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function new_versionOp()
|
|
|
|
+ {
|
|
|
|
+ Tpl::showpage('analysis.new_version');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function provider_dataOp()
|
|
|
|
+ {
|
|
|
|
+ $provider_list = $this->providers();
|
|
|
|
+ $result = [];
|
|
|
|
+ foreach ($provider_list as $value) {
|
|
|
|
+ $data['name'] = $value['store_name'] ?? $value['name'];
|
|
|
|
+ $data['value'] = $value['name'];
|
|
|
|
+ $result[] = $data;
|
|
|
|
+ }
|
|
|
|
+ echo json_encode($result);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function object_array($array)
|
|
|
|
+ {
|
|
|
|
+ if(is_object($array))
|
|
|
|
+ {
|
|
|
|
+ $array = (array)$array;
|
|
|
|
+ }
|
|
|
|
+ if(is_array($array))
|
|
|
|
+ {
|
|
|
|
+ foreach($array as $key=>$value)
|
|
|
|
+ {
|
|
|
|
+ $array[$key] = $this->object_array($value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $array;
|
|
|
|
+ }
|
|
|
|
+}
|