Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
53e218f4
Commit
53e218f4
authored
Mar 11, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取活动列表
parent
e9e5454d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
19 deletions
+83
-19
ActivityService.php
application/api/service/ActivityService.php
+5
-0
Activity.php
application/index/controller/Activity.php
+57
-19
CActivity.php
application/model/CActivity.php
+21
-0
No files found.
application/api/service/ActivityService.php
View file @
53e218f4
...
...
@@ -44,6 +44,11 @@ class ActivityService
$arr
[
"activity_rule"
]
=
$activity_rule
;
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
if
(
$activity_start_time
>
time
())
{
$arr
[
"status"
]
=
5
;
}
else
{
$arr
[
"status"
]
=
0
;
}
return
$arr
;
}
}
application/index/controller/Activity.php
View file @
53e218f4
...
...
@@ -4,6 +4,7 @@ namespace app\index\controller;
use
app\index\extend\Basic
;
use
app\api\service\ActivityService
;
use
app\model\CActivity
;
use
think\Request
;
/**
...
...
@@ -22,21 +23,25 @@ class Activity extends Basic
$this
->
activityService
=
new
ActivityService
();
}
/**
* 新增活动
* @return \think\Response
*/
public
function
createActivity
()
{
$params
=
$this
->
params
;
/* $params = array(
'title' => '活动1',
'return_type' => '1',
'money' => '1121',
'return_action' => '0',
'activity_start_time' => time(),
'activity_end_time' => time(),
'use_period' => 30,
'total' => 100,
'available' => 1,
'activity_rule' => '加拉时间的发送去问问人情味',
);*/
$params
=
$this
->
params
;
/* $params = array(
'title' => '活动1',
'return_type' => '1',
'money' => '1121',
'return_action' => '0',
'activity_start_time' => time(),
'activity_end_time' => time(),
'use_period' => 30,
'total' => 100,
'available' => 1,
'activity_rule' => '加拉时间的发送去问问人情味',
);*/
$checkResult
=
$this
->
validate
(
$params
,
"ActivityValidate.create"
);
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
...
...
@@ -51,16 +56,48 @@ class Activity extends Basic
$total
=
$params
[
"total"
];
$available
=
$params
[
"available"
];
$activity_rule
=
$params
[
"activity_rule"
];
if
(
$activity_start_time
<=
time
()
||
$activity_end_time
<
time
())
{
return
$this
->
response
(
"101"
,
"活动开始时间和结束时间不能小于当前时间"
);
if
(
$activity_start_time
<=
time
()
||
$activity_end_time
<
time
())
{
return
$this
->
response
(
"101"
,
"活动开始时间和结束时间不能小于当前时间"
);
}
$is_ok
=
$this
->
activityService
->
createActivity
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
);
if
(
$is_ok
>
0
){
return
$this
->
response
(
"200"
,
"add success"
);
}
else
{
return
$this
->
response
(
"101"
,
"faild"
);
if
(
$is_ok
>
0
)
{
return
$this
->
response
(
"200"
,
"add success"
);
}
else
{
return
$this
->
response
(
"101"
,
"faild"
);
}
}
/**
* 获取活动列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getActivityList
()
{
$params
=
$this
->
params
;
/* $params = array(
"title" => "asd",
"pageNo" => 1,
"pageSize" => 15,
);*/
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$activityModel
=
new
CActivity
();
$field
=
'id,activity_start_time,activity_end_time,available,get_number'
;
$where_
=
[];
if
(
!
empty
(
$params
[
"title"
]))
{
$where_
[
"title"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
'title'
])
.
"%"
);
}
$where_
[
"status"
]
=
array
(
"neq"
,
4
);
$list
=
$activityModel
->
getActivityList
(
$field
,
$where_
,
$pageNo
,
$pageSize
);
return
$this
->
response
(
"200"
,
"success"
,
$list
);
}
}
\ No newline at end of file
application/model/CActivity.php
View file @
53e218f4
...
...
@@ -56,6 +56,27 @@ class CActivity extends Model
return
$result
;
}
/**
* @param $field
* @param $params
* @param $pageNo
* @param $pageSize
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getActivityList
(
$field
,
$params
,
$pageNo
,
$pageSize
)
{
$result
=
$this
->
db_
->
field
(
$field
)
->
where
(
$params
)
->
page
(
$pageNo
)
->
limit
(
$pageSize
)
->
select
();
return
$result
;
}
/**
* 更新
* @param $activity_id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment