修正医生体现数据
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(){
|
||||||
@ -379,28 +380,28 @@ class TestController extends AbstractController
|
|||||||
$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;
|
||||||
@ -134,43 +136,11 @@ class DoctorAccountService extends BaseService
|
|||||||
$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'])) {
|
||||||
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'])) {
|
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||||
$result['cancel_remarks'] = inquiryCancelReasonToPushString($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'];
|
||||||
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||||
@ -182,13 +152,38 @@ 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['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
$result['entry_status'] = 1;// 入账中
|
$result['patient_name_mask'] = $result['OrderServicePackage']['patient_name_mask'];
|
||||||
}elseif ($result['OrderServicePackage']['order_service_status'] == 4){
|
$result['patient_sex'] = $result['OrderServicePackage']['patient_sex'];
|
||||||
$result['entry_status'] = 2;// 入账成功
|
$result['patient_age'] = $result['OrderServicePackage']['patient_age'];
|
||||||
}elseif ($result['OrderServicePackage']['order_service_status'] == 5){
|
$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 = array();
|
||||||
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
$params['order_service_no'] = $result['OrderServicePackage']['order_service_no'];
|
||||||
@ -201,23 +196,79 @@ class DoctorAccountService extends BaseService
|
|||||||
|
|
||||||
// 订单退款金额
|
// 订单退款金额
|
||||||
$result['refund_total'] = $refund_total;
|
$result['refund_total'] = $refund_total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (($result['OrderServicePackage']['payment_amount_total'] - $refund_total) > 0){
|
// 计算预计收入
|
||||||
|
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;// 入账成功
|
$result['entry_status'] = 2;// 入账成功
|
||||||
} else {
|
} else {
|
||||||
$result['entry_status'] = 3;// 入账失败
|
$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 {
|
} else {
|
||||||
$result['entry_status'] = 0;// 未知
|
$result['entry_status'] = 0;// 未知
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
|
||||||
$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'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($result['OrderInquiry']);
|
unset($result['OrderInquiry']);
|
||||||
@ -291,23 +342,13 @@ 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);
|
||||||
|
|
||||||
@ -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'])) {
|
||||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
foreach ($results['data'] as &$result) {
|
||||||
$order_inquiry = OrderInquiry:: getDoctorOrderInquiryPage($params,$inquiry_status_params, $fields,$page,$per_page);
|
// 填入字段
|
||||||
}else{
|
if (!empty($result['OrderInquiry'])) {
|
||||||
$inquiry_type_not_params = [2,4];
|
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||||
$order_inquiry = OrderInquiry:: getCooperationDoctorOrderInquiryPage($params,$inquiry_status_params,$inquiry_type_not_params, $fields,$page,$per_page);
|
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($order_inquiry['data'])) {
|
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||||
foreach ($order_inquiry['data'] as &$item) {
|
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||||
$item['expected_amount_total'] = floor($item['amount_total'] * 0.75 * 100) / 100;
|
$result['patient_sex'] = $result['OrderInquiry']['patient_sex'];
|
||||||
|
$result['patient_age'] = $result['OrderInquiry']['patient_age'];
|
||||||
|
$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($result['OrderServicePackage'])) {
|
||||||
|
$result['patient_name'] = $result['OrderServicePackage']['patient_name'];
|
||||||
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success($order_inquiry);
|
// 服务包订单
|
||||||
|
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($results);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -422,12 +595,12 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,9 +626,24 @@ class DoctorAccountService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$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'];
|
||||||
|
$order = Order::getOne($params);
|
||||||
|
if (empty($order)) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证订单提现状态
|
||||||
|
if ($order['is_withdrawal'] != 0) {
|
||||||
|
return fail(HttpEnumCode::HTTP_ERROR, "存在已提现订单");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 问诊订单
|
||||||
|
if ($order['order_type'] == 1){
|
||||||
|
$params = array();
|
||||||
|
$params['order_id'] = $order['order_id'];
|
||||||
$params['doctor_id'] = $user_info['client_user_id'];
|
$params['doctor_id'] = $user_info['client_user_id'];
|
||||||
$order_inquiry = OrderInquiry::getOne($params);
|
$order_inquiry = OrderInquiry::getOne($params);
|
||||||
if (empty($order_inquiry)) {
|
if (empty($order_inquiry)) {
|
||||||
@ -477,12 +665,88 @@ class DoctorAccountService extends BaseService
|
|||||||
return fail(HttpEnumCode::HTTP_ERROR, "存在未支付订单");
|
return fail(HttpEnumCode::HTTP_ERROR, "存在未支付订单");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算订单总金额
|
// 订单退款金额
|
||||||
$amount_total = bcadd($amount_total,$order_inquiry["amount_total"],2);
|
$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
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 服务包订单
|
||||||
|
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);
|
||||||
@ -553,21 +817,39 @@ class DoctorAccountService extends BaseService
|
|||||||
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['order_no'] = $order_no;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['is_withdrawal'] = 2;
|
||||||
|
$data['withdrawal_time'] = date('Y-m-d H:i:s', time());
|
||||||
|
Order::edit($params,$data);
|
||||||
|
|
||||||
// 修改问诊订单提现状态
|
// 修改问诊订单提现状态
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_inquiry_id'] = $value;
|
$params['order_id'] = $order['order_id'];;
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['is_withdrawal'] = 2;
|
$data['is_withdrawal'] = 2;
|
||||||
|
|||||||
@ -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