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
ac188e65
Commit
ac188e65
authored
Sep 24, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 订单支付、支付回调
parent
d4916818
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
111 additions
and
95 deletions
+111
-95
Code.php
application/exception/custom/Code.php
+3
-3
PayException.php
application/exception/custom/PayException.php
+3
-3
CallbackLog.php
application/models/order/mysql/CallbackLog.php
+1
-1
MarketingAccount.php
application/models/order/mysql/MarketingAccount.php
+1
-1
MarketingAccountLog.php
application/models/order/mysql/MarketingAccountLog.php
+1
-1
MarketingAccountMap.php
application/models/order/mysql/MarketingAccountMap.php
+1
-1
PayCouponItem.php
application/models/order/mysql/PayCouponItem.php
+1
-1
PayOrder.php
application/models/order/mysql/PayOrder.php
+1
-1
PayOrderClearing.php
application/models/order/mysql/PayOrderClearing.php
+1
-1
PayOrderClearingItem.php
application/models/order/mysql/PayOrderClearingItem.php
+1
-1
PayOrderItem.php
application/models/order/mysql/PayOrderItem.php
+1
-1
PayOrderLog.php
application/models/order/mysql/PayOrderLog.php
+1
-1
PlatformAccount.php
application/models/order/mysql/PlatformAccount.php
+1
-1
PlatformAccountLog.php
application/models/order/mysql/PlatformAccountLog.php
+1
-1
PlatformConfig.php
application/models/order/mysql/PlatformConfig.php
+1
-1
PlatformFunds.php
application/models/order/mysql/PlatformFunds.php
+1
-1
PlatformFundsLog.php
application/models/order/mysql/PlatformFundsLog.php
+1
-1
RefundMerchantRecord.php
application/models/order/mysql/RefundMerchantRecord.php
+1
-1
RefundOrder.php
application/models/order/mysql/RefundOrder.php
+1
-1
RefundOrderItem.php
application/models/order/mysql/RefundOrderItem.php
+1
-1
RefundPersonalRecord.php
application/models/order/mysql/RefundPersonalRecord.php
+1
-1
RefundPlatformRecord.php
application/models/order/mysql/RefundPlatformRecord.php
+1
-1
WriteOffMerchantRecord.php
application/models/order/mysql/WriteOffMerchantRecord.php
+1
-1
WriteOffOrder.php
application/models/order/mysql/WriteOffOrder.php
+1
-1
WriteOffOrderItem.php
application/models/order/mysql/WriteOffOrderItem.php
+1
-1
WriteOffPersonalRecord.php
application/models/order/mysql/WriteOffPersonalRecord.php
+1
-1
WriteOffPlatformRecord.php
application/models/order/mysql/WriteOffPlatformRecord.php
+1
-1
Order.php
application/modules/Pay/controllers/Order.php
+1
-5
Pingxx.php
application/services/channel/Pingxx.php
+21
-23
FundsService.php
application/services/pay/FundsService.php
+3
-3
PayService.php
application/services/pay/PayService.php
+54
-32
FileLog.php
vendor/api/php_utils/src/Log/FileLog.php
+1
-1
No files found.
application/exception/custom/Code.php
View file @
ac188e65
...
...
@@ -14,7 +14,7 @@ class Code
const
PAY
=
101000
;
const
REFUND
=
102000
;
const
ORDER
=
103000
;
const
SDK
=
104000
;
const
FUNDS
=
105000
;
const
P_ACCOUNT
=
106000
;
const
SDK
=
104000
;
const
FUNDS
=
105000
;
const
P_ACCOUNT
=
106000
;
}
\ No newline at end of file
application/exception/custom/PayException.php
View file @
ac188e65
...
...
@@ -19,8 +19,8 @@ class PayException extends BaseException
5
=>
'订单缺少过期时间,请联系管理员'
,
6
=>
'订单过期,不允许支付'
,
7
=>
'支付订单创建失败,请管理员关注'
,
8
=>
'
支付订单创建失败,请管理员关注
'
,
9
=>
'
订单已经支付,请勿重复支付
'
,
8
=>
'
订单已经支付,请勿重复支付
'
,
9
=>
'
获取商户账户ID失败,请联系管理员
'
,
10
=>
'回调失败,支付订单不存在'
,
11
=>
'回调失败,支付金额错误'
,
...
...
@@ -30,7 +30,7 @@ class PayException extends BaseException
10
=>
'未支付订单不允许核销,请管理员关注'
,
11
=>
'商家仅允许核销自己的订单,请管理员关注'
,
12
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
14
=>
'订单缺少商品信息,请联系管理员'
,
15
=>
'订单存在过期商品,不能支付'
,
...
...
application/models/order/mysql/CallbackLog.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
CallbackLog
extends
MysqlBase
{
const
TABLE_NAME
=
'callback_log'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/MarketingAccount.php
View file @
ac188e65
...
...
@@ -7,5 +7,5 @@ use App\Exception\custom\PayException;
class
MarketingAccount
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_account'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/MarketingAccountLog.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
MarketingAccountLog
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_account_log'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/MarketingAccountMap.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
MarketingAccountMap
extends
MysqlBase
{
const
TABLE_NAME
=
'marketing_account_map'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PayCouponItem.php
View file @
ac188e65
...
...
@@ -7,5 +7,5 @@ use App\Exception\custom\PayException;
class
PayCouponItem
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_coupon_item'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PayOrder.php
View file @
ac188e65
...
...
@@ -7,7 +7,7 @@ use App\Exception\custom\PayException;
class
PayOrder
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_order'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
/**
* @param $order_id
...
...
application/models/order/mysql/PayOrderClearing.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PayOrderClearing
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_order_clearing'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PayOrderClearingItem.php
View file @
ac188e65
...
...
@@ -7,7 +7,7 @@ use App\Exception\BaseException;
class
PayOrderClearingItem
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_order_clearing_item'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
public
static
function
marketSaleCount
(
$accountId
)
{
...
...
application/models/order/mysql/PayOrderItem.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PayOrderItem
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_order_item'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PayOrderLog.php
View file @
ac188e65
...
...
@@ -7,5 +7,5 @@ use App\Exception\custom\PayException;
class
PayOrderLog
extends
MysqlBase
{
const
TABLE_NAME
=
'pay_order_log'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PlatformAccount.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PlatformAccount
extends
MysqlBase
{
const
TABLE_NAME
=
'platform_account'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PlatformAccountLog.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PlatformAccountLog
extends
MysqlBase
{
const
TABLE_NAME
=
'platform_account_log'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PlatformConfig.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PlatformConfig
extends
MysqlBase
{
const
TABLE_NAME
=
'platform_config'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PlatformFunds.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PlatformFunds
extends
MysqlBase
{
const
TABLE_NAME
=
'platform_funds'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/PlatformFundsLog.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PlatformFundsLog
extends
MysqlBase
{
const
TABLE_NAME
=
'platform_funds_log'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/RefundMerchantRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundMerchantRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'refund_merchant_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/RefundOrder.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundOrder
extends
MysqlBase
{
const
TABLE_NAME
=
'refund_order'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/RefundOrderItem.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundOrderItem
extends
MysqlBase
{
const
TABLE_NAME
=
'refund_order_item'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/RefundPersonalRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundPersonalRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'refund_personal_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/RefundPlatformRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundPlatformRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'refund_platform_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/WriteOffMerchantRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
WriteOffMerchantRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'writeoff_merchant_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/WriteOffOrder.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
WriteOffOrder
extends
MysqlBase
{
const
TABLE_NAME
=
'writeoff_order'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/WriteOffOrderItem.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
WriteOffOrderItem
extends
MysqlBase
{
const
TABLE_NAME
=
'writeoff_order_item'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/WriteOffPersonalRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
WriteOffPersonalRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'writeoff_personal_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/models/order/mysql/WriteOffPlatformRecord.php
View file @
ac188e65
...
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
WriteOffPlatformRecord
extends
MysqlBase
{
const
TABLE_NAME
=
'writeoff_platform_record'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
const
CONFIG_INDEX
=
'pay'
;
}
application/modules/Pay/controllers/Order.php
View file @
ac188e65
...
...
@@ -16,10 +16,6 @@ class OrderController extends Base
public
function
payAction
()
{
$params
=
$this
->
params
;
$user_id
=
$params
[
'user_id'
];
$order_id
=
$params
[
'order_id'
];
$pay_method_id
=
$params
[
'pay_method_id'
]
??
106
;
$extra
=
[];
if
(
!
empty
(
$params
[
'extra'
]))
{
if
(
is_string
(
$params
[
'extra'
]))
{
...
...
@@ -30,7 +26,7 @@ class OrderController extends Base
}
$paySrv
=
new
PayService
();
$ret
=
$paySrv
->
do_pay
(
$
order_id
,
$user_id
,
$pay_method_id
,
$extra
);
$ret
=
$paySrv
->
do_pay
(
$
params
,
$extra
);
//兼容C端客户端支付,调整返回结构,ping++ 返回 order,原生:微信、支付宝返回charge
$result
=
[];
...
...
application/services/channel/Pingxx.php
View file @
ac188e65
...
...
@@ -11,13 +11,7 @@ use App\Exception\BaseException;
class
Pingxx
{
/**
* @param $pay_order
* @param $mata_data
* 系统支付
*/
public
function
pay
(
$pay_order
,
$mata_data
,
$extra
=
[])
{
// 已经创建,需要查询返回
public
function
makeOrder
(
$pay_order
,
$mata_data
)
{
if
(
!
empty
(
$pay_order
[
'third_order_id'
]))
{
$ret
=
PingxxService
::
getInstance
()
->
getOrder
(
$pay_order
[
'third_order_id'
]);
}
else
{
...
...
@@ -39,12 +33,21 @@ class Pingxx {
}
else
{
throw
new
PayException
([
'cus'
=>
103
]);
}
return
$ret
;
}
/**
* @param $pay_order
* @param $mata_data
* 系统支付
*/
public
function
pay
(
$pay_order
,
$object
,
$extra
=
[])
{
$channel_exist
=
false
;
$channel
=
$this
->
get
Channel
(
$pay_order
[
'pay_channel'
]);
if
(
!
empty
(
$
re
t
[
'charges'
][
'data'
]))
{
$channel
=
$this
->
pay2
Channel
(
$pay_order
[
'pay_channel'
]);
if
(
!
empty
(
$
objec
t
[
'charges'
][
'data'
]))
{
//是否存在
foreach
(
$
re
t
[
'charges'
][
'data'
]
as
$ch
)
{
foreach
(
$
objec
t
[
'charges'
][
'data'
]
as
$ch
)
{
if
(
$ch
[
'channel'
]
==
$channel
)
{
$channel_exist
=
true
;
}
...
...
@@ -61,7 +64,7 @@ class Pingxx {
'extra'
=>
$extra
,
];
$pay
=
PingxxService
::
getInstance
()
->
pay
(
$
re
t
[
'id'
],
$payment
);
$pay
=
PingxxService
::
getInstance
()
->
pay
(
$
objec
t
[
'id'
],
$payment
);
if
(
!
empty
(
$pay
[
'error'
]))
{
throw
new
BaseException
([
'msg'
=>
$pay
[
'error'
][
'message'
],
'code'
=>
'2002'
]);
}
...
...
@@ -69,7 +72,7 @@ class Pingxx {
return
$pay
;
}
else
{
return
$
re
t
;
return
$
objec
t
;
}
}
...
...
@@ -110,7 +113,7 @@ class Pingxx {
return
PingxxService
::
getInstance
()
->
sendRefund
(
$refund
);
}
private
function
get
Channel
(
$pay_method_id
)
{
private
function
pay2
Channel
(
$pay_method_id
)
{
$maps
=
[
1
=>
"syt"
,
//系统余额支付
...
...
@@ -149,7 +152,7 @@ class Pingxx {
throw
new
PayException
([
'cus'
=>
104
]);
}
$float_tip
=
$info
[
'rate'
]
*
$pay_order
[
'pay
me
nt'
]
/
10000
;
$float_tip
=
$info
[
'rate'
]
*
$pay_order
[
'pay
_amou
nt'
]
/
10000
;
if
(
$float_tip
>=
1
)
{
$total_tip
=
round
(
$float_tip
);
...
...
@@ -178,15 +181,10 @@ class Pingxx {
$float_tip
=
$info
[
'rate'
]
*
$pay_order
[
'total_price'
]
/
10000
;
$total_tip
=
round
(
$float_tip
);
if
(
$float_tip
>=
1
)
{
return
[
'account_id'
=>
$info
[
'account_id'
],
'amount'
=>
$total_tip
,
];
}
else
{
return
[];
}
return
[
'account_id'
=>
$info
[
'account_id'
],
'amount'
=>
$total_tip
,
];
}
public
function
getFundsInfo
(
$pay_order
)
{
...
...
application/services/pay/FundsService.php
View file @
ac188e65
...
...
@@ -22,7 +22,7 @@ class FundsService
$info
=
PlatformFunds
::
getMaster
(
'*'
,
[
'channel'
=>
$channel
,
'source_name'
=>
$source_name
,
'service_name'
=>
$service_name
]);
if
(
empty
(
$info
))
{
throw
new
FundsException
([
'cus'
=>
1
]);
throw
new
FundsException
([
'cus'
=>
1
]);
}
$cnt
=
PlatformFunds
::
update
([
...
...
@@ -32,8 +32,8 @@ class FundsService
$l_cnt
=
PlatformFundsLog
::
insert
([
'platform_funds_id'
=>
$info
[
'platform_funds_id'
],
'trade_id'
=>
$data
[
'
order
_id'
],
'third_order_id'
=>
$data
[
'third_id'
],
'trade_id'
=>
$data
[
'
trade
_id'
],
'third_order_id'
=>
$data
[
'third_
order_
id'
],
'fund_type'
=>
1
,
'amount'
=>
$data
[
'amount'
],
'tip'
=>
$data
[
'tip'
],
...
...
application/services/pay/PayService.php
View file @
ac188e65
...
...
@@ -52,11 +52,11 @@ class PayService
*/
private
function
pay_validate
(
$params
)
{
if
(
$params
[
'order_id'
]
)
{
if
(
empty
(
$params
[
'order_id'
])
)
{
throw
new
PayException
([
'cus'
=>
1
]);
}
if
(
$params
[
'user_id'
]
)
{
if
(
empty
(
$params
[
'user_id'
])
)
{
throw
new
PayException
([
'cus'
=>
2
]);
}
...
...
@@ -103,7 +103,7 @@ class PayService
$pay_order_id
=
array_shift
(
$ids
);
PayOrder
::
beginTransaction
();
$pay
=
self
::
getMaster
(
'*'
,
[
'order_id'
=>
$order
[
'order_id'
]]);
$pay
=
PayOrder
::
getMaster
(
'*'
,
[
'order_id'
=>
$order
[
'order_id'
]]);
if
(
!
empty
(
$pay
))
{
//更新支付渠道
if
(
$pay
[
'pay_order_status'
]
==
0
)
{
...
...
@@ -124,7 +124,7 @@ class PayService
'order_id'
=>
$order
[
'order_id'
],
'pay_order_status'
=>
0
,
'total_price'
=>
$order
[
'total_price'
],
'
discount_fee'
=>
$order
[
'discount_fee'
],
'
pay_discount'
=>
$order
[
'discount_fee'
],
//pay_discount
'pay_amount'
=>
$order
[
'payment'
],
'pay_channel'
=>
$pay_method_id
,
'third_order_id'
=>
''
,
...
...
@@ -146,6 +146,15 @@ class PayService
'order_id'
=>
$r
[
'order_id'
],
'order_item_id'
=>
$r
[
'order_item_id'
],
'user_id'
=>
$r
[
'user_id'
],
'goods_spu_id'
=>
$r
[
'goods_spu_id'
],
'goods_sku_id'
=>
$r
[
'goods_sku_id'
],
'goods_version'
=>
$r
[
'goods_version'
],
'goods_name'
=>
$r
[
'goods_name'
],
'goods_type'
=>
$r
[
'goods_type'
],
'goods_sale_type'
=>
$r
[
'goods_sale_type'
],
'rule_refund'
=>
$r
[
'rule_refund'
],
'price'
=>
$r
[
'price'
],
'goods_num'
=>
$r
[
'goods_num'
],
'payment'
=>
$r
[
'payment'
],
'share_coupon'
=>
$r
[
'share_coupon'
],
];
...
...
@@ -234,11 +243,13 @@ class PayService
try
{
$payer
=
Channel
::
getChannel
(
$params
[
'pay_method_id'
]);
$ret
=
$payer
->
pay
(
$pay_order
,
$meta_data
,
$extr
a
);
$ret
=
$payer
->
makeOrder
(
$pay_order
,
$meta_dat
a
);
PayOrder
::
update
([
'pay_order_status'
=>
1
],
PayOrder
::
update
([
'pay_order_status'
=>
1
,
'third_order_id'
=>
$ret
[
'id'
]
],
[
'pay_order_id'
=>
$pay_order
[
'pay_order_id'
],
'pay_order_status'
=>
0
]);
$response
=
$payer
->
pay
(
$pay_order
,
$ret
,
$extra
);
}
catch
(
BaseException
$e
)
{
throw
$e
;
...
...
@@ -246,7 +257,7 @@ class PayService
throw
new
BaseException
([
'msg'
=>
$e
->
getMessage
(),
'code'
=>
'2301'
]);
}
return
$re
t
;
return
$re
sponse
;
}
/**
...
...
@@ -694,7 +705,7 @@ class PayService
$wx_tip
=
$this
->
make_tip_clearing
(
$payer
);
//渠道手续费
$distribution_tip
=
$this
->
make_distribution_clearing
();
//团长收益
$platform
=
$this
->
make_platform_clearing
();
//平台收益
$platform
=
$this
->
make_platform_clearing
(
$payer
);
//平台收益
$merchant_cash
=
$this
->
pay_order
[
'pay_amount'
]
+
$this
->
pay_order
[
'pay_discount'
]
-
$wx_tip
-
$distribution_tip
-
$platform
[
'amount'
];
...
...
@@ -712,7 +723,7 @@ class PayService
throw
new
PayException
([
'cus'
=>
12
]);
}
$this
->
make_merchant_clearing
(
$merchant_cash
);
//商户收益
$this
->
make_merchant_clearing
(
$merchant_cash
,
$platform
);
//商户收益
try
{
$cnt
=
true
;
...
...
@@ -720,7 +731,7 @@ class PayService
//总账资金记账
$cnt
=
$cnt
&&
FundsService
::
credit
([
'trade_id'
=>
$this
->
pay_order
[
'order_id'
],
'trade_id'
=>
$this
->
pay_order
[
'
pay_
order_id'
],
'third_order_id'
=>
$this
->
pay_order
[
'third_order_id'
],
'amount'
=>
$this
->
pay_order
[
'pay_amount'
],
'tip'
=>
$wx_tip
,
...
...
@@ -728,18 +739,15 @@ class PayService
//营销扣款
$cnt
=
$cnt
&&
AccountService
::
pay
(
$coupon_items
,
$this
->
pay_order
[
'order_id'
]);
$cnt
=
$cnt
&&
PayOrderClearing
::
insert
(
$this
->
clear_list
,
[
'rowCount'
=>
true
]);
$cnt
=
$cnt
&&
PayOrderClearingItem
::
insert
(
$this
->
clear_items_list
,
[
'rowCount'
=>
true
]);
if
(
$cnt
==
false
)
{
throw
new
PayException
([
'cus'
=>
0
]);
}
PayOrderClearing
::
commit
();
}
catch
(
\Exception
$e
)
{
PayOrderClearing
::
rollback
();
throw
new
PayException
([
'cut'
=>
5
])
;
throw
$e
;
}
//如果是不可退款商品,则需进入结算队列
...
...
@@ -792,7 +800,7 @@ class PayService
*/
private
function
make_platform_clearing
(
$payer
)
{
$account
=
$payer
->
clearPlatformTips
(
$this
->
order_info
);
$account
=
$payer
->
clearPlatformTips
(
$this
->
pay_order
);
if
(
empty
(
$account
))
{
return
0
;
}
...
...
@@ -926,7 +934,9 @@ class PayService
}
}
array_push
(
$this
->
clear_list
,
array_values
(
$maps
));
if
(
$maps
)
{
array_push
(
$this
->
clear_list
,
array_values
(
$maps
));
}
return
$total_tip
;
}
...
...
@@ -938,9 +948,9 @@ class PayService
*/
private
function
make_merchant_clearing
(
$merchant_cash
,
$platform
)
{
$m
=
$this
->
get_merchant_account
(
$this
->
pay_order
[
'life_account_id'
],
$this
->
pay_order
[
'life_account_id'
]
);
$m
=
$this
->
get_merchant_account
(
$this
->
pay_order
);
$merchant
[
'account_id'
]
=
$m
[
'id'
];
//商户
$merchant
[
'account_id'
]
=
$m
[
'
account_
id'
];
//商户
$merchant
[
'account_type'
]
=
2
;
//商户
$merchant
[
'pay_type'
]
=
1
;
//收入
$merchant
[
'pay_sub_type'
]
=
407
;
//商品交易102
...
...
@@ -970,18 +980,20 @@ class PayService
if
(
!
empty
(
$r
[
'clear_price'
]))
{
$clear_payment
=
$r
[
'goods_num'
]
*
$r
[
'clear_price'
];
$platform_amount
=
$current_tip
-
$clear_payment
;
}
else
{
$clear_payment
=
0
;
$clear_payment
=
$current_tip
;
$platform_amount
=
0
;
}
$pay_amount
=
$current_tip
;
if
(
$current_tip
<
$clear_payment
)
{
if
(
$platform_amount
<
0
)
{
throw
new
PayException
([
'cus'
=>
12
]);
//结算价不能大于商家分成部分
}
}
elseif
(
$clear_payment
<
$current_tip
)
{
if
(
$platform_amount
>
0
)
{
//结算价剩余部分返回平台
$p_tip
=
$current_tip
-
$clear_payment
;
$platform
[
'pay_amount'
]
+=
$p_tip
;
$platform
[
'amount'
]
+=
$platform_amount
;
$this
->
clear_items_list
[]
=
[
'pay_order_clearing_item_id'
=>
array_shift
(
$this
->
gen_ids
),
'pay_order_clearing_id'
=>
$p_clearing_id
,
...
...
@@ -990,7 +1002,7 @@ class PayService
'order_item_id'
=>
$r
[
'order_item_id'
],
'account_id'
=>
$platform
[
'account_id'
],
'account_type'
=>
$platform
[
'account_type'
],
'pay_amount'
=>
$p
_tip
,
'pay_amount'
=>
$p
latform_amount
,
'clear_payment'
=>
0
,
//商品结算价格
'pay_type'
=>
$platform
[
'pay_type'
],
'pay_sub_type'
=>
$platform
[
'pay_sub_type'
],
...
...
@@ -1009,8 +1021,8 @@ class PayService
'order_item_id'
=>
$r
[
'order_item_id'
],
'account_id'
=>
$merchant
[
'account_id'
],
'account_type'
=>
$merchant
[
'account_type'
],
'pay_amount'
=>
$
pay_amount
,
'clear_payment'
=>
$clear_payment
,
//商品结算价格
'pay_amount'
=>
$
clear_payment
,
//商品结算价格
'clear_payment'
=>
0
,
'pay_type'
=>
$merchant
[
'pay_type'
],
'pay_sub_type'
=>
$merchant
[
'pay_sub_type'
],
'remark'
=>
$remark
,
...
...
@@ -1061,16 +1073,26 @@ class PayService
return
$this
->
gen_ids
;
}
private
function
get_merchant_account
(
$
life_account_id
,
$shop_id
)
private
function
get_merchant_account
(
$
params
)
{
/*
///account/account/get_account
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (!$url) {
throw new CodeSpecialException("failed" . __METHOD__);
}
$params
=
[
'life_account_id'
=>
$life_account_id
];
$account
=
Sdk
::
call
(
$url
,
$params
);
return
$account
;
*/
$url
=
"http://account.dev.yidian-inc.com/account/account/get_account"
;
$ret
=
Sdk
::
call
(
$url
,
[
'life_account_id'
=>
$params
[
'life_account_id'
],
'shop_id'
=>
$params
[
'shop_id'
],
'source_name'
=>
$params
[
'source_name'
],
'service_name'
=>
$params
[
'service_name'
],
]);
if
(
empty
(
$ret
[
'result'
]))
{
throw
new
PayException
([
'cus'
=>
9
]);
}
return
$ret
[
'result'
];
}
private
function
getNextTime
(
$times
=
0
)
{
...
...
vendor/api/php_utils/src/Log/FileLog.php
View file @
ac188e65
...
...
@@ -62,7 +62,7 @@ class FileLog
$exception_info
=
''
;
}
$log
.=
' [exception info: ]'
.
$exception_info
;
$log
.=
' [debug_backtrace info: ]'
.
print_r
(
debug_backtrace
(),
1
);
//
$log .= ' [debug_backtrace info: ]' . print_r(debug_backtrace(), 1);
error_log
(
$log
);
if
(
empty
(
$mail_to
))
{
$mail_to
=
'bp-server@yidian-inc.com'
;
...
...
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