stanley-king vor 2 Jahren
Ursprung
Commit
2957f119df

+ 14 - 8
crontab/control/minutes.php

@@ -443,7 +443,8 @@ class minutesControl extends BaseCronControl
         while (true)
         {
             try {
-                $this->stat_util();
+                $this->_stat_util();
+                $this->_calc_arrears();
             } catch (Exception $ex) {
                 Log::record($ex->getMessage(), Log::ERR);
             }
@@ -452,15 +453,15 @@ class minutesControl extends BaseCronControl
         }
     }
 
-    private function stat_util()
+    private function _stat_util()
     {
         //查找最早的充值中的单子
-//        $update_earliest_ordertime = function () {
-//            $mod = Model('refill_detail');
-//            $time = $mod->getEarliestSendTime();
-//            wcache('earliest_sending', ['order_time' => $time], 'refill-stat-');
-//        };
-//        $update_earliest_ordertime();
+        $update_earliest_ordertime = function () {
+            $mod = Model('refill_detail');
+            $time = $mod->getEarliestSendTime();
+            wcache('stat-info', ['earliest_order_time' => $time], 'refill-');
+        };
+        $update_earliest_ordertime();
 
         $update_earliest_ordertime_bymerchant = function () {
             $mod = Model('refill_detail');
@@ -472,6 +473,11 @@ class minutesControl extends BaseCronControl
         $update_earliest_ordertime_bymerchant();
     }
 
+    private function _calc_arrears()
+    {
+        
+    }
+
     /**
      * 执行通用任务
      */

+ 2 - 1
docker/compose/homecuda/acc/docker-compose.yml

@@ -27,7 +27,8 @@ services:
     volumes:
       - ../../../../:/var/www/html
       - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+#      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /mnt/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
       - ../conf/php/mobile-spwan-start:/usr/local/bin/docker-spwan-start

+ 1 - 1
mobile/control/refill.php

@@ -72,7 +72,7 @@ class refillControl extends merchantControl
         }
 
         $amount = intval($_GET['amount']);
-        $card_no = $_GET['cardno'];
+        $card_no = trim($_GET['cardno']);
         $notify_url = $_GET['notifyurl'];
         $mch_order = $_GET['order_sn'];   //对方的order编号
         $quality = $_GET['quality'] ?? 0;

+ 10 - 3
plot/refill/MerchantCalc.py

@@ -1,3 +1,4 @@
+from redis.client import Redis
 
 from .DataStream import EMchPosmap as pos_map, span_days
 from .MerchantReader import MerchantReader
@@ -96,7 +97,7 @@ class MerchantCalc(object):
         sdays = [strtime(day) for day in days]
         logger.debug(sdays)
 
-        return reader,days, start_time, end_time
+        return reader, days, start_time, end_time
         pass
 
     def _send_amounts(self, rclient):
@@ -121,6 +122,12 @@ class MerchantCalc(object):
             else:
                 mamounts[_mchid]['send_amounts'] += send_amounts
                 mamounts[_mchid]['lack_amounts'] += lack_amounts
-        logger.debug(mamounts)
 
-        return mamounts
+        result = dict()
+        for _mchid, _val in mamounts.items():
+            _send_amounts = round(_val['send_amounts'], 2)
+            _lack_amounts = round(_val['lack_amounts'], 2)
+            result[_mchid] = {'send_amounts': _send_amounts, 'lack_amounts': _lack_amounts}
+
+        logger.debug(result)
+        return result

+ 1 - 1
plot/refill/algorithm.py

@@ -58,4 +58,4 @@ def calc_morder_lack(data, pos_map: type(EMchPosmap), start: int, end: int):
     lack_amounts = send_amounts * ratio
     logger.info("send_count=%d send_amounts=%.4f ratio=%.4f lack_amounts=%.4f", send_count, send_amounts, ratio, lack_amounts)
 
-    return round(send_amounts, 4), round(lack_amounts, 4)
+    return send_amounts, lack_amounts

+ 0 - 53
test/TestFcgi.php

@@ -1,53 +0,0 @@
-<?php
-
-
-use PHPUnit\Framework\TestCase;
-
-define('APP_ID', 'test');
-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_CORE_PATH . '/framework/function/http.php');
-require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
-require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
-
-class TestFcgi extends TestCase
-{
-    public static function setUpBeforeClass() : void
-    {
-        Base::run_util();
-    }
-
-    public function testEcho()
-    {
-        $phone = '13911129867';
-        $amount = 100;
-        $url = 'http://host.docker.internal' . "/mobile/index.php";
-        $params = ['mchid' => 1,
-            'cardno' => $phone,
-            'amount' => $amount,
-            "act" => "refill",
-            "op" => "add",
-            'order_sn' => $this->make_sn(),
-            'notifyurl' => "http://www.baidu.com"];
-        $proxy = new refill_proxy("1ff02223b771c0414468c8892151c602");
-        while (true) {
-            $resp = $proxy->send($url, $params);
-        }
-    }
-
-    private function make_sn()
-    {
-        return mt_rand(1000, 9999)
-            . sprintf('%010d', time())
-            . sprintf('%06d', (float)microtime() * 1000000);
-    }
-
-    public function testMicroTime()
-    {
-        [$micro,$time] = explode(' ',microtime());
-    }
-}

+ 90 - 0
test/TestRefillPhone.php

@@ -0,0 +1,90 @@
+<?php
+
+
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+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_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+
+class TestRefillPhone extends TestCase
+{
+    const LocalTest = 1;
+    const NetTest = 2;
+    const HomeCuda = 3;
+    const WorkCuda = 4;
+
+    const CurrentTest = self::HomeCuda;
+
+    private $mReqHost;
+    private $mKey;
+    private $mMchid;
+
+    public function __construct(?string $name = null, array $data = [], $dataName = '')
+    {
+        parent::__construct($name, $data, $dataName);
+
+        if (self::CurrentTest == self::LocalTest) {
+            $this->mReqHost = BASE_SITE_URL;
+            $this->mMchid = 1;
+            $this->mKey = '1ff02223b771c0414468c8892151c602';
+        }
+        elseif (self::CurrentTest == self::HomeCuda) {
+            $this->mReqHost = 'http://192.168.3.104';
+            $this->mMchid = 1092;
+            $this->mKey = '210fe406954220f56085997d6a4c5b80';
+        }
+    }
+
+    public static function setUpBeforeClass() : void
+    {
+        Base::run_util();
+    }
+
+    private function requrl() {
+        return $this->mReqHost . "/mobile/index.php";
+    }
+
+    public function testAdd()
+    {
+        $phone = '13911129867';
+        $amount = 100;
+
+        $url = $this->requrl();
+        $order_sn = $this->make_sn();
+        $order_sn = '      smsasdadad23';
+
+        $params = ['mchid' => $this->mMchid,
+            'cardno' => $phone,
+            'amount' => $amount,
+            "act" => "refill",
+            "op" => "add",
+            'order_sn' => $order_sn,
+            'notifyurl' => "http://www.baidu.com"];
+
+        $proxy = new refill_proxy($this->mKey);
+        for ($i = 0; $i < 10; $i++) {
+            $resp = $proxy->send($url, $params);
+            Log::record("resp={$resp}", Log::DEBUG);
+        }
+    }
+
+    private function make_sn()
+    {
+        return mt_rand(1000, 9999)
+            . sprintf('%010d', time())
+            . sprintf('%06d', (float)microtime() * 1000000);
+    }
+
+    public function testMicroTime()
+    {
+        [$micro,$time] = explode(' ',microtime());
+    }
+}