add_balance('system', 0, 0, strtotime('2021-12-01'), 'order_time'); } //docker-compose run -d phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefillBalance::testInitBalance)( .*)?$/" --test-suffix TestRefillBalance.php /var/www/html/test public function testInitBalance() { $refill_balance = new statistics\refill_balance(); $refill_balance->stat_all(strtotime('2022-05-24')); } public function testFirstDay() { $refill_time = function ($type, $cid, $start) { if ($start != 0) { return $start; } if ($type == 'system') { $mod_refill = Model('refill_order'); $item = $mod_refill->table('refill_order')->field('order_id,order_time')->order('order_id asc')->find(); } elseif ($type == 'merchant') { $mod_refill = Model('refill_order'); $item = $mod_refill->table('refill_order')->field('order_id,order_time')->where(['mchid' => $cid])->order('order_id asc')->find(); } else { $mod_refill = Model('vr_order'); $item = $mod_refill->table('vr_order')->field('order_id,add_time')->where(['store_id' => $cid])->order('order_id asc')->find(); } $time = $item['order_time'] ?? 0; return $time; }; $order_start = $refill_time('system', 0, 0); $order_start = $refill_time('merchant', 1092, 0); $order_start = $refill_time('provider', 49, 0); } public function testMerchantPaytime() { $refill_time = function ($type, $cid, $start) { if ($start != 0) { return $start; } $mod_pay = Model(); if ($type == 'system') { $item = $mod_pay->table('refill_evidence') ->field('min(add_time) as add_time') ->find(); } elseif ($type == 'merchant') { $item = $mod_pay->table('refill_evidence') ->field('min(add_time) as add_time') ->where(['mchid' => $cid]) ->find(); } $time = $item['add_time'] ?? time(); Log::record(date('Y-m-d', $time),Log::DEBUG); return $time; }; $order_start = $refill_time('system', 0, 0); $order_start = $refill_time('merchant', 1092, 0); } public function testProviderPaytime() { $refill_time = function ($type, $cid, $start) { if ($start != 0) { return $start; } $mod_pay = Model(); if ($type == 'system') { $item = $mod_pay->table('provider_amount') ->field('min(add_time) as add_time') ->find(); } elseif ($type == 'merchant') { $item = $mod_pay->table('provider_amount') ->field('min(add_time) as add_time') ->where(['provider_id' => $cid]) ->find(); } $time = $item['add_time'] ?? time(); Log::record(date('Y-m-d', $time),Log::DEBUG); return $time; }; $order_start = $refill_time('system', 0, 0); $order_start = $refill_time('provider', 49, 0); } public function testBalanceConfig() { $x = wcache('balance-cfg', ['a' => 1,'b' => 2], 'refill-'); $y = rcache('balance-cfg','refill-','a,b'); $x = wcache('balance-cfg', ['adc' => serialize(['a' => 1,'b' => 2])], 'refill-'); $y = rcache('balance-cfg','refill-','adc'); $z = unserialize($y) ?? []; } }