Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fusionapi
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
林洽文
fusionapi
Commits
5998d11c
Commit
5998d11c
authored
May 08, 2023
by
zazaname
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支付回调
parent
c9493749
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
10 deletions
+43
-10
ExampleController.php
app/Http/Controllers/ExampleController.php
+2
-1
PayController.php
app/Http/Controllers/PayController.php
+2
-0
Jiuzi.php
app/Http/InterfaceClass/SdkImpl/Jiuzi.php
+1
-0
PayService.php
app/Http/Service/PayService.php
+30
-5
ExampleJob.php
app/Jobs/ExampleJob.php
+8
-4
No files found.
app/Http/Controllers/ExampleController.php
View file @
5998d11c
...
...
@@ -12,6 +12,7 @@ class ExampleController extends Controller
public
function
test
(
Request
$request
){
$this
->
dispatch
(
new
ExampleJob
(
11111
));
dispatch
(
new
ExampleJob
(
"fuck"
));
var_dump
(
"cdcd"
);
}
}
app/Http/Controllers/PayController.php
View file @
5998d11c
...
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use
App\Http\Service\PayService
;
use
Illuminate\Http\JsonResponse
;
use
Illuminate\Support\Facades\Log
;
class
PayController
extends
Controller
{
...
...
@@ -41,6 +42,7 @@ class PayController extends Controller
* 渠道支付回调,平台标识找sdk配置,验签,通过则向CP发起发货通知
*/
public
function
verBack
(){
Log
::
info
(
"渠道回调日志:"
.
file_get_contents
(
'php://input'
));
$this
->
checkParam
([
'app_id'
,
'ver'
]);
$data
=
$this
->
paySv
->
verBack
(
$this
->
requestData
);
return
is_array
(
$data
)
?
json
(
$data
)
:
$data
;
...
...
app/Http/InterfaceClass/SdkImpl/Jiuzi.php
View file @
5998d11c
...
...
@@ -64,6 +64,7 @@ class Jiuzi implements ISdkFactory
return
[
'order_id'
=>
$request
[
'order_num'
],
'money'
=>
$request
[
'money'
],
'channel_order_id'
=>
$request
[
'channel_order_id'
],
'result'
=>
$this
->
result
(
'200'
,
'发货成功'
,
$request
[
'order_num'
])
];
}
...
...
app/Http/Service/PayService.php
View file @
5998d11c
...
...
@@ -12,6 +12,7 @@ use Illuminate\Support\Facades\DB;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Redis
;
use
RuntimeException
;
use
WpOrg\Requests\Requests
;
class
PayService
{
...
...
@@ -145,11 +146,12 @@ class PayService
$sdkManager
=
new
SdkManager
();
// 返回渠道订单号+订单金额[单位元]
$payInfo
=
$sdkManager
->
pay
(
$verInfo
,
$gameInfo
,
$params
);
if
(
!
isset
(
$pa
rams
[
'order_id'
])
&&
!
isset
(
$params
[
'money'
]))
{
if
(
!
isset
(
$pa
yInfo
[
'order_id'
])
&&
!
isset
(
$payInfo
[
'money'
]))
{
return
$payInfo
[
'result'
];
}
$orderModel
=
DB
::
table
(
'app_order'
);
// 更新回调时间+金额
DB
::
table
(
'app_order'
)
->
where
([
'order_id'
=>
$payInfo
[
'order_id'
]])
->
update
([
'status'
=>
1
,
'amount'
=>
$payInfo
[
'money
'
],
'dateline'
=>
time
()]);
$orderModel
->
where
([
'order_id'
=>
$payInfo
[
'order_id'
]])
->
update
([
'status'
=>
1
,
'amount'
=>
$payInfo
[
'money'
],
'channel_order_id'
=>
$payInfo
[
'channel_order_id
'
],
'dateline'
=>
time
()]);
// 保存回调日志
DB
::
table
(
'app_callback_log'
)
->
insert
([
'order_id'
=>
$payInfo
[
'order_id'
],
...
...
@@ -158,9 +160,32 @@ class PayService
'reqresult'
=>
var_export
(
$payInfo
,
true
),
'reqtime'
=>
time
(),
]);
// 通知CP发货,redis队列,后台发货, 订单号|appid|渠道号
$list
=
"
{
$payInfo
[
'order_id'
]
}
|
{
$params
[
'app_id'
]
}
|
{
$params
[
'ver'
]
}
"
;
Redis
::
lpush
(
'send_order_list'
,
$list
);
// 获取订单信息
$orderInfo
=
$orderModel
->
where
([
'order_id'
=>
$payInfo
[
'order_id'
]])
->
first
();
// 通知CP发货,组装post参数,并签名
$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="
.
$gameInfo
->
paykey
;
$params
[
'sign'
]
=
md5
(
$signStr
);
$response
=
Requests
::
post
(
$gameInfo
->
send_url
,[
'Accept'
=>
'application/json'
],
$post_params
)
->
body
;
$response_arr
=
json_decode
(
$response
,
true
);
if
(
$response_arr
[
'code'
]
===
200
)
{
$orderModel
->
where
([
'order_id'
=>
$payInfo
[
'order_id'
]])
->
update
([
'gstatus'
=>
1
]);
}
// 返回渠道要求返回的提示 成功|失败
return
$payInfo
[
'result'
];
}
...
...
app/Jobs/ExampleJob.php
View file @
5998d11c
...
...
@@ -2,12 +2,16 @@
namespace
App\Jobs
;
//use Illuminate\Contracts\Bus\SelfHandling;
use
Illuminate\Queue\SerializesModels
;
use
Illuminate\Queue\InteractsWithQueue
;
use
Illuminate\Contracts\Bus\SelfHandling
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
class
ExampleJob
extends
Job
implements
ShouldQueue
class
ExampleJob
extends
Job
implements
SelfHandling
,
ShouldQueue
{
use
InteractsWithQueue
,
SerializesModels
;
private
$cc
;
/**
* Create a new job instance.
...
...
@@ -27,7 +31,7 @@ class ExampleJob extends Job implements ShouldQueue
public
function
handle
()
{
sleep
(
5
);
echo
getmypid
()
.
'-'
.
time
();
dump
(
$this
->
cc
);
//
echo getmypid().'-'.time();
//
dump($this->cc);
}
}
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