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
a963c378
Commit
a963c378
authored
Jul 04, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: init post
parent
9b9c9981
Changes
32
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
847 additions
and
1811 deletions
+847
-1811
Index.php
application/controllers/Index.php
+18
-1
Code.php
application/exception/custom/Code.php
+2
-0
CodeSpecialException.php
application/exception/custom/CodeSpecialException.php
+31
-0
OrderException.php
application/exception/custom/OrderException.php
+22
-0
PayException.php
application/exception/custom/PayException.php
+3
-2
RefundException.php
application/exception/custom/RefundException.php
+1
-0
WalletException.php
application/exception/custom/WalletException.php
+22
-0
Sdk.php
application/library/Helpers/Sdk.php
+35
-0
helper.php
application/library/helper.php
+1
-1
Dictionary.php
application/models/Dictionary.php
+3
-0
PayOrder.php
application/models/order/mysql/PayOrder.php
+0
-1
PayOrderItem.php
application/models/order/mysql/PayOrderItem.php
+23
-0
Account.php
application/modules/Pay/controllers/Account.php
+0
-250
Callback.php
application/modules/Pay/controllers/Callback.php
+47
-0
Order.php
application/modules/Pay/controllers/Order.php
+47
-0
Recruit.php
application/modules/Pay/controllers/Recruit.php
+0
-147
Mongo.php
application/modules/Test/controllers/Mongo.php
+0
-55
Mysql.php
application/modules/Test/controllers/Mysql.php
+0
-85
Request.php
application/modules/Test/controllers/Request.php
+0
-90
Session.php
application/modules/Test/controllers/Session.php
+0
-216
Test.php
application/modules/Test/controllers/Test.php
+0
-13
Ttt.php
application/modules/Test/controllers/Ttt.php
+0
-590
Hook.php
application/plugins/Hook.php
+1
-1
MongoService.php
application/services/demo/MongoService.php
+0
-75
MysqlService.php
application/services/demo/MysqlService.php
+0
-130
OrderService.php
application/services/order/OrderService.php
+23
-64
PayService.php
application/services/pay/PayService.php
+222
-40
PingxxService.php
application/services/pingxx/PingxxService.php
+192
-0
RefundService.php
application/services/refund/RefundService.php
+119
-50
WalletService.php
application/services/wallet/WalletService.php
+29
-0
demo.php
public/demo.php
+4
-0
index.php
public/index.php
+2
-0
No files found.
application/controllers/Index.php
View file @
a963c378
<?php
<?php
use
Api\PhpServices\Idgen\Idgen
;
use
Yaf\Controller_Abstract
;
use
Yaf\Controller_Abstract
;
/**
/**
...
@@ -10,6 +11,22 @@ class IndexController extends Controller_Abstract
...
@@ -10,6 +11,22 @@ class IndexController extends Controller_Abstract
use
\Helpers\ApiResponse
;
use
\Helpers\ApiResponse
;
public
function
IndexAction
()
{
public
function
IndexAction
()
{
$this
->
success
();
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
"55c768"
,
'number'
=>
12
,
"count"
=>
1
]]);
$id
=
$res
[
'id_datetime'
][
'55c768'
]
??
[];
$this
->
success
([
'id'
=>
$id
]);
}
public
function
orderAction
()
{
$ret
=
[
'id'
=>
'aa'
,
];
$this
->
success
(
$ret
);
}
}
}
}
application/exception/custom/Code.php
View file @
a963c378
...
@@ -13,4 +13,6 @@ class Code
...
@@ -13,4 +13,6 @@ class Code
{
{
const
PAY
=
101000
;
const
PAY
=
101000
;
const
REFUND
=
102000
;
const
REFUND
=
102000
;
const
ORDER
=
103000
;
const
WALLET
=
104000
;
}
}
\ No newline at end of file
application/exception/custom/CodeSpecialException.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
/**
* Class TestException
* @package App\Exception\custom
*/
class
CodeSpecialException
extends
BaseException
{
public
function
__construct
(
$err
,
$re_msg
=
""
)
{
$params
=
[];
$code
=
\Yaconf
::
get
(
"errorcode.common.code."
.
$err
);
$msg
=
$re_msg
??
\Yaconf
::
get
(
"errorcode.common.msg."
.
$err
);
if
(
strlen
(
$code
)
&&
strlen
(
$msg
)){
$params
=
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
parent
::
__construct
(
$params
);
}
}
\ No newline at end of file
application/exception/custom/OrderException.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
OrderException
extends
BaseException
{
protected
$base_code
=
Code
::
ORDER
;
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
1
=>
'订单信息不存在,请核对'
,
2
=>
'退款已经成功操作,请核对'
,
3
=>
'退款进行中,请稍等'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
5
=>
'该订单不允许退款,请核对'
,
6
=>
'该退款单核对ping++状态为未支付,请稍后重试!'
,
];
}
application/exception/custom/PayException.php
View file @
a963c378
...
@@ -11,8 +11,9 @@ class PayException extends BaseException
...
@@ -11,8 +11,9 @@ class PayException extends BaseException
protected
$base_code
=
Code
::
PAY
;
protected
$base_code
=
Code
::
PAY
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'
用户已通过个人认证,无需重复认证
'
,
0
=>
'
系统错误,请稍收重试
'
,
1
=>
'企业已通过认证,无需重复认证
'
,
3
=>
'该订单已经支付,请刷新确认
'
,
4
=>
'费率计算错误,费率分母为0'
,
4
=>
'费率计算错误,费率分母为0'
,
5
=>
'支付回调失败,请核对订单'
,
];
];
}
}
application/exception/custom/RefundException.php
View file @
a963c378
...
@@ -17,5 +17,6 @@ class RefundException extends BaseException
...
@@ -17,5 +17,6 @@ class RefundException extends BaseException
3
=>
'退款进行中,请稍等'
,
3
=>
'退款进行中,请稍等'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
5
=>
'该订单不允许退款,请核对'
,
5
=>
'该订单不允许退款,请核对'
,
6
=>
'该退款单核对ping++状态为未支付,请稍后重试!'
,
];
];
}
}
application/exception/custom/WalletException.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
WalletException
extends
BaseException
{
protected
$base_code
=
Code
::
WALLET
;
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
1
=>
'订单信息不存在,请核对'
,
2
=>
'退款已经成功操作,请核对'
,
3
=>
'退款进行中,请稍等'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
5
=>
'该订单不允许退款,请核对'
,
6
=>
'该退款单核对ping++状态为未支付,请稍后重试!'
,
];
}
application/library/Helpers/Sdk.php
0 → 100644
View file @
a963c378
<?php
namespace
Helpers
;
use
Helpers\Logger
;
use
Api\PhpUtils\Common\TimeOut
;
/**
* Sdk 获取接口
*/
class
Sdk
{
/**
* @param $current_amount
* @param $total_amount
* @param $cleared_amount
* @param $total_tip
* @param $cleared_tip
* 计算微信手续费公式,计算单位是分
*/
public
static
function
call
(
$url
,
$params
,
$headers
=
[])
{
$header
=
[
'X-REQUEST-ID'
=>
Logger
::
getTraceId
(),
'Content-type'
=>
'application/json'
,
];
$headers
=
array_merge
(
$headers
,
$header
);
Logger
::
info
(
'api request'
,
[
'url'
=>
$url
,
'params'
=>
$params
]);
$data
=
(
new
TimeOut
())
->
runPost
(
$url
,
$params
,
$headers
);
Logger
::
info
(
'api request'
,
[
'ret'
=>
$data
]);
return
$data
;
}
}
\ No newline at end of file
application/library/helper.php
View file @
a963c378
...
@@ -16,7 +16,7 @@ if (!function_exists('config')) {
...
@@ -16,7 +16,7 @@ if (!function_exists('config')) {
*/
*/
function
config
(
$file
,
$param
=
''
){
function
config
(
$file
,
$param
=
''
){
if
(
empty
(
$file
)
||
!
file_exists
(
ROOT_PATH
.
"/yaconf/"
.
$file
.
".ini"
)){
if
(
empty
(
$file
)
||
!
file_exists
(
ROOT_PATH
.
"/yaconf/"
.
$file
.
".ini"
)){
return
""
;
//
return "";
}
}
$env
=
Application
::
app
()
->
environ
()
??
"test"
;
$env
=
Application
::
app
()
->
environ
()
??
"test"
;
...
...
application/models/Dictionary.php
View file @
a963c378
...
@@ -46,4 +46,7 @@ class Dictionary
...
@@ -46,4 +46,7 @@ class Dictionary
public
const
REFUND_ORDER_STATUS_SEND
=
1
;
//待确认
public
const
REFUND_ORDER_STATUS_SEND
=
1
;
//待确认
public
const
REFUND_ORDER_STATUS_OK
=
2
;
//已退款
public
const
REFUND_ORDER_STATUS_OK
=
2
;
//已退款
public
const
SEND_ACCOUNT_STATUS_UNDO
=
0
;
//未通知
public
const
SEND_ACCOUNT_STATUS_DONE
=
1
;
//已通知
}
}
application/models/order/mysql/PayOrder.php
View file @
a963c378
...
@@ -42,7 +42,6 @@ class PayOrder extends MysqlBase
...
@@ -42,7 +42,6 @@ class PayOrder extends MysqlBase
)
->
fetch
();
)
->
fetch
();
if
(
empty
(
$order
))
{
if
(
empty
(
$order
))
{
$new
[
'order_id'
]
=
$order_id
;
$link
->
insert
(
self
::
getTableName
(),
$pay_order
);
$link
->
insert
(
self
::
getTableName
(),
$pay_order
);
$order
=
$link
->
query
(
$order
=
$link
->
query
(
$sql
,
[
$sql
,
[
...
...
application/models/order/mysql/PayOrderItem.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Models\order\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
PayOrderItem
extends
MysqlBase
{
protected
static
$write
;
protected
static
$read
;
protected
static
$db_config_index
=
'metro'
;
protected
function
getTableName
()
{
return
'pay_order_item'
;
}
protected
function
getPKey
()
{
return
'pay_order_item_id'
;
}
}
application/modules/Pay/controllers/Account.php
deleted
100644 → 0
View file @
9b9c9981
This diff is collapsed.
Click to expand it.
application/modules/Pay/controllers/Callback.php
0 → 100644
View file @
a963c378
<?php
use
App\Base\Base
;
use
App\Services\pay\PayService
;
use
App\Services\refund\RefundService
;
class
CallbackController
extends
Base
{
/**
* 创建支付订单,返回前端ping++的支付信息
*/
public
function
payAction
()
{
try
{
$raw_data
=
file_get_contents
(
'php://input'
);
$paySrv
=
new
PayService
();
$ret
=
$paySrv
->
call_back
(
$raw_data
);
$this
->
success
([
'result'
=>
$ret
]);
}
catch
(
Exception
$e
)
{
http_response_code
(
500
);
$this
->
failed
(
'500'
);
}
}
public
function
refundAction
()
{
try
{
$raw_data
=
file_get_contents
(
'php://input'
);
$refundSrv
=
new
RefundService
();
$ret
=
$refundSrv
->
call_back
(
$raw_data
);
$this
->
success
([
'result'
=>
$ret
]);
}
catch
(
Exception
$e
)
{
http_response_code
(
500
);
$this
->
failed
(
'500'
);
}
}
}
application/modules/Pay/controllers/Order.php
0 → 100644
View file @
a963c378
<?php
use
App\Base\Base
;
use
App\Services\pay\PayService
;
use
App\Services\refund\RefundService
;
class
OrderController
extends
Base
{
/**
* 创建支付订单,返回前端ping++的支付信息
*/
public
function
payAction
()
{
$params
=
$this
->
params
;
$user_id
=
$params
[
'user_id'
];
$order_id
=
$params
[
'order_id'
];
$paySrv
=
new
PayService
();
$ret
=
$paySrv
->
do_pay
(
$order_id
,
$user_id
);
$this
->
success
([
'result'
=>
$ret
]);
}
public
function
refundAction
()
{
$params
=
$this
->
params
;
$user_id
=
$params
[
'user_id'
];
$order_item_id
=
$params
[
'order_item_id'
];
$refundSrv
=
new
RefundService
();
$ret
=
$refundSrv
->
do_refund
(
$order_item_id
,
$user_id
);
$this
->
success
([
'result'
=>
$ret
]);
}
public
function
write_offAction
()
{
$params
=
$this
->
params
;
$user_id
=
$params
[
'user_id'
];
$order_item_id
=
$params
[
'order_item_id'
];
$refundSrv
=
new
PayService
();
$ret
=
$refundSrv
->
write_off
(
$order_item_id
,
$user_id
);
$this
->
success
([
'result'
=>
$ret
]);
}
}
application/modules/Pay/controllers/Recruit.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
use
App\Exception\custom\LifeAccountException
;
use
App\Models\auth\mysql\LifeAccount
;
use
App\Models\auth\mysql\Merchant
;
use
App\Services\lifeaccount\LifeAccountService
;
use
Validate\RecruitValidate
;
use
App\Models\auth\mysql\RecruitAccount
;
use
App\Exception\custom\DataException
;
use
App\Models\auth\mysql\EnterpriseAuthRecord
;
use
Api\PhpServices\JwUser\JwUser
;
class
RecruitController
extends
Base
{
/**
* 创建招聘个人生活号
*/
public
function
create_recruitAction
(){
// 验证参数
(
new
RecruitValidate
())
->
validate
();
$params
=
$this
->
params
;
$uid
=
$params
[
'ownerId'
];
$name
=
$params
[
'name'
];
if
(
!
isset
(
$uid
)
||
!
isset
(
$name
)){
//添加招聘表数据
$params
[
'lifeAccountId'
]
=
-
1
;
//uid、name为空 不具备创建生活号的条件
$recruit_id
=
RecruitAccount
::
insert
(
$params
);
if
(
!
$recruit_id
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
$this
->
success
([
'result'
=>
[
'life_account_id'
=>
-
1
]]);
}
// 查询是否有创建资格
if
(
!
LifeAccountService
::
permission
(
$uid
)[
'personal'
]){
throw
new
LifeAccountException
([
'cus'
=>
3
]);
}
try
{
RecruitAccount
::
beginTransaction
();
//创建未认证的生活号
$life_account_id
=
LifeAccountService
::
unauth_account
(
$uid
,
$name
,
0
,
'merchant-c'
);
if
(
!
$life_account_id
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
//添加招聘表数据
$recruit_id
=
RecruitAccount
::
insert
(
$params
);
if
(
!
$recruit_id
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
RecruitAccount
::
commit
();
}
catch
(
\Exception
$exception
)
{
RecruitAccount
::
rollback
();
throw
$exception
;
}
$this
->
success
([
'result'
=>
[
'life_account_id'
=>
$life_account_id
]]);
}
/**
* 更新招聘个人生活号
*/
public
function
update_recruitAction
(){
// 验证参数
(
new
RecruitValidate
())
->
scene
(
'ent'
)
->
validate
();
$params
=
$this
->
params
;
$uid
=
$params
[
'ownerId'
];
$res
=
RecruitAccount
::
update
(
$params
,
[
'ownerId'
=>
$uid
]);
if
(
$res
===
false
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
$this
->
success
();
}
/**
* 查看招聘个人生活号
*/
public
function
get_recruitAction
(){
// 验证参数
(
new
RecruitValidate
())
->
scene
(
'ent'
)
->
validate
();
$params
=
$this
->
params
;
$uid
=
$params
[
'ownerId'
];
$recruit_ret
=
RecruitAccount
::
get
(
'*'
,
[
'ownerId'
=>
$uid
]);
if
(
empty
(
$recruit_ret
))
{
throw
new
DataException
([
'cus'
=>
0
]);
}
foreach
(
$recruit_ret
as
$key
=>
$val
){
if
(
$val
===
'NULL'
){
unset
(
$recruit_ret
[
$key
]);
}
}
$this
->
success
([
'result'
=>
$recruit_ret
]);
}
/**
* 检测未绑定招聘个人生活号,并创建个人未认证生活号 并绑定
*/
public
function
check_recruitAction
(){
$recruit_ret
=
RecruitAccount
::
select
(
'*'
,
[
'lifeAccountId '
=>
0
]);
if
(
empty
(
$recruit_ret
))
{
throw
new
DataException
([
'cus'
=>
0
]);
}
foreach
(
$recruit_ret
as
$key
=>
$val
){
//获取简网用户信息
$jwUser
=
new
JwUser
();
$user_info
=
$jwUser
->
getUserByUserId
([
'user_id'
=>
$val
[
'ownerId'
]]);
$avatar
=
$user_info
[
'data'
][
'avatar'
]
??
'http://qn.jwshq.cn/profile_unknown_2019_1'
;
// 查询是否有创建资格
if
(
!
LifeAccountService
::
permission
(
$val
[
'ownerId'
])[
'personal'
]){
throw
new
LifeAccountException
([
'cus'
=>
3
]);
}
try
{
RecruitAccount
::
beginTransaction
();
//查询是否有重复的生活号名称,有重复的加一个随机数
$lifeInfo
=
LifeAccount
::
getRecord
([
'life_account_name'
=>
$val
[
'name'
]]);
if
(
!
empty
(
$lifeInfo
)){
$rand_num
=
mt_rand
(
0
,
99
);
$val
[
'name'
]
=
$val
[
'name'
]
.
$rand_num
;
}
//创建未认证的生活号
$life_account_id
=
LifeAccountService
::
unauth_account
(
$val
[
'ownerId'
],
$val
[
'name'
],
0
,
'batch'
,
$avatar
);
if
(
!
$life_account_id
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
//更新招聘表数据生活号ID
$res
=
RecruitAccount
::
update
([
'lifeAccountId'
=>
$life_account_id
],
[
'ownerId'
=>
$val
[
'ownerId'
]]);
if
(
$res
===
false
)
{
throw
new
DataException
([
'cus'
=>
1
]);
}
RecruitAccount
::
commit
();
}
catch
(
\Exception
$exception
)
{
RecruitAccount
::
rollback
();
throw
$exception
;
}
sleep
(
1
);
}
$this
->
success
([
'result'
=>
[
'life_account_id'
=>
$life_account_id
]]);
}
}
\ No newline at end of file
application/modules/Test/controllers/Mongo.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
use
App\Services\demo\MongoService
;
class
MongoController
extends
Base
{
public
function
addAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
addUser
();
var_dump
(
$ret
);
exit
;
}
public
function
addManyAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
addManyUser
();
var_dump
(
$ret
);
exit
;
}
public
function
deleteAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
deleteUser
();
var_dump
(
$ret
);
exit
;
}
public
function
updateAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
updateUser
();
var_dump
(
$ret
);
exit
;
}
public
function
getAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
getUser
();
var_dump
(
$ret
);
exit
;
}
public
function
getManyAction
()
{
$mongo_service
=
new
MongoService
();
$ret
=
$mongo_service
->
getManyUser
();
var_dump
(
$ret
);
exit
;
}
}
application/modules/Test/controllers/Mysql.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
use
App\Services\demo\MysqlService
;
class
MysqlController
extends
Base
{
public
function
addAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
addUser
();
var_dump
(
$ret
);
exit
;
}
public
function
addManyAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
addManyUser
();
var_dump
(
$ret
);
exit
;
}
public
function
deleteAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
deleteUser
();
var_dump
(
$ret
);
exit
;
}
public
function
updateAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
updateUser
();
var_dump
(
$ret
);
exit
;
}
public
function
getAction
()
{
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
getUser
();
var_dump
(
$ret
);
exit
;
}
public
function
getManyAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
getManyUser
();
var_dump
(
$ret
);
exit
;
}
public
function
countAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
countUser
();
var_dump
(
$ret
);
exit
;
}
public
function
maxAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
maxUser
();
var_dump
(
$ret
);
exit
;
}
public
function
minAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
minUser
();
var_dump
(
$ret
);
exit
;
}
public
function
avgAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
avgUser
();
var_dump
(
$ret
);
exit
;
}
public
function
sumAction
(){
$mysql_service
=
new
MysqlService
();
$ret
=
$mysql_service
->
sumUser
();
var_dump
(
$ret
);
exit
;
}
}
application/modules/Test/controllers/Request.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
use
Api\PhpUtils\Http\Request
;
class
RequestController
extends
Base
{
public
function
GetAction
()
{
$url
=
'http://10.103.17.132:8007/adserver/goodsAds'
;
$options
=
[
'query'
=>
[
'docIdList'
=>
'0SQ0d3dH'
,
'appId'
=>
'pro'
,
'platform'
=>
0
],
'timeout'
=>
0.5
//自定义超时秒数,覆盖默认值
];
$request
=
new
Request
();
$ret
=
$request
->
get
(
$url
,
$options
);
var_dump
(
$ret
);
exit
;
}
public
function
PostAction
(){
$url
=
'http://sso.dengwei4378.com/api/master/getInfoByMasterName'
;
$options
=
[
'form_params'
=>
[
"masterName"
=>
'dengwei4378'
,
"system"
=>
'rbac'
],
'timeout'
=>
1
//自定义超时秒数,覆盖默认值
];
$request
=
new
Request
();
$post_ret
=
$request
->
post
(
$url
,
$options
);
var_dump
(
$post_ret
);
exit
;
}
/**
* 并发GET
*/
public
function
ConGetAction
(){
$params
=
[
0
=>
[
'url'
=>
'http://sso.dengwei4378.com'
,
'timeout'
=>
3
//自定义超时秒数,覆盖默认值
],
1
=>
[
'url'
=>
'https://api.github.com/'
,
'timeout'
=>
3
//自定义超时秒数,覆盖默认值
],
];
$request
=
new
Request
();
$ret
=
$request
->
concurrencyGet
(
$params
);
var_dump
(
$ret
);
exit
;
}
public
function
ConPostAction
(){
$params
=
[
0
=>
[
'url'
=>
'http://lock-screen-push.int.yidian-inc.com/lock-screen/list'
,
'headers'
=>
[
'Content-type'
=>
'application/json'
,
'User-Agent'
=>
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3100.0 Safari/537.36'
],
'json'
=>
[
//json格式
"bizid"
=>
"YDZX"
,
"uid"
=>
"765073697"
,
"platform"
=>
"1"
,
"appid"
=>
"hipu"
],
'timeout'
=>
0.1
//自定义超时秒数,覆盖默认值
],
1
=>
[
'url'
=>
'http://sso.dengwei4378.com/api/master/getInfoByMasterName'
,
'form_params'
=>
[
//表单格式
"masterName"
=>
'dengwei4378'
,
"system"
=>
'rbac'
],
'timeout'
=>
0.2
//自定义超时秒数,覆盖默认值
],
];
$request
=
new
Request
();
$ret
=
$request
->
concurrencyPost
(
$params
);
var_dump
(
$ret
);
exit
;
}
}
application/modules/Test/controllers/Session.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
use
Helpers\Aes
;
use
Api\PhpUtils\Http\Request
;
use
Api\PhpServices\Session\SessionManager
;
use
App\Exception\BaseException
;
class
SessionController
extends
Base
{
public
function
StartAction
()
{
// $key = 'asdfasdfasdfasdf';
// $iv = 'fdsafdsafdsafdsa';
// $salt = "12341/5";
// var_dump(base64_encode($salt));
// var_dump(strtolower(str_replace(array('+','/','='), array(''), base64_encode($salt))));
// var_dump($data = openssl_encrypt($salt, "AES-128-CBC", $key, 0, $iv));
// var_dump(openssl_decrypt($data, "AES-128-CBC", $key, 0, $iv));
// exit;
// $result = (new Request())->get('http://10.126.171.30:18080/topom', [], 1);
// // $proxy = $result['stats']['proxy'];
// $server = $result['stats']['group']['models'];
// $arr = [];
// foreach ($server as $item) {
// $arr[] = $item['servers'][1]['server'];
// }
// print_r($arr);
// exit;
// print_r(\Yaconf::get('interface.test.service'));exit;
// echo $s = '{'.str_replace(array('+','/','='), array('-','_',''), base64_encode('12345')).'}';
// exit;
// $s = json_decode(json_encode(['a' =>'{MTIzNDU}e3eec597a5a3f9420b445c89d38a6fbc7c']),true);
// print_r($s);exit;
// phpinfo();exit;
// $key = 'interface.test.service.session.get';
// echo \Yaconf::get($key);
// exit;
$ret
=
SessionManager
::
start
();
// print_r($_SERVER);
// print_r($_COOKIE);
var_dump
(
$ret
);
print_r
(
$_SESSION
);
// $ret1 = SessionManager::destroy();
// // print_r($_SERVER);
// // print_r($_COOKIE);
// var_dump($ret1);
// print_r($_SESSION);
// var_dump($ret);
}
public
function
CreateAction
()
{
$ret
=
SessionManager
::
set
(
'metro'
,
'12345'
,
true
,
[
'a'
=>
'aaa'
,
'b'
=>
'bbb'
,
'c'
=>
'ccc'
,
'd'
=>
'ddd'
],
1
);
var_dump
(
$ret
);
print_r
(
$_SESSION
);
exit
;
}
public
function
DestroyAction
()
{
$ret
=
SessionManager
::
destroy
();
// print_r($_SERVER);
// print_r($_COOKIE);
var_dump
(
$ret
);
print_r
(
$_SESSION
);
}
public
function
GetAction
()
{
print_r
(
$request
=
$this
->
getRequest
()
->
getRequest
());
$sessionid
=
$request
[
'sid'
]
??
'aedcc37ea232aade90037716ddab1debe6'
;
$url
=
$this
->
getBaseUri
()
.
'/get-session'
;
$query
=
[
'sessionid'
=>
$sessionid
];
// $query = ['sessionid' => 'jssionidtest'];
$result
=
(
new
Request
())
->
get
(
$url
,
$query
,
3000
);
print_r
(
$result
);
exit
;
if
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
==
0
)
{
return
true
;
}
return
false
;
}
public
function
SetAction
()
{
$url
=
$this
->
getBaseUri
()
.
'/set-session'
;
$sessionData
=
[
'id'
=>
123
,
'name'
=>
'test'
];
$params
=
[
'sessionid'
=>
'jssionidtest11'
,
'data'
=>
(
$sessionData
),
'expire'
=>
600
,
'key'
=>
'c071f6e5923a648a5ef88f32b6f738e1'
];
$result
=
(
new
Request
())
->
post
(
$url
,
$params
,
1000
,
'json'
);
print_r
(
$result
);
}
public
function
DelAction
()
{
$url
=
$this
->
getBaseUri
()
.
'/delete-session'
;
$query
=
[
'sessionid'
=>
[
'jssionidtest1'
,
'jssionidtest'
],
'key'
=>
'c071f6e5923a648a5ef88f32b6f738e1'
];
$result
=
(
new
Request
())
->
get
(
$url
,
$query
,
1000
);
print_r
(
$result
);
}
public
function
MgetAction
()
{
$url
=
$this
->
getBaseUri
()
.
'/get-many-session'
;
$query
=
[
'sessionid'
=>
[
'YPZQISU1Tjxg3wJLFWJmVA'
,
'E4vo3R5EfaPS-pnyDzia3Q'
]];
$result
=
(
new
Request
())
->
get
(
$url
,
$query
,
2000
);
print_r
(
$result
);
exit
;
$url
=
$this
->
getBaseUri
()
.
'/get-many-session'
;
$query
=
[
'sessionid'
=>
[
'jssionidtest2'
,
'jssionidtest1'
]];
$result
=
(
new
Request
())
->
get
(
$url
,
$query
,
2000
);
print_r
(
$result
);
exit
;
// $validSessionIds[] = 'a';
// $validSessionIds[] = 'b';
// $validSessionIds[] = 'c';
// echo $validSessionIds[rand(0, count($validSessionIds) - 1)];
// exit;
// // todo 请求接口读redis
// echo $url = $this->getBaseUri() . '/get-session1';
// $query = ['sessionid' => 'jssionidtest'];
// $result = (new Request())->get($url, $query, 1000);
// if (isset($result['code']) && $result['code'] == 0 && isset($result['result'])) {
// $data = $result['result'];
// print_r($data);
// }else {
// print_r($result);
// }
// exit;
// $r = \Api\PhpUtils\Common\IP::find('114.114.114.114');
// print_r($r);
// exit;
// $_SESSION['abc'] = 'ttt';
// echo $_SESSION['abc'];
// echo $_SESSION['abc'];
// echo $_SESSION['abc'];
// echo $_SESSION['abc'];
// exit;
// $abc = '123'. "\x7F" . 456;
// var_dump($abc);exit;//string(7) "123456" 不可见字任作为分隔符
// $a = base64_encode('6543211111dasfsdfasdf1111asdfasdfs1111');
// var_dump($a);
// var_dump(sha1($a));
// var_dump(substr(sha1($a), -2));
// $a = $a . substr(sha1($a), -2);
// var_dump($a);
// var_dump(substr($a, 0, -2));
// $a = substr($a, 0, -2);
// var_dump($a);
// var_dump(sha1($a));
// var_dump(substr(sha1($a), -2));
// exit;
// var_dump(strlen($a));
// var_dump($a);exit;
// var_dump($this->response);
// var_dump(Yaf\Dispatcher::getInstance()->getResponse());
// exit;
// $data = ['appid'=> 'appid', 'verison'=>'023200', 'reqid'=>'11adddddddfasdfasdfasdfasdfdsafwerqwersfasfasdvasdfsdfffs1', 'platform'=>'1', 'ts' => ceil(microtime(true) * 1000)];
// echo $sign = Aes::createSign($data);
// exit;
// $data = ['appid'=> 'appid', 'verison'=>'023200', 'reqid'=>'111', 'platform'=>'1'];
// $data['sign'] = 'l4lBCE3B_v-ODFeuoxFksl0IUY9ehBnjN_FtU3ESdrn_bMPDsEIxA8IUw0pDJ_kX06P6OOw23in46acBucgceSBE2Vx3Ew52w3FfmRn8IhE';
// $sign = Aes::checkSign($data);
// var_dump($sign);
// exit;
// $obj = new App\Models\User();
// print_r($obj->getUserData());//Array ( [name] => zhangsan [age] => 18 )
// exit;
// $http = $this->getRequest()->getRequest();
// var_dump($http);
// var_dump(file_get_contents("php://input"));
// var_dump($this->requestAll());yaf
// exit;
$res
=
[
"userid"
=>
'user'
,
"code"
=>
0
];
// print_r($this->failed(-1,'reason'));
$this
->
success
(
$res
);
}
/**
* get uri
* @return string
*/
public
function
getBaseUri
()
{
$env
=
\Yaf\Application
::
app
()
->
environ
()
??
"dev1"
;
if
(
$env
==
'product'
)
{
$this
->
baseUri
=
'http://a4.go2yd.com/Website/session'
;
}
elseif
(
$env
==
'dev'
)
{
$this
->
baseUri
=
'http://127.0.0.1/Website/session'
;
}
else
{
$this
->
baseUri
=
'http://a4-1.go2yd.com/Website/session'
;
}
return
$this
->
baseUri
;
}
}
\ No newline at end of file
application/modules/Test/controllers/Test.php
deleted
100644 → 0
View file @
9b9c9981
<?php
use
App\Base\Base
;
class
TestController
extends
Base
{
public
function
indexAction
()
{
$this
->
success
();
}
}
application/modules/Test/controllers/Ttt.php
deleted
100644 → 0
View file @
9b9c9981
This diff is collapsed.
Click to expand it.
application/plugins/Hook.php
View file @
a963c378
...
@@ -48,7 +48,7 @@ class Hook extends \Yaf\Plugin_Abstract {
...
@@ -48,7 +48,7 @@ class Hook extends \Yaf\Plugin_Abstract {
if
(
!
$_POST
&&
$request
->
isPost
()
if
(
!
$_POST
&&
$request
->
isPost
()
&&
$request
->
getServer
(
'CONTENT_TYPE'
)
==
'application/json'
)
{
&&
$request
->
getServer
(
'CONTENT_TYPE'
)
==
'application/json'
)
{
$jsonPost
=
file_get_contents
(
"php://input"
);
$jsonPost
=
file_get_contents
(
"php://input"
);
if
(
$jsonPost
)
{
if
(
false
&&
$jsonPost
)
{
$_POST
=
json_decode
(
$jsonPost
,
true
);
$_POST
=
json_decode
(
$jsonPost
,
true
);
$ini
=
ini_get
(
'request_order'
);
$ini
=
ini_get
(
'request_order'
);
if
(
$ini
)
{
if
(
$ini
)
{
...
...
application/services/demo/MongoService.php
deleted
100644 → 0
View file @
9b9c9981
<?php
namespace
App\Services\demo
;
use
App\Models\demo\mongo\User
;
class
MongoService
{
public
function
addUser
()
{
$user
=
User
::
getInstance
();
$data
=
[
'_id'
=>
4
,
'name'
=>
'dw04'
,
'mobile'
=>
'17701340004'
];
return
$user
->
add
(
$data
);
}
public
function
addManyUser
()
{
$user
=
User
::
getInstance
();
$data
=
[
[
'_id'
=>
5
,
'name'
=>
'dw05'
,
'mobile'
=>
'17701340005'
],
[
'_id'
=>
6
,
'name'
=>
'dw06'
,
'mobile'
=>
'17701340006'
]
];
return
$user
->
addMany
(
$data
);
}
public
function
deleteUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'name'
=>
'dw01'
];
return
$user
->
delete
(
$params
);
}
public
function
updateUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'name'
=>
'dw02'
];
$data
=
[
'mobile'
=>
'17701340002'
];
return
$user
->
update
(
$params
,
$data
);
}
public
function
getUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'name'
=>
'dw02'
];
return
$user
->
get
(
$params
);
}
public
function
getManyUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'name'
=>
'dw02'
];
return
$user
->
getMany
(
$params
);
}
}
application/services/demo/MysqlService.php
deleted
100644 → 0
View file @
9b9c9981
<?php
namespace
App\Services\demo
;
use
App\Models\demo\mysql\User
;
class
MysqlService
{
public
function
addUser
()
{
$user
=
User
::
getWriteInstance
();
$data
=
[
'name'
=>
'dw07'
,
'mobile'
=>
'17701340007'
];
return
$user
->
add
(
$data
);
}
public
function
addManyUser
()
{
$user
=
User
::
getWriteInstance
();
$data
=
[
[
'name'
=>
'dw08'
,
'mobile'
=>
'17701340008'
],
[
'name'
=>
'dw09'
,
'mobile'
=>
'17701340009'
]
];
return
$user
->
addMany
(
$data
);
}
public
function
deleteUser
()
{
$user
=
User
::
getWriteInstance
();
$params
=
[
'name'
=>
'dw08'
];
return
$user
->
delete
(
$params
);
}
public
function
updateUser
()
{
$user
=
User
::
getWriteInstance
();
$params
=
[
'name'
=>
'dw02'
];
$data
=
[
'mobile'
=>
'15030690002'
];
return
$user
->
update
(
$params
,
$data
);
}
public
function
getUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'name'
=>
'dw02'
];
$column
=
[
'name'
,
'mobile'
];
return
$user
->
get
(
$params
,
$column
);
}
public
function
getManyUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'id[>]'
=>
3
];
$column
=
[
'name'
,
'mobile'
];
return
$user
->
getMany
(
$params
,
$column
);
}
public
function
countUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'master_name'
=>
'dw04'
];
$column
=
'id'
;
return
$user
->
count
(
$params
,
$column
);
}
public
function
maxUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'id[>]'
=>
1
];
$column
=
'id'
;
return
$user
->
max
(
$params
,
$column
);
}
public
function
minUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'id[>]'
=>
1
];
$column
=
'id'
;
return
$user
->
min
(
$params
,
$column
);
}
public
function
avgUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'id[>]'
=>
1
];
$column
=
'id'
;
return
$user
->
avg
(
$params
,
$column
);
}
public
function
sumUser
()
{
$user
=
User
::
getInstance
();
$params
=
[
'id[>]'
=>
1
];
$column
=
'id'
;
return
$user
->
sum
(
$params
,
$column
);
}
}
application/services/order/OrderService.php
View file @
a963c378
...
@@ -3,83 +3,42 @@
...
@@ -3,83 +3,42 @@
namespace
App\Services\order
;
namespace
App\Services\order
;
use
App\Exception\custom\CodeSpecialException
;
use
Helpers\Sdk
;
class
OrderService
class
OrderService
{
{
public
static
function
get_idgen_id
(
$number
,
$count
=
1
){
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
"merchant_shop_id"
,
'number'
=>
$number
,
"count"
=>
$count
]]);
$id
=
$res
[
'id_datetime'
][
'merchant_shop_id'
]
??
[];
return
$id
;
}
/**
/**
* @param $orderId
* @param $orderId
* @param $userId
* @param $userId
* 调用内部服务获取用户订单、子单、分润信息
* 调用内部服务获取用户订单、子单、分润信息
*/
*/
public
static
function
getOrderData
(
$order_id
,
$user_id
)
{
public
static
function
getOrderData
(
$order_id
,
$user_id
)
{
return
self
::
getDemoData
(
$order_id
,
$user_id
);
}
public
static
function
getOrderItemData
(
$order_item_id
,
$user_id
)
{
return
[
'order_item_id'
=>
$order_item_id
,
'order_id'
=>
$order_item_id
.
'11'
,
'user_id'
=>
$user_id
,
'goods_spu_id'
=>
$order_item_id
.
'22'
,
'goods_sku_id'
=>
$order_item_id
.
'33'
,
'marketing_type'
=>
1
,
];
}
public
static
function
getDemoData
(
$orderId
,
$userId
)
{
$url
=
config
(
'interface'
,
'order.order.pay_order'
);
$order
=
[
if
(
!
$url
)
{
'order_id'
=>
$orderId
,
throw
new
CodeSpecialException
(
"failed"
);
'user_id'
=>
$userId
,
}
'life_account_id'
=>
2312
,
//'生活号id',
'shop_id'
=>
2312
,
//'店铺shop_id',
'order_type'
=>
1
,
//'1虚拟商品,2实体商品',
'payment'
=>
1
,
//'1虚拟商品,2实体商品',
'order_status'
=>
100
,
//'100 待付款',
];
$order_items
=
[
$params
=
[
'user_id'
=>
$user_id
,
'order_id'
=>
$order_id
];
[
return
Sdk
::
call
(
$url
,
$params
);
'order_item_id'
=>
$orderId
.
rand
(
100
,
999
),
}
'order_id'
=>
$orderId
,
'user_id'
=>
$userId
,
'goods_spu_id'
=>
$orderId
.
rand
(
100
,
999
),
'goods_sku_id'
=>
$orderId
.
rand
(
100
,
999
),
'marketing_type'
=>
1
,
],
[
'order_item_id'
=>
$orderId
.
rand
(
100
,
999
),
'order_id'
=>
$orderId
,
'user_id'
=>
$userId
,
'goods_spu_id'
=>
$orderId
.
rand
(
100
,
999
),
'goods_sku_id'
=>
$orderId
.
rand
(
100
,
999
),
'marketing_type'
=>
1
,
]
];
foreach
(
$order_items
as
$r
)
{
/**
$order_distribution
[]
=
[
* @param $order_item_id
'commission_mode'
=>
1
,
* @param $user_id
'distributor_user_id'
=>
122234
,
* @return bool|mixed
'distributor_commission_value'
=>
60
,
* @throws CodeSpecialException
'parent_user_id'
=>
122234
.
rand
(
111
,
999
),
* 获取订单子单信息
'parent_commission_value'
=>
60
,
*/
];
public
static
function
getOrderItemData
(
$order_item_id
,
$user_id
)
{
//merchant.account.get_role_list
$url
=
config
(
'interface'
,
'order.order.pay_order_item'
);
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
);
}
}
return
[
$params
=
[
'user_id'
=>
$user_id
,
'order_item_id'
=>
$order_item_id
];
'order'
=>
$order
,
return
Sdk
::
call
(
$url
,
$params
);
'order_items'
=>
$order_items
,
'order_distribution'
=>
$order_distribution
,
];
}
}
}
}
\ No newline at end of file
application/services/pay/PayService.php
View file @
a963c378
This diff is collapsed.
Click to expand it.
application/services/pingxx/PingxxService.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Services\pingxx
;
use
Pingpp\Order
;
use
Pingpp\OrderRefund
;
use
Helpers\Logger
;
class
PingxxService
{
/**
* @param $order_item_id
* @param $user_id
* @throws RefundException
* 发起退款请求
*/
public
static
function
sendRefund
(
$refundData
,
$chargeId
)
{
try
{
Logger
::
info
(
'退款订单发起'
,
[
'chargeId'
=>
$chargeId
,
'refundData'
=>
$refundData
]);
$royalty_users
=
[];
$ret
=
OrderRefund
::
create
(
$refundData
[
'pay_order_id'
],
[
'charge'
=>
$chargeId
,
//在该订单中,需要退款的 charge 对象 ID,默认全部退款。
'charge_amount'
=>
$refundData
[
'refund_amount'
],
//charge 退款金额,默认为全额退款。必须和 charge 参数同时使用。单位:分。
'description'
=>
'用户申请退款'
,
//退款附加说明。
'metadata'
=>
[
'refund_order_id'
=>
$refundData
[
'refund_order_id'
],
'order_item_id'
=>
$refundData
[
'order_item_id'
],
'goods_sku_id'
=>
$refundData
[
'goods_sku_id'
]
??
''
],
'refund_mode'
=>
'to_source'
,
//退款模式。原路退回:to_source,退至余额:to_balance。默认为原路返回。
'royalty_users'
=>
$royalty_users
,
]
);
Logger
::
info
(
'退款订单返回'
,
[
'res'
=>
$ret
]);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
[
'data'
];
/*
{
"object": "list",
"url": "/v1/orders/2111608270000005209/order_refunds",
"has_more": false,
"data": [
{
"id": "re_y1u944PmfnrTHyvnL0nD0iD1",
"object": "refund",
"order_no": "y1u944PmfnrTHyvnL0nD0iD1",
"amount": 800,
"created": 1499930518,
"succeed": true,
"status": "succeeded",
"time_succeed": 1499930518,
"description": "Refund Description",
"failure_code": null,
"failure_msg": null,
"metadata": {},
"charge": "ch_8SCSCCn90ir1bb54m5fjbnX5",
"charge_order_no": "2017071102122327",
"transaction_no": "2004450349201512090096425284",
"extra": {}
}
]
}
*
*/
}
catch
(
\Pingpp\Error\Base
$e
)
{
if
(
$e
->
getHttpStatus
()
!=
null
)
{
header
(
'Status: '
.
$e
->
getHttpStatus
());
echo
$e
->
getHttpBody
();
}
else
{
echo
$e
->
getMessage
();
}
}
}
/**
* @param $orderId ping++ 支付订单ID
* @param $refundId ping++ 退款ID
* @return mixed
* 退款信息查询
*/
public
static
function
getRefund
(
$orderId
,
$refundId
)
{
try
{
Logger
::
info
(
'退款查询发起'
,
[
'orderId'
=>
$orderId
,
'refundId'
=>
$refundId
]);
$ret
=
OrderRefund
::
retrieve
(
$orderId
,
$refundId
);
Logger
::
info
(
'退款查询返回'
,
[
'res'
=>
$ret
]);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
}
catch
(
\Pingpp\Error\Base
$e
)
{
if
(
$e
->
getHttpStatus
()
!=
null
)
{
header
(
'Status: '
.
$e
->
getHttpStatus
());
echo
$e
->
getHttpBody
();
}
else
{
echo
$e
->
getMessage
();
}
}
}
/**
* @param $order
* @return mixed
* 创建订单
*/
public
static
function
createOrder
(
$order
)
{
try
{
Logger
::
info
(
'创建订单发起'
,
$order
);
$royalty_users
=
[];
$ret
=
Order
::
create
(
[
"amount"
=>
$order
[
'pay_amount'
],
"app"
=>
APP_ID
,
"merchant_order_no"
=>
$order
[
'pay_order_id'
],
"subject"
=>
"用户购买"
,
"currency"
=>
"cny"
,
"body"
=>
"购买商品"
,
"uid"
=>
$order
[
'user_id'
],
"client_ip"
=>
"192.168.0.101"
,
'receipt_app'
=>
APP_ID
,
// 收款方应用
'service_app'
=>
APP_ID
,
// 服务方应用
'royalty_users'
=>
$royalty_users
,
//'balance_settlement' => [ // 可选参数,余额结算信息。
// 'user' => 'user_001',
// 'user_fee' => 1
//]
]
);
Logger
::
info
(
'创建订单返回'
,
[
'res'
=>
$ret
]);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
}
catch
(
\Pingpp\Error\Base
$e
)
{
// 捕获报错信息
if
(
$e
->
getHttpStatus
()
!=
null
)
{
echo
$e
->
getHttpStatus
()
.
PHP_EOL
;
echo
$e
->
getHttpBody
()
.
PHP_EOL
;
}
else
{
echo
$e
->
getMessage
()
.
PHP_EOL
;
}
}
}
/**
* @param $orderId
* 订单查询
*/
public
static
function
getOrder
(
$orderId
)
{
try
{
Logger
::
info
(
'查询订单发起'
,
[
'orderId'
=>
$orderId
]);
$ret
=
Order
::
retrieve
(
$orderId
);
Logger
::
info
(
'查询订单返回'
,
[
'res'
=>
$ret
]);
$respose
=
json_decode
(
$ret
,
true
);
return
$respose
;
}
catch
(
\Pingpp\Error\Base
$e
)
{
if
(
$e
->
getHttpStatus
()
!=
null
)
{
header
(
'Status: '
.
$e
->
getHttpStatus
());
echo
$e
->
getHttpBody
();
}
else
{
echo
$e
->
getMessage
();
}
}
}
/**
* @param $raw
* @param $header
* @return int
* 校验回调是否合法
*/
public
static
function
verifySignature
(
$raw
,
$headers
)
{
$signature
=
isset
(
$headers
[
'X-Pingplusplus-Signature'
])
?
$headers
[
'X-Pingplusplus-Signature'
]
:
null
;
$pub_key_path
=
''
;
$pub_key_contents
=
file_get_contents
(
$pub_key_path
);
return
openssl_verify
(
$raw
,
base64_decode
(
$signature
),
$pub_key_contents
,
'sha256'
);
}
}
\ No newline at end of file
application/services/refund/RefundService.php
View file @
a963c378
...
@@ -11,14 +11,18 @@ use App\Models\order\mysql\PayOrderClearingItem;
...
@@ -11,14 +11,18 @@ use App\Models\order\mysql\PayOrderClearingItem;
use
App\Models\order\mysql\RefundOrder
;
use
App\Models\order\mysql\RefundOrder
;
use
App\Services\Order\OrderService
;
use
App\Services\Order\OrderService
;
use
App\Services\pingxx\PingxxService
;
use
Helpers\Strategy
;
use
Helpers\Strategy
;
use
Helpers\Logger
;
use
Helpers\Logger
;
use
App\Exception\custom\RefundException
;
use
App\Exception\custom\RefundException
;
use
App\Exception\custom\WalletException
;
class
RefundService
class
RefundService
{
{
private
$refund_order
=
[];
/**
/**
* @param $order_item_id
* @param $order_item_id
* @param $user_id
* @param $user_id
...
@@ -41,75 +45,73 @@ class RefundService
...
@@ -41,75 +45,73 @@ class RefundService
'refund_order_id'
=>
$this
->
gen_refund_order_id
(),
'refund_order_id'
=>
$this
->
gen_refund_order_id
(),
];
];
$refund_order
=
$this
->
can_refund
(
$where
,
$order_item
);
$data
=
$this
->
can_refund
(
$where
,
$order_item
);
// 发起ping++ 创建退款
// 构造退款数据
try
{
$refund
=
[
// 通过发起一次退款请求创建一个新的 refund 对象,只能对已经发生交易并且没有全额退款的 charge 对象发起退款
'charge'
=>
$data
[
'pay_order'
][
'third_order_id'
],
$re
=
\Pingpp\Refund
::
create
(
'charge_amount'
=>
$data
[
'refund_order'
][
'refund_amount'
],
$refund_order
[
'third_order_id'
],
'metadata'
=>
[
[
'refund_order_id'
=>
$data
[
'refund_order'
][
'refund_order_id'
],
'amount'
=>
$refund_order
[
'refund_amount'
],
'order_item_id'
=>
$data
[
'refund_order'
][
'order_item_id'
],
'description'
=>
'订单申请退款'
,
'goods_sku_id'
=>
$order_item
[
'goods_sku_id'
]
??
''
,
'metadata'
=>
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]
],
]
];
);
try
{
$ret
=
PingxxService
::
sendRefund
(
$refund
);
$ret
=
json_decode
(
$re
,
true
);
if
(
!
empty
(
$ret
[
"data"
]))
{
if
(
!
empty
(
$ret
[
"data"
]))
{
$edit
=
[
$edit
=
[
'request_pingxx_success_time'
=>
date
(
'Y-m-d H:i:s'
)];
'request_pingxx_success_time'
=>
date
(
'Y-m-d H:i:s'
),
];
}
else
{
}
else
{
$edit
=
[
$edit
=
[
'refund_order_status'
=>
Dictionary
::
REFUND_ORDER_STATUS_UNDO
,];
'refund_order_status'
=>
Dictionary
::
REFUND_ORDER_STATUS_UNDO
,
];
}
}
}
catch
(
\Pingpp\Error\Base
$e
)
{
$edit
=
[
'refund_order_status'
=>
Dictionary
::
REFUND_ORDER_STATUS_UNDO
,
];
Logger
::
error
(
$e
->
getHttpBody
());
}
RefundOrder
::
update
(
$edit
,
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]);
}
catch
(
\Exception
$e
)
{
$edit
=
[
'refund_order_status'
=>
Dictionary
::
REFUND_ORDER_STATUS_UNDO
,];
Logger
::
error
(
$e
->
getMessage
());
}
RefundOrder
::
update
(
$edit
,
[
'refund_order_id'
=>
$data
[
'refund_order'
][
'refund_order_id'
]]);
//返回信息
}
}
public
function
call_back
(
$data
)
{
public
function
call_back
(
$data
)
{
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
if
(
empty
(
$data
[
'data'
][
'object'
]))
{
Logger
::
error
(
'回调参数错误:'
,
$data
);
Logger
::
error
(
'回调参数错误:'
,
$data
);
throw
new
RefundException
([
'cus'
=>
6
]);
}
}
$object
=
$data
[
'data'
][
'object'
];
if
(
empty
(
$object
[
'metadata'
][
'refund_order_id'
]))
{
if
(
empty
(
$object
[
'metadata'
][
'refund_order_id'
]))
{
throw
new
RefundException
([
'cus'
=>
0
]);
throw
new
RefundException
([
'cus'
=>
0
]);
}
}
$refund_order_id
=
$object
[
'metadata'
][
'refund_order_id'
];
// 获取退款回调信息,确认订单ID
$charge
=
$object
[
'charges'
][
'data'
][
0
];
$ping_refund
=
PingxxService
::
getRefund
(
$charge
[
'id'
],
$object
[
'id'
]);
if
(
$ping_refund
[
'status'
]
!=
'succeeded'
)
{
throw
new
RefundException
([
'cus'
=>
6
]);
}
// 修改状态,锁定业务
$refund_order_id
=
$object
[
'metadata'
][
'refund_order_id'
];
$this
->
lock_refund_clear
(
$refund_order_id
);
//不用搞清分核算,是否需要平台记账?
$this
->
make_refund_clear
(
$refund_order_id
);
try
{
/*
// 查询 refund 对象列表
try{
$re_list
=
\Pingpp\Refund
::
all
(
'ch_L8qn10mLmr1GS8e5OODmHaL4'
,
[
$ret = $this->send_wallet();
'limit'
=>
10
,
if($ret) {
]);
$edit = ['notify_account_success_time'=>date('Y-m-d H:i:s')];
echo
$re_list
;
// 输出 Ping++ 返回的 refund 对象列表
}
catch
(
\Pingpp\Error\Base
$e
)
{
if
(
$e
->
getHttpStatus
()
!=
null
)
{
header
(
'Status: '
.
$e
->
getHttpStatus
());
echo
$e
->
getHttpBody
();
} else {
} else {
echo
$e
->
getMessage
()
;
$edit = ['notify_account_status'=>Dictionary::SEND_ACCOUNT_STATUS_UNDO]
;
}
}
}catch (WalletException $e) {
$edit = ['notify_account_status'=>Dictionary::SEND_ACCOUNT_STATUS_UNDO];
}
}
//状态确认或回退,回退交给补偿服务处理
RefundOrder::update($edit, $refund_order_id);
*/
}
}
/**
/**
...
@@ -185,9 +187,17 @@ class RefundService
...
@@ -185,9 +187,17 @@ class RefundService
'refund_amount'
=>
$order_item
[
'payment'
],
'refund_amount'
=>
$order_item
[
'payment'
],
'refund_wx_tip'
=>
$wx_tip
,
'refund_wx_tip'
=>
$wx_tip
,
];
];
RefundOrder
::
update
(
$edit
,
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]);
$ret
=
RefundOrder
::
update
(
$edit
,
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]);
if
(
!
$ret
)
{
throw
new
RefundException
([
'cus'
=>
0
]);
}
$refund_order
[
'third_order_id'
]
=
$pay_order
[
'third_order_id'
];
//重新获取
$refund_order
=
RefundOrder
::
getMaster
(
'*'
,
[
'refund_order_id'
=>
$refund_order
[
'refund_order_id'
]]);
$data
=
[
'refund_order'
=>
$refund_order
,
'pay_order'
=>
$pay_order
,
];
RefundOrder
::
commit
();
RefundOrder
::
commit
();
...
@@ -197,7 +207,66 @@ class RefundService
...
@@ -197,7 +207,66 @@ class RefundService
throw
new
RefundException
([
'cut'
=>
0
]);
throw
new
RefundException
([
'cut'
=>
0
]);
}
}
return
$refund_order
;
return
$data
;
}
private
function
lock_refund_clear
(
$refund_order_id
)
{
try
{
RefundOrder
::
beginTransaction
();
$refund_order
=
RefundOrder
::
get
(
'*'
,
[
'refund_order_id'
=>
$refund_order_id
]);
if
(
empty
(
$refund_order
))
{
throw
new
RefundException
([
'cus'
=>
0
]);
}
$this
->
refund_order
=
$refund_order
;
if
(
$refund_order
[
'refund_order_status'
]
==
Dictionary
::
REFUND_ORDER_STATUS_OK
)
{
throw
new
RefundException
([
'cus'
=>
0
]);
}
$edit
=
[
'refund_order_status'
=>
Dictionary
::
REFUND_ORDER_STATUS_OK
,
'pingxx_callback_success_time'
=>
date
(
'Y-m-d H:i:s'
),
'notify_account_status'
=>
Dictionary
::
SEND_ACCOUNT_STATUS_DONE
,
];
RefundOrder
::
update
(
$edit
,
[
'refund_order_id'
=>
$refund_order_id
]);
RefundOrder
::
commit
();
}
catch
(
\PDOException
$e
)
{
RefundOrder
::
rollback
();
Logger
::
error
(
$e
->
getMessage
(),
$edit
);
throw
$e
;
}
}
private
function
make_refund_clear
()
{
$this
->
refund_order
;
$pay_order
=
PayOrder
::
get
(
'*'
,
[
'order_id'
=>
$this
->
refund_order
[
'order_id'
],
'pay_order_status'
=>
Dictionary
::
O_PAY_STATUS_PAYED
]);
$list
=
PayOrderClearingItem
::
get
(
'*'
,
[
'order_item_id'
=>
$this
->
refund_order
[
'order_item_id'
],
'pay_order_id'
=>
$pay_order
[
'pay_order_id'
]]);
//仅处理WX手续费,平台总帐,平台补贴,商户补贴
$platform_account_id
=
config
(
'pay'
,
'platform_account.account_id'
);
$wallet
[
'platform_account_id'
]
=
[
'account_id'
=>
$platform_account_id
,
'account_type'
=>
Dictionary
::
ACCOUNT_TYPE_ST
,
'pay_amount'
=>
0
,
'pay_type'
=>
Dictionary
::
PAY_TYPE_OUT
,
'pay_sub_type'
=>
1
,
];
foreach
(
$list
as
$r
)
{
if
(
$r
[
'pay_type'
]
==
Dictionary
::
PAY_TYPE_OUT
)
{
$wallet
[
'platform_account_id'
][
'pay_amount'
]
+=
$r
[
'pay_amount'
];
}
else
{
$wallet
[
'platform_account_id'
][
'pay_amount'
]
+=
$r
[
'pay_amount'
];
}
}
}
}
}
}
\ No newline at end of file
application/services/wallet/WalletService.php
0 → 100644
View file @
a963c378
<?php
namespace
App\Services\wallet
;
use
App\Exception\custom\CodeSpecialException
;
use
Helpers\Sdk
;
class
WalletService
{
/**
* @param $params
* @return bool|mixed
* @throws CodeSpecialException
* 钱包记录同步
*/
public
static
function
send
(
$params
)
{
$url
=
config
(
'interface'
,
'wallet.wallet.recharge'
);
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
);
}
return
Sdk
::
call
(
$url
,
$params
);
}
}
\ No newline at end of file
public/demo.php
0 → 100644
View file @
a963c378
<?php
var_dump
(
$_POST
);
public/index.php
View file @
a963c378
...
@@ -5,6 +5,7 @@ ini_set("display_errors", "On");
...
@@ -5,6 +5,7 @@ ini_set("display_errors", "On");
/* 定义这个常量是为了在application.ini中引用*/
/* 定义这个常量是为了在application.ini中引用*/
define
(
'ROOT_PATH'
,
realpath
(
__DIR__
.
'/../'
));
define
(
'ROOT_PATH'
,
realpath
(
__DIR__
.
'/../'
));
define
(
'APP_PATH'
,
realpath
(
__DIR__
.
'/../application'
));
define
(
'APP_PATH'
,
realpath
(
__DIR__
.
'/../application'
));
define
(
'LOG_PATH'
,
realpath
(
__DIR__
.
'/../logs'
)
.
'/'
);
define
(
'APP_START'
,
microtime
(
true
));
define
(
'APP_START'
,
microtime
(
true
));
// 调试参数 __debug 的值
// 调试参数 __debug 的值
...
@@ -17,3 +18,4 @@ define('_ERROR_LEVEL', E_ALL);
...
@@ -17,3 +18,4 @@ define('_ERROR_LEVEL', E_ALL);
$application
=
new
Yaf\Application
(
ROOT_PATH
.
"/conf/application.ini"
);
$application
=
new
Yaf\Application
(
ROOT_PATH
.
"/conf/application.ini"
);
$application
->
bootstrap
()
->
run
();
$application
->
bootstrap
()
->
run
();
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