Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
backend
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
亲子游项目
backend
Commits
0b26760f
Commit
0b26760f
authored
Sep 28, 2018
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api
parent
756ac1fa
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
216 additions
and
19 deletions
+216
-19
application/api/controller/Base.php
+0
-0
application/api/controller/Comment.php
+3
-4
application/api/controller/Order.php
+0
-0
application/api/controller/User.php
+68
-0
application/common/model/Order.php
+86
-9
application/config.php
+59
-6
No files found.
application/api/controller/Base.php
View file @
0b26760f
application/api/controller/Comment.php
View file @
0b26760f
...
...
@@ -29,7 +29,7 @@ class Comment extends Base
$p
=
input
(
'post.p/d'
,
1
);
$page
=
input
(
'post.p/d'
,
8
);
$comment
=
CommentModel
::
with
(
'user'
)
->
where
([
'pid'
=>
input
(
'post.pid'
),
'status'
=>
config
(
'
user_
comment_status.pass'
)])
->
where
([
'pid'
=>
input
(
'post.pid'
),
'status'
=>
config
(
'comment_status.pass'
)])
->
page
(
$p
,
$page
)
->
select
();
if
(
!
$comment
)
{
...
...
@@ -61,7 +61,7 @@ class Comment extends Base
$order
=
OrderModel
::
get
([
'uid'
=>
$this
->
userinfo
[
0
],
'id'
=>
input
(
'post.order_id'
),
'is_comment'
=>
[
'in'
,
[
config
(
'
user_comment_status.audit'
),
config
(
'user_
comment_status.no_pass'
)]]
'is_comment'
=>
[
'in'
,
[
config
(
'
comment_status.no'
),
config
(
'
comment_status.no_pass'
)]]
]);
//检验是否重复写入
if
(
!
$order
)
{
...
...
@@ -75,8 +75,7 @@ class Comment extends Base
'pid'
=>
$order
->
pid
,
'uid'
=>
$this
->
userinfo
[
0
],
]);
$order
->
is_comment
=
config
(
'user_comment_status.examine'
);
$order
->
is_comment
=
config
(
'comment_status.to_examine'
);
$order
->
save
();
//查询订单
return
[
'code'
=>
0
,
'msg'
=>
'评论成功'
];
...
...
application/api/controller/Order.php
View file @
0b26760f
This diff is collapsed.
Click to expand it.
application/api/controller/User.php
View file @
0b26760f
...
...
@@ -3,6 +3,7 @@
namespace
app\api\controller
;
use
app\common\model\User
as
UserModel
;
use
app\admin\controller\Upload
;
class
User
extends
Base
{
...
...
@@ -160,4 +161,70 @@ class User extends Base
$user
[
'hidephone'
]
=
substr_replace
(
$user
[
'phone'
],
'****'
,
3
,
4
);
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$user
];
}
/**
* 更新用户
* @url /api/User/update
* @param nickname 姓名
* @param sex 性别
* @return json
*/
public
function
update
()
{
//用户ID
$uid
=
$this
->
userinfo
[
0
];
$user
=
UserModel
::
get
(
$uid
);
//可选更新
if
(
input
(
'post.nickname'
))
$user
->
nickname
=
input
(
'post.nickname'
);
if
(
input
(
'post.gender'
))
$user
->
gender
=
input
(
'post.gender'
);
$user
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'更新成功'
];
}
/**
* 用户收藏列表
* @url /api/User/userCollections
* @param p 当前页
* @param page 一页显示几条
* @return json
*/
public
function
userCollections
()
{
$uid
=
$this
->
userinfo
[
0
];
$p
=
input
(
'post.p/d'
,
1
);
$page
=
input
(
'post.page/d'
,
8
);
$list
=
collection
(
UserModel
::
get
(
$uid
)
->
project
()
->
page
(
$p
,
$page
)
->
select
());
if
(
$list
->
isEmpty
())
{
return
[
'code'
=>
1
,
'msg'
=>
'没有更多'
];
}
$list
=
$list
->
visible
([
'title'
,
'night_num'
,
'price'
,
'vip_price'
,
'poster'
,])
->
append
([
'sign_endtime_str'
]);
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$list
];
}
/**
* 更新头像
* @url /api/User/uploadAvatar
* @param avatar 头像资源
* @return json
*/
public
function
uploadAvatar
()
{
$file
=
request
()
->
file
(
'avatar'
);
$upload
=
new
Upload
();
$result
=
$upload
->
sava
(
$file
);
if
(
$result
[
'error'
]
==
1
)
{
return
[
'code'
=>
1
,
'msg'
=>
$result
[
'msg'
]];
}
$url
=
$result
[
'result'
][
'url'
];
//上传头像
$user
=
UserModel
::
get
(
$this
->
userinfo
[
0
]);
$user
->
avatar
=
$url
;
$user
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'更新成功'
,
'avatar_url'
=>
$user
->
avatar
];
}
}
\ No newline at end of file
application/common/model/Order.php
View file @
0b26760f
...
...
@@ -9,32 +9,109 @@
namespace
app\common\model
;
use
app\common\model\BaseModel
;
use
think\Collection
;
use
traits\model\SoftDelete
;
use
app\common\model\Project
as
ProjectModel
;
use
app\common\model\User
as
UserModel
;
class
Order
extends
BaseModel
{
use
SoftDelete
;
// 设置当前模型对应的完整数据表名称
protected
$table
=
'mr_user_orders'
;
//获取订单商品
public
function
project
(){
return
$this
->
belongsTo
(
'Project'
,
'pid'
,
'id'
);
public
function
project
()
{
return
$this
->
belongsTo
(
'Project'
,
'pid'
,
'id'
);
}
//获取下单用户信息
public
function
userInfo
(){
return
$this
->
belongsTo
(
'User'
,
'uid'
,
'id'
);
public
function
userInfo
()
{
return
$this
->
belongsTo
(
'User'
,
'uid'
,
'id'
);
}
//处理订单状态
public
function
getStatusNameAttr
(
$value
,
$data
){
public
function
getStatusNameAttr
(
$value
,
$data
)
{
$statusNameArr
=
array
(
'0'
=>
[
'color'
=>
'#cc2e2e'
,
'name'
=>
'待付款'
],
'1'
=>
[
'color'
=>
'#c33eff'
,
'name'
=>
'进行中'
],
'2'
=>
[
'color'
=>
'#68dff0'
,
'name'
=>
'待评价'
],
'3'
=>
[
'color'
=>
'#4acc2e'
,
'name'
=>
'已完成'
]
'0'
=>
[
'color'
=>
'#cc2e2e'
,
'name'
=>
'待付款'
],
'1'
=>
[
'color'
=>
'#c33eff'
,
'name'
=>
'进行中'
],
'2'
=>
[
'color'
=>
'#68dff0'
,
'name'
=>
'待评价'
],
'3'
=>
[
'color'
=>
'#4acc2e'
,
'name'
=>
'已完成'
]
);
return
$statusNameArr
[
$data
[
'status'
]];
// 0-未付款,1-进行中,2-待评价,3-已完成
}
//extras转化成数组
public
function
getExtrasAttr
(
$value
)
{
return
json_decode
(
$value
,
true
);
}
//转化成json
public
function
setExtrasAttr
(
$value
)
{
return
json_encode
(
$value
);
}
//检验家庭组限制->已上锁
public
static
function
getGroupNumberByProject
(
$pid
,
$sign_limits
)
{
//获取家庭组限制
$project
=
ProjectModel
::
get
(
$pid
);
$order
=
self
::
lock
(
true
)
->
where
([
'status'
=>
config
(
'order_status.no_pay'
),
'created_at'
=>
[
'> time'
,
date
(
'Y-m-d H:i:s'
,
time
()
-
300
)]])
->
whereOr
(
'status'
,
'in'
,
[
config
(
'order_status.pay'
),
config
(
'order_status.wait_comment'
),
config
(
'order_status.complete'
)])
->
select
();
$count
=
0
;
if
(
$order
)
{
foreach
(
$order
as
$k
=>
$v
)
{
if
(
$v
[
'type'
]
==
config
(
'order_type.project'
)){
$count
+=
$v
[
'extras'
][
'sign_limits'
];
}
}
}
if
(
$count
+
$sign_limits
>
$project
[
'sign_limits'
])
{
return
true
;
}
return
false
;
}
//订单状态
public
function
getStatusTextAttr
(
$value
,
$data
)
{
$str
=
''
;
if
(
$data
[
'status'
]
==
config
(
'order_status.pay'
)){
//进行中
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no'
)){
$str
=
'申请退款'
;
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.to_examine'
)){
$str
=
'退款申请中'
;
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no_pass'
)){
$str
=
'退款失败'
;
}
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.wait_comment'
)){
//待评价
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no'
)){
$str
=
'待评价'
;
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.to_examine'
)){
$str
=
'评价审核中'
;
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no_pass'
)){
$str
=
'评价失败'
;
}
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.complete'
)){
//待评价
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.pass'
)){
$str
=
'已完成'
;
}
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.pass'
)){
$str
=
'已退款'
;
}
}
return
$str
;
}
}
application/config.php
View file @
0b26760f
...
...
@@ -29,7 +29,7 @@ $config = [
// 注册的根命名空间
'root_namespace'
=>
[],
// 扩展函数文件
'extra_file_list'
=>
[
APP_PATH
.
'helper.php'
,
THINK_PATH
.
'helper'
.
EXT
],
'extra_file_list'
=>
[
APP_PATH
.
'helper.php'
,
THINK_PATH
.
'helper'
.
EXT
],
// 默认输出类型
'default_return_type'
=>
'html'
,
// 默认AJAX 数据返回格式,可选json xml ...
...
...
@@ -141,8 +141,8 @@ $config = [
// 视图输出字符串内容替换
'view_replace_str'
=>
[],
// 默认跳转页面对应的模板文件
'dispatch_success_tmpl'
=>
ROOT_PATH
.
'/public/dispatch_jump.html'
,
'dispatch_error_tmpl'
=>
ROOT_PATH
.
'/public/dispatch_jump.html'
,
'dispatch_success_tmpl'
=>
ROOT_PATH
.
'/public/dispatch_jump.html'
,
'dispatch_error_tmpl'
=>
ROOT_PATH
.
'/public/dispatch_jump.html'
,
// +----------------------------------------------------------------------
// | 异常及错误设置
...
...
@@ -239,8 +239,8 @@ $config = [
// 访问错误
'http_exception_template'
=>
[
404
=>
ROOT_PATH
.
'/public/404.html'
,
500
=>
ROOT_PATH
.
'/public/500.html'
,
404
=>
ROOT_PATH
.
'/public/404.html'
,
500
=>
ROOT_PATH
.
'/public/500.html'
,
],
'app_name'
=>
'美行者亲子游'
,
...
...
@@ -272,7 +272,60 @@ $config = [
'secretKey'
=>
'FuiGofChZbYMxC3MKeCj28E-dwU8Ji-wLgByczjG'
,
'domain'
=>
'http://pezwu2vm9.bkt.clouddn.com'
,
'bucket'
=>
'meixingzhe'
,
]
],
// +----------------------------------------------------------------------
// | 退款状态
// +----------------------------------------------------------------------
'refund_status'
=>
[
'no'
=>
0
,
//无
'to_examine'
=>
1
,
//审核
'no_pass'
=>
2
,
//驳回
'pass'
=>
3
//通过
],
// +----------------------------------------------------------------------
// | 评论状态
// +----------------------------------------------------------------------
'comment_status'
=>
[
'no'
=>
0
,
//无
'to_examine'
=>
1
,
//审核
'no_pass'
=>
2
,
//驳回
'pass'
=>
3
//通过
],
// +----------------------------------------------------------------------
// | 下单类型
// +----------------------------------------------------------------------
'order_type'
=>
[
'project'
=>
1
,
'vip'
=>
2
],
// +----------------------------------------------------------------------
// | 下单状态
// +----------------------------------------------------------------------
'order_status'
=>
[
'no_pay'
=>
0
,
//待付款
'pay'
=>
1
,
//进行中(已支付)
'wait_comment'
=>
2
,
//等评论
'complete'
=>
3
//已完成
],
// +----------------------------------------------------------------------
// | 微信支付
// +----------------------------------------------------------------------
'wx_pay'
=>
[
'notify_url'
=>
'域名/api/Order/callback'
,
'vip_title'
=>
'美行者会员VIP'
,
'vip_price'
=>
49.00
],
];
return
$config
;
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