채택완료

지정한 라인으로 리턴시키는 함수가 잇나요?

2014-03-04 (화) 12:39:43 5,861
아래는 취소자에 따른 대기자를 주문으로 승급시키는 업데이트 로직인데요.
빨간부분을 읽은뒤에 파란색으로 표시된부분으로 다시 리턴시킬수 잇는 함수가 잇나요?
 
<?
include_once("_common.php");
if (!$member[mb_id])
    alert_close("잘못된 접근입니다.");
if (!($write[mb_id] == $member[mb_id] || $mb_id == $member[mb_id]))
     alert_close("잘못된 접근입니다.");
if (!($bo_table && $wr_id && $mb_id && $sc_no))
    die("값이 제대로 넘어오지 않았습니다.");
$sco = sql_fetch(" select * from g4_sc_order where sc_id = '$wr_id' and or_st = '1' and sc_no = '$sc_no' and mb_id = '$mb_id' ");
if (!$sco)
    alert_close("주문정보가 없습니다.");
 $sc = sql_fetch(" select * from g4_sc where sc_id = '$wr_id' and sc_no = '$sc_no' ");
if (!$sc)
    alert_close("특가정보가 없습니다.");
 
이부분부터 다시 시작
 
//첫번째 대기자 정보 뽑음
$scover = sql_fetch("select * from g4_sc_order where sc_id = '$wr_id' and or_st = '0' and sc_no = '$sc_no' order by or_datetime limit 0,1");
 
