Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fusionadmin
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
林洽文
fusionadmin
Commits
01b77a39
Commit
01b77a39
authored
May 08, 2023
by
zazaname
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聚合服务端后台V1.0
parent
8605bf82
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
1 deletion
+82
-1
Send.php
app/command/controller/Send.php
+82
-1
No files found.
app/command/controller/Send.php
View file @
01b77a39
...
...
@@ -4,15 +4,96 @@ declare (strict_types = 1);
namespace
app\command\controller
;
use
app\command\CmdLog
;
use
think\Exception
;
use
think\facade\Config
;
use
think\facade\Db
;
use
think\facade\Log
;
use
WpOrg\Requests\Requests
;
class
Send
{
// 订单数 => 分钟数
private
$mintue
=
[
0
=>
2
,
1
=>
5
,
2
=>
15
,
3
=>
30
,
4
=>
60
,
5
=>
120
,
6
=>
240
,
];
// 发货入口
public
function
runs
(){
CmdLog
::
debug
(
"正在执行发货..."
);
CmdLog
::
debug
(
"正在执行补单..."
);
// 查询发放失败的订单
$time
=
time
();
// 当前时间
$where
=
"status =1 and gstatus !=1 and dateline >= "
.
(
$time
-
1
*
24
*
60
*
60
);
// 回调失败的订单
$orderList
=
Db
::
table
(
'app_order'
)
->
where
(
$where
)
->
limit
(
50
)
->
select
()
->
toArray
();
// 游戏未发货订单处理
if
(
!
empty
(
$orderList
))
{
foreach
(
$orderList
as
$k
=>
$v
)
{
// 查询订单 自动补单次数
$fixOrderCount
=
$v
[
'wap_number'
];
foreach
(
$this
->
mintue
as
$minK
=>
$minV
)
{
// 补单次数 && 订单间隔时间 大于 当前次数时间
if
(
$minK
===
$fixOrderCount
&&
$time
-
$v
[
'dateline'
]
>=
$minV
*
60
)
{
$res
=
$this
->
fixOrder
(
$v
);
if
(
!
$res
){
continue
;
}
}
}
}
}
else
{
CmdLog
::
debug
(
"无订单补发!"
);
}
}
private
function
fixOrder
(
$orderInfo
)
{
// 通过下单的 appid 找到游戏配置
$gamesInfo
=
Db
::
table
(
'app_games_config'
)
->
where
([
'app_id'
=>
$orderInfo
[
'appid'
]])
->
find
();
if
(
!
$gamesInfo
){
CmdLog
::
info
(
"order_id:
{
$orderInfo
[
'appid'
]
}
游戏配置没找到!"
);
return
false
;
}
// 组装post参数,并签名
$params
=
[
'order_id'
=>
$orderInfo
[
'order_id'
],
'good_name'
=>
$orderInfo
[
'subject'
],
'cp_order_id'
=>
$orderInfo
[
'cp_order_id'
],
'uid'
=>
$orderInfo
[
'uid'
],
'money'
=>
$orderInfo
[
'money'
],
'app_id'
=>
$orderInfo
[
'appid'
],
'service_id'
=>
$orderInfo
[
'server_id'
],
'service_name'
=>
$orderInfo
[
'server_name'
],
'role_id'
=>
$orderInfo
[
'role_id'
],
'role_name'
=>
$orderInfo
[
'role_name'
],
'time'
=>
time
(),
'pay_status'
=>
$orderInfo
[
'status'
],
'extend'
=>
$orderInfo
[
'extra_info'
],
];
ksort
(
$params
);
$signStr
=
http_build_query
(
$params
)
.
"&paykey="
.
$gamesInfo
[
'paykey'
];
$params
[
'sign'
]
=
md5
(
$signStr
);
$response
=
Requests
::
post
(
$gamesInfo
[
'send_url'
],[
'Accept'
=>
'application/json'
],
$params
)
->
body
;
Db
::
table
(
'app_order'
)
->
where
([
'order_id'
=>
$orderInfo
[
'order_id'
]])
->
update
([
'wap_number'
=>
Db
::
raw
(
'wap_number+1'
)]);
$response_arr
=
json_decode
(
$response
,
true
);
if
(
$response_arr
[
'code'
]
===
200
){
Db
::
table
(
'app_order'
)
->
where
([
'order_id'
=>
$orderInfo
[
'order_id'
]])
->
update
([
'gstatus'
=>
1
]);
CmdLog
::
info
(
"order_id:
{
$orderInfo
[
'appid'
]
}
补单成功!"
);
return
true
;
}
else
{
Db
::
table
(
'app_order'
)
->
where
([
'order_id'
=>
$orderInfo
[
'order_id'
]])
->
update
([
'gstatus'
=>
2
]);
CmdLog
::
info
(
"order_id:
{
$orderInfo
[
'appid'
]
}
补单失败!返回:
{
$response
}
"
);
}
return
false
;
}
}
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