Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pay
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
bp
pay
Commits
162cf54a
Commit
162cf54a
authored
Jul 25, 2021
by
万继龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'test'
add: 增加商品过期时间的判断 See merge request bp/pay!29
parents
def5e688
16cfbbea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
55 deletions
+41
-55
PayException.php
application/exception/custom/PayException.php
+2
-0
Tcc.php
application/modules/Pay/controllers/Tcc.php
+25
-55
PayService.php
application/services/pay/PayService.php
+14
-0
No files found.
application/exception/custom/PayException.php
View file @
162cf54a
...
...
@@ -26,6 +26,8 @@ class PayException extends BaseException
11
=>
'商家仅允许核销自己的订单,请管理员关注'
,
12
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
14
=>
'订单缺少商品信息,请联系管理员'
,
15
=>
'订单商品存在过期商品,不能支付'
,
...
...
application/modules/Pay/controllers/Tcc.php
View file @
162cf54a
...
...
@@ -11,96 +11,66 @@ use Helpers\DingTalk;
class
TccController
extends
Base
{
/**
*
创建支付订单,返回前端ping++的支付信息
*
tcc test
*/
public
function
tryAction
()
{
if
(
!
empty
(
$this
->
params
[
'sleep'
]))
{
sleep
(
$this
->
params
[
'sleep'
]);
}
if
(
!
empty
(
$this
->
params
[
'throw'
]))
{
throw
new
\Exception
(
'test for Exception.'
,
'3001'
);
}
if
(
!
empty
(
$this
->
params
[
'lock'
]))
{
//todo make a lock for mysql
if
(
!
empty
(
$this
->
params
[
'error'
]))
{
throw
new
\App\Exception\BaseException
([
'msg'
=>
'try is error'
,
'code'
=>
2001
]);
}
$this
->
success
([
'result'
=>
[]]);
}
public
function
confirmAction
()
{
public
function
mainAction
()
{
if
(
!
empty
(
$this
->
params
[
'sleep'
]))
{
sleep
(
$this
->
params
[
'sleep'
]);
}
if
(
!
empty
(
$this
->
params
[
'
throw
'
]))
{
throw
new
\Exception
(
'test for Exception.'
,
'3001'
);
if
(
!
empty
(
$this
->
params
[
'
error
'
]))
{
$this
->
success
([
'data'
=>
2
]
);
}
if
(
!
empty
(
$this
->
params
[
'lock'
]))
{
$this
->
success
([
'data'
=>
1
]);
}
public
function
sleepAction
()
{
//todo make a lock for mysql
if
(
!
empty
(
$this
->
params
[
'sleep'
]))
{
sleep
(
$this
->
params
[
'sleep'
]);
}
$this
->
success
([
'result'
=>
[]]);
$this
->
success
([
'result'
=>
$this
->
params
]);
}
public
function
c
ancel
Action
()
{
public
function
c
onfirm
Action
()
{
if
(
!
empty
(
$this
->
params
[
'sleep'
]))
{
sleep
(
$this
->
params
[
'sleep'
]);
}
if
(
!
empty
(
$this
->
params
[
'throw'
]))
{
throw
new
\Exception
(
'test for Exception.'
,
'3001'
);
}
if
(
!
empty
(
$this
->
params
[
'lock'
]))
{
//todo make a lock for mysql
if
(
!
empty
(
$this
->
params
[
'error'
]))
{
throw
new
\App\Exception\BaseException
([
'msg'
=>
'confirm is error'
,
'code'
=>
2001
]);
}
$this
->
success
([
'result'
=>
[]]);
}
public
function
traceAction
()
{
\Helpers\Tracer
::
info
(
'traceId'
,
''
);
}
public
function
cancelAction
()
{
public
function
pdoAction
()
{
$dsn
=
'mysql:dbname=testdb;host=127.0.0.1'
;
$user
=
'dbuser'
;
$password
=
'dbpass'
;
$user
=
config
(
'mysql'
,
'pay.username'
);
$password
=
config
(
'mysql'
,
'pay.password'
);
$host
=
config
(
'mysql'
,
'pay.write.host'
);
$db
=
config
(
'mysql'
,
'pay.database_name'
);
$dsn
=
'mysql:dbname='
.
$db
.
';host='
.
$host
;
$dbh
=
new
PDO
(
$dsn
,
$user
,
$password
);
sleep
(
15
);
$sth
=
$dbh
->
prepare
(
'SELECT * FROM pay_order WHERE user_id = ? limit 1'
);
var_dump
(
$sth
,
'----'
);
$sth
->
execute
([
510226436112
]);
$one
=
$sth
->
fetchAll
();
$sth
->
execute
([
510230120298
]);
$two
=
$sth
->
fetchAll
();
if
(
!
empty
(
$this
->
params
[
'sleep'
]))
{
sleep
(
$this
->
params
[
'sleep'
]);
}
$this
->
success
([
'one'
=>
$one
,
'two'
=>
$two
]);
if
(
!
empty
(
$this
->
params
[
'error'
]))
{
throw
new
\App\Exception\BaseException
([
'msg'
=>
'confirm is error'
,
'code'
=>
2001
]);
}
$this
->
success
([
'result'
=>
[]]);
}
}
application/services/pay/PayService.php
View file @
162cf54a
...
...
@@ -50,6 +50,10 @@ class PayService
throw
new
PayException
([
'cus'
=>
3
]);
}
if
(
empty
(
$data
[
'result'
][
'order_item_list'
]))
{
throw
new
PayException
([
'cus'
=>
14
]);
}
$metadata
=
[
'app_id'
=>
'merchant-c'
,
'environ'
=>
Application
::
app
()
->
environ
(),
...
...
@@ -57,12 +61,22 @@ class PayService
'goods'
=>
[],
'order_item_id'
=>
[],
];
$min_expire_time
=
$now
=
time
();
foreach
(
$data
[
'result'
][
'order_item_list'
]
as
$item
)
{
if
(
strtotime
(
$item
[
'expiration_time'
])
<
$min_expire_time
)
{
$min_expire_time
=
strtotime
(
$item
[
'expiration_time'
]);
}
$metadata
[
'goods'
][
$item
[
'goods_sku_id'
]]
=
$item
[
'goods_num'
];
array_push
(
$metadata
[
'order_item_id'
],
$item
[
'order_item_id'
]);
}
if
(
$now
>
$min_expire_time
)
{
throw
new
PayException
([
'cus'
=>
15
]);
}
// 判断是否存在有效订单
$max_expire_time
=
config
(
'pay'
,
'pay.expire_time'
)
??
1800
;
$expire_time
=
time
()
+
$max_expire_time
;
...
...
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