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
f0e0a0f2
Commit
f0e0a0f2
authored
Mar 11, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建修改活动
parent
2b207672
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
20 deletions
+74
-20
ActivityService.php
application/api/service/ActivityService.php
+40
-10
ActivityValidate.php
application/api/validate/ActivityValidate.php
+2
-1
Activity.php
application/index/controller/Activity.php
+20
-9
CActivity.php
application/model/CActivity.php
+12
-0
No files found.
application/api/service/ActivityService.php
View file @
f0e0a0f2
...
@@ -19,32 +19,62 @@ class ActivityService
...
@@ -19,32 +19,62 @@ class ActivityService
$this
->
activityModel
=
new
CActivity
();
$this
->
activityModel
=
new
CActivity
();
}
}
public
function
createActivity
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
public
function
createActivity
(
$
id
,
$
title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
{
{
return
$this
->
activityModel
->
addActivity
(
$arr
=
$this
->
activityBin
(
$id
,
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$this
->
activityBin
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
);
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
$id
=
0
;
);
if
(
$id
>
0
){
$id
=
$this
->
activityModel
->
editorActivity
(
$id
,
$arr
);
}
else
{
$id
=
$this
->
activityModel
->
addActivity
(
$arr
);
}
return
$id
;
}
}
private
function
activityBin
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
private
function
activityBin
(
$
id
,
$
title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
{
{
if
(
$id
==
0
)
{
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
}
if
(
!
empty
(
$title
))
{
$arr
[
"title"
]
=
$title
;
$arr
[
"title"
]
=
$title
;
}
if
(
isset
(
$return_type
))
{
$arr
[
"return_type"
]
=
$return_type
;
$arr
[
"return_type"
]
=
$return_type
;
}
if
(
!
empty
(
$money
))
{
$arr
[
"money"
]
=
$money
;
$arr
[
"money"
]
=
$money
;
}
if
(
isset
(
$return_action
))
{
$arr
[
"return_action"
]
=
$return_action
;
$arr
[
"return_action"
]
=
$return_action
;
$arr
[
"activity_start_time"
]
=
date
(
"Y-m-d H:i:s"
,
$activity_start_time
);
}
$arr
[
"activity_end_time"
]
=
date
(
"Y-m-d H:i:s"
,
$activity_end_time
);
if
(
!
empty
(
$activity_start_time
))
{
$arr
[
"activity_start_time"
]
=
$activity_start_time
;
}
if
(
!
empty
(
$activity_end_time
))
{
$arr
[
"activity_end_time"
]
=
$activity_end_time
;
}
if
(
!
empty
(
$use_period
))
{
$arr
[
"use_period"
]
=
$use_period
;
$arr
[
"use_period"
]
=
$use_period
;
}
if
(
!
empty
(
$total
))
{
$arr
[
"total"
]
=
$total
;
$arr
[
"total"
]
=
$total
;
}
if
(
!
empty
(
$available
))
{
$arr
[
"available"
]
=
$available
;
$arr
[
"available"
]
=
$available
;
}
if
(
!
empty
(
$activity_rule
))
{
$arr
[
"activity_rule"
]
=
$activity_rule
;
$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
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
if
(
$activity_start_time
>
time
())
{
//新增的时候才判断是否开始活动
if
(
$activity_start_time
>
time
()
&&
$id
==
0
)
{
$arr
[
"status"
]
=
5
;
$arr
[
"status"
]
=
5
;
}
else
{
}
else
{
$arr
[
"status"
]
=
0
;
$arr
[
"status"
]
=
0
;
...
...
application/api/validate/ActivityValidate.php
View file @
f0e0a0f2
...
@@ -58,6 +58,6 @@ class ActivityValidate extends Validate
...
@@ -58,6 +58,6 @@ class ActivityValidate extends Validate
protected
$scene
=
[
protected
$scene
=
[
'create'
=>
[
'title'
,
'return_type'
,
'money'
,
'return_action'
,
'activity_start_time'
,
'activity_end_time'
,
'use_period'
,
'create'
=>
[
'title'
,
'return_type'
,
'money'
,
'return_action'
,
'activity_start_time'
,
'activity_end_time'
,
'use_period'
,
'total'
,
'available'
,
'activity_rule'
,
'status'
],
'total'
,
'available'
,
'activity_rule'
],
];
];
}
}
\ No newline at end of file
application/index/controller/Activity.php
View file @
f0e0a0f2
...
@@ -24,13 +24,14 @@ class Activity extends Basic
...
@@ -24,13 +24,14 @@ class Activity extends Basic
}
}
/**
/**
* 新增活动
* 新增
or修改
活动
* @return \think\Response
* @return \think\Response
*/
*/
public
function
creat
eActivity
()
public
function
sav
eActivity
()
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/* $params = array(
/* $params = array(
'id' => 1,
'title' => '活动1',
'title' => '活动1',
'return_type' => '1',
'return_type' => '1',
'money' => '1121',
'money' => '1121',
...
@@ -42,7 +43,7 @@ class Activity extends Basic
...
@@ -42,7 +43,7 @@ class Activity extends Basic
'available' => 1,
'available' => 1,
'activity_rule' => '加拉时间的发送去问问人情味',
'activity_rule' => '加拉时间的发送去问问人情味',
);*/
);*/
$checkResult
=
$this
->
validate
(
$params
,
"ActivityValidate.
create
"
);
$checkResult
=
$this
->
validate
(
$params
,
"ActivityValidate.
editor
"
);
if
(
true
!==
$checkResult
)
{
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
...
@@ -56,13 +57,20 @@ class Activity extends Basic
...
@@ -56,13 +57,20 @@ class Activity extends Basic
$total
=
$params
[
"total"
];
$total
=
$params
[
"total"
];
$available
=
$params
[
"available"
];
$available
=
$params
[
"available"
];
$activity_rule
=
$params
[
"activity_rule"
];
$activity_rule
=
$params
[
"activity_rule"
];
//编辑
$id
=
0
;
if
(
!
empty
(
$params
[
"id"
])
&&
isset
(
$params
[
"id"
]))
{
$id
=
$params
[
"id"
];
}
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"
,
"活动开始时间和结束时间不能小于当前时间"
);
}
}
$is_ok
=
$this
->
activityService
->
createActivity
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
}
$is_ok
=
$this
->
activityService
->
createActivity
(
$id
,
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
);
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
);
if
(
$is_ok
>
0
)
{
if
(
$is_ok
>
0
)
{
return
$this
->
response
(
"200"
,
"
add
success"
);
return
$this
->
response
(
"200"
,
"success"
);
}
else
{
}
else
{
return
$this
->
response
(
"101"
,
"faild"
);
return
$this
->
response
(
"101"
,
"faild"
);
}
}
...
@@ -79,7 +87,8 @@ class Activity extends Basic
...
@@ -79,7 +87,8 @@ class Activity extends Basic
public
function
getActivityList
()
public
function
getActivityList
()
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/* $params = array(
/* $params = array(
"id" => 1,
"title" => "asd",
"title" => "asd",
"pageNo" => 1,
"pageNo" => 1,
"pageSize" => 15,
"pageSize" => 15,
...
@@ -87,16 +96,18 @@ class Activity extends Basic
...
@@ -87,16 +96,18 @@ class Activity extends Basic
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageNo
=
empty
(
$params
[
'pageNo'
])
?
1
:
$params
[
'pageNo'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$pageSize
=
empty
(
$params
[
'pageSize'
])
?
15
:
$params
[
'pageSize'
];
$activityModel
=
new
CActivity
();
$activityModel
=
new
CActivity
();
$field
=
'id,activity_start_time,activity_end_time,available,get_number'
;
$field
=
'id,title,return_type,money,return_action,activity_start_time,activity_end_time,use_period,total,
available,get_number,activity_rule,status,create_time'
;
$where_
=
[];
$where_
=
[];
if
(
!
empty
(
$params
[
"title"
]))
{
if
(
!
empty
(
$params
[
"title"
]))
{
$where_
[
"title"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
'title'
])
.
"%"
);
$where_
[
"title"
]
=
array
(
"like"
,
"%"
.
trim
(
$params
[
'title'
])
.
"%"
);
}
}
if
(
!
empty
(
$params
[
"id"
]))
{
$where_
[
"id"
]
=
$params
[
'id'
];
}
$where_
[
"status"
]
=
array
(
"neq"
,
4
);
$where_
[
"status"
]
=
array
(
"neq"
,
4
);
$list
=
$activityModel
->
getActivityList
(
$field
,
$where_
,
$pageNo
,
$pageSize
);
$list
=
$activityModel
->
getActivityList
(
$field
,
$where_
,
$pageNo
,
$pageSize
);
return
$this
->
response
(
"200"
,
"success"
,
$list
);
return
$this
->
response
(
"200"
,
"success"
,
$list
);
}
}
...
...
application/model/CActivity.php
View file @
f0e0a0f2
...
@@ -31,6 +31,18 @@ class CActivity extends Model
...
@@ -31,6 +31,18 @@ class CActivity extends Model
}
}
return
$id
;
return
$id
;
}
}
public
function
editorActivity
(
$id
,
$data
)
{
Db
::
startTrans
();
try
{
$this
->
db_
->
where
(
'id'
,
$id
)
->
update
(
$data
);
Db
::
commit
();
return
$id
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
0
;
}
}
/**
/**
* 查询
* 查询
...
...
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