Ejemplo n.º 1
0
         $all_info = get_user_wechat_info($access_token, $wechat_user->openid);
         if (isset($all_info->unionid)) {
             $get_account = 'select `account` from ' . $db->table('member') . ' where `unionid`=\'' . $db->escape($all_info->unionid) . '\'';
             $account = $db->fetchOne($get_account);
             if ($account) {
                 $member_data = array('openid' => $_SESSION['openid']);
                 $db->autoUpdate('member', $member_data, '`account`=\'' . $account . '\'');
             }
         }
         if (!$account) {
             //如果用户不存在,则直接新注册用户
             $log->record("register new member");
             register_member($_SESSION['openid'], $_SESSION['parent_id']);
             $get_parent_account = 'select `account` from ' . $db->table('member') . ' where `id`=' . $_SESSION['parent_id'];
             $parent_account = $db->fetchOne($get_account);
             if ($config['recommend_integral'] > 0 && add_recommend_integral($parent_account, $config['recommend_integral'], '推荐新用户奖励')) {
                 $log->record('add recommend integral success:' . $account . ' increment ' . $config['recommend_integral']);
             } else {
                 $log->record('add recommend integral fail:' . $account . ' increment ' . $config['recommend_integral']);
             }
         }
     }
     $member_data = array('sex' => $wechat_user->sex, 'nickname' => $wechat_user->nickname, 'province' => $wechat_user->province, 'city' => $wechat_user->city, 'headimg' => $wechat_user->headimgurl);
     if (isset($wechat_user->unionid)) {
         $member_data['unionid'] = $wechat_user->unionid;
     }
     $db->autoUpdate('member', $member_data, '`openid`=\'' . $wechat_user->openid . '\'');
     $get_account = 'select `account` from ' . $db->table('member') . ' where `openid`=\'' . $wechat_user->openid . '\'';
     $_SESSION['account'] = $db->fetchOne($get_account);
 } else {
     echo 'ERROR 2048: 获取授权信息失败';
Ejemplo n.º 2
0
    }
}
$openid = $db->escape($openid);
$get_user = '******' . $db->table('member') . ' where `openid`=\'' . $openid . '\'';
$access_token = get_access_token($config['appid'], $config['appsecret']);
$all_info = get_user_wechat_info($access_token, $openid);
if (isset($all_info->unionid)) {
    $unionid = $db->escape($all_info->unionid);
    $get_user = '******' . $db->table('member') . ' where `unionid`=\'' . $unionid . '\'';
}
$uid = $db->fetchOne($get_user);
if (!$uid && register_member($openid, $parent_id)) {
    if (get_user_wechat_info($access_token, $openid)) {
        $log->record('update user info success');
    }
    $log->record('async user list, add new user with: openid=' . $openid . ',scene_id=' . $scene_id);
    //发放推广奖励
    if ($account != '') {
        if (add_recommend_integral($account, $config['recommend_integral'], '推荐新用户奖励')) {
            $log->record('add recommend integral success:' . $account . ' increment ' . $config['recommend_integral']);
        } else {
            $log->record('add recommend integral fail:' . $account . ' increment ' . $config['recommend_integral']);
        }
    } else {
        $log->record('account is empty');
    }
} else {
    $log->record('async user list fail. openid=' . $openid . ',scene_id=' . $scene_id);
}
echo json_encode($response);
exit;