stanley-king 2 rokov pred
rodič
commit
43acd8027c

+ 0 - 57
crontab/control/minutes.php

@@ -447,7 +447,6 @@ class minutesControl extends BaseCronControl
             try {
                 $this->_update_earlist_send();
                 $this->_calc_arrears();
-                $this->_update_mixed_cfg();
 
             } catch (Exception $ex) {
                 Log::record($ex->getMessage(), Log::ERR);
@@ -617,62 +616,6 @@ class minutesControl extends BaseCronControl
         }
     }
 
-    private function _update_mixed_cfg()
-    {
-        $read_cfg = function ($cfg)
-        {
-            $lower_ratio = $cfg['lower_ratio'] ?? [];
-            if (empty($lower_ratio)) {
-                [$ratio, $period] = [0.0, 3600];
-            } else {
-                [$ratio, $period] = [$lower_ratio['ratio'], $lower_ratio['period']];
-            }
-
-            $profit_ratio = $cfg['profit_ratio'] ?? 0.0;
-            $profit_formula = $cfg['profit_formula'] ?? 'qts';
-
-            return ['ratio' => $ratio, 'period' => $period, 'profit_ratio' => $profit_ratio, 'profit_formula' => $profit_formula];
-        };
-
-        $mch_configs = function () use ($read_cfg)
-        {
-            $result = [];
-
-            $i = 0;
-            while (true)
-            {
-                $start = $i * 100;
-                $items = Model()->table('merchant')->where(['mchid' => ['gt', 0], 'merchant_state' => 1])->field('mchid,retry_times_cfg,quality')->order('mchid asc')->limit("{$start},100")->select();
-                if(empty($items)) {
-                    break;
-                }
-                $i++;
-
-                foreach ($items as $item)
-                {
-                    $mchid = intval($item['mchid']);
-                    $quality = intval($item['quality']);
-                    if($mchid <= 0 || $quality <= 0) continue;
-                    if (!PolicyUtil::mixed_quality($quality)) {
-                        continue;
-                    }
-
-                    $retry_times_cfg = unserialize($item['retry_times_cfg']);
-                    if(empty($retry_times_cfg)) continue;
-
-
-                    $result[$mchid] = $read_cfg($retry_times_cfg);
-                }
-            }
-
-            return $result;
-        };
-
-        $result = $mch_configs();
-        $val = json_encode($result);
-        wkcachex('stat-merchant-mixed', $val, 'refill-');
-    }
-
     /**
      * 执行通用任务
      */

+ 2 - 2
docker/compose/workcuda/admin/docker-compose.yml

@@ -20,13 +20,13 @@ services:
           cpus: '8'
 
   websrv:
-    image: php-fpm-ex:alpine
+    image: php-fpm:alpine
     ports:
       - 9000:9000
     volumes:
       - ../../../../:/var/www/html
       - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - ../conf/php-fpm/php-fpm.conf:/usr/local/etc/php-fpm.conf
       - /mnt/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log

+ 71 - 0
helper/message/pubevent.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace message;
+
+require_once(BASE_HELPER_PATH . '/refill/policy/PolicyUtil.php');
+
+use refill;
+
+class pubevent
+{
+    public function onRefillBefore()
+    {
+        $this->_update_mixed_cfg();
+    }
+
+    private function _update_mixed_cfg()
+    {
+        $read_cfg = function ($cfg)
+        {
+            $lower_ratio = $cfg['lower_ratio'] ?? [];
+            if (empty($lower_ratio)) {
+                [$ratio, $period] = [0.0, 3600];
+            } else {
+                [$ratio, $period] = [$lower_ratio['ratio'], $lower_ratio['period']];
+            }
+
+            $profit_ratio = $cfg['profit_ratio'] ?? 0.0;
+            $profit_formula = $cfg['profit_formula'] ?? 'qts';
+
+            return ['ratio' => $ratio, 'period' => $period, 'profit_ratio' => $profit_ratio, 'profit_formula' => $profit_formula];
+        };
+
+        $mch_configs = function () use ($read_cfg)
+        {
+            $result = [];
+
+            $i = 0;
+            while (true)
+            {
+                $start = $i * 100;
+                $items = Model()->table('merchant')->where(['mchid' => ['gt', 0], 'merchant_state' => 1])->field('mchid,retry_times_cfg,quality')->order('mchid asc')->limit("{$start},100")->select();
+                if(empty($items)) {
+                    break;
+                }
+                $i++;
+
+                foreach ($items as $item)
+                {
+                    $mchid = intval($item['mchid']);
+                    $quality = intval($item['quality']);
+                    if($mchid <= 0 || $quality <= 0) continue;
+                    if (!refill\PolicyUtil::mixed_quality($quality)) {
+                        continue;
+                    }
+
+                    $retry_times_cfg = unserialize($item['retry_times_cfg']);
+                    if(empty($retry_times_cfg)) continue;
+
+
+                    $result[$mchid] = $read_cfg($retry_times_cfg);
+                }
+            }
+
+            return $result;
+        };
+
+        $result = $mch_configs();
+        $val = json_encode($result);
+        wkcachex('stat-merchant-mixed', $val, 'refill-');
+    }
+}

+ 5 - 0
helper/message/publisher.php

@@ -8,6 +8,8 @@
 
 namespace message;
 
+require_once (BASE_ROOT_PATH . '/helper/message/pubevent.php');
+
 use Log;
 use Redis;
 
@@ -227,6 +229,9 @@ class publisher
     {
         Log::record(__METHOD__,Log::DEBUG);
         if($this->mConnected) {
+            $event = new pubevent();
+            $event->onRefillBefore();
+
             $this->mRedis->publish('refill',json_encode(['type'=>'channel','value' => 0]));
         }
     }