修正医生体现数据2
This commit is contained in:
@@ -135,6 +135,8 @@ class DoctorAccountService extends BaseService
|
||||
|
||||
$results = Order::getDoctorCreatedDateOrderInquiryPage($params, $date_params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||
if (!empty($results['data'])) {
|
||||
$OrderService = new OrderService();
|
||||
|
||||
foreach ($results['data'] as &$result) {
|
||||
// 填入字段
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
@@ -161,80 +163,11 @@ class DoctorAccountService extends BaseService
|
||||
$result['finish_time'] = $result['OrderServicePackage']['finish_time'];
|
||||
}
|
||||
|
||||
// 默认退款金额为0;
|
||||
$result['refund_total'] = 0;
|
||||
// 计算退款金额
|
||||
if ($result['refund_status'] == 3){
|
||||
// 问诊订单
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
// 获取退款数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $result['OrderInquiry']['inquiry_no'];
|
||||
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||
if (!empty($order_inquiry_refunds)) {
|
||||
$refund_total = 0;
|
||||
foreach ($order_inquiry_refunds as $order_inquiry_refund) {
|
||||
$refund_total = $refund_total + $order_inquiry_refund['refund_total'];
|
||||
}
|
||||
// 获取订单退款金额
|
||||
$result['refund_total'] = $OrderService->getOrderRefundAmount($result['order_no']);
|
||||
|
||||
// 订单退款金额
|
||||
$result['refund_total'] = $refund_total;
|
||||
}
|
||||
}
|
||||
|
||||
// 服务包订单
|
||||
if (!empty($result['OrderServicePackage'])) {
|
||||
// 获取退款数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||
$order_service_package_refunds = OrderServicePackageRefund::getList($params);
|
||||
if (!empty($order_service_package_refunds)) {
|
||||
$refund_total = 0;
|
||||
foreach ($order_service_package_refunds as $order_service_package_refund) {
|
||||
$refund_total = $refund_total + $order_service_package_refund['refund_total'];
|
||||
}
|
||||
|
||||
// 订单退款金额
|
||||
$result['refund_total'] = $refund_total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算预计收入
|
||||
if ($result['order_type'] == 1){
|
||||
$result['estimate_income'] = bcmul(
|
||||
bcsub(
|
||||
$result['OrderInquiry']['amount_total'],
|
||||
$result['refund_total'],
|
||||
3
|
||||
),
|
||||
0.75,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
if ($result['order_type'] == 4 || $result['order_type'] == 5){
|
||||
// 获取订单详情数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (!empty($order_service_package_detail)){
|
||||
|
||||
$result['estimate_income'] = bcmul( // 可提现费用
|
||||
bcsub( // 退款费用
|
||||
bcmul( // 问诊费用
|
||||
(string)$order_service_package_detail['service_count'],
|
||||
(string)$order_service_package_detail['single_inquiry_price'],
|
||||
3
|
||||
),
|
||||
$result['refund_total'],
|
||||
3
|
||||
),
|
||||
0.75,
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
// 获取订单可提现金额
|
||||
$result['expected_amount_total'] = $OrderService->getOrderWithdrawalAmount($result,$result['refund_total']);
|
||||
|
||||
// 处理入账状态
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
@@ -349,6 +282,41 @@ class DoctorAccountService extends BaseService
|
||||
$amount_total = $doctor_account['balance_account'];
|
||||
}
|
||||
|
||||
// 获取可提现订单列表
|
||||
$orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']);
|
||||
if (empty($orders)){
|
||||
// 无订单,账户余额强制赋0;
|
||||
$amount_total = 0;
|
||||
}
|
||||
|
||||
$OrderService = new OrderService();
|
||||
|
||||
// 可提现金额
|
||||
$expected_amount_total = 0;
|
||||
|
||||
// 订单号数据
|
||||
$order_nos = [];
|
||||
|
||||
foreach ($orders as $order){
|
||||
// 获取订单退款金额
|
||||
$refund_total = $OrderService->getOrderRefundAmount($order['order_no']);
|
||||
|
||||
// 获取订单可提现金额
|
||||
$expected_amount_total = bcadd(
|
||||
$expected_amount_total,
|
||||
$OrderService->getOrderWithdrawalAmount($order,$refund_total),
|
||||
2
|
||||
);
|
||||
|
||||
$order_nos[] = $order['order_no'];
|
||||
}
|
||||
|
||||
// 对比订单金额和账户金额;金额相差1元及以上返回错误
|
||||
$diff_amount_total = abs($amount_total - $expected_amount_total);
|
||||
if ($diff_amount_total >= 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "提现金额错误");
|
||||
}
|
||||
|
||||
// 计算医生个人所得税
|
||||
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
||||
|
||||
@@ -361,6 +329,7 @@ class DoctorAccountService extends BaseService
|
||||
$result['amount_total'] = $amount_total; // 账户余额
|
||||
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
||||
$result['income_tax'] = $income_tax; // 个人所得税
|
||||
$result['order_nos'] = $order_nos; // 订单号
|
||||
|
||||
return success($result);
|
||||
}
|
||||
@@ -445,9 +414,11 @@ class DoctorAccountService extends BaseService
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['is_withdrawal'] = 0;
|
||||
|
||||
$results = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||
$results = Order:: getDoctorWithdrawalOrderPage($params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||
|
||||
if (!empty($results['data'])) {
|
||||
$OrderService = new OrderService();
|
||||
|
||||
foreach ($results['data'] as &$result) {
|
||||
// 填入字段
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
@@ -474,79 +445,11 @@ class DoctorAccountService extends BaseService
|
||||
$result['finish_time'] = $result['OrderServicePackage']['finish_time'];
|
||||
}
|
||||
|
||||
// 默认退款金额为0;
|
||||
$result['refund_total'] = 0;
|
||||
// 计算退款
|
||||
if ($result['refund_status'] == 3){
|
||||
// 问诊订单
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
// 获取退款数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $result['OrderInquiry']['inquiry_no'];
|
||||
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||
if (!empty($order_inquiry_refunds)) {
|
||||
$refund_total = 0;
|
||||
foreach ($order_inquiry_refunds as $order_inquiry_refund) {
|
||||
$refund_total = $refund_total + $order_inquiry_refund['refund_total'];
|
||||
}
|
||||
// 获取订单退款金额
|
||||
$result['refund_total'] = $OrderService->getOrderRefundAmount($result['order_no']);
|
||||
|
||||
// 订单退款金额
|
||||
$result['refund_total'] = $refund_total;
|
||||
}
|
||||
}
|
||||
|
||||
// 服务包订单
|
||||
if (!empty($result['OrderServicePackage'])) {
|
||||
// 获取退款数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||
$order_service_package_refunds = OrderServicePackageRefund::getList($params);
|
||||
if (!empty($order_service_package_refunds)) {
|
||||
$refund_total = 0;
|
||||
foreach ($order_service_package_refunds as $order_service_package_refund) {
|
||||
$refund_total = $refund_total + $order_service_package_refund['refund_total'];
|
||||
}
|
||||
|
||||
// 订单退款金额
|
||||
$result['refund_total'] = $refund_total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算可提现金额
|
||||
if ($result['order_type'] == 1){
|
||||
$result['expected_amount_total'] = bcmul(
|
||||
bcsub(
|
||||
$result['OrderInquiry']['amount_total'],
|
||||
$result['refund_total'],
|
||||
3
|
||||
),
|
||||
0.75,
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
if ($result['order_type'] == 4 || $result['order_type'] == 5){
|
||||
// 获取订单详情数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (!empty($order_service_package_detail)){
|
||||
$result['expected_amount_total'] = bcmul( // 可提现费用
|
||||
bcsub( // 退款费用
|
||||
bcmul( // 问诊费用
|
||||
(string)$order_service_package_detail['service_count'],
|
||||
(string)$order_service_package_detail['single_inquiry_price'],
|
||||
3
|
||||
),
|
||||
$result['refund_total'],
|
||||
3
|
||||
),
|
||||
0.75,
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
// 获取订单可提现金额
|
||||
$result['expected_amount_total'] = $OrderService->getOrderWithdrawalAmount($result,$result['refund_total']);
|
||||
|
||||
unset($result['OrderInquiry']);
|
||||
unset($result['OrderServicePackage']);
|
||||
|
||||
Reference in New Issue
Block a user