Example #1
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;
 }
Example #2
0
 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;
 }
 public static function checkCodeSuccess($activityId, $code, $uid)
 {
     $config = ActivityUtils::getInviteConfig($activityId);
     $sql1 = 'UPDATE %t SET';
     $sql1 .= ' invite_count=invite_count+1,';
     $sql1 .= 'reward_sum=reward_sum+' . $config['invite_reward'] . ',';
     $sql1 .= 'available_reward=available_reward+' . $config['invite_reward'];
     $sql1 .= ' WHERE exchange_num=%s';
     $sql2 = 'UPDATE %t SET';
     $sql2 .= ' joining=1';
     // $sql2 .= 'reward_sum=reward_sum+'.$config['invite_reward'].',';
     // $sql2 .= 'available_reward=available_reward+'.$config['invite_reward'];
     $sql2 .= ' WHERE uid=%d';
     DbUtils::getDzDbUtils(true)->query($sql1, array('appbyme_activity_invite_user', $code));
     DbUtils::getDzDbUtils(true)->query($sql2, array('appbyme_activity_invite_user', $uid));
 }
Example #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;
 }