From 1064eefa1bc89731eed6745c5b8b9c206fbd4357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 16 Aug 2023 19:08:51 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Config/Routes.php | 27 +++--- app/Controllers/Admin/BillingController.php | 6 +- app/Controllers/BaseController.php | 86 +++++++++--------- app/Controllers/Front/BillingController.php | 25 ++++- app/Controllers/Front/BoardController.php | 10 +- .../Front/Order/OrderController.php | 4 +- .../Front/Order/Payment/CardController.php | 19 ++-- .../Front/Order/Payment/DepositController.php | 36 +++----- .../Front/Order/Payment/PaymentController.php | 68 +++++++++----- app/Database/shoppingmall.sql | 9 +- app/Entities/BillingEntity.php | 5 +- app/Helpers/Billing_helper.php | 31 +++++-- app/Helpers/Board_helper.php | 27 +++--- app/Helpers/Card_helper.php | 4 +- app/Helpers/Deposit_helper.php | 4 +- app/Language/ko/Billing.php | 2 + app/Language/ko/Card.php | 2 +- app/Language/ko/Deposit.php | 2 +- app/Models/BillingModel.php | 13 ++- app/Views/front/billing/index.php | 1 - app/Views/front/order/deposit/billing.php | 2 +- composer.json | 3 +- ...adc-3ac1-858616da109b_2023-08-16_1808.xlsx | Bin 0 -> 6430 bytes 23 files changed, 226 insertions(+), 160 deletions(-) create mode 100644 writable/billing/8ba39b2a-dffb-badc-3ac1-858616da109b_2023-08-16_1808.xlsx diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 8011bef..9ea29f9 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -62,7 +62,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('category', static function ($routes) { $routes->get('', 'CategoryController::index'); - $routes->get('excel', 'CategoryController::excel/$1'); + $routes->get('excel', 'CategoryController::excel'); $routes->get('insert', 'CategoryController::insert_form'); $routes->post('insert', 'CategoryController::insert'); $routes->get('update/(:num)', 'CategoryController::update_form/$1'); @@ -76,7 +76,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('board', static function ($routes) { $routes->get('', 'BoardController::index'); - $routes->get('excel', 'BoardController::excel/$1'); + $routes->get('excel', 'BoardController::excel'); $routes->get('insert', 'BoardController::insert_form'); $routes->post('insert', 'BoardController::insert'); $routes->get('update/(:num)', 'BoardController::update_form/$1'); @@ -91,7 +91,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('sitepage', static function ($routes) { $routes->get('', 'SitepageController::index'); - $routes->get('excel', 'SitepageController::excel/$1'); + $routes->get('excel', 'SitepageController::excel'); $routes->get('insert', 'SitepageController::insert_form'); $routes->post('insert', 'SitepageController::insert'); $routes->get('update/(:num)', 'SitepageController::update_form/$1'); @@ -103,7 +103,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('product', static function ($routes) { $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); + $routes->get('excel', 'ProductController::excel'); $routes->get('insert', 'ProductController::insert_form'); $routes->post('insert', 'ProductController::insert'); $routes->get('update/(:uuid)', 'ProductController::update_form/$1'); @@ -116,6 +116,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('order', static function ($routes) { $routes->get('', 'OrderController::index'); + $routes->get('excel', 'OrderController::excel'); $routes->get('update/(:uuid)', 'OrderController::update_form/$1'); $routes->post('update/(:uuid)', 'OrderController::update/$1'); $routes->get('view/(:uuid)', 'OrderController::view/$1'); @@ -125,13 +126,14 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('billing', static function ($routes) { $routes->get('', 'BillingController::index'); - $routes->get('update/(:uuid)', 'BillingController::update_form/$1'); - $routes->post('update/(:uuid)', 'BillingController::update/$1'); - $routes->get('view/(:uuid)', 'BillingController::view/$1'); - $routes->get('delete/(:uuid)', 'BillingController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'BillingController::toggle/$1/$2'); + $routes->get('excel', 'BillingController::excel'); + $routes->get('update/(:num)', 'BillingController::update_form/$1'); + $routes->post('update/(:num)', 'BillingController::update/$1'); + $routes->get('view/(:num)', 'BillingController::view/$1'); + $routes->get('delete/(:num)', 'BillingController::delete/$1', ['filter' => 'authFilter:master']); + $routes->get('toggle/(:num)/(:hash)', 'BillingController::toggle/$1/$2'); $routes->post('batchjob', 'BillingController::batchjob`'); - $routes->get('download/(:any)/(:uuid)', 'BillingController::download/$1/$2'); + $routes->get('download/(:any)/(:num)', 'BillingController::download/$1/$2'); }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { @@ -148,7 +150,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou }); $routes->group('board', static function ($routes) { $routes->get('', 'BoardController::index'); - $routes->get('excel', 'BoardController::excel/$1'); $routes->get('insert', 'BoardController::insert_form'); $routes->post('insert', 'BoardController::insert'); $routes->get('update/(:num)', 'BoardController::update_form/$1'); @@ -164,7 +165,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou }); $routes->group('product', static function ($routes) { $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); $routes->get('view/(:uuid)', 'ProductController::view/$1'); }); $routes->group('order', ['namespace' => 'App\Controllers\Front\Order'], static function ($routes) { @@ -180,7 +180,8 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou }); }); $routes->group('billing', static function ($routes) { - $routes->get('', 'BillingController::index'); + $routes->get('', 'BillingController::index', ['filter' => 'authFilter:user']); + $routes->get('download/(:any)/(:num)', 'BillingController::download/$1/$2'); }); }); /* diff --git a/app/Controllers/Admin/BillingController.php b/app/Controllers/Admin/BillingController.php index 6565949..019019d 100644 --- a/app/Controllers/Admin/BillingController.php +++ b/app/Controllers/Admin/BillingController.php @@ -24,14 +24,14 @@ class BillingController extends AdminController { switch ($action) { case 'update': - return ["user_uid", 'order_uid', "title", "upload_file", "status"]; + return ["user_uid", 'order_uid', "email", "phone", "title", "upload_file", "status"]; break; case "index": case "excel": - return ["user_uid", "order_uid", "title", "upload_file", "status", "updated_at", "created_at"]; + return ["user_uid", "order_uid", "email", "phone", "title", "upload_file", "status", "updated_at", "created_at"]; break; case "view": - return ["user_uid", 'order_uid', "title", "upload_file", "status", "updated_at", "created_at", 'response']; + return ["user_uid", 'order_uid', "email", "phone", "title", "upload_file", "status", "updated_at", "created_at", 'response']; break; default: return []; diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 267fd75..bc41848 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -550,10 +550,13 @@ abstract class BaseController extends Controller private function index_getEntitys(): array { $this->index_setCondition(); - return $this->_viewDatas['page'] ? $this->_model->findAll( - $this->_viewDatas['per_page'], - $this->_viewDatas['page'] * $this->_viewDatas['per_page'] - $this->_viewDatas['per_page'] - ) : $this->_model->findAll(); + if (array_key_exists('page', $this->_viewDatas)) { + return $this->_model->findAll( + $this->_viewDatas['per_page'], + $this->_viewDatas['page'] * $this->_viewDatas['per_page'] - $this->_viewDatas['per_page'] + ); + } + return $this->_model->findAll(); } public function index() { @@ -596,37 +599,44 @@ abstract class BaseController extends Controller } //Excel 관련 - private function excel_spreadSheet(array $viewDatas) + final protected function spreadSheet(string $html) { - //Excepl 초기화 - $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); - $sheet = $spreadsheet->getActiveSheet(); - //Header용 - $column = 'A'; - foreach ($viewDatas['fields'] as $field) { - $sheet->setCellValue($column++ . '1', lang($this->_viewDatas['className'] . '.label.' . $field)); - } - //본문용 - $line = 2; - foreach ($this->index_getEntitys() as $entity) { - $column = 'A'; - foreach ($viewDatas['fields'] as $field) { - $value = in_array($field, $viewDatas['fieldFilters']) ? $viewDatas['fieldFormOptions'][$field][$entity->$field] : $entity->$field; - $sheet->setCellValue($column . $line, $value); - $column++; - } - $line++; - } - return $spreadsheet; + // //HTML저장 + // file_put_contents($fileName . '.html', $html); + + //HTML Read + $reader = new \PhpOffice\PhpSpreadsheet\Reader\Html(); + $spreadsheet = $reader->loadFromString($html); + // from File의 경우 + // $spreadsheet = $reader->load($fileName . '.html'); + + //Excel저장 + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); + // $writer->save($fileName . '.xlsx'); + + // //PDF저장 + // $writer = new \PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf($spreadsheet); + // $writer->save($fileName . '.pdf'); + return $writer; } public function excel() { try { $this->_viewDatas = $this->init(__FUNCTION__); - $fileName = date('Y-m-d_Hm') . '.xlsx'; - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($this->excel_spreadSheet($this->_viewDatas), 'Xlsx'); + $this->_viewDatas['Entitys'] = $this->index_getEntitys(); + $html = view( + $this->_viewPath . '/excel', + ['viewDatas' => $this->_viewDatas] + ); //결과파일저장 - $writer->save(PATHS['EXCEL'] . '/' . $fileName); + $fileName = sprintf( + "%s/%s_%s", + PATHS['EXCEL'], + $this->_viewDatas['className'], + date('Y-m-d_Hm') + ); + $writer = $this->spreadSheet($html); + $writer->save($fileName . '.xlsx'); //Download시 header("Content-Type: application/vnd.ms-excel"); header(sprintf("Content-Disposition: attachment; filename=%s", urlencode($fileName))); @@ -642,25 +652,19 @@ abstract class BaseController extends Controller } } //File Download관련 - public function download_process($entity) + public function download_process($field, $entity) { - return $entity; + list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); + if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) { + throw new \Exception("첨부파일이 확인되지 않습니다.\n"); + } + return $this->response->download(PATHS['UPLOAD'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename); } public function download(string $field, $uid) { try { $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); - if (!$entity->$field) { - throw new \Exception("첨부파일이 확인되지 않습니다."); - } - $entity = $this->download_process($entity); - echo "TEST"; - exit; - list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); - if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) { - throw new \Exception("파일이 확인되지 않습니다.\n" . PATHS['UPLOAD'] . "/" . $uploaded_filename); - } - return $this->response->download(PATHS['UPLOAD'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename); + return $this->download_process($field, $entity); } catch (\Exception $e) { return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/")->with('return_message', $e->getMessage()); } diff --git a/app/Controllers/Front/BillingController.php b/app/Controllers/Front/BillingController.php index fd4128c..18a450b 100644 --- a/app/Controllers/Front/BillingController.php +++ b/app/Controllers/Front/BillingController.php @@ -28,14 +28,14 @@ class BillingController extends FrontController { switch ($action) { case 'update': - return ['order_uid', "title", "upload_file", "status"]; + return ['order_uid', "email", "phone", "title", "upload_file", "status"]; break; case "index": case "excel": - return ["order_uid", "title", "upload_file", "status", "updated_at", "created_at"]; + return ["order_uid", "email", "phone", "title", "upload_file", "status", "updated_at", "created_at"]; break; case "view": - return ['order_uid', "title", "upload_file", "status", "updated_at", "created_at", 'response']; + return ['order_uid', "email", "phone", "title", "upload_file", "status", "updated_at", "created_at", 'response']; break; default: return []; @@ -50,4 +50,23 @@ class BillingController extends FrontController { return ["status"]; } + + //Index관련 + protected function index_setCondition() + { + //사용자정보(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(); + } + + //Download관련 + public function download_process($field, $entity) + { + list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); + if (!is_file(PATHS['BILLING'] . "/" . $uploaded_filename)) { + throw new \Exception("첨부파일이 확인되지 않습니다.\n"); + } + return $this->response->download(PATHS['BILLING'] . "/" . $uploaded_filename, null)->setFileName(date("Ymd") . '_' . $filename); + } } diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index 530e388..1c19550 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -145,10 +145,16 @@ class BoardController extends FrontController parent::index_setCondition(); } //Download관련 - public function download_process($entity) + public function download_process($field, $entity): array { + $entity = parent::download_process($field, $entity); //권한체크 $this->isRole('download', $entity); - return parent::download_process($entity); + list($filename, $uploaded_filename) = explode(DEFAULTS['DELIMITER_FILE'], $entity->$field); + if (!is_file(PATHS['UPLOAD'] . "/" . $uploaded_filename)) { + throw new \Exception("파일이 확인되지 않습니다.\n" . PATHS['UPLOAD'] . "/" . $uploaded_filename); + } + return array($filename, $uploaded_filename); + return parent::download_process($field, $entity); } } diff --git a/app/Controllers/Front/Order/OrderController.php b/app/Controllers/Front/Order/OrderController.php index dbc9a72..ed7e565 100644 --- a/app/Controllers/Front/Order/OrderController.php +++ b/app/Controllers/Front/Order/OrderController.php @@ -30,11 +30,11 @@ class OrderController extends FrontController $this->isRole('index'); } - final protected function getUserModel() + final protected function getUserModel(): UserModel { return $this->_userModel = $this->_userModel ?: new UserModel(); } - final protected function getProductModel() + final protected function getProductModel(): ProductModel { return $this->_productModel = $this->_productModel ?: new ProductModel(); } diff --git a/app/Controllers/Front/Order/Payment/CardController.php b/app/Controllers/Front/Order/Payment/CardController.php index 535b7ee..faf570e 100644 --- a/app/Controllers/Front/Order/Payment/CardController.php +++ b/app/Controllers/Front/Order/Payment/CardController.php @@ -23,7 +23,7 @@ class CardController extends PaymentController { switch ($action) { case 'update': - return ["card_quota", "card_number", "card_expiration", "email", "mobile"]; + return ["card_quota", "card_number", "card_expiration", "email", "phone"]; break; default: return []; @@ -48,7 +48,7 @@ class CardController extends PaymentController case "email": $rules[$field] = 'required|valid_email'; break; - case "mobile": + case "phone": $rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]'; break; default: @@ -98,19 +98,18 @@ class CardController extends PaymentController } protected function update_process($entity) { - //결제처리 - $this->_viewDatas['fieldDatas'] = array("status" => $this->_viewDatas['className']); - $entity = parent::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['fieldDatas']] + $this->_viewPath . '/billing', + ['viewDatas' => $this->_viewDatas] ); - //청구서 발행 - $this->billing($entity, $subject, $html); - return $entity; + //결과파일저장 + $this->createBilling($entity, $subject, $html, $response); + //결제처리 + return $this->_model->modify($entity, ["status" => $this->_viewDatas['className']]); } } diff --git a/app/Controllers/Front/Order/Payment/DepositController.php b/app/Controllers/Front/Order/Payment/DepositController.php index 2d17b00..29e7b4f 100644 --- a/app/Controllers/Front/Order/Payment/DepositController.php +++ b/app/Controllers/Front/Order/Payment/DepositController.php @@ -16,13 +16,18 @@ class DepositController extends PaymentController $this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title'); $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($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 { switch ($action) { case 'update': - return ["email", "mobile"]; + return ["email", "phone"]; break; default: return []; @@ -38,7 +43,7 @@ class DepositController extends PaymentController case "email": $rules[$field] = 'required|valid_email'; break; - case "mobile": + case "phone": $rules[$field] = 'required|regex_match[/^[0-9]{3}-[0-9]{4}-[0-9]{4}/]'; break; default: @@ -57,32 +62,19 @@ class DepositController extends PaymentController } //Insert관련 - //무통장입금결제Form - protected function update_form_process($entity) - { - $entity = parent::update_form_process($entity); - $this->_viewDatas['bank'] = [ - "name" => getenv("payment.deposit.bank.name") ?: "은행명", - "account" => getenv("payment.deposit.bank.account") ?: "계좌번호", - "holder" => getenv("payment.deposit.bank.holder") ?: "예금주" - ]; - return $entity; - } - //무통장입금결제처리 protected function update_process($entity) { - //겔제처리 - $this->_viewDatas['fieldDatas'] = array("status" => $this->_viewDatas['className']); - $entity = parent::update_process($entity); //청구서 발행정보 + $this->_viewDatas['entity'] = $entity; $subject = sprintf("%s %s 청구서입니다.", $entity->getTitle(), date("Y년 m월")); $html = view( - $this->_viewPath . 'billing', - ['viewDatas' => $this->_viewDatas['fieldDatas']] + $this->_viewPath . '/billing', + ['viewDatas' => $this->_viewDatas] ); - //청구서 발행 - $this->billing($entity, $subject, $html); - return $entity; + //결과파일저장 + $this->createBilling($entity, $subject, $html); + //결제처리 + return $this->_model->modify($entity, ["status" => $this->_viewDatas['className']]); } } diff --git a/app/Controllers/Front/Order/Payment/PaymentController.php b/app/Controllers/Front/Order/Payment/PaymentController.php index 900218a..20c92a0 100644 --- a/app/Controllers/Front/Order/Payment/PaymentController.php +++ b/app/Controllers/Front/Order/Payment/PaymentController.php @@ -3,19 +3,26 @@ namespace App\Controllers\Front\Order\Payment; use App\Controllers\Front\Order\OrderController; +use App\Entities\BillingEntity; use App\Entities\OrderEntity; +use App\Models\BillingModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use Dompdf\Dompdf; use Psr\Log\LoggerInterface; class PaymentController extends OrderController { + protected $_billingModel = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); } + final protected function getBillingModel(): BillingModel + { + return $this->_billingModel = $this->_billingModel ?: new BillingModel(); + } + //Update관련 (결제처리용) protected function update_form_process($entity) { @@ -46,10 +53,16 @@ class PaymentController extends OrderController $this->_product = $this->getProductModel()->getEntity([$this->_model->getPrimaryKey() => $entity->product_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']); @@ -60,30 +73,35 @@ class PaymentController extends OrderController } //청구서관련 - final protected function billing(OrderEntity $entity, string $subject, string $html) + final protected function createBilling(OrderEntity $entity, string $subject, string $html, $response = ''): BillingEntity { - //Email 발송 - $email = \Config\Services::email(); - $email->setFrom(MALLS['support'], MALLS['title'], MALLS['master']); - $email->setTo($entity->email); - $email->setCC(MALLS['master']); - $email->setSubject($subject); - $email->setMessage($html); - $email->send(); - - //PDF저장 - $dompdf = new Dompdf(); - $dompdf->loadHtml($html); - $dompdf->setPaper('A4', 'landscape'); - $dompdf->render(); - //Output the generated PDF to Browser - // $dompdf->stream(); - $filename = sprintf( - "%s/%s_%s.pdf", - PATHS['BILLING'], - $entity->getPrimaryKey(), - date("Y-m") - ); - file_put_contents($filename, $dompdf->output()); + //청구서파일 생성 + $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->getBillingModel()->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(); } } diff --git a/app/Database/shoppingmall.sql b/app/Database/shoppingmall.sql index 20b8df1..3369290 100644 --- a/app/Database/shoppingmall.sql +++ b/app/Database/shoppingmall.sql @@ -158,10 +158,13 @@ CREATE TABLE shoppingmall.tw_order ( DROP TABLE IF EXISTS shoppingmall.tw_billing; CREATE TABLE shoppingmall.tw_billing ( uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT, - order_uid varchar(36) NULL COMMENT '주문 정보', - user_uid varchar(36) NULL COMMENT '사용자 정보', + order_uid varchar(36) NOT NULL COMMENT '주문 정보', + user_uid varchar(36) NOT NULL COMMENT '사용자 정보', + email varchar(50) NOT NULL, + phone varchar(20) NULL COMMENT '연락처', title varchar(255) NOT NULL COMMENT '청구서제목', - upload_file varchar(255) NULL COMMENT 'PDF 파일명', + content text NOT NULL COMMENT '정구서내용', + upload_file varchar(255) NULL COMMENT '파일명', response text NULL COMMENT '결제처리결과', status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용, unuse: 사용않함 등등', updated_at timestamp NULL DEFAULT NULL, diff --git a/app/Entities/BillingEntity.php b/app/Entities/BillingEntity.php index 01b0d6c..8f804ff 100644 --- a/app/Entities/BillingEntity.php +++ b/app/Entities/BillingEntity.php @@ -12,7 +12,7 @@ class BillingEntity extends BaseEntity //기본기능 final public function getTitle(): string { - return $this->attributes['name']; + return $this->attributes['title']; } //추가기능 //파일관련 Field전용 @@ -21,9 +21,10 @@ class BillingEntity extends BaseEntity if (is_null($this->attributes[$field])) { return ""; } + $files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]); return anchor( $url, - ICONS['IMAGE_FILE'] . $this->attributes[$field], + ICONS['IMAGE_FILE'] . $files[0], ["target" => "_self"] ); } diff --git a/app/Helpers/Billing_helper.php b/app/Helpers/Billing_helper.php index dc4018d..5b08577 100644 --- a/app/Helpers/Billing_helper.php +++ b/app/Helpers/Billing_helper.php @@ -136,17 +136,26 @@ function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): str switch ($field) { case 'title': case 'name': - $uid = lang("{$viewDatas['className']}.label.uid") . ' : ' . str_split($entity->getPrimaryKey(), 4)[0] . '-xx-' . str_split($entity->getPrimaryKey(), 4)[1]; - $title = anchor( + return anchor( current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(), $value, ["target" => "_self"] ); - return sprintf("%s
%s", $uid, $title); + break; + case 'order_uid': + case 'user_uid': + return getFieldView_BillingHelper($field, $entity, $viewDatas); break; case 'board_file': case 'upload_file': - return $entity->getFileDownload(base_url() . $viewDatas['control'] . '/billing', $field); + // echo var_export($entity, true); + // exit; + return $entity->getFileDownload( + base_url() . + $viewDatas['control'] . + "/billing/download/{$field}/{$entity->getPrimaryKey()}", + $field + ); break; default: return getFieldView_BillingHelper($field, $entity, $viewDatas); @@ -160,16 +169,20 @@ function getFieldIndex_Row_BillingHelper_Admin($field, $entity, array $viewDatas switch ($field) { case 'title': case 'name': - $uid = lang("{$viewDatas['className']}.label.uid") . ' : ' . str_split($entity->getPrimaryKey(), 4)[0] . '-xx-' . str_split($entity->getPrimaryKey(), 4)[1]; - $title = anchor( + return anchor( current_url() . '/view/' . $entity->getPrimaryKey(), $value, ["target" => "_self"] ); - return sprintf("%s
%s", $uid, $title); break; - case 'user_uid': - return getFieldView_BillingHelper($field, $entity, $viewDatas); + case 'board_file': + case 'upload_file': + return $entity->getFileDownload( + base_url() . + $viewDatas['control'] . + "/billing/download/{$field}/{$entity->getPrimaryKey()}", + $field + ); break; default: if (in_array($field, $viewDatas['fieldFilters'])) { diff --git a/app/Helpers/Board_helper.php b/app/Helpers/Board_helper.php index 08fb08c..c4625bc 100644 --- a/app/Helpers/Board_helper.php +++ b/app/Helpers/Board_helper.php @@ -73,16 +73,6 @@ function getFieldView_BoardHelper($field, $entity, array $viewDatas) } return $value; break; - case 'board_file': - case 'upload_file': - return $entity->getFileDownload( - base_url() . - $viewDatas['control'] . - "/board/download/{$field}/{$entity->getPrimaryKey()}" . - '?category=' . $viewDatas['category']->getPrimaryKey(), - $field - ); - break; case 'photo': return $entity->getFileImage('middle', $field); break; @@ -151,6 +141,16 @@ function getFieldIndex_Row_BoardHelper($field, $entity, array $viewDatas): strin ); return sprintf("%s%s %s", $depth, $reply, $view); break; + case 'board_file': + case 'upload_file': + return $entity->getFileDownload( + base_url() . + $viewDatas['control'] . + "/board/download/{$field}/{$entity->getPrimaryKey()}" . + '?category=' . $viewDatas['category']->getPrimaryKey(), + $field + ); + break; default: return getFieldView_BoardHelper($field, $entity, $viewDatas); break; @@ -182,7 +182,12 @@ function getFieldIndex_Row_BoardHelper_Admin($field, $entity, array $viewDatas): break; case 'board_file': case 'upload_file': - return $entity->getFileDownload(base_url() . $viewDatas['control'] . '/board', $field); + return $entity->getFileDownload( + base_url() . + $viewDatas['control'] . + "/board/download/{$field}/{$entity->getPrimaryKey()}", + $field + ); break; default: if (in_array($field, $viewDatas['fieldFilters'])) { diff --git a/app/Helpers/Card_helper.php b/app/Helpers/Card_helper.php index e64dccb..2d59bd3 100644 --- a/app/Helpers/Card_helper.php +++ b/app/Helpers/Card_helper.php @@ -49,8 +49,8 @@ function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attrib case 'email': return form_input($field, $viewDatas['user']->email); break; - case 'mobile': - return form_input($field, $viewDatas['user']->mobile); + case 'phone': + return form_input($field, $viewDatas['user']->phone); break; default: return form_input($field, $value); diff --git a/app/Helpers/Deposit_helper.php b/app/Helpers/Deposit_helper.php index beb40ab..977bb48 100644 --- a/app/Helpers/Deposit_helper.php +++ b/app/Helpers/Deposit_helper.php @@ -20,8 +20,8 @@ function getFieldForm_DepositHelper($field, $value, array $viewDatas, array $att case 'email': return form_input($field, $viewDatas['user']->email); break; - case 'mobile': - return form_input($field, $viewDatas['user']->mobile); + case 'phone': + return form_input($field, $viewDatas['user']->phone); break; default: return form_input($field, $value); diff --git a/app/Language/ko/Billing.php b/app/Language/ko/Billing.php index 3b5eb3f..9594e23 100644 --- a/app/Language/ko/Billing.php +++ b/app/Language/ko/Billing.php @@ -5,6 +5,8 @@ return [ 'uid' => "청구서번호", 'order_uid' => "주문정보", 'user_uid' => "사용자정보", + 'email' => '이메일', + 'phone' => '연락처', 'title' => "청구서명", 'upload_file' => "청구서파일", 'response' => "결제처리결과", diff --git a/app/Language/ko/Card.php b/app/Language/ko/Card.php index 9e11733..0b1e859 100644 --- a/app/Language/ko/Card.php +++ b/app/Language/ko/Card.php @@ -7,7 +7,7 @@ return [ 'card_number' => '카드번호', 'card_expiration' => '유효기간', 'email' => '이메일', - 'mobile' => '인증휴대폰', + 'phone' => '연락처', ], "CARD_QUOTA" => [ "00" => "일시불", diff --git a/app/Language/ko/Deposit.php b/app/Language/ko/Deposit.php index 5a82e37..23addbe 100644 --- a/app/Language/ko/Deposit.php +++ b/app/Language/ko/Deposit.php @@ -4,6 +4,6 @@ return [ 'label' => [ 'order_uid' => '주문번호', 'email' => '이메일', - 'mobile' => '인증휴대폰', + 'phone' => '연락처', ], ]; diff --git a/app/Models/BillingModel.php b/app/Models/BillingModel.php index 857164f..81639f4 100644 --- a/app/Models/BillingModel.php +++ b/app/Models/BillingModel.php @@ -8,15 +8,14 @@ use App\Entities\ProductEntity; class BillingModel extends BaseModel { private $_order_options = null; - protected $table = "tw_order"; - protected $useAutoIncrement = false; + protected $table = "tw_billing"; protected $returnType = BillingEntity::class; protected $useSoftDeletes = true; public function __construct() { parent::__construct('Billing'); $this->allowedFields = [ - ...$this->allowedFields, 'order_uid', "user_uid", + ...$this->allowedFields, 'order_uid', "user_uid", "email", "phone", "title", "upload_file", "response", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; @@ -31,6 +30,12 @@ class BillingModel extends BaseModel 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": + $rules[$field] = "required|trim|valid_email"; + break; + case "phone": + $rules[$field] = "if_exist|string"; + break; case $this->getTitleField(): $rules[$field] = "required|trim|string"; break; @@ -38,7 +43,7 @@ class BillingModel extends BaseModel $rules[$field] = "if_exist|string"; break; case "response": - $rules[$field] = "required|string"; + $rules[$field] = "if_exist|string"; break; default: $rules = parent::getFieldRule($field, $rules, $action); diff --git a/app/Views/front/billing/index.php b/app/Views/front/billing/index.php index e33dd3e..b5ba845 100644 --- a/app/Views/front/billing/index.php +++ b/app/Views/front/billing/index.php @@ -16,7 +16,6 @@ status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)"> - diff --git a/app/Views/front/order/deposit/billing.php b/app/Views/front/order/deposit/billing.php index b3ff1f9..05de74e 100644 --- a/app/Views/front/order/deposit/billing.php +++ b/app/Views/front/order/deposit/billing.php @@ -1,4 +1,4 @@ - +" media=" screen" rel="stylesheet" type="text/css" /> diff --git a/composer.json b/composer.json index c70711c..3addc0e 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,7 @@ "twbs/bootstrap": "5.2.3", "guzzlehttp/guzzle": "^7.7", "google/apiclient": "2.12.1", - "tinymce/tinymce": "^6.6", - "dompdf/dompdf": "^2.0" + "tinymce/tinymce": "^6.6" }, "require-dev": { "fakerphp/faker": "^1.9", diff --git a/writable/billing/8ba39b2a-dffb-badc-3ac1-858616da109b_2023-08-16_1808.xlsx b/writable/billing/8ba39b2a-dffb-badc-3ac1-858616da109b_2023-08-16_1808.xlsx new file mode 100644 index 0000000000000000000000000000000000000000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