Commit 39b3962e by 庄欣

套系增加时间判断

parent ae50c283
......@@ -44,6 +44,7 @@ class ControllerBase
$client->setUrl($this->prefix."?".$query);
$client->setMethod("get");
$res = $client->curl();
$res = $this->after_hook($res);
return Response::success($res);
} catch (\Exception $e) {
return Response::error($e->getMessage());
......@@ -183,4 +184,8 @@ class ControllerBase
}
return $result;
}
protected function after_hook($res) {
return $res;
}
}
\ No newline at end of file
......@@ -14,6 +14,29 @@ class Sets extends ControllerBase
protected $prefix = "sets";
const TIME_BEFORE = 0;
const TIME_IN = 1;
const TIME_AFTER = 2;
protected function after_hook($res)
{
$path = app_path("Lib")."/underscore.php";
include_once $path;
$data = [];
$now = time();
__()->each($res->data,function($item) use (&$data,$now){
if (strtotime($item->start_time) > $now) {
$item->time_status = Sets::TIME_BEFORE;
} elseif(strtotime($item->end_time) < $now) {
$item->time_status = Sets::TIME_AFTER;
} else {
$item->time_status = Sets::TIME_IN;
}
array_push($data,$item);
});
$res->data = $data;
return parent::after_hook($res);
}
//上下架
public function shelf_up($id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment