Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
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
wangtao
projecttwo
Commits
1b86245d
Commit
1b86245d
authored
Jun 25, 2025
by
wangtao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
学习资料
parent
44b3818e
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
389 additions
and
146 deletions
+389
-146
Advert.php
app/admin/controller/Advert.php
+1
-1
Cert.php
app/admin/controller/cert/Cert.php
+2
-0
CertOrder.php
app/admin/controller/cert/CertOrder.php
+5
-1
Project.php
app/admin/controller/project/Project.php
+1
-1
Setting.php
app/admin/controller/system/Setting.php
+1
-1
index.html
app/admin/view/cert/cert_order/index.html
+1
-0
index.html
app/admin/view/project/project/index.html
+2
-1
index.html
app/admin/view/users/user_exp_rule/index.html
+2
-2
User.php
app/api/controller/User.php
+83
-66
Wecaht.php
app/api/controller/Wecaht.php
+76
-2
User.php
app/api/controller/mine/User.php
+67
-71
Project.php
app/api/controller/project/Project.php
+2
-0
WeChatLoginService.php
app/api/service/WeChatLoginService.php
+74
-0
UserValidate.php
app/api/validate/UserValidate.php
+4
-0
common.php
app/common.php
+68
-0
No files found.
app/admin/controller/Advert.php
View file @
1b86245d
...
...
@@ -36,7 +36,7 @@ class Advert extends AdminBase
$list
=
$this
->
advert
->
with
([
'coverImg'
])
->
append
([
'advcatename'
])
->
where
(
$map
)
->
paginate
(
$post
[
'limit'
]);
return
$this
->
returnMsg
(
$list
);
}
$categorydata
=
AdvertCate
::
select
()
->
toArray
();
$categorydata
=
AdvertCate
::
where
(
'is_del'
,
0
)
->
select
()
->
toArray
();
$this
->
assign
(
'categorydata'
,
$categorydata
);
$this
->
assign
(
'limit'
,
$limit
);
$this
->
assign
(
'get'
,
input
());
...
...
app/admin/controller/cert/Cert.php
View file @
1b86245d
...
...
@@ -12,6 +12,7 @@ namespace app\admin\controller\cert;
use
app\admin\controller\AdminBase
;
use
app\admin\validate\CertValidate
;
use
app\api\service\UtilService
;
use
app\model\Cert
as
CertModel
;
use
think\App
;
use
think\facade\Db
;
...
...
@@ -102,6 +103,7 @@ class Cert extends AdminBase
$msg
=
'更新成功'
;
$this
->
cert
->
update
(
$post
,
[
'id'
=>
$post
[
'id'
]]);
}
else
{
$post
[
'sn'
]
=
UtilService
::
generateCompactOrderNo
(
0
,
'SMBH'
);
$post
[
'createtime'
]
=
time
();
unset
(
$post
[
'id'
]);
$msg
=
'添加成功'
;
...
...
app/admin/controller/cert/CertOrder.php
View file @
1b86245d
...
...
@@ -44,10 +44,14 @@ class CertOrder extends AdminBase
if
(
isset
(
$post
[
'kw'
])
&&
!
empty
(
$post
[
'kw'
]))
{
$hasmap
[]
=
[
'user.username|user.mobile'
,
'like'
,
'%'
.
$post
[
'kw'
]
.
'%'
];
}
$certmap
=
[];
if
(
isset
(
$post
[
'cert_title'
])
&&
!
empty
(
$post
[
'cert_title'
]))
{
$certmap
[]
=
[
'cert.title'
,
'like'
,
'%'
.
trim
(
$post
[
'cert_title'
])
.
'%'
];
}
if
(
isset
(
$post
[
'status'
])
&&
!
empty
(
$post
[
'status'
]))
{
$map
[]
=
[
'status'
,
'='
,
$post
[
'status'
]];
}
$list
=
$this
->
certorder
->
hasWhere
(
'userprofile'
,
$hasmap
)
->
where
(
$map
)
->
with
([
'certdata'
,
'userprofile'
])
->
append
([
'status_text'
])
->
order
(
'createtime desc'
)
->
paginate
(
$post
[
'limit'
]);
$list
=
$this
->
certorder
->
hasWhere
(
'userprofile'
,
$hasmap
)
->
hasWhere
(
'certdata'
,
$certmap
)
->
where
(
$map
)
->
with
([
'certdata'
,
'userprofile'
])
->
append
([
'status_text'
])
->
order
(
'createtime desc'
)
->
paginate
(
$post
[
'limit'
]);
return
$this
->
returnMsg
(
$list
);
}
...
...
app/admin/controller/project/Project.php
View file @
1b86245d
...
...
@@ -60,7 +60,7 @@ class Project extends AdminBase
if
(
isset
(
$post
[
'user'
])
&&
!
empty
(
$post
[
'user'
]))
{
$hasmap
[]
=
[
'username|mobile'
,
'like'
,
'%'
.
$post
[
'user'
]
.
'%'
];
}
$list
=
$this
->
project
->
where
(
$map
)
->
hasWhere
(
'getuserdata'
,
$hasmap
)
->
with
([
'projectcatedata'
,
'getuserdata'
])
->
append
([
'sh_status_text'
,
'status_text'
])
->
order
(
'createtime desc'
)
->
paginate
(
$post
[
'limit'
]);
$list
=
$this
->
project
->
where
(
$map
)
->
hasWhere
(
'getuserdata'
,
$hasmap
)
->
with
([
'projectcatedata'
,
'getuserdata'
,
'thumb'
])
->
append
([
'sh_status_text'
,
'status_text'
])
->
order
(
'createtime desc'
)
->
paginate
(
$post
[
'limit'
]);
return
$this
->
returnMsg
(
$list
);
}
$category
=
projectCategory
::
field
(
'*,pid as parentid'
)
->
order
(
'sort desc'
)
->
select
()
->
toArray
();
...
...
app/admin/controller/system/Setting.php
View file @
1b86245d
...
...
@@ -181,7 +181,7 @@ class Setting extends AdminBase
{
$d
=
$this
->
only
(
$do
?
[
'@token'
=>
''
,
'id/d/ID参数错误'
,
'av'
,
'af'
]
:
[
'@token'
=>
''
,
'id/d/ID参数错误'
,
$this
->
ptype
,
$this
->
pname
,
$this
->
ptitle
,
$this
->
pgroup
,
$this
->
ptips
,
'value/u'
,
'options/u'
,
'listorder/d'
]);
$id
=
$d
[
'id'
];
if
(
in_array
(
$id
,
[
1
,
2
]))
return
$this
->
returnMsg
(
"系统关键配置项不可修改"
);
//
if(in_array($id, [1,2])) return $this->returnMsg("系统关键配置项不可修改");
$Myobj
=
S
::
one
(
"id =
$id
"
);
if
(
!
$Myobj
)
return
$this
->
returnMsg
(
"数据不存在"
);
if
(
$do
==
'up'
){
...
...
app/admin/view/cert/cert_order/index.html
View file @
1b86245d
...
...
@@ -11,6 +11,7 @@
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
style=
"width:250px;"
><input
type=
"text"
name=
"kw"
placeholder=
"用户名,用户手机号"
autocomplete=
"off"
class=
"layui-input"
lay-affix=
"clear"
/></div>
<div
class=
"layui-inline"
style=
"width:250px;"
><input
type=
"text"
name=
"cert_title"
placeholder=
"证书名称"
autocomplete=
"off"
class=
"layui-input"
lay-affix=
"clear"
/></div>
<div
class=
"layui-inline"
style=
"width:150px;"
>
<select
name=
"status"
>
<option
value=
""
>
审核状态
</option>
...
...
app/admin/view/project/project/index.html
View file @
1b86245d
...
...
@@ -165,7 +165,8 @@
cols
:
[[
{
type
:
'checkbox'
,
fixed
:
'left'
},
{
field
:
'id'
,
width
:
50
,
unresize
:
true
,
align
:
'center'
,
title
:
'ID'
,
sort
:
!
0
},
{
field
:
'sn'
,
align
:
'center'
,
width
:
160
,
title
:
'项目编号'
},
{
field
:
'thumb'
,
width
:
80
,
height
:
80
,
align
:
'center'
,
title
:
'项目图片'
,
templet
:
'<div class="files_itemwproject"><img src="{{d.thumb.fileurl}}" lay-event="project-event-image" /></div>'
},
// {field:'sn',align:'center',width:160,title:'项目编号'},
{
field
:
'username'
,
align
:
'center'
,
width
:
130
,
title
:
'发布者'
,
templet
:
'<div>{{= d.getuserdata.username}}</div>'
},
{
field
:
'title'
,
align
:
'center'
,
width
:
240
,
title
:
'项目名称'
},
{
field
:
'cate_name'
,
width
:
120
,
align
:
'center'
,
title
:
'类别'
,
templet
:
'<div>{{= d.projectcatedata.title}}</div>'
},
...
...
app/admin/view/users/user_exp_rule/index.html
View file @
1b86245d
...
...
@@ -38,8 +38,8 @@
cols
:
[[
{
field
:
'id'
,
width
:
50
,
unresize
:
true
,
align
:
'center'
,
title
:
'ID'
,
sort
:
!
0
},
{
field
:
'event'
,
align
:
'center'
,
width
:
160
,
title
:
'事件名称'
,
edit
:
'text'
,
editTrigger
:
'dblclick'
},
{
field
:
'action'
,
align
:
'center'
,
title
:
'控制器/方法 格式如:user/login'
},
{
field
:
'event'
,
align
:
'center'
,
title
:
'事件名称'
,
edit
:
'text'
,
editTrigger
:
'dblclick'
},
//
{field:'action',align:'center',title:'控制器/方法 格式如:user/login'},
{
field
:
'exp'
,
align
:
'center'
,
width
:
160
,
title
:
'可获经验值'
,
edit
:
'text'
,
editTrigger
:
'dblclick'
},
{
field
:
'daily_limit'
,
align
:
'center'
,
width
:
160
,
title
:
'每日上限'
,
edit
:
'text'
,
editTrigger
:
'dblclick'
},
{
field
:
'interval_limit'
,
align
:
'center'
,
width
:
160
,
title
:
'间隔时间(秒)'
,
edit
:
'text'
,
editTrigger
:
'dblclick'
},
...
...
app/api/controller/User.php
View file @
1b86245d
...
...
@@ -17,60 +17,53 @@ class User extends BaseController
public
function
login
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'password'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'password'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
where
(
'is_del'
,
0
)
->
find
();
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
where
(
'is_del'
,
0
)
->
find
();
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
}
$data
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
if
(
$data
[
'password'
]
!=
$user
[
'password'
])
{
return
$this
->
returnMsg
(
'密码不正确'
,
0
);
$data
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
if
(
$data
[
'password'
]
!=
$user
[
'password'
])
{
return
$this
->
returnMsg
(
'密码不正确'
,
0
);
}
if
(
$user
[
'status'
]
!=
1
)
{
return
$this
->
returnMsg
(
'账号禁止登录'
,
0
);
if
(
$user
[
'status'
]
!=
1
)
{
return
$this
->
returnMsg
(
'账号禁止登录'
,
0
);
}
$token
=
TokenService
::
generateToken
(
$user
[
'id'
],
$user
->
toArray
());
$token
=
TokenService
::
generateToken
(
$user
[
'id'
],
$user
->
toArray
());
$update
[
'token'
]
=
$token
;
$update
[
'last_login_time'
]
=
time
();
userModel
::
where
([
'id'
=>
$user
[
'id'
]])
->
update
(
$update
);
userModel
::
where
([
'id'
=>
$user
[
'id'
]])
->
update
(
$update
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
[
'token'
=>
$token
,
'expires_in'
=>
TokenService
::
EXPIRE
]);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
[
'token'
=>
$token
,
'expires_in'
=>
TokenService
::
EXPIRE
]);
}
public
function
register
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'name'
,
'mobile'
,
'password'
,
'code'
,
'role
'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'name'
,
'mobile'
,
'password'
,
'code'
,
'role'
,
'password2
'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$is_exit
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
where
(
'is_del'
,
0
)
->
count
();
if
(
$is_exit
)
{
return
$this
->
returnMsg
(
'用户已存在'
,
0
);
$is_exit
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
where
(
'is_del'
,
0
)
->
count
();
if
(
$is_exit
)
{
return
$this
->
returnMsg
(
'用户已存在'
,
0
);
}
//只有普通用户验证验证码
if
(
$data
[
'role'
]
==
1
)
{
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'mobile'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
if
(
$data
[
'role'
]
==
1
)
{
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'mobile'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
return
$this
->
returnMsg
(
'验证码错误'
);
}
}
...
...
@@ -79,83 +72,110 @@ class User extends BaseController
$user
[
'username'
]
=
$data
[
'name'
];
$user
[
'mobile'
]
=
$data
[
'mobile'
];
$user
[
'salt'
]
=
random
(
4
);
$user
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
$user
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
$user
[
'reg_time'
]
=
time
();
$user
[
'create_time'
]
=
time
();
$user
[
'role'
]
=
$data
[
'role'
]
??
1
;
$user
[
'headico'
]
=
vconfig
(
'default_user'
)
??
null
;
$res
=
userModel
::
insert
(
$user
);
if
(
!
$res
)
{
return
$this
->
returnMsg
(
'注册失败'
,
0
);
if
(
!
$res
)
{
return
$this
->
returnMsg
(
'注册失败'
,
0
);
}
return
$this
->
returnMsg
(
'注册成功'
,
1
);
return
$this
->
returnMsg
(
'注册成功'
,
1
);
}
//微信登录成功绑定手机号
public
function
bindmobile
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'user_id'
,
'name'
,
'mobile'
,
'password'
,
'code'
,
'password2'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$is_exit
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
where
(
'is_del'
,
0
)
->
count
();
if
(
$is_exit
)
{
return
$this
->
returnMsg
(
'手机号已存在'
);
}
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'mobile'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
// return $this->returnMsg('验证码错误');
}
$user
[
'username'
]
=
$data
[
'name'
];
$user
[
'mobile'
]
=
$data
[
'mobile'
];
$user
[
'salt'
]
=
random
(
4
);
$user
[
'reg_time'
]
=
time
();
$user
[
'create_time'
]
=
time
();
$user
[
'is_del'
]
=
0
;
$user
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
$user
[
'last_login_time'
]
=
time
();
$token
=
TokenService
::
generateToken
(
$data
[
'user_id'
],
$user
);
$user
[
'token'
]
=
$token
;
userModel
::
where
(
'id'
,
$data
[
'user_id'
])
->
update
(
$user
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
[
'token'
=>
$token
,
'expires_in'
=>
TokenService
::
EXPIRE
]);
}
public
function
restUserPasswordStep1
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'str'
,
'code'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'str'
,
'code'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'str'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'str'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
return
$this
->
returnMsg
(
'验证码错误'
);
}
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'str'
]])
->
whereOr
([
'username'
=>
$data
[
'str'
]])
->
find
();
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'str'
]])
->
whereOr
([
'username'
=>
$data
[
'str'
]])
->
find
();
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
}
// 生成重置令牌并设置过期时间(如10分钟)
$resetToken
=
md5
(
uniqid
()
.
$user
[
'id'
]
.
time
());
cache
(
'reset_token_'
.
$user
[
'id'
],
$resetToken
,
600
);
// 10分钟有效期
$resetToken
=
md5
(
uniqid
()
.
$user
[
'id'
]
.
time
());
cache
(
'reset_token_'
.
$user
[
'id'
],
$resetToken
,
600
);
// 10分钟有效期
//sms
return
$this
->
returnMsg
(
'success'
,
1
,
[
'reset_token'
=>
$resetToken
]);
return
$this
->
returnMsg
(
'success'
,
1
,
[
'reset_token'
=>
$resetToken
]);
}
public
function
restUserPasswordStep2
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'str'
,
'confirm_password'
,
'password'
,
'reset_token'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'str'
,
'confirm_password'
,
'password'
,
'reset_token'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'str'
]])
->
whereOr
([
'username'
=>
$data
[
'str'
]])
->
find
();
$user
=
userModel
::
where
([
'mobile'
=>
$data
[
'str'
]])
->
whereOr
([
'username'
=>
$data
[
'str'
]])
->
find
();
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
}
// 验证重置令牌
$storedToken
=
cache
(
'reset_token_'
.
$user
[
'id'
]);
$storedToken
=
cache
(
'reset_token_'
.
$user
[
'id'
]);
if
(
!
$storedToken
||
$storedToken
!==
$data
[
'reset_token'
])
{
return
$this
->
returnMsg
(
'无效的重置令牌或已过期'
,
0
);
}
$update
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
userModel
::
where
([
'id'
=>
$user
[
'id'
]])
->
update
(
$update
);
$update
[
'password'
]
=
md5
(
$data
[
'password'
]
.
$user
[
'salt'
]);
userModel
::
where
([
'id'
=>
$user
[
'id'
]])
->
update
(
$update
);
// 清除重置令牌
cache
(
'reset_token_'
.
$user
[
'id'
],
null
);
cache
(
'reset_token_'
.
$user
[
'id'
],
null
);
//销毁token
TokenService
::
deleteToken
(
$user
[
'token'
]);
return
$this
->
returnMsg
(
'success'
,
1
);
return
$this
->
returnMsg
(
'success'
,
1
);
}
...
...
@@ -163,13 +183,13 @@ class User extends BaseController
{
try
{
// 验证参数
(
new
UserValidate
())
->
goCheck
([
'str'
,
'code'
]);
(
new
UserValidate
())
->
goCheck
([
'str'
,
'code'
]);
}
catch
(
ValidateException
$e
)
{
return
$this
->
returnMsg
(
$e
->
getError
(),
0
);
return
$this
->
returnMsg
(
$e
->
getError
(),
0
);
}
catch
(
\Exception
$e
)
{
return
json
([
'code'
=>
500
,
'msg'
=>
'系统错误'
,
'msg'
=>
'系统错误'
,
'data'
=>
null
],
500
);
}
...
...
@@ -182,19 +202,18 @@ class User extends BaseController
*/
public
function
checkSmsCode
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'code'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'code'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'mobile'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
$checkSmsCode
=
UtilService
::
checkSmsCode
(
$data
[
'mobile'
],
$data
[
'code'
]);
if
(
!
$checkSmsCode
)
{
return
$this
->
returnMsg
(
'验证码错误'
);
}
return
$this
->
returnMsg
(
'success'
,
1
);
return
$this
->
returnMsg
(
'success'
,
1
);
}
...
...
@@ -207,12 +226,11 @@ class User extends BaseController
$data
=
$request
->
param
();
$count
=
userModel
::
where
([
'mobile'
=>
$data
[
'mobile'
]])
->
count
();
if
(
$count
>
0
)
{
if
(
$count
>
0
)
{
return
$this
->
returnMsg
(
'手机号已存在'
);
}
return
$this
->
returnMsg
(
'success'
,
1
);
return
$this
->
returnMsg
(
'success'
,
1
);
}
...
...
@@ -222,11 +240,10 @@ class User extends BaseController
$type
=
$request
->
param
(
'type'
,
'all'
);
$list
=
UserService
::
rankUserExperience
(
$limit
,
$type
);
$list
=
UserService
::
rankUserExperience
(
$limit
,
$type
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
}
\ No newline at end of file
app/api/controller/Wecaht.php
View file @
1b86245d
...
...
@@ -2,10 +2,17 @@
namespace
app\api\controller
;
use
app\api\service\TokenService
;
use
app\model\project\User
as
userModel
;
use
think\facade\Log
;
use
think\Request
;
use
app\api\validate\ArticleValidate
;
use
app\BaseController
;
use
app\model\ArticleModel
;
use
app\api\service\WeChatLoginService
;
use
think\facade\Cache
;
use
app\model\project\User
;
class
Wecaht
extends
BaseController
{
...
...
@@ -13,9 +20,36 @@ class Wecaht extends BaseController
public
function
index
()
{
$get
=
input
();
exit
(
$get
[
'echostr'
]);
$body
=
file_get_contents
(
'php://input'
);
$simpleXml
=
simplexml_load_string
(
$body
,
'SimpleXMLElement'
,
LIBXML_NOCDATA
);
$json
=
json_encode
(
$simpleXml
);
$array
=
json_decode
(
$json
,
true
);
// true表示转为关联数组
Log
::
write
(
'微信登录事件'
);
Log
::
write
(
$array
);
if
(
$array
[
'Event'
]
==
'SCAN'
||
$array
[
'Event'
]
==
'subscribe'
)
{
$EventKey
=
$array
[
'EventKey'
];
if
(
$array
[
'Event'
]
==
'subscribe'
)
{
$EventKeys
=
explode
(
'_'
,
$array
[
'EventKey'
]);
$EventKey
=
$EventKeys
[
1
]
.
'_'
.
$EventKeys
[
2
];
}
$cachekey
=
Cache
::
get
(
$EventKey
);
if
(
$cachekey
==
$array
[
'Ticket'
])
{
$openid
=
$array
[
'FromUserName'
];
Log
::
write
(
'扫描成功'
);
Cache
::
set
(
$EventKey
,
$openid
,
1000
);
$user
=
User
::
where
(
'wx_openid'
,
$openid
)
->
find
();
if
(
empty
(
$user
))
{
$user
[
'wx_openid'
]
=
$openid
;
$user
[
'is_del'
]
=
1
;
$user
[
'create_time'
]
=
time
();
$user
[
'headico'
]
=
vconfig
(
'default_user'
)
??
null
;
userModel
::
insert
(
$user
);
}
}
}
// // 配置 Token(需与微信公众号后台设置一致)
// define("WX_TOKEN", "YOUR_TOKEN_HERE");
// // 处理微信服务器发送的 GET 验证请求
...
...
@@ -66,4 +100,44 @@ class Wecaht extends BaseController
}
}
//检车微信openid是否登录 2秒轮询
public
function
checkwxlogin
()
{
$param
=
$this
->
request
->
post
();
$cachekey
=
$param
[
'cachekey'
];
$openid
=
Cache
::
get
(
$cachekey
);
$user
=
User
::
where
(
'wx_openid'
,
$openid
)
->
find
();
if
(
isset
(
$user
[
'id'
])
&&
empty
(
$user
[
'mobile'
]))
{
$redata
=
[
'token'
=>
''
,
'expires_in'
=>
0
,
'user_id'
=>
$user
[
'id'
],
'is_mobile'
=>
0
];
}
elseif
(
$user
)
{
if
(
$user
[
'status'
]
!=
1
)
{
return
$this
->
returnMsg
(
'账号禁止登录'
,
0
);
}
if
(
$user
[
'is_del'
]
!=
0
)
{
return
$this
->
returnMsg
(
'账号已删除'
,
0
);
}
$token
=
TokenService
::
generateToken
(
$user
[
'id'
],
$user
->
toArray
());
$update
[
'token'
]
=
$token
;
$update
[
'last_login_time'
]
=
time
();
User
::
where
([
'id'
=>
$user
[
'id'
]])
->
update
(
$update
);
$redata
=
[
'token'
=>
$token
,
'expires_in'
=>
TokenService
::
EXPIRE
,
'user_id'
=>
$user
[
'id'
],
'is_mobile'
=>
1
];
}
else
{
return
$this
->
returnMsg
(
"登录失败,请重新扫码"
,
0
);
}
return
$this
->
returnMsg
(
"success"
,
1
,
$redata
);
}
//生成二维码
public
function
createwxewm
()
{
try
{
$data
=
WeChatLoginService
::
createerwm
();
}
catch
(
\Exception
$e
)
{
return
$this
->
returnMsg
(
$e
->
getMessage
());
}
return
$this
->
returnMsg
(
"success"
,
1
,
$data
);
}
}
\ No newline at end of file
app/api/controller/mine/User.php
View file @
1b86245d
...
...
@@ -20,6 +20,7 @@ use app\model\project\UserSmrz;
use
app\model\project\UserWithdrawal
;
use
app\Request
;
use
app\model\project\User
as
UserModel
;
use
think\facade\Db
;
class
User
extends
BaseController
{
...
...
@@ -37,26 +38,31 @@ class User extends BaseController
$data
=
$request
->
header
();
$user
=
UserService
::
getUserInfo
(
$data
[
'token'
]);
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'token无效'
,
0
);
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'token无效'
,
0
);
}
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$user
);
$info_status
=
''
;
if
(
$user
[
'role'
]
==
2
)
{
$info_status
=
Db
::
name
(
'business'
)
->
where
(
'user_id'
,
$user
[
'id'
])
->
value
(
'status'
);
}
elseif
(
$user
[
'role'
]
==
3
)
{
$info_status
=
Db
::
name
(
'school'
)
->
where
(
'user_id'
,
$user
[
'id'
])
->
value
(
'status'
);
}
$user
[
'info_status'
]
=
$info_status
;
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$user
);
}
public
function
updateUserInfo
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'updateField'
,
'updateValue'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'updateField'
,
'updateValue'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$data
=
$request
->
param
();
$res
=
UserService
::
updateUserInfo
(
$data
[
'updateField'
],
$data
[
'updateValue'
]);
$res
=
UserService
::
updateUserInfo
(
$data
[
'updateField'
],
$data
[
'updateValue'
]);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
}
public
function
bindZfb
(
Request
$request
)
...
...
@@ -66,8 +72,7 @@ class User extends BaseController
return
$vo
;
}
if
(
UserAccount
::
where
([
'user_id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
count
())
{
if
(
UserAccount
::
where
([
'user_id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
count
())
{
return
$this
->
returnMsg
(
'请勿重复提交'
);
}
...
...
@@ -80,13 +85,13 @@ class User extends BaseController
$res
=
UserAccount
::
create
(
$data
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
}
public
function
editMobile
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'code'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'mobile'
,
'code'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
...
...
@@ -95,20 +100,19 @@ class User extends BaseController
//check sms
$res
=
UserService
::
updateUserInfo
(
'mobile'
,
$data
[
'mobile'
]);
$res
=
UserService
::
updateUserInfo
(
'mobile'
,
$data
[
'mobile'
]);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
}
public
function
realUser
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'realname'
,
'idcard'
,
'idcard_q'
,
'idcard_h'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'realname'
,
'idcard'
,
'idcard_q'
,
'idcard_h'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
if
(
UserSmrz
::
where
([
'user_id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
count
())
{
if
(
UserSmrz
::
where
([
'user_id'
=>
$request
->
userId
,
'is_del'
=>
0
])
->
count
())
{
return
$this
->
returnMsg
(
'请勿重复提交'
);
}
...
...
@@ -118,13 +122,13 @@ class User extends BaseController
$res
=
UserSmrz
::
create
(
$data
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$res
);
}
public
function
withdrawal
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'amount'
,
'txType'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'amount'
,
'txType'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
...
...
@@ -132,45 +136,41 @@ class User extends BaseController
$userId
=
$request
->
userId
;
$userInfo
=
UserModel
::
where
([
'id'
=>
$userId
,
'is_del'
=>
0
])
->
find
();
if
(
$userInfo
[
'money'
]
<
$data
[
'amount'
])
{
$userInfo
=
UserModel
::
where
([
'id'
=>
$userId
,
'is_del'
=>
0
])
->
find
();
if
(
$userInfo
[
'money'
]
<
$data
[
'amount'
])
{
return
$this
->
returnMsg
(
'余额不足'
);
}
$count
=
UserMoneyLog
::
where
([
'user_id'
=>
$userId
,
'type'
=>
1
])
$count
=
UserMoneyLog
::
where
([
'user_id'
=>
$userId
,
'type'
=>
1
])
->
whereBetween
(
'createtime'
,
[
strtotime
(
'today'
),
strtotime
(
'tomorrow'
)
-
1
])
->
count
();
if
(
$count
)
{
if
(
$count
)
{
return
$this
->
returnMsg
(
'每天只能提现一次'
);
}
$UserWithdrawalModel
=
new
UserWithdrawal
();
$sum
=
$UserWithdrawalModel
->
where
([
'user_id'
=>
$userId
])
$sum
=
$UserWithdrawalModel
->
where
([
'user_id'
=>
$userId
])
->
whereBetween
(
'createtime'
,
[
strtotime
(
'today'
),
strtotime
(
'tomorrow'
)
-
1
])
->
sum
(
'tx_money'
);
if
(
$sum
>
10000
)
{
if
(
$sum
>
10000
)
{
return
$this
->
returnMsg
(
'超出每日限额'
);
}
$userAccount
=
UserAccount
::
where
([
'user_id'
=>
$userId
,
'is_del'
=>
0
,
'type'
=>
$data
[
'txType'
]])
->
find
();
$userAccount
=
UserAccount
::
where
([
'user_id'
=>
$userId
,
'is_del'
=>
0
,
'type'
=>
$data
[
'txType'
]])
->
find
();
$commission
=
vconfig
(
'commission'
)
?
:
0
;
$commission
=
vconfig
(
'commission'
)
?:
0
;
// halt($commission);
$res
=
$UserWithdrawalModel
->
applyWithdrawal
(
$userId
,
$data
[
'amount'
],
$data
[
'txType'
],
$userAccount
[
'account'
],
$userInfo
[
'realname'
],
$commission
,
$userInfo
[
'money'
]);
$res
=
$UserWithdrawalModel
->
applyWithdrawal
(
$userId
,
$data
[
'amount'
],
$data
[
'txType'
],
$userAccount
[
'account'
],
$userInfo
[
'realname'
],
$commission
,
$userInfo
[
'money'
]);
if
(
!
$res
[
'status'
])
{
if
(
!
$res
[
'status'
])
{
return
$this
->
returnMsg
(
$res
[
'msg'
]);
}
return
$this
->
returnMsg
(
'success'
,
1
);
return
$this
->
returnMsg
(
'success'
,
1
);
}
...
...
@@ -180,13 +180,13 @@ class User extends BaseController
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$list
=
Mail
::
order
(
'createtime'
,
'desc'
)
$list
=
Mail
::
order
(
'createtime'
,
'desc'
)
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
public
function
buyCourse
(
\think\Request
$request
)
...
...
@@ -210,8 +210,7 @@ class User extends BaseController
if
(
!
$course
)
{
return
$this
->
returnMsg
(
'课程不存在'
);
}
if
(
$course
[
'price'
]
<=
0
)
{
if
(
$course
[
'price'
]
<=
0
)
{
return
$this
->
returnMsg
(
'免费课程无需购买'
);
}
...
...
@@ -220,11 +219,11 @@ class User extends BaseController
return
$this
->
returnMsg
(
'请勿重复购买'
);
}
$params
=
[
'order_id'
=>
$data
[
'course_id'
],
'order_type'
=>
1
,
'pay_method'
=>
$data
[
'pay_method'
],
'amount'
=>
$course
[
'price'
],
'user_id'
=>
$userId
,
'order_id'
=>
$data
[
'course_id'
],
'order_type'
=>
1
,
'pay_method'
=>
$data
[
'pay_method'
],
'amount'
=>
$course
[
'price'
],
'user_id'
=>
$userId
,
];
$payController
=
new
PayController
();
...
...
@@ -259,9 +258,8 @@ class User extends BaseController
// return $this->returnMsg('免费证书无需购买');
// }
$courseOrder
=
CertOrder
::
where
([
'status'
=>
0
,
'user_id'
=>
$userId
,
'cert_id'
=>
$course
[
'id'
]])
->
count
();
if
(
!
$courseOrder
)
{
$courseOrder
=
CertOrder
::
where
([
'status'
=>
0
,
'user_id'
=>
$userId
,
'cert_id'
=>
$course
[
'id'
]])
->
count
();
if
(
!
$courseOrder
)
{
return
$this
->
returnMsg
(
'请先报名'
);
}
...
...
@@ -270,11 +268,11 @@ class User extends BaseController
return
$this
->
returnMsg
(
'请勿重复购买'
);
}
$params
=
[
'order_id'
=>
$data
[
'cert_id'
],
'order_type'
=>
2
,
'pay_method'
=>
$data
[
'pay_method'
],
'amount'
=>
$course
[
'price'
],
'user_id'
=>
$userId
,
'order_id'
=>
$data
[
'cert_id'
],
'order_type'
=>
2
,
'pay_method'
=>
$data
[
'pay_method'
],
'amount'
=>
$course
[
'price'
],
'user_id'
=>
$userId
,
];
$payController
=
new
PayController
();
...
...
@@ -285,7 +283,7 @@ class User extends BaseController
public
function
editPassword
(
Request
$request
)
{
$vo
=
(
new
UserValidate
())
->
goCheck
([
'confirm_password'
,
'password'
,
'old_password'
]);
$vo
=
(
new
UserValidate
())
->
goCheck
([
'confirm_password'
,
'password'
,
'old_password'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
...
...
@@ -293,22 +291,20 @@ class User extends BaseController
$userId
=
$request
->
userId
;
$user
=
userModel
::
where
(
'id'
,
$userId
)
->
find
();
$user
=
userModel
::
where
(
'id'
,
$userId
)
->
find
();
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
if
(
!
$user
)
{
return
$this
->
returnMsg
(
'用户不存在'
,
0
);
}
$data
[
'old_password'
]
=
md5
(
$data
[
'old_password'
]
.
$user
[
'salt'
]);
if
(
$data
[
'old_password'
]
!=
$user
[
'password'
])
{
$data
[
'old_password'
]
=
md5
(
$data
[
'old_password'
]
.
$user
[
'salt'
]);
if
(
$data
[
'old_password'
]
!=
$user
[
'password'
])
{
return
$this
->
returnMsg
(
'密码不正确'
);
}
userModel
::
where
(
'id'
,
$userId
)
->
update
([
'password'
=>
md5
(
$data
[
'password'
]
.
$user
[
'salt'
])]);
userModel
::
where
(
'id'
,
$userId
)
->
update
([
'password'
=>
md5
(
$data
[
'password'
]
.
$user
[
'salt'
])]);
return
$this
->
returnMsg
(
'success'
,
1
);
return
$this
->
returnMsg
(
'success'
,
1
);
}
...
...
@@ -317,22 +313,22 @@ class User extends BaseController
{
$page
=
$request
->
param
(
'page/d'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize/d'
,
10
);
$where
=
[
'p.user_id'
=>
$request
->
userId
];
// 搜索条件
$order_no
=
$request
->
param
(
'order_no'
,
''
);
if
(
$order_no
)
{
$where
[
'p.order_no'
]
=
[
'like'
,
"%
{
$order_no
}
%"
];
}
$pay_no
=
$request
->
param
(
'pay_no'
,
''
);
if
(
$pay_no
)
{
$where
[
'p.pay_no'
]
=
[
'like'
,
"%
{
$pay_no
}
%"
];
}
$keyword
=
$request
->
param
(
'keyword'
,
''
);
$query
=
Payment
::
alias
(
'p'
)
->
where
(
$where
)
->
leftJoin
(
'course c'
,
"p.order_id = c.id AND p.order_type = 1"
)
...
...
@@ -351,7 +347,7 @@ class User extends BaseController
'IF(p.order_type=1, c.title, ce.title) as title'
,
'IF(p.order_type=1, c.price, ce.price) as price'
]);
if
(
$keyword
)
{
$query
=
$query
->
where
(
'c.title|ce.title'
,
'like'
,
"%
{
$keyword
}
%"
);
}
...
...
@@ -361,7 +357,7 @@ class User extends BaseController
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
// foreach ($list as &$item) {
// $item['order_type_text'] = $item['order_type'] == 1 ? '课程' : '证书';
// $item['pay_method_text'] = $item['pay_method'] == 1 ? '支付宝' : '微信';
...
...
app/api/controller/project/Project.php
View file @
1b86245d
...
...
@@ -80,6 +80,8 @@ class Project extends BaseController
[
'user_id'
=>
27
,
'total_money'
=>
2500.0
,
'record_count'
=>
8
,
'user_info'
=>
[
'username'
=>
'Alice'
,
'realname'
=>
'Alice Smith'
,
'headico'
=>
41
,
'id'
=>
2
]],
[
'user_id'
=>
28
,
'total_money'
=>
2000.0
,
'record_count'
=>
7
,
'user_info'
=>
[
'username'
=>
'Bob'
,
'realname'
=>
'Bob Johnson'
,
'headico'
=>
42
,
'id'
=>
3
]],
[
'user_id'
=>
29
,
'total_money'
=>
1800.0
,
'record_count'
=>
6
,
'user_info'
=>
[
'username'
=>
'David'
,
'realname'
=>
'David Lee'
,
'headico'
=>
43
,
'id'
=>
4
]],
[
'user_id'
=>
33
,
'total_money'
=>
1500.0
,
'record_count'
=>
6
,
'user_info'
=>
[
'username'
=>
'张三'
,
'realname'
=>
'张三'
,
'headico'
=>
43
,
'id'
=>
4
]],
[
'user_id'
=>
34
,
'total_money'
=>
1300.0
,
'record_count'
=>
6
,
'user_info'
=>
[
'username'
=>
'李四'
,
'realname'
=>
'李四'
,
'headico'
=>
43
,
'id'
=>
4
]],
];
}
...
...
app/api/service/WeChatLoginService.php
0 → 100644
View file @
1b86245d
<?php
namespace
app\api\service
;
use
think\facade\Cache
;
use
think\facade\Log
;
use
think\Response
;
class
WeChatLoginService
{
// Token前缀
const
TOKEN_PREFIX
=
'wechat_login_token:'
;
// 过期时间(秒)
const
EXPIRE
=
5400
;
// 1.5小时
const
appid
=
"wx24528a99c58e1919"
;
const
appsecret
=
"9ff78ed83a517231754217784eab29a6"
;
//生成access_token
public
static
function
createAccessToken
()
{
$cacheKey
=
self
::
TOKEN_PREFIX
.
self
::
appid
;
$accessToken
=
Cache
::
get
(
$cacheKey
);
if
(
$accessToken
)
{
return
$accessToken
;
}
$appid
=
self
::
appid
;
$appsecret
=
self
::
appsecret
;
$url
=
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=
{
$appid
}
&secret=
{
$appsecret
}
"
;
// 发送HTTP请求
$response
=
http_get
(
$url
);
$data
=
json_decode
(
$response
,
true
);
if
(
isset
(
$data
[
'access_token'
])
&&
$data
[
'access_token'
])
{
// 存入缓存
Cache
::
set
(
$cacheKey
,
$data
[
'access_token'
],
self
::
EXPIRE
);
return
$data
[
'access_token'
];
}
throw
new
\Exception
(
'access_token生成失败001'
);
}
//生成二维码
public
static
function
createerwm
()
{
$accessToken
=
self
::
createAccessToken
();
if
(
!
$accessToken
)
{
throw
new
\Exception
(
'access_token生成失败002'
);
}
$cachekey
=
'wxlogin_'
.
md5
(
self
::
TOKEN_PREFIX
.
uniqid
());
$pram
[
'expire_seconds'
]
=
500
;
$pram
[
'action_name'
]
=
'QR_STR_SCENE'
;
$pram
[
'action_info'
][
'scene'
]
=
array
(
'scene_str'
=>
$cachekey
,
'scene_id'
=>
1000
);
$url
=
"https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token="
.
$accessToken
;
$response
=
http_post
(
$url
,
json_encode
(
$pram
,
true
));
$data
=
json_decode
(
$response
,
true
);
if
(
isset
(
$data
[
'ticket'
])
&&
$data
[
'ticket'
])
{
$ewmurl
=
"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
.
urlencode
(
$data
[
'ticket'
]);
$returndata
[
'cachekey'
]
=
$cachekey
;
$returndata
[
'ewmurl'
]
=
$ewmurl
;
Cache
::
set
(
$cachekey
,
$data
[
'ticket'
],
1000
);
return
$returndata
;
}
throw
new
\Exception
(
'二维码获取失败'
);
}
}
\ No newline at end of file
app/api/validate/UserValidate.php
View file @
1b86245d
...
...
@@ -14,6 +14,7 @@ class UserValidate extends BaseValidate
'token'
=>
'require'
,
'str'
=>
'require'
,
'confirm_password'
=>
'require|checkPasswordEqual'
,
'password2'
=>
'require|checkPasswordEqual'
,
'updateField'
=>
'require|in:username,realname,sex,headico,description,email,qq,wechat'
,
'updateValue'
=>
'require'
,
'zfb'
=>
'require'
,
...
...
@@ -25,9 +26,11 @@ class UserValidate extends BaseValidate
'txType'
=>
'require'
,
'reset_token'
=>
'require'
,
'role'
=>
'require'
,
'user_id'
=>
'require'
,
];
protected
$message
=
[
'user_id.require'
=>
'用户id不能为空'
,
'name.require'
=>
'名称必须'
,
'mobile.require'
=>
'手机号不能为空'
,
'mobile.mobile'
=>
'手机号格式不正确'
,
...
...
@@ -36,6 +39,7 @@ class UserValidate extends BaseValidate
'token.require'
=>
'token必须'
,
'str.require'
=>
'必填项不能为空'
,
'confirm_password.checkPasswordEqual'
=>
'两次输入的密码不一致'
,
'password2.checkPasswordEqual'
=>
'两次输入的密码不一致'
,
'updateField.require'
=>
'必填项不能为空'
,
'updateField.in'
=>
'范围不合法'
,
'amount.require'
=>
'金额不能为空'
,
...
...
app/common.php
View file @
1b86245d
...
...
@@ -610,4 +610,72 @@ function build_bill_no(string $code, string $spr = "-%03d", string $start = "-00
}
else
{
return
'??'
.
date
(
"Ymd"
,
$day
)
.
'001'
;
}
}
/**
* POST 请求
* @param string $url
* @param array $param
* @param boolean $post_file 是否文件上传
* @return string content
*/
function
http_post
(
$url
,
$param
,
$post_file
=
false
)
{
$oCurl
=
curl_init
();
if
(
stripos
(
$url
,
"https://"
)
!==
FALSE
)
{
curl_setopt
(
$oCurl
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$oCurl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$oCurl
,
CURLOPT_SSLVERSION
,
1
);
//CURL_SSLVERSION_TLSv1
}
if
(
is_string
(
$param
)
||
$post_file
)
{
$strPOST
=
$param
;
}
else
{
$aPOST
=
array
();
foreach
(
$param
as
$key
=>
$val
)
{
$aPOST
[]
=
$key
.
"="
.
urlencode
(
$val
);
}
$strPOST
=
join
(
"&"
,
$aPOST
);
}
curl_setopt
(
$oCurl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$oCurl
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$oCurl
,
CURLOPT_POST
,
true
);
curl_setopt
(
$oCurl
,
CURLOPT_POSTFIELDS
,
$strPOST
);
// curl_setopt($oCurl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727);BURNK NT 1.0.1;");
curl_error
(
$oCurl
);
$sContent
=
curl_exec
(
$oCurl
);
$aStatus
=
curl_getinfo
(
$oCurl
);
curl_close
(
$oCurl
);
if
(
intval
(
$aStatus
[
"http_code"
])
==
200
)
{
return
$sContent
;
}
else
{
return
false
;
}
}
/**
* GET 请求
* @param string $url
*/
function
http_get
(
$url
)
{
$oCurl
=
curl_init
();
if
(
stripos
(
$url
,
"https://"
)
!==
FALSE
)
{
curl_setopt
(
$oCurl
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$oCurl
,
CURLOPT_SSL_VERIFYHOST
,
FALSE
);
curl_setopt
(
$oCurl
,
CURLOPT_SSLVERSION
,
1
);
//CURL_SSLVERSION_TLSv1
}
curl_setopt
(
$oCurl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$oCurl
,
CURLOPT_RETURNTRANSFER
,
1
);
$sContent
=
curl_exec
(
$oCurl
);
$aStatus
=
curl_getinfo
(
$oCurl
);
curl_close
(
$oCurl
);
if
(
intval
(
$aStatus
[
"http_code"
])
==
200
)
{
return
$sContent
;
}
else
{
return
false
;
}
}
\ 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