修正医生体现数据
This commit is contained in:
parent
c499184ebe
commit
2d0305ea2f
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Command;
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\Model\DoctorWithdrawalOrder;
|
||||||
use App\Model\Order;
|
use App\Model\Order;
|
||||||
use App\Model\OrderCoupon;
|
use App\Model\OrderCoupon;
|
||||||
use App\Model\OrderDetection;
|
use App\Model\OrderDetection;
|
||||||
@ -64,6 +65,9 @@ class MoveOrderCommand extends HyperfCommand
|
|||||||
|
|
||||||
// 处理检测订单退款
|
// 处理检测订单退款
|
||||||
// $this->handleOrderDetectionRefund();
|
// $this->handleOrderDetectionRefund();
|
||||||
|
|
||||||
|
// 修正医生提现关联订单表数据
|
||||||
|
// $this->handleDoctorWithdrawalOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,6 +124,9 @@ class MoveOrderCommand extends HyperfCommand
|
|||||||
if (!empty($order_inquiry['cancel_reason'])){
|
if (!empty($order_inquiry['cancel_reason'])){
|
||||||
$data['cancel_remarks'] = inquiryCancelReasonToString($order_inquiry['cancel_reason']);
|
$data['cancel_remarks'] = inquiryCancelReasonToString($order_inquiry['cancel_reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['is_withdrawal'] = $order_inquiry['is_withdrawal'];
|
||||||
|
$data['withdrawal_time'] = $order_inquiry['withdrawal_time'];
|
||||||
$order = Order::addOrder($data);
|
$order = Order::addOrder($data);
|
||||||
if (empty($order)) {
|
if (empty($order)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
@ -314,6 +321,7 @@ class MoveOrderCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
$data['cancel_time'] = $order_product['cancel_time'];
|
$data['cancel_time'] = $order_product['cancel_time'];
|
||||||
$data['cancel_remarks'] = $order_product['cancel_remarks'];
|
$data['cancel_remarks'] = $order_product['cancel_remarks'];
|
||||||
|
$data['is_withdrawal'] = 3;
|
||||||
$order = Order::addOrder($data);
|
$order = Order::addOrder($data);
|
||||||
if (empty($order)) {
|
if (empty($order)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
@ -502,6 +510,8 @@ class MoveOrderCommand extends HyperfCommand
|
|||||||
$data['cancel_remarks'] = detectionCancelReasonToString($order_detection['cancel_reason']);
|
$data['cancel_remarks'] = detectionCancelReasonToString($order_detection['cancel_reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data['is_withdrawal'] = 3;
|
||||||
|
|
||||||
$order = Order::addOrder($data);
|
$order = Order::addOrder($data);
|
||||||
if (empty($order)) {
|
if (empty($order)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
@ -583,4 +593,42 @@ class MoveOrderCommand extends HyperfCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修正医生提现关联订单表数据
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handleDoctorWithdrawalOrder(): void
|
||||||
|
{
|
||||||
|
$params = array();
|
||||||
|
$doctor_withdrawal_orders = DoctorWithdrawalOrder::getList($params);
|
||||||
|
if (empty($doctor_withdrawal_orders)){
|
||||||
|
$this->line("无检测退款订单需要执行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($doctor_withdrawal_orders as $doctor_withdrawal_order){
|
||||||
|
$params = array();
|
||||||
|
$params['order_inquiry_id'] = $doctor_withdrawal_order['order_inquiry_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)){
|
||||||
|
$this->line("无对应订单数据");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::beginTransaction();
|
||||||
|
try {
|
||||||
|
$params = array();
|
||||||
|
$params['withdrawal_order_id'] = $doctor_withdrawal_order['withdrawal_order_id'];
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['order_id'] = $order_inquiry['order_id'];
|
||||||
|
DoctorWithdrawalOrder::edit($params,$data);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
}catch (\Throwable $e){
|
||||||
|
Db::rollBack();
|
||||||
|
$this->line($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@ class TestController extends AbstractController
|
|||||||
// $this->test_12();
|
// $this->test_12();
|
||||||
// $this->test_13();
|
// $this->test_13();
|
||||||
// $this->test_14();
|
// $this->test_14();
|
||||||
$this->test_17();
|
$this->test_14();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取未接诊的医生
|
// 获取未接诊的医生
|
||||||
@ -360,6 +360,7 @@ class TestController extends AbstractController
|
|||||||
if (empty($doctor_pharmacist_cert)){
|
if (empty($doctor_pharmacist_cert)){
|
||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
return 111;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_15(){
|
public function test_15(){
|
||||||
@ -378,29 +379,29 @@ class TestController extends AbstractController
|
|||||||
public function test_16(){
|
public function test_16(){
|
||||||
$CaOnline = new CaOnline();
|
$CaOnline = new CaOnline();
|
||||||
|
|
||||||
// 测试医生
|
// 测试医生
|
||||||
// $data = array();
|
$data = array();
|
||||||
// $data['user_id'] = "491925054435950592";
|
$data['user_id'] = "491925054435950592";
|
||||||
// $data['mobile'] = "13028643897";
|
$data['mobile'] = "13028643897";
|
||||||
// $data['card_name'] = "郝明明";
|
$data['card_name'] = "郝明明";
|
||||||
// $data['card_num'] = "130582199202032038";
|
$data['card_num'] = "130582199202032038";
|
||||||
// $data['orgDept'] = "科室名称";
|
$data['orgDept'] = "科室名称";
|
||||||
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
$data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||||||
// $data['org_number'] = "91510106MABTJY4K9R";
|
$data['org_number'] = "91510106MABTJY4K9R";
|
||||||
// $result = $CaOnline->getCloudCert($data);
|
$result = $CaOnline->getCloudCert($data);
|
||||||
//
|
|
||||||
// $data = array();
|
$data = array();
|
||||||
// $data['user_id'] = "491925054435950592";
|
$data['user_id'] = "491925054435950592";
|
||||||
// $data['type'] = 2;
|
$data['type'] = 2;
|
||||||
// $data['cert_base64'] = $result['certBase64'];
|
$data['cert_base64'] = $result['certBase64'];
|
||||||
// $data['cert_chain_p7'] = $result['certP7'];
|
$data['cert_chain_p7'] = $result['certP7'];
|
||||||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
$data['cert_serial_number'] = $result['certSerialnumber'];
|
||||||
// $data['ca_pin'] = "491925054435950592";
|
$data['ca_pin'] = "491925054435950592";
|
||||||
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
$doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
||||||
// if (empty($doctor_pharmacist_cert)){
|
if (empty($doctor_pharmacist_cert)){
|
||||||
// return fail();
|
return fail();
|
||||||
// }
|
}
|
||||||
// dump(111);
|
dump(111);
|
||||||
|
|
||||||
// // 测试药师
|
// // 测试药师
|
||||||
// $data = array();
|
// $data = array();
|
||||||
@ -423,35 +424,36 @@ class TestController extends AbstractController
|
|||||||
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
||||||
// if (empty($doctor_pharmacist_cert)){
|
// if (empty($doctor_pharmacist_cert)){
|
||||||
// return fail();
|
// return fail();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $params = array();
|
||||||
|
// $params['ca_pin'] = "491925054435950592";
|
||||||
|
// $params['type'] = "2";
|
||||||
|
// $user_ca_cert = UserCaCert::getOne($params);
|
||||||
|
// if (empty($user_ca_cert)){
|
||||||
|
// return fail();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
$params = array();
|
return 122;
|
||||||
$params['ca_pin'] = "491925054435950592";
|
// // 测试医院
|
||||||
$params['type'] = "2";
|
// $data = array();
|
||||||
$user_ca_cert = UserCaCert::getOne($params);
|
// $data['user_id'] = "491925054435950592";
|
||||||
if (empty($user_ca_cert)){
|
// $result = $CaOnline->renewCloudCert($data);
|
||||||
return fail();
|
//
|
||||||
}
|
// dump($result);
|
||||||
|
//
|
||||||
// 测试医院
|
// $data = array();
|
||||||
$data = array();
|
// $data['cert_base64'] = $result['certBase64'];
|
||||||
$data['user_id'] = "491925054435950592";
|
// $data['cert_chain_p7'] = $result['certP7'];
|
||||||
$result = $CaOnline->renewCloudCert($data);
|
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||||||
|
// $data['ca_pin'] = "491925054435950592";
|
||||||
dump($result);
|
//
|
||||||
|
// $params = array();
|
||||||
$data = array();
|
// $params['cert_id'] = $user_ca_cert['cert_id'];
|
||||||
$data['cert_base64'] = $result['certBase64'];
|
// $res = UserCaCert::edit($params,$data);
|
||||||
$data['cert_chain_p7'] = $result['certP7'];
|
// if (empty($res)){
|
||||||
$data['cert_serial_number'] = $result['certSerialnumber'];
|
// return fail();
|
||||||
$data['ca_pin'] = "491925054435950592";
|
// }
|
||||||
|
|
||||||
$params = array();
|
|
||||||
$params['cert_id'] = $user_ca_cert['cert_id'];
|
|
||||||
$res = UserCaCert::edit($params,$data);
|
|
||||||
if (empty($res)){
|
|
||||||
return fail();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_17(){
|
public function test_17(){
|
||||||
|
|||||||
@ -12,6 +12,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $withdrawal_order_id 主键id
|
* @property int $withdrawal_order_id 主键id
|
||||||
* @property int $withdrawal_id 提现表id
|
* @property int $withdrawal_id 提现表id
|
||||||
* @property int $doctor_id 医生id
|
* @property int $doctor_id 医生id
|
||||||
|
* @property int $order_id 订单id
|
||||||
* @property int $order_inquiry_id 订单-问诊id
|
* @property int $order_inquiry_id 订单-问诊id
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
@ -28,7 +29,7 @@ class DoctorWithdrawalOrder extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['withdrawal_order_id', 'withdrawal_id', 'doctor_id', 'order_inquiry_id', 'created_at', 'updated_at'];
|
protected array $fillable = ['withdrawal_order_id', 'withdrawal_id', 'doctor_id', 'order_id', 'order_inquiry_id', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "withdrawal_order_id";
|
protected string $primaryKey = "withdrawal_order_id";
|
||||||
|
|
||||||
@ -64,4 +65,15 @@ class DoctorWithdrawalOrder extends Model
|
|||||||
{
|
{
|
||||||
return self::create($data);
|
return self::create($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
* @param array $params
|
||||||
|
* @param array $data
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function edit(array $params = [], array $data = []): int
|
||||||
|
{
|
||||||
|
return self::where($params)->update($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $pay_channel 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
* @property int $pay_channel 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||||
* @property int $pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
* @property int $pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||||
* @property string $pay_time 支付时间
|
* @property string $pay_time 支付时间
|
||||||
* @property int $refund_status 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
* @property int $refund_status 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||||
* @property string $order_no 系统订单编号
|
* @property string $order_no 系统订单编号
|
||||||
* @property string $escrow_trade_no 第三方支付流水号
|
* @property string $escrow_trade_no 第三方支付流水号
|
||||||
* @property string $amount_total 订单金额
|
* @property string $amount_total 订单金额
|
||||||
@ -32,8 +32,12 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property string $cancel_time 订单取消时间
|
* @property string $cancel_time 订单取消时间
|
||||||
* @property string $cancel_remarks 取消订单备注
|
* @property string $cancel_remarks 取消订单备注
|
||||||
* @property string $order_remarks 订单备注
|
* @property string $order_remarks 订单备注
|
||||||
* @property Carbon $created_at 创建时间
|
* @property int $is_withdrawal 是否提现(0:否 1:是 2:提现中 3:无需提现)
|
||||||
* @property Carbon $updated_at 修改时间
|
* @property string $withdrawal_time 提现时间
|
||||||
|
* @property \Carbon\Carbon $created_at 创建时间
|
||||||
|
* @property \Carbon\Carbon $updated_at 修改时间
|
||||||
|
* @property-read OrderInquiry|null $OrderInquiry
|
||||||
|
* @property-read OrderServicePackage|null $OrderServicePackage
|
||||||
*/
|
*/
|
||||||
class Order extends Model
|
class Order extends Model
|
||||||
{
|
{
|
||||||
@ -47,7 +51,7 @@ class Order extends Model
|
|||||||
/**
|
/**
|
||||||
* The attributes that are mass assignable.
|
* The attributes that are mass assignable.
|
||||||
*/
|
*/
|
||||||
protected array $fillable = ['order_id', 'user_id', 'patient_id', 'doctor_id', 'order_type', 'is_delete', 'pay_channel', 'pay_status', 'pay_time', 'refund_status', 'order_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'cancel_status', 'cancel_time', 'cancel_remarks', 'order_remarks', 'created_at', 'updated_at'];
|
protected array $fillable = ['order_id', 'user_id', 'patient_id', 'doctor_id', 'order_type', 'is_delete', 'pay_channel', 'pay_status', 'pay_time', 'refund_status', 'order_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'cancel_status', 'cancel_time', 'cancel_remarks', 'order_remarks', 'is_withdrawal', 'withdrawal_time', 'created_at', 'updated_at'];
|
||||||
|
|
||||||
protected string $primaryKey = "order_id";
|
protected string $primaryKey = "order_id";
|
||||||
|
|
||||||
@ -122,7 +126,9 @@ class Order extends Model
|
|||||||
*/
|
*/
|
||||||
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(array $params, array $date_params,string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||||
{
|
{
|
||||||
$query = self::with(['OrderInquiry', 'OrderServicePackage'])->where($params);
|
$query = self::with(['OrderInquiry', 'OrderServicePackage'])
|
||||||
|
->whereIn('order_type',[1,4,5])
|
||||||
|
->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){
|
||||||
@ -166,7 +172,8 @@ class Order extends Model
|
|||||||
*/
|
*/
|
||||||
public static function getDoctorDayAmountTotal(array $params, array $date_params,string|int $is_platform_deep_cooperation): int|null|string
|
public static function getDoctorDayAmountTotal(array $params, array $date_params,string|int $is_platform_deep_cooperation): int|null|string
|
||||||
{
|
{
|
||||||
$query = self::where($params);
|
$query = self::where($params)
|
||||||
|
->whereIn('order_type',[1,4,5]);
|
||||||
|
|
||||||
// 问诊订单
|
// 问诊订单
|
||||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
||||||
@ -208,7 +215,8 @@ class Order extends Model
|
|||||||
*/
|
*/
|
||||||
public static function getDoctorDayCompletedAmountTotal(array $params, array $date_params,string|int $is_platform_deep_cooperation): int|null|string
|
public static function getDoctorDayCompletedAmountTotal(array $params, array $date_params,string|int $is_platform_deep_cooperation): int|null|string
|
||||||
{
|
{
|
||||||
$query = self::where($params);
|
$query = self::where($params)
|
||||||
|
->whereIn('order_type',[1,4,5]);
|
||||||
|
|
||||||
// 问诊订单
|
// 问诊订单
|
||||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
||||||
@ -240,4 +248,58 @@ class Order extends Model
|
|||||||
->sum("amount_total");;
|
->sum("amount_total");;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取可提现订单列表
|
||||||
|
* @param array $params
|
||||||
|
* @param string|int $is_platform_deep_cooperation
|
||||||
|
* @param array $fields
|
||||||
|
* @param int|null $page
|
||||||
|
* @param int|null $per_page
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getDoctorWithdrawalOrderList(array $params, string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||||
|
{
|
||||||
|
$query = self::with(['OrderInquiry', 'OrderServicePackage'])
|
||||||
|
->where($params)
|
||||||
|
->whereIn('order_type',[1,4,5]);
|
||||||
|
|
||||||
|
// 问诊订单
|
||||||
|
$query = $query->where(function ($query) use ($is_platform_deep_cooperation){
|
||||||
|
$query->whereExists(function ($subQuery) use ($is_platform_deep_cooperation){
|
||||||
|
$subQuery->from('order_inquiry');
|
||||||
|
if ($is_platform_deep_cooperation == 1){
|
||||||
|
$subQuery->whereNotIn('inquiry_type', [2,4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$subQuery->whereNotIn('inquiry_mode', [7,8,9])
|
||||||
|
->whereIn('inquiry_status', [6])
|
||||||
|
->whereIn('inquiry_refund_status', [0,3])
|
||||||
|
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||||
|
})
|
||||||
|
->orWhereExists(function ($subQuery) {
|
||||||
|
$subQuery->from('order_service_package')
|
||||||
|
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||||
|
->whereIn('refund_status', [0,3])
|
||||||
|
->where('pay_status', 2)
|
||||||
|
->where('start_time', 2)
|
||||||
|
->whereIn('order_service_status', [4,5])
|
||||||
|
->WhereExists(function ($subQuery){
|
||||||
|
$subQuery->from("order_service_package_inquiry")
|
||||||
|
->whereRaw('gdxz_order_service_package.order_service_id = gdxz_order_service_package_inquiry.order_service_id');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$result = $query->paginate($per_page, $fields, "page", $page);
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['current_page'] = $result->currentPage();// 当前页码
|
||||||
|
$data['total'] = $result->total();//数据总数
|
||||||
|
$data['data'] = $result->items();//数据
|
||||||
|
$data['per_page'] = $result->perPage();//每页个数
|
||||||
|
$data['last_page'] = $result->lastPage();//最后一页
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -234,40 +234,13 @@ class OrderInquiry extends Model
|
|||||||
* 已结束
|
* 已结束
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param array $inquiry_status_params
|
* @param array $inquiry_status_params
|
||||||
* @param array $fields
|
|
||||||
* @param int|null $page
|
|
||||||
* @param int|null $per_page
|
|
||||||
* @return int|mixed|string
|
|
||||||
*/
|
|
||||||
public static function getDoctorOrderInquiryPage(array $params, array $inquiry_status_params, array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
|
||||||
{
|
|
||||||
$raw = self::where($params)
|
|
||||||
->whereIn('inquiry_status', $inquiry_status_params)
|
|
||||||
->orderBy('finish_time', 'desc')
|
|
||||||
->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取医生接诊订单分页数据-坐班医生
|
|
||||||
* 已结束
|
|
||||||
* @param array $params
|
|
||||||
* @param array $inquiry_status_params
|
|
||||||
* @param array $inquiry_type_not_params
|
* @param array $inquiry_type_not_params
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
* @param int|null $page
|
* @param int|null $page
|
||||||
* @param int|null $per_page
|
* @param int|null $per_page
|
||||||
* @return int|mixed|string
|
* @return int|mixed|string
|
||||||
*/
|
*/
|
||||||
public static function getCooperationDoctorOrderInquiryPage(array $params, array $inquiry_status_params,array $inquiry_type_not_params = [], array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
public static function getDoctorOrderInquiryPage(array $params, array $inquiry_status_params,array $inquiry_type_not_params = [], array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||||
{
|
{
|
||||||
$raw = self::where($params)
|
$raw = self::where($params)
|
||||||
->whereIn('inquiry_status', $inquiry_status_params)
|
->whereIn('inquiry_status', $inquiry_status_params)
|
||||||
|
|||||||
@ -13,6 +13,8 @@ use App\Model\DoctorWithdrawalOrder;
|
|||||||
use App\Model\Order;
|
use App\Model\Order;
|
||||||
use App\Model\OrderInquiry;
|
use App\Model\OrderInquiry;
|
||||||
use App\Model\OrderInquiryRefund;
|
use App\Model\OrderInquiryRefund;
|
||||||
|
use App\Model\OrderServicePackage;
|
||||||
|
use App\Model\OrderServicePackageDetail;
|
||||||
use App\Model\OrderServicePackageRefund;
|
use App\Model\OrderServicePackageRefund;
|
||||||
use App\Model\UserDoctor;
|
use App\Model\UserDoctor;
|
||||||
use App\Model\UserDoctorInfo;
|
use App\Model\UserDoctorInfo;
|
||||||
@ -33,13 +35,13 @@ class DoctorAccountService extends BaseService
|
|||||||
|
|
||||||
$year = $this->request->input('date');
|
$year = $this->request->input('date');
|
||||||
|
|
||||||
$date = date('Y-m-d',time());
|
$date = date('Y-m-d', time());
|
||||||
|
|
||||||
// 获取医生数据
|
// 获取医生数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$user_doctor = UserDoctor::getOne($params);
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
if (empty($user_doctor)){
|
if (empty($user_doctor)) {
|
||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,22 +49,22 @@ class DoctorAccountService extends BaseService
|
|||||||
$OrderServicePackageService = new OrderServicePackageService();
|
$OrderServicePackageService = new OrderServicePackageService();
|
||||||
|
|
||||||
// 获取医生当日的接诊订单金额
|
// 获取医生当日的接诊订单金额
|
||||||
$doctor_today_inquiry_total = $inquiryService->getDoctorDayAmountTotal($user_doctor['doctor_id'],$date,$user_doctor['is_platform_deep_cooperation']);
|
$doctor_today_inquiry_total = $inquiryService->getDoctorDayAmountTotal($user_doctor['doctor_id'], $date, $user_doctor['is_platform_deep_cooperation']);
|
||||||
|
|
||||||
// 获取医生当日的服务包订单问诊金额-开始时间
|
// 获取医生当日的服务包订单问诊金额-开始时间
|
||||||
$doctor_today_service_package_total = $OrderServicePackageService->getDoctorDayAmountTotal($user_doctor['doctor_id'],$date);
|
$doctor_today_service_package_total = $OrderServicePackageService->getDoctorDayAmountTotal($user_doctor['doctor_id'], $date);
|
||||||
|
|
||||||
// 医生当日的订单金额
|
// 医生当日的订单金额
|
||||||
$doctor_today_total = bcadd($doctor_today_inquiry_total,$doctor_today_service_package_total,2);
|
$doctor_today_total = bcadd($doctor_today_inquiry_total, $doctor_today_service_package_total, 2);
|
||||||
|
|
||||||
// 获取医生当日已完成未结束的问诊订单金额
|
// 获取医生当日已完成未结束的问诊订单金额
|
||||||
$doctor_day_inquiry_completed_amount_total = $inquiryService->getDoctorDayCompletedAmountTotal($user_doctor['doctor_id'],$date,$user_doctor['is_platform_deep_cooperation']);
|
$doctor_day_inquiry_completed_amount_total = $inquiryService->getDoctorDayCompletedAmountTotal($user_doctor['doctor_id'], $date, $user_doctor['is_platform_deep_cooperation']);
|
||||||
|
|
||||||
// 获取医生当日未完成的服务包订单问诊金额-结束时间
|
// 获取医生当日未完成的服务包订单问诊金额-结束时间
|
||||||
$doctor_day_service_package_completed_amount_total = $OrderServicePackageService->getDoctorDayNoFinishAmountTotal($user_doctor['doctor_id'],$date);
|
$doctor_day_service_package_completed_amount_total = $OrderServicePackageService->getDoctorDayNoFinishAmountTotal($user_doctor['doctor_id'], $date);
|
||||||
|
|
||||||
// 已完成待入账金额
|
// 已完成待入账金额
|
||||||
$doctor_day_completed_amount_total = bcadd($doctor_day_inquiry_completed_amount_total,$doctor_day_service_package_completed_amount_total,2);
|
$doctor_day_completed_amount_total = bcadd($doctor_day_inquiry_completed_amount_total, $doctor_day_service_package_completed_amount_total, 2);
|
||||||
|
|
||||||
// 获取医生账户余额
|
// 获取医生账户余额
|
||||||
$balance_account = 0;
|
$balance_account = 0;
|
||||||
@ -83,7 +85,7 @@ class DoctorAccountService extends BaseService
|
|||||||
if (!empty($doctor_account_days)) {
|
if (!empty($doctor_account_days)) {
|
||||||
foreach ($doctor_account_days as $doctor_account_day) {
|
foreach ($doctor_account_days as $doctor_account_day) {
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['total_amount'] = bcmul((string)$doctor_account_day['total_amount'],1,2);
|
$data['total_amount'] = bcmul((string)$doctor_account_day['total_amount'], 1, 2);
|
||||||
$data['month'] = $doctor_account_day['month'];
|
$data['month'] = $doctor_account_day['month'];
|
||||||
$bill[] = $data;
|
$bill[] = $data;
|
||||||
}
|
}
|
||||||
@ -91,9 +93,9 @@ class DoctorAccountService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$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); // 今日预计收入
|
||||||
$result['doctor_day_completed_amount_total'] = bcmul((string)$doctor_day_completed_amount_total ,"0.75",2); // 今日已完成收入
|
$result['doctor_day_completed_amount_total'] = bcmul((string)$doctor_day_completed_amount_total, "0.75", 2); // 今日已完成收入
|
||||||
$result['balance_account'] = bcmul((string)$balance_account ,"1",2); // 账户余额
|
$result['balance_account'] = bcmul((string)$balance_account, "1", 2); // 账户余额
|
||||||
$result['bill'] = $bill; // 账单
|
$result['bill'] = $bill; // 账单
|
||||||
|
|
||||||
return success($result);
|
return success($result);
|
||||||
@ -115,15 +117,15 @@ class DoctorAccountService extends BaseService
|
|||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$user_doctor = UserDoctor::getOne($params);
|
$user_doctor = UserDoctor::getOne($params);
|
||||||
if (empty($user_doctor)){
|
if (empty($user_doctor)) {
|
||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
$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));
|
||||||
|
|
||||||
// 获取当月结束时间
|
// 获取当月结束时间
|
||||||
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
||||||
@ -131,45 +133,13 @@ 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($params, $date_params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||||
if (!empty($results['data'])) {
|
if (!empty($results['data'])) {
|
||||||
foreach ($results['data'] as &$result) {
|
foreach ($results['data'] as &$result) {
|
||||||
// 入账金额
|
// 填入字段
|
||||||
$result['estimate_income'] = bcmul((string)$result['amount_total'],"0.75",2);
|
if (!empty($result['OrderInquiry'])) {
|
||||||
|
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||||
// 入账状态-问诊订单
|
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||||
if (!empty($result['OrderInquiry'])){
|
|
||||||
if ($result['OrderInquiry']['inquiry_status'] == 4 || $result['OrderInquiry']['inquiry_status'] == 5){
|
|
||||||
$result['entry_status'] = 1;// 入账中
|
|
||||||
}elseif ($result['OrderInquiry']['inquiry_status'] == 6){
|
|
||||||
$result['entry_status'] = 2;// 入账成功
|
|
||||||
}elseif ($result['OrderInquiry']['inquiry_status'] == 7){
|
|
||||||
$result['entry_status'] = 3;// 入账失败
|
|
||||||
// 获取退款数据
|
|
||||||
$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'] = $refund_total;
|
|
||||||
|
|
||||||
if (($result['OrderInquiry']['payment_amount_total'] - $refund_total) > 0){
|
|
||||||
$result['entry_status'] = 2;// 入账成功
|
|
||||||
}else{
|
|
||||||
$result['entry_status'] = 3;// 入账失败
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($result['OrderInquiry']['cancel_reason'])){
|
|
||||||
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$result['entry_status'] = 0;// 未知
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||||
@ -182,36 +152,7 @@ class DoctorAccountService extends BaseService
|
|||||||
$result['inquiry_mode'] = $result['OrderInquiry']['inquiry_mode'];
|
$result['inquiry_mode'] = $result['OrderInquiry']['inquiry_mode'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 入账状态-服务包订单
|
if (!empty($result['OrderServicePackage'])) {
|
||||||
if (!empty($result['OrderServicePackage'])){
|
|
||||||
if ($result['OrderServicePackage']['order_service_status'] == 3){
|
|
||||||
$result['entry_status'] = 1;// 入账中
|
|
||||||
}elseif ($result['OrderServicePackage']['order_service_status'] == 4){
|
|
||||||
$result['entry_status'] = 2;// 入账成功
|
|
||||||
}elseif ($result['OrderServicePackage']['order_service_status'] == 5){
|
|
||||||
// 获取退款数据
|
|
||||||
$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['OrderServicePackage']['payment_amount_total'] - $refund_total) > 0){
|
|
||||||
$result['entry_status'] = 2;// 入账成功
|
|
||||||
}else{
|
|
||||||
$result['entry_status'] = 3;// 入账失败
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$result['entry_status'] = 0;// 未知
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
||||||
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
||||||
@ -220,6 +161,116 @@ class DoctorAccountService extends BaseService
|
|||||||
$result['finish_time'] = $result['OrderServicePackage']['finish_time'];
|
$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'] = $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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理入账状态
|
||||||
|
if (!empty($result['OrderInquiry'])) {
|
||||||
|
if ($result['OrderInquiry']['inquiry_status'] == 4 || $result['OrderInquiry']['inquiry_status'] == 5) {
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
} elseif ($result['OrderInquiry']['inquiry_status'] == 6) {
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
} elseif ($result['OrderInquiry']['inquiry_status'] == 7) {
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
|
||||||
|
if (($result['OrderInquiry']['amount_total'] - $result['refund_total']) > 0) {
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
} else {
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result['entry_status'] = 0;// 未知
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($result['OrderServicePackage'])) {
|
||||||
|
if ($result['OrderServicePackage']['order_service_status'] == 3) {
|
||||||
|
$result['entry_status'] = 1;// 入账中
|
||||||
|
} elseif ($result['OrderServicePackage']['order_service_status'] == 4) {
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
} elseif ($result['OrderServicePackage']['order_service_status'] == 5) {
|
||||||
|
if (($result['OrderServicePackage']['amount_total'] - $result['refund_total']) > 0) {
|
||||||
|
$result['entry_status'] = 2;// 入账成功
|
||||||
|
} else {
|
||||||
|
$result['entry_status'] = 3;// 入账失败
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result['entry_status'] = 0;// 未知
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unset($result['OrderInquiry']);
|
unset($result['OrderInquiry']);
|
||||||
unset($result['OrderServicePackage']);
|
unset($result['OrderServicePackage']);
|
||||||
}
|
}
|
||||||
@ -291,32 +342,22 @@ class DoctorAccountService extends BaseService
|
|||||||
$amount_total = 0;
|
$amount_total = 0;
|
||||||
|
|
||||||
// 获取医生账户总表
|
// 获取医生账户总表
|
||||||
|
$params = array();
|
||||||
// 获取医生账户余额
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$InquiryService = new InquiryService();
|
$doctor_account = DoctorAccount::getOne($params);
|
||||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
if (!empty($doctor_account)) {
|
||||||
$order_inquiry = $InquiryService->getDoctorCanWithdrawalInquiryOrder($user_info['client_user_id']);
|
$amount_total = $doctor_account['balance_account'];
|
||||||
}else{
|
|
||||||
$order_inquiry = $InquiryService->getCooperationDoctorCanWithdrawalInquiryOrder($user_info['client_user_id']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($order_inquiry)){
|
|
||||||
foreach ($order_inquiry as $value){
|
|
||||||
$amount_total = bcadd((string)$amount_total,(string)$value["amount_total"],2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$amount_total = bcmul((string)$amount_total,"0.75",2);
|
|
||||||
|
|
||||||
// 计算医生个人所得税
|
// 计算医生个人所得税
|
||||||
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
||||||
|
|
||||||
$withdrawal_amount = bcsub($amount_total,$income_tax,2);
|
$withdrawal_amount = bcsub($amount_total, $income_tax, 2);
|
||||||
|
|
||||||
$income_tax = bcmul($income_tax,1,2);
|
$income_tax = bcmul($income_tax, 1, 2);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['bank'] = $bank;//银行数据
|
$result['bank'] = $bank; //银行数据
|
||||||
$result['amount_total'] = $amount_total; // 账户余额
|
$result['amount_total'] = $amount_total; // 账户余额
|
||||||
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
||||||
$result['income_tax'] = $income_tax; // 个人所得税
|
$result['income_tax'] = $income_tax; // 个人所得税
|
||||||
@ -324,6 +365,63 @@ class DoctorAccountService extends BaseService
|
|||||||
return success($result);
|
return success($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 获取可提现问诊订单列表
|
||||||
|
// * @return array
|
||||||
|
// */
|
||||||
|
// public function getDoctorWithdrawalOrderList(): array
|
||||||
|
// {
|
||||||
|
// $user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
//
|
||||||
|
// $page = $this->request->input('page', 1);
|
||||||
|
// $per_page = $this->request->input('per_page', 10);
|
||||||
|
//
|
||||||
|
// // 获取医生信息
|
||||||
|
// $params = array();
|
||||||
|
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
// $user_doctor = UserDoctor::getOne($params);
|
||||||
|
// if (empty($user_doctor)) {
|
||||||
|
// return fail();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $fields = [
|
||||||
|
// 'order_inquiry_id',
|
||||||
|
// 'inquiry_type',
|
||||||
|
// 'inquiry_mode',
|
||||||
|
// 'inquiry_status',
|
||||||
|
// 'inquiry_refund_status',
|
||||||
|
// 'inquiry_no',
|
||||||
|
// 'amount_total',
|
||||||
|
// 'payment_amount_total',
|
||||||
|
// 'reception_time',
|
||||||
|
// 'finish_time',
|
||||||
|
// 'patient_name',
|
||||||
|
// 'patient_sex',
|
||||||
|
// 'patient_age',
|
||||||
|
// ];
|
||||||
|
//
|
||||||
|
// $params = array();
|
||||||
|
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
// $params['inquiry_refund_status'] = 0; // inquiry_refund_status:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||||
|
//
|
||||||
|
// $inquiry_status_params = [6]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||||
|
//
|
||||||
|
// $inquiry_type_not_params = [];
|
||||||
|
// if ($user_doctor['is_platform_deep_cooperation'] == 0) {
|
||||||
|
// $inquiry_type_not_params = [2, 4];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $order_inquiry = OrderInquiry:: getDoctorOrderInquiryPage($params, $inquiry_status_params, $inquiry_type_not_params, $fields, $page, $per_page);
|
||||||
|
//
|
||||||
|
// if (!empty($order_inquiry['data'])) {
|
||||||
|
// foreach ($order_inquiry['data'] as &$item) {
|
||||||
|
// $item['expected_amount_total'] = floor($item['amount_total'] * 0.75 * 100) / 100;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return success($order_inquiry);
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取可提现问诊订单列表
|
* 获取可提现问诊订单列表
|
||||||
* @return array
|
* @return array
|
||||||
@ -343,44 +441,119 @@ class DoctorAccountService extends BaseService
|
|||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取医生当日接诊订单金额
|
|
||||||
$fields = [
|
|
||||||
'order_inquiry_id',
|
|
||||||
'inquiry_type',
|
|
||||||
'inquiry_mode',
|
|
||||||
'inquiry_status',
|
|
||||||
'inquiry_refund_status',
|
|
||||||
'inquiry_no',
|
|
||||||
'amount_total',
|
|
||||||
'payment_amount_total',
|
|
||||||
'reception_time',
|
|
||||||
'finish_time',
|
|
||||||
'patient_name',
|
|
||||||
'patient_sex',
|
|
||||||
'patient_age',
|
|
||||||
];
|
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$params['inquiry_refund_status'] = 0; // inquiry_refund_status:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
$params['is_withdrawal'] = 0;
|
||||||
|
|
||||||
$inquiry_status_params = [6]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
$results = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||||
|
|
||||||
|
if (!empty($results['data'])) {
|
||||||
|
foreach ($results['data'] as &$result) {
|
||||||
|
// 填入字段
|
||||||
|
if (!empty($result['OrderInquiry'])) {
|
||||||
|
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||||
|
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||||
$order_inquiry = OrderInquiry:: getDoctorOrderInquiryPage($params,$inquiry_status_params, $fields,$page,$per_page);
|
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||||
}else{
|
$result['patient_sex'] = $result['OrderInquiry']['patient_sex'];
|
||||||
$inquiry_type_not_params = [2,4];
|
$result['patient_age'] = $result['OrderInquiry']['patient_age'];
|
||||||
$order_inquiry = OrderInquiry:: getCooperationDoctorOrderInquiryPage($params,$inquiry_status_params,$inquiry_type_not_params, $fields,$page,$per_page);
|
$result['start_time'] = $result['OrderInquiry']['reception_time'];
|
||||||
}
|
$result['finish_time'] = $result['OrderInquiry']['finish_time'];
|
||||||
|
$result['inquiry_type'] = $result['OrderInquiry']['inquiry_type'];
|
||||||
|
$result['inquiry_mode'] = $result['OrderInquiry']['inquiry_mode'];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($order_inquiry['data'])) {
|
if (!empty($result['OrderServicePackage'])) {
|
||||||
foreach ($order_inquiry['data'] as &$item) {
|
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
$item['expected_amount_total'] = floor($item['amount_total'] * 0.75 * 100) / 100;
|
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
||||||
|
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
||||||
|
$result['patient_age'] = $result['OrderServicePackage']['patient_age'];
|
||||||
|
$result['start_time'] = $result['OrderServicePackage']['start_time'];
|
||||||
|
$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'] = $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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($result['OrderInquiry']);
|
||||||
|
unset($result['OrderServicePackage']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success($order_inquiry);
|
return success($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -392,21 +565,21 @@ class DoctorAccountService extends BaseService
|
|||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
$year = $this->request->input('year');
|
$year = $this->request->input('year');
|
||||||
$page = $this->request->input('page',1);
|
$page = $this->request->input('page', 1);
|
||||||
$per_page = $this->request->input('per_page',10);
|
$per_page = $this->request->input('per_page', 10);
|
||||||
|
|
||||||
// 获取当年开始时间
|
// 获取当年开始时间
|
||||||
$start_date = $year.'-1-1 00:00:00';
|
$start_date = $year . '-1-1 00:00:00';
|
||||||
|
|
||||||
// 获取当年结束时间
|
// 获取当年结束时间
|
||||||
$end_date = $year.'-12-31 23:59:59';
|
$end_date = $year . '-12-31 23:59:59';
|
||||||
|
|
||||||
$created_at_params = [$start_date, $end_date];
|
$created_at_params = [$start_date, $end_date];
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params,$created_at_params,['*'],$page,$per_page);
|
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params, $created_at_params, ['*'], $page, $per_page);
|
||||||
if (empty($doctor_withdrawal['data'])){
|
if (empty($doctor_withdrawal['data'])) {
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,20 +595,20 @@ class DoctorAccountService extends BaseService
|
|||||||
{
|
{
|
||||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||||
|
|
||||||
$order_inquiry_id = $this->request->input('order_inquiry_id');
|
$order_no = $this->request->input('order_no');
|
||||||
$withdrawal_amount_total = $this->request->input('withdrawal_amount_total');
|
$withdrawal_amount_total = $this->request->input('withdrawal_amount_total');
|
||||||
$bank_card_id = $this->request->input('bank_card_id');
|
$bank_card_id = $this->request->input('bank_card_id');
|
||||||
|
|
||||||
$order_inquiry_id = explode(',',$order_inquiry_id);
|
$order_nos = explode(',', $order_no);
|
||||||
if (empty($order_inquiry_id)){
|
if (empty($order_nos)) {
|
||||||
return fail();
|
return fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
$app_env = config('app_env');
|
$app_env = config('app_env');
|
||||||
if ($app_env != "dev"){
|
if ($app_env != "dev") {
|
||||||
// 正式环境高于300元才可以提现
|
// 正式环境高于300元才可以提现
|
||||||
if ($withdrawal_amount_total < 300){
|
if ($withdrawal_amount_total < 300) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"提现金额小于300元");
|
return fail(HttpEnumCode::HTTP_ERROR, "提现金额小于300元");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,46 +616,137 @@ class DoctorAccountService extends BaseService
|
|||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
|
||||||
$start_time = date('Y-m-01',time());
|
$start_time = date('Y-m-01', time());
|
||||||
$end_time = date('Y-m-t 24:00:00',time());
|
$end_time = date('Y-m-t 24:00:00', time());
|
||||||
$created_at = [$start_time,$end_time];
|
$created_at = [$start_time, $end_time];
|
||||||
|
|
||||||
$doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params,$created_at,['*'],);
|
$doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params, $created_at, ['*'],);
|
||||||
if (!empty($doctor_withdrawal)){
|
if (!empty($doctor_withdrawal)) {
|
||||||
return fail("每月只允许提现一次");
|
return fail("每月只允许提现一次");
|
||||||
}
|
}
|
||||||
|
|
||||||
$amount_total = 0;
|
$amount_total = 0;
|
||||||
foreach ($order_inquiry_id as $value){
|
foreach ($order_nos as $order_no) {
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $value;
|
$params['order_no'] = $order_no;
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
$order = Order::getOne($params);
|
||||||
if (empty($order_inquiry)){
|
if (empty($order)) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"存在不可提现订单");
|
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||||
}
|
|
||||||
|
|
||||||
// 验证订单状态
|
|
||||||
if ($order_inquiry['inquiry_status'] != 6){
|
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"提现失败");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单提现状态
|
// 验证订单提现状态
|
||||||
if ($order_inquiry['is_withdrawal'] != 0){
|
if ($order['is_withdrawal'] != 0) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"存在已提现订单");
|
return fail(HttpEnumCode::HTTP_ERROR, "存在已提现订单");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证订单支付状态
|
// 问诊订单
|
||||||
if ($order_inquiry['inquiry_pay_status'] != 2){
|
if ($order['order_type'] == 1){
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"存在未支付订单");
|
$params = array();
|
||||||
|
$params['order_id'] = $order['order_id'];
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
|
if (empty($order_inquiry)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单状态
|
||||||
|
if ($order_inquiry['inquiry_status'] != 6) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单提现状态
|
||||||
|
if ($order_inquiry['is_withdrawal'] != 0) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在已提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单支付状态
|
||||||
|
if ($order_inquiry['inquiry_pay_status'] != 2) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在未支付订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单退款金额
|
||||||
|
$refund_total = 0;
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['inquiry_no'] = $order_inquiry['inquiry_no'];
|
||||||
|
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||||
|
if (!empty($order_inquiry_refunds)) {
|
||||||
|
foreach ($order_inquiry_refunds as $order_inquiry_refund) {
|
||||||
|
$refund_total = $refund_total + $order_inquiry_refund['refund_total'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$amount_total = bcadd(
|
||||||
|
$amount_total,
|
||||||
|
bcsub(
|
||||||
|
$order_inquiry['amount_total'],
|
||||||
|
$refund_total,
|
||||||
|
3
|
||||||
|
),
|
||||||
|
3
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算订单总金额
|
// 服务包订单
|
||||||
$amount_total = bcadd($amount_total,$order_inquiry["amount_total"],2);
|
if ($order['order_type'] == 4 || $order['order_type'] == 5){
|
||||||
|
$params = array();
|
||||||
|
$params['order_id'] = $order['order_id'];
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order_service_package = OrderServicePackage::getOne($params);
|
||||||
|
if (empty($order_service_package)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单状态
|
||||||
|
if ($order_service_package['order_service_status'] != 4 || $order_service_package['order_service_status'] != 5) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单支付状态
|
||||||
|
if ($order_service_package['pay_status'] != 2) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在未支付订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取退款数据
|
||||||
|
$refund_total = 0;
|
||||||
|
|
||||||
|
$params = array();
|
||||||
|
$params['order_service_no'] = $order_service_package['order_service_no'];
|
||||||
|
$order_service_package_refunds = OrderServicePackageRefund::getList($params);
|
||||||
|
if (!empty($order_service_package_refunds)) {
|
||||||
|
foreach ($order_service_package_refunds as $order_service_package_refund) {
|
||||||
|
$refund_total = $refund_total + $order_service_package_refund['refund_total'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取订单详情数据
|
||||||
|
$params = array();
|
||||||
|
$params['order_service_no'] = $order_service_package['order_service_no'];
|
||||||
|
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||||
|
if (empty($order_service_package_detail)){
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "提现失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算本次问诊服务包问诊金额
|
||||||
|
$amount_total = bcadd(
|
||||||
|
(string)$amount_total,
|
||||||
|
bcsub(
|
||||||
|
bcmul(
|
||||||
|
(string)$order_service_package_detail['service_count'],
|
||||||
|
(string)$order_service_package_detail['single_inquiry_price'],
|
||||||
|
3
|
||||||
|
),
|
||||||
|
$refund_total,
|
||||||
|
3
|
||||||
|
),
|
||||||
|
3
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提现金额
|
// 提现金额
|
||||||
$amount_total = $amount_total * 0.75;
|
$amount_total = bcmul((string)$amount_total,0.75,2);
|
||||||
|
|
||||||
// 计算医生个人所得税
|
// 计算医生个人所得税
|
||||||
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
||||||
@ -490,28 +754,28 @@ class DoctorAccountService extends BaseService
|
|||||||
// 实际提现金额
|
// 实际提现金额
|
||||||
$withdrawal_amount = $amount_total - $income_tax;
|
$withdrawal_amount = $amount_total - $income_tax;
|
||||||
|
|
||||||
if ($withdrawal_amount > 0){
|
if ($withdrawal_amount > 0) {
|
||||||
$withdrawal_amount = floor($withdrawal_amount * 100) / 100;
|
$withdrawal_amount = floor($withdrawal_amount * 100) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($withdrawal_amount_total != $withdrawal_amount){
|
if ($withdrawal_amount_total != $withdrawal_amount) {
|
||||||
return fail(HttpEnumCode::SERVER_ERROR,"金额不符合");
|
return fail(HttpEnumCode::SERVER_ERROR, "金额不符合");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测提现银行卡
|
// 检测提现银行卡
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['bank_card_id'] = $bank_card_id;
|
$params['bank_card_id'] = $bank_card_id;
|
||||||
$doctor_bank_card = DoctorBankCard::getOne($params);
|
$doctor_bank_card = DoctorBankCard::getOne($params);
|
||||||
if (empty($doctor_bank_card)){
|
if (empty($doctor_bank_card)) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"银行卡错误");
|
return fail(HttpEnumCode::HTTP_ERROR, "银行卡错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取银行数据
|
// 获取银行数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['bank_id'] = $doctor_bank_card['bank_id'];
|
$params['bank_id'] = $doctor_bank_card['bank_id'];
|
||||||
$basic_bank = BasicBank::getOne($params);
|
$basic_bank = BasicBank::getOne($params);
|
||||||
if (empty($basic_bank)){
|
if (empty($basic_bank)) {
|
||||||
return fail(HttpEnumCode::HTTP_ERROR,"银行卡错误");
|
return fail(HttpEnumCode::HTTP_ERROR, "银行卡错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::beginTransaction();
|
Db::beginTransaction();
|
||||||
@ -522,16 +786,16 @@ class DoctorAccountService extends BaseService
|
|||||||
$data['account_name'] = $basic_bank['bank_name'];
|
$data['account_name'] = $basic_bank['bank_name'];
|
||||||
$data['bank_card_code'] = $doctor_bank_card['bank_card_code'];
|
$data['bank_card_code'] = $doctor_bank_card['bank_card_code'];
|
||||||
$data['bank_card_code_four'] = substr($doctor_bank_card['bank_card_code'], -4);
|
$data['bank_card_code_four'] = substr($doctor_bank_card['bank_card_code'], -4);
|
||||||
if ($amount_total > 0){
|
if ($amount_total > 0) {
|
||||||
$data['applied_withdrawal_amount'] = floor($amount_total * 100) / 100; // 提现金额
|
$data['applied_withdrawal_amount'] = floor($amount_total * 100) / 100; // 提现金额
|
||||||
}
|
}
|
||||||
$data['actual_withdrawal_amount'] = $withdrawal_amount; // 实际提现金额
|
$data['actual_withdrawal_amount'] = $withdrawal_amount; // 实际提现金额
|
||||||
if ($income_tax > 0){
|
if ($income_tax > 0) {
|
||||||
$data['income_tax'] = floor($income_tax * 100) / 100; // 提现所得税金额
|
$data['income_tax'] = floor($income_tax * 100) / 100; // 提现所得税金额
|
||||||
}
|
}
|
||||||
$data['examine_status'] = 1; // 审核状态(1:审核中 2:审核通过 3:审核未通过)
|
$data['examine_status'] = 1; // 审核状态(1:审核中 2:审核通过 3:审核未通过)
|
||||||
$doctor_withdrawal = DoctorWithdrawal::addDoctorWithdrawal($data);
|
$doctor_withdrawal = DoctorWithdrawal::addDoctorWithdrawal($data);
|
||||||
if (empty($doctor_withdrawal)){
|
if (empty($doctor_withdrawal)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
return fail(HttpEnumCode::SERVER_ERROR);
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
}
|
}
|
||||||
@ -548,53 +812,71 @@ class DoctorAccountService extends BaseService
|
|||||||
$data['county_id'] = $doctor_bank_card['county_id'];
|
$data['county_id'] = $doctor_bank_card['county_id'];
|
||||||
$data['county'] = $doctor_bank_card['county'];
|
$data['county'] = $doctor_bank_card['county'];
|
||||||
$doctor_withdrawal_bank = DoctorWithdrawalBank::addDoctorWithdrawalBank($data);
|
$doctor_withdrawal_bank = DoctorWithdrawalBank::addDoctorWithdrawalBank($data);
|
||||||
if (empty($doctor_withdrawal_bank)){
|
if (empty($doctor_withdrawal_bank)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
return fail(HttpEnumCode::SERVER_ERROR);
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($order_inquiry_id as $value){
|
foreach ($order_nos as $order_no) {
|
||||||
|
$params = array();
|
||||||
|
$params['order_no'] = $order_no;
|
||||||
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
|
$order = Order::getOne($params);
|
||||||
|
if (empty($order)) {
|
||||||
|
Db::rollBack();
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
// 新增医生提现-关联订单表
|
// 新增医生提现-关联订单表
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['withdrawal_id'] = $doctor_withdrawal['withdrawal_id'];
|
$data['withdrawal_id'] = $doctor_withdrawal['withdrawal_id'];
|
||||||
$data['doctor_id'] = $user_info['client_user_id'];
|
$data['doctor_id'] = $user_info['client_user_id'];
|
||||||
$data['order_inquiry_id'] = $value;
|
$data['order_id'] = $order['order_id'];
|
||||||
$doctor_withdrawal_order = DoctorWithdrawalOrder::addDoctorWithdrawalOrder($data);
|
$doctor_withdrawal_order = DoctorWithdrawalOrder::addDoctorWithdrawalOrder($data);
|
||||||
if (empty($doctor_withdrawal_order)){
|
if (empty($doctor_withdrawal_order)) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
return fail(HttpEnumCode::SERVER_ERROR);
|
return fail(HttpEnumCode::SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改问诊订单提现状态
|
// 修改订单提现状态
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $value;
|
$params['order_no'] = $order_no;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['is_withdrawal'] = 2;
|
$data['is_withdrawal'] = 2;
|
||||||
$data['withdrawal_time'] = date('Y-m-d H:i:s',time());
|
$data['withdrawal_time'] = date('Y-m-d H:i:s', time());
|
||||||
OrderInquiry::edit($params,$data);
|
Order::edit($params,$data);
|
||||||
|
|
||||||
|
// 修改问诊订单提现状态
|
||||||
|
$params = array();
|
||||||
|
$params['order_id'] = $order['order_id'];;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['is_withdrawal'] = 2;
|
||||||
|
$data['withdrawal_time'] = date('Y-m-d H:i:s', time());
|
||||||
|
OrderInquiry::edit($params, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 账户表锁定
|
// 账户表锁定
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
// 账户余额
|
// 账户余额
|
||||||
DoctorAccount::dec($params,'balance_account',$amount_total);
|
DoctorAccount::dec($params, 'balance_account', $amount_total);
|
||||||
|
|
||||||
// 提现金额
|
// 提现金额
|
||||||
DoctorAccount::inc($params,'applied_withdrawal_amount',$amount_total);
|
DoctorAccount::inc($params, 'applied_withdrawal_amount', $amount_total);
|
||||||
|
|
||||||
// 实际提现金额
|
// 实际提现金额
|
||||||
DoctorAccount::inc($params,'actual_withdrawal_amount',$withdrawal_amount);
|
DoctorAccount::inc($params, 'actual_withdrawal_amount', $withdrawal_amount);
|
||||||
|
|
||||||
// 所得税金额
|
// 所得税金额
|
||||||
DoctorAccount::inc($params,'income_tax',$income_tax);
|
DoctorAccount::inc($params, 'income_tax', $income_tax);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return success();
|
return success();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
return fail(HttpEnumCode::SERVER_ERROR,$e->getMessage());
|
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +936,7 @@ class DoctorAccountService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 实际纳税金额
|
// 实际纳税金额
|
||||||
if ($income > 4000){
|
if ($income > 4000) {
|
||||||
$income = $income * 0.8;
|
$income = $income * 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -892,7 +892,7 @@ Router::addGroup('/case', function () {
|
|||||||
|
|
||||||
// 测试使用
|
// 测试使用
|
||||||
Router::addGroup('/test', function () {
|
Router::addGroup('/test', function () {
|
||||||
Router::get('', [TestController::class, 'test_17']);
|
Router::get('', [TestController::class, 'test_16']);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Router::get('/uninquiry', [TestController::class, 'uninquiry']);
|
// Router::get('/uninquiry', [TestController::class, 'uninquiry']);
|
||||||
|
|||||||
@ -359,7 +359,6 @@ abstract class Ca
|
|||||||
|
|
||||||
$arg = array_merge($arg, $option);
|
$arg = array_merge($arg, $option);
|
||||||
|
|
||||||
dump($arg);
|
|
||||||
$response = $this->client->post($path, $arg);
|
$response = $this->client->post($path, $arg);
|
||||||
|
|
||||||
if ($response->getStatusCode() != '200') {
|
if ($response->getStatusCode() != '200') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user