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
2867ef0b
Commit
2867ef0b
authored
Jul 06, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 调整日志为FileLog
parent
05fea7e4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
22 deletions
+52
-22
PayException.php
application/exception/custom/PayException.php
+1
-0
Sdk.php
application/library/Helpers/Sdk.php
+9
-9
PayOrder.php
application/models/order/mysql/PayOrder.php
+0
-1
Callback.php
application/modules/Pay/controllers/Callback.php
+23
-0
PayService.php
application/services/pay/PayService.php
+3
-1
PingxxService.php
application/services/pingxx/PingxxService.php
+12
-10
RefundService.php
application/services/refund/RefundService.php
+4
-1
No files found.
application/exception/custom/PayException.php
View file @
2867ef0b
...
@@ -21,5 +21,6 @@ class PayException extends BaseException
...
@@ -21,5 +21,6 @@ class PayException extends BaseException
9
=>
'未支付订单不允许核销,请管理员关注'
,
9
=>
'未支付订单不允许核销,请管理员关注'
,
10
=>
'仅允许核销商家自己的订单,请管理员关注'
,
10
=>
'仅允许核销商家自己的订单,请管理员关注'
,
11
=>
'该订单已超时关闭,请重新下单'
,
11
=>
'该订单已超时关闭,请重新下单'
,
12
=>
'订单不存在,请核对'
,
];
];
}
}
application/library/Helpers/Sdk.php
View file @
2867ef0b
<?php
<?php
namespace
Helpers
;
namespace
Helpers
;
use
Helpers\Logger
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\
Common\TimeOu
t
;
use
Api\PhpUtils\
Http\Reques
t
;
/**
/**
* Sdk 获取接口
* Sdk 获取接口
...
@@ -19,17 +19,17 @@ class Sdk {
...
@@ -19,17 +19,17 @@ class Sdk {
*/
*/
public
static
function
call
(
$url
,
$params
,
$headers
=
[])
{
public
static
function
call
(
$url
,
$params
,
$headers
=
[])
{
/*
$header = [
$header = [
'X-REQUEST-ID'=>Logger::getTraceId(),
'X-REQUEST-ID'=>Logger::getTraceId(),
'Content-type'
=>
'application/json'
,
];
];
$headers = array_merge($headers, $header);
$headers = array_merge($headers, $header);
*/
Logger
::
info
(
'api request'
,
[
'url'
=>
$url
,
'params'
=>
$params
]
);
$data
=
(
new
Request
())
->
post
(
$url
,
$params
,
3000
,
'json'
);
$data
=
(
new
TimeOut
())
->
runPost
(
$url
,
$params
,
$headers
)
;
//$data['response']
;
Logger
::
info
(
'api response'
,
[
'ret'
=>
$data
]
);
//var_export($data
);
FileLog
::
info
(
'sdk_call:'
.
'services return'
,
json_encode
([
'url'
=>
$url
,
$headers
,
'req'
=>
$params
,
'res'
=>
$data
]));
return
$data
;
return
$data
[
'response'
]
;
}
}
}
}
\ No newline at end of file
application/models/order/mysql/PayOrder.php
View file @
2867ef0b
...
@@ -3,7 +3,6 @@ namespace App\Models\order\mysql;
...
@@ -3,7 +3,6 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
App\Exception\custom\PayException
;
use
App\Exception\custom\PayException
;
use
Helpers\Logger
;
class
PayOrder
extends
MysqlBase
class
PayOrder
extends
MysqlBase
{
{
...
...
application/modules/Pay/controllers/Callback.php
View file @
2867ef0b
...
@@ -49,4 +49,27 @@ class CallbackController extends Base
...
@@ -49,4 +49,27 @@ class CallbackController extends Base
$this->failed('500');
$this->failed('500');
}*/
}*/
}
}
public
function
rawAction
()
{
// try{
$raw_data
=
file_get_contents
(
'php://input'
);
file_put_contents
(
'/tmp/aa.log'
,
$raw_data
,
FILE_APPEND
);
$paySrv
=
new
PayService
();
//todo ping++ 回调数据验签
$data
=
json_decode
(
$raw_data
,
true
);
file_put_contents
(
'/tmp/aa.log'
,
json_encode
(
$data
),
FILE_APPEND
);
$ret
=
$paySrv
->
call_back
(
$data
);
$this
->
success
([
'result'
=>
$ret
]);
/*
}catch (Exception $e) {
http_response_code(500);
$this->failed('500');
}*/
}
}
}
application/services/pay/PayService.php
View file @
2867ef0b
...
@@ -42,6 +42,9 @@ class PayService
...
@@ -42,6 +42,9 @@ class PayService
}
}
$order
=
$data
[
'result'
][
'order_info'
];
$order
=
$data
[
'result'
][
'order_info'
];
if
(
$order
[
'user_id'
]
!=
$user_id
)
{
throw
new
PayException
([
'cus'
=>
1
]);
}
$metadata
=
[
$metadata
=
[
'goods_sku_id'
=>
[],
'goods_sku_id'
=>
[],
...
@@ -126,7 +129,6 @@ class PayService
...
@@ -126,7 +129,6 @@ class PayService
}
}
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
Logger
::
error
(
'回调参数错误:'
,
$data
);
throw
new
PayException
([
'cus'
=>
6
]);
throw
new
PayException
([
'cus'
=>
6
]);
}
}
...
...
application/services/pingxx/PingxxService.php
View file @
2867ef0b
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Services\pingxx
;
namespace
App\Services\pingxx
;
use
Api\PhpUtils\Log\FileLog
;
use
Pingpp\Order
;
use
Pingpp\Order
;
use
Pingpp\Pingpp
;
use
Pingpp\Pingpp
;
use
Pingpp\OrderRefund
;
use
Pingpp\OrderRefund
;
...
@@ -42,7 +43,7 @@ class PingxxService
...
@@ -42,7 +43,7 @@ class PingxxService
try
{
try
{
Logger
::
info
(
'退款订单发起'
,
$refundData
);
FileLog
::
info
(
'ping++:'
.
'退款订单发起'
,
json_encode
(
$refundData
)
);
$royalty_users
=
[];
$royalty_users
=
[];
$ret
=
OrderRefund
::
create
(
$ret
=
OrderRefund
::
create
(
...
@@ -56,9 +57,9 @@ class PingxxService
...
@@ -56,9 +57,9 @@ class PingxxService
]
]
);
);
Logger
::
info
(
'退款订单返回'
,
[
'res'
=>
$ret
]
);
FileLog
::
info
(
'ping++:'
.
'退款订单返回'
,
json_encode
([
'res'
=>
$ret
])
);
$respose
=
json_decode
(
$ret
,
true
);
$respo
n
se
=
json_decode
(
$ret
,
true
);
return
$respose
[
'data'
];
return
$respo
n
se
[
'data'
];
/*
/*
{
{
...
@@ -107,9 +108,9 @@ class PingxxService
...
@@ -107,9 +108,9 @@ class PingxxService
*/
*/
public
function
getRefund
(
$orderId
,
$refundId
)
{
public
function
getRefund
(
$orderId
,
$refundId
)
{
try
{
try
{
Logger
::
info
(
'退款查询发起'
,
[
'orderId'
=>
$orderId
,
'refundId'
=>
$refundId
]
);
FileLog
::
info
(
'ping++:'
.
'退款查询发起'
,
json_encode
([
'orderId'
=>
$orderId
,
'refundId'
=>
$refundId
])
);
$ret
=
OrderRefund
::
retrieve
(
$orderId
,
$refundId
);
$ret
=
OrderRefund
::
retrieve
(
$orderId
,
$refundId
);
Logger
::
info
(
'退款查询返回'
,
[
'res'
=>
$ret
]
);
FileLog
::
info
(
'ping++:'
.
'退款查询返回'
,
json_encode
([
'res'
=>
$ret
])
);
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
@@ -130,7 +131,8 @@ class PingxxService
...
@@ -130,7 +131,8 @@ class PingxxService
*/
*/
public
function
createOrder
(
$order
,
$metadata
)
{
public
function
createOrder
(
$order
,
$metadata
)
{
try
{
try
{
Logger
::
info
(
'创建订单发起'
,
$order
);
FileLog
::
info
(
'ping++:'
.
'创建订单发起'
,
json_encode
(
$order
));
$royalty_users
=
[];
$royalty_users
=
[];
$ret
=
Order
::
create
(
$ret
=
Order
::
create
(
[
[
...
@@ -148,7 +150,7 @@ class PingxxService
...
@@ -148,7 +150,7 @@ class PingxxService
]
]
);
);
Logger
::
info
(
'创建订单返回'
,
[
'res'
=>
$ret
]
);
FileLog
::
info
(
'ping++:'
.
'创建订单返回'
,
json_encode
([
'res'
=>
$ret
])
);
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
@@ -170,10 +172,10 @@ class PingxxService
...
@@ -170,10 +172,10 @@ class PingxxService
public
function
getOrder
(
$orderId
)
{
public
function
getOrder
(
$orderId
)
{
try
{
try
{
Logger
::
info
(
'查询订单发起'
,
[
'orderId'
=>
$orderId
]
);
FileLog
::
info
(
'ping++:'
.
'查询订单发起'
,
json_encode
([
'orderId'
=>
$orderId
])
);
$ret
=
Order
::
retrieve
(
$orderId
);
$ret
=
Order
::
retrieve
(
$orderId
);
Logger
::
info
(
'查询订单返回'
,
[
'res'
=>
$ret
]
);
FileLog
::
info
(
'ping++:'
.
'查询订单返回'
,
json_encode
([
'res'
=>
$ret
])
);
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
...
application/services/refund/RefundService.php
View file @
2867ef0b
...
@@ -36,6 +36,10 @@ class RefundService
...
@@ -36,6 +36,10 @@ class RefundService
throw
new
RefundException
([
'cus'
=>
1
]);
throw
new
RefundException
([
'cus'
=>
1
]);
}
}
if
(
empty
(
$ret
[
'result'
]))
{
throw
new
RefundException
([
'cus'
=>
1
]);
}
$order_item
=
$ret
[
'result'
];
$order_item
=
$ret
[
'result'
];
$where
=
[
$where
=
[
'order_item_id'
=>
$order_item_id
,
'order_item_id'
=>
$order_item_id
,
...
@@ -78,7 +82,6 @@ class RefundService
...
@@ -78,7 +82,6 @@ class RefundService
public
function
call_back
(
$data
)
{
public
function
call_back
(
$data
)
{
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
Logger
::
error
(
'回调参数错误:'
,
$data
);
throw
new
RefundException
([
'cus'
=>
6
]);
throw
new
RefundException
([
'cus'
=>
6
]);
}
}
...
...
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