shoppingmallv2 init...
This commit is contained in:
parent
53856edb90
commit
cde478771c
@ -58,10 +58,10 @@ class BillingController extends FrontController
|
|||||||
break;
|
break;
|
||||||
case "index":
|
case "index":
|
||||||
case "excel":
|
case "excel":
|
||||||
return ["title", "price", "email", "phone", "status", "created_at"];
|
return ["title", "price", "email", "phone", "type", "status", "created_at"];
|
||||||
break;
|
break;
|
||||||
case "view":
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
@ -119,7 +119,7 @@ class BillingController extends FrontController
|
|||||||
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
|
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
|
||||||
return parent::insert_process();
|
return parent::insert_process();
|
||||||
}
|
}
|
||||||
public function insert()
|
final public function insert()
|
||||||
{
|
{
|
||||||
$msg = "";
|
$msg = "";
|
||||||
try {
|
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 관련
|
//View 관련
|
||||||
protected function view_process($entity)
|
protected function view_process($entity)
|
||||||
{
|
{
|
||||||
@ -173,11 +195,11 @@ class BillingController extends FrontController
|
|||||||
{
|
{
|
||||||
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
|
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
|
||||||
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
$this->_model->where('user_uid', $this->_session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]);
|
||||||
$this->_model->where("status", DEFAULTS['STATUS']);
|
|
||||||
parent::index_setCondition();
|
parent::index_setCondition();
|
||||||
}
|
}
|
||||||
|
|
||||||
//추가기능
|
//추가기능
|
||||||
|
//메일발송
|
||||||
final protected function sendMail(BillingEntity $entity): bool
|
final protected function sendMail(BillingEntity $entity): bool
|
||||||
{
|
{
|
||||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
$this->_viewDatas = $this->init(__FUNCTION__);
|
||||||
|
|||||||
@ -82,34 +82,32 @@ class CardController extends BillingController
|
|||||||
return $options;
|
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 = "";
|
$response = "";
|
||||||
foreach ($result as $key => $value) {
|
if ($isTest) {
|
||||||
$response .= "{$key}:{$value}\n";
|
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;
|
return $response;
|
||||||
}
|
}
|
||||||
protected function update_process($entity)
|
protected function update_process($entity)
|
||||||
{
|
{
|
||||||
//카드결제
|
//카드결제
|
||||||
$response = $this->pg_process();
|
$this->_viewDatas['fieldDatas']["response"] = $this->pg_process(true);
|
||||||
//청구서 발행정보
|
//Card 결제처리
|
||||||
$this->_viewDatas['entity'] = $entity;
|
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
||||||
$subject = sprintf("%s %s 청구서입니다.", $entity->getTitle(), date("Y년 m월"));
|
return parent::update_process($entity);
|
||||||
$html = view(
|
|
||||||
$this->_viewPath . '/billing',
|
|
||||||
['viewDatas' => $this->_viewDatas]
|
|
||||||
);
|
|
||||||
//결과파일저장
|
|
||||||
$this->createBilling($entity, $subject, $html, $response);
|
|
||||||
//결제처리
|
|
||||||
return $this->_model->modify($entity, ["status" => $this->_viewDatas['className']]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,31 +54,11 @@ class DepositController extends BillingController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Update관련
|
//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)
|
protected function update_process($entity)
|
||||||
{
|
{
|
||||||
|
//Deposit 결제처리
|
||||||
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
$this->_viewDatas['fieldDatas']["type"] = $this->_viewDatas['className'];
|
||||||
//결제처리
|
|
||||||
return parent::update_process($entity);
|
return parent::update_process($entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -166,9 +166,8 @@ CREATE TABLE shoppingmall.tw_billing (
|
|||||||
phone varchar(20) NULL COMMENT '연락처',
|
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 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 '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,
|
||||||
|
|||||||
@ -75,10 +75,6 @@ function getFieldView_BillingHelper($field, $entity, array $viewDatas)
|
|||||||
case 'price':
|
case 'price':
|
||||||
return number_format(!$value ? 0 : $value) . "원";
|
return number_format(!$value ? 0 : $value) . "원";
|
||||||
break;
|
break;
|
||||||
case 'stock':
|
|
||||||
case 'view_cnt':
|
|
||||||
return number_format(!$value ? 0 : $value);
|
|
||||||
break;
|
|
||||||
case 'response':
|
case 'response':
|
||||||
return nl2br($value);
|
return nl2br($value);
|
||||||
break;
|
break;
|
||||||
@ -150,9 +146,8 @@ function getFieldIndex_Row_BillingHelper($field, $entity, array $viewDatas): str
|
|||||||
$field
|
$field
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'status':
|
case 'type':
|
||||||
//미납인경우
|
if ($entity->status != DEFAULTS['STATUS']) {
|
||||||
if ($value == DEFAULTS['STATUS']) {
|
|
||||||
$card = anchor(
|
$card = anchor(
|
||||||
URLS['card'] . '/' . $entity->getPrimaryKey(),
|
URLS['card'] . '/' . $entity->getPrimaryKey(),
|
||||||
ICONS['CARD'] . lang("{$viewDatas['className']}.TYPE.CARD"),
|
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);
|
return sprintf("%s<BR>%s", $card, $deposit);
|
||||||
} else {
|
} else {
|
||||||
//결제처리가된경우
|
//결제처리가된경우
|
||||||
return getFieldView_OrderHelper('type', $entity, $viewDatas);
|
$value = strtoupper($value);
|
||||||
|
return ICONS[$value] . lang("{$viewDatas['className']}.TYPE.{$value}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -22,7 +22,7 @@ function getFieldForm_CardHelper($field, $value, array $viewDatas, array $attrib
|
|||||||
break;
|
break;
|
||||||
case 'card_number':
|
case 'card_number':
|
||||||
return sprintf(
|
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]),
|
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++) {
|
for ($i = $start; $i <= $end; $i++) {
|
||||||
$years[$i] = "{$i}년";
|
$years[$i] = "{$i}년";
|
||||||
}
|
}
|
||||||
return sprintf(
|
return form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']) . '/ ' .
|
||||||
"%s월 %s년",
|
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']);
|
||||||
form_dropdown("{$field}[]", $months, DEFAULTS['EMPTY']),
|
|
||||||
form_dropdown("{$field}[]", $years, DEFAULTS['EMPTY']),
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'email':
|
case 'email':
|
||||||
return form_input($field, $viewDatas['user']->email);
|
return form_input($field, $viewDatas['user']->email);
|
||||||
|
|||||||
@ -15,8 +15,8 @@ return [
|
|||||||
'created_at' => "작성일"
|
'created_at' => "작성일"
|
||||||
],
|
],
|
||||||
"STATUS" => [
|
"STATUS" => [
|
||||||
"use" => "미납",
|
"use" => "납부완료",
|
||||||
"unuse" => "납부완료",
|
"unuse" => "미납중",
|
||||||
],
|
],
|
||||||
"TYPE" => [
|
"TYPE" => [
|
||||||
'CARD' => " 카 드 결 제",
|
'CARD' => " 카 드 결 제",
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class BillingModel extends BaseModel
|
|||||||
parent::__construct('Billing');
|
parent::__construct('Billing');
|
||||||
$this->allowedFields = [
|
$this->allowedFields = [
|
||||||
...$this->allowedFields, "user_uid", "type", "email", "phone",
|
...$this->allowedFields, "user_uid", "type", "email", "phone",
|
||||||
"title", "price", "content", "response", "status"
|
"title", "price", "response", "status"
|
||||||
];
|
];
|
||||||
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<tr>
|
<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>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?= form_close(); ?>
|
<?= form_close(); ?>
|
||||||
Loading…
Reference in New Issue
Block a user