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
bd90acb0
Commit
bd90acb0
authored
Dec 12, 2018
by
LiuJunYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新需求
parent
3b7aeda1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
200 additions
and
59 deletions
+200
-59
application/admin/controller/Project.php
+14
-0
application/admin/controller/VipRelation.php
+21
-5
application/admin/view/project/index.html
+18
-3
application/admin/view/public/sidebar.html
+4
-1
application/admin/view/vip_relation/index.html
+11
-24
application/api/controller/Project.php
+109
-26
application/api/controller/User.php
+4
-0
application/common/model/VipRelation.php
+19
-0
No files found.
application/admin/controller/Project.php
View file @
bd90acb0
...
...
@@ -542,6 +542,20 @@ class Project extends AuthBase
}
}
//设置置顶排序
public
function
setTransfer
()
{
$is_transfer
=
input
(
'post.is_transfer'
);
$id
=
input
(
'post.id'
);
$res
=
model
(
'project'
)
->
save
([
'is_transfer'
=>
$is_transfer
],
[
'id'
=>
$id
]);
if
(
$res
)
{
$this
->
success
(
'开启成功'
);
}
else
{
$this
->
success
(
'开启失败'
);
}
}
//设置排序
public
function
setSort
()
{
...
...
application/admin/controller/VipRelation.php
View file @
bd90acb0
...
...
@@ -5,23 +5,37 @@ namespace app\admin\controller;
use
cocolait\extend\Excel
;
use
think\Db
;
use
think\Exception
;
use
app\common\model\VipRelation
as
VipRelationModel
;
class
VipRelation
extends
AuthBase
{
/**
*
导入
列表
*
关联
列表
*/
public
function
index
()
{
$list
=
VipRelationModel
::
order
(
'id'
,
'desc'
)
->
paginate
();
return
$this
->
fetch
(
''
,
compact
(
'list'
));
$list
=
VipRelationModel
::
where
(
function
(
$query
)
{
if
(
input
(
'mobile'
))
{
$query
->
where
(
'mobile'
,
input
(
'mobile'
));
}
})
->
order
(
'id'
,
'desc'
)
->
paginate
();
return
$this
->
fetch
(
''
,
compact
(
'list'
));
}
/**
* excel关联会员
* @return \think\response\Json
* @throws \PHPExcel_Exception
*/
public
function
excel
()
{
try
{
Db
::
startTrans
();
$model
=
new
VipRelationModel
();
$file
=
request
()
->
file
(
'file'
)
->
getInfo
();
//获取导入的数据
$data
=
Excel
::
excelFileToArray
(
$file
[
'tmp_name'
],
pathinfo
(
$file
[
'name'
],
PATHINFO_EXTENSION
));
...
...
@@ -32,15 +46,17 @@ class VipRelation extends AuthBase
'nickname'
=>
$v
[
0
],
'mobile'
=>
$v
[
1
],
'wx_number'
=>
$v
[
2
],
'vip_expire'
=>
str_replace
(
'_'
,
'/'
,
$v
[
3
])
,
'vip_expire'
=>
$v
[
3
]
,
'address'
=>
$v
[
4
],
];
$model
->
relationVip
(
$arr
);
array_push
(
$params
,
$arr
);
}
$model
=
new
VipRelationModel
();
$model
->
saveAll
(
$params
);
Db
::
commit
();
return
json
([
'code'
=>
0
,
'msg'
=>
'导入成功'
]);
}
catch
(
Exception
$e
)
{
Db
::
rollback
();
return
json
([
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()]);
}
}
...
...
application/admin/view/project/index.html
View file @
bd90acb0
...
...
@@ -32,7 +32,7 @@
}
</style>
<section
class=
"wrapper"
>
<h3><i
class=
"fa fa-angle-right"
></i>
活动商家列表
</h3>
<h3
style=
"margin-top: 15px"
><i
class=
"fa fa-angle-right"
></i>
活动商家列表
</h3>
<!-- 分割线 -->
<hr>
...
...
@@ -97,6 +97,7 @@
<th>
活动/商家信息
</th>
<th>
状态
</th>
<th>
推荐置顶
</th>
<th>
转让专区
</th>
<th>
排序
</th>
<th>
操作
</th>
</tr>
...
...
@@ -158,12 +159,18 @@
</td>
<td>
{$vo.sign_endtime_str}
</td>
<td>
<div
data-id=
"{$vo.id}"
class=
"switch"
checked
data-on-label=
"开启"
data-off-label=
"关闭"
<div
data-id=
"{$vo.id}"
class=
"switch
heat
"
checked
data-on-label=
"开启"
data-off-label=
"关闭"
data-off=
"success"
>
<input
type=
"checkbox"
name=
"heat"
{$
vo
.
heat
?
'
checked
'
:
''
;}
/>
</div>
</td>
<td>
<div
data-id=
"{$vo.id}"
class=
"switch transfer"
checked
data-on-label=
"开启"
data-off-label=
"关闭"
data-off=
"success"
>
<input
type=
"checkbox"
name=
"is_transfer"
{$
vo
.
is_transfer
?
'
checked
'
:
''
;}
/>
</div>
</td>
<td>
<input
type=
"number"
size=
"4"
style=
"width:50px"
onchange=
"setSort(this.value,{$vo.id})"
value=
"{$vo.sort}"
>
</td>
...
...
@@ -189,7 +196,7 @@
</section>
<script
type=
"text/javascript"
>
$
(
'.
switch
'
).
on
(
'switch-change'
,
function
(
e
,
data
)
{
$
(
'.
heat
'
).
on
(
'switch-change'
,
function
(
e
,
data
)
{
var
heat
=
data
.
value
?
1
:
0
;
var
id
=
$
(
this
).
attr
(
'data-id'
);
$
.
post
(
"{:url('setHeat')}"
,
{
id
:
id
,
heat
:
heat
},
function
(
res
)
{
...
...
@@ -197,6 +204,14 @@
});
});
$
(
'.transfer'
).
on
(
'switch-change'
,
function
(
e
,
data
)
{
var
is_transfer
=
data
.
value
?
1
:
0
;
var
id
=
$
(
this
).
attr
(
'data-id'
);
$
.
post
(
"{:url('setTransfer')}"
,
{
id
:
id
,
is_transfer
:
is_transfer
},
function
(
res
)
{
location
.
reload
();
});
});
//设置排序
function
setSort
(
sort
,
id
)
{
$
.
post
(
"{:url('setSort')}"
,
{
id
:
id
,
sort
:
sort
},
function
()
{
...
...
application/admin/view/public/sidebar.html
View file @
bd90acb0
...
...
@@ -14,7 +14,7 @@
</a>
</li>
<li
class=
"sub-menu"
>
<a
<?
php
if
(
in_array
(
CONTROLLER_NAME
,
array
('
User
'))){
echo
'
class=
"active"
';}?
>
href="javascript:void(0);" >
<a
<?
php
if
(
in_array
(
CONTROLLER_NAME
,
array
('
User
'
,'
VipRelation
'
))){
echo
'
class=
"active"
';}?
>
href="javascript:void(0);" >
<i
class=
"fa fa-user"
></i>
<span>
用户管理
</span>
</a>
...
...
@@ -22,6 +22,9 @@
<li
<?
php
if
(
CONTROLLER_NAME =
=
'
User
'&&
ACTION_NAME=
='index'){echo
'
class=
"active"
';}?
>
>
<a
href=
"<?php echo url("
@
admin
/
User
/
index
")?
>
">用户列表
</a>
</li>
<li
<?
php
if
(
CONTROLLER_NAME =
=
'
VipRelation
'&&
ACTION_NAME=
='index'){echo
'
class=
"active"
';}?
>
>
<a
href=
"<?php echo url("
admin
/
VipRelation
/
index
")?
>
">关联会员
</a>
</li>
</ul>
</li>
<li
class=
"sub-menu"
>
...
...
application/admin/view/vip_relation/index.html
View file @
bd90acb0
{layout name="public/layout_main"}
<link
rel=
"stylesheet"
href=
"/static/layui/css/layui.css"
>
<section
class=
"wrapper"
>
<h3
style=
"margin-top: 15px;"
><i
class=
"fa fa-angle-right"
></i>
用户管理
</h3>
<h3
style=
"margin-top: 15px;"
><i
class=
"fa fa-angle-right"
></i>
关联会员
</h3>
<!-- 分割线 -->
<hr>
<div
class=
"row margin-bottom"
>
<div
class=
"col-md-12"
>
<!--<form class="form-inline pull-left" method="GET" action="{:url('admin/user/index')}" >-->
<!--<div class="form-group margin-right">-->
<!--<input class="form-control" type="text" name="phone" id="phone" value="{:input('phone')}" placeholder="手机号"/>-->
<!--</div>-->
<!--<div class="form-group margin-right">-->
<!--<input class="form-control" type="text" name="nickname" id="nickname" value="{:input('nickname')}" placeholder="昵称"/>-->
<!--</div>-->
<!--<div class="form-group margin-right">-->
<!--<select name="is_vip" id="is_vip" class="form-control">-->
<!--<option value="">是否会员</option>-->
<!--<option value="1" {if condition="input('is_vip')==1"}selected{/if}>会员</option>-->
<!--<option value="0" {if condition="input('is_vip')==='0'"}selected{/if}>非会员</option>-->
<!--</select>-->
<!--</div>-->
<!--<div class="form-group margin-right">-->
<!--<label for="">注册时间:</label>-->
<!--<input class="form-control" type="date" name="start_time" id="start_time" value="{:input('start_time')}" placeholder="起始"/>-->
<!------>
<!--<input class="form-control" type="date" name="end_time" id="end_time" value="{:input('end_time')}" placeholder="结束"/>-->
<!--</div>-->
<!--<button type="submit" class="btn btn-primary">搜索</button>-->
<!--</form>-->
<form
class=
"form-inline pull-left"
method=
"GET"
action=
""
>
<div
class=
"form-group margin-right"
>
<input
class=
"form-control"
type=
"text"
name=
"mobile"
value=
"{:input('mobile')}"
placeholder=
"手机号"
/>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
搜索
</button>
</form>
<button
type=
"button"
class=
"layui-btn pull-right"
id=
"excel"
><i
class=
"layui-icon"
>
</i>
导入会员列表
</button>
</div>
</div>
...
...
@@ -84,7 +68,10 @@
,
url
:
"{:url('excel')}"
,
accept
:
'file'
//普通文件
,
done
:
function
(
res
){
console
.
log
(
res
)
layer
.
msg
(
res
.
msg
);
if
(
res
.
code
===
0
){
location
.
reload
();
}
}
});
});
...
...
application/api/controller/Project.php
View file @
bd90acb0
...
...
@@ -67,30 +67,35 @@ class Project extends Base
}
}
$project
=
ProjectModel
::
all
(
function
(
$query
)
use
(
$map
,
$p
,
$page
)
{
$query
->
where
(
$map
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
if
(
input
(
'sort'
)
==
'id'
)
{
$query
->
order
(
'id'
,
'desc'
);
}
elseif
(
input
(
'price'
)
==
'price'
)
{
$query
->
order
(
'price'
);
}
else
{
$query
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
);
}
})
->
order
(
'sort'
,
'desc'
)
->
page
(
$p
,
$page
);
});
$query
->
where
(
$map
)
->
where
(
'is_transfer'
,
input
(
'is_transfer'
,
0
));
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
// if (input('sort') == 'id') {
// $query->order('id', 'desc');
// } elseif (input('price') == 'price') {
// $query->order('price');
// } else {
// $query->order('sort', 'desc')->order('id', 'desc');
// }
//排序
if
(
input
(
'order'
,
'default'
)
===
'default'
)
{
$query
->
order
(
'sort'
,
'desc'
);
}
elseif
(
input
(
'order'
,
'default'
)
===
'new'
)
{
$query
->
order
(
'id'
,
'desc'
);
}
elseif
(
input
(
'order'
,
'default'
)
===
'price'
)
{
$query
->
order
(
'price'
,
'asc'
);
}
$query
->
page
(
$p
,
$page
);
});
$project
=
$project
?
collection
(
$project
)
->
visible
([
'id'
,
'title'
,
'poster'
,
'sign_limits'
,
'night_num'
,
'tags'
,
'price'
,
'vip_price'
,
'type'
,
'location'
,
'latitude'
,
'longitude'
])
->
append
([
'sign_endtime_str'
])
->
toArray
()
:
[];
if
(
!
$project
)
return
[
'code'
=>
1
,
'msg'
=>
'没有更多'
];
return
[
'code'
=>
0
,
'msg'
=>
'success'
,
'data'
=>
$project
];
...
...
@@ -106,6 +111,19 @@ class Project extends Base
//最新活动-只显示3个
$newProjects
=
ProjectModel
::
all
(
function
(
$query
)
{
$query
->
where
(
'type'
,
1
)
->
where
(
'is_transfer'
,
0
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
limit
(
6
);
...
...
@@ -115,6 +133,19 @@ class Project extends Base
//爆款专区-只显示3个
$heatProjects
=
ProjectModel
::
all
(
function
(
$query
)
{
$query
->
where
(
'type'
,
2
)
->
where
(
'is_transfer'
,
0
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
where
(
'heat'
,
'neq'
,
0
)
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
...
...
@@ -126,6 +157,19 @@ class Project extends Base
$businessProjects
=
ProjectModel
::
all
(
function
(
$query
)
{
$query
->
where
(
'catalog_id'
,
5
)
->
where
(
'type'
,
2
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
where
(
'is_transfer'
,
0
)
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
limit
(
8
);
...
...
@@ -159,6 +203,19 @@ class Project extends Base
if
(
$type
==
1
)
{
$newProjects
=
ProjectModel
::
all
(
function
(
$query
)
use
(
$p
,
$page
)
{
$query
->
where
(
'type'
,
1
)
->
where
(
'is_transfer'
,
0
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
page
(
$p
,
$page
);
...
...
@@ -166,6 +223,19 @@ class Project extends Base
}
elseif
(
$type
==
2
)
{
$newProjects
=
ProjectModel
::
all
(
function
(
$query
)
use
(
$p
,
$page
)
{
$query
->
where
(
'type'
,
2
)
->
where
(
'is_transfer'
,
0
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
where
(
'heat'
,
'neq'
,
0
)
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
...
...
@@ -212,6 +282,19 @@ class Project extends Base
$businessProjects
=
ProjectModel
::
all
(
function
(
$query
)
use
(
$p
,
$page
)
{
$query
->
where
(
'catalog_id'
,
5
)
->
where
(
'type'
,
2
)
->
where
(
function
(
$query
)
{
//地域
if
(
input
(
'level_1'
))
{
$query
->
where
(
'level_1'
,
input
(
'level_1'
));
}
if
(
input
(
'level_2'
))
{
$query
->
where
(
'level_2'
,
input
(
'level_2'
));
}
if
(
input
(
'level_3'
))
{
$query
->
where
(
'level_3'
,
input
(
'level_3'
));
}
})
->
where
(
'is_transfer'
,
0
)
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
page
(
$p
,
$page
);
...
...
@@ -231,8 +314,8 @@ class Project extends Base
public
function
guides
(
$p
=
1
,
$page
=
8
)
{
$guides
=
GuideModel
::
all
(
function
(
$query
)
use
(
$p
,
$page
)
{
if
(
input
(
'title'
))
{
$query
->
where
(
'title'
,
'like'
,
'%'
.
input
(
'title'
)
.
'%'
);
if
(
input
(
'title'
))
{
$query
->
where
(
'title'
,
'like'
,
'%'
.
input
(
'title'
)
.
'%'
);
}
$query
->
order
(
'sort'
,
'desc'
)
->
order
(
'id'
,
'desc'
)
->
page
(
$p
,
$page
);
...
...
@@ -248,7 +331,7 @@ class Project extends Base
* @param int pid 活动/商家id
* @return json
*/
public
function
collect
(
$pid
=
0
)
public
function
collect
(
$pid
=
0
)
{
if
(
empty
(
$pid
))
return
[
'code'
=>
1
,
'msg'
=>
'缺少参数pid'
];
$uid
=
$this
->
userinfo
[
0
];
...
...
application/api/controller/User.php
View file @
bd90acb0
...
...
@@ -141,6 +141,10 @@ class User extends Base
$hidephone
=
substr_replace
(
$phone
,
'****'
,
3
,
4
);
$user
=
UserModel
::
get
(
$this
->
userinfo
[
0
]);
$onlyPhone
=
UserModel
::
get
([
'id'
=>
[
'neq'
,
$this
->
userinfo
[
0
]],
'phone'
=>
$phone
]);
if
(
$onlyPhone
){
return
[
"code"
=>
1
,
"msg"
=>
"该手机号已注册"
];
}
$user
->
phone
=
$phone
;
$user
->
save
();
...
...
application/common/model/VipRelation.php
View file @
bd90acb0
...
...
@@ -18,4 +18,22 @@ class VipRelation extends BaseModel
$arr
=
[
'未关联'
,
'已关联'
];
return
$arr
[
$data
[
'is_relation'
]];
}
/**
* 检测是否可以关联
* @param $data
* @throws \think\exception\DbException
*/
public
function
relationVip
(
&
$data
)
{
//先查询数据库手机号,如果没有直接略过
$user
=
User
::
get
([
'phone'
=>
$data
[
'mobile'
]]);
if
(
$user
){
//直接把到期时间替换了
$user
->
vip_endtime
=
$data
[
'vip_expire'
];
$user
->
save
();
$data
[
'is_relation'
]
=
1
;
}
}
}
\ No newline at end of file
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