vhost init...2
This commit is contained in:
parent
47778e0ee9
commit
dd57f23659
@ -4,7 +4,6 @@ namespace App\Controllers\Front\Billing;
|
|||||||
|
|
||||||
use App\Controllers\Front\FrontController;
|
use App\Controllers\Front\FrontController;
|
||||||
use App\Entities\BillingEntity;
|
use App\Entities\BillingEntity;
|
||||||
use App\Entities\OrderEntity;
|
|
||||||
use App\Models\BillingModel;
|
use App\Models\BillingModel;
|
||||||
use App\Models\OrderBillingModel;
|
use App\Models\OrderBillingModel;
|
||||||
use App\Models\OrderModel;
|
use App\Models\OrderModel;
|
||||||
@ -15,6 +14,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
|
|
||||||
class BillingController extends FrontController
|
class BillingController extends FrontController
|
||||||
{
|
{
|
||||||
|
const DEFAULT_CATEGORY = "billinginfo";
|
||||||
private $_userModel = null;
|
private $_userModel = null;
|
||||||
private $_orderModel = null;
|
private $_orderModel = null;
|
||||||
private $_orderBillingModel = null;
|
private $_orderBillingModel = null;
|
||||||
@ -27,11 +27,6 @@ class BillingController extends FrontController
|
|||||||
$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']);
|
||||||
|
|
||||||
//Default 회원정보 Category
|
|
||||||
$this->_category = DEFAULTS['CATEGORY_BILLING'];
|
|
||||||
$this->isRole('index');
|
|
||||||
|
|
||||||
//사용자정보
|
//사용자정보
|
||||||
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
$this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $this->_viewDatas['auth'][AUTH_FIELDS['ID']]]);
|
||||||
}
|
}
|
||||||
@ -77,17 +72,17 @@ class BillingController extends FrontController
|
|||||||
return ["status"];
|
return ["status"];
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getOrdersByBillingEntity(BillingEntity $entity): array
|
//청구서용 Order정보 가져오기
|
||||||
|
private function getOrdersByBillingEntity(BillingEntity $entity): array
|
||||||
{
|
{
|
||||||
//청구서 연결 주문정보 가져오기
|
|
||||||
$orderBillings = $this->getOrderBillingModel()->getEntitys(['billing_uid' => $entity->getPrimaryKey()]);
|
$orderBillings = $this->getOrderBillingModel()->getEntitys(['billing_uid' => $entity->getPrimaryKey()]);
|
||||||
$orders = array();
|
$orders = array();
|
||||||
foreach ($orderBillings as $orderBilling) {
|
foreach ($orderBillings as $orderBilling) {
|
||||||
array_push(
|
array_push(
|
||||||
$orders,
|
$orders,
|
||||||
$this->getOrderModel()->getEntity(
|
$this->getOrderModel()->getEntity(
|
||||||
[$this->getOrderModel()->getPrimaryKey() => $orderBilling->order_uid]
|
[$this->getOrderModel()->getPrimaryKey() => $orderBilling->order_uid],
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $orders;
|
return $orders;
|
||||||
@ -99,83 +94,40 @@ class BillingController extends FrontController
|
|||||||
parent::insert_form_process();
|
parent::insert_form_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Insert관련
|
//청구서처리
|
||||||
private function linkOrderBilling(BillingEntity $entity, array $orders)
|
|
||||||
{
|
|
||||||
foreach ($orders as $order) {
|
|
||||||
$this->getOrderBillingModel()->create([
|
|
||||||
"billing_uid" => $entity->getPrimaryKey(),
|
|
||||||
'order_uid' => $order->getPrimaryKey()
|
|
||||||
]);
|
|
||||||
$this->getOrderModel()->modify($order, ['status' => DEFAULTS['STATUS']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected function insert_process()
|
protected function insert_process()
|
||||||
{
|
{
|
||||||
//title지정하기
|
//청구서 title지정하기
|
||||||
$this->_viewDatas['fieldDatas']['title'] = date("Y년m월") . " 청구서입니다.";
|
$this->_viewDatas['fieldDatas']['title'] = date("Y년m월") . " 청구서입니다.";
|
||||||
//사용자정보
|
//청구서용 고객정보지정하기
|
||||||
$this->_viewDatas['fieldDatas']['email'] = $this->_viewDatas['user']->email;
|
$user = $this->getUserModel()->getData($this->_viewDatas['user']);
|
||||||
$this->_viewDatas['fieldDatas']['phone'] = $this->_viewDatas['user']->phone;
|
$this->_viewDatas['fieldDatas']['email'] = $user->getEmail();
|
||||||
return parent::insert_process();
|
$this->_viewDatas['fieldDatas']['phone'] = $user->getPhone();
|
||||||
}
|
$entity = parent::insert_process();
|
||||||
final public function insert()
|
|
||||||
{
|
|
||||||
$msg = "";
|
|
||||||
try {
|
|
||||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
|
||||||
$this->insert_validate();
|
|
||||||
//주문정보 가져오기
|
//주문정보 가져오기
|
||||||
$order_uids = $this->request->getVar('order_uids') ?: throw new \Exception("주문정보가 지정되지 않았습니다.");
|
$order_uids = $this->request->getVar('order_uids') ?: throw new \Exception("주문정보가 지정되지 않았습니다.");
|
||||||
$orders = array();
|
$orders = array();
|
||||||
foreach ($order_uids as $order_uid) {
|
foreach ($order_uids as $order_uid) {
|
||||||
array_push($orders, $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $order_uid]));
|
$order = $this->getOrderModel()->getEntity([$this->getOrderModel()->getPrimaryKey() => $order_uid]);
|
||||||
}
|
$this->getOrderBillingModel()->create([
|
||||||
//Transaction 시작
|
"billing_uid" => $entity->getPrimaryKey(),
|
||||||
$this->_model->transStart();
|
'order_uid' => $order->getPrimaryKey(),
|
||||||
//Billing 생성
|
]);
|
||||||
$entity = $this->insert_process();
|
$this->getOrderModel()->modify($order, ['status' => 'status']);
|
||||||
//DB연결용
|
|
||||||
$this->linkOrderBilling($entity, $orders);
|
|
||||||
//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);
|
|
||||||
}
|
}
|
||||||
|
return $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update관련
|
//Update관련
|
||||||
final public function update_form($uid)
|
protected function update_form_process($entity)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
|
||||||
//청구서정보 가져오기
|
|
||||||
$this->_viewDatas['entity'] = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]);
|
|
||||||
//청구서 연결 주문정보 가져오기
|
//청구서 연결 주문정보 가져오기
|
||||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||||
if (!count($this->_viewDatas['orders'])) {
|
if (!count($this->_viewDatas['orders'])) {
|
||||||
throw new \Exception("해당하는 주문정보가 없습니다.");
|
throw new \Exception("해당하는 주문정보가 없습니다.");
|
||||||
}
|
}
|
||||||
$this->update_form_process($entity);
|
return parent::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 관련
|
||||||
@ -191,6 +143,12 @@ class BillingController extends FrontController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
protected function index_process()
|
||||||
|
{
|
||||||
|
//Category 확인
|
||||||
|
$this->setCategory($this->request->getVar('category') ?: self::DEFAULT_CATEGORY);
|
||||||
|
parent::index_process();
|
||||||
|
}
|
||||||
protected function index_setCondition()
|
protected function index_setCondition()
|
||||||
{
|
{
|
||||||
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
|
//사용자정보(user_uid)에 맞는 Biiling정보 가져오기
|
||||||
@ -202,7 +160,7 @@ class BillingController extends FrontController
|
|||||||
//메일발송
|
//메일발송
|
||||||
final protected function sendMail(BillingEntity $entity): bool
|
final protected function sendMail(BillingEntity $entity): bool
|
||||||
{
|
{
|
||||||
$this->_viewDatas = $this->init(__FUNCTION__);
|
$this->_viewDatas = $this->action_init(['action' => __FUNCTION__]);
|
||||||
$this->_viewDatas['entity'] = $entity;
|
$this->_viewDatas['entity'] = $entity;
|
||||||
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
$this->_viewDatas['orders'] = $this->getOrdersByBillingEntity($entity);
|
||||||
|
|
||||||
@ -211,10 +169,12 @@ class BillingController extends FrontController
|
|||||||
$mail->setTo($entity->email);
|
$mail->setTo($entity->email);
|
||||||
$mail->setCC(MALLS['master']);
|
$mail->setCC(MALLS['master']);
|
||||||
$mail->setSubject($entity->getTitle());
|
$mail->setSubject($entity->getTitle());
|
||||||
$mail->setMessage(view(
|
$mail->setMessage(
|
||||||
|
view(
|
||||||
$this->_viewPath . '/billing',
|
$this->_viewPath . '/billing',
|
||||||
['viewDatas' => $this->_viewDatas]
|
['viewDatas' => $this->_viewDatas],
|
||||||
));
|
),
|
||||||
|
);
|
||||||
return $mail->send();
|
return $mail->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,6 +108,12 @@ class UserController extends FrontController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Index관련
|
//Index관련
|
||||||
|
protected function index_process()
|
||||||
|
{
|
||||||
|
//Category 확인
|
||||||
|
$this->setCategory($this->request->getVar('category') ?: self::DEFAULT_CATEGORY);
|
||||||
|
parent::index_process();
|
||||||
|
}
|
||||||
//사용자 UID 조건추가
|
//사용자 UID 조건추가
|
||||||
protected function index_setCondition()
|
protected function index_setCondition()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,7 +11,7 @@ div#order {
|
|||||||
/* border:1px solid red; */
|
/* border:1px solid red; */
|
||||||
}
|
}
|
||||||
div#order div.orderbox {
|
div#order div.orderbox {
|
||||||
position:fixed;
|
/* position:fixed; */
|
||||||
width:200px;
|
width:200px;
|
||||||
padding:5px;
|
padding:5px;
|
||||||
border:1px solid gray;
|
border:1px solid gray;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user