dbms_init...1
This commit is contained in:
parent
07a1706ab0
commit
60639f4116
@ -3,8 +3,9 @@
|
||||
namespace App\Controllers\Admin\Customer;
|
||||
|
||||
use App\Helpers\Customer\ServiceHelper;
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Customer\ServicePaymentService;
|
||||
|
||||
use App\Services\Customer\ServiceService;
|
||||
use App\Services\Equipment\CodeService;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
@ -14,6 +15,7 @@ use Psr\Log\LoggerInterface;
|
||||
class ServiceController extends CustomerController
|
||||
{
|
||||
private ?CodeService $_codeService = null;
|
||||
private ?ServicePaymentService $_servicePaymentService = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
@ -44,6 +46,13 @@ class ServiceController extends CustomerController
|
||||
}
|
||||
return $this->_codeService;
|
||||
}
|
||||
public function getServicePaymentService(): ServicePaymentService
|
||||
{
|
||||
if (!$this->_servicePaymentService) {
|
||||
$this->_servicePaymentService = new ServicePaymentService($this->request);
|
||||
}
|
||||
return $this->_servicePaymentService;
|
||||
}
|
||||
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
|
||||
{
|
||||
switch ($this->getAction()) {
|
||||
@ -86,6 +95,8 @@ class ServiceController extends CustomerController
|
||||
}
|
||||
protected function index_process(): array
|
||||
{
|
||||
//서비스별 미납 Count
|
||||
$this->unPaids = $this->getServicePaymentService()->getUnPaidCountByService();
|
||||
//LINE,IP,SERVER등 추가 FilterOption 셋팅용
|
||||
$this->setFilterOptionsByItemType();
|
||||
$entities = [];
|
||||
|
||||
@ -80,9 +80,9 @@ class Home extends AdminController
|
||||
$this->interval = intval($this->request->getVar('interval') ?? SERVICE_NEW_INTERVAL);
|
||||
$this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval);
|
||||
$this->newServiceCount = count($this->newServiceEntities);
|
||||
//미납 서버 정보
|
||||
$this->unPaidEntities = $this->getServicePaymentService()->getEntitiesByUnPaid();
|
||||
$this->unPaidCount = count($this->unPaidEntities);
|
||||
//서비스별 미납 Count
|
||||
$this->unPaids = $this->getServicePaymentService()->getUnPaidCountByService();
|
||||
$this->unPaidCount = count($this->unPaids);
|
||||
helper(['form']);
|
||||
return $this->getResultSuccess();
|
||||
}
|
||||
|
||||
@ -47,10 +47,10 @@ class Payment extends BaseController
|
||||
//Transaction Start
|
||||
$this->getServiceService()->getModel()->transStart();
|
||||
try {
|
||||
//서비스중 결제일이 오늘인 서비스 모두 연장처리
|
||||
//서비스중 결제일이 오늘이고, 상태가 사용중이 경우만 서비스 모두 연장처리
|
||||
$this->getServiceService()->extendBillingAt(date('Y-m-d'), DEFAULTS['STATUS']);
|
||||
//결제일이 오늘보다 큰 서비스가져오기
|
||||
foreach ($this->getServiceService()->getEntities(['billing_at >' => date("Y-m-d")]) as $serviceEntity) {
|
||||
//결제일이 오늘보다 크고, 상태가 사용중인 서비스정보를 이용해서 결제정보에 신규 추가하기
|
||||
foreach ($this->getServiceService()->getEntities(['billing_at >' => date("Y-m-d"), 'status' => DEFAULTS['STATUS']]) as $serviceEntity) {
|
||||
// echo $serviceEntity->getPK() . ":" . $serviceEntity->getBillingAt() . "\n";
|
||||
foreach ($this->getServiceItemService()->getEntities(['serviceinfo_uid' => $serviceEntity->getPK()]) as $itemEntity) {
|
||||
//결제정보 ServicePaymentService에 월별 결제만 신규등록
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -101,6 +101,10 @@ class ServiceHelper extends CustomerHelper
|
||||
$temps[] = "</ul>";
|
||||
$value = implode("", $temps);
|
||||
break;
|
||||
case 'billing_at':
|
||||
$value .= array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids']) ? "<BR>미지급항목: " . $viewDatas['unPaids'][$viewDatas['entity']->getPK()] . "개" : "";
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
|
||||
@ -10,6 +10,7 @@ abstract class CommonService
|
||||
private $_serviceDatas = [];
|
||||
private $_model = null;
|
||||
private $_classNames = [];
|
||||
private $_myAuth = null;
|
||||
private $_request = null;
|
||||
protected function __construct(mixed $_request = null)
|
||||
{
|
||||
@ -20,6 +21,13 @@ abstract class CommonService
|
||||
abstract public function getFormFields(): array;
|
||||
abstract public function getFilterFields(): array;
|
||||
abstract public function getBatchJobFields(): array;
|
||||
final protected function getMyAuth(): mixed
|
||||
{
|
||||
if (!$this->_myAuth) {
|
||||
$this->_myAuth = service('myauth');
|
||||
}
|
||||
return $this->_myAuth;
|
||||
}
|
||||
final public function getRequest(): mixed
|
||||
{
|
||||
return $this->_request;
|
||||
|
||||
@ -91,12 +91,19 @@ class ServicePaymentService extends CustomerService
|
||||
return $options;
|
||||
}
|
||||
//미납서비스 정보
|
||||
final public function getEntitiesByUnPaid(): array
|
||||
final public function getUnPaidCountByService(): array
|
||||
{
|
||||
$where = sprintf("billing_at < NOW() AND amount > 0 AND status = '%s'", DEFAULTS['STATUS']);
|
||||
return $this->getEntities($where);
|
||||
$sql = sprintf("SELECT serviceinfo_uid,COUNT(*) as CNT
|
||||
FROM serviceinfo_payment
|
||||
WHERE billing_at < NOW() AND amount > 0 AND status = '%s'
|
||||
GROUP BY serviceinfo_uid", DEFAULTS['STATUS']);
|
||||
$unpaids = [];
|
||||
foreach ($this->getModel()->query($sql)->getResult() as $row) {
|
||||
$unpaids[$row->serviceinfo_uid] = $row->CNT;
|
||||
}
|
||||
return $unpaids;
|
||||
}
|
||||
//ServiceItemService에서 사용
|
||||
//결체처리정보 등록 : ServiceItemService에서 사용
|
||||
public function createByServiceItem(ServiceItemEntity $serviceItemEntity): ServicePaymentEntity
|
||||
{
|
||||
$serviceEntity = $this->getServiceService()->getEntity($serviceItemEntity->getServiceUid());
|
||||
@ -113,9 +120,13 @@ class ServicePaymentService extends CustomerService
|
||||
'billing_at' => $serviceEntity->getBillingAt(),
|
||||
'issue_at' => date('Y-m-d'),
|
||||
];
|
||||
//금액(amount)가 0원일경우는 바로 결제완료 및 결제자 등록 처리함.
|
||||
if ($serviceItemEntity->getAmount() === 0) {
|
||||
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
||||
$formDatas['status'] = 'paid';
|
||||
}
|
||||
return $this->create($formDatas);
|
||||
}
|
||||
|
||||
//Service정보 와 관리자가 기존 정보과 같고, 결제가 아직 완료되지 않은 결제정보의 관리자 변경
|
||||
public function modifyOwnerByService(ServiceEntity $serviceEntity, int $ownerinfo_uid)
|
||||
{
|
||||
|
||||
@ -204,7 +204,7 @@ class ServiceService extends CustomerService
|
||||
$this->getCodeService()->setStatus($formDatas['code'], CodeEntity::STATUS_OCCUPIED);
|
||||
}
|
||||
//관리자가 바뀐경우 결제쪽에도 결제가 완료되지않은 것은 관리자를 변경해줘야함
|
||||
if ($entity->getOwnerUID() !== intval($formDatas['ownerinfo_uid'])) {
|
||||
if (array_key_exists('ownerinfo_uid', $formDatas) && $entity->getOwnerUID() !== intval($formDatas['ownerinfo_uid'])) {
|
||||
$this->getServicePaymentService()->modifyOwnerByService($entity, $formDatas['ownerinfo_uid']);
|
||||
}
|
||||
return parent::modify($entity, $formDatas);
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/bash
|
||||
/usr/bin/php /home/dbms/public/index.php cli/billing
|
||||
/usr/bin/php /home/donfig/dbms/public/index.php cli/billing
|
||||
|
||||
Loading…
Reference in New Issue
Block a user