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
4de1c466
Commit
4de1c466
authored
Jul 10, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 1. 调整发号器必须整数,2. 增加ping++订单支付
parent
f4eeef64
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
13 deletions
+60
-13
PayException.php
application/exception/custom/PayException.php
+1
-0
Sdk.php
application/library/Helpers/Sdk.php
+1
-1
Callback.php
application/modules/Pay/controllers/Callback.php
+0
-2
PayService.php
application/services/pay/PayService.php
+20
-3
PingxxService.php
application/services/pingxx/PingxxService.php
+37
-7
RefundService.php
application/services/refund/RefundService.php
+1
-0
No files found.
application/exception/custom/PayException.php
View file @
4de1c466
...
@@ -24,5 +24,6 @@ class PayException extends BaseException
...
@@ -24,5 +24,6 @@ class PayException extends BaseException
12
=>
'订单不存在,请核对'
,
12
=>
'订单不存在,请核对'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
14
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
14
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
15
=>
'支付订单金额与实际支付金额不等,请管理员关注'
,
];
];
}
}
application/library/Helpers/Sdk.php
View file @
4de1c466
...
@@ -28,7 +28,7 @@ class Sdk {
...
@@ -28,7 +28,7 @@ class Sdk {
*/
*/
$data
=
(
new
Request
())
->
post
(
$url
,
$params
,
2000
,
'json'
);
$data
=
(
new
Request
())
->
post
(
$url
,
$params
,
2000
,
'json'
);
FileLog
::
info
(
'sdk_call:'
.
'services return'
,
json_encode
([
'url'
=>
$url
,
$headers
,
'req'
=>
$params
,
'res'
=>
$data
]));
FileLog
::
info
(
'sdk_call:'
.
'services return'
,
json_encode
([
'url'
=>
$url
,
$headers
,
'req'
=>
$params
,
'res'
=>
$data
]
,
JSON_UNESCAPED_UNICODE
));
/*
/*
[
[
"http_code"=> 200,
"http_code"=> 200,
...
...
application/modules/Pay/controllers/Callback.php
View file @
4de1c466
...
@@ -42,11 +42,9 @@ class CallbackController extends Base
...
@@ -42,11 +42,9 @@ class CallbackController extends Base
}
}
$ret
=
$paySrv
->
call_back
(
$data
);
$ret
=
$paySrv
->
call_back
(
$data
);
$this
->
success
([
'result'
=>
$ret
]);
$this
->
success
([
'result'
=>
$ret
]);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
http_response_code
(
500
);
$this
->
failed
(
'500'
,
$e
->
getMessage
());
$this
->
failed
(
'500'
,
$e
->
getMessage
());
}
}
}
}
...
...
application/services/pay/PayService.php
View file @
4de1c466
...
@@ -120,7 +120,19 @@ class PayService
...
@@ -120,7 +120,19 @@ class PayService
$ret
[
'exist'
]
=
true
;
$ret
[
'exist'
]
=
true
;
}
}
return
$ret
;
// 创建支付单
$payment
=
[
'charge_order_no'
=>
$order
[
'pay_order_id'
],
'charge_amount'
=>
$order
[
'payment'
],
'channel'
=>
'wx'
,
];
$pay
=
PingxxService
::
getInstance
()
->
pay
(
$ret
[
'id'
],
$payment
);
if
(
!
empty
(
$pay
[
'error'
]))
{
throw
new
\Exception
(
$pay
[
'error'
][
'message'
],
'2001'
);
}
return
$pay
;
}
}
/**
/**
...
@@ -165,6 +177,10 @@ class PayService
...
@@ -165,6 +177,10 @@ class PayService
return
[
'pay_order_id'
=>
$pay_order_id
];
return
[
'pay_order_id'
=>
$pay_order_id
];
}
}
if
(
$pay_order
[
'pay_amount'
]
!=
$object
[
'actual_amount'
])
{
throw
new
PayException
([
'cus'
=>
15
]);
}
//获取订单 + 子单 + 分销信息
//获取订单 + 子单 + 分销信息
$ret
=
OrderService
::
getFullOrderData
(
$pay_order
[
'order_id'
],
$pay_order
[
'user_id'
]);
$ret
=
OrderService
::
getFullOrderData
(
$pay_order
[
'order_id'
],
$pay_order
[
'user_id'
]);
if
(
empty
(
$ret
[
'result'
][
'order_info'
]))
{
if
(
empty
(
$ret
[
'result'
][
'order_info'
]))
{
...
@@ -272,7 +288,7 @@ class PayService
...
@@ -272,7 +288,7 @@ class PayService
],
[
'order_item_id'
=>
$order_item_id
,
'can_notify_account'
=>
1
]);
],
[
'order_item_id'
=>
$order_item_id
,
'can_notify_account'
=>
1
]);
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
FileLog
::
error
(
'wallet: 钱包同步失败'
,
json_encode
(
$wallet_list
),
$e
);
FileLog
::
error
(
'wallet: 钱包同步失败'
,
json_encode
(
$wallet_list
,
JSON_UNESCAPED_UNICODE
),
$e
);
//补偿处理
//补偿处理
PayOrderItem
::
update
([
PayOrderItem
::
update
([
'notify_account_status'
=>
0
,
'notify_account_status'
=>
0
,
...
@@ -486,7 +502,7 @@ class PayService
...
@@ -486,7 +502,7 @@ class PayService
$log_string
=
json_encode
([
$log_string
=
json_encode
([
'life_account_id'
=>
$this
->
order_info
[
'life_account_id'
],
'life_account_id'
=>
$this
->
order_info
[
'life_account_id'
],
'ret'
=>
$ret
,
'ret'
=>
$ret
,
]);
]
,
JSON_UNESCAPED_UNICODE
);
FileLog
::
error
(
'pay:'
,
'获取生活号管理员失败'
,
$log_string
);
FileLog
::
error
(
'pay:'
,
'获取生活号管理员失败'
,
$log_string
);
throw
new
PayException
([
'cus'
=>
13
]);
throw
new
PayException
([
'cus'
=>
13
]);
...
@@ -595,6 +611,7 @@ class PayService
...
@@ -595,6 +611,7 @@ class PayService
private
function
get_idgen_id
(
$number
,
$count
=
1
)
private
function
get_idgen_id
(
$number
,
$count
=
1
)
{
{
$number
=
intval
(
$number
);
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
"55c768"
,
"type"
=>
"55c768"
,
'number'
=>
$number
,
'number'
=>
$number
,
...
...
application/services/pingxx/PingxxService.php
View file @
4de1c466
...
@@ -43,7 +43,7 @@ class PingxxService
...
@@ -43,7 +43,7 @@ class PingxxService
try
{
try
{
FileLog
::
info
(
'ping++:'
.
'退款订单发起'
,
json_encode
(
$refundData
));
FileLog
::
info
(
'ping++:'
.
'退款订单发起'
,
json_encode
(
$refundData
,
JSON_UNESCAPED_UNICODE
));
$royalty_users
=
[];
$royalty_users
=
[];
$ret
=
OrderRefund
::
create
(
$ret
=
OrderRefund
::
create
(
...
@@ -56,7 +56,7 @@ class PingxxService
...
@@ -56,7 +56,7 @@ class PingxxService
'refund_mode'
=>
'to_source'
,
//退款模式。原路退回:to_source,退至余额:to_balance。默认为原路返回。
'refund_mode'
=>
'to_source'
,
//退款模式。原路退回:to_source,退至余额:to_balance。默认为原路返回。
]
]
);
);
FileLog
::
info
(
'ping++:'
.
'退款订单返回'
,
json_encode
([
'res'
=>
$ret
]));
FileLog
::
info
(
'ping++:'
.
'退款订单返回'
,
json_encode
([
'res'
=>
$ret
]
,
JSON_UNESCAPED_UNICODE
));
$response
=
json_decode
(
$ret
,
true
);
$response
=
json_decode
(
$ret
,
true
);
return
$response
;
return
$response
;
...
@@ -83,9 +83,9 @@ class PingxxService
...
@@ -83,9 +83,9 @@ class PingxxService
*/
*/
public
function
getRefund
(
$orderId
,
$refundId
)
{
public
function
getRefund
(
$orderId
,
$refundId
)
{
try
{
try
{
FileLog
::
info
(
'ping++:'
.
'退款查询发起'
,
json_encode
([
'orderId'
=>
$orderId
,
'refundId'
=>
$refundId
]));
FileLog
::
info
(
'ping++:'
.
'退款查询发起'
,
json_encode
([
'orderId'
=>
$orderId
,
'refundId'
=>
$refundId
]
,
JSON_UNESCAPED_UNICODE
));
$ret
=
OrderRefund
::
retrieve
(
$orderId
,
$refundId
);
$ret
=
OrderRefund
::
retrieve
(
$orderId
,
$refundId
);
FileLog
::
info
(
'ping++:'
.
'退款查询返回'
,
json_encode
([
'res'
=>
$ret
]));
FileLog
::
info
(
'ping++:'
.
'退款查询返回'
,
json_encode
([
'res'
=>
$ret
]
,
JSON_UNESCAPED_UNICODE
));
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
@@ -111,7 +111,7 @@ class PingxxService
...
@@ -111,7 +111,7 @@ class PingxxService
public
function
createOrder
(
$order
,
$metadata
)
{
public
function
createOrder
(
$order
,
$metadata
)
{
try
{
try
{
FileLog
::
info
(
'ping++:'
.
'创建订单发起'
,
json_encode
(
$order
));
FileLog
::
info
(
'ping++:'
.
'创建订单发起'
,
json_encode
(
$order
,
JSON_UNESCAPED_UNICODE
));
$royalty_users
=
[];
$royalty_users
=
[];
$ret
=
Order
::
create
(
$ret
=
Order
::
create
(
[
[
...
@@ -129,7 +129,7 @@ class PingxxService
...
@@ -129,7 +129,7 @@ class PingxxService
]
]
);
);
FileLog
::
info
(
'ping++:'
.
'创建订单返回'
,
json_encode
([
'res'
=>
$ret
]));
FileLog
::
info
(
'ping++:'
.
'创建订单返回'
,
json_encode
([
'res'
=>
$ret
]
,
JSON_UNESCAPED_UNICODE
));
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
@@ -157,6 +157,36 @@ class PingxxService
...
@@ -157,6 +157,36 @@ class PingxxService
}
}
}
}
public
function
pay
(
$orderId
,
$pay
)
{
$params
=
[
'charge_order_no'
=>
substr
(
md5
(
time
()),
0
,
10
),
'charge_amount'
=>
100
,
'channel'
=>
'alipay_qr'
,
];
try
{
FileLog
::
info
(
'ping++:'
.
'订单pay发起'
,
json_encode
(
$pay
,
JSON_UNESCAPED_UNICODE
));
$ret
=
Order
::
pay
(
$orderId
,
$pay
);
FileLog
::
info
(
'ping++:'
.
'订单pay返回'
,
json_encode
([
'res'
=>
$ret
],
JSON_UNESCAPED_UNICODE
));
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
}
catch
(
\Pingpp\Error\Base
$e
)
{
// 捕获报错信息
if
(
$e
->
getHttpStatus
()
!=
null
)
{
return
json_decode
(
$e
->
getHttpBody
(),
true
);
}
else
{
return
[
'error'
=>
[
'message'
=>
$e
->
getMessage
()],
'type'
=>
'http error'
,
];
}
}
}
/**
/**
* @param $orderId
* @param $orderId
* 订单查询
* 订单查询
...
@@ -167,7 +197,7 @@ class PingxxService
...
@@ -167,7 +197,7 @@ class PingxxService
FileLog
::
info
(
'ping++:'
.
'查询订单发起'
,
json_encode
([
'orderId'
=>
$orderId
]));
FileLog
::
info
(
'ping++:'
.
'查询订单发起'
,
json_encode
([
'orderId'
=>
$orderId
]));
$ret
=
Order
::
retrieve
(
$orderId
);
$ret
=
Order
::
retrieve
(
$orderId
);
FileLog
::
info
(
'ping++:'
.
'查询订单返回'
,
json_encode
([
'res'
=>
$ret
]));
FileLog
::
info
(
'ping++:'
.
'查询订单返回'
,
json_encode
([
'res'
=>
$ret
]
,
JSON_UNESCAPED_UNICODE
));
$respose
=
json_decode
(
$ret
,
true
);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
return
$respose
;
...
...
application/services/refund/RefundService.php
View file @
4de1c466
...
@@ -247,6 +247,7 @@ class RefundService
...
@@ -247,6 +247,7 @@ class RefundService
private
function
get_idgen_id
(
$number
,
$count
=
1
)
private
function
get_idgen_id
(
$number
,
$count
=
1
)
{
{
$number
=
intval
(
$number
);
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
"55c768"
,
"type"
=>
"55c768"
,
'number'
=>
$number
,
'number'
=>
$number
,
...
...
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