コード例 #1
0
ファイル: Func.php プロジェクト: HackathonTsubaki/Backend
 /**
  * 扫码送网薪接口
  * @param string $num 厦大学号
  * @param int $award 发放网薪额度
  * @param string $act 扫码活动md5
  * @param string $end 扫码活动结束时间
  * @return string 网薪发放情况
  * @author Nili
  */
 public static function pay($num, $award, $act, $end)
 {
     $yibanInfo = Data_Db::getYibanInfoByXmuNum($num);
     $key = 'rollcall_' . $act . '_award' . $num;
     $cache = Vera_Cache::getInstance();
     if (!empty($cache->get($key))) {
         return '您已在该活动获得过网薪';
     }
     if (!$yibanInfo['yiban_islinked']) {
         return '未绑定易班身份,无法获得网薪';
     }
     if ($yibanInfo['expire_time'] < date('Y-m-d H:i:s')) {
         return '易班身份已过期,无法获得网薪';
     }
     Vera_Autoload::changeApp('yiban');
     $ret = Data_Yiban::awardSalary($yibanInfo['yiban_uid'], $yibanInfo['access_token'], $award);
     Vera_Autoload::reverseApp();
     if ($ret) {
         $cache->set($key, 1, $end);
         return "{$award}网薪已发往您的账户";
     } else {
         return '';
         //网薪发放失败
     }
 }
コード例 #2
0
ファイル: Autoload.php プロジェクト: HackathonTsubaki/Backend
 public static function reverseApp()
 {
     if (!self::$oldApp) {
         Vera_Log::addWarning('reverse app failed, no oldApp found');
         return false;
     }
     $GLOBALS['APP_NAME'] = self::$oldApp;
     Vera_Log::addNotice('reverse app to ' . self::$oldApp);
     self::$oldApp = NULL;
     Vera_Conf::resetBuffer();
     return true;
 }
コード例 #3
0
ファイル: Media.php プロジェクト: HackathonTsubaki/Backend
 public function run()
 {
     $wechatConf = Vera_Conf::getConf('global')['testWechat'];
     $appId = $wechatConf['AppID'];
     $appSecret = $wechatConf['AppSecret'];
     Vera_Autoload::changeApp('wechat');
     $accessToken = Data_Base::getAccessToken($appId, $appSecret);
     Vera_Autoload::reverseApp();
     $ret = array('access_token' => $accessToken);
     echo json_encode($ret);
     return false;
 }
コード例 #4
0
ファイル: Sign.php プロジェクト: HackathonTsubaki/Backend
 public function run()
 {
     if (empty($_SERVER['HTTP_REFERER'])) {
         echo json_encode(array('errmsg' => 'referer is empty'));
         return false;
     }
     $wechatConf = Vera_Conf::getConf('global')['testWechat'];
     $url = $_SERVER['HTTP_REFERER'];
     $appId = $wechatConf['AppID'];
     $appSecret = $wechatConf['AppSecret'];
     Vera_Autoload::changeApp('wechat');
     $ticket = Data_Base::getJsTicket($appId, $appSecret);
     $signArr = Data_Base::getJsSign($url, $ticket);
     Vera_Autoload::reverseApp();
     $signArr['appId'] = $appId;
     echo json_encode($signArr);
     return false;
 }
コード例 #5
0
 /**
  * 初始化环境,返回action层对应类的实例
  * @return class 触发到的action层对应类
  */
 public function init()
 {
     Vera_Autoload::init();
     $router = new Vera_Router();
     if (!Vera_Router::isApp()) {
         //如果app未开启,停止运行
         exit;
     }
     set_exception_handler('Action_Error::run');
     //最高级的异常捕获,统一显示为每个app自定的错误
     self::$Log = new Vera_Log();
     self::$Log->init();
     if (Vera_Autoload::isExists('Action_Auth')) {
         if (!Action_Auth::run()) {
             Vera_Log::addNotice('auth', 'fail');
             exit;
         }
         Vera_Log::addNotice('auth', 'success');
     }
     return $router->getAction();
 }
コード例 #6
0
ファイル: Rollcall.php プロジェクト: HackathonTsubaki/Backend
 public function checkin($act, $token)
 {
     $openId = self::$resource['FromUserName'];
     $nickname = Data_Wechat_User::getNick($openId);
     $avatar = Data_Wechat_User::getAvatar($openId);
     Vera_Autoload::changeApp('rollcall');
     $service = new Service_Func();
     $checkin = $service->checkin($act, $token, $openId, $nickname);
     Vera_Autoload::reverseApp();
     if ($checkin['errno']) {
         $ret['type'] = 'text';
         $ret['data']['Content'] = $checkin['errmsg'];
         return $ret;
     }
     $data = array('a' => $avatar, 'n' => $nickname);
     $ret['type'] = 'news';
     $temp['Articles'][0]['Title'] = "您是第{$checkin['rank']}位在【{$checkin['actInfo']['name']}】签到";
     $temp['Articles'][0]['Description'] = "点击大图参与大屏幕弹幕互动。";
     $temp['Articles'][0]['PicUrl'] = 'http://www.novaxmu.cn/templates/rollcall/img/success.png';
     $temp['Articles'][0]['Url'] = 'http://hackathontsubaki.github.io/Frontend/client.html?' . http_build_query($data);
     // Vera_Log::addNotice('url', $temp['Articles'][0]['Url']);
     $temp['Articles'][1]['Title'] = "SegmentFault";
     $temp['Articles'][1]['PicUrl'] = 'http://tp1.sinaimg.cn/2036070420/180/40003289296/0';
     $temp['Articles'][1]['Url'] = 'segmentfault.com';
     $temp['Articles'][2]['Title'] = "FreesFund | 峰瑞资本";
     $temp['Articles'][2]['PicUrl'] = 'http://freesvc.com/favicon.0bf61f76.ico';
     $temp['Articles'][2]['Url'] = 'http://freesvc.com/';
     $temp['Articles'][3]['Title'] = "有赞";
     $temp['Articles'][3]['PicUrl'] = 'http://static.segmentfault.com/app/hackathon-2015/logos/youzan.8bf6b2b.png';
     $temp['Articles'][3]['Url'] = 'https://www.youzan.com/';
     $temp['Articles'][4]['Title'] = "TalkingData";
     $temp['Articles'][4]['PicUrl'] = 'http://segmentfault.com/img/bVp4TP';
     $temp['Articles'][4]['Url'] = 'https://www.talkingdata.com/';
     $temp['Articles'][5]['Title'] = "阿里百川";
     $temp['Articles'][5]['PicUrl'] = 'http://static.segmentfault.com/app/hackathon-2015/logos/baichuan.cabac3c0.png';
     $temp['Articles'][5]['Url'] = 'https://baichuan.taobao.com/';
     $ret['data'] = $temp;
     return $ret;
 }
コード例 #7
0
ファイル: Aa.php プロジェクト: HackathonTsubaki/Backend
 /**
  * 幸运日辅助函数
  * @param  array $dbRes 身份信息,学号,易班id等
  * @return string        发网薪的msg
  * @author nili 
  */
 public function awardTmpLuck($dbRes)
 {
     if (Data_Db::getTodayLog($dbRes['yiban_uid'])) {
         return "您今日抽奖次数已用完,下次再来~";
     }
     $award = (rand() % 5 + 1) * 100;
     $msg = "你抽中了{$award}网薪,";
     $validAccessToken = Data_Db::getValidAccessToken($dbRes['yiban_uid']);
     if (!$validAccessToken) {
         $msg .= "但是易班身份已过期,可以重新绑定再来抽奖~";
         return $msg;
     }
     Data_Db::insertLog($dbRes['yiban_uid'], $dbRes['xmu_num'], $award);
     $requestUri = $_SERVER['REQUEST_URI'];
     Vera_Autoload::setApp('yiban');
     $_SERVER['REQUEST_URI'] = '/wechat/tmpLuck';
     $awardRes = Data_Yiban::awardSalary($dbRes['yiban_uid'], $validAccessToken, $award);
     Vera_Autoload::setApp('wechat');
     $_SERVER['REQUEST_URI'] = $requestUri;
     if ($awardRes) {
         $msg .= '网薪已发放至您的账户。';
     } else {
         $msg .= '未知原因发网薪失败,可截图找管理员找回~';
     }
     return $msg;
 }