Commit 52a93edb authored by zw's avatar zw

活动添加修改获取

parent f467d9aa
...@@ -54,10 +54,10 @@ class ActivityService ...@@ -54,10 +54,10 @@ class ActivityService
$arr["return_action"] = $return_action; $arr["return_action"] = $return_action;
} }
if (!empty($activity_start_time)) { if (!empty($activity_start_time)) {
$arr["activity_start_time"] = $activity_start_time; $arr["activity_start_time"] = date("Y-m-d H:i:s", $activity_start_time);
} }
if (!empty($activity_end_time)) { if (!empty($activity_end_time)) {
$arr["activity_end_time"] = $activity_end_time; $arr["activity_end_time"] = date("Y-m-d H:i:s", $activity_end_time);
} }
if (!empty($use_period)) { if (!empty($use_period)) {
$arr["use_period"] = $use_period; $arr["use_period"] = $use_period;
......
...@@ -25,13 +25,14 @@ class Activity extends Basic ...@@ -25,13 +25,14 @@ class Activity extends Basic
/** /**
* 新增or修改活动 * 新增or修改活动
* doc url :http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=817
* @return \think\Response * @return \think\Response
*/ */
public function saveActivity() public function saveActivity()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /*$params = array(
'id' => 1, //'id' => 1,
'title' => '活动1', 'title' => '活动1',
'return_type' => '1', 'return_type' => '1',
'money' => '1121', 'money' => '1121',
...@@ -43,7 +44,7 @@ class Activity extends Basic ...@@ -43,7 +44,7 @@ class Activity extends Basic
'available' => 1, 'available' => 1,
'activity_rule' => '加拉时间的发送去问问人情味', 'activity_rule' => '加拉时间的发送去问问人情味',
);*/ );*/
$checkResult = $this->validate($params, "ActivityValidate.editor"); $checkResult = $this->validate($params, "ActivityValidate.create");
if (true !== $checkResult) { if (true !== $checkResult) {
return $this->response("101", $checkResult); return $this->response("101", $checkResult);
} }
...@@ -62,7 +63,7 @@ class Activity extends Basic ...@@ -62,7 +63,7 @@ class Activity extends Basic
if (!empty($params["id"]) && isset($params["id"])) { if (!empty($params["id"]) && isset($params["id"])) {
$id = $params["id"]; $id = $params["id"];
} else { } else {
if ($activity_start_time <= time() || $activity_end_time < time()) { if ($activity_start_time < time() || $activity_end_time < time()) {
return $this->response("101", "活动开始时间和结束时间不能小于当前时间"); return $this->response("101", "活动开始时间和结束时间不能小于当前时间");
} }
} }
...@@ -79,6 +80,7 @@ class Activity extends Basic ...@@ -79,6 +80,7 @@ class Activity extends Basic
/** /**
* 获取活动列表 * 获取活动列表
* doc url :http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=818
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
......
...@@ -82,7 +82,9 @@ class Basic extends Controller ...@@ -82,7 +82,9 @@ class Basic extends Controller
'index/uploadEditor', 'index/uploadEditor',
'index/downloadFile', 'index/downloadFile',
'index/getStoreRandKingListByAgentId', 'index/getStoreRandKingListByAgentId',
'index/getRandKingListByAgentId' 'index/getRandKingListByAgentId',
'index/saveActivity',
'index/getActivityList',
); );
/** /**
......
<?php
namespace app\index\validate;
use think\Validate;
/**
* Created by PhpStorm.
* User: zw
* Date: 2019/3/11
* Time: 9:49
*/
class ActivityValidate extends Validate
{
protected $rule = [
'id' => 'require',
'title' => 'require|length:1,80',
'return_type' => 'require|in:0,1',
'money' => 'require|number|gt:0|lt:5000',
'return_action' => 'require|in:0,1,2',
'activity_start_time' => 'require',
'activity_end_time' => 'require',
'use_period' => 'require|number',
'total' => 'require|number',
'available' => 'require|number',
'get_number' => 'require|number|gt:0',
'activity_rule' => 'require',
'status' => 'require|number|in:0,1,2,3,4,5',
];
protected $message = [
'id.require' => '活动id不能为空',
'title.length:1,80' => '活动标题字数必须1-80',
'return_type.require' => '奖励类型为必须字段',
'return_type.in' => '奖励类型错误',
'money.require' => '奖励金额为必填',
'money.number' => '奖励金额必须是数字',
'money.gt' => '奖励金额必须大于0',
'money.lt' => '奖励金额不能大于5000',
'return_action.require' => '奖励动作为必填',
'return_action.in' => '奖励动作值错误',
'activity_start_time.require' => '活动开始时间为必填',
'activity_end_time.require' => '活动结束时间为必填',
'use_period.require' => '使用有效期为必须字段',
'use_period.number' => '使用有效期必须是数字',
'total.require' => '可发放总数为必须字段',
'total.number' => '可发放总数必须是数字',
'available.require' => '用户可领数为必须字段',
'available.number' => '用户可领数必须是数字',
'get_number.require' => '已领数不能为空',
'get_number.number' => '已领数只能是数字',
'get_number.gt' => '已领数必须大于0',
'activity_rule.require' => '活动规则为必填',
'status.require' => '活动状态为必填',
'status.number' => '活动状态必须为数字',
'status.in' => '活动状态值错误',
];
protected $scene = [
'create' => ['title', 'return_type', 'money', 'return_action', 'activity_start_time', 'activity_end_time', 'use_period',
'total', 'available', 'activity_rule'],
];
}
\ No newline at end of file
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