获取我的账户数据-获取医生服务包每月账单数据
This commit is contained in:
parent
cef772f53c
commit
1a164b7cea
@ -116,7 +116,7 @@ class Order extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取医生某一时间段收益明细分页数据
|
* 获取医生某一时间段收益明细分页数据
|
||||||
* @param array $params
|
* @param string|int $doctor_id
|
||||||
* @param array $date_params 时间区间
|
* @param array $date_params 时间区间
|
||||||
* @param string|int $is_platform_deep_cooperation
|
* @param string|int $is_platform_deep_cooperation
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
@ -124,27 +124,34 @@ class Order extends Model
|
|||||||
* @param int|null $per_page
|
* @param int|null $per_page
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getDoctorCreatedDateOrderInquiryPage(array $params, array $date_params,string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
public static function getDoctorCreatedDateOrderInquiryPage(string|int $doctor_id, array $date_params,string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||||
{
|
{
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $doctor_id;
|
||||||
|
|
||||||
$query = self::with(['OrderInquiry', 'OrderServicePackage'])
|
$query = self::with(['OrderInquiry', 'OrderServicePackage'])
|
||||||
->whereIn('order_type',[1,4,5])
|
->whereIn('order_type',[1,4,5])
|
||||||
->where($params);
|
->where($params);
|
||||||
|
|
||||||
// 问诊订单
|
// 问诊订单
|
||||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation,$doctor_id){
|
||||||
$query->whereExists(function ($subQuery) use ($date_params,$is_platform_deep_cooperation){
|
$query->whereExists(function ($subQuery) use ($date_params,$is_platform_deep_cooperation,$doctor_id){
|
||||||
$subQuery->from('order_inquiry');
|
$subQuery->from('order_inquiry');
|
||||||
if ($is_platform_deep_cooperation == 1){
|
if ($is_platform_deep_cooperation == 1){
|
||||||
$subQuery->whereNotIn('inquiry_type', [2,4]);
|
$subQuery->whereNotIn('inquiry_type', [2,4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subQuery->whereNotIn('inquiry_mode', [7,8,9])
|
$subQuery->where('doctor_id', $doctor_id)
|
||||||
|
->whereNotIn('inquiry_mode', [7,8,9])
|
||||||
|
->where('doctor_id', $doctor_id)
|
||||||
->whereIn('inquiry_status', [6,7])
|
->whereIn('inquiry_status', [6,7])
|
||||||
->whereBetween('reception_time', $date_params)
|
->whereBetween('reception_time', $date_params)
|
||||||
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||||
})
|
})
|
||||||
->orWhereExists(function ($subQuery) use ($date_params) {
|
->orWhereExists(function ($subQuery) use ($date_params,$doctor_id) {
|
||||||
$subQuery->from('order_service_package')
|
$subQuery->from('order_service_package');
|
||||||
|
|
||||||
|
$subQuery->where('doctor_id', $doctor_id)
|
||||||
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||||
->whereIn('order_service_status', [4,5,6,7])
|
->whereIn('order_service_status', [4,5,6,7])
|
||||||
->whereBetween('start_time', $date_params);
|
->whereBetween('start_time', $date_params);
|
||||||
|
|||||||
@ -607,4 +607,30 @@ class OrderInquiry extends Model
|
|||||||
->orderBy('created_at')
|
->orderBy('created_at')
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取医生每月账单数据
|
||||||
|
* @param array $params
|
||||||
|
* @param string $year
|
||||||
|
* @param string|int $is_platform_deep_cooperation
|
||||||
|
* @param array $fields
|
||||||
|
* @return \Hyperf\Collection\Collection
|
||||||
|
*/
|
||||||
|
public static function getMonthlyGroupBill(array $params, string $year,string|int $is_platform_deep_cooperation,array $fields = ["*"]): \Hyperf\Collection\Collection
|
||||||
|
{
|
||||||
|
$query = self::select([Db::raw('YEAR(reception_time) AS `year`') ,Db::raw('MONTH(reception_time) AS `month`')])
|
||||||
|
->where($params)
|
||||||
|
->whereNotIn('inquiry_mode', [7,8,9])
|
||||||
|
->whereIn('inquiry_status', [6])
|
||||||
|
->where(Db::raw('YEAR(reception_time)'), $year);
|
||||||
|
|
||||||
|
if ($is_platform_deep_cooperation == 1){
|
||||||
|
$query->whereNotIn('inquiry_type', [2,4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $query->groupBy([Db::raw('YEAR(reception_time)'),Db::raw('MONTH(reception_time)')])
|
||||||
|
->get($fields);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ namespace App\Model;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Hyperf\Database\Model\Collection;
|
use Hyperf\Database\Model\Collection;
|
||||||
use Hyperf\Database\Model\Relations\HasOne;
|
use Hyperf\Database\Model\Relations\HasOne;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,4 +216,21 @@ class OrderServicePackage extends Model
|
|||||||
->orderBy('start_time')
|
->orderBy('start_time')
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取医生每月账单数据
|
||||||
|
* @param array $params
|
||||||
|
* @param string $year
|
||||||
|
* @param array $fields
|
||||||
|
* @return \Hyperf\Collection\Collection
|
||||||
|
*/
|
||||||
|
public static function getMonthlyGroupBill(array $params, string $year,array $fields = ["*"]): \Hyperf\Collection\Collection
|
||||||
|
{
|
||||||
|
return self::select([Db::raw('YEAR(start_time) AS `year`') ,Db::raw('MONTH(start_time) AS `month`')])
|
||||||
|
->where($params)
|
||||||
|
->whereIn('order_service_status', [3,4,5])
|
||||||
|
->where(Db::raw('YEAR(start_time)'), $year)
|
||||||
|
->groupBy([Db::raw('YEAR(start_time)'),Db::raw('MONTH(start_time)')])
|
||||||
|
->get($fields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,22 +75,26 @@ class DoctorAccountService extends BaseService
|
|||||||
$balance_account = $doctor_account['balance_account'];
|
$balance_account = $doctor_account['balance_account'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取医生每月账单数据
|
// 获取医生问诊每月账单数据
|
||||||
$bill = [];
|
// $bill = [];
|
||||||
|
//
|
||||||
|
// $params = array();
|
||||||
|
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
// $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'] = bcmul((string)$doctor_account_day['total_amount'], 1, 2);
|
||||||
|
// $data['month'] = $doctor_account_day['month'];
|
||||||
|
// $bill[] = $data;
|
||||||
|
// }
|
||||||
|
// unset($doctor_account_days);
|
||||||
|
// }
|
||||||
|
|
||||||
$params = array();
|
// 获取医生服务包每月账单数据
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$year = date('Y',strtotime($year));
|
||||||
$params['year'] = $year;
|
$bill = $this->getDoctorMonthlyGroupBill($user_doctor,$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'] = bcmul((string)$doctor_account_day['total_amount'], 1, 2);
|
|
||||||
$data['month'] = $doctor_account_day['month'];
|
|
||||||
$bill[] = $data;
|
|
||||||
}
|
|
||||||
unset($doctor_account_days);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['doctor_today_inquiry_total'] = bcmul((string)$doctor_today_total, "0.75", 2); // 今日预计收入
|
$result['doctor_today_inquiry_total'] = bcmul((string)$doctor_today_total, "0.75", 2); // 今日预计收入
|
||||||
@ -121,9 +125,6 @@ class DoctorAccountService extends BaseService
|
|||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = array();
|
|
||||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
|
||||||
|
|
||||||
// 获取当月开始时间
|
// 获取当月开始时间
|
||||||
$start_date = date('Y-m-01 00:00:00', strtotime($date));
|
$start_date = date('Y-m-01 00:00:00', strtotime($date));
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ class DoctorAccountService extends BaseService
|
|||||||
|
|
||||||
$date_params = [$start_date, $end_date];
|
$date_params = [$start_date, $end_date];
|
||||||
|
|
||||||
$results = Order::getDoctorCreatedDateOrderInquiryPage($params, $date_params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
$results = Order::getDoctorCreatedDateOrderInquiryPage($user_doctor['doctor_id'], $date_params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||||
if (!empty($results['data'])) {
|
if (!empty($results['data'])) {
|
||||||
$OrderService = new OrderService();
|
$OrderService = new OrderService();
|
||||||
|
|
||||||
@ -865,4 +866,41 @@ class DoctorAccountService extends BaseService
|
|||||||
|
|
||||||
return $income_tax;
|
return $income_tax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取医生每月账单数据
|
||||||
|
* @param array|object $user_doctor
|
||||||
|
* @param string $year
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDoctorMonthlyGroupBill(array|object $user_doctor,string $year): array
|
||||||
|
{
|
||||||
|
// 获取医生服务包每月账单数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||||
|
$order_service_package = OrderServicePackage::getMonthlyGroupBill($params,$year);
|
||||||
|
if (!empty($order_service_package)){
|
||||||
|
$order_service_package = $order_service_package->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取医生问诊每月账单数据
|
||||||
|
$params = array();
|
||||||
|
$params['doctor_id'] = $user_doctor['doctor_id'];;
|
||||||
|
$order_inquiry = OrderInquiry::getMonthlyGroupBill($params,$year,$user_doctor['is_platform_deep_cooperation']);
|
||||||
|
if (!empty($order_inquiry)){
|
||||||
|
$order_inquiry = $order_inquiry->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理月账单数据
|
||||||
|
// 合并两个数组
|
||||||
|
$merged = array_merge($order_service_package, $order_inquiry);
|
||||||
|
|
||||||
|
// 去除重复的元素
|
||||||
|
$bill = array_unique($merged, SORT_REGULAR);
|
||||||
|
|
||||||
|
// 重新索引数组
|
||||||
|
$bill = array_values($bill);
|
||||||
|
|
||||||
|
return $bill;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user