shoppingmallv2 init...

This commit is contained in:
최준흠 2023-08-18 13:57:39 +09:00
parent 53856edb90
commit cde478771c
9 changed files with 60 additions and 65 deletions

View File

@ -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__);

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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<BR>%s", $card, $deposit);
} else {
//결제처리가된경우
return getFieldView_OrderHelper('type', $entity, $viewDatas);
$value = strtoupper($value);
return ICONS[$value] . lang("{$viewDatas['className']}.TYPE.{$value}");
}
break;
default:

View File

@ -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);

View File

@ -15,8 +15,8 @@ return [
'created_at' => "작성일"
],
"STATUS" => [
"use" => "",
"unuse" => "납부완료",
"use" => "부완료",
"unuse" => "미납중",
],
"TYPE" => [
'CARD' => " 카 드 결 제",

View File

@ -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),];
}

View File

@ -23,7 +23,10 @@
</tr>
<?php endforeach; ?>
<tr>
<td valign="bottom" colspan="2"><?= form_submit('', '카드결제', array("class" => "btn btn-outline btn-primary")); ?></td>
<td class="label"></td>
<td class="column">
<?= form_submit('', '카드결제', array("class" => "btn btn-outline btn-primary")); ?>
</td>
</tr>
</table>
<?= form_close(); ?>