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
659ad841
Commit
659ad841
authored
May 06, 2023
by
zazaname
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加渠道下单
parent
e4e2d607
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
1 deletion
+57
-1
ISdkFactory.php
app/Http/InterfaceClass/ISdkFactory.php
+3
-0
Jiuzi.php
app/Http/InterfaceClass/SdkImpl/Jiuzi.php
+11
-0
SdkManager.php
app/Http/Manager/SdkManager.php
+25
-0
PayService.php
app/Http/Service/PayService.php
+18
-1
No files found.
app/Http/InterfaceClass/ISdkFactory.php
View file @
659ad841
...
@@ -8,6 +8,9 @@ interface ISdkFactory
...
@@ -8,6 +8,9 @@ interface ISdkFactory
// 登录
// 登录
public
function
login
(
$verInfo
,
$gameInfo
,
$request
)
:
array
;
public
function
login
(
$verInfo
,
$gameInfo
,
$request
)
:
array
;
// 创建订单号
public
function
createOrder
(
$verInfo
,
$gameInfo
,
$request
)
:
string
;
// 支付
// 支付
public
function
pay
(
$verInfo
,
$gameInfo
,
$request
)
:
array
;
public
function
pay
(
$verInfo
,
$gameInfo
,
$request
)
:
array
;
}
}
app/Http/InterfaceClass/SdkImpl/Jiuzi.php
View file @
659ad841
...
@@ -68,6 +68,17 @@ class Jiuzi implements ISdkFactory
...
@@ -68,6 +68,17 @@ class Jiuzi implements ISdkFactory
];
];
}
}
/**
* 创建订单号
* @param $verInfo
* @param $gameInfo
* @param $request
* @return array
*/
public
function
createOrder
(
$verInfo
,
$gameInfo
,
$request
)
:
string
{
return
''
;
}
/**
/**
* 按渠道的格式返回
* 按渠道的格式返回
* @param $statusCode
* @param $statusCode
...
...
app/Http/Manager/SdkManager.php
View file @
659ad841
...
@@ -62,5 +62,30 @@ class SdkManager
...
@@ -62,5 +62,30 @@ class SdkManager
return
$sdkObj
->
pay
(
$verInfo
,
$gameInfo
,
$params
);
return
$sdkObj
->
pay
(
$verInfo
,
$gameInfo
,
$params
);
}
}
/**
* 返回渠道订单号
* @param $verInfo
* @param $gameInfo
* @param $params
* @return array
*/
public
function
createOrder
(
$verInfo
,
$gameInfo
,
$params
)
:
string
{
$channelClass
=
ucfirst
(
$verInfo
->
ver_class
);
try
{
/** @var ISdkFactory $sdkObj */
$sdkFileClass
=
"App
\\
Http
\\
InterfaceClass
\\
SdkImpl
\\
{
$channelClass
}
"
;
$sdkObj
=
new
$sdkFileClass
;
if
(
!
$sdkObj
instanceof
ISdkFactory
)
{
throw
new
RuntimeException
(
$channelClass
.
'不是ISdkFactory子类!'
);
}
}
catch
(
Exception
$e
)
{
$msg
=
'创建'
.
$channelClass
.
'类失败!'
;
throw
new
RuntimeException
(
$msg
);
}
return
$sdkObj
->
createOrder
(
$verInfo
,
$gameInfo
,
$params
);
}
}
}
app/Http/Service/PayService.php
View file @
659ad841
...
@@ -43,6 +43,22 @@ class PayService
...
@@ -43,6 +43,22 @@ class PayService
if
(
empty
(
$params
[
'app_id'
])
||
empty
(
$params
[
'ctype'
])
||
empty
(
$params
[
'money'
])
||
empty
(
$params
[
'uid'
]))
{
if
(
empty
(
$params
[
'app_id'
])
||
empty
(
$params
[
'ctype'
])
||
empty
(
$params
[
'money'
])
||
empty
(
$params
[
'uid'
]))
{
return
error
(
"提交参数异常!"
);
return
error
(
"提交参数异常!"
);
}
}
//获取游戏表配置
$gameInfo
=
DB
::
table
(
"app_games_config"
)
->
where
([
'app_id'
=>
$params
[
'app_id'
]])
->
first
();
if
(
is_null
(
$gameInfo
))
{
return
error
(
'该游戏配置不存在,app_id:'
.
$params
[
'app_id'
]);
}
// 获取渠道表配置
$verInfo
=
DB
::
table
(
"app_ver_game as avg"
)
->
leftJoin
(
'app_ver as av'
,
'avg.ver'
,
'='
,
'av.ver_class'
)
->
where
([
'app_id'
=>
$params
[
'app_id'
],
'ver_code'
=>
$params
[
'ctype'
]])
->
first
();
if
(
is_null
(
$verInfo
))
{
return
error
(
'该游戏渠道没配置,app_id:'
.
$params
[
'app_id'
]);
}
// 走一下渠道的下单接口,如果部分渠道没有,则返回空
$sdkManager
=
new
SdkManager
();
$channel_order_id
=
$sdkManager
->
createOrder
(
$verInfo
,
$gameInfo
,
$params
);
// 查找融合用户信息
// 查找融合用户信息
$userInfo
=
DB
::
table
(
'app_member'
)
->
where
([
'uid'
=>
$params
[
'uid'
]])
->
first
();
$userInfo
=
DB
::
table
(
'app_member'
)
->
where
([
'uid'
=>
$params
[
'uid'
]])
->
first
();
// 入库
// 入库
...
@@ -51,6 +67,7 @@ class PayService
...
@@ -51,6 +67,7 @@ class PayService
'uid'
=>
$params
[
'uid'
],
'uid'
=>
$params
[
'uid'
],
'order_id'
=>
$orderId
,
'order_id'
=>
$orderId
,
'cp_order_id'
=>
$params
[
'cp_order_id'
],
'cp_order_id'
=>
$params
[
'cp_order_id'
],
'channel_order_id'
=>
$channel_order_id
,
'veruniqid'
=>
$userInfo
->
veruniqid
,
'veruniqid'
=>
$userInfo
->
veruniqid
,
'ver'
=>
$params
[
'ctype'
],
'ver'
=>
$params
[
'ctype'
],
'appid'
=>
$params
[
'app_id'
],
'appid'
=>
$params
[
'app_id'
],
...
@@ -66,7 +83,7 @@ class PayService
...
@@ -66,7 +83,7 @@ class PayService
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
'create_time'
=>
date
(
'Y-m-d H:i:s'
)
];
];
$model
->
insert
(
$insertData
);
$model
->
insert
(
$insertData
);
return
success
(
'success'
,[
'order_id'
=>
$orderId
]);
return
success
(
'success'
,[
'order_id'
=>
$orderId
,
'channel_order_id'
=>
$channel_order_id
]);
}
}
/**
/**
...
...
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