public function indexAction() { if (!isset($_GET['iccid'])) { throw new Exception("参数错误"); } else { $iccid = $_GET['iccid']; } //通过查来的iccid,得到用户的电话号码 if (strlen($iccid) == 20) { $iccid = substr($iccid, 0, 19); } elseif (strlen($iccid) != 19) { throw new Exception("请检查您的ICCID!"); } $data = (array) TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($iccid); if (empty($data) || count($data) == 0 || !isset($data['ctelephone'])) { //不存在于我们的数据库中 throw new Exception("未查到相关信息,请确认是否为747流量卡!"); } //得到去联通官网查询时所需的电话号码 $ctelephone = $data['ctelephone']; $flow = TZ_Loader::service('Flow', 'Flow')->getSurplusFlow($ctelephone); if ($flow) { TZ_Request::success(array($flow)); } else { TZ_Request::error('网络繁忙'); } }
public function advertAction() { //获取广告图 $ads_info = TZ_Loader::service('Advert', 'Api')->getAdvert(); if (count($ads_info) > 0) { TZ_Request::success($ads_info); } else { TZ_Request::error($ads_info); } }
public function indexAction() { $session_id = trim($_POST['session_id']); $iccid = trim($_POST['iccid']); $flag = trim($_POST['flag']); if ($session_id != '' && $flag != '') { $uid = TZ_Loader::service('SessionManager', 'User')->getUid($session_id); if (empty($uid)) { TZ_Request::error('登录过期'); exit; } else { $iccid = trim($iccid, ','); $arrIccid = explode(',', $iccid); if ($flag == 'off') { $set = array('status' => 0); } elseif ($flag == 'on') { $set = array('status' => 1); } else { TZ_Request::error('无效参数'); exit; } $conditions = array('uid:eq' => $uid); foreach ($arrIccid as $val) { if ($val) { $conditions['ccid:eq'] = $val; } $row = TZ_Loader::model('UserSubscription', 'User')->select($conditions, 'id', 'ROW'); if ($row['id']) { TZ_Loader::model('UserSubscription', 'User')->update($set, $conditions); } else { $upUser = TZ_Loader::model('UserCard', 'User')->select($conditions, '*', 'ALL'); if ($upUser) { foreach ($upUser as $v) { $cols = array(); $cols['user_card_id'] = $v['id']; $cols['uid'] = $v['uid']; $cols['ccid'] = $v['ccid']; $cols['telephone'] = $v['telephone']; $cols['ctelephone'] = $v['ctelephone']; $cols['messages_id'] = 0; $cols['status'] = $set['status']; $cols['created_at'] = $cols['updated_at'] = date('Y-m-d H:i:s'); TZ_Loader::model('UserSubscription', 'User')->insert($cols); } } } } TZ_Request::success('ok'); exit; } } else { TZ_Request::error('无效参数'); exit; } }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $password = TZ_Request::checkPassword(); if (!empty($_POST['debug'])) { $password = hash('sha256', $password); } if (TZ_Loader::service('Blacklist')->inList($telephone)) { TZ_Request::error('系统检测你有违规操作,帐号已被冻结。', 500); } $sessionId = TZ_Loader::service('User', 'User')->login($telephone, $password); TZ_Request::success(array(array('session_id' => $sessionId))); }
public function getflowdifferAction() { $params = TZ_Request::getParams('get'); $ccid = $params['ccid']; if ($ccid > 0) { if (strlen($ccid) == 20) { $ccid = substr($ccid, 0, 19); } elseif (strlen($ccid) != 19) { throw new Exception("您输入的ICCID有误,请检查"); } //得到卡的相关信息。主要是ctelephone $data = (array) TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($ccid); $ctelephone = $data['ctelephone']; //获取流量详情 $rep = TZ_Loader::service('Flow', 'Flow')->getSurplusFlow($ctelephone, true); if (!empty($rep)) { //流量处理 $result = array('unlimit' => $rep['unlimit'], 'local' => $rep['local'], 'punlimit' => 0, 'plocal' => 0); if ($result['unlimit'] > 0) { $result['punlimit'] = sprintf($rep['unlimit'] / 2048) * 100; } if ($result['local'] > 0) { $result['plocal'] = sprintf($rep['local'] / 8192) * 100; } if ($result['unlimit'] > 100) { $result['unlimit'] = floor($result['unlimit']); } if ($result['local'] > 100) { $result['local'] = floor($result['local']); } TZ_Request::success($result); } else { $detail = "获取失败"; TZ_Request::error($detail, "500"); } } else { throw new Exception("参数错误"); } }