if ($scover) { //###########대기자가 있다면
         if ($sco[or_cnt]<$scover[or_cnt]) { //@@@@@@@@@@@@@@@@@@@@@@주문자보다 대기자의 수량이 더 많다면
   $point_save =  $write[wr_7]*$sco[or_cnt]; //-------수량에 따른 포인트값 계산
         $idp = get_member($scover['mb_id'], mb_point);
                                        
           if ($idp[mb_point]<$point_save) { //신청포인트부족시
            // 대기자정보 신청포인트미달로 대기자 하락 업데이트
                                             mysql_query(" update g4_sc_order set or_datetime = '$g4[time_ymdhis]' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
           }else{
              //신청포인트만큼 차감
    $query="insert g4_point values ('', '{$scover[mb_id]}', now(), '$wr_id 특가 신청포인트 차감', '-$point_save', '$bo_table', '$wr_id', '특가찬스')";
    $resultt=mysql_query($query);
      
    //회원정보의 포인트 갱신
    mysql_query("update g4_member set mb_point=mb_point-'$point_save' where mb_id='{$scover[mb_id]}'");
           }

         $mocnt = $scover[or_cnt] - $sco[or_cnt]; //대기자의 수량에서 취소자의 수량뺌
   $moprice = $scover[or_price] - $sco[or_price]; //대기자의 금액에서 취소자의 금액뺌
   // 대기자정보 업데이트
         mysql_query(" update g4_sc_order set or_st = '1', or_cnt = '{$sco[or_cnt]}', or_price = '{$sco[or_price]}' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
         //남는수량만큼 대기자정보 새로추가
   $sql = " insert into g4_sc_order
              set sc_id = '$wr_id',
                    sc_product = '{$scover[sc_product]}',
                    sc_name = '{$scover[sc_name]}',
                    sc_no = '{$scover[sc_no]}',
                    mb_id = '$mb_id',
                    or_cnt = '{$mocnt}',
                    or_price = '{$moprice}',
                    or_name = '{$scover[or_name]}',
                    or_bank = '{$scover[or_bank]}',
                    or_tel = '{$scover[or_tel]}',
                    or_addr = '{$scover[or_addr]}',
                    or_ip = '{$scover[or_ip]}',
                    or_memo = '{$scover[or_memo]}',
                    or_datetime = '{$scover[or_datetime]}',
                    or_st = '0' ";
        sql_query($sql);
        
   }else if ($sco[or_cnt]>$scover[or_cnt]) { //@@@@@@@@@@@@@@@@@@@주문자보다 대기자의 수량이 적다면
                                   $point_save =  $write[wr_7]*$scover[or_cnt]; //-------수량에 따른 포인트값 계산
                                         $idp = get_member($scover['mb_id'], mb_point);
                                        
           if ($idp[mb_point]<$point_save) { //신청포인트부족시
            // 대기자정보 신청포인트미달로 대기자 하락 업데이트
                                             mysql_query(" update g4_sc_order set or_datetime = '$g4[time_ymdhis]' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
           }else{
              //신청포인트만큼 차감
    $query="insert g4_point values ('', '{$scover[mb_id]}', now(), '$wr_id 특가 신청포인트 차감', '-$point_save', '$bo_table', '$wr_id', '특가찬스')";
    $resultt=mysql_query($query);
      
    //회원정보의 포인트 갱신
    mysql_query("update g4_member set mb_point=mb_point-'$point_save' where mb_id='{$scover[mb_id]}'");
           }
   $modcnt = $sco[or_cnt] - $scover[or_cnt]; //취소자의 수량에서 대기자의 수량뺌
   $modprice = $sco[or_price] - $scover[or_price]; //취소자의 금액에서 대기자의 금액뺌
   // 대기자정보 업데이트
         mysql_query(" update g4_sc_order set or_st = '1' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
   // 취소자정보 업데이트
         mysql_query(" update g4_sc_order set or_cnt = '$modcnt', or_price = '$modprice' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '$mb_id' and or_st = '1' ");
 
 
        }else if ($sco[or_cnt]==$scover[or_cnt]) { //@@@@@@@@@@@@@@@@@@@주문자 대기자 수량이 같다면

                                        $point_save =  $write[wr_7]*$scover[or_cnt]; //-------수량에 따른 포인트값 계산
                                         $idp = get_member($scover['mb_id'], mb_point);
                                        
           if ($idp[mb_point]<$point_save) { //신청포인트부족시
            // 대기자정보 신청포인트미달로 대기자 하락 업데이트
                                             mysql_query(" update g4_sc_order set or_datetime = '$g4[time_ymdhis]' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
           }else{
              //신청포인트만큼 차감
    $query="insert g4_point values ('', '{$scover[mb_id]}', now(), '$wr_id 특가 신청포인트 차감', '-$point_save', '$bo_table', '$wr_id', '특가찬스')";
    $resultt=mysql_query($query);
      
    //회원정보의 포인트 갱신
    mysql_query("update g4_member set mb_point=mb_point-'$point_save' where mb_id='{$scover[mb_id]}'");
           }
   // 대기자정보 업데이트
         mysql_query(" update g4_sc_order set or_st = '1' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '{$scover[mb_id]}' and or_st = '0' ");
   // 취소자정보 업데이트
         mysql_query(" update g4_sc_order set or_st = '0', or_datetime = '$g4[time_ymdhis]' where sc_id = '$wr_id' and sc_no = '$sc_no' and mb_id = '$mb_id' and or_st = '1' ");

  } //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@수량비교끝
}else{ //###############대기자가 없다면
// 상품수량증가 업데이트
mysql_query(" update g4_sc set sc_stock = sc_stock +'$sco[or_cnt]', sc_sell = sc_sell -'$sco[or_cnt]' where sc_id = '$wr_id' and sc_no = '$sc_no' ");
} //##################대기자가 있다면 끝

// 주문자정보 대기자로 업데이트
mysql_query(" update g4_sc_order set or_st = '0', or_datetime = '$g4[time_ymdhis]' where sc_id = '$wr_id' and mb_id = '$mb_id' and or_st = '1' ");

if ($member[mb_id] == $write[mb_id]) { //--------판매자에의한 취소의경우
             //주문자에게 쪽지보내기~
   $tmp_row = sql_fetch(" select max(me_id) as max_me_id from $g4[memo_table] ");
   $me_id = $tmp_row[max_me_id] + 1;
   
   $team_dall = substr($g4[time_ymdhis],0,4).".".substr($g4[time_ymdhis],5,2).".".substr($g4[time_ymdhis],8,2)." (".get_yoil($g4[time_ymdhis]).") ".substr($g4[time_ymdhis],11,5);
   
   $recv_mb_id   = $mb_id;
   $memo="{$write[wr_6]})의 특가담당자가 {$team_dall} 주문을 취소처리하였습니다.\\n다음 기회에 좀더 특별한 혜택으로 만나길 희망합니다.\\n감사합니다.\\n특가주소 : http://$_SERVER[SERVER_NAME]/$bo_table/$wr_id";
        $sql2 = " insert into $g4[memo_table]
                    set me_id = '$me_id',
                    me_recv_mb_id = '$recv_mb_id',
                    me_send_mb_id = '$write[mb_id]',
                    me_send_datetime = '$g4[time_ymdhis]',
                    me_memo = '$memo' ";
        sql_query($sql2);
        // 실시간 쪽지 알림 기능
        sql_query(" UPDATE $g4[member_table] SET mb_memo_call = '$write[mb_id]' WHERE mb_id = '$recv_mb_id' ");
  } //--------판매자에의한 취소의경우

?>
|

답변 1개 / 댓글 3개

채택된 답변
+20 포인트
2014-03-04 (화) 12:56:47
가능하긴 한데 로직상 추천해 드리진 않습니다.


참고하세요

답변에 대한 댓글 3개

그럼 맞을꺼야님은 어떤걸 추천해주시나요?
페이지를 로딩할때마다 한번씩 실행시키면 되지 않을까요?
글쎄요 빨간부분이 실행될시에만 지정된 파란부분부터 다시 내려오면되는거라 매번 반복시키는 개념은 아닌거 같아요ㅜㅜ

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