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; }
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; }
private function _inviteCheck($res, $code, $device, $accessToken, $accessSecret, $activityId) { global $_G; // 获取邀请注册活动的配置 $config = ActivityUtils::getInviteConfig($activityId); // 验证是否能进行参数活动 $checkInvite = ActivityUtils::checkInvite($config, $_G['uid'], $device); if ($checkInvite['rs'] == 0) { return $this->makeErrorInfo($res, $checkInvite['errcode']); } $isSelf = AppbymeActivityInviteUser::getCheckByUidCode($_G['uid'], $code); if ($isSelf) { // 输入的是自己的验证码 return $this->makeErrorInfo($res, 'mobcent_check_code_self'); } $checkCode = AppbymeActivityInviteUser::checkCode($code); if (!$checkCode) { // 兑换码验证失败 return $this->makeErrorInfo($res, 'mobcent_check_code_self'); } if ($checkCode) { AppbymeActivityInviteUser::checkCodeSuccess($activityId, $code, $_G['uid']); } return $res; }
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; }
public function actionFlagUser($uid) { $res = WebUtils::initWebApiResult(); $res['errCode'] = 1; $data = array('flag' => 1); $flagInfo = AppbymeActivityInviteUser::flagUser($uid, $data); if (!$flagInfo) { $res['errCode'] = 0; $res['errMsg'] = '标记失败!'; } echo WebUtils::outputWebApi($res, '', true); }