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
440ba706
Commit
440ba706
authored
Jun 30, 2021
by
cuiweifeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_wanjilong' of
https://gitlab.yidian-inc.com/bp/pay
into dev_wanjilong
parents
07b1614b
c487b748
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
436 additions
and
82 deletions
+436
-82
PayException.php
application/exception/custom/PayException.php
+2
-1
Strategy.php
application/library/Helpers/Strategy.php
+45
-0
Dictionary.php
application/models/Dictionary.php
+17
-0
PayOrder.php
application/models/order/mysql/PayOrder.php
+31
-3
Account.php
application/modules/Pay/controllers/Account.php
+1
-1
OrderService.php
application/services/order/OrderService.php
+3
-0
PayService.php
application/services/pay/PayService.php
+337
-77
No files found.
application/exception/custom/PayException.php
View file @
440ba706
...
...
@@ -12,6 +12,7 @@ class PayException extends BaseException
protected
$cus
=
[
0
=>
'用户已通过个人认证,无需重复认证'
,
1
=>
'企业已通过认证,无需重复认证'
1
=>
'企业已通过认证,无需重复认证'
,
4
=>
'费率计算错误,费率分母为0'
,
];
}
application/library/Helpers/Strategy.php
0 → 100644
View file @
440ba706
<?php
namespace
Helpers
;
/**
* Strategy 计算手续费策略
*/
class
Strategy
{
/**
* @param $current_amount
* @param $total_amount
* @param $cleared_amount
* @param $total_tip
* @param $cleared_tip
* 计算微信手续费公式,计算单位是分
*/
public
static
function
getWxTip
(
$current_amount
,
$total_amount
,
$cleared_amount
,
$total_tip
,
$cleared_tip
)
{
$left_amount
=
$total_amount
-
$cleared_amount
;
if
(
$left_amount
==
0
)
{
return
$left_amount
;
}
return
round
(
$current_amount
/
$left_amount
*
(
$total_tip
-
$cleared_tip
));
}
/**
* @param $current_amount
* @param $total_amount
* @param $cleared_amount
* @param $total_tip
* @param $cleared_tip
* @return false|float
* 计算平台手续费
*/
public
static
function
getTip
(
$current_amount
,
$total_amount
,
$cleared_amount
,
$total_tip
,
$cleared_tip
)
{
$left_amount
=
$total_amount
-
$cleared_amount
;
if
(
$left_amount
==
0
)
{
return
$left_amount
;
}
return
round
(
$current_amount
/
$left_amount
*
(
$total_tip
-
$cleared_tip
));
}
}
\ No newline at end of file
application/models/Dictionary.php
View file @
440ba706
...
...
@@ -24,4 +24,21 @@ class Dictionary
public
const
SOURCE_LIFE
=
1
;
//生活圈
public
const
SOURCE_MAIN
=
2
;
//主端
public
const
PAY_TYPE_IN
=
1
;
//入账
public
const
PAY_TYPE_OUT
=
2
;
//出账
public
const
PAY_SUB_TYPE_WX
=
1
;
//微信手续费
public
const
PAY_SUB_TYPE_SYS_IN
=
3
;
//平台营收
public
const
PAY_SUB_TYPE_M_IN
=
4
;
//商家收入
public
const
PAY_SUB_TYPE_C_IN
=
5
;
//团长收入
public
const
PAY_SUB_TYPE_SYS_OUT
=
21
;
//平台补贴
public
const
PAY_SUB_TYPE_M_OUT
=
22
;
//商家补贴
public
const
ACCOUNT_TYPE_C
=
1
;
//用户
public
const
ACCOUNT_TYPE_M
=
2
;
//商户
public
const
ACCOUNT_TYPE_SS
=
3
;
//平台(平台收入+平台补贴)
public
const
ACCOUNT_TYPE_ST
=
4
;
//平台交易总账+三方手续费
}
application/models/order/mysql/PayOrder.php
View file @
440ba706
...
...
@@ -21,10 +21,38 @@ class PayOrder extends MysqlBase
return
'pay_order_id'
;
}
public
function
selectForUpdate
(
$id
)
{
/**
* @param $order_id
* @param $pay_order
* @return array
*/
public
static
function
get_valid_order
(
$order_id
,
$pay_order
)
{
$link
=
self
::
getConnection
(
'write'
);
$link
->
pdo
->
$order
=
[];
$link
->
action
(
function
(
$link
,
$order_id
,
$pay_order
)
use
(
&
$order
)
{
$_date
=
date
(
'Y-h-m H:i:s'
);
$sql
=
"select * from "
.
self
::
getTableName
()
.
" where order_id = :order_id and expire_time >:date limit 1 for update"
;
$order
=
$link
->
query
(
$sql
,
[
":order_id"
=>
$order_id
,
":date"
=>
$_date
]
)
->
fetch
();
if
(
empty
(
$order
))
{
$new
[
'order_id'
]
=
$order_id
;
$link
->
insert
(
self
::
getTableName
(),
$pay_order
);
$order
=
$link
->
query
(
$sql
,
[
":order_id"
=>
$order_id
,
":date"
=>
$_date
]
)
->
fetch
();
}
});
return
$order
;
}
}
application/modules/Pay/controllers/Account.php
View file @
440ba706
...
...
@@ -25,7 +25,7 @@ class AccountController extends Base
/**
* 创建未认证的个人生活号
*/
public
function
create
_unauthorized
Action
()
public
function
createAction
()
{
// 获取手机号
(
new
UserPhoneValidate
())
->
validate
();
...
...
application/services/order/OrderService.php
View file @
440ba706
...
...
@@ -55,6 +55,9 @@ class OrderService
]
];
foreach
(
$order_items
as
$r
)
{
$order_distribution
[]
=
[
'commission_mode'
=>
1
,
...
...
application/services/pay/PayService.php
View file @
440ba706
This diff is collapsed.
Click to expand it.
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