Commit f2f599e7 authored by suntengda's avatar suntengda

update 获取团长活动配置 默认不传date参数,获取最近配置的一条数据

parent be68fb37
...@@ -15,11 +15,6 @@ class ColonelConfigValidate extends BaseValidate ...@@ -15,11 +15,6 @@ class ColonelConfigValidate extends BaseValidate
'marketing_id' => 'marketing_id 参数不能为空', 'marketing_id' => 'marketing_id 参数不能为空',
]; ];
public function sceneDate()
{
return $this->only(["date"])->append("date", "require");
}
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(["date","config","marketing_id"])->append("marketing_id", "require"); return $this->only(["date","config","marketing_id"])->append("marketing_id", "require");
......
...@@ -68,8 +68,6 @@ class ColonelController extends Base ...@@ -68,8 +68,6 @@ class ColonelController extends Base
*/ */
public function colonel_configAction() public function colonel_configAction()
{ {
(new ColonelConfigValidate())->scene("date")->validate();
$params = $this->params; $params = $this->params;
$data = PindanActivityColonelConfigService::colonelConfig($params); $data = PindanActivityColonelConfigService::colonelConfig($params);
return $this->success(["result" => $data]); return $this->success(["result" => $data]);
......
...@@ -65,9 +65,16 @@ class PindanActivityColonelConfigService ...@@ -65,9 +65,16 @@ class PindanActivityColonelConfigService
*/ */
public static function colonelConfig($params = []) public static function colonelConfig($params = [])
{ {
$day = empty($params["date"]) ? date("Y-m-d") : $params["date"]; $day = $params["date"];
$type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"]; $type = empty($params["type"]) ? ColonelDistributorConfig::TYPE_COLONEL : $params["type"];
if(empty($day)) {
//默认取最近更新的一条配置
$config = ColonelDistributorConfig::getRecord([
"type" => $type,"ORDER" => ["update_time" => "DESC"], "LIMIT" => 1
]);
}else {
$config = ColonelDistributorConfig::getRecord(["date" => $day, "type" => $type]); $config = ColonelDistributorConfig::getRecord(["date" => $day, "type" => $type]);
}
if (empty($config)) { if (empty($config)) {
$config = ColonelDistributorConfig::getRecord([ $config = ColonelDistributorConfig::getRecord([
"date[<=]" => $day, "date[<=]" => $day,
......
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