예제 #1
3
 public static function checkInvite($config, $uid, $device)
 {
     $res = array('rs' => 1, 'errcode' => '');
     // 活动没有开始
     if (time() < $config['start_time']) {
         return array('rs' => 0, 'errcode' => 'mobcent_activity_no_start');
     }
     // 活动已经结束
     if (time() > $config['stop_time']) {
         return array('rs' => 0, 'errcode' => 'mobcent_activity_end');
     }
     // 用户
     if ($config['limit_user']) {
         $userExchange = AppbymeActivityInviteUser::getExchangeInfo($uid);
         if ($userExchange['joining']) {
             return array('rs' => 0, 'errcode' => 'mobcent_invite_user_ed');
         }
     }
     // 设备
     if ($config['limit_device']) {
         $deviceExchange = AppbymeActivityInviteUser::getExchangeInfoByDevice($device);
         if ($deviceExchange['joining']) {
             return array('rs' => 0, 'errcode' => 'mobcent_invite_device_ed');
         }
     }
     return $res;
 }
예제 #2
2
 private function _userReward($res, $activityId, $accessToken, $accessSecret)
 {
     $uid = AppbymeUserAccess::getUserIdByAccess($accessToken, $accessSecret);
     if (!$uid) {
         return $this->makeErrorInfo($res, 'mobcent_user_error');
     }
     $exchangeInfo = AppbymeActivityInviteUser::getExchangeInfo($uid);
     $config = ActivityUtils::getInviteConfig($activityId);
     $res['body']['exchangeMin'] = (int) $config['exchange_min'];
     $res['body']['exchangeStatus'] = (int) $exchangeInfo['exchange_status'];
     $res['body']['virtualName'] = (string) $config['virtual_name'];
     $res['body']['exchangeRatio'] = (int) $config['exchange_ratio'];
     $res['body']['rewardSum'] = (int) $exchangeInfo['reward_sum'];
     $res['body']['availableReward'] = (int) $exchangeInfo['available_reward'];
     return $res;
 }
예제 #3
2
 public function actionRewardExchange($uid, $exchangeNum)
 {
     $res = WebUtils::initWebApiResult();
     $res['errCode'] = 1;
     $exchangeInfo = AppbymeActivityInviteUser::getExchangeInfo($uid);
     if ($exchangeNum > $exchangeInfo['available_reward']) {
         $res['errCode'] = 0;
         $res['errMsg'] = '请输入正确的兑换金额';
     }
     if (!$exchangeInfo['exchange_status']) {
         $res['errCode'] = 0;
         $res['errMsg'] = '用户没有申请兑换!';
     }
     $exchangeInfo = AppbymeActivityInviteUser::execExchange($uid, $exchangeNum);
     // var_dump($exchangeInfo);die;
     // mobcent::dumpSql();
     if (!$exchangeInfo) {
         $res['errCode'] = 0;
         $res['errMsg'] = '兑换失败!';
     }
     echo WebUtils::outputWebApi($res, '', true);
 }
예제 #4
0
 private function _inviteExchange($res, $mobile, $type, $activityId)
 {
     global $_G;
     $config = ActivityUtils::getInviteConfig($activityId);
     // 是否结束
     if (time() > $config['stop_time']) {
         return $this->makeErrorInfo($res, 'mobcent_activity_end');
     }
     // 兑换金额是否超过最低兑换值
     $exchangeInfo = AppbymeActivityInviteUser::getExchangeInfo($_G['uid']);
     if ($exchangeInfo['available_reward'] < $config['exchange_min']) {
         return $this->makeErrorInfo($res, 'mobcent_exchange_min');
     }
     if (!in_array($type, array('mobile', 'forum'))) {
         return $this->makeErrorInfo($res, 'mobcent_exchange_type_error');
     }
     $exchange = array('exchange_type' => $type, 'mobile' => $mobile, 'exchange_status' => 1);
     $excInfo = AppbymeActivityInviteUser::inviteExchange($_G['uid'], $exchange);
     if (!$excInfo) {
         return $this->makeErrorInfo($res, 'mobcent_exchange_error');
     }
     return $res;
 }