CMS솔루션마켓, 이온디 - 워드프레스, 라이믹스, 카페24, 그누보드, 엑셀

Contents Management System

Contents 모듈

기존 코드

<!--@if($seller)-->
{@
// number_format(filter_var($sale_pointview, 519)*$module_info->point_ratio*0.01)P
// 셀러(해당 게시물 작성자)에게는 판매된 포인트 수익금을 보여준다.
$saleCopy = $oContents->purchase_count?(int)$oContents->purchase_count:0; // 판매갯수
$profit = filter_var($sale_pointview,519) * $module_info->point_ratio * 0.01 * $saleCopy;
//$profit = (int)$sale_pointview * $module_info->point_ratio * 0.01 * $saleCopy;
}
{number_format($profit)}P
<!--@else-->
{$sale_pointview}
<!--@end-->

참고로 $seller 란 글 작성자를 뜻하는 변수로 사용했습니다.

$seller = $oDocument->getMemberSrl() == $logged_info->member_srl;

먼저 현재 보고 있는 글 작성자와 로그인한 유저가 같을 경우로 변수를 설정했습니다.


$sale_pointview 는 해당 게시물의 판매포인트입니다.

이 부분은 int가 아니기에 int로 다시 변경하거나, filter_var($sale_pointview, 519) 함수를 사용하여 1,000 자리의 쉼표를 떼주는 식으로 사용했었는데요,


다시 생각해보니 판매포인트는 판매가 되고 나서도 수정이 가능했기 때문에 정확한 판매수익포인트는 아니었습니다.


자, 여기서부터 이제 디버깅을 시작해봅니다.


1. 구매자의 리스트를 보여주는 페이지

modules/contents/skins/ec_imin/form/file/purchase_view.html

해당상품의 구매자 리스트를 보여주는 페이지입니다.

이 부분에서 구매포인트 변수는 다음과 같습니다.

{$oTransaction->point}

여기서 힌트를 찾아서 모듈에서 $oTransaction 이 사용된 부분을 찾습니다.


2. 구매자를 뽑아오는 구문

modules/contents/contents.controller.php

// 구매자들
$output = executeQueryArray('contents.getContentsTransaction', $obj);
foreach($output->data as $oTransaction)
{
   if($oTransaction->point && $oTransaction->purchase_way == 'point')
   {
      $profit_point += round($oTransaction->point*($module_info->point_ratio/100));

      // for 포인트 히스토리
      Context::set('__point_message_id__', 'module.contents.delete_refund');
      Context::set('__point_message__', sprintf(Context::getLang('point_message_delete_contents_refund'), $module_info->browser_title, cut_str($oDocument->get('title'), 30)));

      // 구매자에게 포인트 100% 환불
      $oContentsModel->setTransactionMoney($this->module_info->module_srl, $oTransaction->member_srl, $oTransaction->point,'add');

      //쪽지발송
      $title = Context::getLang('msg_declare_refund_message_title').' ['.$oTransaction->title.']';
      $content = '<b>['.$oTransaction->title.']</b> '.Context::getLang('msg_declare_refund_message_content1').'<span style="COLOR: #ef007c"><strong>'.number_format($oTransaction->point).'P</strong></span>'.Context::getLang('msg_declare_refund_message_content2');

      $oCommunicationController->sendMessage($logged_info->member_srl, $oTransaction->member_srl, $title, $content, false);
   }
}

3. 본격적인 코드 작업

이제 스킨 파일에서 원하는 곳에 아래 코드를 추가해줍니다.

{@
         $obj = $obj ?? new stdClass;
$obj->document_srl = $document_srl;
         $output = executeQueryArray('contents.getContentsTransaction', $obj);
         foreach ($output->data as $value) :
             $pointsum += $value->point;
         endforeach;
         }
         {$pointsum}P
 
댓글은 로그인 사용자만 작성 가능합니다. 로그인하기