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
69c9bde1
Commit
69c9bde1
authored
Jul 13, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 增加多次支付异常报警逻辑
parent
18043c63
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
12 deletions
+30
-12
RefundException.php
application/exception/custom/RefundException.php
+2
-3
PingxxService.php
application/services/pingxx/PingxxService.php
+5
-4
RefundService.php
application/services/refund/RefundService.php
+23
-5
No files found.
application/exception/custom/RefundException.php
View file @
69c9bde1
...
...
@@ -19,13 +19,12 @@ class RefundException extends BaseException
5
=>
'已核销计算订单不支持退款!'
,
6
=>
'退款处理完成,请勿重复申请'
,
7
=>
'退款处理中请稍等'
,
6
=>
'该退款单核对ping++状态为未支付,请稍后重试!'
,
8
=>
'退款消息类型匹配失败,请管理员关注!'
,
9
=>
'ping++退款消息格式错误,请管理员关注!'
,
10
=>
'ping++退单状态异常,请管理员关注!'
,
11
=>
'ping++退单缺少matadata!'
,
13
=>
'
仅支持自己操作订单退款!
'
,
12
=>
'ping++未支付订单不允许退款。'
,
13
=>
'
ping++存在多次支付场景,请联系管理员确认。
'
,
];
}
application/services/pingxx/PingxxService.php
View file @
69c9bde1
...
...
@@ -47,7 +47,7 @@ class PingxxService
$royalty_users
=
[];
$ret
=
OrderRefund
::
create
(
$refundData
[
'
charge
'
],
$refundData
[
'
id
'
],
[
'charge'
=>
$refundData
[
'charge'
],
//在该订单中,需要退款的 charge 对象 ID,默认全部退款。
'charge_amount'
=>
$refundData
[
'charge_amount'
],
//charge 退款金额,默认为全额退款。必须和 charge 参数同时使用。单位:分。
...
...
@@ -64,7 +64,8 @@ class PingxxService
// 捕获报错信息
if
(
$e
->
getHttpStatus
()
!=
null
)
{
return
json_encode
(
$e
->
getHttpBody
(),
true
);
return
json_decode
(
$e
->
getHttpBody
(),
true
);
}
else
{
return
[
...
...
@@ -92,7 +93,7 @@ class PingxxService
}
catch
(
\Pingpp\Error\Base
$e
)
{
// 捕获报错信息
if
(
$e
->
getHttpStatus
()
!=
null
)
{
return
json_
en
code
(
$e
->
getHttpBody
(),
true
);
return
json_
de
code
(
$e
->
getHttpBody
(),
true
);
}
else
{
return
[
...
...
@@ -199,7 +200,7 @@ class PingxxService
}
catch
(
\Pingpp\Error\Base
$e
)
{
// 捕获报错信息
if
(
$e
->
getHttpStatus
()
!=
null
)
{
return
json_
en
code
(
$e
->
getHttpBody
(),
true
);
return
json_
de
code
(
$e
->
getHttpBody
(),
true
);
}
else
{
return
[
...
...
application/services/refund/RefundService.php
View file @
69c9bde1
...
...
@@ -4,6 +4,7 @@
namespace
App\Services\refund
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Exception\BaseException
;
use
App\Models\Dictionary
;
use
App\Models\order\mysql\PayOrder
;
...
...
@@ -15,7 +16,6 @@ use App\Services\order\OrderService;
use
App\Services\pingxx\PingxxService
;
use
Helpers\Strategy
;
use
Helpers\Logger
;
use
App\Exception\custom\RefundException
;
use
Yaf\Application
;
...
...
@@ -23,8 +23,6 @@ use Yaf\Application;
class
RefundService
{
private
$refund_order
=
[];
/**
* @param $order_item_id
* @param $user_id
...
...
@@ -57,9 +55,30 @@ class RefundService
$data
=
$this
->
can_refund
(
$where
,
$order_item
);
/*
https://www.pingxx.com/api/%E8%AE%A2%E5%8D%95%20Refunds%20%E9%80%80%E6%AC%BE%E6%A6%82%E8%BF%B0.html
订单退款 paid = true, status = canceled, amount_paid > 0 则表明可以退款
amount_paid 大于 actual_amount 需要最后一单全退。
具体见ping++ 文档
*/
$pay
=
PingxxService
::
getInstance
()
->
getOrder
(
$data
[
'pay_order'
][
'third_order_id'
]);
if
(
empty
(
$pay
[
'paid'
])
||
$pay
[
'paid'
]
!=
true
)
{
throw
new
RefundException
([
'cus'
=>
12
]);
}
// 存在多次支付的场景需要人工介入处理, 修复订单支付金额,退款金额
if
(
$pay
[
'amount_paid'
]
>
$pay
[
'actual_amount'
])
{
FileLog
::
error
(
'pay-service: 订单存在多次支付成功,需人工处理。'
,
json_encode
(
$pay
,
JSON_UNESCAPED_UNICODE
));
throw
new
RefundException
([
'cus'
=>
13
]);
}
// 构造退款数据
$refund
=
[
'charge'
=>
$data
[
'pay_order'
][
'third_order_id'
],
'id'
=>
$pay
[
'id'
],
//pingxx订单ID
'charge'
=>
$pay
[
'charge'
],
//pingxx 支付订单ID
'refund_mode'
=>
'to_source'
,
//默认返回
'charge_amount'
=>
$data
[
'refund_order'
][
'refund_amount'
],
'metadata'
=>
[
'app_id'
=>
'merchant-c'
,
...
...
@@ -227,7 +246,6 @@ class RefundService
if
(
!
$ret
)
{
throw
new
RefundException
([
'cus'
=>
0
]);
}
//重新获取
$refund_order
=
RefundOrder
::
getMaster
(
'*'
,
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]);
$data
=
[
...
...
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