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
1758a2e9
Commit
1758a2e9
authored
Mar 11, 2019
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存活动
parent
81e34180
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
12 deletions
+103
-12
Activity.php
application/api/controller/Activity.php
+41
-3
ActivityService.php
application/api/service/ActivityService.php
+39
-1
CActivity.php
application/model/CActivity.php
+23
-8
No files found.
application/api/controller/Activity.php
View file @
1758a2e9
<?php
<?php
namespace
app\api\controller
;
namespace
app\api\controller
;
use
app\api\extend\Basic
;
use
app\api\extend\Basic
;
use
app\api\service\ActivityService
;
use
think\Request
;
use
think\Request
;
/**
/**
...
@@ -9,16 +12,50 @@ use think\Request;
...
@@ -9,16 +12,50 @@ use think\Request;
* Date: 2019/3/11
* Date: 2019/3/11
* Time: 9:46
* Time: 9:46
*/
*/
class
Activity
extends
Basic
{
class
Activity
extends
Basic
{
private
$activityService
;
public
function
__construct
(
Request
$request
=
null
)
public
function
__construct
(
Request
$request
=
null
)
{
{
parent
::
__construct
(
$request
);
parent
::
__construct
(
$request
);
$this
->
activityService
=
new
ActivityService
();
}
}
public
function
createActivity
(){
public
function
createActivity
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$checkResult
=
$this
->
validate
(
$params
,
"UWxInfoValidate.add"
);
$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
)
{
if
(
true
!==
$checkResult
)
{
return
$this
->
response
(
"101"
,
$checkResult
);
return
$this
->
response
(
"101"
,
$checkResult
);
}
}
$title
=
$params
[
"title"
];
$return_type
=
$params
[
"return_type"
];
$money
=
$params
[
"money"
];
$return_action
=
$params
[
"return_action"
];
$activity_start_time
=
$params
[
"activity_start_time"
];
$activity_end_time
=
$params
[
"activity_end_time"
];
$use_period
=
$params
[
"use_period"
];
$total
=
$params
[
"total"
];
$available
=
$params
[
"available"
];
$activity_rule
=
$params
[
"activity_rule"
];
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
);
}
}
}
}
\ No newline at end of file
application/api/service/ActivityService.php
View file @
1758a2e9
<?php
<?php
namespace
app\api\service
;
namespace
app\api\service
;
use
app\model\CActivity
;
/**
/**
* Created by PhpStorm.
* Created by PhpStorm.
* User: zw
* User: zw
* Date: 2019/3/11
* Date: 2019/3/11
* Time: 10:15
* Time: 10:15
*/
*/
class
ActivityService
{
class
ActivityService
{
private
$activityModel
;
public
function
__construct
()
{
$this
->
activityModel
=
new
CActivity
();
}
public
function
createActivity
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
{
return
$this
->
activityModel
->
addActivity
(
$this
->
activityBin
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
);
}
private
function
activityBin
(
$title
,
$return_type
,
$money
,
$return_action
,
$activity_start_time
,
$activity_end_time
,
$use_period
,
$total
,
$available
,
$activity_rule
)
{
$arr
[
"title"
]
=
$title
;
$arr
[
"return_type"
]
=
$return_type
;
$arr
[
"money"
]
=
$money
;
$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
);
$arr
[
"use_period"
]
=
$use_period
;
$arr
[
"total"
]
=
$total
;
$arr
[
"available"
]
=
$available
;
$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
());
return
$arr
;
}
}
}
application/model/CActivity.php
View file @
1758a2e9
...
@@ -9,14 +9,27 @@ class CActivity extends Model
...
@@ -9,14 +9,27 @@ class CActivity extends Model
{
{
// 设置当前模型对应的完整数据表名称
// 设置当前模型对应的完整数据表名称
protected
$table
=
'c_activity'
;
protected
$table
=
'c_activity'
;
private
$db_
;
public
function
__construct
(
$data
=
[])
{
parent
::
__construct
(
$data
);
$this
->
db_
=
Db
::
table
(
$this
->
table
);
}
public
function
addActivity
(
$data
)
{
$time
=
date
(
"Y-m-d H:i:s"
,
time
());
$data
[
'create_time'
]
=
$time
;
public
function
addActivity
(
$data
)
$data
[
'update_time'
]
=
$time
;
{
return
$this
->
insert
(
$data
);
Db
::
startTrans
();
$id
=
0
;
try
{
$id
=
$this
->
db_
->
insertGetId
(
$data
);
Db
::
commit
();
return
$id
;
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
}
return
$id
;
}
}
/**
/**
...
@@ -28,7 +41,7 @@ class CActivity extends Model
...
@@ -28,7 +41,7 @@ class CActivity extends Model
public
function
getActivity
(
$field
,
$params
)
public
function
getActivity
(
$field
,
$params
)
{
{
$params
[
'status'
]
=
0
;
$params
[
'status'
]
=
0
;
$result
=
Db
::
table
(
$this
->
table
)
$result
=
$this
->
db_
->
field
(
$field
)
->
field
(
$field
)
->
where
(
$params
)
->
where
(
$params
)
->
select
();
->
select
();
...
@@ -42,9 +55,11 @@ class CActivity extends Model
...
@@ -42,9 +55,11 @@ class CActivity extends Model
* @param $status
* @param $status
* @return $this
* @return $this
*/
*/
public
function
updateStatus
(
$activity_id
,
$status
)
public
function
updateStatus
(
$activity_id
,
$status
)
{
{
$result
=
$this
->
where
([
'id'
=>
$activity_id
])
->
update
([
'status'
=>
$status
]);
$result
=
$this
->
db_
->
where
([
'id'
=>
$activity_id
])
->
update
([
'status'
=>
$status
]);
// big_log($this->getLastSql());
// big_log($this->getLastSql());
return
$result
;
return
$result
;
}
}
...
...
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