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
c47063eb
Commit
c47063eb
authored
Mar 04, 2019
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner顺序,购买限制,销售量
parent
a9ef5176
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
41 deletions
+110
-41
application/admin/controller/Banner.php
+12
-1
application/admin/view/banner/index.html
+32
-11
application/api/controller/Banner.php
+1
-1
application/api/controller/Order.php
+5
-0
application/api/controller/Project.php
+5
-3
application/common/model/Order.php
+55
-25
No files found.
application/admin/controller/Banner.php
View file @
c47063eb
...
...
@@ -21,10 +21,11 @@ class Banner extends AuthBase
$condition
[
'status'
]
=
$status
;
}
$banner_model
=
model
(
'banner'
);
$banner_list
=
$banner_model
->
where
(
$condition
)
->
order
(
'created_at'
,
'
desc'
)
->
paginate
(
10
,
false
,
[
'query'
=>
[
'status'
=>
$status
]]);
$banner_list
=
$banner_model
->
where
(
$condition
)
->
order
(
'sort desc,created_at
desc'
)
->
paginate
(
10
,
false
,
[
'query'
=>
[
'status'
=>
$status
]]);
$this
->
assign
(
'banner_list'
,
$banner_list
);
return
$this
->
fetch
();
}
//新建banner
public
function
create
()
{
...
...
@@ -49,6 +50,7 @@ class Banner extends AuthBase
return
$this
->
fetch
(
'update'
);
}
}
//更新banner
public
function
update
(
$id
)
{
...
...
@@ -77,6 +79,7 @@ class Banner extends AuthBase
return
$this
->
fetch
();
}
}
//删除banner
public
function
delete
()
{
...
...
@@ -91,4 +94,12 @@ class Banner extends AuthBase
$this
->
error
(
'删除失败'
,
''
,
''
,
1
);
}
}
public
function
changeSort
(
$id
,
$sort
=
0
)
{
$info
=
\app\common\model\Banner
::
get
(
$id
);
$info
->
sort
=
$sort
;
$info
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'修改成功'
];
}
}
application/admin/view/banner/index.html
View file @
c47063eb
...
...
@@ -7,12 +7,15 @@
<div
class=
"row margin-bottom"
>
<div
class=
"col-md-12"
>
<form
class=
"form-inline pull-left"
method=
"GET"
id=
"order-search"
action=
"<?php echo url('@admin/banner/index')?>"
>
<form
class=
"form-inline pull-left"
method=
"GET"
id=
"order-search"
action=
"<?php echo url('@admin/banner/index')?>"
>
<div
class=
"form-group"
>
<select
name=
"status"
class=
"form-control"
id=
"status"
>
<option
value=
""
>
显示状态
</option>
<option
value=
"1"
{
if
condition=
"input('status')=='1'"
}
selected
{/
if
}
>
显示
</option>
<option
value=
"2"
{
if
condition=
"input('status')=='2'"
}
selected
{/
if
}
>
不显示
</option>
<option
value=
"1"
{
if
condition=
"input('status')=='1'"
}
selected
{
/
if
}
>
显示
</option>
<option
value=
"2"
{
if
condition=
"input('status')=='2'"
}
selected
{
/
if
}
>
不显示
</option>
</select>
</div>
<!--<button type="submit" class="btn btn-primary">搜索</button>-->
...
...
@@ -40,6 +43,7 @@
<th>
图片
</th>
<th>
类型
</th>
<th>
地址
</th>
<th>
排序
</th>
<th>
是否显示
</th>
<th>
发布时间
</th>
<th>
操作
</th>
...
...
@@ -62,6 +66,8 @@
{/if}
</td>
<td>
{$vo.url}
</td>
<td><input
data-id=
"{$vo.id}"
class=
"changeSort"
type=
"text"
name=
"sort"
value=
"{$vo['sort']}"
>
</td>
<td>
{if condition="$vo.status == 1"}
显示
...
...
@@ -71,8 +77,10 @@
</td>
<td>
{$vo.created_at}
</td>
<td>
<a
href=
"{:url('admin/banner/update',['id'=>$vo.id])}"
class=
"btn btn-xs btn-primary"
><i
class=
"fa fa-pencil"
></i></a>
<a
href=
"javascript:"
oid=
"{$vo.id}"
class=
"btn btn-xs btn-danger btn-delete"
><i
class=
"fa fa-trash"
></i></a>
<a
href=
"{:url('admin/banner/update',['id'=>$vo.id])}"
class=
"btn btn-xs btn-primary"
><i
class=
"fa fa-pencil"
></i></a>
<a
href=
"javascript:"
oid=
"{$vo.id}"
class=
"btn btn-xs btn-danger btn-delete"
><i
class=
"fa fa-trash"
></i></a>
</td>
</tr>
{/volist}
...
...
@@ -90,27 +98,40 @@
<script
type=
"text/javascript"
>
// 文档加载完毕之后,会进入该方法
$
(
"#status"
).
change
(
function
()
{
$
(
"#status"
).
change
(
function
()
{
$
(
"#order-search"
).
submit
();
});
$
(
function
()
{
$
(
".btn-delete"
).
click
(
function
()
{
$
(
function
()
{
$
(
".btn-delete"
).
click
(
function
()
{
var
_this
=
$
(
this
);
var
url
=
"{:url('admin/banner/delete')}"
;
var
oid
=
_this
.
attr
(
'oid'
);
showDialog
(
"提示"
,
"确定删除该轮播图吗?"
,
function
()
{
showDialog
(
"提示"
,
"确定删除该轮播图吗?"
,
function
()
{
// ajax post 方法
$
.
post
(
url
,
{
id
:
oid
},
function
(
res
)
{
$
.
post
(
url
,
{
id
:
oid
},
function
(
res
)
{
// var res = JSON.parse(res);
if
(
res
.
code
==
1
)
{
// javascript 的默认弹出提示方法
_this
.
remove
();
$
(
"#tr_"
+
oid
).
fadeOut
();
$
(
"#tr_"
+
oid
).
fadeOut
();
}
else
{
alert
(
res
.
msg
);
}
});
});
});
//
$
(
'.changeSort'
).
change
(
function
()
{
let
sort
=
$
(
this
).
val
()
let
id
=
$
(
this
).
attr
(
'data-id'
)
$
.
post
(
"{:url('changeSort')}"
,{
id
:
id
,
sort
:
sort
},
function
(
res
)
{
if
(
res
.
code
===
0
){
layer
.
msg
(
res
.
msg
,
function
(){
location
.
reload
()
})
}
})
})
});
</script>
application/api/controller/Banner.php
View file @
c47063eb
...
...
@@ -20,7 +20,7 @@ class Banner extends Base
public
function
index
()
{
$banner
=
BannerModel
::
where
(
'status'
,
1
)
->
order
(
'
id'
,
'
desc'
)
->
order
(
'
sort desc,id
desc'
)
->
select
();
if
(
!
$banner
)
return
[
'code'
=>
1
,
'msg'
=>
'没有更多'
];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$banner
];
...
...
application/api/controller/Order.php
View file @
c47063eb
...
...
@@ -61,6 +61,11 @@ class Order extends Base
//活动过期
return
[
'code'
=>
1
,
'msg'
=>
'活动已截止报名'
];
}
//检验VIP超过
if
(
UserModel
::
get
(
$this
->
userinfo
[
0
])[
'is_vip'
]){
if
(
input
(
'sign_limits'
)
+
(
new
OrderModel
)
->
getBuyVipLimits
(
$this
->
userinfo
[
0
],
$project
[
'id'
])
>
$project
[
'vip_limits'
])
return
[
'code'
=>
1
,
'msg'
=>
'您已超过此活动的会员限购次数,如需额外购买,请联系客服处理!'
];
}
//生成订单
try
{
//开始事务
...
...
application/api/controller/Project.php
View file @
c47063eb
...
...
@@ -424,13 +424,15 @@ class Project extends Base
$project
[
'is_vip'
]
=
$user
[
'is_vip'
];
if
(
$project
[
'type'
]
==
1
){
//会员限购
$project
[
'buy_vip_limits'
]
=
\app\common\model\Order
::
where
([
'uid'
=>
$this
->
userinfo
[
0
],
$project
[
'buy_vip_limits'
]
=
(
new
\app\common\model\Order
)
->
getBuyVipLimits
(
$this
->
userinfo
[
0
],
$project
[
'id'
]);
}
//获取销售量
$project
[
'sales_count'
]
=
\app\common\model\Order
::
where
([
'pid'
=>
$project
[
'id'
],
'status'
=>
[
'in'
,
'1,2,3'
],
'is_refund'
=>
[
'neq'
,
3
]
])
->
count
(
'id'
);
}
$project
[
'sales_count'
]
=
(
new
\app\common\model\Order
)
->
getSales
(
$project
[
'id'
]);
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$project
];
}
...
...
application/common/model/Order.php
View file @
c47063eb
...
...
@@ -21,12 +21,15 @@ class Order extends BaseModel
protected
$table
=
'mr_user_orders'
;
// 订单退款信息
public
function
linkrefund
(){
return
$this
->
hasOne
(
'refund'
,
'order_id'
,
'id'
)
->
field
(
'id'
);
public
function
linkrefund
()
{
return
$this
->
hasOne
(
'refund'
,
'order_id'
,
'id'
)
->
field
(
'id'
);
}
// 订单退款信息
public
function
linkcomment
(){
return
$this
->
hasOne
(
'comment'
,
'order_id'
,
'id'
)
->
field
(
'id'
);
public
function
linkcomment
()
{
return
$this
->
hasOne
(
'comment'
,
'order_id'
,
'id'
)
->
field
(
'id'
);
}
...
...
@@ -72,69 +75,96 @@ class Order extends BaseModel
{
//获取家庭组限制
$project
=
ProjectModel
::
lock
(
true
)
->
find
(
$pid
);
if
(
$project
[
'sign_limits'
]
>=
intval
(
$project
[
'sign_num'
])
+
$sign_limits
)
{
if
(
$project
[
'sign_limits'
]
>=
intval
(
$project
[
'sign_num'
])
+
$sign_limits
)
{
return
true
;
}
return
false
;
}
//订单状态
public
function
getStatusTextAttr
(
$value
,
$data
)
public
function
getStatusTextAttr
(
$value
,
$data
)
{
$str
=
''
;
if
(
$data
[
'status'
]
==
config
(
'order_status.pay'
))
{
if
(
$data
[
'status'
]
==
config
(
'order_status.pay'
))
{
//进行中
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no'
))
{
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no'
))
{
$str
=
'申请退款'
;
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.to_examine'
))
{
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.to_examine'
))
{
$str
=
'退款申请中'
;
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no_pass'
))
{
}
elseif
(
$data
[
'is_refund'
]
==
config
(
'refund_status.no_pass'
))
{
$str
=
'退款失败'
;
}
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.wait_comment'
))
{
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.wait_comment'
))
{
//待评价
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no'
))
{
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no'
))
{
$str
=
'待评价'
;
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.to_examine'
))
{
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.to_examine'
))
{
$str
=
'评价审核中'
;
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no_pass'
))
{
}
elseif
(
$data
[
'is_comment'
]
==
config
(
'comment_status.no_pass'
))
{
$str
=
'评价失败'
;
}
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.complete'
))
{
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.complete'
))
{
//待评价
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.pass'
))
{
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.pass'
))
{
$str
=
'已完成'
;
}
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.pass'
))
{
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.pass'
))
{
$str
=
'已退款'
;
}
}
return
$str
;
}
public
function
getStatusAdminTextAttr
(
$value
,
$data
)
public
function
getStatusAdminTextAttr
(
$value
,
$data
)
{
$str
=
''
;
if
(
$data
[
'status'
]
==
config
(
'order_status.pay'
))
{
if
(
$data
[
'status'
]
==
config
(
'order_status.pay'
))
{
//进行中
$str
=
"进行中"
;
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.wait_comment'
))
{
$str
=
"进行中"
;
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.wait_comment'
))
{
//待评价
$str
=
'待评价'
;
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.complete'
))
{
}
elseif
(
$data
[
'status'
]
==
config
(
'order_status.complete'
))
{
//待评价
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.pass'
))
{
if
(
$data
[
'is_comment'
]
==
config
(
'comment_status.pass'
))
{
$str
=
'已完成'
;
}
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.pass'
))
{
if
(
$data
[
'is_refund'
]
==
config
(
'refund_status.pass'
))
{
$str
=
'已退款'
;
}
}
elseif
(
$data
[
'status'
]
==
0
)
{
}
elseif
(
$data
[
'status'
]
==
0
)
{
$str
=
'未付款'
;
}
return
$str
;
}
public
function
getBuyVipLimits
(
$user_id
,
$project_id
)
{
$list
=
$this
->
where
([
'uid'
=>
$user_id
,
'pid'
=>
$project_id
,
'status'
=>
[
'in'
,
'1,2,3'
],
'is_refund'
=>
[
'neq'
,
3
]
])
->
select
();
$sum
=
0
;
foreach
(
$list
as
$v
)
{
$sum
+=
$v
[
'extras'
][
'sign_limits'
];
}
return
$sum
;
}
public
function
getSales
(
$project_id
)
{
$list
=
$this
->
where
([
'pid'
=>
$project_id
,
'status'
=>
[
'in'
,
'1,2,3'
],
'is_refund'
=>
[
'neq'
,
3
]
])
->
select
();
$sum
=
0
;
foreach
(
$list
as
$v
)
{
$sum
+=
$v
[
'extras'
][
'sign_limits'
];
}
return
$sum
;
}
}
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