新增提现模型,修正我的账户

This commit is contained in:
wucongxing 2023-02-23 17:28:40 +08:00
parent 956c9c6474
commit 695cb4f1a2
5 changed files with 111 additions and 115 deletions

View File

@ -15,7 +15,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
* @property int $month 12
* @property int $day 01
* @property string $date 日期2022-01-01
* @property string $total_amount_day 订单总金额-
* @property string $total_amount 订单总金额-
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
@ -31,7 +31,7 @@ class DoctorAccountDay extends Model
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['account_detail_id', 'doctor_id', 'year', 'month', 'day', 'date', 'total_amount_day', 'created_at', 'updated_at'];
protected array $fillable = ['account_detail_id', 'doctor_id', 'year', 'month', 'day', 'date', 'total_amount', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
@ -69,6 +69,6 @@ class DoctorAccountDay extends Model
*/
public static function getDoctorSumTotalAmount(array $params): mixed
{
return self::where($params)->sum("total_amount_day");
return self::where($params)->sum("total_amount");
}
}

View File

@ -1,64 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $account_month_id 主键id
* @property int $doctor_id 医生id
* @property int $year 2023
* @property int $month 12
* @property string $total_amount 总金额
* @property string $withdrawal_amount 已提现金额
* @property string $income_tax 已提现所得税
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class DoctorAccountMonth extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_account_month';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['account_month_id', 'doctor_id', 'year', 'month', 'total_amount', 'withdrawal_amount', 'income_tax', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['account_month_id' => 'integer', 'doctor_id' => 'integer', 'year' => 'integer', 'month' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "account_month_id";
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getOne(array $params, array $fields = ['*']): object|null
{
return self::where($params)->first($fields);
}
/**
* 获取信息-多条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getList(array $params, array $fields = ['*']): object|null
{
return self::where($params)->get($fields);
}
}

View File

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $withdrawal_id 主键id
* @property int $doctor_id 医生id
* @property int $bank_card_id 医生银行卡id
* @property string $account_name 银行卡姓名
* @property string $bank_card_code 银行卡号
* @property string $bank_card_code_four 银行卡号(后四位)
* @property string $applied_withdrawal_amount 提现金额
* @property string $actual_withdrawal_amount 实际提现金额
* @property string $income_tax 提现所得税金额
* @property int $examine_status 审核状态1:审核中 2:审核通过 3:审核未通过)
* @property string $examine_fail_reason 审核失败原因
* @property string $examine_time 审核日期
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class DoctorWithdrawal extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_withdrawal';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['withdrawal_id', 'doctor_id', 'bank_card_id', 'account_name', 'bank_card_code', 'bank_card_code_four', 'applied_withdrawal_amount', 'actual_withdrawal_amount', 'income_tax', 'examine_status', 'examine_fail_reason', 'examine_time', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['withdrawal_id' => 'integer', 'doctor_id' => 'integer', 'bank_card_id' => 'integer', 'examine_status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "withdrawal_id";
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getOne(array $params, array $fields = ['*']): object|null
{
return self::where($params)->first($fields);
}
/**
* 获取信息-多条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getList(array $params, array $fields = ['*']): object|null
{
return self::where($params)->get($fields);
}
}

View File

@ -107,10 +107,7 @@ class OrderInquiry extends Model
/**
* 获取医生接诊订单列表
* 已结束-已取消
* inquiry_status问诊订单状态1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
* inquiry_refund_status问诊订单退款状态0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
* cancel_reason取消订单原因0:默认 1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
* 已结束
* @param array $params
* @param array $reception_time 接诊时间区间 ['2023-01-02','2023-01-03']
* @param array $fields
@ -121,12 +118,8 @@ class OrderInquiry extends Model
public static function getDoctorAccountInfoPage(array $params, array $reception_time,array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
{
$raw = self::where($params)
->whereIn('inquiry_status',[6,7])
->whereIn('inquiry_refund_status',[0,3])
->whereIn('cancel_reason',[0,4])
->whereBetween('finish_time',$reception_time)
->orderBy('finish_time')
->orderBy('cancel_time')
->paginate($per_page, $fields, "page", $page);
$data = array();

View File

@ -5,8 +5,8 @@ namespace App\Services;
use App\Constants\HttpEnumCode;
use App\Model\DoctorAccount;
use App\Model\DoctorAccountDay;
use App\Model\DoctorAccountMonth;
use App\Model\DoctorBankCard;
use App\Model\DoctorWithdrawal;
use App\Model\OrderInquiry;
use App\Model\UserDoctor;
@ -31,31 +31,24 @@ class DoctorAccountService extends BaseService
$balance_account = $balance_account * 0.75;
}
// 月余额-已结束订单
$amount_total_month = 0;
// 获取医生余额
$amount_total_month = $this->getDoctorMonthAmountTotal($user_info['client_user_id'],$date);;
// 月已提现金额
$withdrawal_amount_month = 0;
// 获取医生账户某月数据
// 获取医生月度已提现金额-审核通过时间为准
$params = array();
$params['doctor_id'] = $user_info['client_user_id'];
$params['year'] = date('Y',strtotime($date));
$params['month'] = date('m',strtotime($date));
$doctor_account_month = DoctorAccountMonth::getOne($params);
if (!empty($doctor_account_month)){
if (!empty($doctor_account_month['total_amount'])){
$amount_total_month = $doctor_account_month['total_amount'] * 0.75;
}
$withdrawal_amount_month = $doctor_account_month['withdrawal_amount'] ?: 0;
$doctor_withdrawal = DoctorWithdrawal::getOne($params);
if (empty($doctor_withdrawal)){
$withdrawal_amount_month = 0;
}else{
$withdrawal_amount_month = $doctor_withdrawal['actual_withdrawal_amount'];
}
// 获取医生每日账单数据
$bill = [];
$fields = [
'total_amount_day',
'total_amount',
'month',
'day',
];
@ -68,7 +61,7 @@ class DoctorAccountService extends BaseService
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['total_amount'] = $doctor_account_day['total_amount'] * 0.75;
$data['month'] = $doctor_account_day['month'];
$data['day'] = $doctor_account_day['day'];
$bill[] = $data;
@ -123,12 +116,13 @@ class DoctorAccountService extends BaseService
$params = array();
$params['doctor_id'] = $user_info['client_user_id'];
// $params['cancel_reason'] = ;
$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::getDoctorAccountInfoPage($params,$reception_time,$fields);
if (!empty($order_inquiry['data'])){
foreach ($order_inquiry['data'] as &$item){
$item['estimate_income'] = $item['amount_total'] * 0.75;
$item['amount_total'] = $item['amount_total'] * 0.75;
}
}
@ -212,28 +206,32 @@ class DoctorAccountService extends BaseService
return $balance_account;
}
// /**
// * 获取医生账户某日预计收益
// * @param string $doctor_id 医生id
// * @param string $day 日期 Ymd形式
// * @return float|int|mixed|string
// */
// public function getDoctorDayAmountTotal(string $doctor_id, string $day): mixed
// {
// $params = array();
// $params['doctor_id'] = $doctor_id;
// $params['year'] = date('Y',strtotime($day));
// $params['month'] = date('m',strtotime($day));
// $params['day'] = date('d',strtotime($day));
// $total_amount_day = DoctorAccountDay::getDoctorSumTotalAmount($params);
// if (!empty($total_amount_day)){
// $total_amount_day = $total_amount_day * 0.75;
// }
//
// return $total_amount_day ?: 0;
// }
/**
* 获取某月医生账户已结束订单金额
* @param string $doctor_id 医生id
* @param string $date 日期 Ymd形式
* @return float|int|mixed|string
*/
public function getDoctorMonthAmountTotal(string $doctor_id, string $date): mixed
{
$params = array();
$params['doctor_id'] = $doctor_id;
$params['year'] = date('Y',strtotime($date));
$params['month'] = date('m',strtotime($date));
$total_amount = DoctorAccountDay::getDoctorSumTotalAmount($params);
if (empty($total_amount)){
$total_amount = 0;
}
return $total_amount;
}
// 获取医生某月提现数据
// 审核通过时间为准
public function getDoctorMonthWithdrawalData(){
}
// 计算个人所得税
protected function computeIndividualIncomeTax(){