Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
workbiu-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gxx
workbiu-admin
Commits
2fe195f2
Commit
2fe195f2
authored
Oct 09, 2017
by
gxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
系统短信余额插入数据库记录
parent
b42b85c9
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
290 additions
and
116 deletions
+290
-116
SMSServiceContract.php
app/Contracts/SMSServiceContract.php
+3
-0
GroupController.php
app/Http/Controllers/GroupController.php
+0
-3
SMSController.php
app/Http/Controllers/SMSController.php
+12
-31
GroupService.php
app/Services/GroupService.php
+20
-5
SMSService.php
app/Services/SMSService.php
+58
-0
UserService.php
app/Services/UserService.php
+0
-3
FeigeSMS.php
app/Util/FeigeSMS.php
+196
-0
groupinformation.blade.php
resources/views/admin/group/groupinformation.blade.php
+0
-3
update.blade.php
resources/views/admin/group/update.blade.php
+1
-71
No files found.
app/Contracts/SMSServiceContract.php
View file @
2fe195f2
...
@@ -13,4 +13,7 @@ interface SMSServiceContract
...
@@ -13,4 +13,7 @@ interface SMSServiceContract
{
{
public
function
sendSMS
(
$phone
,
$ip
=
""
,
$fingerPrint
=
""
,
$timegap
=
5
);
public
function
sendSMS
(
$phone
,
$ip
=
""
,
$fingerPrint
=
""
,
$timegap
=
5
);
public
function
checkSMS
(
$phone
,
$code
,
$ip
=
""
,
$fingerPrint
=
""
,
$timegap
=
5
);
public
function
checkSMS
(
$phone
,
$code
,
$ip
=
""
,
$fingerPrint
=
""
,
$timegap
=
5
);
public
function
SystemSms
(
$timeType
=
false
,
$time
=
1
);
}
}
\ No newline at end of file
app/Http/Controllers/GroupController.php
View file @
2fe195f2
...
@@ -44,8 +44,6 @@ class GroupController extends Controller
...
@@ -44,8 +44,6 @@ class GroupController extends Controller
public
function
updatePage
(
Request
$request
)
public
function
updatePage
(
Request
$request
)
{
{
$rules
=
[
$rules
=
[
'id'
=>
'required'
,
'id'
=>
'required'
,
];
];
...
@@ -70,7 +68,6 @@ class GroupController extends Controller
...
@@ -70,7 +68,6 @@ class GroupController extends Controller
public
function
update
(
Request
$request
)
public
function
update
(
Request
$request
)
{
{
$rules
=
[
$rules
=
[
'name'
=>
'required'
,
'name'
=>
'required'
,
'id'
=>
'required'
,
'id'
=>
'required'
,
...
...
app/Http/Controllers/SMSController.php
View file @
2fe195f2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
App\Http\Controllers
;
namespace
App\Http\Controllers
;
use
App\Contracts\SMSServiceContract
;
use
App\Models\SMS
;
use
App\Models\SMS
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
...
@@ -10,45 +11,25 @@ use Illuminate\Support\Facades\DB;
...
@@ -10,45 +11,25 @@ use Illuminate\Support\Facades\DB;
class
SMSController
extends
Controller
class
SMSController
extends
Controller
{
{
public
$sms
;
public
function
surplus
(
)
public
function
__construct
(
SMSServiceContract
$sms
)
{
{
$sid
=
SMS
::
max
(
'id'
);
$this
->
mSms
=
$sms
;
$sms
=
SMS
::
find
(
$sid
);
if
(
$sms
->
created_at
->
isToday
()){
}
else
{
echo
"插入记录"
;
}
}
dd
(
"aa"
);
$account
=
env
(
'FEIGE_ACCOUNT'
);
public
function
surplus
()
$pwd
=
env
(
'FEIGE_PWD'
);
{
$url
=
"http://api.feige.ee/Account/Balance?Account="
.
$account
.
"&Pwd="
.
$pwd
.
""
;
$surplus
=
$this
->
mSms
->
SystemSms
(
$timeType
=
'minute'
,
$time
=
2
);
$smsSurplus
=
$this
->
post
(
$url
,
$data
=
array
());
$surplus
=
json_decode
(
$smsSurplus
)
;
return
view
(
'admin/sms/smsstatistics'
,
compact
(
'surplus'
));
return
view
(
'admin/sms/smsstatistics'
,
compact
(
'surplus'
));
}
}
public
function
post
(
$url
,
$data
,
$proxy
=
null
,
$timeout
=
20
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
//在HTTP请求中包含一个"User-Agent: "头的字符串。
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
0
);
//启用时会将头文件的信息作为数据流输出。
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
//发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
//Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_FOLLOWLOCATION
,
1
);
//启用时会将服务器服务器返回的"Location: "放在header中递归的返回给服务器,使用CURLOPT_MAXREDIRS可以限定递归返回的数量。
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
//文件流形式
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
$timeout
);
//设置cURL允许执行的最长秒数。
$content
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
unset
(
$curl
);
return
$content
;
}
public
function
surplusPage
()
public
function
surplusPage
()
{
{
...
...
app/Services/GroupService.php
View file @
2fe195f2
...
@@ -12,6 +12,7 @@ namespace App\Services;
...
@@ -12,6 +12,7 @@ namespace App\Services;
use
App\Contracts\GroupServiceContract
;
use
App\Contracts\GroupServiceContract
;
use
App\Models\Group
;
use
App\Models\Group
;
use
App\Models\User
;
use
App\Models\User
;
use
App\Util\UploadPhoto
;
class
GroupService
implements
GroupServiceContract
class
GroupService
implements
GroupServiceContract
{
{
...
@@ -50,15 +51,29 @@ class GroupService implements GroupServiceContract
...
@@ -50,15 +51,29 @@ class GroupService implements GroupServiceContract
public
function
update
(
$group_id
,
$name
,
$logo
,
$brief
,
$status
)
public
function
update
(
$group_id
,
$name
,
$logo
,
$brief
,
$status
)
{
{
$group
=
Group
::
find
(
$group_id
);
$group
=
Group
::
find
(
$group_id
);
if
(
$group
==
null
){
if
(
$group
==
null
){
return
false
;
return
false
;
}
}
if
(
$logo
==
null
){
$group
->
name
=
$name
;
$group
->
name
=
$name
;
$group
->
logo
=
$logo
;
$group
->
logo
=
$logo
;
$group
->
brief
=
$brief
;
$group
->
brief
=
$brief
;
$group
->
status
=
$status
;
$group
->
status
=
$status
;
$result
=
$group
->
update
();
$result
=
$group
->
update
();
}
else
{
$upload
=
new
UploadPhoto
();
$imgPath
=
$upload
->
upload
(
$logo
);
$group
->
name
=
$name
;
$group
->
logo
=
$imgPath
;
$group
->
brief
=
$brief
;
$group
->
status
=
$status
;
$result
=
$group
->
update
();
}
if
(
$result
){
if
(
$result
){
return
true
;
return
true
;
}
else
{
}
else
{
...
...
app/Services/SMSService.php
View file @
2fe195f2
...
@@ -10,8 +10,11 @@ namespace App\Services;
...
@@ -10,8 +10,11 @@ namespace App\Services;
use
App\Contracts\SMSServiceContract
;
use
App\Contracts\SMSServiceContract
;
use
App\Models\SMS
;
use
App\Models\SmsVerify
;
use
App\Models\SmsVerify
;
use
App\Util\FeigeSMS
;
use
App\Util\Message
;
use
App\Util\Message
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
class
SMSService
implements
SMSServiceContract
class
SMSService
implements
SMSServiceContract
...
@@ -65,4 +68,59 @@ class SMSService implements SMSServiceContract
...
@@ -65,4 +68,59 @@ class SMSService implements SMSServiceContract
return
Message
::
makeError
(
"invalid capcha"
);
return
Message
::
makeError
(
"invalid capcha"
);
}
}
}
}
public
function
SystemSms
(
$timeType
=
'hour'
,
$time
=
1
)
{
if
(
$timeType
==
'hour'
){
$condition
=
$time
*
3600
;
}
if
(
$timeType
==
'minute'
){
$condition
=
$time
*
60
;
}
$feigesms
=
new
FeigeSMS
();
$surplus
=
$feigesms
->
system
();
$sid
=
SMS
::
max
(
'id'
);
$sms
=
SMS
::
find
(
$sid
);
if
(
$sms
->
created_at
->
isToday
()){
$date
=
Carbon
::
now
();
$difference
=
strtotime
(
$date
)
-
strtotime
(
$sms
->
created_at
)
;
if
(
$difference
>
$condition
){
$addRecord
=
new
SMS
();
$addRecord
->
sms_surplus
=
$surplus
->
Balance
;
$addRecord
->
save
();
return
$surplus
;
}
}
return
$surplus
;
}
public
function
post
(
$url
,
$data
,
$proxy
=
null
,
$timeout
=
20
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
//在HTTP请求中包含一个"User-Agent: "头的字符串。
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
0
);
//启用时会将头文件的信息作为数据流输出。
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
//发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
//Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_FOLLOWLOCATION
,
1
);
//启用时会将服务器服务器返回的"Location: "放在header中递归的返回给服务器,使用CURLOPT_MAXREDIRS可以限定递归返回的数量。
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
//文件流形式
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
$timeout
);
//设置cURL允许执行的最长秒数。
$content
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
unset
(
$curl
);
return
$content
;
}
}
}
\ No newline at end of file
app/Services/UserService.php
View file @
2fe195f2
...
@@ -23,10 +23,7 @@ class UserService implements UserServiceContract
...
@@ -23,10 +23,7 @@ class UserService implements UserServiceContract
$users
=
User
::
where
(
'user_name'
,
'like'
,
'%'
.
$search_content
.
'%'
)
$users
=
User
::
where
(
'user_name'
,
'like'
,
'%'
.
$search_content
.
'%'
)
->
orWhere
(
'phone'
,
'like'
,
'%'
.
$search_content
.
'%'
)
->
orWhere
(
'phone'
,
'like'
,
'%'
.
$search_content
.
'%'
)
->
orWhere
(
'email'
,
'like'
,
'%'
.
$search_content
.
'%'
)
->
orWhere
(
'email'
,
'like'
,
'%'
.
$search_content
.
'%'
)
// ->get();
->
paginate
(
$page
);
->
paginate
(
$page
);
return
$users
;
return
$users
;
}
}
...
...
app/Util/FeigeSMS.php
0 → 100644
View file @
2fe195f2
<?php
/**
* Created by PhpStorm.
* User: mirzat
* Date: 2017/9/26
* Time: 19:34
*/
namespace
App\Util
;
class
FeigeSMS
{
private
$account
,
$password
,
$content
,
$mobile
,
$signId
,
$apiUrl
;
const
API_URL
=
"http://api.feige.ee/SmsService/Send"
;
public
function
__construct
(
$account
=
''
,
$pwd
=
''
,
$signId
=
''
)
{
if
(
env
(
'FEIGE_ACCOUT'
)){
$this
->
account
=
env
(
'FEIGE_ACCOUT'
);
}
else
{
$this
->
account
=
$account
;
}
if
(
env
(
'FEIGE_PASSWORD'
)){
$this
->
password
=
env
(
'FEIGE_PASSWORD'
);
}
else
{
$this
->
password
=
$pwd
;
}
if
(
env
(
'FEIGE_SIGN_ID'
)){
$this
->
signId
=
env
(
'FEIGE_SIGN_ID'
);
}
else
{
$this
->
signId
=
$signId
;
}
}
/**
* @return mixed
*/
public
function
getAccount
()
{
return
$this
->
account
;
}
/**
* @return mixed
*/
public
function
getApiUrl
()
{
return
$this
->
apiUrl
;
}
/**
* @param mixed $apiUrl
*/
public
function
setApiUrl
(
$apiUrl
)
{
$this
->
apiUrl
=
$apiUrl
;
}
public
function
getConfigArray
(){
$data
[
"Account"
]
=
$this
->
account
;
$data
[
"Pwd"
]
=
$this
->
password
;
$data
[
"Content"
]
=
$this
->
content
;
$data
[
"Mobile"
]
=
$this
->
mobile
;
$data
[
"SignId"
]
=
$this
->
signId
;
return
$data
;
}
public
static
function
makeSender
(
$data
=
[]){
$sender
=
new
FeigeSMS
(
$data
[
'Account'
],
$data
[
'Pwd'
],
$data
[
'Content'
],
$data
[
'Mobile'
],
$data
[
'SignId'
]);
$sender
->
setApiUrl
(
FeigeSMS
::
API_URL
);
return
$sender
;
}
public
static
function
sendSMS
(
$phone
,
$text
){
$sender
=
new
FeigeSMS
();
$sender
->
setContent
(
$text
);
$sender
->
setMobile
(
$phone
);
$data
=
$sender
->
getConfigArray
();
$result
=
$sender
->
doPost
(
FeigeSMS
::
API_URL
,
$data
);
return
$result
;
}
public
function
sendText
(
$phone
,
$text
){
$this
->
doPost
(
$this
,
$this
->
apiUrl
,
$this
->
transform
());
}
public
function
system
(){
$account
=
$this
->
account
;
$pwd
=
$this
->
password
;
$url
=
"http://api.feige.ee/Account/Balance?Account="
.
$account
.
"&Pwd="
.
$pwd
.
""
;
$smsSurplus
=
$this
->
doPost
(
$url
,
$data
=
array
());
$surplus
=
json_decode
(
$smsSurplus
)
;
return
$surplus
;
}
public
function
doPost
(
$url
,
$data
,
$proxy
=
null
,
$timeout
=
20
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
//在HTTP请求中包含一个"User-Agent: "头的字符串。
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
0
);
//启用时会将头文件的信息作为数据流输出。
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
//发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
$data
);
//Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_FOLLOWLOCATION
,
1
);
//启用时会将服务器服务器返回的"Location: "放在header中递归的返回给服务器,使用CURLOPT_MAXREDIRS可以限定递归返回的数量。
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
//文件流形式
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
$timeout
);
//设置cURL允许执行的最长秒数。
$content
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
unset
(
$curl
);
return
$content
;
}
/**
* @param mixed $account
*/
public
function
setAccount
(
$account
)
{
$this
->
account
=
$account
;
}
/**
* @return mixed
*/
public
function
getPwd
()
{
return
$this
->
pwd
;
}
/**
* @param mixed $pwd
*/
public
function
setPwd
(
$pwd
)
{
$this
->
pwd
=
$pwd
;
}
/**
* @return mixed
*/
public
function
getSignId
()
{
return
$this
->
signId
;
}
/**
* @param mixed $signId
*/
public
function
setSignId
(
$signId
)
{
$this
->
signId
=
$signId
;
}
/**
* @return mixed
*/
public
function
getMobile
()
{
return
$this
->
mobile
;
}
/**
* @param mixed $mobile
*/
public
function
setMobile
(
$mobile
)
{
$this
->
mobile
=
$mobile
;
}
/**
* @return mixed
*/
public
function
getContent
()
{
return
$this
->
content
;
}
/**
* @param mixed $content
*/
public
function
setContent
(
$content
)
{
$this
->
content
=
$content
;
}
}
\ No newline at end of file
resources/views/admin/group/groupinformation.blade.php
View file @
2fe195f2
...
@@ -107,11 +107,8 @@
...
@@ -107,11 +107,8 @@
@
foreach
(
$groups
->
usergroup
as
$user
)
@
foreach
(
$groups
->
usergroup
as
$user
)
<
div
style
=
"float: left;margin-left: 50px;"
>
<
div
style
=
"float: left;margin-left: 50px;"
>
<
img
class
=
"profile-user-img img-responsive img-circle"
src
=
"
{
{url('storage/1.jpg')}
}
"
alt
=
"User profile picture"
style
=
"height: 110px;"
>
<
img
class
=
"profile-user-img img-responsive img-circle"
src
=
"
{
{url('storage/1.jpg')}
}
"
alt
=
"User profile picture"
style
=
"height: 110px;"
>
<
h3
class
=
"profile-username text-center"
>
{{
$user
->
users
[
0
][
'user_name'
]}}
</
h3
>
<
h3
class
=
"profile-username text-center"
>
{{
$user
->
users
[
0
][
'user_name'
]}}
</
h3
>
</
div
>
</
div
>
...
...
resources/views/admin/group/update.blade.php
View file @
2fe195f2
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
<
label
for
=
"exampleInputFile"
>
团队Logo
</
label
>
<
label
for
=
"exampleInputFile"
>
团队Logo
</
label
>
<
p
>
<
p
>
<
img
src
=
"
{
{asset($group['logo']==''?url('storage/1.jpg'):$group
s
['logo'])}
}
"
alt
=
""
width
=
"100px"
height
=
"110px"
style
=
"border-radius: 80%"
>
<
img
src
=
"
{
{asset($group['logo']==''?url('storage/1.jpg'):$group['logo'])}
}
"
alt
=
""
width
=
"100px"
height
=
"110px"
style
=
"border-radius: 80%"
>
</
p
>
</
p
>
</
div
>
</
div
>
<
div
class
=
"form-group"
>
<
div
class
=
"form-group"
>
...
@@ -54,74 +54,4 @@
...
@@ -54,74 +54,4 @@
<
script
src
=
"
{
{url('js/jquery-3.2.1.min.js')}
}
"
>
</
script
>
<
script
src
=
"
{
{url('js/jquery-3.2.1.min.js')}
}
"
>
</
script
>
{{
--<
script
>--
}}
{{
--
$
(
"#exampleInputFile"
)
.
change
(
function
(){
--
}}
{{
--
var
file
=
this
.
files
[
0
];
--
}}
{{
--//
判断文件大小
--
}}
{{
--
if
(
file
.
size
>
5
*
1024
*
1024
){
--
}}
{{
--
alert
(
'文件过大!'
);
--
}}
{{
--
}
--
}}
{{
--//
使用FileReader
接口
--
}}
{{
--
var
reader
=
new
FileReader
();
--
}}
{{
--//
成功读取
--
}}
{{
--
reader
.
onload
=
function
(){
--
}}
{{
--//
通过reader
.
result
属性
来访问生成的
base
64
DataURL
--
}}
{{
--
var
fileInfo
=
reader
.
result
;
--
}}
{{
--
$
(
'#Preview'
)
.
attr
(
'src'
,
fileInfo
)
.
css
({
width
:
100
,
height
:
90
});
--
}}
{{
--//
console
.
log
(
fileInfo
);
--
}}
{{
--
var
name
=
$
(
'#exampleInputFile'
)
.
val
();
--
}}
{{
--//
分割字符串
--
}}
{{
--
var
arr
=
name
.
split
(
'\\'
);
--
}}
{{
--
var
fileName
=
arr
[
arr
.
length
-
1
];
--
}}
{{
--
base64_uploading
(
fileInfo
,
fileName
);
--
}}
{{
--
}
--
}}
{{
--
reader
.
readAsDataURL
(
file
);
--
}}
{{
--
})
--
}}
{{
--//
AJAX
上传base
64
--
}}
{{
--
function
base64_uploading
(
base64Data
,
fileName
){
--
}}
{{
--
$
.
ajax
({
--
}}
{{
--
type
:
'post'
,
--
}}
{{
--
url
:
"
{
{url('user/update')}}",--}
}
{{--data:
{
--}
}
{
{--'base64':base64Data,--}
}
{
{--'name':fileName--}
}
{
{--},--}
}
{
{--dataType:"json",--}
}
{{--headers:
{
--}
}
{{--'X-CSRF-TOKEN': $('meta[name="
_token
"]').attr('content')--}}
{
{--},--}
}
{
{--success:function(data){--}
}
{
{--console.log(data);--}
}
{{--if (data ==1 )
{
--}
}
{
{--alert('上传成功')--}
}
{
{--
}
else
{
--}
}
{
{--alert('上传失败')--}
}
{
{--}--}
}
{
{--},--}
}
{{--error:function (data)
{
--}
}
{
{--alert(1);--}
}
{
{--console.log(data);--}
}
{
{--}--}
}
{
{--})--}
}
{
{--}--}
}
{
{--</script>--}
}
@
endsection
@
endsection
\ 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