修改自动完成服务包订单分成金额计算
This commit is contained in:
parent
6849f1c15b
commit
86cc28ea13
@ -12,6 +12,8 @@ use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderPrescriptionService;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\Utils;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
@ -121,16 +123,10 @@ class AutoCompleteServicePackageDelayDirectConsumer extends ConsumerMessage
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
OrderServicePackage::edit($params,$data);
|
||||
|
||||
// 计算本次问诊服务包问诊金额
|
||||
if ($order_service_package['order_service_type'] == 1){
|
||||
$amount_total = bcmul(
|
||||
(string)$order_service_package_detail['single_inquiry_price'],
|
||||
(string)$order_service_package_detail['service_count'],
|
||||
8
|
||||
);
|
||||
}else{
|
||||
$amount_total = $order_service_package_detail['service_price'];
|
||||
}
|
||||
// 处理统计问题
|
||||
// 获取服务包订单中医生可分成的问诊金额
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$amount_total = $OrderServicePackageService->getServicePackageDoctorInquiryAmountTotal($order_service_package['order_service_no'],$order_service_package,$order_service_package_detail);
|
||||
|
||||
// 处理医生账户总表
|
||||
$res = $this->handleDoctorAccount($amount_total,$order_service_package['doctor_id']);
|
||||
@ -215,17 +211,6 @@ class AutoCompleteServicePackageDelayDirectConsumer extends ConsumerMessage
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order_service_package['order_service_status'] == 5){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单已取消" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
if (!in_array($order_service_package['refund_status'],[0,4,5])){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单退款中" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// 订单支付状态
|
||||
if ($order_service_package['pay_status'] != 2){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单未支付" );
|
||||
@ -297,8 +282,6 @@ class AutoCompleteServicePackageDelayDirectConsumer extends ConsumerMessage
|
||||
*/
|
||||
protected function handleDoctorAccount(string|int $amount_total,string|int $doctor_id): bool
|
||||
{
|
||||
$amount_total = bcmul((string)$amount_total,"0.75",8);
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$doctor_account = DoctorAccount::getOne($params);
|
||||
@ -338,8 +321,6 @@ class AutoCompleteServicePackageDelayDirectConsumer extends ConsumerMessage
|
||||
*/
|
||||
protected function handleDoctorAccountDay(string|int $amount_total,string|int $doctor_id,string $start_time): bool
|
||||
{
|
||||
$amount_total = bcmul((string)$amount_total,"0.75",8);
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['date'] = date('Y-m-d', strtotime($start_time));
|
||||
|
||||
@ -93,13 +93,11 @@ class AddServicePackageCompleteQueueCommand extends HyperfCommand
|
||||
$finish_time_params = [$three_day_start_time,$three_day_finish_time];
|
||||
|
||||
$params = array();
|
||||
$params['order_service_status'] = 3; // 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
$params['pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$params['refund_status'] = 0; // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
$params['add_finish_status'] = 0; // 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||||
|
||||
|
||||
$order_service_packages = OrderServicePackage::getInquiryWithFinishTime($params,$finish_time_params);
|
||||
$order_service_status_params = [3,5]; // 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
$order_service_packages = OrderServicePackage::getInquiryWithFinishTime($params,$order_service_status_params,$finish_time_params);
|
||||
if (empty($order_service_packages)){
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -172,12 +172,14 @@ class OrderServicePackage extends Model
|
||||
/**
|
||||
* 获取某一时间段服务包订单-结束时间
|
||||
* @param array $params
|
||||
* @param array $order_service_status_params
|
||||
* @param array $finish_time_params 结束时间区间
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getInquiryWithFinishTime(array $params, array $finish_time_params): Collection|array
|
||||
public static function getInquiryWithFinishTime(array $params, array $order_service_status_params, array $finish_time_params): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereIn('order_service_status',$order_service_status_params)
|
||||
->whereBetween('finish_time', $finish_time_params)
|
||||
->orderBy('finish_time')
|
||||
->get();
|
||||
|
||||
@ -25,6 +25,7 @@ use App\Model\OrderServicePackageCase;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\OrderServicePackageProduct;
|
||||
use App\Model\OrderServicePackageRefund;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\PatientFamilyHealth;
|
||||
use App\Model\PatientFamilyPersonal;
|
||||
@ -1656,4 +1657,92 @@ class OrderServicePackageService extends BaseService
|
||||
|
||||
return $order_service_package->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取服务包退款金额
|
||||
* @param string|int $order_service_no
|
||||
* @return string|int
|
||||
*/
|
||||
public function getServicePackageRefundTotal(string|int $order_service_no): string|int
|
||||
{
|
||||
// 获取退款数据
|
||||
$refund_total = 0;
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $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 = bcadd(
|
||||
(string)$refund_total,
|
||||
(string)$order_service_package_refund['refund_total'],
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $refund_total;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单中医生可分成的问诊金额
|
||||
* @param string|int $order_service_no
|
||||
* @param array|object $order_service_package
|
||||
* @param array|object $order_service_package_detail
|
||||
* @return string
|
||||
*/
|
||||
public function getServicePackageDoctorInquiryAmountTotal(string|int $order_service_no,array|object $order_service_package,array|object $order_service_package_detail): string
|
||||
{
|
||||
// 获取服务包退款金额
|
||||
$refund_total = $this->getServicePackageRefundTotal($order_service_no);
|
||||
|
||||
if ($order_service_package['order_service_type'] == 1){
|
||||
// 健康包
|
||||
// 实际问诊数量
|
||||
$inquiry_count = 0;
|
||||
|
||||
// 获取健康包关联问诊订单
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_package['order_service_no'];
|
||||
$order_service_package_inquirys = OrderServicePackageInquiry::getList($params);
|
||||
foreach ($order_service_package_inquirys as $order_service_package_inquiry){
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_service_package_inquiry['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (!empty($order_inquiry)){
|
||||
if (in_array($order_inquiry['inquiry_status'],[4,5,6])){
|
||||
$inquiry_count = $inquiry_count + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$amount_total = bcmul(
|
||||
(string)$inquiry_count,
|
||||
bcmul(
|
||||
(string)$order_service_package_detail['single_inquiry_price'],
|
||||
"0.75",
|
||||
3),
|
||||
3
|
||||
);
|
||||
}else{
|
||||
// 随访包
|
||||
$amount_total = bcsub(
|
||||
(string)$order_service_package['payment_amount_total'],
|
||||
(string)$refund_total,
|
||||
3
|
||||
);
|
||||
}
|
||||
|
||||
$amount_total = bcmul(
|
||||
(string)$amount_total,
|
||||
"0.75",
|
||||
8
|
||||
);
|
||||
return $amount_total;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user