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
11e8f98f
Commit
11e8f98f
authored
Jul 01, 2021
by
wanjilong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: init
parent
4d37e865
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
154 additions
and
12 deletions
+154
-12
RefundException.php
application/exception/custom/RefundException.php
+21
-0
Dictionary.php
application/models/Dictionary.php
+5
-0
PayOrderClearing.php
application/models/order/mysql/PayOrderClearing.php
+1
-1
PayOrderClearingItem.php
application/models/order/mysql/PayOrderClearingItem.php
+1
-1
RefundOrder.php
application/models/order/mysql/RefundOrder.php
+1
-1
OrderService.php
application/services/order/OrderService.php
+13
-5
PayService.php
application/services/pay/PayService.php
+2
-4
RefundService.php
application/services/refund/RefundService.php
+110
-0
No files found.
application/exception/custom/RefundException.php
0 → 100644
View file @
11e8f98f
<?php
namespace
App\Exception\custom
;
use
App\Exception\BaseException
;
class
RefundException
extends
BaseException
{
protected
$base_code
=
Code
::
REFUND
;
protected
$cus
=
[
0
=>
'系统异常请联系管理员'
,
1
=>
'订单信息不存在,请核对'
,
2
=>
'退款已经成功操作,请核对'
,
3
=>
'退款进行中,请稍等'
,
4
=>
'目前仅支持支付后的订单退款,请核对'
,
5
=>
'该订单不允许退款,请核对'
,
];
}
application/models/Dictionary.php
View file @
11e8f98f
...
@@ -41,4 +41,9 @@ class Dictionary
...
@@ -41,4 +41,9 @@ class Dictionary
public
const
ACCOUNT_TYPE_SS
=
3
;
//平台(平台收入+平台补贴)
public
const
ACCOUNT_TYPE_SS
=
3
;
//平台(平台收入+平台补贴)
public
const
ACCOUNT_TYPE_ST
=
4
;
//平台交易总账+三方手续费
public
const
ACCOUNT_TYPE_ST
=
4
;
//平台交易总账+三方手续费
public
const
REFUND_ORDER_STATUS_UNDO
=
0
;
//未退款
public
const
REFUND_ORDER_STATUS_SEND
=
1
;
//待确认
public
const
REFUND_ORDER_STATUS_OK
=
2
;
//已退款
}
}
application/models/order/mysql/PayOrderClearing.php
View file @
11e8f98f
<?php
<?php
namespace
App\Models\order\mysql
;
namespace
App\Models\order\mysql
;
use
Api\PhpUtils\Mysql\Base
;
use
Api\PhpUtils\Mysql\
Mysql
Base
;
class
PayOrderClearing
extends
MysqlBase
class
PayOrderClearing
extends
MysqlBase
{
{
...
...
application/models/order/mysql/PayOrderClearingItem.php
View file @
11e8f98f
<?php
<?php
namespace
App\Models\order\mysql
;
namespace
App\Models\order\mysql
;
use
Api\PhpUtils\Mysql\Base
;
use
Api\PhpUtils\Mysql\
Mysql
Base
;
class
PayOrderClearingItem
extends
MysqlBase
class
PayOrderClearingItem
extends
MysqlBase
{
{
...
...
application/models/order/mysql/RefundOrder.php
View file @
11e8f98f
<?php
<?php
namespace
App\Models\order\mysql
;
namespace
App\Models\order\mysql
;
use
Api\PhpUtils\Mysql\Base
;
use
Api\PhpUtils\Mysql\
Mysql
Base
;
class
RefundOrder
extends
MysqlBase
class
RefundOrder
extends
MysqlBase
{
{
...
...
application/services/order/OrderService.php
View file @
11e8f98f
...
@@ -21,8 +21,19 @@ class OrderService
...
@@ -21,8 +21,19 @@ class OrderService
* @param $userId
* @param $userId
* 调用内部服务获取用户订单、子单、分润信息
* 调用内部服务获取用户订单、子单、分润信息
*/
*/
public
static
function
getOrderData
(
$orderId
,
$userId
)
{
public
static
function
getOrderData
(
$order_id
,
$user_id
)
{
return
self
::
getDemoData
(
$orderId
,
$userId
);
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
)
{
public
static
function
getDemoData
(
$orderId
,
$userId
)
{
...
@@ -55,9 +66,6 @@ class OrderService
...
@@ -55,9 +66,6 @@ class OrderService
]
]
];
];
foreach
(
$order_items
as
$r
)
{
foreach
(
$order_items
as
$r
)
{
$order_distribution
[]
=
[
$order_distribution
[]
=
[
'commission_mode'
=>
1
,
'commission_mode'
=>
1
,
...
...
application/services/pay/PayService.php
View file @
11e8f98f
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
namespace
App\Services\pay
;
namespace
App\Services\pay
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Models\Dictionary
;
use
App\Models\Dictionary
;
use
App\Models\order\mysql\PayOrder
;
use
App\Models\order\mysql\PayOrder
;
...
@@ -116,7 +115,6 @@ class PayService
...
@@ -116,7 +115,6 @@ class PayService
$merchant_cash
=
$this
->
order_info
[
'payment'
]
+
$subsidy_tip
+
$merchant_tip
-
$wx_tip
-
$distribution_tip
-
$platform_tip
;
$merchant_cash
=
$this
->
order_info
[
'payment'
]
+
$subsidy_tip
+
$merchant_tip
-
$wx_tip
-
$distribution_tip
-
$platform_tip
;
$this
->
make_merchant_clearing
(
$merchant_cash
);
//商户收益
$this
->
make_merchant_clearing
(
$merchant_cash
);
//商户收益
try
{
try
{
PayOrderClearing
::
beginTransaction
();
PayOrderClearing
::
beginTransaction
();
$cnt
=
PayOrderClearing
::
insert
(
$this
->
clear_list
,
[
'rowCount'
=>
true
]);
$cnt
=
PayOrderClearing
::
insert
(
$this
->
clear_list
,
[
'rowCount'
=>
true
]);
...
@@ -330,8 +328,8 @@ class PayService
...
@@ -330,8 +328,8 @@ class PayService
$this
->
clear_items_list
[]
=
[
$this
->
clear_items_list
[]
=
[
'pay_order_clearing_item_id'
=>
$this
->
gen_pay_order_clearing_item_id
(),
'pay_order_clearing_item_id'
=>
$this
->
gen_pay_order_clearing_item_id
(),
'pay_order_clearing_id'
=>
$
this
->
pay_order
[
'pay_order_id'
]
,
'pay_order_clearing_id'
=>
$
pay_order_clearing_id
,
'pay_order_id'
=>
$this
->
order_info
[
'order_id'
],
'pay_order_id'
=>
$this
->
order_info
[
'
pay_
order_id'
],
'order_id'
=>
$this
->
order_info
[
'order_id'
],
'order_id'
=>
$this
->
order_info
[
'order_id'
],
'account_id'
=>
$account
[
'account_id'
],
'account_id'
=>
$account
[
'account_id'
],
'account_type'
=>
$account
[
'account_type'
],
'account_type'
=>
$account
[
'account_type'
],
...
...
application/services/refund/RefundService.php
0 → 100644
View file @
11e8f98f
<?php
namespace
App\Services\refund
;
use
Api\PhpServices\Idgen\Idgen
;
use
App\Models\Dictionary
;
use
App\Models\order\mysql\PayOrder
;
use
App\Models\order\mysql\PayOrderClearing
;
use
App\Models\order\mysql\PayOrderClearingItem
;
use
App\Models\order\mysql\RefundOrder
;
use
App\Services\Order\OrderService
;
use
Helpers\Strategy
;
use
Helpers\Logger
;
use
App\Exception\custom\RefundException
;
class
RefundService
{
public
function
do_refund
(
$order_item_id
,
$user_id
)
{
// 获取子单信息
$order_item
=
OrderService
::
getOrderItemData
(
$order_item_id
,
$user_id
);
if
(
empty
(
$order_item
))
{
throw
new
RefundException
([
'cus'
=>
1
]);
}
$where
=
[
'order_item_id'
=>
$order_item_id
,
'user_id'
=>
$user_id
,
'order_id'
=>
$order_item
[
'order_id'
],
'refund_order_id'
=>
$this
->
gen_refund_order_id
(),
];
$refund_order
=
$this
->
can_refund
(
$where
);
// 重新计算手续费
// 创建退款订单,计算微信退款手续费
// 修改订单支付状态,
// 发起ping++ 创建退款
$this
->
send_pingxx
(
$order_item
);
}
/**
* @param $where
* @return \Api\PhpUtils\Mysql\MysqlBase|array
* @throws RefundException
* 判断订单是否可退,判断是否存在退款申请
*/
private
function
can_refund
(
$where
)
{
/**
* 业务方自行解决,订单关闭、订单超过时长不允许退款等逻辑
* 支付中心退款判断仅做主单是否支付,主单是否支持退款的判断
*/
try
{
RefundOrder
::
beginTransaction
();
$pay_order
=
PayOrder
::
getMaster
(
'*'
,
[
'order_id'
=>
$where
[
'order_id'
],
'pay_order_status'
=>
Dictionary
::
O_PAY_STATUS_PAYED
]);
if
(
empty
(
$pay_order
))
{
throw
new
RefundException
([
'cus'
=>
4
]);
}
/* 子单是否已经结算分润
if($pay_order['can_refund']) {
throw new RefundException(['cus' => 5]);
}
*/
$refund_order
=
RefundOrder
::
getMaster
(
'*'
,
[
'order_item_id'
=>
$where
[
'order_item_id'
]]);
if
(
!
empty
(
$refund_order
))
{
if
(
$refund_order
[
'refund_order_status'
]
==
Dictionary
::
REFUND_ORDER_STATUS_OK
)
{
throw
new
RefundException
([
'cus'
=>
2
]);
}
if
(
$refund_order
[
'refund_order_status'
]
==
Dictionary
::
REFUND_ORDER_STATUS_SEND
)
{
throw
new
RefundException
([
'cus'
=>
3
]);
}
}
else
{
$refund_order
=
$where
;
$refund_order
[
'refund_order_status'
]
=
Dictionary
::
REFUND_ORDER_STATUS_SEND
;
$refund_order
[
'refund_amount'
]
=
0
;
$cnt
=
RefundOrder
::
insert
(
$refund_order
,
[
'rowCount'
=>
true
]);
if
(
$cnt
==
0
)
{
throw
new
RefundException
([
'cus'
=>
0
]);
}
}
RefundOrder
::
commit
();
}
catch
(
\PDOException
$e
)
{
Logger
::
error
(
$e
->
getMessage
(),
[]);
RefundOrder
::
rollback
();
throw
new
RefundException
([
'cut'
=>
0
]);
}
return
$refund_order
;
}
}
\ 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