Explorar el Código

for mprofit_ratios

stanley-king hace 2 años
padre
commit
ec9db3580d

+ 2 - 2
docker/compose/homecuda/statcalc/docker-compose.yml

@@ -10,7 +10,7 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - /mnt/stdata:/var/www/html/data/stdata
     container_name: "panda-mamount"
-    command: [ 'python','mamount.py', '-h', '192.168.3.104', '-p', '6379' ]
+    command: ['python','mamount.py', '-h', '192.168.3.104', '-p', '6379']
 
   mpratios:
     image: pycpu:3.7.10
@@ -21,4 +21,4 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - /mnt/stdata:/var/www/html/data/stdata
     container_name: "panda-mpratios"
-    command: [ 'python','mprofit_ratio.py', '-h', '192.168.3.104', '-p', '6379' ]
+    command: ['python','mprofit_ratio.py', '-h', '192.168.3.104', '-p', '6379']

+ 11 - 1
docker/compose/xyz/statcalc/docker-compose.yml

@@ -9,4 +9,14 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - /mnt/stdata:/var/www/html/data/stdata
     container_name: "panda-mamount"
-    command: [ 'python','mamount.py', '-h', '172.26.105.125', '-p', '6379' ]
+    command: ['python','mamount.py', '-h', '172.26.105.125', '-p', '6379']
+
+  mpratios:
+    image: pycpu:3.7.10
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - /mnt/shoplog:/var/www/html/data/log
+      - /mnt/stdata:/var/www/html/data/stdata
+    container_name: "panda-mpratios"
+    command: ['python','mprofit_ratio.py', '-h', '172.26.105.125', '-p', '6379']

+ 7 - 7
helper/refill/policy/quaility.php

@@ -329,14 +329,12 @@ class Quality
         {
             $times_qualities = $times_checker(true, $all_qualities, $used_times);
             $time_qualities = $timeout_checker(true, $all_qualities, $left_time);
-
             $pre_qualities = array_intersect($times_qualities, $time_qualities, $all_qualities);
-            if(count($pre_qualities) < count($all_qualities))
-            {
+
+            if (count($pre_qualities) < count($all_qualities)) {
                 $match_ratio = $this->mRatioCtl->ratio_match($mchid, $org_quality, $card_type, $spec, $all_qualities);
 
-            }
-            else {
+            } else {
                 $match_ratio = true;
             }
 
@@ -346,6 +344,8 @@ class Quality
             } else {
                 $timeing_qualities = $all_qualities;
             }
+
+            $cur_qualities = array_intersect($pre_qualities, $timeing_qualities);
         }
         else {
             $match_ratio = true;
@@ -354,10 +354,10 @@ class Quality
 
         if ($match_ratio) {
             $all = $this->qualities($org_quality);
-            $all_qualities = PolicyUtil::mixed_remove_last($org_quality, $cur_qualities, $all);
+            $cur_qualities = PolicyUtil::mixed_remove_last($org_quality, $cur_qualities, $all);
         }
 
-        return [$all_qualities,$match_ratio];
+        return [$cur_qualities,$match_ratio];
 
     }
 

+ 1 - 1
plot/refill/MProfitRatioCalc.py

@@ -33,7 +33,7 @@ class MProfitRatioCalc(MerchantCalcBase):
         detail = dict()
 
         for mchid, period, formula in mixed_ratios:
-            end_time = int(time.time() - 86400 * 10)
+            end_time = int(time.time())
             days, start_time, end_time = self.calc_time(reader, end_time - period, end_time)
             if len(days) == 0:
                 continue

+ 0 - 1
test/TestRefillPolicy.php

@@ -2,7 +2,6 @@
 
 
 use PHPUnit\Framework\TestCase;
-use refill\mratio_controlex;
 
 define('APP_ID', 'refill_stat');
 define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));

+ 34 - 1
test/TestSmartCard.php

@@ -15,7 +15,40 @@ class TestSmartCard extends TestCase
     public static function setUpBeforeClass(): void
     {
         Base::run_util();
-        refill\RefillFactory::instance();
     }
 
+    public function testGenChannelCode()
+    {
+        $result = [];
+        $name_count = ['huanxishuyu' => 10];
+        foreach ($name_count as $name => $count)
+        {
+            $codes = $this->gen_code($name,$count);
+            $result[$name] = $codes;
+        }
+
+        $x = $result;
+    }
+
+    private function gen_code($name,$count)
+    {
+        $gendor = function ($str) {
+            $code = md5($str);
+            $code = substr($code,0,12);
+            return $code;
+        };
+
+        $base = 'https://ylapi.xyzshops.cn/chinatelecom/#/starcard?code=';
+
+        $result = [];
+        for ($i = 0; $i < $count; $i++)
+        {
+            $key = "{$name}-{$i}";
+            $code = $gendor($key);
+            $link = $base . $code;
+
+            $result[$key] = ['code' => $code,'link' => $link];
+        }
+        return $result;
+    }
 }