refill_successful.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. include(BASE_CONFIG_PATH . CONFIG_PREFIX . '/refill.ini.php');
  3. require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
  4. require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
  5. class refill_successfulControl extends SystemControl
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function indexOp()
  12. {
  13. $type = $_GET['type'] ?? 'provider';
  14. $page = "{$type}.successful";
  15. $days = $this->successful_where($type);
  16. Tpl::output('days', $days);
  17. Tpl::showpage($page);
  18. }
  19. private function successful_where($type) {
  20. if ($type == 'system') {
  21. $url = BASE_SITE_URL . '/plot/mchdays';
  22. } else {
  23. $url = BASE_SITE_URL . '/plot/days';
  24. }
  25. Log::record("successful get timestamp url : {$url}", Log::DEBUG);
  26. $data = http_request($url);
  27. if(empty($data)) return [];
  28. preg_match_all('/\d{10}/', $data, $matches);
  29. $days = $matches[0];
  30. if(empty($days)) return [];
  31. $result = [];
  32. foreach ($days as $day) {
  33. $result[$day] = date("Y-m-d",$day);
  34. }
  35. return $result;
  36. }
  37. public function successful_time_get_whereOp(){
  38. $type = $_GET['type'] ?? 'provider';
  39. if ($type == 'system') {
  40. $url = BASE_SITE_URL . '/plot/mchpaths?time_stamp='.$_GET['timestamp'];
  41. } else {
  42. $url = BASE_SITE_URL . '/plot/paths?time_stamp='.$_GET['timestamp'];
  43. }
  44. Log::record("successful get where url : {$url}", Log::DEBUG);
  45. $data = http_request($url);
  46. if(empty($data)) {
  47. echo(json_encode(''));
  48. exit;
  49. }
  50. if($type == 'system') {
  51. preg_match_all('/\d{10}\/\d+\/\d{1,2}\/\d\/\d{2,4}/', $data, $matches);
  52. } else {
  53. preg_match_all('/\d{10}\/[a-z]+_*[a-z]*\/\d{1,2}\/\d\/\d{2,4}/', $data, $matches);
  54. }
  55. $conds = $matches[0];
  56. if(empty($conds)) {
  57. echo(json_encode(''));
  58. exit;
  59. }
  60. foreach ($conds as $cond) {
  61. $arr = explode('/',$cond);
  62. $chname[] = $arr[1];
  63. $qualitys[] = $arr[2];
  64. $card_types[] = $arr[3];
  65. $amount[] = intval($arr[4]);
  66. }
  67. $chnameData = array_unique($chname);
  68. sort($chnameData);
  69. $result['chname'] = $chnameData;
  70. if ($type == 'system') {
  71. $merchants = [];
  72. $merchant_list = Model('')->table('merchant')->limit(1000)->field('mchid,name,company_name')->select();
  73. foreach ($merchant_list as $key => $value) {
  74. $merchants[$value['mchid']] = $value;
  75. }
  76. foreach ($chnameData as $mchid) {
  77. $merchant_name = $merchants[$mchid]['company_name'] == '' ? $merchants[$mchid]['name'] : $merchants[$mchid]['company_name'];
  78. $mchname[$mchid] = "{$mchid}-{$merchant_name}";
  79. }
  80. asort($mchname);
  81. $result['chname'] = $mchname;
  82. }
  83. $amountData = array_unique($amount);
  84. sort($amountData);
  85. $result['amount'] = $amountData;
  86. foreach (array_unique($card_types) as $card_type) {
  87. $card_type_text = $this->scard_type($card_type);
  88. if($card_type_text != 'unknown') {
  89. $card_typeData[$card_type] = $card_type_text;
  90. }
  91. }
  92. ksort($card_typeData);
  93. $result['card_type'] = $card_typeData;
  94. $quality_txt = [\refill\Quality::Normal=>'普充', \refill\Quality::Quick=>'快充', \refill\Quality::CardKey=>'卡密',
  95. \refill\Quality::ThirdShop=>'三方', \refill\Quality::SlowTwentyFour=>'慢24', \refill\Quality::SlowSix=>'慢6', \refill\Quality::SlowTwo=>'慢2'];
  96. foreach (array_unique($qualitys) as $quality) {
  97. if(array_key_exists($quality, $quality_txt)) {
  98. $qualityData[$quality] = $quality_txt[$quality];
  99. }
  100. }
  101. ksort($qualityData);
  102. $result['quality'] = $qualityData;
  103. echo(json_encode($result));
  104. exit;
  105. }
  106. }