新增我的账户日账单明细数据
This commit is contained in:
parent
c1320cb71e
commit
ebf34e28e7
@ -15,7 +15,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
class DoctorAccountController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* 获取医生我的账户数据
|
||||
* 获取我的账户数据
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
@ -29,4 +29,20 @@ class DoctorAccountController extends AbstractController
|
||||
$data = $DoctorAccountService->getDoctorAccount();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的账户日账单明细数据
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getDoctorAccountInfo(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorAccountRequest::class);
|
||||
$request->scene('getDoctorAccountInfo')->validateResolved();
|
||||
|
||||
$DoctorAccountService = new DoctorAccountService();
|
||||
$data = $DoctorAccountService->getDoctorAccountInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -104,17 +104,29 @@ class OrderInquiry extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生某天预计收益
|
||||
* 获取医生接诊列表
|
||||
* 已完成-已结束
|
||||
* @param array $params
|
||||
* @param array $reception_time 接诊时间区间
|
||||
* @param array $reception_time 接诊时间区间 ['2023-01-02','2023-01-03']
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getDoctorOneDayAmountTotal(array $params, array $reception_time): mixed
|
||||
public static function getDoctorAccountInfoPage(array $params, array $reception_time,array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||
{
|
||||
return self::where($params)
|
||||
$raw = self::where($params)
|
||||
->whereIn('inquiry_status',[5,6])
|
||||
->whereBetween('reception_time',$reception_time)
|
||||
->sum("amount_total");
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $raw->currentPage();// 当前页码
|
||||
$data['total'] = $raw->total();//数据总数
|
||||
$data['data'] = $raw->items();//数据
|
||||
$data['per_page'] = $raw->perPage();//每页个数
|
||||
$data['last_page'] = $raw->lastPage();//最后一页
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,10 @@ use Hyperf\Validation\Request\FormRequest;
|
||||
class DoctorAccountRequest extends FormRequest
|
||||
{
|
||||
protected array $scenes = [
|
||||
'getInquiryConfig' => [ // 获取医生问诊配置
|
||||
'getInquiryConfig' => [ // 获取我的账户数据
|
||||
'date',
|
||||
],
|
||||
'getDoctorAccountInfo' => [ // 获取我的账户日账单明细数据
|
||||
'date',
|
||||
],
|
||||
];
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Services;
|
||||
use App\Model\DoctorAccount;
|
||||
use App\Model\DoctorAccountDay;
|
||||
use App\Model\DoctorAccountMonth;
|
||||
use App\Model\OrderInquiry;
|
||||
|
||||
/**
|
||||
* 医生账户
|
||||
@ -12,7 +13,7 @@ use App\Model\DoctorAccountMonth;
|
||||
class DoctorAccountService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 获取医生账户数据
|
||||
* 获取我的账户数据
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorAccount(): array
|
||||
@ -41,9 +42,13 @@ class DoctorAccountService extends BaseService
|
||||
$withdrawal_amount_month = $doctor_account_month['withdrawal_amount'] ?: 0;
|
||||
}
|
||||
|
||||
// 获取医生每日数据
|
||||
// 获取医生每日账单数据
|
||||
$bill = [];
|
||||
|
||||
$fields = [
|
||||
'total_amount_day'
|
||||
'total_amount_day',
|
||||
'month',
|
||||
'day',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
@ -51,17 +56,19 @@ class DoctorAccountService extends BaseService
|
||||
$params['year'] = date('Y',strtotime($date));
|
||||
$params['month'] = date('m',strtotime($date));
|
||||
$doctor_account_days = DoctorAccountDay::getList($params,$fields);
|
||||
if (empty($doctor_account_days)){
|
||||
$bill = [];
|
||||
}else{
|
||||
foreach ($doctor_account_days as &$doctor_account_day){
|
||||
$doctor_account_day['total_amount_day'] = $doctor_account_day['total_amount_day'] * 0.75;
|
||||
if (!empty($doctor_account_days)){
|
||||
foreach ($doctor_account_days as $doctor_account_day){
|
||||
$data = array();
|
||||
$data['total_amount_day'] = $doctor_account_day['total_amount_day'] * 0.75;
|
||||
$data['month'] = $doctor_account_day['month'];
|
||||
$data['day'] = $doctor_account_day['day'];
|
||||
$bill[] = $data;
|
||||
}
|
||||
$bill = $doctor_account_days;
|
||||
unset($doctor_account_days);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['balance_account'] = $balance_account; // 获取医生账户余额-未提现金额
|
||||
$result['balance_account'] = $balance_account; // 账户余额
|
||||
$result['amount_total_month'] = $amount_total_month * 0.75; // 月预计收益
|
||||
$result['withdrawal_amount_month'] = $withdrawal_amount_month; // 月已提现金额
|
||||
$result['bill'] = $bill; // 账单
|
||||
@ -69,6 +76,57 @@ class DoctorAccountService extends BaseService
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的账户日账单明细数据
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorAccountInfo(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$date = $this->request->input('date');
|
||||
$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));
|
||||
|
||||
// 获取当天结束时间
|
||||
$end_date = date('Y-m-d 23:59:59',strtotime($date));
|
||||
|
||||
$reception_time = [$start_date,$end_date];
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
$fields = [
|
||||
'order_inquiry_id',
|
||||
'inquiry_type',
|
||||
'inquiry_mode',
|
||||
'inquiry_status',
|
||||
'inquiry_refund_status',
|
||||
'inquiry_no',
|
||||
'amount_total',
|
||||
'payment_amount_total',
|
||||
'reception_time',
|
||||
'patient_name',
|
||||
'patient_sex',
|
||||
'patient_age',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_refund_status'] = 0; // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$params['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
|
||||
$order_inquiry = OrderInquiry::getDoctorAccountInfoPage($params,$reception_time,$fields);
|
||||
if (!empty($order_inquiry['data'])){
|
||||
foreach ($order_inquiry['data'] as &$item){
|
||||
$item['estimate_income'] = $item['amount_total'] * 0.75;
|
||||
}
|
||||
}
|
||||
|
||||
return success($order_inquiry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生账户余额
|
||||
* @param string $doctor_id
|
||||
|
||||
@ -307,7 +307,7 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
return $order_evaluation;
|
||||
return success($order_evaluation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -505,37 +505,4 @@ class UserDoctorService extends BaseService
|
||||
|
||||
return success($user_doctor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生某天预计收益
|
||||
* 当日完成的订单金额*0.75
|
||||
* @param string $doctor_id
|
||||
* @param string $date
|
||||
* @return float
|
||||
*/
|
||||
public function getDoctorOneDayAmountTotal(string $doctor_id,string $date): float
|
||||
{
|
||||
// 获取当天开始时间
|
||||
$start_date = date('Y-m-d 00:00:00',strtotime($date));
|
||||
|
||||
// 获取当天结束时间
|
||||
$end_date = date('Y-m-d 23:59:59',strtotime($date));
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_refund_status'] = 0; // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$params['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$params['settlement_status'] = 0; // 订单与医生结算状态(0:未结算 1:已结算)
|
||||
|
||||
$reception_time = [$start_date,$end_date];
|
||||
|
||||
$amount_total_sum = OrderInquiry::getDoctorOneDayAmountTotal($params,$reception_time);
|
||||
|
||||
if (!empty($amount_total_sum)){
|
||||
$amount_total_sum = $amount_total_sum * 0.75;
|
||||
}
|
||||
|
||||
return $amount_total_sum ?: 0;
|
||||
}
|
||||
}
|
||||
@ -97,11 +97,16 @@ Router::addGroup('/doctor', function () {
|
||||
// 获取医生个人中心数据
|
||||
Router::get('', [UserDoctorController::class, 'getDoctorCenter']);
|
||||
|
||||
// 医生我的账户
|
||||
Router::addGroup('/account', function () {
|
||||
// 获取医生我的账户数据
|
||||
Router::get('', [DoctorAccountController::class, 'getDoctorAccount']);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 我的账户
|
||||
Router::addGroup('/account', function () {
|
||||
// 获取我的账户数据
|
||||
Router::get('', [DoctorAccountController::class, 'getDoctorAccount']);
|
||||
|
||||
// 获取我的账户日账单明细数据
|
||||
Router::get('/info', [DoctorAccountController::class, 'getDoctorAccountInfo']);
|
||||
});
|
||||
|
||||
// 处方
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user