Skip to content

Commit

Permalink
Merge pull request Waterticket#34 from Waterticket/develop
Browse files Browse the repository at this point in the history
리워드 포인트 기능 추가
  • Loading branch information
Waterticket authored Jul 30, 2023
2 parents 9c7f36a + a43987d commit 1b92be9
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions hotopay.admin.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function procHotopayAdminInsertConfig()
$config->point_discount = empty($vars->point_discount) ? 'N' : 'Y';
$config->cart_item_limit = $vars->cart_item_limit;
$config->min_product_price = $vars->min_product_price;
$config->purchase_reward_point_percent = $vars->purchase_reward_point_percent / 100;
$config->change_group_to_regular_when_pay = empty($vars->change_group_to_regular_when_pay) ? 'N' : 'Y';
$config->associate_group_srl = $vars->associate_group_srl;
$config->regular_group_srl = $vars->regular_group_srl;
Expand Down
7 changes: 7 additions & 0 deletions hotopay.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public function getConfig()
if(!isset(self::$_config_cache->change_group_to_regular_when_pay)) self::$_config_cache->change_group_to_regular_when_pay = 'N'; // 결제시에 회원 그룹을 정회원으로 변경
if(!isset(self::$_config_cache->associate_group_srl)) self::$_config_cache->associate_group_srl = 2; // 준회원 그룹 srl
if(!isset(self::$_config_cache->regular_group_srl)) self::$_config_cache->regular_group_srl = 3; // 정회원 그룹 srl
if(!isset(self::$_config_cache->purchase_reward_point_percent)) self::$_config_cache->purchase_reward_point_percent = 0; // 결제 후 적립 포인트 비율 (0~1)

if(!isset(self::$_config_cache->hotopay_license_key)) self::$_config_cache->hotopay_license_key = ''; // Hotopay 라이선스 키
if(!isset(self::$_config_cache->hotopay_last_license_expire_alert_date)) self::$_config_cache->hotopay_last_license_expire_alert_date = 0; // 라이선스 만료 경고 마지막 날짜
Expand Down Expand Up @@ -464,6 +465,7 @@ public function checkUpdate()
if(!$oDB->isColumnExists("hotopay_product","allow_use_point")) return true;
if(!$oDB->isColumnExists("hotopay_purchase_item","subscription_srl")) return true;
if(!$oDB->isIndexExists("hotopay_purchase_item","idx_subscription_srl")) return true;
if(!$oDB->isColumnExists("hotopay_purchase","reward_point")) return true;

$config = $this->getConfig();
if (self::HOTOPAY_NEEDED_DB_VERSION > $config->hotopay_db_version)
Expand Down Expand Up @@ -606,6 +608,11 @@ public function moduleUpdate()
$oDB->addIndex('hotopay_purchase_item',"idx_subscription_srl","subscription_srl");
}

if(!$oDB->isColumnExists("hotopay_purchase","reward_point"))
{
$oDB->addColumn('hotopay_purchase',"reward_point","number",20,0,true,"is_billing");
}

$config = $this->getConfig();
if (self::HOTOPAY_NEEDED_DB_VERSION > $config->hotopay_db_version)
{
Expand Down
25 changes: 25 additions & 0 deletions hotopay.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public function procHotopayOrderProcess()
$args->regdate = time();
$args->pay_data = '';
$args->extra_vars = serialize($extra_vars);
$args->reward_point = round($config->purchase_reward_point_percent * $total_price);

$pg = in_array($vars->pg, ['toss']) ? $vars->pg : $vars->pay_method;
if(substr($pg, 0, 6) === 'paypl_')
Expand Down Expand Up @@ -1736,6 +1737,20 @@ public function _ActivePurchase($purchase_srl, $member_srl = -1)
}
}

$validator = new HotopayLicenseValidator();
$isLicenseValid = $validator->validate($config->hotopay_license_key);
if ($isLicenseValid)
{
$reward_point = $purchase->reward_point;

if ($reward_point > 0)
{
$oPointController = \PointController::getInstance();
Context::set('__point_message__', sprintf('포인트 적립 #%d', $purchase_srl));
$output = $oPointController->setPoint($member_srl, $reward_point, 'add');
}
}

$trigger_obj->group_srls = $group_srls;
ModuleHandler::triggerCall('hotopay.activePurchase', 'after', $trigger_obj);
}
Expand Down Expand Up @@ -1888,6 +1903,16 @@ public function _RefundProcess($purchase_srl, $output_data = [])
}
}

