获取我的账户数据
This commit is contained in:
parent
847a77da57
commit
649ef58f2d
@ -32,7 +32,7 @@ class DoctorAccountController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的账户日账单明细数据
|
||||
* 获取我的账户月账单明细数据
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
|
||||
@ -6,6 +6,9 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@ -103,4 +106,18 @@ class DoctorAccountDay extends Model
|
||||
{
|
||||
return self::where($params)->decrement($field,$numeral);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生账户月份金额
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return \Hyperf\Collection\Collection
|
||||
*/
|
||||
public static function getDoctorMonth(array $params,array $fields = ['*']): \Hyperf\Collection\Collection
|
||||
{
|
||||
return self::select(['month',Db::raw('SUM(total_amount) AS `total_amount`')])
|
||||
->where($params)
|
||||
->groupBy(['month'])
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,17 +178,19 @@ class OrderInquiry extends Model
|
||||
* 获取医生某一时间段接诊订单分页数据
|
||||
* 已结束
|
||||
* @param array $params
|
||||
* @param array $reception_time 接诊时间区间 ['2023-01-02','2023-01-03']
|
||||
* @param array $reception_time 接诊时间区间 ['2023-01','2023-01']
|
||||
* @param array $inquiry_status_params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getDoctorCreatedDateOrderInquiryPage(array $params, array $reception_time, array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||
public static function getDoctorCreatedDateOrderInquiryPage(array $params, array $reception_time, array $inquiry_status_params,array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||
{
|
||||
$raw = self::where($params)
|
||||
->whereBetween('finish_time', $reception_time)
|
||||
->orderBy('finish_time')
|
||||
->whereIn('inquiry_status', $inquiry_status_params)
|
||||
->whereBetween('reception_time', $reception_time)
|
||||
->orderBy('reception_time')
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
|
||||
@ -28,7 +28,9 @@ class DoctorAccountService extends BaseService
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$date = $this->request->input('date');
|
||||
$year = $this->request->input('date');
|
||||
|
||||
$date = date('Y-m-d',time());
|
||||
|
||||
// 今日接诊收入
|
||||
$inquiryService = new InquiryService();
|
||||
@ -40,43 +42,35 @@ class DoctorAccountService extends BaseService
|
||||
// 获取医生账户余额
|
||||
$balance_account = $this->getDoctorBalanceAccount($user_info['client_user_id']);
|
||||
|
||||
// 获取医生月度余额
|
||||
$amount_total_month = $this->getDoctorMonthAmountTotal($user_info['client_user_id'], $date);
|
||||
// // 获取医生月度余额
|
||||
// $amount_total_month = $this->getDoctorMonthAmountTotal($user_info['client_user_id'], $date);
|
||||
//
|
||||
// // 获取医生月度已提现金额-审核通过时间为准
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
//
|
||||
// $start_time = date('Y-m-01',strtotime($date));
|
||||
// $end_time = date('Y-m-t 24:00:00',strtotime($date));
|
||||
// $created_at = [$start_time,$end_time];
|
||||
// $doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params,$created_at,['*']);
|
||||
// if (empty($doctor_withdrawal)) {
|
||||
// $withdrawal_amount_month = 0;
|
||||
// } else {
|
||||
// $withdrawal_amount_month = $doctor_withdrawal['actual_withdrawal_amount'];
|
||||
// }
|
||||
|
||||
// 获取医生月度已提现金额-审核通过时间为准
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$start_time = date('Y-m-01',strtotime($date));
|
||||
$end_time = date('Y-m-t 24:00:00',strtotime($date));
|
||||
$created_at = [$start_time,$end_time];
|
||||
$doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params,$created_at,['*']);
|
||||
if (empty($doctor_withdrawal)) {
|
||||
$withdrawal_amount_month = 0;
|
||||
} else {
|
||||
$withdrawal_amount_month = $doctor_withdrawal['actual_withdrawal_amount'];
|
||||
}
|
||||
|
||||
// 获取医生每日账单数据
|
||||
// 获取医生每月账单数据
|
||||
$bill = [];
|
||||
|
||||
$fields = [
|
||||
'total_amount',
|
||||
'month',
|
||||
'day',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['year'] = date('Y', strtotime($date));
|
||||
$params['month'] = date('m', strtotime($date));
|
||||
$doctor_account_days = DoctorAccountDay::getList($params, $fields);
|
||||
$params['year'] = $year;
|
||||
$doctor_account_days = DoctorAccountDay::getDoctorMonth($params);
|
||||
if (!empty($doctor_account_days)) {
|
||||
foreach ($doctor_account_days as $doctor_account_day) {
|
||||
$data = array();
|
||||
$data['total_amount'] = floor($doctor_account_day['total_amount'] * 100) / 100;
|
||||
$data['total_amount'] = bcmul($doctor_account_day['total_amount'],1,2);
|
||||
$data['month'] = $doctor_account_day['month'];
|
||||
$data['day'] = $doctor_account_day['day'];
|
||||
$bill[] = $data;
|
||||
}
|
||||
unset($doctor_account_days);
|
||||
@ -92,7 +86,7 @@ class DoctorAccountService extends BaseService
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的账户日账单明细数据
|
||||
* 获取我的账户月账单明细数据
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorAccountInfo(): array
|
||||
@ -103,11 +97,12 @@ class DoctorAccountService extends BaseService
|
||||
$page = $this->request->input('page', 1);
|
||||
$per_page = $this->request->input('per_page', 10);
|
||||
|
||||
// 获取当天开始时间
|
||||
$start_date = date('Y-m-d 00:00:00', strtotime($date));
|
||||
// 获取当月开始时间
|
||||
$start_date = date('Y-m-01 00:00:00', strtotime($date));
|
||||
|
||||
// 获取当天结束时间
|
||||
$end_date = date('Y-m-d 23:59:59', strtotime($date));
|
||||
// 获取当月结束时间
|
||||
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
||||
$end_date = date("Y-m-d 23:59:59", strtotime("+1 month", strtotime($start_date)) - 1);
|
||||
|
||||
$reception_time = [$start_date, $end_date];
|
||||
|
||||
@ -126,18 +121,32 @@ class DoctorAccountService extends BaseService
|
||||
'patient_name',
|
||||
'patient_sex',
|
||||
'patient_age',
|
||||
'cancel_reason',
|
||||
'cancel_remarks',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_status'] = 6; // inquiry_status:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$params['inquiry_refund_status'] = 0; // inquiry_refund_status:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
|
||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $fields,$page,$per_page);
|
||||
$inquiry_status_params = [4,5,6,7]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $inquiry_status_params,$fields,$page,$per_page);
|
||||
if (!empty($order_inquiry['data'])) {
|
||||
foreach ($order_inquiry['data'] as &$item) {
|
||||
$item['estimate_income'] = floor($item['amount_total'] * 0.75 * 100) / 100;
|
||||
$item['estimate_income'] = bcmul($item['amount_total'],0.75,2);
|
||||
|
||||
// 入账状态
|
||||
if ($item['inquiry_status'] == 4 || $item['inquiry_status'] == 5){
|
||||
$item['entry_status'] = 1;// 入账中
|
||||
}elseif ($item['inquiry_status'] == 6){
|
||||
$item['entry_status'] = 2;// 入账成功
|
||||
}elseif ($item['inquiry_status'] == 7){
|
||||
$item['entry_status'] = 3;// 入账失败
|
||||
if (!empty($item['cancel_reason'])){
|
||||
$item['cancel_reason'] = inquiryCancelReasonToPushString($item['cancel_reason']);
|
||||
}
|
||||
}else{
|
||||
$item['entry_status'] = 0;// 未知
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ Router::addGroup('/doctor', function () {
|
||||
// 获取我的账户数据
|
||||
Router::get('', [DoctorAccountController::class, 'getDoctorAccount']);
|
||||
|
||||
// 获取我的账户日账单明细数据
|
||||
// 获取我的账户月账单明细数据
|
||||
Router::get('/info', [DoctorAccountController::class, 'getDoctorAccountInfo']);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user