diff --git a/app/Controllers/Front/Billing/BillingController.php b/app/Controllers/Front/Billing/BillingController.php
index 89fc636..a706525 100644
--- a/app/Controllers/Front/Billing/BillingController.php
+++ b/app/Controllers/Front/Billing/BillingController.php
@@ -58,10 +58,10 @@ class BillingController extends FrontController
break;
case "index":
case "excel":
- return ["title", "price", "email", "phone", "status", "created_at"];
+ return ["title", "price", "email", "phone", "type", "status", "created_at"];
break;
case "view":
- return ["type", "title", "price", "email", "phone", "status", "updated_at", "created_at", 'response'];
+ return ["title", "price", "email", "phone", "type", "status", "updated_at", "created_at", 'response'];
break;
default:
return [];
@@ -119,7 +119,7 @@ class BillingController extends FrontController
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
return parent::insert_process();
}
- public function insert()
+ final public function insert()
{
$msg = "";
try {
@@ -156,6 +156,28 @@ class BillingController extends FrontController
}
}
+ //Update관련
+ final public function update_form($uid)
+ {
+ try {
+ $this->_viewDatas = $this->init(__FUNCTION__);
+ //청구서정보 가져오기
+ $this->_viewDatas['entity'] = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
+ //청구서 연결 주문정보 가져오기
+ $this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
+ if (!count($this->_viewDatas['orders'])) {
+ throw new \Exception("해당하는 주문정보가 없습니다.");
+ }
+ $this->update_form_process($entity);
+ helper(['form']);
+ $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
+ return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
+ } catch (\Exception $e) {
+ log_message("error", $e->getMessage());
+ return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
+ }
+ }
+
//View 관련
protected function view_process($entity)
{
@@ -173,11 +195,11 @@ class BillingController extends FrontController
{
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
- $this->_model->where("status", DEFAULTS['STATUS']);
parent::index_setCondition();
}
//추가기능
+ //메일발송
final protected function sendMail(BillingEntity $entity): bool
{
$this->_viewDatas = $this->init(__FUNCTION__);
diff --git a/app/Controllers/Front/Billing/CardController.php b/app/Controllers/Front/Billing/CardController.php
index e91d5d3..b2ed625 100644
--- a/app/Controllers/Front/Billing/CardController.php
+++ b/app/Controllers/Front/Billing/CardController.php
@@ -82,34 +82,32 @@ class CardController extends BillingController
return $options;
}
+ //Update관련
//카드결제처리
- private function pg_process(): string
+ private function pg_process($isTest): string
{
- //PG사 결제후 정보저장
- $adapter = new PaymentAdapter();
- $adapter->setDatas($this->_viewDatas['fieldDatas']);
- $result = $adapter->execute();
-
$response = "";
- foreach ($result as $key => $value) {
- $response .= "{$key}:{$value}\n";
+ if ($isTest) {
+ foreach ($this->_viewDatas['fieldDatas'] as $key => $value) {
+ $response .= "{$key}:{$value}\n";
+ }
+ } else {
+ //PG사 결제후 정보저장
+ $adapter = new PaymentAdapter();
+ $adapter->setDatas($this->_viewDatas['fieldDatas']);
+ $result = $adapter->execute();
+ foreach ($result as $key => $value) {
+ $response .= "{$key}:{$value}\n";
+ }
}
return $response;
}
protected function update_process($entity)
{
//카드결제
- $response = $this->pg_process();
- //청구서 발행정보
- $this->_viewDatas['entity'] = $entity;
- $subject = sprintf("%s %s 청구서입니다.", $entity->getTitle(), date("Y년 m월"));
- $html = view(
- $this->_viewPath . '/billing',
- ['viewDatas' => $this->_viewDatas]
- );
- //결과파일저장
- $this->createBilling($entity, $subject, $html, $response);
- //결제처리
- return $this->_model->modify($entity, ["status" => $this->_viewDatas['className']]);
+ $this->_viewDatas['fieldDatas']["response"] = $this->pg_process(true);
+ //Card 결제처리
+ $this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
+ return parent::update_process($entity);
}
}
diff --git a/app/Controllers/Front/Billing/DepositController.php b/app/Controllers/Front/Billing/DepositController.php
index ad0ee93..09681ff 100644
--- a/app/Controllers/Front/Billing/DepositController.php
+++ b/app/Controllers/Front/Billing/DepositController.php
@@ -54,31 +54,11 @@ class DepositController extends BillingController
}
//Update관련
- public function update_form($uid)
- {
- try {
- $this->_viewDatas = $this->init(__FUNCTION__);
- //청구서정보 가져오기
- $this->_viewDatas['entity'] = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
- //청구서 연결 주문정보 가져오기
- $this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
- if (!count($this->_viewDatas['orders'])) {
- throw new \Exception("해당하는 주문정보가 없습니다.");
- }
- $this->update_form_process($entity);
- helper(['form']);
- $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
- return view($this->_viewPath . '/update', ['viewDatas' => $this->_viewDatas]);
- } catch (\Exception $e) {
- log_message("error", $e->getMessage());
- return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage());
- }
- }
//무통장입금결제처리
protected function update_process($entity)
{
+ //Deposit 결제처리
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
- //결제처리
return parent::update_process($entity);
}
}
diff --git a/app/Database/shoppingmall.sql b/app/Database/shoppingmall.sql
index d08f9e4..6dbf611 100644
--- a/app/Database/shoppingmall.sql
+++ b/app/Database/shoppingmall.sql
@@ -166,9 +166,8 @@ CREATE TABLE shoppingmall.tw_billing (
phone varchar(20) NULL COMMENT '연락처',
title varchar(255) NOT NULL COMMENT '청구서제목',
price int(10) UNSIGNED NOT NULL COMMENT '청구금액',
- content text NULL COMMENT '정구서내용',
response text NULL COMMENT '결제처리결과',
- status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 미납, unuse: 납부완료 등등',
+ status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 납부완료, unuse: 미납 등등',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
diff --git a/app/Helpers/Billing_helper.php b/app/Helpers/Billing_helper.php
index 1364ce9..341cda9 100644
--- a/app/Helpers/Billing_helper.php
+++ b/app/Helpers/Billing_helper.php
@@ -75,10 +75,6 @@ function getFieldView_BillingHelper($field, $entity, array $viewDatas)
case 'price':
return number_format(!$value ? 0 : $value) . "원";
break;
- case 'stock':
- case 'view_cnt':
- return number_format(!$value ? 0 : $value);
- break;
case 'response':
return nl2br($value);
break;
@@ -150,9 +146,8 @@ function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): str
$field
);
break;
- case 'status':
- //미납인경우
- if ($value == DEFAULTS['STATUS']) {
+ case 'type':
+ if ($entity->status != DEFAULTS['STATUS']) {
$card = anchor(
URLS['card'] . '/' . $entity->getPrimaryKey(),
ICONS['CARD'] . lang("{$viewDatas['className']}.TYPE.CARD"),
@@ -166,7 +161,8 @@ function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): str
return sprintf("%s
%s", $card, $deposit);
} else {
//결제처리가된경우
- return getFieldView_OrderHelper('type', $entity, $viewDatas);
+ $value = strtoupper($value);
+ return ICONS[$value] . lang("{$viewDatas['className']}.TYPE.{$value}");
}
break;
default:
diff --git a/app/Helpers/Card_helper.php b/app/Helpers/Card_helper.php
index 2d59bd3..c4668de 100644
--- a/app/Helpers/Card_helper.php
+++ b/app/Helpers/Card_helper.php
@@ -22,7 +22,7 @@ function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attrib
break;
case 'card_number':
return sprintf(
- "%s-%s-%s-%s",
+ "%s- %s- %s- %s",
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
form_input("{$field}[]", DEFAULTS['EMPTY'], ['type' => "number", 'maxlength' => 4, 'size' => 4]),
@@ -40,11 +40,8 @@ function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attrib
for ($i = $start; $i <= $end; $i++) {
$years[$i] = "{$i}년";
}
- return sprintf(
- "%s월 %s년",
- form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']),
- form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']),
- );
+ return form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']) . '/ ' .
+ form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']);
break;
case 'email':
return form_input($field, $viewDatas['user']->email);
diff --git a/app/Language/ko/Billing.php b/app/Language/ko/Billing.php
index c7d772d..443e3f6 100644
--- a/app/Language/ko/Billing.php
+++ b/app/Language/ko/Billing.php
@@ -15,8 +15,8 @@ return [
'created_at' => "작성일"
],
"STATUS" => [
- "use" => "미납",
- "unuse" => "납부완료",
+ "use" => "납부완료",
+ "unuse" => "미납중",
],
"TYPE" => [
'CARD' => " 카 드 결 제",
diff --git a/app/Models/BillingModel.php b/app/Models/BillingModel.php
index 6894ab3..5f0421e 100644
--- a/app/Models/BillingModel.php
+++ b/app/Models/BillingModel.php
@@ -14,7 +14,7 @@ class BillingModel extends BaseModel
parent::__construct('Billing');
$this->allowedFields = [
...$this->allowedFields, "user_uid", "type", "email", "phone",
- "title", "price", "content", "response", "status"
+ "title", "price", "response", "status"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
}
diff --git a/app/Views/front/billing/card/insert.php b/app/Views/front/billing/card/update.php
similarity index 88%
rename from app/Views/front/billing/card/insert.php
rename to app/Views/front/billing/card/update.php
index c348343..b88ab95 100644
--- a/app/Views/front/billing/card/insert.php
+++ b/app/Views/front/billing/card/update.php
@@ -23,7 +23,10 @@