修正医生体现数据2

This commit is contained in:
2024-04-23 14:44:00 +08:00
parent 18b6bf72ae
commit 37ca9c1e21
5 changed files with 189 additions and 201 deletions
+76
View File
@@ -15,6 +15,7 @@ use App\Model\OrderProduct;
use App\Model\OrderProductRefund;
use App\Model\OrderRefund;
use App\Model\OrderServicePackage;
use App\Model\OrderServicePackageDetail;
use App\Model\OrderServicePackageInquiry;
use App\Model\OrderServicePackageRefund;
use App\Utils\Log;
@@ -1009,4 +1010,79 @@ class OrderService extends BaseService
return $result;
}
/**
* 获取订单退款金额
* @param string|int $order_no
* @return string|int
*/
public function getOrderRefundAmount(string|int $order_no): string|int
{
// 退款金额
$refund_total = 0;
// 获取订单退款数据
$params = array();
$params['inquiry_no'] = $order_no;
$order_refunds = OrderRefund::getList($params);
if (!empty($order_refunds)) {
foreach ($order_refunds as $order_refund) {
$refund_total = bcadd(
(string)$refund_total,
(string)$order_refund['refund_total'],
2
);
}
}
return $refund_total;
}
/**
* 获取订单可提现金额
* @param array|object $order
* @param string|int $refund_total 订单退款金额
* @return int|string
*/
public function getOrderWithdrawalAmount(array|object $order,string|int $refund_total): int|string
{
// 可提现金额
$expected_amount_total = 0;
// 计算可提现金额
if ($order['order_type'] == 1){
$expected_amount_total = bcmul(
bcsub(
$order['amount_total'],
$refund_total,
3
),
0.75,
2
);
}
if ($order['order_type'] == 4 || $order['order_type'] == 5){
// 获取订单详情数据
$params = array();
$params['order_service_no'] = $order['order_no'];
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
if (!empty($order_service_package_detail)){
$expected_amount_total = bcmul( // 可提现费用
bcsub( // 退款费用
bcmul( // 问诊费用
(string)$order_service_package_detail['service_count'],
(string)$order_service_package_detail['single_inquiry_price'],
3
),
$refund_total,
3
),
0.75,
2
);
}
}
return $expected_amount_total;
}
}