public function indexAction() { $sNewCardID = Yaf_Registry::get('config')->newcardid; $sOldCardID = Yaf_Registry::get('config')->oldcardid; if (!empty($_GET['ccid'])) { $ccid = $_GET['ccid']; } if (strlen($ccid) == 20) { $ccid = substr($ccid, 0, 19); } else { if (strlen($ccid) != 19) { throw new Exception("请检查您的ICCID!"); } } $cfArr = TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($ccid); if (empty($cfArr)) { $this->_view->display("no_info.html"); die; //throw new Exception("该卡不属于747卡!"); } else { $pid = $cfArr['cpid']; } if (intval($sNewCardID) != $pid && $pid != $sOldCardID) { $this->_view->display("no_info.html"); } else { if ($pid == $sOldCardID) { header("location:http://app.747.cn"); } else { $this->_view->display('pay.html'); } } }
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 indexAction() { $params = TZ_Request::getParams('post'); $sessionId = TZ_Request::checkSessionId('post'); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('您还没有登陆,无法继续操作。'); } // "params":"session_id=18600622921&did=123&cid=123&fid=123" $did = $cid = $fid = 0; //可以单买盒子,也可以单买卡和流量,还可以都买。 if (isset($params['did']) && is_numeric($params['did'])) { $did = $params['did']; if (isset($params['cid']) && is_numeric($params['cid']) && isset($params['fid']) && is_numeric($params['fid'])) { $cid = $params['cid']; $fid = $params['fid']; } } elseif (isset($params['cid']) && is_numeric($params['cid']) && isset($params['fid']) && is_numeric($params['fid'])) { $cid = $params['cid']; $fid = $params['fid']; } else { throw new Exception('对不起,参数错误。'); } $arUserInfo = TZ_Loader::service('User', 'User')->getInfoByUid($uid); //1:需要绑定 其余解除绑定 $type = $params['type'] > 0 ? $params['type'] : 1; $ccid = $params['ccid']; $result = TZ_Loader::service('UserFlow', 'Flow')->setUserCard($uid, $ccid, $arUserInfo['telephone'], $type); TZ_Request::success($result); }
public function indexAction() { $sessionId = TZ_Request::checkSessionId(); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('请先登陆。'); } $verifyCode = TZ_Request::checkVerifyCode(); $userInfo = TZ_Loader::service('User', 'User')->getInfoByUid($uid); if (empty($userInfo) || !is_array($userInfo)) { throw new Exception('请先登陆。'); } //valid $telephone = $userInfo['telephone']; $validStatus = TZ_Loader::service('VerifyCode', 'User')->valid($telephone, $verifyCode); if (!$validStatus) { throw new Exception('验证码错误。'); } //unset TZ_Loader::service('VerifyCode', 'User')->discard($telephone); //更新验证字段 TZ_Loader::service('User', 'User')->validTelphone($telephone); //response TZ_Request::success(array(array('session_id' => $sessionId))); }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $verifyCode = TZ_Request::checkVerifyCode(); $validStatus = TZ_Loader::service('VerifyCode', 'User')->valid($telephone, $verifyCode); TZ_Request::success(array(array('verified' => $validStatus))); }
public function getMonthTotal($iccid) { $condition = array(); $condition['ccid:eq'] = $iccid; $condition['status:eq'] = 2; $condition['start_date:elt'] = date("Y-m-d H:i:s"); $condition['end_date:gt'] = date("Y-m-d H:i:s"); //从flow_order 表中得到fid(流量套餐ID),当前时间在套餐有效期之间的 $floworderArr = TZ_Loader::model('FlowOrder', 'Flow')->select($condition, 'fid', 'ROW'); if (empty($floworderArr)) { $condition = array(); $condition['ccid:eq'] = $iccid; $condition['status:eq'] = 2; $condition['order'] = "end_time desc"; //从flow_order 表中得到fid(流量套餐ID),当前时间在套餐有效期之间的 $floworderArr = TZ_Loader::model('FlowOrder', 'Flow')->select($condition, 'fid', 'ROW'); } $fid = $floworderArr['fid']; $packageArr = $this->getFid($fid); //判断是否是新卡 $sNewCardID = Yaf_Registry::get('config')->newcardid; $cfArr = TZ_Loader::service('UserFlow', 'Flow')->getFlowProductId($iccid); //如果是新卡,有多条充值记录,就将充值记录数量*month_size的值作为总流量返回 //从flow_order 表中得到fid(流量套餐ID),当前时间在套餐有效期之间的 $floworderArrAll = TZ_Loader::model('FlowOrder', 'Flow')->getfFLowOrdersAll($iccid); //var_dump($floworderArrAll); if ($sNewCardID == $cfArr['cpid'] && !empty($floworderArrAll)) { return count($floworderArrAll) * $packageArr['month_size']; } else { return $packageArr['month_size']; } }
public function indexAction() { $params = TZ_Request::getParams('get'); $sessionId = TZ_Request::checkSessionId('get'); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('您还没有登陆,无法继续操作。'); } $arUserInfo = TZ_Loader::service('User', 'User')->getInfoByUid($uid); //1:需要绑定 其余解除绑定 $type = isset($params['type']) ? $params['type'] : 1; $ccid = $params['iccid']; if (strlen($ccid) == 20) { $ccid = substr($ccid, 0, 19); } elseif (strlen($ccid) != 19) { throw new Exception("您输入的ICCID有误,请检查"); } $result = TZ_Loader::service('UserFlow', 'Flow')->setUserCard($uid, $ccid, $arUserInfo['telephone'], $type); if ($result) { if ($result == 1) { TZ_Request::success(array(array("status" => 1, "message" => "绑定成功"))); } else { TZ_Request::success(array(array("status" => 1, "message" => "恭喜你绑定成功并获得免费通话时长!"))); } } else { TZ_Request::success(array(array("status" => 2, "message" => "绑定失败"))); } }
/** * connect to redis server * * @param string $host * @param int $port * @return object */ public static function connect($index = 'user', $host = null, $port = null) { //----------------------------octopus update 2014-01-03---------------------------------- //根据业务,把redis拆分成两部分,user 和 card // if (!isset(self::$_dbIndex[$index])) { // throw new Exception('DB index not found.'); // } //$db = self::$_dbIndex[$index]; if (!extension_loaded('redis')) { throw new Exception('Redis extension not found.'); } $redisConfig = TZ_Loader::config('redis'); if (empty($redisConfig)) { throw new Exception('Reids Configuration error.'); } $redis = new Redis(); $host = null === $host ? $redisConfig[$index]['host'] : $host; $port = null === $port ? $redisConfig[$index]['port'] : $port; $connection = $redis->connect($host, $port); if (!$connection) { throw new Exception('Can\'t connect to Redis server.'); } //$redis->select($db); //-----------------------------------end --------------------------------------------------- return $redis; }
public function indexAction() { $params = TZ_Request::getParams('get'); /* $sessionId = TZ_Request::checkSessionId('get'); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('您还没有登陆,无法继续操作。'); } $arUserInfo = TZ_Loader::service('User', 'User')->getInfoByUid($uid); */ $ccid = $params['ccid']; if (strlen($ccid) == 20) { $ccid = substr($ccid, 0, 19); } elseif (strlen($ccid) != 19) { throw new Exception("您输入的ICCID有误,请检查"); } if ($ccid > 0) { //应用调取接口 if (isset($params['type']) && intval($params['type']) > 0) { $result = TZ_Loader::service('UserFlow', 'Flow')->getFlowInfo($ccid); $result['demo'] = preg_replace("/<br>/is", "", $result['demo']); TZ_Request::success(array($result)); } else { $result = TZ_Loader::service('UserFlow', 'Flow')->getProductCardInfo($ccid); TZ_Request::success(array($result)); } } else { throw new Exception("参数错误"); } }
public function indexAction() { //测试url //http://www.ccds.com/crontab/inituserflowlog/index?date=2014-08-01 $date = $_GET['date'] ? $_GET['date'] : date("Y-m-d", strtotime("1 days ago")); $res = TZ_Loader::service('FlowLog', 'Crontab')->InitFlowLog($date); echo $res; }
/** * 获得用户订单信息 * * @param $session_id 用户session * * @Return array */ public function indexAction() { $params = array(); $params = array('day' => date('Y-m-d H:i:s'), 'company' => '黑米世纪'); //$params = array('code'=>1222); $resutl = TZ_Loader::service('Sendmessage', 'Sms')->send('2', '15201655587', $params); var_dump($resutl); }
/** * reset code * * @param string $telephone * @return string */ public function createResetCode($telephone) { $userInfo = TZ_Loader::model('Users', 'User')->getInfoByTelephone($telephone); if (empty($userInfo)) { throw new Exception('号码不存在,请确认输入号码是否正确。'); } return $this->_sendCode($telephone); }
public function indexAction() { $sessionId = TZ_Request::checkSessionId(); $logoutStatus = TZ_Loader::service('User', 'User')->logout($sessionId); /*if (!$logoutStatus) throw new Exception('注销登陆失败。'); */ TZ_Request::success(); }
public function ischanged($ccid) { $res = TZ_Loader::model('CardChange', 'Device')->select(array('ccid_old:eq' => $ccid), 'id', 'ROW'); if ($res['id']) { return true; } else { return false; } }
public function insertCardFlowAction() { $host = Yaf_Application::app()->getConfig()->crontab->flow->host; //获取接口域名 $date = date("Y-m-d"); //同步当天时间 //查看当天是否已有成功执行的记录,有则不在同步(一天同步一次) // $re = TZ_Loader::model('Crontablog', 'Crontab')->select(array("status:eq" => 1, "type:eq" => 1, "created_at:eq" => $date), "id", "ROW"); // if (!empty($re)) { // echo "今天已经同步过数据"; // die; // } //查询最后一个手机号添加时间 $url = $host . "/traffic_find_web/getLastCardTime"; $cardLastTime = TZ_Loader::service("Data", "Crontab")->getData($url); //var_dump($cardLastTime);die; if ($cardLastTime == "fail") { //处理 插入错误原因为”查询最后一个手机号添加时间失败“ $arError = array("data" => "查询最后一个手机号添加时间失败", "status" => 0, "created_at" => $date, "updated_at" => $date); TZ_Loader::model('Crontablog', 'Crontab')->insert($arError); echo "查询最后一个手机号添加时间失败"; die; } else { $condition['created_at:gt'] = $cardLastTime; //$condition['limit'] = 1; $data = TZ_Loader::model('CardFlow', 'Flow')->select($condition, "id,pid,pname,ctelephone,cpid,ccid,operate_name as operateName,start_date as startDate,end_date as endDate,status,updated_at as updatedAt,created_at as createdAt", "ALL"); //var_dump($data); if (empty($data)) { //处理成功 插入一条数据 $arOk = array("data" => "无任何数据更新", "status" => 1, "created_at" => $date, "updated_at" => $date); TZ_Loader::model('Crontablog', 'Crontab')->insert($arOk); echo "没有最新数据"; die; } else { $data = array("card" => $data); $json = json_encode($data); } } //var_dump($json);die; //调取插入数据接口 $url1 = $host . "/traffic_find_web/insertCardFlow"; $dataNew["cards"] = $json; $result = TZ_Loader::service("Data", "Crontab")->postData($dataNew, $url1); if ($result == "fail") { //处理失败 插入错误原因为”批量插入手机号失败“ $arError = array("data" => "批量插入手机号失败", "status" => 0, "created_at" => $date, "updated_at" => $date); TZ_Loader::model('Crontablog', 'Crontab')->insert($arError); echo "插入数据失败"; die; } elseif ($result == "success") { //处理成功 插入一条数据 $arOk = array("data" => "数据同步成功", "status" => 1, "created_at" => $date, "updated_at" => $date); TZ_Loader::model('Crontablog', 'Crontab')->insert($arOk); echo "同步成功"; die; } }
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() { $params = TZ_Request::getParams('get'); $sessionId = TZ_Request::checkSessionId('get'); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('您还没有登陆,无法继续操作。'); } $result = TZ_Loader::service('Product', 'Device')->getCardList($uid); TZ_Request::success($result); }
public function indexAction() { $sessionId = TZ_Request::checkSessionId(); $password = TZ_Request::checkPassword(); $oldPassword = TZ_Request::checkOldPassword(); $changeStatus = TZ_Loader::service('User', 'User')->changePassword($sessionId, $oldPassword, $password); if (!$changeStatus) { throw new Exception('修改密码失败。'); } TZ_Request::success(); }
public function indexAction() { $params = TZ_Request::getParams('get'); $sCcid = $params['ccid']; if (strlen($sCcid) == 20) { $sCcid = substr($sCcid, 0, 19); } elseif (strlen($sCcid) != 19) { throw new Exception("您输入的ICCID有误,请检查"); } $result = TZ_Loader::service('Product', 'Device')->getPayFlowList($sCcid); TZ_Request::success($result); }
public function indexAction() { //测试url //http://www.ccds.com/crontab/initflowjob/index?date=2014-08-01 $date = $_GET['date'] ? $_GET['date'] : date("Y-m-d", strtotime("1 days ago")); $res = TZ_Loader::service('Flow', 'Crontab')->InitFlowJob($date); if (!$res) { echo "任务表已经执行!"; } else { echo "执行成功!"; } }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $reset = TZ_Request::checkVerifyMode(); $service = TZ_Loader::service('VerifyCode', 'User'); if ($reset == '1') { $verifyCode = $service->createRegisterCode($telephone); } else { $verifyCode = $service->createResetCode($telephone); } TZ_Request::success(array(array('verify_code' => ''))); }
/** * create session info * * @param string $uid * @return string */ public function create($uid) { $sessionId = TZ_Loader::service('IdManager', 'User')->createSessionId($uid); $redis = TZ_Redis::connect('session'); //---------------octopus update 2014-01-03--------------------------------- //设置一下时间戳,传入两个传 $setStatus = $redis->hmset(self::$_sessionPreKey . $sessionId, array($uid, time())); if (!$setStatus) { throw new Exception('创建用户SESSION失败。'); } //-------------------------------end--------------------------------- return $sessionId; }
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 indexAction() { $params = TZ_Request::getParams('get'); $sessionId = TZ_Request::checkSessionId('get'); $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sessionId); if (!$uid) { throw new Exception('您还没有登陆,无法继续操作。'); } //ccid $sCcid = $params['ccid']; $result = TZ_Loader::service('UserFlow', 'Device')->getFlowNextRechargeMonth($uid, $sCcid); TZ_Request::success($result); }
/** * * 获取用户的默认信息接口 * * 需要传值 * session_id * * 返回一个数组,数组下标如下 * name 收货人姓名 * receive_tel 收货人电话 * address 收货人地址 */ public function getDefaultAddress($session_id, $addressId) { $sid = !empty($session_id) ? $session_id : ""; $uid = TZ_Loader::service('SessionManager', 'User')->getUid($sid); if (empty($uid)) { return "error"; } //$uid = 11; //get data $arAddress = array("id" => "", "name" => "", "receive_tel" => "", "postcode" => "", "address" => ""); $condition = array(); $condition['uid:eq'] = $uid; $condition['status:eq'] = 1; if (!empty($addressId)) { $condition['id:eq'] = $addressId; $arAddressInfo_def = $this->getAddressInfo($condition); } else { //查找该用户使用状态的地址信息总数 $arAddressTotal = $this->getAddressTotal($condition); //如果没有地址信息返回空数组 if ($arAddressTotal == 0) { //var_dump($arAddress); return $arAddress; } $condition['is_default:eq'] = 1; //查找该用户的默认地址地址信息 $arAddressInfo_def = $this->getAddressInfo($condition); if (empty($arAddressInfo_def)) { //如果没有默认地址,就将最新一条数组查出来 $condition1 = array(); $condition1['uid:eq'] = $uid; $condition1['status:eq'] = 1; $condition1['limit'] = "0,1"; $condition1['order'] = 'id DESC'; $arAddressInfo_def = $this->getAddressInfo($condition1); } } if (!empty($arAddressInfo_def)) { $arAddress['id'] = $arAddressInfo_def['id']; $arAddress['name'] = $arAddressInfo_def['name']; $arAddress['receive_tel'] = $arAddressInfo_def['receive_tel']; $arAddress['postcode'] = $arAddressInfo_def['postcode']; if ($arAddressInfo_def['area'] == 0) { $area = ""; } $arAddress['address'] = $arAddressInfo_def['province'] . $arAddressInfo_def['city'] . $area . $arAddressInfo_def['detail']; } //var_dump($arAddress); return $arAddress; }
public function indexAction() { $telephone = TZ_Request::checkTelephone(); $password = TZ_Request::checkPassword(); $params = TZ_Request::getParams('post'); if (isset($params['name']) && $params['name'] != '') { $name = $params['name']; } else { $name = '747er_' . substr(md5($telephone), 0, 6); } //register $sessionId = TZ_Loader::service('User', 'User')->register($telephone, $password, $name); //response TZ_Request::success(array(array('session_id' => $sessionId))); }
public function send($tId, $tel, $params, $type = 'post', $delimiter = '?', $charset = 'utf-8', $needcharset = 'utf-8') { $config = Yaf_Registry::get('config'); $smsHost = $config->sms->host; if (array_key_exists($tId, $this->arrTemplate)) { $params['phone'] = $tel; $params['uuid'] = $this->arrTemplate[$tId]['uuid']; $params['id'] = $this->arrTemplate[$tId]['id']; $result = TZ_Loader::service('CurlTool', 'Sms')->sendcurl($smsHost, $type, $params, $charset, $needcharset, $delimiter); return $result; } else { $error = array('result' => 'Not find template ID', 'msg' => 'fail'); return json_encode($error); } }
public function updateOrder($orderId, $status) { $ret = true; //1未付款,2未发货,3已发货,4已关闭,5已删除 $condition = array('order_sn:eq' => $orderId); $order = TZ_Loader::model('Orders', 'Order')->select($condition, array('goods_id', 'status', 'num'), 'ROW'); if ($order['status'] == '1') { $cols = array('status' => $status); $ret = TZ_Loader::model('Orders', 'Order')->update($cols, $condition); TZ_Loader::model('Goods', 'Api')->updateNum($order['goods_id'], $order['num']); //刷新商品信息 $redis = TZ_Redis::connect('mall'); $redis->hDel('goods_info', $order['goods_id']); } return $ret; }
public function getAdvert() { $is = $this->redis->hExists($this->redis_advert, 'banner'); if ($is) { $banner_info = $this->redis->hGet($this->redis_advert, 'banner'); $banner_info = unserialize($banner_info); return $banner_info; } else { $conditions = array('status:eq' => 1, 'order' => ' `id` DESC'); $banner_info = TZ_Loader::model('Advert', 'Api')->select($conditions, array('img', 'src'), 'ALL'); if ($banner_info) { $this->redis->hSet($this->redis_advert, 'banner', serialize($banner_info)); } return $banner_info; } }