From e7e2a276d84c06e64d0bcd4e9b45993b5a5dcceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 22 Aug 2023 17:10:06 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Controllers/Admin/BillingController.php | 42 +++++++++++++++++++++ app/Helpers/Billing_helper.php | 12 +++--- app/Models/BaseModel.php | 8 ++-- app/Models/CategoryModel.php | 4 +- app/Models/UserModel.php | 4 +- app/Views/admin/billing/view.php | 40 ++++++++++++++++++++ 6 files changed, 96 insertions(+), 14 deletions(-) create mode 100644 app/Views/admin/billing/view.php diff --git a/app/Controllers/Admin/BillingController.php b/app/Controllers/Admin/BillingController.php index 1a0e92a..9f733f9 100644 --- a/app/Controllers/Admin/BillingController.php +++ b/app/Controllers/Admin/BillingController.php @@ -2,13 +2,18 @@ namespace App\Controllers\Admin; +use App\Entities\BillingEntity; use App\Models\BillingModel; +use App\Models\OrderBillingModel; +use App\Models\OrderModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; class BillingController extends AdminController { + private $_orderBillingModel = null; + private $_orderModel = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -20,6 +25,15 @@ class BillingController extends AdminController helper($this->_viewDatas['className']); } + 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) { @@ -46,4 +60,32 @@ class BillingController extends AdminController { return ["user_uid", "status"]; } + + final protected function getOrdersByBillingEntity(BillingEntity $entity): array + { + //청구서 연결 주문정보 가져오기 + $orderBillings = $this->getOrderBillingModel()->getEntitys(['billing_uid' => $entity->getPrimaryKey()]); + $orders = array(); + foreach ($orderBillings as $orderBilling) { + array_push( + $orders, + $this->getOrderModel()->getEntity( + [$this->getOrderModel()->getPrimaryKey() => $orderBilling->order_uid] + ) + ); + } + return $orders; + } + + //View 관련 + protected function view_process($entity) + { + $entity = parent::view_process($entity); + //청구서 연결 주문정보 가져오기 + $this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity); + if (!count($this->_viewDatas['orders'])) { + throw new \Exception("해당하는 주문정보가 없습니다."); + } + return $entity; + } } diff --git a/app/Helpers/Billing_helper.php b/app/Helpers/Billing_helper.php index 341cda9..6bed1b8 100644 --- a/app/Helpers/Billing_helper.php +++ b/app/Helpers/Billing_helper.php @@ -148,17 +148,17 @@ function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): str break; case 'type': if ($entity->status != DEFAULTS['STATUS']) { - $card = anchor( - URLS['card'] . '/' . $entity->getPrimaryKey(), - ICONS['CARD'] . lang("{$viewDatas['className']}.TYPE.CARD"), - ["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"] - ); + // $card = anchor( + // URLS['card'] . '/' . $entity->getPrimaryKey(), + // ICONS['CARD'] . lang("{$viewDatas['className']}.TYPE.CARD"), + // ["class" => "btn btn-sm btn-primary btn-circle", "style" => "color:white", "target" => "_self"] + // ); $deposit = anchor( URLS['deposit'] . '/' . $entity->getPrimaryKey(), ICONS['DEPOSIT'] . lang("{$viewDatas['className']}.TYPE.DEPOSIT"), ["class" => "btn btn-sm btn-info btn-circle", "style" => "color:white", "target" => "_self"] ); - return sprintf("%s
%s", $card, $deposit); + return $deposit; } else { //결제처리가된경우 $value = strtoupper($value); diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index 399d882..96c6e98 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -192,7 +192,7 @@ abstract class BaseModel extends Model } break; case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가 - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && !is_null($formDatas[$field])) { //관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용 $entity->$field = $formDatas[$field]; } elseif ($action == 'create' && $this->_session->get(SESSION_NAMES["ISLOGIN"])) { @@ -202,17 +202,17 @@ abstract class BaseModel extends Model } break; case "passwd": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = password_hash($formDatas[$field], PASSWORD_DEFAULT); } break; case "content": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = htmlentities($formDatas[$field]); } break; default: - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = $formDatas[$field]; } break; diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 8853745..496cfed 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -79,13 +79,13 @@ class CategoryModel extends BaseHierarchyModel case "isreply": case "isupload": case "isdownload": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; } break; case "head": case "tail": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = htmlentities($formDatas[$field]); } break; diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index e0c428a..fc01aee 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -64,13 +64,13 @@ class UserModel extends BaseModel { switch ($field) { case "role": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; } break; case "head": case "tail": - if (array_key_exists($field, $formDatas)) { + if (array_key_exists($field, $formDatas) && $formDatas[$field]) { $entity->$field = htmlentities($formDatas[$field]); } break; diff --git a/app/Views/admin/billing/view.php b/app/Views/admin/billing/view.php new file mode 100644 index 0000000..936f62e --- /dev/null +++ b/app/Views/admin/billing/view.php @@ -0,0 +1,40 @@ +extend('layouts/admin') ?> +section('content') ?> + +
+ + + + + + + + + + + + + + + + + + + +
주문정보 +
    + +
  • getTitle() ?> * quantity ?>개 = price) ?>원
  • + +
+
결제금액price) ?>원
은행정보 +
    + +
  • , ,
  • + +
+
+ +
+
+endSection() ?> \ No newline at end of file