<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/5/25
 * Time: 下午3:55
 */

define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
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');

class TestStat extends PHPUnit_Framework_TestCase
{
    public static function setUpBeforeClass()
    {
        Base::run_util();
    }
    public function testBonusPaid()
    {
        $param = ['time' => time(),'use_type' => 2,'rate' => 30,'amount' => 50,'member_id' => 0];
        stat_helper::onUseBonus($param);
    }

    public function testMember()
    {
        $cur_date = new DateTime();
        $cur_date->setDate(2016,8,20);
        $inter = new DateInterval('P1D');
        $cur_date->sub($inter);
        stat_helper::onDaiyMember($cur_date->getTimestamp());
        stat_helper::onDaiyBonus($cur_date->getTimestamp());
        stat_helper::onDaiyOrder($cur_date->getTimestamp());
    }

    public function testSelfDiscount()
    {
        stat_helper::onInitSelfDiscount();
    }

    public function testInviteeDiscount()
    {
        stat_helper::onInitInviteesDiscount();
    }
    public function testDailySelfDicount()
    {
        $cur_date = new DateTime();
        $inter = new DateInterval('P1D');
        $cur_date->sub($inter);
        stat_helper::onDailySelfDiscount($cur_date->getTimestamp());
    }
    public function testDailyInviteeDiscount()
    {

    }
    private function inviter($mod_member,$member_id)
    {
        $members = $mod_member->field('inviter_id')->where(['member_id' => $member_id])->limit(false)->select();
        if(empty($members)) {
            return false;
        }

        return intval($members[0]['member_id']);
    }
    public function testOme()
    {
        $x = "3.1.7";
        $y = intval($x * 100 + 0.5);
    }
}