$config = $this->getConfig();
$reward_point = $purchase->reward_point;

if ($reward_point > 0)
{
$oPointController = \PointController::getInstance();
Context::set('__point_message__', sprintf('포인트 회수 #%d', $purchase_srl));
$oPointController->setPoint($member_srl, $reward_point, 'minus');
}

$oMemberController = getController('member');
if(version_compare(__XE_VERSION__, '2.0.0', '<'))
{
Expand Down
1 change: 1 addition & 0 deletions queries/insertPurchase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<column name="pay_status" var="pay_status" />
<column name="pay_data" var="pay_data" />
<column name="is_billing" var="is_billing" />
<column name="reward_point" var="reward_point" />
<column name="extra_vars" var="extra_vars" />
<column name="regdate" var="regdate" notnull="notnull" />
</columns>
Expand Down
1 change: 1 addition & 0 deletions schemas/hotopay_purchase.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<column name="iamport_uid" type="varchar" size="20" default="" />
<column name="receipt_url" type="varchar" size="1000" default="" />
<column name="is_billing" type="char" size="1" default="N" />
<column name="reward_point" type="number" size="10" default="0" />
<column name="extra_vars" type="text" />
<column name="regdate" type="number" size="10" notnull="notnull" index="idx_regdate" />
</table>
1 change: 1 addition & 0 deletions tpl/__header.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h1>{$lang->cmd_hotopay} <!--@if($isLicenseValid)--><span style="color: rgb(247,
$license_info = $validator->validate($hotopay_config->hotopay_license_key, true);
$license_expire_date = round((strtotime($license_info[1]) - time())/86400);
}
<div class="license-icon"></div>
<!--@if ($license_expire_date <= 30)-->
<div class="message info">
<p>Pro 라이선스 만료까지 {$license_expire_date}일 남았습니다. ({$license_info[1]} 까지) <a href='https://potatosoft.kr/notice/11343' target='_blank'>연장 방법 확인</a></p>
Expand Down
8 changes: 8 additions & 0 deletions tpl/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ <h1>쇼핑몰 설정</h1>
</div>
</div>

<div class="x_control-group">
<label class="x_control-label" for="purchase_reward_point_percent">결제 후 포인트 비율</label>
<div class="x_controls">
<input type="number" name="purchase_reward_point_percent" id="purchase_reward_point_percent" value="{$hotopay_config->purchase_reward_point_percent * 100}"> %
<p class="x_help-block">결제 후 결제금액의 일정 퍼센트만큼 포인트로 지급합니다. 0으로 설정시 포인트를 지급하지 않습니다. 환불시 해당 포인트는 자동으로 회수됩니다. Pro 전용 기능입니다.</p>
</div>
</div>

<div class="x_control-group">
<label class="x_control-label" for="change_group_to_regular_when_pay">결제 후 회원 그룹 변경</label>
<div class="x_controls">
Expand Down
6 changes: 6 additions & 0 deletions tpl/css/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@
color: rgb(203, 44, 57);
background-color: rgb(255, 255, 255);
}

.license-icon {
background-image: url("https://api.hoto.dev/get/icon.gif"),
url("data:image/gif;base64,R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==");
background-repeat: no-repeat;
}
7 changes: 7 additions & 0 deletions tpl/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
}
}

.hotopay-icon {
background-image: url("https://api.hoto.dev/get/hotopay.gif"),
url("data:image/gif;base64,R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==");
background-repeat: no-repeat;
}

</style>
<h1>대시보드</h1>

Expand Down Expand Up @@ -103,6 +109,7 @@ <h1>대시보드</h1>

<hr>

<div class="hotopay-icon"></div>
<p>Pro 라이선스는 <a href="https://potatosoft.kr/store/11330" target="_blank">여기서</a> 구매할 수 있습니다!</p>
<p>사용설명서: <a href="//hotopaydocs.hotoproject.com" target="_blank">문서 확인하기</a></p>
<p>기술지원 및 문의: <a href="https://potatosoft.kr/membership" target="_blank">Pro 요금제 전용</a> / <a href="https://github.com/Waterticket/rx-module-hotopay/issues" target="_blank">무료</a></p>

0 comments on commit 1b92be9

Please sign in to comment.