Преглед на файлове

Merge branch 'raccount' into rchannel

xiaoyu преди 3 години
родител
ревизия
fd82baee27

+ 31 - 31
data/config/xyz/refill.ini.php

@@ -2529,49 +2529,49 @@ $guochuang_nation_phone = ['name' => 'guochuang_nation', 'store_id' => 121, 'qua
     'amount' => [
         1  => [
             ['goods_id' => 7051, 'price' => 1.021, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7051, 'price' => 1.046, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7051, 'price' => 1.031, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         2  => [
             ['goods_id' => 7052, 'price' => 2.042, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7052, 'price' => 2.092, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7052, 'price' => 2.062, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         3  => [
             ['goods_id' => 7053, 'price' => 3.063, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7053, 'price' => 3.138, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7053, 'price' => 3.093, 'quality' => 2, 'card_type' => 'chinatelecom']
 
         ],
         4  => [
-            ['goods_id' => 7054, 'price' => 4.084, 'quality' => 2, 'card_type' => 'chinaunicom']
+            ['goods_id' => 7054, 'price' => 4.124, 'quality' => 2, 'card_type' => 'chinaunicom']
         ],
         5  => [
             ['goods_id' => 7055, 'price' => 5.305, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7055, 'price' => 5.105, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7055, 'price' => 5.155, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7055, 'price' => 5.255, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         6  => [
             ['goods_id' => 7056, 'price' => 6.306, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7056, 'price' => 6.126, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7056, 'price' => 6.186, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7056, 'price' => 6.2562, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         7  => [
             ['goods_id' => 7057, 'price' => 7.308, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7057, 'price' => 7.147, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7057, 'price' => 7.217, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7057, 'price' => 7.2569, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         8  => [
             ['goods_id' => 7058, 'price' => 8.308, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7058, 'price' => 8.168, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7058, 'price' => 8.248, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7058, 'price' => 8.2584, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         9  => [
             ['goods_id' => 7059, 'price' => 9.3105, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7059, 'price' => 9.189, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7059, 'price' => 9.279, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7059, 'price' => 9.2592, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
         10 => [
             ['goods_id' => 7060, 'price' => 10.31, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7060, 'price' => 10.14, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7060, 'price' => 10.11, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7060, 'price' => 10.26, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         20 => [
@@ -2581,27 +2581,27 @@ $guochuang_nation_phone = ['name' => 'guochuang_nation', 'store_id' => 121, 'qua
         ],
         30 => [
             ['goods_id' => 7062, 'price' => 30.33, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7062, 'price' => 30.06, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7062, 'price' => 30.024, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7062, 'price' => 30.33, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         50 => [
             ['goods_id' => 7063, 'price' => 50.125, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7063, 'price' => 50.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7063, 'price' => 50.04, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7063, 'price' => 50.35, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         100 => [
             ['goods_id' => 7064, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7064, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7064, 'price' => 100.08, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7064, 'price' => 100.4, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         200 => [
             ['goods_id' => 7065, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7065, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7065, 'price' => 200.16, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7065, 'price' => 200.46, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         300 => [
             ['goods_id' => 7066, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 7066, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7066, 'price' => 300.24, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 7066, 'price' => 300.69, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
         500 => [
@@ -3448,27 +3448,27 @@ $yiqian_phone = ['name' => 'yiqian', 'store_id' => 158,'qualitys' => '2',
 //        ]
         //周末高价
         100 => [
-            ['goods_id' => 7337, 'price' => 100.1, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7337, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 7337, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7337, 'price' => 100, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7337, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
         200 => [
-            ['goods_id' => 7338, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7338, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 7338, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7338, 'price' => 200, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7338, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
         300 => [
-            ['goods_id' => 7339, 'price' => 300.3, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7339, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 7339, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7339, 'price' => 300, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7339, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
         500 => [
-            ['goods_id' => 7340, 'price' => 500.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7340, 'price' => 501, 'quality' => 2, 'card_type' => 'chinamobile'],
             ['goods_id' => 7340, 'price' => 499, 'quality' => 2, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7340, 'price' => 500, 'quality' => 2, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7340, 'price' => 501, 'quality' => 2, 'card_type' => 'chinatelecom']
         ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
@@ -4032,22 +4032,22 @@ $yamiao_normal_phone = ['name' => 'yamiao_normal', 'store_id' => 172, 'qualitys'
         30 => [
             ['goods_id' => 7465, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7465, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7465, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinatelecom'],
+            ['goods_id' => 7465, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinatelecom'],
         ],
         50 => [
             ['goods_id' => 7466, 'price' => 47.95, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7466, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7466, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7466, 'price' => 47.85, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         100 => [
             ['goods_id' => 7467, 'price' => 95.9, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7467, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7467, 'price' => 95, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7467, 'price' => 95.7, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         200 => [
             ['goods_id' => 7468, 'price' => 191.8, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7468, 'price' => 191, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7468, 'price' => 190, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7468, 'price' => 191.4, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         300 => [
             ['goods_id' => 7469, 'price' => 287.1, 'quality' => 1, 'card_type' => 'chinamobile'],
@@ -4407,22 +4407,22 @@ $chizeng_normal_phone = ['name' => 'chizeng_normal', 'store_id' => 182,'qualitys
         30 => [
             ['goods_id' => 7538, 'price' => 28.74, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7538, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7538, 'price' => 28.71, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7538, 'price' => 28.65, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         50 => [
             ['goods_id' => 7539, 'price' => 47.9, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7539, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7539, 'price' => 47.85, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7539, 'price' => 47.75, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         100 => [
             ['goods_id' => 7540, 'price' => 95.8, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7540, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7540, 'price' => 95.7, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7540, 'price' => 95.5, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         200 => [
             ['goods_id' => 7541, 'price' => 191.6, 'quality' => 1, 'card_type' => 'chinamobile'],
             ['goods_id' => 7541, 'price' => 191, 'quality' => 1, 'card_type' => 'chinaunicom'],
-            ['goods_id' => 7541, 'price' => 191.4, 'quality' => 1, 'card_type' => 'chinatelecom']
+            ['goods_id' => 7541, 'price' => 191, 'quality' => 1, 'card_type' => 'chinatelecom']
         ],
         300 => [
             ['goods_id' => 7542, 'price' => 287.4, 'quality' => 1, 'card_type' => 'chinamobile'],

+ 2 - 1
docker/compose/xyz/conf/crontab/slave_root

@@ -16,6 +16,7 @@
 
 */1    *   *   *   *   php /var/www/html/crontab/index.php minutes update_channel_balance
 0   1   *   *   *   php /var/www/html/crontab/index.php date refill_clear
+0   5   *   *   *   php /var/www/html/crontab/index.php sh /var/www/html/util/purge.sh
 1   0   *   *   *   php /var/www/html/crontab/index.php date merchant_nightime
 1   6   *   *   *   php /var/www/html/crontab/index.php date merchant_daytime
-0   0    *   *   *   php /var/www/html/crontab/index.php date merchant_available
+#0   0    *   *   *   php /var/www/html/crontab/index.php date merchant_available

BIN
helper/refill/api/xyz/guochuang/20220304陕西电信调价.png


+ 1 - 1
helper/refill/api/xyz/guochuang/config.php

@@ -89,7 +89,7 @@ class config
         "5-10-14" => 10.04, "5-20-14" => 20.08, "5-30-14" => 30.12, "5-50-14" => 50.2, "5-100-14" => 100.3, "5-200-14" => 200.6, "5-300-14" => 300.9, "5-500-14" => 501.5,//江西 14
         "5-20-23" => 20.08, "5-30-23" => 30.12, "5-50-23" => 50.2, "5-100-23" => 100.4, "5-200-23" => 200.8, "5-300-23" => 301.2, "5-500-23" => 502,//四川 23
         //电信
-        "6-10-27" => 9.95, "6-20-27" => 19.9, "6-30-27" => 29.85, "6-50-27" => 49.75, "6-100-27" => 99.5, "6-200-27" => 199, "6-300-27" => 298.5, "6-500-27" => 497.5,//陕西 27
+        "6-10-27" => 9.94, "6-20-27" => 19.88, "6-30-27" => 29.82, "6-50-27" => 49.7, "6-100-27" => 99.4, "6-200-27" => 198.8, "6-300-27" => 298.5, "6-500-27" => 497.5,//陕西 27
         "6-10-4" => 9.935, "6-20-4" => 19.87, "6-30-4" => 29.805, "6-50-4" => 49.675, "6-100-4" => 99.35, "6-200-4" => 198.7, "6-300-4" => 298.05, "6-500-4" => 496.75,//山西 4
         "6-10-18" => 10.13, "6-20-18" => 20.26, "6-30-18" => 30.39, "6-50-18" => 50.15, "6-100-18" => 100.3, "6-200-18" => 200.6, "6-300-18" => 300.9, "6-500-18" => 501.5,//湖南 18
         "6-10-15" => 10.21, "6-20-15" => 20.22, "6-30-15" => 30.231, "6-50-15" => 50.25, "6-100-15" => 100.3, "6-200-15" => 200.3, "6-300-15" => 300.45, "6-500-15" => 500.75,//山东 15

+ 5 - 5
test/TestRefillClear.php

@@ -71,10 +71,10 @@ class TestRefillClear extends TestCase
     //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillClear::test202203)( .*)?$/" --test-suffix TestRefillClear.php /var/www/html/test
     public function test202203()
     {
-        $start_date = strtotime('2022-03-02');
-        $end_date   = strtotime('2022-03-03');
+        $start_date = strtotime('2022-03-04');
+        $end_date   = strtotime('2022-03-05');
         $clear = new refill\order_clear();
-        $clear->clear($start_date,$end_date,1286179);
+        $clear->clear($start_date,$end_date);
     }
 
     private function earlist_orderday()
@@ -114,8 +114,8 @@ class TestRefillClear extends TestCase
     //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillClear::testLog202203)( .*)?$/" --test-suffix TestRefillClear.php /var/www/html/test
     public function testLog202203()
     {
-        $start_date = strtotime('2022-03-01 13:55:01');
-        $end_date = strtotime('2022-03-03');
+        $start_date = strtotime('2022-03-03');
+        $end_date = strtotime('2022-03-05');
         $clear = new refill\pdlog_clear();
         $clear->clear($start_date,$end_date);
     }

+ 2 - 1
test/TestRefillCommand.php

@@ -10,6 +10,7 @@ require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_CORE_PATH . '/lrlz.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
 
+require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
 require_once(BASE_HELPER_PATH . '/refill/ops/order_clear.php');
 require_once(BASE_HELPER_PATH . '/refill/ops/pdlog_clear.php');
 
@@ -24,7 +25,7 @@ class TestRefillCommand extends TestCase
     public function testRefillStat()
     {
         $dates = [
-            '2022-02-22'
+            '2022-03-04'
         ];
         $refill = new statistics\stat_refill();
         $refill->restat($dates);

+ 0 - 2
test/TestTime.php

@@ -12,8 +12,6 @@ define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
 require_once(BASE_ROOT_PATH . '/global.php');
 require_once(BASE_CORE_PATH . '/lrlz.php');
 require_once(BASE_ROOT_PATH . '/fooder.php');
-
-require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/stat_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/util_helper.php');
 require_once(BASE_ROOT_PATH . '/helper/refill/functional.php');

+ 82 - 4
util/purge.sh

@@ -2,18 +2,96 @@
 # 假设将sakila数据库名改为new_sakila
 # MyISAM直接更改数据库目录下的文件即可
 
+
+
+declare -i cur_diff=0 min_diff=3600
+
+time_diff() {
+  cur_sec=`date '+%s'`
+  echo $cur_sec
+
+  today=$(date "+%Y-%m-%d")
+  today_time=`date -d "$today" +%s`
+  echo $today_time
+
+  cur_diff=`expr $cur_sec - $today_time`
+}
+
+time_diff
+echo $cur_diff,${min_diff}
+
+if [[ $cur_diff -gt ${min_diff} ]]; then
+  echo 'can purge'
+else
+  echo '请等到凌晨一点后删除'
+  exit
+fi
+
+function slave_running() {
+    ra=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_IO_Running:`
+    rb=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_SQL_Running:`
+
+    a=${ra#*:}
+    b=${rb#*:}
+    a=`echo $a | xargs`
+    b=`echo $b | xargs`
+
+    if [[ $a == 'Yes' &&  $b == 'Yes' ]];then
+        return 1
+    else
+      echo a,b
+      return 0
+    fi
+}
+
+function slave_behind_match() {
+    r=`mysql -uroot -pXTZ@shop@951688 --host=$host -e "show slave status\G; " | grep Seconds_Behind_Master:`
+    ssecs=${r#*:}
+    secs=`echo $ssecs | xargs`
+    echo Seconds_Behind_Master = $secs
+
+    diff=`expr $cur_diff - 3600`
+
+    if [[ $secs < $diff ]];then
+        return 1
+    else
+      return 0
+    fi
+}
+
 #master = '172.26.80.10'
 slave_hosts=(172.26.80.8 172.26.80.6)
+allhosts=(172.26.80.10 172.26.80.8 172.26.80.6)
 
 # shellcheck disable=SC2068
 for host in ${slave_hosts[@]}
 do
   echo $host
-  result=`mysql -uroot -pXTZ@shop@951688 --host=$host -e "show slave status\G; " | grep Seconds_Behind_Master:`
-  echo $result
-  secs=${result#'*:'}
-  echo $secs
+  slave_running $host
+  running=$?
+
+  if [[ $running == 0 ]];then
+    echo "slave ${host} has stoped"
+    exit
+  fi
+
+  slave_behind_match $host
+  behind_match=$?
+
+  if [[ $behind_match == 0 ]];then
+    echo "slave ${host} 延迟太大"
+    exit
+  fi
+  echo $host can purge
 done
 
+today=$(date "+%Y-%m-%d")
+command="PURGE master LOGS BEFORE '${today} 00:00:00';"
+
+# shellcheck disable=SC2068
+for host in ${allhosts[@]}
+do
+  mysql -uroot -pXTZ@shop@951688 --host=$host -e "$command"
+done
 
 

+ 19 - 7
util/test.sh

@@ -1,17 +1,29 @@
 #!/bin/bash
 
-cur_sec=`date '+%s'`
-echo $cur_sec
+declare -i cur_diff=0 min_diff=3600
 
-today=$(date "+%Y-%m-%d")
-init_time=`date -d "$today" +%s`
-echo $init_time
+time_diff() {
+  cur_sec=`date '+%s'`
+  echo $cur_sec
 
-delta=`expr $cur_sec - $init_time`
-echo $delta
+  today=$(date "+%Y-%m-%d")
+  today_time=`date -d "$today" +%s`
+  echo $today_time
 
+  cur_diff=`expr $cur_sec - $today_time`
+}
 
+time_diff
 
+# shellcheck disable=SC2154
+if [[ $cur_diff > ${min_diff} ]]; then
+  echo 'can purge'
+else
+  echo 'cannot purge'
+fi
 
 
+today=$(date "+%Y-%m-%d")
+command="PURGE master LOGS BEFORE '${today} 00:00:00'; "
+echo $command