채택완료

회원가입시 추천인에 대해 질문드립니다.

2014-06-10 (화) 14:44:20 6,193

회원가입시 추천인 아이디를 적으면 추천인에게 포인트가 주어지는데,

아이디 대신 닉네임으로 변경 하고싶은데 조언 부탁드립니다.^^

|

답변 1개 / 댓글 1개

채택된 답변
+20 포인트
2014-06-11 (수) 03:16:28
/lib/common.lib.php 889라인 insert_point함수 부분을 전체적으로 수정해 주셔야 합니다.
insert_point 함수는 그누의 다른 곳에서도 많이 쓰이는 함수로 함부로 수정하시면 안되구요 inser_point함수를 복사하셔서 insert_recommand_point라는 함수를 하나 만들어 줍니다.

Copy
function insert_recommand_point($mb_nick, $point, $content='', $rel_table='', $rel_id='', $rel_action='', $expire=0){    global $config;    global $g5;    global $is_admin;        // 포인트 사용을 하지 않는다면 return    if (!$config['cf_use_point']) { return 0; }    // 포인트가 없다면 업데이트 할 필요 없음    if ($point == 0) { return 0; }    $sql="select mb_id from g5_member where mb_nick='$mb_nick'";    $mb_id=sql_fetch($sql);    // 회원아이디가 없다면 업데이트 할 필요 없음    if ($mb_id == '') { return 0; }    $mb = sql_fetch(" select mb_id from {$g5['member_table']} where mb_id = '$mb_id' ");    if (!$mb['mb_id']) { return 0; }    // 회원포인트    $mb_point = get_point_sum($mb_id);    // 이미 등록된 내역이라면 건너뜀    if ($rel_table || $rel_id || $rel_action)    {        $sql = " select count(*) as cnt from {$g5['point_table']}                  where mb_id = '$mb_id'                    and po_rel_table = '$rel_table'                    and po_rel_id = '$rel_id'                    and po_rel_action = '$rel_action' ";        $row = sql_fetch($sql);        if ($row['cnt'])            return -1;    }    // 포인트 건별 생성    $po_expire_date = '9999-12-31';    if($config['cf_point_term'] > 0) {        if($expire > 0)            $po_expire_date = date('Y-m-d', strtotime('+'.($expire - 1).' days', G5_SERVER_TIME));        else            $po_expire_date = date('Y-m-d', strtotime('+'.($config['cf_point_term'] - 1).' days', G5_SERVER_TIME));    }    $po_expired = 0;    if($point < 0) {        $po_expired = 1;        $po_expire_date = G5_TIME_YMD;    }    $po_mb_point = $mb_point + $point;    $sql = " insert into {$g5['point_table']}                set mb_id = '$mb_id',                    po_datetime = '".G5_TIME_YMDHIS."',                    po_content = '".addslashes($content)."',                    po_point = '$point',                    po_use_point = '0',                    po_mb_point = '$po_mb_point',                    po_expired = '$po_expired',                    po_expire_date = '$po_expire_date',                    po_rel_table = '$rel_table',                    po_rel_id = '$rel_id',                    po_rel_action = '$rel_action' ";    sql_query($sql);    // 포인트를 사용한 경우 포인트 내역에 사용금액 기록    if($point < 0) {        insert_use_point($mb_id, $point);    }    // 포인트 UPDATE    $sql = " update {$g5['member_table']} set mb_point = '$po_mb_point' where mb_id = '$mb_id' ";    sql_query($sql);    return 1;}


위의 코드를 /lib/common.lib.php 에 붙여 넣기 해주시면 아마도 될거에요.
테스트는 안해봤습니다..

그리고 db를 살펴보니 mb_nick는 인덱스를 타지 않아서 회원수가 만명이상이 넘어 갈 경우 mb_nick에다가 index를 걸어 주시는게 좋을거에요





답변에 대한 댓글 1개

쉽지가 않은 작업이군요~답변 주셔서 감사합니다.

답변을 작성하려면 로그인이 필요합니다.