shoppingmallv2/app/Controllers/Admin/OrderController.php
2023-08-09 17:48:53 +09:00

55 lines
1.8 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Models\OrderModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class OrderController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
$this->_model = new OrderModel();
parent::initController($request, $response, $logger);
$this->_viewPath .= strtolower($this->_model->getClassName());
}
final public function getFields(string $action = ""): array
{
switch ($action) {
case 'update':
return ['product_uid', "cost", "sale", "quantity", "status"];
break;
case "index":
case "excel":
case "view":
return ["user_uid", 'product_uid', "name", "cost", "sale", "quantity", "price", "status", "updated_at", "created_at"];
break;
default:
return throw new \Exception("{$action} 해당기능은 없습니다.");
break;
}
}
final public function getFieldFilters(): array
{
return ["user_uid", 'product_uid', "status"];
}
final public function getFieldBatchFilters(): array
{
return ["status"];
}
//가격이나,할인가,수량 변경했을경우 다시 계산해서 Price에 넣기위해
protected function update_process($entity)
{
//가격이나,할인가,수량 변경했을경우 다시 계산해서 결제금액(price)에 넣기위해
$this->_viewDatas['fieldDatas']['price'] =
($this->_viewDatas['fieldDatas']['cost'] -
$this->_viewDatas['fieldDatas']['sale']) *
$this->_viewDatas['fieldDatas']['quantity'];
return parent::update_process($entity);
}
}