module('admin'); $user = \app\main\service\UserService::instance()->getUserModel()->getUserInfo($this->user_id); AdminKlUpdateService::instance()->setUser((new \app\main\model\object\UserObject())->bind($user)); $_SERVER['HTTP_X_FORWARDED_FOR'] = '112.90.77.178'; Ip::ip(); } public function testCheckScreenCity() { $data = Redis::instance()->sMembers("ALIC:1734"); var_dump($data); exit; $city = '深圳市'; $new = false; $pay = false; $op = 'and'; var_dump(IP::city()); $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertTrue($data); } public function testCheckScreenNew() { $city = false; $new = '>1'; $pay = false; $op = 'and'; $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertFalse($data); $cacheNew = CacheConstants::getNewUserCacheKey(AdminKlUpdateService::instance()->getUser()->channel_id); Redis::instance()->set($cacheNew, 2); $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertTrue($data); } public function testCheckScreenPay() { $city = false; $new = false; $pay = '>1'; $op = 'and'; $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertFalse($data); $cacheNew = CacheConstants::getPayUserLimitCacheKey(AdminKlUpdateService::instance()->getUser()->channel_id); Redis::instance()->set($cacheNew, 2); $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertTrue($data); } public function testCheckScreen() { $city = '深圳市'; $new = '<1'; $pay = '=1'; $op = 'and'; $data = AdminKlUpdateService::instance()->checkScreen($city, $new, $pay, $op)->data; $this->assertFalse($data); } public function testCheckFilterUserPayTime() { $order = app\main\service\OrderService::instance()->getOrderModel() ->where('user_id', $this->user_id) ->where('state', \app\main\constants\OrderContents::ORDER_STATE_PAID) ->order('finishtime', 'desc') ->find(); if ($order) { OrderService::instance()->getOrderModel() ->update(['finishtime' => time()], ['id' => $order['id']]); $pay_time_span = 1; $pay_type = false; $read_chapter_count = false; $shubi_left = false; $order_count = false; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); OrderService::instance()->getOrderModel() ->update(['finishtime' => time() - $pay_time_span * 3600], ['id' => $order['id']]); $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertFalse($data); } } public function testCheckFilterUserPayType() { $order = new OrderObject(); $order->bind(['book_id'=>1]); AdminKlUpdateService::instance()->setOrder($order); $pay_time_span = false; $pay_type = 'Z'; $read_chapter_count = false; $shubi_left = false; $order_count = false; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); $order->bind(['activity_id'=>1]); AdminKlUpdateService::instance()->setOrder($order); $pay_type = 'activity'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); } public function testCheckFilterUserChapter() { $pay_time_span = false; $pay_type = false; $read_chapter_count = '>5'; $shubi_left = false; $order_count = false; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); $read_chapter_count = '>100'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertFalse($data); } public function testCheckFilterUserShubi() { UserService::instance()->getUserModel()->setConnect($this->user_id)->update( ['kandian' => 101], ['id' => $this->user_id] ); $user = UserService::instance()->getUserModel()->getUserInfo($this->user_id, true); AdminKlUpdateService::instance()->setUser((new UserObject())->bind($user)); $pay_time_span = false; $pay_type = false; $read_chapter_count = false; $shubi_left = '>100'; $order_count = false; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); } public function testCheckFilterUserOrderCount() { $pay_time_span = false; $pay_type = false; $read_chapter_count = false; $shubi_left = false; $order_count = '>10'; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertTrue($data); $order_count = '>100'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertFalse($data); } public function testCheckFilterUser() { $order = new OrderObject(); $order->bind(['day'=>1]); AdminKlUpdateService::instance()->setOrder($order); $pay_time_span = 1; $pay_type = 'vip'; $read_chapter_count = '>2'; $shubi_left = '>10'; $order_count = '>10'; $op = 'and'; $data = AdminKlUpdateService::instance()->checkFilterUser($pay_time_span, $pay_type, $read_chapter_count, $shubi_left, $order_count, $op)->data; $this->assertFalse($data); } public function testCheckRegister() { $time = '>1'; $data = AdminKlUpdateService::instance()->checkFilterOrderAndRegister($time)->data; $this->assertTrue($data); } public function testOrderKlDouble() { $double_pay = 40; $new = false; $old = false; $data = AdminKlUpdateService::instance()->checkOrderKL($double_pay, $new, $old)->data; } public function testOrderKlNew() { $double_pay = false; $new = 40; $old = false; $data = AdminKlUpdateService::instance()->checkOrderKL($double_pay, $new, $old)->data; } public function testOrderKlOld() { $double_pay = false; $new = false; $old = 40; $data = AdminKlUpdateService::instance()->checkOrderKL($double_pay, $new, $old)->data; } public function testKlEq() { $rule_id = 12; $redisKey = KlConstants::REDIS_KEY_PREFIX.$rule_id; Redis::instance()->del($redisKey); $data = \app\main\service\KlService::instance()->getRuleConfig($rule_id); var_dump($data); } }