shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-17 18:06:18 +09:00
parent 00d0660b91
commit f0ae0902b7
17 changed files with 329 additions and 243 deletions

View File

@ -175,9 +175,9 @@ define('URLS', [
'Order' => '/front/order', 'Order' => '/front/order',
'addCart' => '/front/order/addCart', 'addCart' => '/front/order/addCart',
'cancelCart' => '/front/order/cancelCart', 'cancelCart' => '/front/order/cancelCart',
'Billing' => '/front/billing/insert', 'Billing' => '/front/billing',
'cardPayment' => '/front/billing/payment/card', 'card' => '/front/billing/card',
'depositPayment' => '/front/billing/payment/deposit', 'deposit' => '/front/billing/deposit',
]); ]);
//SESSION 관련 //SESSION 관련
define('SESSION_NAMES', [ define('SESSION_NAMES', [
@ -207,7 +207,11 @@ define('AUTH_ADAPTERS', [
define("MALLS", [ define("MALLS", [
"support" => "support@idcjp.jp", "support" => "support@idcjp.jp",
"master" => "master@idcjp.jp", "master" => "master@idcjp.jp",
"title" => "Mall Master" "title" => "Mall Master",
"banks" => [
["name" => "신한은행", "account" => "계좌번호", "holder" => "예금주"],
["name" => "국민은행", "account" => "계좌번호1", "holder" => "예금주1"],
]
]); ]);
//Upload , Download 관련 //Upload , Download 관련

View File

@ -174,14 +174,12 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou
$routes->get('cancelCart/(:uuid)', 'CartController::delete/$1'); $routes->get('cancelCart/(:uuid)', 'CartController::delete/$1');
}); });
$routes->group('billing', ['namespace' => 'App\Controllers\Front\Billing', 'filter' => 'authFilter:user'], static function ($routes) { $routes->group('billing', ['namespace' => 'App\Controllers\Front\Billing', 'filter' => 'authFilter:user'], static function ($routes) {
$routes->get('', 'BillingController::index', ['filter' => 'authFilter:user']); $routes->get('', 'BillingController::index');
$routes->get('download/(:any)/(:num)', 'BillingController::download/$1/$2'); $routes->post('', 'BillingController::insert');
$routes->group('payment', ['namespace' => 'App\Controllers\Front\Billing\Payment'], static function ($routes) { $routes->get('card', 'CardController::insert_form');
$routes->get('card/(:num)', 'CardController::update_form/$1'); $routes->post('card', 'CardController::insert');
$routes->post('card/(:num)', 'CardController::update/$1'); $routes->get('deposit', 'DepositController::insert_form');
$routes->get('deposit/(:num)', 'DepositController::update_form/$1'); $routes->post('deposit', 'DepositController::insert');
$routes->post('deposit/(:num)', 'DepositController::update/$1');
});
}); });
}); });
/* /*

View File

@ -2,16 +2,22 @@
namespace App\Controllers\Front\Billing; namespace App\Controllers\Front\Billing;
use App\Controllers\Front\FrontController;
use App\Entities\BillingEntity;
use App\Entities\OrderEntity;
use App\Models\BillingModel; use App\Models\BillingModel;
use App\Models\OrderBillingModel;
use App\Models\OrderModel;
use App\Models\UserModel;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use App\Controllers\Front\FrontController;
use App\Models\UserModel;
class BillingController extends FrontController class BillingController extends FrontController
{ {
private $_userModel = null; private $_userModel = null;
private $_orderModel = null;
private $_orderBillingModel = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
@ -25,6 +31,9 @@ class BillingController extends FrontController
//Default 회원정보 Category //Default 회원정보 Category
$this->_category = DEFAULTS['CATEGORY_BILLING']; $this->_category = DEFAULTS['CATEGORY_BILLING'];
$this->isRole('index'); $this->isRole('index');
//사용자정보
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
} }
final protected function getUserModel(): UserModel final protected function getUserModel(): UserModel
@ -32,32 +41,100 @@ class BillingController extends FrontController
return $this->_userModel = $this->_userModel ?: new UserModel(); return $this->_userModel = $this->_userModel ?: new UserModel();
} }
final public function getFields(string $action = ""): array final protected function getOrderModel(): OrderModel
{
return $this->_orderModel = $this->_orderModel ?: new OrderModel();
}
final protected function getOrderBillingModel(): OrderBillingModel
{
return $this->_orderBillingModel = $this->_orderBillingModel ?: new OrderBillingModel();
}
public function getFields(string $action = ""): array
{ {
switch ($action) { switch ($action) {
case 'update': case "insert":
return ['order_uid', "title", "upload_file", "status"]; return ["price"];
break; break;
case "index": case "index":
case "excel": case "excel":
return ["order_uid", "title", "upload_file", "status", "updated_at", "created_at"]; return ["email", "phone", "title", "price", "status", "updated_at", "created_at"];
break; break;
case "view": case "view":
return ['order_uid', "title", "upload_file", "status", "updated_at", "created_at", 'response']; return ["email", "phone", "title", "price", "status", "updated_at", "created_at", 'response'];
break; break;
default: default:
return []; return [];
break; break;
} }
} }
final public function getFieldFilters(): array public function getFieldFilters(): array
{
return ['order_uid', "status"];
}
final public function getFieldBatchFilters(): array
{ {
return ["status"]; return ["status"];
} }
public function getFieldBatchFilters(): array
{
return ["status"];
}
//Insert관련 (결제처리용)
protected function insert_form_process()
{
parent::insert_form_process();
}
//Insert관련
private function linkOrderBilling(BillingEntity $entity, array $order_uids)
{
foreach ($order_uids as $order_uid) {
$this->getOrderBillingModel()->create([
"billing_uid" => $entity->getPrimaryKey(),
'order_uid' => $order_uid
]);
}
}
protected function insert_process()
{
//title지정하기
$this->_viewDatas['fieldDatas']['title'] = date("Y년m월") . " 청구서입니다.";
//사용자정보
$this->_viewDatas['fieldDatas']['email'] = $this->_viewDatas['user']->email;
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
return parent::insert_process();
}
public function insert()
{
$msg = "";
try {
$this->_viewDatas = $this->init(__FUNCTION__);
$this->insert_validate();
//주문정보 가져오기
$order_uids = $this->request->getVar('order_uids') ?: throw new \Exception("주문정보가 지정되지 않았습니다.");
//Transaction 시작
$this->_model->transStart();
//Billing 생성
$entity = $this->insert_process();
//DB연결용
$this->linkOrderBilling($entity, $order_uids);
//Transaction Commit
$this->_model->transComplete();
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}" . __FUNCTION__ . " 완료하였습니다.";
//기존 return_url 무시
$this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->to(URLS['Billing']);
} catch (\Exception $e) {
//Transaction Rollback
$this->_model->transRollback();
$msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage();
log_message("error", $e->getMessage());
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
} finally {
$this->_session->setFlashdata("return_message", $msg);
}
}
//Index관련 //Index관련
protected function index_setCondition() protected function index_setCondition()
@ -68,13 +145,37 @@ class BillingController extends FrontController
parent::index_setCondition(); parent::index_setCondition();
} }
//Download관련 //추가기능
public function download_process($field, $entity) //청구서관련
final protected function createBilling(OrderEntity $entity, string $subject, string $html, $response = ''): BillingEntity
{ {
list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); //청구서파일 생성
if (!is_file(PATHS['BILLING'] . "/" . $uploaded_filename)) { $fileName = sprintf("%s_%s", $entity->getPrimaryKey(), date('Y-m-d_Hm') . '.xlsx');
throw new \Exception("첨부파일이 확인되지 않습니다.\n"); $writer = $this->spreadSheet($html);
} $writer->save(PATHS['BILLING'] . '/' . $fileName);
return $this->response->download(PATHS['BILLING'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename); //메일발송
$this->sendBilling($this->_viewDatas['fieldDatas']['email'], $subject, $html);
$fieldDatas = [
'order_uid' => $entity->getPrimaryKey(),
'user_uid' => $this->_viewDatas['auth'][AUTH_FIELDS['ID']],
'email' => $this->_viewDatas['fieldDatas']['email'],
'phone' => $this->_viewDatas['fieldDatas']['phone'],
'title' => $subject,
'content' => $html,
'upload_file' => sprintf("%s%s%s", $this->_viewDatas['className'] . '.xlsx', DEFAULTS['DELIMITER_FILE'], $fileName),
'response' => $response,
'status' => DEFAULTS['STATUS']
];
return $this->_model->create($fieldDatas);
}
final protected function sendBilling($email, string $subject, string $html): bool
{
$mail = \Config\Services::email();
$mail->setFrom(MALLS['support'], MALLS['title'], MALLS['master']);
$mail->setTo($email);
$mail->setCC(MALLS['master']);
$mail->setSubject($subject);
$mail->setMessage($html);
return $mail->send();
} }
} }

View File

@ -1,13 +1,13 @@
<?php <?php
namespace App\Controllers\Front\Order\Payment; namespace App\Controllers\Front\Billing;
use App\Libraries\Adapter\Payment\CookiePayment as PaymentAdapter; use App\Libraries\Adapter\Payment\CookiePayment as PaymentAdapter;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class CardController extends PaymentController class CardController extends BillingController
{ {
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Controllers\Front\Order\Payment; namespace App\Controllers\Front\Billing\Payment;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
@ -16,17 +16,12 @@ class DepositController extends PaymentController
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title'); $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title');
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])]; $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])];
helper($this->_viewDatas['className']); helper($this->_viewDatas['className']);
$this->_viewDatas['bank'] = [
"name" => getenv("payment.deposit.bank.name") ?: "은행명",
"account" => getenv("payment.deposit.bank.account") ?: "계좌번호",
"holder" => getenv("payment.deposit.bank.holder") ?: "예금주"
];
} }
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
switch ($action) { switch ($action) {
case 'update': case 'insert':
return ["email", "phone"]; return ["email", "phone"];
break; break;
default: default:
@ -37,15 +32,21 @@ class DepositController extends PaymentController
protected function getFieldRule(string $field, array $rules, string $action = ""): array protected function getFieldRule(string $field, array $rules, string $action = ""): array
{ {
switch ($field) { switch ($field) {
case "order_uid":
$rules[$field] = 'required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]';
break;
case "email": case "email":
$rules[$field] = 'required|valid_email'; $rules[$field] = 'required|valid_email';
break; break;
case "phone": case "phone":
$rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]'; $rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]';
break; break;
case "title":
$rules[$field] = 'required|string';
break;
case "price":
$rules[$field] = 'required|numeric';
break;
case "content":
$rules[$field] = 'required|string';
break;
default: default:
$rules = parent::getFieldRule($field, $rules, $action); $rules = parent::getFieldRule($field, $rules, $action);
break; break;
@ -62,6 +63,34 @@ class DepositController extends PaymentController
} }
//Insert관련 //Insert관련
protected function insert_form_process()
{
parent::insert_form_process();
$this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => ['price' => $this->_viewDatas['price']]];
}
public function insert_form()
{
try {
$this->_viewDatas = $this->init(__FUNCTION__);
//결제금액 가져오기
$this->_viewDatas['price'] = $this->request->getVar('price') ?: throw new \Exception("결제금액이 지정되지 않았습니다.");
//주문정보 가져오기
$order_uids = $this->request->getVar('order_uids') ?: throw new \Exception("주문정보가 지정되지 않았습니다.");
// echo var_export($order_uids, true);
// exit;
$this->_viewDatas['orders'] = $this->getOrderModel()->whereIn($this->getOrderModel()->getPrimaryKey(), $order_uids)->findAll();
if (!count($this->_viewDatas['orders'])) {
throw new \Exception("해당하는 주문정보가 없습니다.");
}
$this->insert_form_process();
helper(['form']);
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return view($this->_viewPath . '/insert', ['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) protected function update_process($entity)
{ {

View File

@ -1,98 +0,0 @@
<?php
namespace App\Controllers\Front\Billing\Payment;
use App\Entities\BillingEntity;
use App\Entities\OrderEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Controllers\Front\Billing\BillingController;
class PaymentController extends BillingController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
}
//Update관련 (결제처리용)
protected function update_form_process($entity)
{
$entity = parent::update_form_process($entity);
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
return $entity;
}
final public function update_form($uid)
{
try {
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
$this->_viewDatas = $this->init(__FUNCTION__);
$this->_viewDatas['entity'] = $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());
}
}
final public function update($uid)
{
$msg = "";
try {
$entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
$this->_viewDatas = $this->init(__FUNCTION__);
$this->update_validate($entity);
//Transaction 시작
$this->_model->transStart();
$entity = $this->update_process($entity);
//Transaction Commit
$this->_model->transComplete();
$msg = "{$this->_viewDatas['title']}에서 {$entity->getTitle()}의 결제가 완료하였습니다.";
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
} catch (\Exception $e) {
//Transaction Rollback
$this->_model->transRollback();
$msg = "{$this->_viewDatas['title']}에서 결제를 실패하였습니다.\n" . $e->getMessage();
log_message("error", $e->getMessage());
$this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']);
return redirect()->back()->withInput();
} finally {
$this->_session->setFlashdata("return_message", $msg);
}
}
//청구서관련
final protected function createBilling(OrderEntity $entity, string $subject, string $html, $response = ''): BillingEntity
{
//청구서파일 생성
$fileName = sprintf("%s_%s", $entity->getPrimaryKey(), date('Y-m-d_Hm') . '.xlsx');
$writer = $this->spreadSheet($html);
$writer->save(PATHS['BILLING'] . '/' . $fileName);
//메일발송
$this->sendBilling($this->_viewDatas['fieldDatas']['email'], $subject, $html);
$fieldDatas = [
'order_uid' => $entity->getPrimaryKey(),
'user_uid' => $this->_viewDatas['auth'][AUTH_FIELDS['ID']],
'email' => $this->_viewDatas['fieldDatas']['email'],
'phone' => $this->_viewDatas['fieldDatas']['phone'],
'title' => $subject,
'content' => $html,
'upload_file' => sprintf("%s%s%s", $this->_viewDatas['className'] . '.xlsx', DEFAULTS['DELIMITER_FILE'], $fileName),
'response' => $response,
'status' => DEFAULTS['STATUS']
];
return $this->_model->create($fieldDatas);
}
final protected function sendBilling($email, string $subject, string $html): bool
{
$mail = \Config\Services::email();
$mail->setFrom(MALLS['support'], MALLS['title'], MALLS['master']);
$mail->setTo($email);
$mail->setCC(MALLS['master']);
$mail->setSubject($subject);
$mail->setMessage($html);
return $mail->send();
}
}

View File

@ -148,7 +148,7 @@ CREATE TABLE shoppingmall.tw_order (
quantity varchar(255) NOT NULL COMMENT '수량', quantity varchar(255) NOT NULL COMMENT '수량',
type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성', type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성',
paymentday int(2) UNSIGNED NULL COMMENT '결제일', paymentday int(2) UNSIGNED NULL COMMENT '결제일',
status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 사용, unuse: 장바구니/사용않함', status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 사용, unuse: 사용않함',
updated_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(), created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,
@ -161,10 +161,12 @@ DROP TABLE IF EXISTS shoppingmall.tw_billing;
CREATE TABLE shoppingmall.tw_billing ( CREATE TABLE shoppingmall.tw_billing (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT, uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
user_uid varchar(36) NOT NULL COMMENT '사용자 정보', user_uid varchar(36) NOT NULL COMMENT '사용자 정보',
type varchar(10) NULL DEFAULT 'Card' COMMENT 'Card: 카드결제, Deposit:무통장입금',
email varchar(50) NOT NULL,
phone varchar(20) NULL COMMENT '연락처',
title varchar(255) NOT NULL COMMENT '청구서제목', title varchar(255) NOT NULL COMMENT '청구서제목',
price int(10) UNSIGNED NOT NULL COMMENT '청구금액', price int(10) UNSIGNED NOT NULL COMMENT '청구금액',
content text NOT NULL COMMENT '정구서내용', content text NULL COMMENT '정구서내용',
upload_file varchar(255) NULL COMMENT '파일명',
response text NULL COMMENT '결제처리결과', response text NULL COMMENT '결제처리결과',
status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 미납, unuse: 납부완료 등등', status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 미납, unuse: 납부완료 등등',
updated_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL,
@ -172,4 +174,17 @@ CREATE TABLE shoppingmall.tw_billing (
deleted_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL,
PRIMARY KEY (uid), PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid) CONSTRAINT FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='청구서 정보'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='청구서 정보';
DROP TABLE IF EXISTS shoppingmall.tw_orderbilling;
CREATE TABLE shoppingmall.tw_orderbilling (
uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
order_uid varchar(36) NOT NULL COMMENT 'Order 정보',
billing_uid int(10) UNSIGNED NOT NULL COMMENT '청구서 정보',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (uid),
CONSTRAINT FOREIGN KEY (order_uid) REFERENCES tw_order (uid),
CONSTRAINT FOREIGN KEY (billing_uid) REFERENCES tw_billing (uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='주문-청구서 정보';

View File

@ -15,17 +15,5 @@ class BillingEntity extends BaseEntity
return $this->attributes['title']; return $this->attributes['title'];
} }
//추가기능 //추가기능
//파일관련 Field전용
final public function getFileDownload($url, $field = "upload_file")
{
if (is_null($this->attributes[$field])) {
return "";
}
$files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]);
return anchor(
$url,
ICONS['IMAGE_FILE'] . $files[0],
["target" => "_self"]
);
}
} }

View File

@ -0,0 +1,19 @@
<?php
namespace App\Entities;
class OrderBillingEntity extends BaseEntity
{
protected $datamap = [];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $casts = [];
//기본기능
final public function getTitle(): string
{
return $this->attributes['order_uid'];
}
//추가기능
}

View File

@ -2,7 +2,6 @@
return [ return [
'title' => "무통장입금결제", 'title' => "무통장입금결제",
'label' => [ 'label' => [
'order_uid' => '주문번호',
'email' => '이메일', 'email' => '이메일',
'phone' => '연락처', 'phone' => '연락처',
], ],

View File

@ -3,7 +3,6 @@
namespace App\Models; namespace App\Models;
use App\Entities\BillingEntity; use App\Entities\BillingEntity;
use App\Entities\ProductEntity;
class BillingModel extends BaseModel class BillingModel extends BaseModel
{ {
@ -15,8 +14,8 @@ class BillingModel extends BaseModel
{ {
parent::__construct('Billing'); parent::__construct('Billing');
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, 'order_uid', "user_uid", "email", "phone", ...$this->allowedFields, "user_uid", "type", "email", "phone",
"title", "upload_file", "response", "status" "title", "price", "content", "response", "status"
]; ];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
@ -27,9 +26,6 @@ class BillingModel extends BaseModel
public function getFieldRule(string $field, array $rules, string $action = ""): array public function getFieldRule(string $field, array $rules, string $action = ""): array
{ {
switch ($field) { switch ($field) {
case 'order_uid':
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
break;
case "email": case "email":
$rules[$field] = "required|trim|valid_email"; $rules[$field] = "required|trim|valid_email";
break; break;
@ -39,9 +35,6 @@ class BillingModel extends BaseModel
case $this->getTitleField(): case $this->getTitleField():
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
break; break;
case "upload_file": //uploaded[{$field}] == requried와 같은의미
$rules[$field] = "if_exist|string";
break;
case "response": case "response":
$rules[$field] = "if_exist|string"; $rules[$field] = "if_exist|string";
break; break;

View File

@ -0,0 +1,50 @@
<?php
namespace App\Models;
use App\Entities\OrderBillingEntity;
class OrderBillingModel extends BaseModel
{
protected $table = "tw_orderbilling";
protected $returnType = OrderBillingEntity::class;
public function __construct()
{
parent::__construct('Billing');
$this->allowedFields = [
...$this->allowedFields, "order_uid", "billing_uid"
];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
}
final public function getTitleField(): string
{
return 'billing_uid';
}
public function getFieldRule(string $field, array $rules, string $action = ""): array
{
switch ($field) {
case 'order_uid':
$rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
break;
case 'billing_uid':
$rules[$field] = "required|numeric";
break;
default:
$rules = parent::getFieldRule($field, $rules, $action);
break;
}
return $rules;
}
public function getEntity($conditions): OrderBillingEntity
{
return parent::getEntity($conditions);
}
public function create(array $formDatas): OrderBillingEntity
{
return $this->create_process(new OrderBillingEntity(), $formDatas);
}
public function modify(OrderBillingEntity $entity, array $formDatas): OrderBillingEntity
{
return $this->modify_process($entity, $formDatas);
}
}

View File

@ -3,7 +3,7 @@
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" /> <link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content"> <div id="content">
<div><?= html_entity_decode($viewDatas['category']->head) ?></div> <div><?= html_entity_decode($viewDatas['category']->head) ?></div>
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?> <?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-hover table-striped"> <table class="form table table-bordered table-hover table-striped">
<tr> <tr>
<td class="label">상품명</td> <td class="label">상품명</td>

View File

@ -1,23 +0,0 @@
<link href="<?= base_url("css/front/billing.css") ?>" media=" screen" rel="stylesheet" type="text/css" />
<table id="billing">
<tr>
<td class="label">상품명</td>
<td class="column"><?= $viewDatas['entity']->getTitle() ?></td>
</tr>
<tr>
<td class="label">결제금액</td>
<td class="column"><?= number_format($viewDatas['entity']->price) ?>원</td>
</tr>
<tr>
<td class="label">은행명</td>
<td class="column"><?= $viewDatas['bank']['name'] ?></td>
</tr>
<tr>
<td class="label">계좌번호</td>
<td class="column"><?= $viewDatas['bank']['account'] ?></td>
</tr>
<tr>
<td class="label">예금주</td>
<td class="column"><?= $viewDatas['bank']['holder'] ?></td>
</tr>
</table>

View File

@ -0,0 +1,49 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-hover table-striped">
<tr>
<td class="label">주문정보</td>
<td class="column">
<ul class="orders">
<?php foreach ($viewDatas['orders'] as $order) : ?>
<li class="text-start"><?= $order->getTitle() ?> * <?= $order->quantity ?>개 = <?= number_format($order->price) ?>원</li>
<?php endforeach ?>
</ul>
</td>
</tr>
<tr>
<td class="label">결제금액</td>
<td class="column"><?= number_format($viewDatas['price']) ?>원</td>
</tr>
<tr>
<td class="label">은행정보</td>
<td class="column">
<ul class="banks">
<?php foreach (MALLS['banks'] as $bank) : ?>
<li><?= $bank['name'] ?> , <?= $bank['account'] ?> , <?= $bank['holder'] ?></li>
<?php endforeach ?>
</ul>
</td>
</tr>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_DepositHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_DepositHelper($field, old($field, DEFAULTS['EMPTY']), $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td class="label"></td>
<td class="column"><?= form_submit('', '무통장입금', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
<?= form_close(); ?>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -1,44 +0,0 @@
<?= $this->extend('layouts/front') ?>
<?= $this->section('content') ?>
<link href="/css/front/content.css" media="screen" rel="stylesheet" type="text/css" />
<div id="content">
<div><?= html_entity_decode($viewDatas['category']->head) ?></div>
<?= form_open_multipart(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<table class="form table table-bordered table-hover table-striped">
<tr>
<td class="label">상품명</td>
<td class="column"><?= $viewDatas['entity']->getTitle() ?></td>
</tr>
<tr>
<td class="label">결제금액</td>
<td class="column"><?= number_format($viewDatas['entity']->price) ?>원</td>
</tr>
<tr>
<td class="label">은행명</td>
<td class="column"><?= $viewDatas['bank']['name'] ?></td>
</tr>
<tr>
<td class="label">계좌번호</td>
<td class="column"><?= $viewDatas['bank']['account'] ?></td>
</tr>
<tr>
<td class="label">예금주</td>
<td class="column"><?= $viewDatas['bank']['holder'] ?></td>
</tr>
<?php foreach ($viewDatas['fields'] as $field) : ?>
<tr>
<td class="label"><?= getFieldLabel_DepositHelper($field, $viewDatas) ?></td>
<td class="column">
<?= getFieldForm_DepositHelper($field, old($field, $viewDatas['entity']->$field ?: DEFAULTS['EMPTY']), $viewDatas) ?>
<?= validation_show_error($field); ?>
</td>
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '무통장입금', array("class" => "btn btn-outline btn-primary")); ?></td>
</tr>
</table>
<?= form_close(); ?>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -42,8 +42,13 @@
</table> </table>
</div> </div>
<div id="order" class="col-2"> <div id="order" class="col-2">
<?php $price = $total_price - $total_sale ?>
<div class="orderbox"> <div class="orderbox">
<?= form_open(URLS['Billing'], $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?> <?= form_open(URLS['Billing'], ['method' => 'post'], $viewDatas['forms']['hiddens']) ?>
<?php foreach ($viewDatas['entitys'] as $entity) : ?>
<?= form_hidden("order_uids[]", $entity->getPrimaryKey()) ?>
<?php endforeach ?>
<?= form_hidden("price", $price) ?>
<div class="title">결제정보</div> <div class="title">결제정보</div>
<div class="item"> <div class="item">
<span class="label">상품수</span> <span class="label">상품수</span>
@ -59,15 +64,16 @@
</div> </div>
<div class="item total"> <div class="item total">
<span class="label">총결제금액</span> <span class="label">총결제금액</span>
<span class="value"><?= number_format($total_price - $total_sale) ?>원</span> <span class="value"><?= number_format($price) ?>원</span>
</div>
<div class="item submit">
<?= form_submit('', '구매하기', array('', "class" => "btn btn-outline btn-primary")); ?>
</div> </div>
<div class="submit"><?= form_submit('', '결제하기', array("class" => "btn btn-outline btn-primary")); ?></div>
<?= form_close(); ?> <?= form_close(); ?>
</div> </div>
</div> </div>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div> </div>
<div class="bottom"><?= $viewDatas['pagination'] ?></div>
<div><?= html_entity_decode($viewDatas['category']->tail) ?></div>
</div> </div>
</div> <?= $this->endSection() ?>
<?= $this->endSection() ?>