12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace Vip\Lib;
- use Dever;
- class Member
- {
- public function get($uid, $cate_id = 1)
- {
- if (is_array($uid)) {
- $user = $uid;
- } else {
- $user = Dever::db('passport/user')->one($uid);
- }
- if ($user['mobile']) {
- $where['mobile'] = $user['mobile'];
- $source_type = Dever::input('source_type');
- if ($source_type != 'ios' && $source_type != 'android') {
- $where['cate_id'] = $cate_id;
- }
-
- $member = Dever::db('vip/member')->one($where);
- if ($member) {
- if (time() > $member['end']) {
- # 已过期
- return -2;
- } else {
- return $member['end'];
- }
- }
- }
- # 未开通
- return -1;
- }
- public function getEnd($time, $type, $start)
- {
- $key = 'days';
- if ($type == 1) {
- $key = 'days';
- } elseif ($type == 2) {
- $key = 'weeks';
- } elseif ($type == 3) {
- $key = 'months';
- } elseif ($type == 4) {
- $key = 'years';
- }
- $value = strtotime('+' . $time . $key, $start);
- return $value;
- }
- public function test_api()
- {
- $time = Dever::input('time');
- $type = Dever::input('type');
- $start = time();
- $value = $this->getEnd($time, $type, $start);
- return date('Y-m-d H:i:s', $value);
- }
- }
|