c
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Deal\AdminController;
|
||||
|
||||
use Hura8\Components\Deal\Model\DealCollectionModel;
|
||||
use Hura8\System\Controller\aAdminEntityBaseController;
|
||||
|
||||
class ADealCollectionController extends aAdminEntityBaseController
|
||||
{
|
||||
|
||||
/* @var DealCollectionModel $objDealCollectionModel */
|
||||
protected $objDealCollectionModel;
|
||||
|
||||
public function __construct() {
|
||||
$this->objDealCollectionModel = new DealCollectionModel();
|
||||
parent::__construct($this->objDealCollectionModel);
|
||||
}
|
||||
|
||||
public function getAllProductIdInCollection($collection_id) {
|
||||
return $this->objDealCollectionModel->getAllProductIdInCollection($collection_id);
|
||||
}
|
||||
|
||||
public function getAllDealIdInCollection($collection_id) {
|
||||
return $this->objDealCollectionModel->getAllDealIdInCollection($collection_id);
|
||||
}
|
||||
|
||||
public function updateAllDealInCollection($collection_id, $price, $time){
|
||||
return $this->objDealCollectionModel->updateAllDealInCollection($collection_id, $price, $time);
|
||||
}
|
||||
|
||||
public function addProductToCollection($product_id, $collection_id){
|
||||
return $this->objDealCollectionModel->addProductToCollection($product_id, $collection_id);
|
||||
}
|
||||
|
||||
public function removeFromCollection($deal_id, $collection_id){
|
||||
$this->objDealCollectionModel->removeFromCollection($deal_id, $collection_id);
|
||||
}
|
||||
|
||||
public function addToCollection($deal_id, $collection_id){
|
||||
$this->objDealCollectionModel->addToCollection($deal_id, $collection_id);
|
||||
}
|
||||
|
||||
public function updateCollectionView($id){
|
||||
$this->objDealCollectionModel->updateCollectionView($id);
|
||||
}
|
||||
|
||||
protected function deleteFileBeforeDeleteItem($item_id): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Hura8\Components\Deal\AdminController;
|
||||
|
||||
use Hura8\Components\Deal\Controller\bDealController;
|
||||
use Hura8\Interfaces\iEntityAdminController;
|
||||
use Hura8\Traits\AdminEntityBaseControllerTraits;
|
||||
|
||||
class ADealController extends bDealController implements iEntityAdminController
|
||||
{
|
||||
|
||||
use AdminEntityBaseControllerTraits;
|
||||
|
||||
|
||||
public function autoRenew() {
|
||||
$deal_list = $this->objDealModel->getAllAutoRenewableDeal();
|
||||
|
||||
//then renew & log history
|
||||
foreach ($deal_list as $info) {
|
||||
$this->renewDeal($info['id'], $info['from_time'], $info['to_time'], $info['auto_renew_history']);
|
||||
}
|
||||
}
|
||||
|
||||
protected function renewDeal($id, $from_time, $to_time, array $auto_renew_history) {
|
||||
/*$obj_from_date = new \DateTime(date("Y-m-d", $from_time));
|
||||
$obj_to_date = new \DateTime(date("Y-m-d", $to_time));
|
||||
$day_diff = $obj_to_date->diff($obj_from_date)->format('%a');
|
||||
|
||||
$obj_to_date->add(new \DateInterval('P'.$day_diff.'D'));
|
||||
$new_date = $obj_to_date->format('Y-m-d');
|
||||
|
||||
$current_date = date("Y-m-d");
|
||||
$from_time_minute = ($from_time > 0) ? date("H:i", $from_time) : "00:00";
|
||||
$to_time_minute = ($to_time > 0) ? date("H:i", $to_time) : "00:00";*/
|
||||
|
||||
$to_time_new = CURRENT_TIME + ($to_time - $from_time);
|
||||
|
||||
$auto_renew_history[] = [
|
||||
"renew_time" => show_datetime_from_unix(CURRENT_TIME),
|
||||
"from_time" => show_datetime_from_unix(CURRENT_TIME),
|
||||
"to_time" => show_datetime_from_unix($to_time_new),
|
||||
];
|
||||
|
||||
return $this->updateFields( $id,
|
||||
[
|
||||
'from_time' => CURRENT_TIME,
|
||||
'to_time' => $to_time_new,
|
||||
'auto_renew_history' => serialize($auto_renew_history),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function deleteFileBeforeDeleteItem($item_id): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user