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
d4916818
Commit
d4916818
authored
Sep 23, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: init pay_v2
parent
dc61a339
Changes
43
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
1439 additions
and
1102 deletions
+1439
-1102
Code.php
application/exception/custom/Code.php
+2
-0
FundsException.php
application/exception/custom/FundsException.php
+3
-19
PayException.php
application/exception/custom/PayException.php
+21
-11
PlatformAccountException.php
application/exception/custom/PlatformAccountException.php
+2
-2
RefundException.php
application/exception/custom/RefundException.php
+10
-17
CallbackLog.php
application/models/order/mysql/CallbackLog.php
+1
-1
MarketingAccount.php
application/models/order/mysql/MarketingAccount.php
+3
-29
MarketingAccountLog.php
application/models/order/mysql/MarketingAccountLog.php
+3
-4
MarketingAccountMap.php
application/models/order/mysql/MarketingAccountMap.php
+3
-3
PayCouponItem.php
application/models/order/mysql/PayCouponItem.php
+3
-29
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
+3
-29
PlatformAccount.php
application/models/order/mysql/PlatformAccount.php
+3
-3
PlatformAccountLog.php
application/models/order/mysql/PlatformAccountLog.php
+3
-3
PlatformConfig.php
application/models/order/mysql/PlatformConfig.php
+3
-3
PlatformFunds.php
application/models/order/mysql/PlatformFunds.php
+3
-3
PlatformFundsLog.php
application/models/order/mysql/PlatformFundsLog.php
+3
-3
RefundMerchantRecord.php
application/models/order/mysql/RefundMerchantRecord.php
+3
-3
RefundOrder.php
application/models/order/mysql/RefundOrder.php
+1
-1
RefundOrderItem.php
application/models/order/mysql/RefundOrderItem.php
+3
-3
RefundPersonalRecord.php
application/models/order/mysql/RefundPersonalRecord.php
+3
-3
RefundPlatformRecord.php
application/models/order/mysql/RefundPlatformRecord.php
+3
-3
WriteOffMerchantRecord.php
application/models/order/mysql/WriteOffMerchantRecord.php
+3
-3
WriteOffOrder.php
application/models/order/mysql/WriteOffOrder.php
+3
-3
WriteOffOrderItem.php
application/models/order/mysql/WriteOffOrderItem.php
+3
-3
WriteOffPersonalRecord.php
application/models/order/mysql/WriteOffPersonalRecord.php
+3
-3
WriteOffPlatformRecord.php
application/models/order/mysql/WriteOffPlatformRecord.php
+3
-3
Tcc.php
application/modules/Pay/controllers/Tcc.php
+13
-0
Hook.php
application/plugins/Hook.php
+7
-2
Channel.php
application/services/Channel.php
+23
-36
Pingxx.php
application/services/channel/Pingxx.php
+206
-0
Platform.php
application/services/channel/Platform.php
+30
-0
AccountService.php
application/services/marketing/AccountService.php
+181
-22
FundsService.php
application/services/pay/FundsService.php
+57
-279
PayService.php
application/services/pay/PayService.php
+635
-421
PlatformAccountService.php
application/services/pay/PlatformAccountService.php
+14
-49
RefundService.php
application/services/refund/RefundService.php
+158
-97
MerchantAccountService.php
application/services/wallet/MerchantAccountService.php
+7
-4
WalletService.php
application/services/wallet/WalletService.php
+1
-0
demo.php
public/demo.php
+6
-1
No files found.
application/exception/custom/Code.php
View file @
d4916818
...
@@ -15,4 +15,6 @@ class Code
...
@@ -15,4 +15,6 @@ class Code
const
REFUND
=
102000
;
const
REFUND
=
102000
;
const
ORDER
=
103000
;
const
ORDER
=
103000
;
const
SDK
=
104000
;
const
SDK
=
104000
;
const
FUNDS
=
105000
;
const
P_ACCOUNT
=
106000
;
}
}
\ No newline at end of file
application/exception/custom/FundsException.php
View file @
d4916818
...
@@ -6,28 +6,12 @@ namespace App\Exception\custom;
...
@@ -6,28 +6,12 @@ namespace App\Exception\custom;
use
App\Exception\BaseException
;
use
App\Exception\BaseException
;
class
Refund
Exception
extends
BaseException
class
Funds
Exception
extends
BaseException
{
{
protected
$base_code
=
Code
::
REFUND
;
protected
$base_code
=
Code
::
FUNDS
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
0
=>
'系统异常请联系管理员'
,
1
=>
'缺少退款订单ID!'
,
1
=>
'缺少渠道平台账户配置,请联系管理员!'
,
2
=>
'获取订单信息返回错误,请核对'
,
3
=>
'仅支持自己操作订单退款!'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
5
=>
'已核销计算订单不支持退款!'
,
6
=>
'退款处理完成,请勿重复申请'
,
7
=>
'退款处理中请稍等'
,
8
=>
'退款消息类型匹配失败,请管理员关注!'
,
9
=>
'pingxx退款消息格式错误,请管理员关注!'
,
10
=>
'pingxx退单状态异常,请管理员关注!'
,
11
=>
'pingxx退单缺少matadata!'
,
12
=>
'pingxx未支付订单不允许退款。'
,
13
=>
'pingxx订单可能存在多次成功支付,需人工确认处理。'
,
14
=>
'不存在满足条件的退款订单。'
,
15
=>
'订单未支付或不存在,请核对。'
,
16
=>
'订单退款回调处理失败,请核对。'
,
];
];
}
}
application/exception/custom/PayException.php
View file @
d4916818
...
@@ -13,24 +13,34 @@ class PayException extends BaseException
...
@@ -13,24 +13,34 @@ class PayException extends BaseException
protected
$cus
=
[
protected
$cus
=
[
0
=>
'系统错误,请稍收重试'
,
0
=>
'系统错误,请稍收重试'
,
1
=>
'请输入订单ID'
,
1
=>
'请输入订单ID'
,
2
=>
'订单服务获取订单信息失败。'
,
2
=>
'请输入用户ID'
,
3
=>
'请确认订单信息及用户是否一致。'
,
3
=>
'订单服务获取订单信息失败。'
,
4
=>
'支付订单创建失败,请管理员关注'
,
4
=>
'请确认订单信息及用户是否一致。'
,
5
=>
'该订单已经支付,请稍后刷新'
,
5
=>
'订单缺少过期时间,请联系管理员'
,
6
=>
'该订单已超时取消关闭,请重新下单购买'
,
6
=>
'订单过期,不允许支付'
,
7
=>
'支付订单创建失败,请管理员关注'
,
7
=>
'支付回调订单不存在,请管理员关注'
,
8
=>
'支付订单创建失败,请管理员关注'
,
8
=>
'支付订单金额与实际支付金额不等,请管理员关注'
,
9
=>
'订单已经支付,请勿重复支付'
,
9
=>
'退款中订单不允许核销,请管理员关注'
,
10
=>
'回调失败,支付订单不存在'
,
11
=>
'回调失败,支付金额错误'
,
12
=>
'订单服务优惠信息错误'
,
13
=>
'订单明细保存失败'
,
10
=>
'未支付订单不允许核销,请管理员关注'
,
10
=>
'未支付订单不允许核销,请管理员关注'
,
11
=>
'商家仅允许核销自己的订单,请管理员关注'
,
11
=>
'商家仅允许核销自己的订单,请管理员关注'
,
12
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
12
=>
'支付订单预结算失败,结算资金不能负数,请核对配置'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
13
=>
'生活号获取管理员ID失败,请联系管理员'
,
14
=>
'订单缺少商品信息,请联系管理员'
,
14
=>
'订单缺少商品信息,请联系管理员'
,
15
=>
'订单存在过期商品,不能支付'
,
15
=>
'订单存在过期商品,不能支付'
,
16
=>
'订单过期,不允许支付'
,
17
=>
'订单缺少过期时间,请联系管理员'
,
18
=>
'订单不存在,请重试'
,
18
=>
'订单不存在,请重试'
,
100
=>
'支付渠道错误,暂不支持该渠道'
,
101
=>
'该订单已经支付,请稍后刷新'
,
102
=>
'该订单已超时取消关闭,请重新下单购买'
,
103
=>
'该订单已超时取消关闭,请重新下单购买'
,
104
=>
'请增加pingxx渠道手续费配置'
,
];
];
}
}
application/exception/custom/PlatformAccountException.php
View file @
d4916818
...
@@ -6,9 +6,9 @@ namespace App\Exception\custom;
...
@@ -6,9 +6,9 @@ namespace App\Exception\custom;
use
App\Exception\BaseException
;
use
App\Exception\BaseException
;
class
Funds
Exception
extends
BaseException
class
PlatformAccount
Exception
extends
BaseException
{
{
protected
$base_code
=
Code
::
FUNDS
;
protected
$base_code
=
Code
::
P_ACCOUNT
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
0
=>
'系统异常请联系管理员'
,
...
...
application/exception/custom/RefundException.php
View file @
d4916818
...
@@ -11,23 +11,16 @@ class RefundException extends BaseException
...
@@ -11,23 +11,16 @@ class RefundException extends BaseException
protected
$base_code
=
Code
::
REFUND
;
protected
$base_code
=
Code
::
REFUND
;
protected
$cus
=
[
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
0
=>
'系统异常请联系管理员
。
'
,
1
=>
'缺少退款订单ID!'
,
1
=>
'缺少退款订单ID!'
,
2
=>
'获取订单信息返回错误,请核对'
,
2
=>
'订单未支付或不存在,请核对。'
,
3
=>
'仅支持自己操作订单退款!'
,
3
=>
'不存在满足条件的退款订单。'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
4
=>
'退单保存失败,请联系管理员。'
,
5
=>
'已核销计算订单不支持退款!'
,
5
=>
'订单退款回调处理失败,请核对。'
,
6
=>
'退款处理完成,请勿重复申请'
,
7
=>
'退款处理中请稍等'
,
6
=>
'pingxx退单缺少matadata!'
,
7
=>
'pingxx未支付订单不允许退款。'
,
8
=>
'退款消息类型匹配失败,请管理员关注!'
,
8
=>
'pingxx订单可能存在多次成功支付,需人工确认处理。'
,
9
=>
'pingxx退款消息格式错误,请管理员关注!'
,
10
=>
'pingxx退单状态异常,请管理员关注!'
,
11
=>
'pingxx退单缺少matadata!'
,
12
=>
'pingxx未支付订单不允许退款。'
,
13
=>
'pingxx订单可能存在多次成功支付,需人工确认处理。'
,
14
=>
'不存在满足条件的退款订单。'
,
15
=>
'订单未支付或不存在,请核对。'
,
16
=>
'订单退款回调处理失败,请核对。'
,
];
];
}
}
application/models/order/mysql/CallbackLog.php
View file @
d4916818
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
CallbackLog
extends
MysqlBase
class
CallbackLog
extends
MysqlBase
{
{
const
TABLE_NAME
=
'callback_log'
;
const
TABLE_NAME
=
'callback_log'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/MarketingAccount.php
View file @
d4916818
...
@@ -4,34 +4,8 @@ namespace App\Models\order\mysql;
...
@@ -4,34 +4,8 @@ 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
;
class
PayOrder
extends
MysqlBase
class
MarketingAccount
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order'
;
const
TABLE_NAME
=
'marketing_account'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay_v2'
;
/**
* @param $order_id
* @param $pay_order
* @return array
*/
public
static
function
get_valid_order
(
$order_id
,
$pay_order
)
{
self
::
beginTransaction
();
try
{
$order
=
self
::
getMaster
(
'*'
,
[
'order_id'
=>
$order_id
]);
if
(
empty
(
$order
))
{
$cnt
=
self
::
insert
(
$pay_order
,
[
'rowCount'
=>
true
]);
if
(
$cnt
)
{
$order
=
$pay_order
;
}
}
self
::
commit
();
}
catch
(
\PDOException
$e
)
{
self
::
rollback
();
}
return
$order
;
}
}
}
application/models/order/mysql/MarketingAccountLog.php
View file @
d4916818
...
@@ -2,10 +2,9 @@
...
@@ -2,10 +2,9 @@
namespace
App\Models\order\mysql
;
namespace
App\Models\order\mysql
;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
App\Exception\custom\PayException
;
class
MarketingAccount
extends
MysqlBase
class
MarketingAccount
Log
extends
MysqlBase
{
{
const
TABLE_NAME
=
'marketing_account'
;
const
TABLE_NAME
=
'marketing_account
_log
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/MarketingAccountMap.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
MarketingAccount
Log
extends
MysqlBase
class
MarketingAccount
Map
extends
MysqlBase
{
{
const
TABLE_NAME
=
'marketing_account_
log
'
;
const
TABLE_NAME
=
'marketing_account_
map
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PayCouponItem.php
View file @
d4916818
...
@@ -4,34 +4,8 @@ namespace App\Models\order\mysql;
...
@@ -4,34 +4,8 @@ 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
;
class
Pay
Order
extends
MysqlBase
class
Pay
CouponItem
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order'
;
const
TABLE_NAME
=
'pay_coupon_item'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay_v2'
;
/**
* @param $order_id
* @param $pay_order
* @return array
*/
public
static
function
get_valid_order
(
$order_id
,
$pay_order
)
{
self
::
beginTransaction
();
try
{
$order
=
self
::
getMaster
(
'*'
,
[
'order_id'
=>
$order_id
]);
if
(
empty
(
$order
))
{
$cnt
=
self
::
insert
(
$pay_order
,
[
'rowCount'
=>
true
]);
if
(
$cnt
)
{
$order
=
$pay_order
;
}
}
self
::
commit
();
}
catch
(
\PDOException
$e
)
{
self
::
rollback
();
}
return
$order
;
}
}
}
application/models/order/mysql/PayOrder.php
View file @
d4916818
...
@@ -7,7 +7,7 @@ use App\Exception\custom\PayException;
...
@@ -7,7 +7,7 @@ use App\Exception\custom\PayException;
class
PayOrder
extends
MysqlBase
class
PayOrder
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order'
;
const
TABLE_NAME
=
'pay_order'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
/**
/**
* @param $order_id
* @param $order_id
...
...
application/models/order/mysql/PayOrderClearing.php
View file @
d4916818
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PayOrderClearing
extends
MysqlBase
class
PayOrderClearing
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order_clearing'
;
const
TABLE_NAME
=
'pay_order_clearing'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PayOrderClearingItem.php
View file @
d4916818
...
@@ -7,7 +7,7 @@ use App\Exception\BaseException;
...
@@ -7,7 +7,7 @@ use App\Exception\BaseException;
class
PayOrderClearingItem
extends
MysqlBase
class
PayOrderClearingItem
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order_clearing_item'
;
const
TABLE_NAME
=
'pay_order_clearing_item'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
public
static
function
marketSaleCount
(
$accountId
)
{
public
static
function
marketSaleCount
(
$accountId
)
{
...
...
application/models/order/mysql/PayOrderItem.php
View file @
d4916818
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
PayOrderItem
extends
MysqlBase
class
PayOrderItem
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order_item'
;
const
TABLE_NAME
=
'pay_order_item'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PayOrderLog.php
View file @
d4916818
...
@@ -4,34 +4,8 @@ namespace App\Models\order\mysql;
...
@@ -4,34 +4,8 @@ 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
;
class
PayOrder
extends
MysqlBase
class
PayOrder
Log
extends
MysqlBase
{
{
const
TABLE_NAME
=
'pay_order'
;
const
TABLE_NAME
=
'pay_order_log'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay_v2'
;
/**
* @param $order_id
* @param $pay_order
* @return array
*/
public
static
function
get_valid_order
(
$order_id
,
$pay_order
)
{
self
::
beginTransaction
();
try
{
$order
=
self
::
getMaster
(
'*'
,
[
'order_id'
=>
$order_id
]);
if
(
empty
(
$order
))
{
$cnt
=
self
::
insert
(
$pay_order
,
[
'rowCount'
=>
true
]);
if
(
$cnt
)
{
$order
=
$pay_order
;
}
}
self
::
commit
();
}
catch
(
\PDOException
$e
)
{
self
::
rollback
();
}
return
$order
;
}
}
}
application/models/order/mysql/PlatformAccount.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Platform
Funds
extends
MysqlBase
class
Platform
Account
extends
MysqlBase
{
{
const
TABLE_NAME
=
'platform_
funds_log
'
;
const
TABLE_NAME
=
'platform_
account
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PlatformAccountLog.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
PlatformAccount
extends
MysqlBase
class
PlatformAccount
Log
extends
MysqlBase
{
{
const
TABLE_NAME
=
'platform_account'
;
const
TABLE_NAME
=
'platform_account
_log
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PlatformConfig.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Platform
Funds
extends
MysqlBase
class
Platform
Config
extends
MysqlBase
{
{
const
TABLE_NAME
=
'platform_
funds_lo
g'
;
const
TABLE_NAME
=
'platform_
confi
g'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PlatformFunds.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Platform
Account
extends
MysqlBase
class
Platform
Funds
extends
MysqlBase
{
{
const
TABLE_NAME
=
'platform_
account
'
;
const
TABLE_NAME
=
'platform_
funds
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/PlatformFundsLog.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Platform
Account
Log
extends
MysqlBase
class
Platform
Funds
Log
extends
MysqlBase
{
{
const
TABLE_NAME
=
'platform_
account
_log'
;
const
TABLE_NAME
=
'platform_
funds
_log'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/RefundMerchantRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Refund
Platform
Record
extends
MysqlBase
class
Refund
Merchant
Record
extends
MysqlBase
{
{
const
TABLE_NAME
=
'refund_
platform
_record'
;
const
TABLE_NAME
=
'refund_
merchant
_record'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/RefundOrder.php
View file @
d4916818
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
...
@@ -6,5 +6,5 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
RefundOrder
extends
MysqlBase
class
RefundOrder
extends
MysqlBase
{
{
const
TABLE_NAME
=
'refund_order'
;
const
TABLE_NAME
=
'refund_order'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/RefundOrderItem.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
RefundOrder
extends
MysqlBase
class
RefundOrder
Item
extends
MysqlBase
{
{
const
TABLE_NAME
=
'refund_order'
;
const
TABLE_NAME
=
'refund_order
_item
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/RefundPersonalRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Refund
OrderItem
extends
MysqlBase
class
Refund
PersonalRecord
extends
MysqlBase
{
{
const
TABLE_NAME
=
'refund_
order_item
'
;
const
TABLE_NAME
=
'refund_
personal_record
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/RefundPlatformRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
RefundP
ersonal
Record
extends
MysqlBase
class
RefundP
latform
Record
extends
MysqlBase
{
{
const
TABLE_NAME
=
'refund_p
ersonal
_record'
;
const
TABLE_NAME
=
'refund_p
latform
_record'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/WriteOffMerchantRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
WriteOff
Order
extends
MysqlBase
class
WriteOff
MerchantRecord
extends
MysqlBase
{
{
const
TABLE_NAME
=
'writeoff_
order
'
;
const
TABLE_NAME
=
'writeoff_
merchant_record
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/WriteOffOrder.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
Refund
Order
extends
MysqlBase
class
WriteOff
Order
extends
MysqlBase
{
{
const
TABLE_NAME
=
'
refund
_order'
;
const
TABLE_NAME
=
'
writeoff
_order'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/WriteOffOrderItem.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
RefundOrder
extends
MysqlBase
class
WriteOffOrderItem
extends
MysqlBase
{
{
const
TABLE_NAME
=
'
refund_order
'
;
const
TABLE_NAME
=
'
writeoff_order_item
'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/WriteOffPersonalRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
WriteOff
Merchant
Record
extends
MysqlBase
class
WriteOff
Personal
Record
extends
MysqlBase
{
{
const
TABLE_NAME
=
'writeoff_
merchant
_record'
;
const
TABLE_NAME
=
'writeoff_
personal
_record'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/models/order/mysql/WriteOffPlatformRecord.php
View file @
d4916818
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
...
@@ -3,8 +3,8 @@ namespace App\Models\order\mysql;
use
Api\PhpUtils\Mysql\MysqlBase
;
use
Api\PhpUtils\Mysql\MysqlBase
;
class
WriteOffP
ersonal
Record
extends
MysqlBase
class
WriteOffP
latform
Record
extends
MysqlBase
{
{
const
TABLE_NAME
=
'writeoff_p
ersonal
_record'
;
const
TABLE_NAME
=
'writeoff_p
latform
_record'
;
const
CONFIG_INDEX
=
'pay'
;
const
CONFIG_INDEX
=
'pay
_v2
'
;
}
}
application/modules/Pay/controllers/Tcc.php
View file @
d4916818
<?php
<?php
use
Api\PhpServices\Idgen\Idgen
;
use
App\Base\Base
;
use
App\Base\Base
;
use
App\Models\order\mysql\PayOrderItem
;
use
App\Models\order\mysql\PayOrderItem
;
...
@@ -82,4 +83,16 @@ class TccController extends Base
...
@@ -82,4 +83,16 @@ class TccController extends Base
$params
[
'traceId'
]
=
\Helpers\Tracer
::
getTraceId
();
$params
[
'traceId'
]
=
\Helpers\Tracer
::
getTraceId
();
$this
->
success
(
$params
);
$this
->
success
(
$params
);
}
}
public
function
idsAction
()
{
$number
=
$this
->
params
[
'number'
]
??
'12'
;
$count
=
$this
->
params
[
'count'
]
??
5
;
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
"55c768"
,
'number'
=>
$number
,
"count"
=>
$count
]]);
$id
=
$res
[
'id_datetime'
][
'55c768'
]
??
[];
$this
->
success
([
'ids'
=>
$id
]);
}
}
}
application/plugins/Hook.php
View file @
d4916818
...
@@ -51,12 +51,17 @@ class Hook extends \Yaf\Plugin_Abstract {
...
@@ -51,12 +51,17 @@ class Hook extends \Yaf\Plugin_Abstract {
return
false
;
return
false
;
}
}
// 优选选择 raw 方式, raw, $_POST 不能共存。
// raw, $_POST 不能共存。
if
(
!
empty
(
$_POST
))
{
return
false
;
}
// application/json形式,仅处理$_POST, 不整合$_GET
// application/json形式,仅处理$_POST, 不整合$_GET
switch
(
$request
->
getServer
(
'CONTENT_TYPE'
))
{
switch
(
strtolower
(
$request
->
getServer
(
'CONTENT_TYPE'
)
))
{
case
"application/json"
:
case
"application/json"
:
case
"application/json; charset=utf-8"
:
case
"application/json; charset=utf-8"
:
case
"application/json;charset=utf-8"
:
$jsonPost
=
file_get_contents
(
"php://input"
);
$jsonPost
=
file_get_contents
(
"php://input"
);
if
(
empty
(
$jsonPost
))
{
if
(
empty
(
$jsonPost
))
{
$_POST
=
[];
$_POST
=
[];
...
...
application/services/Channel.php
View file @
d4916818
<?php
<?php
namespace
App\Services
\order
;
namespace
App\Services
;
use
App\Exception\custom\CodeSpecialException
;
use
App\Services\channel\Pingxx
;
use
Helpers\Sdk
;
use
App\Services\channel\Platform
;
use
App\Exception\custom\PayException
;
class
OrderService
class
Channel
{
{
/**
/**
* @param $orderId
* @param $orderId
* @param $userId
* @param $userId
* 调用内部服务获取用户订单、子单、分润信息
* 调用内部服务获取用户订单、子单、分润信息
*/
*/
public
static
function
getFullOrderData
(
$order_id
)
{
public
static
function
getChannel
(
$pay_channel
)
{
$payer
=
null
;
switch
(
$pay_channel
)
{
case
'105'
:
case
'106'
:
case
'107'
:
case
'108'
:
case
'109'
:
case
'110'
:
$payer
=
new
Pingxx
();
break
;
case
'1'
:
$payer
=
new
Platform
();
break
;
$url
=
config
(
'interface'
,
'order.order.pay_order'
);
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
.
__METHOD__
);
}
}
$params
=
[
'order_id'
=>
$order_id
];
if
(
empty
(
$payer
))
{
return
Sdk
::
call
(
$url
,
$params
);
throw
new
PayException
([
'cus'
=>
100
]
);
}
}
public
static
function
getOrderInfo
(
$order_id
,
$user_id
)
{
return
$payer
;
//pay_order_info
$url
=
config
(
'interface'
,
'order.order.pay_order_info'
);
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
.
__METHOD__
);
}
}
$params
=
[
'order_id'
=>
$order_id
,
'user_id'
=>
$user_id
];
return
Sdk
::
call
(
$url
,
$params
);
}
/**
* @param $order_item_id
* @param $user_id
* @return bool|mixed
* @throws CodeSpecialException
* 获取订单子单信息
*/
public
static
function
getOrderItemData
(
$order_item_id
)
{
//merchant.account.get_role_list
$url
=
config
(
'interface'
,
'order.order.pay_order_item'
);
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
.
__METHOD__
);
}
$params
=
[
'order_item_id'
=>
$order_item_id
];
return
Sdk
::
call
(
$url
,
$params
);
}
}
}
\ No newline at end of file
application/services/channel/Pingxx.php
View file @
d4916818
<?php
<?php
namespace
App\Services\channel
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Exception\custom\RefundException
;
use
App\Models\order\mysql\PlatformConfig
;
use
App\Services\pingxx\PingxxService
;
use
App\Exception\custom\PayException
;
use
App\Exception\BaseException
;
class
Pingxx
{
/**
* @param $pay_order
* @param $mata_data
* 系统支付
*/
public
function
pay
(
$pay_order
,
$mata_data
,
$extra
=
[])
{
// 已经创建,需要查询返回
if
(
!
empty
(
$pay_order
[
'third_order_id'
]))
{
$ret
=
PingxxService
::
getInstance
()
->
getOrder
(
$pay_order
[
'third_order_id'
]);
}
else
{
$ret
=
PingxxService
::
getInstance
()
->
createOrder
(
$pay_order
,
$mata_data
);
}
if
(
!
empty
(
$ret
[
'error'
]))
{
throw
new
BaseException
([
'msg'
=>
$ret
[
'error'
][
'message'
],
'code'
=>
'2301'
]);
}
if
(
$ret
[
"status"
]
==
'paid'
||
$ret
[
'status'
]
==
'refunded'
)
{
throw
new
PayException
([
'cus'
=>
101
]);
}
elseif
(
$ret
[
"status"
]
==
'canceled'
)
{
throw
new
PayException
([
'cus'
=>
102
]);
}
elseif
(
$ret
[
"status"
]
==
'created'
)
{
;
}
else
{
throw
new
PayException
([
'cus'
=>
103
]);
}
$channel_exist
=
false
;
$channel
=
$this
->
getChannel
(
$pay_order
[
'pay_channel'
]);
if
(
!
empty
(
$ret
[
'charges'
][
'data'
]))
{
//是否存在
foreach
(
$ret
[
'charges'
][
'data'
]
as
$ch
)
{
if
(
$ch
[
'channel'
]
==
$channel
)
{
$channel_exist
=
true
;
}
}
}
//判断是否做过pay操作 charge
if
(
$channel_exist
==
false
)
{
// 创建支付单
$payment
=
[
'charge_order_no'
=>
$pay_order
[
'pay_order_id'
],
'charge_amount'
=>
$pay_order
[
'pay_amount'
],
'channel'
=>
$channel
,
'extra'
=>
$extra
,
];
$pay
=
PingxxService
::
getInstance
()
->
pay
(
$ret
[
'id'
],
$payment
);
if
(
!
empty
(
$pay
[
'error'
]))
{
throw
new
BaseException
([
'msg'
=>
$pay
[
'error'
][
'message'
],
'code'
=>
'2002'
]);
}
return
$pay
;
}
else
{
return
$ret
;
}
}
/**
* @param $pay_order
* @param $mata_data
* 系统退款
*/
public
function
refund
(
$data
,
$mata_data
)
{
/*
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'
=>
7
]);
}
// 存在多次支付的场景需要人工介入处理, 修复订单支付金额,退款金额
if
(
$pay
[
'amount_paid'
]
>
$pay
[
'actual_amount'
])
{
FileLog
::
error
(
'pay-service: 订单可能存在多次成功支付,需人工确认处理。'
,
json_encode
(
$pay
,
JSON_UNESCAPED_UNICODE
));
throw
new
RefundException
([
'cus'
=>
8
]);
}
// 构造退款数据
$refund
=
[
'id'
=>
$pay
[
'id'
],
//pingxx订单ID
'charge'
=>
$pay
[
'charge'
],
//pingxx 支付订单ID
'refund_mode'
=>
'to_source'
,
//默认返回
'charge_amount'
=>
$data
[
'refund_order'
][
'refund_amount'
],
'metadata'
=>
$mata_data
,
];
return
PingxxService
::
getInstance
()
->
sendRefund
(
$refund
);
}
private
function
getChannel
(
$pay_method_id
)
{
$maps
=
[
1
=>
"syt"
,
//系统余额支付
105
=>
"wx"
,
//微信 App 支付
106
=>
"alipay"
,
//支付宝
107
=>
"wx_pub"
,
//微信 JSAPI 支付
108
=>
"wx_pub_qr"
,
//微信 Native 支付
109
=>
"wx_wap"
,
//微信 H5 支付
110
=>
"wx_lite"
,
//微信小程序支付
];
if
(
!
empty
(
$maps
[
$pay_method_id
]))
{
return
$maps
[
$pay_method_id
];
}
else
{
return
$maps
[
105
];
}
}
/**
* @param $pay_order
* @return array
* @throws PayException
* 手续费计算
*/
public
function
clearChannelTips
(
$pay_order
)
{
//PlatformConfig
$info
=
PlatformConfig
::
get
(
'*'
,
[
'account_type'
=>
2
,
'channel'
=>
1
,
'source_name'
=>
$pay_order
[
'source_name'
],
'service_name'
=>
$pay_order
[
'service_name'
]
]);
if
(
empty
(
$info
))
{
throw
new
PayException
([
'cus'
=>
104
]);
}
$float_tip
=
$info
[
'rate'
]
*
$pay_order
[
'payment'
]
/
10000
;
if
(
$float_tip
>=
1
)
{
$total_tip
=
round
(
$float_tip
);
return
[
'account_id'
=>
$info
[
'account_id'
],
'amount'
=>
$total_tip
,
];
}
else
{
return
[];
}
}
public
function
clearPlatformTips
(
$pay_order
)
{
//PlatformConfig
$info
=
PlatformConfig
::
get
(
'*'
,
[
'account_type'
=>
1
,
'channel'
=>
1
,
'source_name'
=>
$pay_order
[
'source_name'
],
'service_name'
=>
$pay_order
[
'service_name'
]
]);
if
(
empty
(
$info
))
{
throw
new
PayException
([
'cus'
=>
104
]);
}
$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
[];
}
}
public
function
getFundsInfo
(
$pay_order
)
{
$info
=
PlatformConfig
::
get
(
'*'
,
[
'account_type'
=>
3
,
'channel'
=>
1
,
'source_name'
=>
$pay_order
[
'source_name'
],
'service_name'
=>
$pay_order
[
'service_name'
]
]);
if
(
empty
(
$info
))
{
throw
new
PayException
([
'cus'
=>
104
]);
}
return
$info
;
}
}
application/services/channel/Platform.php
View file @
d4916818
<?php
<?php
namespace
App\Services\channel
;
class
Platform
{
/**
* @param $pay_order
* @param $mata_data
* 系统支付
*/
public
function
pay
(
$pay_order
,
$mata_data
)
{
//todo 保存数据
return
[];
}
/**
* @param $pay_order
* @param $mata_data
* 系统退款
*/
public
function
refund
(
$pay_order
,
$mata_data
)
{
}
}
\ No newline at end of file
application/services/marketing/AccountService.php
View file @
d4916818
<?php
<?php
namespace
App\Services\
wallet
;
namespace
App\Services\
marketing
;
use
App\Exception\custom\CodeSpecialException
;
use
Helpers\Sdk
;
use
App\Models\order\mysql\MarketingAccount
;
use
App\Models\order\mysql\MarketingAccountLog
;
use
App\Models\order\mysql\MarketingAccountMap
;
class
WalletService
class
AccountService
{
{
private
static
$maps
=
[];
/**
* @param $list
* @param $order_id
* @return bool
* 资金冻结
*/
public
static
function
frozen
(
$list
,
$order_id
)
{
$coupon
=
self
::
formatData
(
$list
);
$cnt
=
true
;
foreach
(
$coupon
as
$id
=>
$amount
)
{
$marketing_account_id
=
self
::
map
(
$id
);
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'frozen_amount[+]'
=>
$amount
,
'receivable_amount[-]'
=>
$amount
,
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$id
,
'fund_type'
=>
1
,
'trade_id'
=>
$order_id
,
'amount'
=>
$amount
,
],
[
'rowCount'
=>
true
]);
}
return
$cnt
;
}
/**
/**
* @param $
params
* @param $
list
* @
return bool|mixe
d
* @
param $order_i
d
* @
throws CodeSpecialException
* @
return bool
*
钱包记录同步
*
营销资金扣款
*/
*/
public
static
function
send
(
$params
)
{
public
static
function
pay
(
$list
,
$order_id
)
{
$coupon
=
self
::
formatData
(
$list
);
$url
=
config
(
'interface'
,
'wallet.account.transfer'
);
$cnt
=
true
;
if
(
!
$url
)
{
// 冻结优惠信息
throw
new
CodeSpecialException
(
"failed"
);
foreach
(
$coupon
as
$id
=>
$amount
)
{
$marketing_account_id
=
self
::
map
(
$id
);
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'frozen_amount[-]'
=>
$amount
,
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$id
,
'fund_type'
=>
2
,
'trade_id'
=>
$order_id
,
'amount'
=>
$amount
,
],
[
'rowCount'
=>
true
]);
}
return
$cnt
;
}
}
// 服务增加签名
/**
$appid
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
'wallet.appid'
);
* @param $list
$secret
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
'wallet.secret'
);
* @param $refund_order_id
* @return bool
* 退款营销可用增加
*/
public
static
function
refund
(
$list
,
$refund_order_id
)
{
$coupon
=
self
::
formatData
(
$list
);
$cnt
=
true
;
$params
[
'time'
]
=
date
(
'Y-m-d H:i:s'
);
foreach
(
$coupon
as
$id
=>
$amount
)
{
$params
[
'transfer_service_id'
]
=
$appid
;
$marketing_account_id
=
self
::
map
(
$id
);
$params
[
'sign'
]
=
self
::
sign
(
$params
,
$secret
);
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'receivable_amount[+]'
=>
$amount
,
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$id
,
'fund_type'
=>
3
,
'trade_id'
=>
$refund_order_id
,
'amount'
=>
$amount
,
],
[
'rowCount'
=>
true
]);
}
return
$cnt
;
}
/**
* @param $list
* @param $order_id
* @return bool
* 未支付取消,营销冻结释放
*/
public
static
function
cancel
(
$list
,
$order_id
)
{
$coupon
=
self
::
formatData
(
$list
);
$cnt
=
true
;
return
Sdk
::
call
(
$url
,
$params
);
foreach
(
$coupon
as
$id
=>
$amount
)
{
$marketing_account_id
=
self
::
map
(
$id
);
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'receivable_amount[+]'
=>
$amount
,
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$id
,
'fund_type'
=>
4
,
'trade_id'
=>
$order_id
,
'amount'
=>
$amount
,
],
[
'rowCount'
=>
true
]);
}
return
$cnt
;
}
/**
* @param $data
* @param $marketing_account_id
* @return bool
* 营销充值
*/
public
static
function
recharge
(
$data
,
$marketing_account_id
)
{
$cnt
=
true
;
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'receivable_amount[+]'
=>
$data
[
'amount'
]
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$data
[
'third_id'
],
'fund_type'
=>
5
,
'trade_id'
=>
$data
[
'trade_id'
],
'amount'
=>
$data
[
'amount'
],
]);
return
$cnt
;
}
public
static
function
transfer
(
$data
,
$marketing_account_id
)
{
$cnt
=
true
;
$cnt
=
$cnt
&&
MarketingAccount
::
update
([
'receivable_amount[-]'
=>
$data
[
'amount'
]
],
[
'marketing_account_id'
=>
$marketing_account_id
]);
$cnt
=
$cnt
&&
MarketingAccountLog
::
insert
([
'marketing_account_id'
=>
$marketing_account_id
,
'third_id'
=>
$data
[
'third_id'
],
'fund_type'
=>
6
,
'trade_id'
=>
$data
[
'trade_id'
],
'amount'
=>
$data
[
'amount'
],
]);
return
$cnt
;
}
public
static
function
map
(
$third_id
,
$source_name
=
10
,
$service_name
=
1
)
{
if
(
!
isset
(
self
::
$maps
[
$third_id
]))
{
$info
=
MarketingAccountMap
::
get
(
'*'
,
[
'third_id'
=>
$third_id
,
'source_name'
=>
$source_name
,
'service_name'
=>
$service_name
]);
if
(
$info
)
{
self
::
$maps
[
$third_id
]
=
$info
[
'marketing_account_id'
];
}
else
{
self
::
$maps
[
$third_id
]
=
''
;
}
}
return
self
::
$maps
[
$third_id
];
}
private
static
function
formatData
(
$list
)
{
$coupon
=
[];
foreach
(
$list
as
$r
)
{
if
(
!
isset
(
$coupon
[
$r
[
'capital_pool_id'
]]))
{
$coupon
[
$r
[
'capital_pool_id'
]]
=
0
;
}
$coupon
[
$r
[
'capital_pool_id'
]]
+=
$r
[
'share_coupon_amount'
];
}
}
private
function
sign
(
$params
,
$secret
)
{
return
$coupon
;
$sign
=
md5
(
$params
[
'time'
]
.
$secret
);
return
$sign
;
}
}
}
}
\ No newline at end of file
application/services/pay/FundsService.php
View file @
d4916818
This diff is collapsed.
Click to expand it.
application/services/pay/PayService.php
View file @
d4916818
This diff is collapsed.
Click to expand it.
application/services/pay/PlatformAccountService.php
View file @
d4916818
...
@@ -4,10 +4,10 @@
...
@@ -4,10 +4,10 @@
namespace
App\Services\pay
;
namespace
App\Services\pay
;
use
App\Exception\custom\FundsException
;
use
App\Exception\custom\FundsException
;
use
App\Models\order\mysql\Platform
Funds
;
use
App\Models\order\mysql\Platform
Account
;
use
App\Models\order\mysql\Platform
Funds
Log
;
use
App\Models\order\mysql\Platform
Account
Log
;
class
Funds
Service
class
PlatformAccount
Service
{
{
/**
/**
* @param $data
* @param $data
...
@@ -17,62 +17,27 @@ class FundsService
...
@@ -17,62 +17,27 @@ class FundsService
* @throws FundsException
* @throws FundsException
* 渠道账户入账记录
* 渠道账户入账记录
*/
*/
public
static
function
credit
(
$data
,
$
channel
=
1
,
$
source_name
=
10
,
$service_name
=
1
)
{
public
static
function
credit
(
$data
,
$source_name
=
10
,
$service_name
=
1
)
{
$info
=
PlatformFunds
::
getMaster
(
'*'
,
$info
=
PlatformAccount
::
getMaster
(
'*'
,
[
'channel'
=>
$channel
,
'source_name'
=>
$source_name
,
'service_name'
=>
$service_name
]);
[
'source_name'
=>
$source_name
,
'service_name'
=>
$service_name
]);
if
(
empty
(
$info
))
{
throw
new
FundsException
([
'cus'
=>
1
]);
}
$cnt
=
PlatformFunds
::
update
([
'total_amount[+]'
=>
$data
[
'amount'
],
'total_tip[+]'
=>
$data
[
'tip'
],
],
[
'platform_funds_id'
=>
$info
[
'platform_funds_id'
]]);
$l_cnt
=
PlatformFundsLog
::
insert
([
'platform_funds_id'
=>
$info
[
'platform_funds_id'
],
'trade_id'
=>
$data
[
'order_id'
],
'third_order_id'
=>
$data
[
'third_id'
],
'fund_type'
=>
1
,
'amount'
=>
$data
[
'amount'
],
'tip'
=>
$data
[
'tip'
],
],
[
'rowCount'
=>
true
]);
return
$l_cnt
&&
$cnt
;
}
/**
* @param $data
* @param int $channel
* @param int $source_name
* @param int $service_name
* @throws FundsException
* 渠道账户出账
*/
public
static
function
payOut
(
$data
,
$channel
=
1
,
$source_name
=
10
,
$service_name
=
1
)
{
$info
=
PlatformFunds
::
getMaster
(
'*'
,
[
'channel'
=>
$channel
,
'source_name'
=>
$source_name
,
'service_name'
=>
$service_name
]);
if
(
empty
(
$info
))
{
if
(
empty
(
$info
))
{
throw
new
FundsException
([
'cus'
=>
1
]);
throw
new
FundsException
([
'cus'
=>
1
]);
}
}
$cnt
=
true
;
$cnt
=
true
;
$cnt
=
$cnt
&&
PlatformFunds
::
update
([
$cnt
=
$cnt
&&
PlatformAccount
::
update
([
'total_amount[-]'
=>
$data
[
'amount'
],
'receivable_amount[+]'
=>
$data
[
'amount'
]
'total_tip[-]'
=>
$data
[
'tip'
],
],
[
'platform_funds_id'
=>
$info
[
'platform_funds_id'
]]);
],
[
'platform_funds_id'
=>
$info
[
'platform_funds_id'
]]);
$cnt
=
$cnt
&&
PlatformFundsLog
::
insert
([
$cnt
=
$cnt
&&
PlatformAccountLog
::
insert
([
'platform_funds_id'
=>
$info
[
'platform_funds_id'
],
'platform_account_id'
=>
$info
[
'platform_account_id'
],
'trade_id'
=>
$data
[
'order_id'
],
'trade_id'
=>
$data
[
'trade_id'
],
'third_order_id'
=>
$data
[
'third_id'
],
'fund_type'
=>
1
,
'fund_type'
=>
2
,
'amount'
=>
$data
[
'amount'
]
'amount'
=>
$data
[
'amount'
],
'tip'
=>
$data
[
'tip'
],
],
[
'rowCount'
=>
true
]);
],
[
'rowCount'
=>
true
]);
return
$cnt
;
return
$cnt
;
}
}
}
}
\ No newline at end of file
application/services/refund/RefundService.php
View file @
d4916818
This diff is collapsed.
Click to expand it.
application/services/wallet/MerchantAccountService.php
View file @
d4916818
...
@@ -7,7 +7,7 @@ use App\Exception\custom\CodeSpecialException;
...
@@ -7,7 +7,7 @@ use App\Exception\custom\CodeSpecialException;
use
Helpers\Sdk
;
use
Helpers\Sdk
;
class
Walle
tService
class
MerchantAccoun
tService
{
{
/**
/**
...
@@ -16,12 +16,15 @@ class WalletService
...
@@ -16,12 +16,15 @@ class WalletService
* @throws CodeSpecialException
* @throws CodeSpecialException
* 钱包记录同步
* 钱包记录同步
*/
*/
public
static
function
send
(
$params
)
{
public
static
function
sync
(
$params
)
{
/*
$url
=
config
(
'interface'
,
'wallet.account.transfer'
);
///account/billrecord/create
$url = config('interface', 'account.account.transfer');
if (!$url) {
if (!$url) {
throw new CodeSpecialException("failed");
throw new CodeSpecialException("failed");
}
}
*/
$url
=
'http://account.dev.yidian-inc.com/account/billrecord/create'
;
// 服务增加签名
// 服务增加签名
$appid
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
'wallet.appid'
);
$appid
=
\Yaf\Application
::
app
()
->
getConfig
()
->
get
(
'wallet.appid'
);
...
...
application/services/wallet/WalletService.php
View file @
d4916818
...
@@ -38,4 +38,5 @@ class WalletService
...
@@ -38,4 +38,5 @@ class WalletService
$sign
=
md5
(
$params
[
'time'
]
.
$secret
);
$sign
=
md5
(
$params
[
'time'
]
.
$secret
);
return
$sign
;
return
$sign
;
}
}
}
}
\ No newline at end of file
public/demo.php
View file @
d4916818
<?php
<?php
var_dump
(
$_POST
);
$ids
=
[
"21092214200312204001"
,
"21092214200312204002"
,
"21092214200312204003"
,
"21092214200312204004"
,
"21092214200312204005"
];
$t
=
array_shift
(
$ids
);
var_dump
(
$t
);
\ No newline at end of file
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