1.3版本合并dev并解决冲突
This commit is contained in:
commit
e723994064
@ -9,14 +9,18 @@ use App\Amqp\Producer\CancelUnInquiryOrdersDelayDirectProducer;
|
||||
use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\ImService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderService;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Services\UserDoctorService;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\Utils;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
@ -49,184 +53,160 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance('queue-AssignDoctor')->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance('queue-AssignDoctor')->info(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Log::getInstance('queue-AssignDoctor')->error("错误:未查询到对应订单数据");
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
// 检测执行次数并处理分配医生失败情况
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Log::getInstance('queue-AssignDoctor')->error("未查询到对应订单数据");
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
|
||||
// 获取病例数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)){
|
||||
Log::getInstance('queue-AssignDoctor')->error("错误:患者病例错误");
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
// 检测执行次数
|
||||
$Utils = new Utils();
|
||||
$redis_key = "assign_doctor_number_" . $data['order_inquiry_id'];
|
||||
$res = $Utils->checkHandleNumber($redis_key);
|
||||
if (!$res) {
|
||||
Log::getInstance("queue-AssignDoctor")->error("超出最大执行次数或检测错误");
|
||||
|
||||
// 检测订单状态
|
||||
$res = $this->checkInquiryStatus($order_inquiry);
|
||||
if (!$res){
|
||||
Log::getInstance('queue-AssignDoctor')->error("错误:订单状态错误");
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测分配时间
|
||||
$pay_time = strtotime($order_inquiry['pay_time']);
|
||||
$diff_time = time() - $pay_time;
|
||||
if ($diff_time < 0) {
|
||||
Log::getInstance('queue-AssignDoctor')->error("错误:支付时间错误");
|
||||
return Result::DROP;// 销毁
|
||||
Db::commit();
|
||||
return Result::ACK;
|
||||
}else{
|
||||
Db::commit();
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 检测当前是否符合系统问诊时间
|
||||
$inquiryService = new InquiryService();
|
||||
$is_system_time_pass = $inquiryService->checkSystemInquiryTime($order_inquiry['inquiry_type']);
|
||||
if (!$is_system_time_pass && $order_inquiry['inquiry_type'] == 4){
|
||||
// 非坐班时间
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:非坐班时间,执行退款");
|
||||
// 获取病例数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)){
|
||||
Log::getInstance('queue-AssignDoctor')->error("患者病例错误");
|
||||
|
||||
$InquiryService = new InquiryService();
|
||||
|
||||
// 检测问诊订单执行退款次数
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:检测执行退款次数");
|
||||
$res = $InquiryService->checkInquiryRefundCount($order_inquiry['order_inquiry_id']);
|
||||
if (!$res){
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:超出最大退款次数");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:订单退款");
|
||||
$InquiryService->inquiryRefund($order_inquiry['order_inquiry_id'], "无可分配医生");
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:取消问诊订单");
|
||||
$save_data = array();
|
||||
$save_data['inquiry_status'] = 7;
|
||||
$save_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$save_data['cancel_reason'] = 3; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$save_data['cancel_remarks'] = "未分配到合适的医生"; // 取消订单备注
|
||||
$save_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $save_data);
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("成功:已退款");
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
Db::commit();
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
|
||||
try {
|
||||
// 患者-分配医生失败-订阅
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->assignDoctorFail();
|
||||
}catch (\Exception $e){
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:" . $e->getMessage());
|
||||
}
|
||||
// 检测订单状态
|
||||
$res = $this->checkInquiryStatus($order_inquiry);
|
||||
if (!$res){
|
||||
Log::getInstance('queue-AssignDoctor')->error("订单状态错误");
|
||||
|
||||
return Result::ACK;
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
Db::commit();
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
|
||||
// 检测分配时间
|
||||
if ($diff_time > 600) {
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:超出10分钟,执行退款");
|
||||
$diff_time = time() - strtotime($order_inquiry['pay_time']);
|
||||
if ($diff_time < 0) {
|
||||
Log::getInstance('queue-AssignDoctor')->error("支付时间错误");
|
||||
|
||||
$InquiryService = new InquiryService();
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊订单执行退款次数
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:检测执行退款次数");
|
||||
$res = $InquiryService->checkInquiryRefundCount($order_inquiry['order_inquiry_id']);
|
||||
if (!$res){
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:超出最大退款次数");
|
||||
return Result::ACK;
|
||||
}
|
||||
Db::commit();
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:订单退款");
|
||||
$InquiryService->inquiryRefund($order_inquiry['order_inquiry_id'], "未分配到合适的医生");
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:取消问诊订单");
|
||||
$save_data = array();
|
||||
$save_data['inquiry_status'] = 7;
|
||||
$save_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$save_data['cancel_reason'] = 3; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$save_data['cancel_remarks'] = "未分配到合适的医生"; // 取消订单备注
|
||||
$save_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $save_data);
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("成功:已退款");
|
||||
// 检测当前是否符合系统问诊时间-非坐班时间,执行退款
|
||||
$inquiryService = new InquiryService();
|
||||
$is_system_time_pass = $inquiryService->checkSystemInquiryTime($order_inquiry['inquiry_type']);
|
||||
if (!$is_system_time_pass && $order_inquiry['inquiry_type'] == 4){
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
Db::commit();
|
||||
|
||||
try {
|
||||
// 患者-分配医生失败-订阅
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->assignDoctorFail();
|
||||
}catch (\Exception $e){
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:" . $e->getMessage());
|
||||
Log::getInstance("queue-AssignDoctor")->error( $e->getMessage());
|
||||
}
|
||||
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 检测执行次数
|
||||
$res = $this->checkHandleNumber($data['order_inquiry_id']);
|
||||
if (!$res) {
|
||||
// 超出执行次数后,不再进行分配,按照结束分配时间,重新加入队列。
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:超出最大执行次数或检测错误");
|
||||
// 检测分配时间-超出10分钟,执行退款
|
||||
if ($diff_time > 600) {
|
||||
// 处理分配医生失败
|
||||
$this->handleAssignDoctorFail($order_inquiry['inquiry_no']);
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:重新加入延迟队列");
|
||||
Db::commit();
|
||||
|
||||
try {
|
||||
// 患者-分配医生失败-订阅
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->assignDoctorFail();
|
||||
}catch (\Exception $e){
|
||||
Log::getInstance("queue-AssignDoctor")->error($e->getMessage());
|
||||
}
|
||||
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 分配医生
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$doctor_id = $UserDoctorService->getInquiryAssignDoctor($order_inquiry['inquiry_type'],$order_inquiry['patient_id'],$is_system_time_pass);
|
||||
if (empty($doctor_id)){
|
||||
$queue_data = array();
|
||||
$queue_data['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
|
||||
// 5分钟-支付时间-1s:10:00支付 此时10:04 5-(10:04-10:00)
|
||||
$time = 1000 * (300- (time() - $pay_time) - 1);
|
||||
$time = 300- (time() - strtotime($order_inquiry['pay_time'])) - 1;
|
||||
|
||||
$message = new AssignDoctorDelayDirectProducer($queue_data);
|
||||
$message->setDelayMs($time);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:重新加入分配医生队列失败,重回队列");
|
||||
Log::getInstance("queue-AssignDoctor")->error("重新加入分配医生队列失败,重回队列");
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
Log::getInstance("queue-AssignDoctor")->info("结束");
|
||||
Log::getInstance("queue-AssignDoctor")->info("重回队列");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:分配医生");
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$doctor_id = $UserDoctorService->getInquiryAssignDoctor($order_inquiry['inquiry_type'],$order_inquiry['patient_id'],$is_system_time_pass);
|
||||
if (empty($doctor_id)){
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:无合适医生");
|
||||
Db::rollBack();
|
||||
|
||||
Log::getInstance("queue-AssignDoctor")->info("信息:重新加入延迟队列");
|
||||
|
||||
// 获取患者家庭成员是否存在未支付的服务包订单
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$order_service_package = $OrderServicePackageService->getPatientFamilyNoPayServicePackage($order_inquiry['user_id'], $order_inquiry['family_id'], $doctor_id);
|
||||
if (!empty($order_service_package)){
|
||||
$queue_data = array();
|
||||
$queue_data['order_inquiry_id'] = $data['order_inquiry_id'];
|
||||
|
||||
// 5分钟-支付时间-1s:10:00支付 此时10:04 5-(10:04-10:00)
|
||||
$time = 300- (time() - strtotime($order_inquiry['pay_time'])) - 1;
|
||||
|
||||
$message = new AssignDoctorDelayDirectProducer($queue_data);
|
||||
$message->setDelayMs(1000 * 60);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:重新加入分配医生队列失败,重回队列");
|
||||
Log::getInstance("queue-AssignDoctor")->error("患者和医生存在未支付的服务包订单,无法分配给该医生,重回队列");
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
@ -235,6 +215,13 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
}
|
||||
|
||||
// 更改数据库
|
||||
$save_data = array();
|
||||
$save_data['doctor_id'] = $doctor_id;
|
||||
|
||||
$params = array();
|
||||
$params['order_id'] = $order_inquiry['order_id'];
|
||||
Order::edit($params, $save_data);
|
||||
|
||||
$save_data = array();
|
||||
$save_data['doctor_id'] = $doctor_id;
|
||||
$save_data['inquiry_status'] = 3; // 待接诊
|
||||
@ -246,6 +233,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
// 加入未接诊取消订单延迟队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$data['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$message = new CancelUnInquiryOrdersDelayDirectProducer($data);
|
||||
// 快速/购药-5分钟
|
||||
$message->setDelayMs(1000 * 60 * 10);
|
||||
@ -253,7 +241,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:加入未接诊取消订单延迟队列失败");
|
||||
Log::getInstance("queue-AssignDoctor")->error("加入未接诊取消订单延迟队列失败");
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
@ -261,7 +249,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
Log::getInstance("queue-AssignDoctor")->info("成功");
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AssignDoctor")->error("失败:" . $e->getMessage());
|
||||
Log::getInstance("queue-AssignDoctor")->error($e->getMessage());
|
||||
return Result::REQUEUE; // 重回队列
|
||||
}
|
||||
|
||||
@ -272,7 +260,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("queue-AssignDoctor")->error("错误:医生数据错误");
|
||||
Log::getInstance("queue-AssignDoctor")->error("医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -283,7 +271,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
$imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
|
||||
// 医生-医生有新问诊 站内、订阅失败发送短信
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->doctorHaveNewInquiry();
|
||||
|
||||
// 加入xx时间未接诊通知队列
|
||||
@ -296,7 +284,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$producer->produce($message);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AssignDoctor")->error("发送消息异常错误:" . $e->getMessage());
|
||||
Log::getInstance("queue-AssignDoctor")->error($e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -380,4 +368,36 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理分配医生失败
|
||||
* @param string $inquiry_no
|
||||
* @return void
|
||||
*/
|
||||
protected function handleAssignDoctorFail(string $inquiry_no): void
|
||||
{
|
||||
$OrderService = new OrderService();
|
||||
$OrderService->orderRefund($inquiry_no, "无可分配医生");
|
||||
|
||||
// 取消订单
|
||||
$order_data = array();
|
||||
$order_data['cancel_status'] = 1;
|
||||
$order_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$order_data['cancel_remarks'] = "未分配到合适的医生";
|
||||
$order_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $inquiry_no;
|
||||
Order::edit($params, $order_data);
|
||||
|
||||
$save_data = array();
|
||||
$save_data['inquiry_status'] = 7;
|
||||
$save_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$save_data['cancel_reason'] = 3; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$save_data['cancel_remarks'] = "未分配到合适的医生"; // 取消订单备注
|
||||
$save_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $inquiry_no;
|
||||
OrderInquiry::edit($params, $save_data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,6 +73,16 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
||||
return Result::ACK;// 销毁
|
||||
}
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("分配药师队列执行结束:缺少问诊订单数据");
|
||||
return Result::ACK;// 销毁
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 分配药师
|
||||
@ -84,7 +94,7 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
||||
Log::getInstance()->error("分配药师队列执行失败:药师数据错误");
|
||||
|
||||
// 分配失败,按照驳回处理
|
||||
$this->reject($data['order_prescription_id'], $user_doctor['user_id'], $user_patient['user_id'], $order_prescription['order_inquiry_id']);
|
||||
$this->reject($data['order_prescription_id'], $user_doctor['user_id'], $user_patient['user_id'], $order_inquiry['inquiry_no']);
|
||||
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
@ -103,7 +113,7 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
||||
Log::getInstance()->error("分配药师队列执行失败原因:" . $e->getMessage());
|
||||
|
||||
// 分配失败,按照驳回处理
|
||||
$this->reject($data['order_prescription_id'], $user_doctor['user_id'],$user_patient['user_id'], $order_prescription['order_inquiry_id']);
|
||||
$this->reject($data['order_prescription_id'], $user_doctor['user_id'],$user_patient['user_id'], $order_inquiry['inquiry_no']);
|
||||
|
||||
return Result::DROP; // 重回队列
|
||||
}
|
||||
@ -118,12 +128,10 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
||||
* @param string $order_prescription_id
|
||||
* @param string $doctor_user_id
|
||||
* @param string $patient_user_id
|
||||
* @param string $order_inquiry_id
|
||||
* @param string $inquiry_no
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function reject(string $order_prescription_id, string $doctor_user_id, string $patient_user_id, string $order_inquiry_id): void
|
||||
public function reject(string $order_prescription_id, string $doctor_user_id, string $patient_user_id, string $inquiry_no): void
|
||||
{
|
||||
try {
|
||||
$params = array();
|
||||
@ -137,11 +145,11 @@ class AssignPharmacistConsumer extends ConsumerMessage
|
||||
OrderPrescription::edit($params, $data);
|
||||
|
||||
// 医生-开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($doctor_user_id, $order_inquiry_id);
|
||||
$MessagePush = new MessagePush($doctor_user_id, $inquiry_no);
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription_id);
|
||||
|
||||
// 患者-处方审核未通过
|
||||
$MessagePush = new MessagePush($patient_user_id, $order_inquiry_id);
|
||||
$MessagePush = new MessagePush($patient_user_id, $inquiry_no);
|
||||
$MessagePush->patientPrescriptionVerifyFail();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
@ -181,7 +181,7 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
if (isset($is_push_prescription_verify_fail)){
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$order_prescription_id = $order_prescription_id ?? "";
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription_id);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
$imService->inquiryEndEvaluation($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
|
||||
// 医生-发送站内消息-问诊结束
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->finishInquiryToDoctor();
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AutoCompleteInquiry")->error($e->getMessage());
|
||||
|
||||
@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Amqp\Producer\AutoCompleteServicePackageDelayDirectProducer;
|
||||
use App\Model\DoctorAccount;
|
||||
use App\Model\DoctorAccountDay;
|
||||
use App\Model\OrderServicePackage;
|
||||
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;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
/**
|
||||
* 自动完成服务包订单
|
||||
* 延迟队列
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
class AutoCompleteServicePackageDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'auto.complete.service.package.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'AutoCompleteServicePackage';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->info(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
try {
|
||||
// 检测执行次数
|
||||
$Utils = new Utils();
|
||||
$redis_key = "CompleteServicePackage" . $data['order_no'];
|
||||
$res = $Utils->checkHandleNumber($redis_key);
|
||||
if (!$res) {
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("超出最大执行次数或检测错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
try {
|
||||
// 检测入参参数
|
||||
$res = $this->detectInputParameters($data);
|
||||
if (!$res){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("入参错误" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $data['order_no'];
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单错误" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
$res = $this->detectOrderStatus($order_service_package);
|
||||
if (!$res){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单状态错误" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 检测订单结束时间
|
||||
$res = $this->detectOrderFinishTime($order_service_package);
|
||||
if (!$res){
|
||||
// 未到结束时间,重新加入队列
|
||||
$res = $this->addQueue($order_service_package);
|
||||
if (!$res){
|
||||
// 重新添加队列失败
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 获取订单详情数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $data['order_no'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (empty($order_service_package_detail)){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单详情错误" );
|
||||
return Result::ACK;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
// 处理业务
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 处理服务包订单为已完成
|
||||
$data = array();
|
||||
$data['order_service_status'] = 4;// 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
OrderServicePackage::edit($params,$data);
|
||||
|
||||
// 处理统计问题
|
||||
// 获取服务包订单中医生可分成的问诊金额
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$amount_total = $OrderServicePackageService->getServicePackageDoctorInquiryAmountTotal($order_service_package['order_service_no'],$order_service_package,$order_service_package_detail);
|
||||
|
||||
if ($amount_total > 0){
|
||||
// 处理医生账户总表
|
||||
$res = $this->handleDoctorAccount($amount_total,$order_service_package['doctor_id']);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
// 处理医生账户表-日
|
||||
$res = $this->handleDoctorAccountDay($amount_total,$order_service_package['doctor_id'],$order_service_package['start_time']);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
// 发送消息
|
||||
try {
|
||||
// 获取订单医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_service_package['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 医生-通知医生患者的服务包服务结束
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_service_package['order_service_no']);
|
||||
$MessagePush->doctorServicePackageFinish();
|
||||
|
||||
// 患者-通知患者服务包服务已结束
|
||||
$MessagePush = new MessagePush($order_service_package['user_id'], $order_service_package['order_service_no']);
|
||||
$MessagePush->patientServicePackageFinish();
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error($e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测入参参数
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function detectInputParameters(array $data): bool
|
||||
{
|
||||
if (empty($data['order_no'])){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测订单状态
|
||||
* @param array|object $order_service_package
|
||||
* @return bool
|
||||
*/
|
||||
public function detectOrderStatus(array|object $order_service_package): bool
|
||||
{
|
||||
if ($order_service_package['order_service_status'] == 1){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单未支付" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order_service_package['order_service_status'] == 2){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单未开始" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($order_service_package['order_service_status'] == 4){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单已完成" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// 订单支付状态
|
||||
if ($order_service_package['pay_status'] != 2){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error("订单未支付" );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测订单结束时间
|
||||
* @param array|object $order_service_package
|
||||
* @return bool
|
||||
*/
|
||||
public function detectOrderFinishTime(array|object $order_service_package): bool
|
||||
{
|
||||
$finish_time = strtotime($order_service_package['finish_time']);
|
||||
|
||||
$diff_time = time() - $finish_time;
|
||||
|
||||
if ($diff_time < 0 && ($diff_time > -7200)){
|
||||
// 负数,表示还未到完成时间。重新加入队列
|
||||
return false;
|
||||
}
|
||||
|
||||
// 正数,已到或已超完成时间。可以取消。
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新加入队列
|
||||
* @param array|object $order_service_package
|
||||
* @return bool
|
||||
*/
|
||||
public function addQueue(array|object $order_service_package): bool
|
||||
{
|
||||
try {
|
||||
$finish_time = strtotime($order_service_package['finish_time']);
|
||||
|
||||
// 结束时间大于当前时间
|
||||
if ($finish_time > time()){
|
||||
$time = $finish_time - time();
|
||||
|
||||
$queue_data = array();
|
||||
$queue_data['order_no'] = $order_service_package['order_service_no'];
|
||||
|
||||
$message = new AutoCompleteServicePackageDelayDirectProducer($queue_data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-AutoCompleteServicePackage")->error($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理医生账户总表
|
||||
* 创建/修改医生账户总表中总金额、账户余额数据
|
||||
* @param string|int $amount_total
|
||||
* @param string|int $doctor_id
|
||||
* @return bool
|
||||
*/
|
||||
protected function handleDoctorAccount(string|int $amount_total,string|int $doctor_id): bool
|
||||
{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$doctor_account = DoctorAccount::getOne($params);
|
||||
if (empty($doctor_account)) {
|
||||
// 首次
|
||||
$data = array();
|
||||
$data['doctor_id'] = $doctor_id;
|
||||
$data['total_amount'] = $amount_total;
|
||||
$data['balance_account'] = $amount_total;
|
||||
$data['applied_withdrawal_amount'] = 0;
|
||||
$data['actual_withdrawal_amount'] = 0;
|
||||
$data['income_tax'] = 0;
|
||||
$doctor_account = DoctorAccount::addDoctorAccount($data);
|
||||
if (empty($doctor_account)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// 非首次
|
||||
// 总金额(已结束订单的总金额)
|
||||
$params = array();
|
||||
$params['account_id'] = $doctor_account['account_id'];
|
||||
DoctorAccount::inc($params, 'total_amount', (float)$amount_total);
|
||||
|
||||
// 账户余额
|
||||
DoctorAccount::inc($params, 'balance_account', (float)$amount_total);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理医生账户表-日
|
||||
* @param string|int $amount_total
|
||||
* @param string|int $doctor_id
|
||||
* @param string $start_time
|
||||
* @return bool
|
||||
*/
|
||||
protected function handleDoctorAccountDay(string|int $amount_total,string|int $doctor_id,string $start_time): bool
|
||||
{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['date'] = date('Y-m-d', strtotime($start_time));
|
||||
$doctor_account_day = DoctorAccountDay::getOne($params);
|
||||
if (empty($doctor_account_day)) {
|
||||
// 当日首次
|
||||
$data = array();
|
||||
$data['doctor_id'] = $doctor_id;
|
||||
$data['year'] = date('Y', strtotime($start_time));
|
||||
$data['month'] = date('m', strtotime($start_time));
|
||||
$data['day'] = date('d', strtotime($start_time));
|
||||
$data['date'] = date('Y-m-d', strtotime($start_time));
|
||||
$data['total_amount'] = $amount_total;
|
||||
$doctor_account_day = DoctorAccountDay::addDoctorAccountDay($data);
|
||||
if (empty($doctor_account_day)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// 非当日首次
|
||||
$params = array();
|
||||
$params['account_detail_id'] = $doctor_account_day['account_detail_id'];
|
||||
DoctorAccountDay::inc($params, 'total_amount', (float)$amount_total);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -152,18 +152,18 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
||||
$this->modifyOrderPrescription($data['order_prescription_id'], 2, "请联系平台客服,请勿重开处方");
|
||||
|
||||
// 医生-开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_prescription['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['inquiry_no']);
|
||||
$MessagePush->prescriptionVerifyFail($data['order_prescription_id']);
|
||||
|
||||
// 患者-处方审核未通过
|
||||
$MessagePush = new MessagePush($user_patient['user_id'], $order_prescription['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_patient['user_id'], $order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientPrescriptionVerifyFail();
|
||||
Db::commit();
|
||||
|
||||
return Result::ACK;
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage());
|
||||
Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
@ -274,12 +274,12 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage
|
||||
$imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$data['order_prescription_id'],7);
|
||||
|
||||
// 发送站内、短信消息-患者的处方被药师审核通过
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientPrescriptionVerifyPass();
|
||||
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核通过
|
||||
// 发送目标不同,重新实例化
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->prescriptionVerifySuccess();
|
||||
|
||||
// 添加处方过期队列
|
||||
|
||||
@ -5,14 +5,20 @@ declare(strict_types=1);
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\ImService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderService;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\Utils;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
@ -46,12 +52,24 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
* @param $data
|
||||
* @param AMQPMessage $message
|
||||
* @return string
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->error("开始执行 取消未接诊问诊订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
try {
|
||||
// 检测执行次数
|
||||
$Utils = new Utils();
|
||||
$redis_key = "orderRefund" . $data['order_inquiry_id'];
|
||||
$res = $Utils->checkHandleNumber($redis_key);
|
||||
if (!$res) {
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("超出最大执行次数或检测错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
@ -62,7 +80,7 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:未找到对应问诊订单" );
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("未找到对应问诊订单" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -70,66 +88,119 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
if ($order_inquiry['inquiry_status'] == 7) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:订单已取消" );
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("订单已取消" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 4) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:订单已接诊" );
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("订单已接诊" );
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] != 3) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:订单状态非待接诊" );
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("订单状态非待接诊" );
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:订单正在退款中" );
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("订单正在退款中" );
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
$order_data = array();
|
||||
$order_data['cancel_status'] = 1;
|
||||
$order_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$order_data['cancel_remarks'] = "医生未接诊";
|
||||
$order_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_id'] = $order_inquiry['order_id'];
|
||||
Order::edit($params, $order_data);
|
||||
|
||||
// 取消问诊订单
|
||||
$save_data = array();
|
||||
$save_data['inquiry_status'] = 7;
|
||||
$save_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$save_data['cancel_reason'] = 1; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$save_data['cancel_remarks'] = "医生未接诊"; // 取消订单备注
|
||||
$save_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
$order_inquiry_data = array();
|
||||
$order_inquiry_data['inquiry_status'] = 7;
|
||||
$order_inquiry_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$order_inquiry_data['cancel_reason'] = 1; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$order_inquiry_data['cancel_remarks'] = "医生未接诊"; // 取消订单备注
|
||||
$order_inquiry_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $save_data);
|
||||
OrderInquiry::edit($params, $order_inquiry_data);
|
||||
|
||||
// 订单退款
|
||||
if ($order_inquiry['inquiry_pay_status'] == 2) {
|
||||
// 检测问诊订单执行退款次数
|
||||
$InquiryService = new InquiryService();
|
||||
$res = $InquiryService->checkInquiryRefundCount($order_inquiry['order_inquiry_id']);
|
||||
if (!$res){
|
||||
$redis_key = "orderRefund" . $order_inquiry['inquiry_no'];
|
||||
$res = $Utils->checkHandleNumber($redis_key);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:超出最大退款次数");
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("超出最大退款次数");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
$InquiryService->inquiryRefund($order_inquiry['order_inquiry_id'], "医生未接诊");
|
||||
$OrderService = new OrderService();
|
||||
$OrderService->orderRefund($order_inquiry['inquiry_no'], "医生未接诊");
|
||||
}
|
||||
|
||||
// 服务包问诊订单处理
|
||||
if ($order_inquiry['inquiry_type'] == 1){
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
// 取消订单
|
||||
$order_data = array();
|
||||
$order_data['cancel_status'] = 1;
|
||||
$order_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = 1; // 取消订单原因(1:医生未接受服务 2:主动取消 4:客服取消 5:支付超时)
|
||||
$order_data['cancel_remarks'] = "医生72小时内未接受服务,已进行退款处理,请注意查看账户信息。";
|
||||
$order_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $order_service_no;
|
||||
Order::edit($params, $order_data);
|
||||
|
||||
// 取消服务包订单
|
||||
$order_service_package_data = array();
|
||||
$order_service_package_data['order_service_status'] = 5;
|
||||
$order_service_package_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$order_service_package_data['cancel_remarks'] = "医生72小时内未接受服务,已进行退款处理,请注意查看账户信息。"; // 取消订单备注
|
||||
$order_service_package_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_no;
|
||||
OrderServicePackage::edit($params, $order_service_package_data);
|
||||
|
||||
// 如果是服务包的首单问诊订单即执行服务包退款
|
||||
$OrderService = new OrderService();
|
||||
$OrderService->orderRefund($order_service_no, "医生72小时内未接受服务,已进行退款处理,请注意查看账户信息。");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("取消未接诊问诊订单失败:" . $e->getMessage());
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
Log::getInstance()->info("取消未接诊问诊订单成功");
|
||||
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息");
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("取消未接诊问诊订单成功");
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("开始发送IM消息");
|
||||
|
||||
try {
|
||||
// 获取订单医生数据
|
||||
@ -137,7 +208,7 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息失败:医生数据错误");
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->error("医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -148,12 +219,32 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
// 发送IM消息-问诊退款
|
||||
$imService->inquiryRefund($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
|
||||
// 发送站内、订阅消息-患者-医生未接诊
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->patientNoInquiry();
|
||||
// 处理服务包情况
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9) {
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
// 患者-医生未接受服务包订单
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientDoctorNoAcceptServicePackage();
|
||||
}else{
|
||||
// 发送站内、订阅消息-患者-医生未接诊
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientNoInquiry();
|
||||
}
|
||||
}else{
|
||||
// 发送站内、订阅消息-患者-医生未接诊
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientNoInquiry();
|
||||
}
|
||||
|
||||
// 发送站内、订阅消息-医生-超时未接诊
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->doctorNoInquiry();
|
||||
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
@ -163,15 +254,15 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
$order_inquiry_coupon = OrderInquiryCoupon::getOne($params);
|
||||
if (!empty($order_inquiry_coupon)){
|
||||
// 发送站内消息-优惠卷退还
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']);
|
||||
}
|
||||
}
|
||||
|
||||
Log::getInstance()->info("取消未接诊问诊订单成功,发送消息成功");
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("发送IM消息成功");
|
||||
} catch (\Exception $e) {
|
||||
// 验证失败
|
||||
Log::getInstance()->error("取消未接诊问诊订单成功,发送消息失败:" . $e->getMessage());
|
||||
Log::getInstance("queue-CancelUnInquiryOrders")->info("发送IM消息失败:" . $e->getMessage());
|
||||
}
|
||||
|
||||
return Result::ACK;
|
||||
|
||||
@ -16,13 +16,16 @@ use App\Model\UserCoupon;
|
||||
use App\Services\DetectionService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\OrderProductService;
|
||||
use App\Services\OrderService;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\Utils;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
@ -49,49 +52,57 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
try {
|
||||
$Utils = new Utils();
|
||||
$redis_key = "cancelUnpayOrders" . $data['order_no'];
|
||||
$res = $Utils->checkHandleNumber($redis_key);
|
||||
if (!$res) {
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("超出最大执行次数或检测错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error($e->getMessage());
|
||||
return Result::REQUEUE;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
if ($data['order_type'] == 1) {
|
||||
// 问诊订单取消
|
||||
$InquiryService = new InquiryService();
|
||||
$result = $InquiryService->cancelUnpayInquiryOrder($data['order_no'], 5, "支付超时");
|
||||
$OrderService = new OrderService();
|
||||
|
||||
if ($data['order_type'] == 1) {
|
||||
// 问诊订单
|
||||
$result = $OrderService->cancelUnpayOrder($data['order_no'],5,"支付超时");
|
||||
} elseif ($data['order_type'] == 2) {
|
||||
// 药品订单取消
|
||||
$OrderProductService = new OrderProductService();
|
||||
$result = $OrderProductService->cancelUnpayProductOrder($data['order_no'], 3, "支付超时");
|
||||
|
||||
// 药品订单
|
||||
$result = $OrderService->cancelUnpayOrder($data['order_no'],3,"支付超时");
|
||||
} elseif ($data['order_type'] == 3) {
|
||||
// 检测订单取消
|
||||
$DetectionService = new DetectionService();
|
||||
$result = $DetectionService->cancelUnpayDetectionOrder($data['order_no'], 3, "支付超时");
|
||||
// 检测订单
|
||||
$result = $OrderService->cancelUnpayOrder($data['order_no'],3,"支付超时");
|
||||
} elseif ($data['order_type'] == 4) {
|
||||
// 服务包订单
|
||||
$result = $OrderService->cancelUnpayOrder($data['order_no'],3,"支付超时");
|
||||
} else {
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单失败:order_type类型错误");
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("order_type类型错误");
|
||||
return Result::DROP;// 销毁
|
||||
}
|
||||
|
||||
if ($result['status'] == 0) {
|
||||
if ($result['status'] != 1) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单失败:" . $result['message']);
|
||||
return Result::DROP;// 销毁
|
||||
} elseif ($result['status'] == 2) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info("取消未支付订单成功:" . $result['message']);
|
||||
return Result::ACK;// 销毁
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error($result['message']);
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info("取消未支付订单 队列执行成功");
|
||||
Log::getInstance("queue-CancelUnpayOrders")->info("成功");
|
||||
return Result::ACK;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单执行失败:" . $e->getMessage());
|
||||
Log::getInstance("queue-CancelUnpayOrders")->error($e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\DetectionCompleteDelayDirectProducer;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionCase;
|
||||
use App\Model\OrderInquiry;
|
||||
@ -150,8 +151,29 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
|
||||
try {
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $order_detection['user_id'];
|
||||
$data['patient_id'] = $order_detection['patient_id'];
|
||||
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||
$data['order_type'] = 1; // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
$data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||
$data['pay_status'] = 2; // 1:待支付
|
||||
$data['order_no'] = "I" . $generator->generate(); // 订单编号
|
||||
$data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号
|
||||
$data['amount_total'] = 0; // 订单金额
|
||||
$data['coupon_amount_total'] = 0; // 优惠卷总金额
|
||||
$data['payment_amount_total'] = 0; // 实际付款金额
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("queue-DetectionComplete")->error("问诊订单创建失败");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
// 创建问诊订单
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['user_id'] = $order_detection['user_id'];
|
||||
$data['patient_id'] = $order_detection['patient_id'];
|
||||
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||
@ -161,8 +183,8 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
|
||||
$data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
$data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||
$data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号
|
||||
$data['inquiry_no'] = $order['order_no'];// 订单编号
|
||||
$data['escrow_trade_no'] = $order['escrow_trade_no']; // 第三方支付流水号
|
||||
$data['amount_total'] = 0;// 订单金额
|
||||
$data['coupon_amount_total'] = 0;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = 0;// 实际付款金额
|
||||
|
||||
@ -7,6 +7,7 @@ namespace App\Amqp\Consumer;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
@ -36,7 +37,7 @@ class DoctorNotYetInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->info(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!isset($data['order_inquiry_id'])){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("缺少参数");
|
||||
@ -65,13 +66,30 @@ class DoctorNotYetInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("医生数据错误");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
// 发送站内、订阅消息-医生-超时未接诊
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->doctorNotYetInquiry();
|
||||
// 处理服务包情况
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
// 医生-医生xx时间后还未接受服务包订单
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->doctorNotYetOrderServicePackage();
|
||||
}
|
||||
}else{
|
||||
// 发送站内、订阅消息-医生-超时未接诊
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->doctorNotYetInquiry();
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error("失败:" . $e->getMessage());
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->error($e->getMessage());
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ class SendStationMessageConsumer extends ConsumerMessage
|
||||
$cloud_custom_data['order_inquiry_id'] = "";
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $data['inquiry_type'] ?? "";
|
||||
$cloud_custom_data['inquiry_mode'] = $data['inquiry_mode'] ?? "";
|
||||
$cloud_custom_data['message_rounds'] = 0;
|
||||
$cloud_custom_data['patient_family_data'] = [];
|
||||
|
||||
|
||||
@ -75,12 +75,15 @@ class UserCouponExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
try {
|
||||
// 处理未过期事件
|
||||
// 先删除-重新添加队列
|
||||
if ($valid_end_time > time()){
|
||||
$time = $valid_end_time - time();
|
||||
if ($time > 0){
|
||||
$time = $valid_end_time - time();
|
||||
if ($time <= 0){
|
||||
$time = 60 * 5;
|
||||
}
|
||||
|
||||
$queue_data = array();
|
||||
$queue_data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$message = new UserCouponExpiredDelayDirectProducer($queue_data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
|
||||
@ -34,7 +34,7 @@ class UserImOffDelayDirectConsumer extends ConsumerMessage
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-UserImOff")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
// Log::getInstance("queue-UserImOff")->info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
// 检测参数
|
||||
if (!isset($data['user_id'])){
|
||||
@ -47,14 +47,14 @@ class UserImOffDelayDirectConsumer extends ConsumerMessage
|
||||
$params['user_id'] = $data['user_id'];
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
Log::getInstance("queue-UserImOff")->error("无该用户");
|
||||
// Log::getInstance("queue-UserImOff")->error("无该用户");
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
try {
|
||||
// 检测用户状态
|
||||
if ($user['is_online'] == 0){
|
||||
Log::getInstance("queue-UserImOff")->info("用户目前已下线,无需处理");
|
||||
// Log::getInstance("queue-UserImOff")->info("用户目前已下线,无需处理");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ class UserImOffDelayDirectConsumer extends ConsumerMessage
|
||||
$diff_time = time() - $im_login_at;
|
||||
if ($diff_time <= (30 * 60 + 10)){
|
||||
// if ($diff_time <= (2 * 50)){
|
||||
Log::getInstance("queue-UserImOff")->info("用户刚上线未满30分钟,无需处理");
|
||||
// Log::getInstance("queue-UserImOff")->info("用户刚上线未满30分钟,无需处理");
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class UserImOffDelayDirectConsumer extends ConsumerMessage
|
||||
return Result::DROP;
|
||||
}
|
||||
|
||||
Log::getInstance("queue-UserImOff")->info("结束:" . $user['user_name'] . "已下线");
|
||||
// Log::getInstance("queue-UserImOff")->info("结束:" . $user['user_name'] . "已下线");
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 自动完成服务包订单
|
||||
* 延迟队列
|
||||
*/
|
||||
#[Producer]
|
||||
class AutoCompleteServicePackageDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'AutoCompleteServicePackage';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
|
||||
}
|
||||
129
app/Command/AddServicePackageCompleteQueueCommand.php
Normal file
129
app/Command/AddServicePackageCompleteQueueCommand.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Amqp\Producer\AutoCompleteServicePackageDelayDirectProducer;
|
||||
use App\Model\OrderServicePackage;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class AddServicePackageCompleteQueueCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
date_default_timezone_set('Asia/Shanghai');
|
||||
parent::__construct('addServicePackageFinishQueue');
|
||||
}
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('添加快结束服务包订单至服务包结束队列');
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->line('开始');
|
||||
|
||||
try {
|
||||
// 获取需执行的订单
|
||||
$order_service_packages = $this->getExecOrder();
|
||||
if (empty($order_service_packages)){
|
||||
$this->line("结束,无订单可执行");
|
||||
return;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_service_packages as $order_service_package){
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 修改订单成功执行
|
||||
$this->putAddFinishStatus($order_service_package['order_service_id'],1);
|
||||
|
||||
// 添加服务包订单完成延迟队列
|
||||
$finish_time = strtotime($order_service_package['finish_time']);
|
||||
$time = $finish_time - time();
|
||||
|
||||
if (\Hyperf\Config\config('app_env') == "dev"){
|
||||
$time = 5;
|
||||
}
|
||||
|
||||
$queue_data = array();
|
||||
$queue_data['order_no'] = $order_service_package['order_service_no'];
|
||||
|
||||
$message = new AutoCompleteServicePackageDelayDirectProducer($queue_data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
$this->line("添加队列失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
// 修改订单执行失败
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
$this->putAddFinishStatus($order_service_package['order_service_id'],2,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->line("全部结束");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需执行的订单
|
||||
* @return array
|
||||
*/
|
||||
public function getExecOrder(): array
|
||||
{
|
||||
// 获取三天后结束时间
|
||||
$three_day_start_time = date('Y-m-d 00:00:00',strtotime('+3 days', strtotime(date('Y-m-d',time()))));
|
||||
$three_day_finish_time = date('Y-m-d 23:59:59',strtotime('+3 days', strtotime(date('Y-m-d',time()))));
|
||||
$finish_time_params = [$three_day_start_time,$three_day_finish_time];
|
||||
|
||||
$params = array();
|
||||
$params['pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$params['add_finish_status'] = 0; // 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||||
|
||||
$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 [];
|
||||
}
|
||||
|
||||
return $order_service_packages->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单状态
|
||||
* @param string $order_service_id
|
||||
* @param int $add_finish_status
|
||||
* @param string $add_finish_fail_reason
|
||||
* @return void
|
||||
*/
|
||||
public function putAddFinishStatus(string $order_service_id,int $add_finish_status,string $add_finish_fail_reason = ""): void
|
||||
{
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_id;
|
||||
|
||||
$data = array();
|
||||
$data['add_finish_status'] = $add_finish_status;
|
||||
$data['add_finish_time'] = date('Y-m-d H:i:s',time());
|
||||
if (!empty($add_finish_fail_reason)){
|
||||
$data['add_finish_fail_reason'] = $add_finish_fail_reason;
|
||||
}
|
||||
|
||||
OrderServicePackage::edit($params,$data);
|
||||
}
|
||||
}
|
||||
163
app/Command/AddUserCouponExpiredQueueCommand.php
Normal file
163
app/Command/AddUserCouponExpiredQueueCommand.php
Normal file
@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer;
|
||||
use App\Amqp\Producer\UserCouponExpiredNoticeDelayDirectProducer;
|
||||
use App\Model\UserCoupon;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 扫描即将过期优惠卷,添加至优惠卷过期队列
|
||||
*/
|
||||
#[Command]
|
||||
class AddUserCouponExpiredQueueCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('AddUserCouponExpiredQueue:command');
|
||||
}
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('添加即将过期优惠卷添加至优惠卷过期队列');
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->line('开始');
|
||||
|
||||
try {
|
||||
// 获取需执行的用户优惠卷
|
||||
$user_coupons = $this->getExecUserCoupon();
|
||||
if (empty($user_coupons)){
|
||||
$this->line("结束,无优惠卷可执行");
|
||||
return;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($user_coupons as $user_coupon){
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 添加优惠卷过期队列
|
||||
$valid_end_time = strtotime($user_coupon['valid_end_time']);
|
||||
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$time = $valid_end_time - time();
|
||||
if ($time < 0){
|
||||
$time = 60 * 5;
|
||||
}
|
||||
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
$this->line("添加队列失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
// 修改优惠卷执行失败
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取需执行提醒的用户优惠卷
|
||||
$user_coupons = $this->getExecNoticeUserCoupon();
|
||||
if (empty($user_coupons)){
|
||||
$this->line("结束,无可执行需要提醒的优惠卷");
|
||||
return;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($user_coupons as $user_coupon){
|
||||
try {
|
||||
// 添加优惠卷过期队列
|
||||
$valid_end_time = strtotime($user_coupon['valid_end_time']);
|
||||
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$time = $valid_end_time - time();
|
||||
if ($time < 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
$message = new UserCouponExpiredNoticeDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
$this->line("添加提醒队列失败");
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
// 修改优惠卷执行失败
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需执行的用户优惠卷
|
||||
* @return array
|
||||
*/
|
||||
public function getExecUserCoupon(): array
|
||||
{
|
||||
// 过期使用时间
|
||||
$valid_end_time_1 = date('Y-m-d 00:00:00',time());
|
||||
$valid_end_time_2 = date('Y-m-d 23:59:59',time());
|
||||
$valid_end_time = [$valid_end_time_1,$valid_end_time_2];
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_status'] = 0;
|
||||
|
||||
$user_coupons = UserCoupon::getUserTodayExpiredCoupon($params,$valid_end_time);
|
||||
if (empty($user_coupons)){
|
||||
return [];
|
||||
}
|
||||
|
||||
return $user_coupons->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需执行提醒的用户优惠卷
|
||||
* @return array
|
||||
*/
|
||||
public function getExecNoticeUserCoupon(): array
|
||||
{
|
||||
// 获取三天后时间
|
||||
$start_time = date('Y-m-d 00:00:00', strtotime(" +3 days")); // 当月第一天的开始时间
|
||||
$end_time = date('Y-m-d 23:59:59', strtotime(" +3 days")); // 从开始时间起的指定天数后的结束时间
|
||||
|
||||
$valid_end_time = [$start_time,$end_time];
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_status'] = 0;
|
||||
|
||||
$user_coupons = UserCoupon::getUserTodayExpiredCoupon($params,$valid_end_time);
|
||||
if (empty($user_coupons)){
|
||||
return [];
|
||||
}
|
||||
|
||||
return $user_coupons->toArray();
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,9 @@ use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 发放优惠卷
|
||||
*/
|
||||
#[Command]
|
||||
class GrantUserCouponCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
634
app/Command/MoveOrderCommand.php
Normal file
634
app/Command/MoveOrderCommand.php
Normal file
@ -0,0 +1,634 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\DoctorWithdrawalOrder;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderCoupon;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionRefund;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\OrderProductCoupon;
|
||||
use App\Model\OrderProductRefund;
|
||||
use App\Model\OrderRefund;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 迁移订单 v1.3使用
|
||||
*/
|
||||
#[Command]
|
||||
class MoveOrderCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('MoveOrder:command');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('迁移历史订单');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->line("开始");
|
||||
|
||||
// 处理问诊订单
|
||||
$this->handleOrderInquiry();
|
||||
|
||||
// 处理问诊订单退款
|
||||
$this->handleOrderInquiryRefund();
|
||||
|
||||
// 处理问诊订单优惠卷
|
||||
$this->handleOrderInquiryCoupon();
|
||||
|
||||
// 处理药品订单
|
||||
$this->handleOrderProduct();
|
||||
|
||||
// 处理药品订单退款
|
||||
$this->handleOrderProductRefund();
|
||||
|
||||
// 处理药品订单优惠卷
|
||||
$this->handleOrderProductCoupon();
|
||||
|
||||
// 处理检测订单
|
||||
$this->handleOrderDetection();
|
||||
|
||||
// 处理检测订单退款
|
||||
$this->handleOrderDetectionRefund();
|
||||
|
||||
// 修正医生提现关联订单表数据
|
||||
$this->handleDoctorWithdrawalOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理问诊订单
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderInquiry(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_inquirys = OrderInquiry::getList($params);
|
||||
if (empty($order_inquirys)){
|
||||
$this->line("无问诊订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_inquirys as $order_inquiry){
|
||||
if (!empty($order_inquiry['order_id'])){
|
||||
// 已存在订单id,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (!empty($order)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $order_inquiry['user_id'];
|
||||
$data['patient_id'] = $order_inquiry['patient_id'];
|
||||
if (!empty($order_inquiry['doctor_id'])){
|
||||
$data['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
}
|
||||
$data['order_type'] = 1;
|
||||
$data['is_delete'] = $order_inquiry['is_delete']; // 删除状态(0:否 1:是)
|
||||
$data['pay_channel'] = $order_inquiry['inquiry_pay_channel'];
|
||||
$data['pay_status'] = $order_inquiry['inquiry_pay_status'];
|
||||
$data['pay_time'] = $order_inquiry['pay_time'];
|
||||
$data['refund_status'] = $order_inquiry['inquiry_refund_status'];
|
||||
$data['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$data['escrow_trade_no'] = $order_inquiry['escrow_trade_no'];
|
||||
$data['amount_total'] = $order_inquiry['amount_total'];
|
||||
$data['coupon_amount_total'] = $order_inquiry['coupon_amount_total'];
|
||||
$data['payment_amount_total'] = $order_inquiry['payment_amount_total'];
|
||||
if ($order_inquiry['inquiry_status'] == 7){
|
||||
$data['cancel_status'] = 1;
|
||||
}
|
||||
$data['cancel_time'] = $order_inquiry['cancel_time'];
|
||||
if (!empty($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);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加问诊订单失败");
|
||||
}
|
||||
|
||||
// 修改问诊订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $order['order_no'];
|
||||
OrderInquiry::edit($params,$data);
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理问诊订单退款
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderInquiryRefund(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_inquiry_refunds = OrderInquiryRefund::getList($params);
|
||||
if (empty($order_inquiry_refunds)){
|
||||
$this->line("无问诊退款订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_inquiry_refunds as $order_inquiry_refund){
|
||||
$params = array();
|
||||
$params['order_no'] = $order_inquiry_refund['inquiry_no'];
|
||||
$order_refund = OrderRefund::getOne($params);
|
||||
if (!empty($order_refund)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_inquiry_refund['inquiry_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
// 已存在订单,跳过
|
||||
$this->line("无对应订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['patient_id'] = $order_inquiry_refund['patient_id'];
|
||||
$data['order_no'] = $order['order_no'];
|
||||
$data['refund_no'] = $order_inquiry_refund['inquiry_refund_no'];
|
||||
$data['refund_id'] = $order_inquiry_refund['refund_id'];
|
||||
$data['refund_status'] = $order_inquiry_refund['inquiry_refund_status'];
|
||||
$data['refund_total'] = $order_inquiry_refund['refund_total'];
|
||||
$data['refund_reason'] = $order_inquiry_refund['refund_reason'];
|
||||
$data['success_time'] = $order_inquiry_refund['success_time'];
|
||||
$order_refund = OrderRefund::addOrderRefund($data);
|
||||
if (empty($order_refund)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加问诊退款订单失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理问诊订单优惠卷
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderInquiryCoupon(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_inquiry_coupons = OrderInquiryCoupon::getList($params);
|
||||
if (empty($order_inquiry_coupons)){
|
||||
$this->line("无问诊订单优惠卷需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_inquiry_coupons as $order_inquiry_coupon){
|
||||
// 获取问诊订单详情
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_coupon['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
$this->line("问诊订单数据错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_inquiry['inquiry_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
$this->line("无对应订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
|
||||
$data['coupon_name'] = $order_inquiry_coupon['coupon_name'];
|
||||
$data['coupon_use_price'] = $order_inquiry_coupon['coupon_use_price'];
|
||||
$order_coupon = OrderCoupon::addOrderCoupon($data);
|
||||
if (empty($order_coupon)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加问诊订单优惠卷失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理药品订单
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderProduct(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_products = OrderProduct::getList($params);
|
||||
if (empty($order_products)){
|
||||
$this->line("无药品订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_products as $order_product){
|
||||
if (!empty($order_product['order_id'])){
|
||||
// 已存在订单id,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $order_product['order_product_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (!empty($order)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
$this->line("无问诊订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $order_inquiry['user_id'];
|
||||
$data['patient_id'] = $order_product['patient_id'];
|
||||
$data['doctor_id'] = $order_product['doctor_id'];
|
||||
$data['order_type'] = 2;
|
||||
$data['is_delete'] = $order_product['is_delete']; // 删除状态(0:否 1:是)
|
||||
$data['pay_channel'] = $order_product['pay_channel'];
|
||||
$data['pay_status'] = $order_product['pay_status'];
|
||||
$data['pay_time'] = $order_product['pay_time'];
|
||||
$data['refund_status'] = $order_product['refund_status'];
|
||||
$data['order_no'] = $order_product['order_product_no'];
|
||||
$data['escrow_trade_no'] = $order_product['escrow_trade_no'];
|
||||
$data['amount_total'] = $order_product['amount_total'];
|
||||
$data['coupon_amount_total'] = $order_product['coupon_amount_total'];
|
||||
$data['payment_amount_total'] = $order_product['payment_amount_total'];
|
||||
if ($order_inquiry['order_product_status'] == 5){
|
||||
$data['cancel_status'] = 1;
|
||||
}
|
||||
$data['cancel_time'] = $order_product['cancel_time'];
|
||||
$data['cancel_remarks'] = $order_product['cancel_remarks'];
|
||||
$data['is_withdrawal'] = 3;
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加药品订单失败");
|
||||
}
|
||||
|
||||
// 修改药品订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
|
||||
$params = array();
|
||||
$params['order_product_no'] = $order['order_no'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理药品订单退款
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderProductRefund(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_product_refunds = OrderProductRefund::getList($params);
|
||||
if (empty($order_product_refunds)){
|
||||
$this->line("无问诊退款订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_product_refunds as $order_product_refund){
|
||||
$params = array();
|
||||
$params['order_no'] = $order_product_refund['order_product_no'];
|
||||
$order_refund = OrderRefund::getOne($params);
|
||||
if (!empty($order_refund)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_product_refund['order_product_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
// 已存在订单,跳过
|
||||
$this->line("无对应订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['patient_id'] = $order_product_refund['patient_id'];
|
||||
$data['order_no'] = $order['order_no'];
|
||||
$data['refund_no'] = $order_product_refund['order_product_no'];
|
||||
$data['refund_id'] = $order_product_refund['refund_id'];
|
||||
$data['refund_status'] = $order_product_refund['product_refund_status'];
|
||||
$data['refund_total'] = $order_product_refund['refund_total'];
|
||||
$data['refund_reason'] = $order_product_refund['refund_reason'];
|
||||
$data['success_time'] = $order_product_refund['success_time'];
|
||||
$order_refund = OrderRefund::addOrderRefund($data);
|
||||
if (empty($order_refund)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加药品退款订单失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理药品订单优惠卷
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderProductCoupon(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_product_coupons = OrderProductCoupon::getList($params);
|
||||
if (empty($order_product_coupons)){
|
||||
$this->line("无药品订单优惠卷需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_product_coupons as $order_product_coupon){
|
||||
// 获取问诊订单详情
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product_coupon['order_product_id'];
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
$this->line("药品订单数据错误");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_product['order_product_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
$this->line("无对应订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['user_coupon_id'] = $order_product_coupon['user_coupon_id'];
|
||||
$data['coupon_name'] = $order_product_coupon['coupon_name'];
|
||||
$data['coupon_use_price'] = $order_product_coupon['coupon_use_price'];
|
||||
$order_coupon = OrderCoupon::addOrderCoupon($data);
|
||||
if (empty($order_coupon)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加问诊订单优惠卷失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检测订单
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderDetection(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_detections = OrderDetection::getList($params);
|
||||
if (empty($order_detections)){
|
||||
$this->line("无检测订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_detections as $order_detection){
|
||||
if (!empty($order_detection['order_id'])){
|
||||
// 已存在订单id,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $order_detection['detection_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (!empty($order)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $order_detection['user_id'];
|
||||
$data['patient_id'] = $order_detection['patient_id'];
|
||||
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||
$data['order_type'] = 3;
|
||||
$data['is_delete'] = $order_detection['is_delete']; // 删除状态(0:否 1:是)
|
||||
$data['pay_channel'] = $order_detection['detection_pay_channel'];
|
||||
$data['pay_status'] = $order_detection['detection_pay_status'];
|
||||
$data['pay_time'] = $order_detection['pay_time'];
|
||||
$data['refund_status'] = $order_detection['detection_refund_status'];
|
||||
$data['order_no'] = $order_detection['detection_no'];
|
||||
$data['escrow_trade_no'] = $order_detection['escrow_trade_no'];
|
||||
$data['amount_total'] = $order_detection['amount_total'];
|
||||
$data['coupon_amount_total'] = $order_detection['coupon_amount_total'];
|
||||
$data['payment_amount_total'] = $order_detection['payment_amount_total'];
|
||||
if ($order_detection['detection_status'] == 5){
|
||||
$data['cancel_status'] = 1;
|
||||
}
|
||||
$data['cancel_time'] = $order_detection['cancel_time'];
|
||||
if (!empty($order_detection['cancel_reason'])){
|
||||
$data['cancel_remarks'] = detectionCancelReasonToString($order_detection['cancel_reason']);
|
||||
}
|
||||
|
||||
$data['is_withdrawal'] = 3;
|
||||
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加检测订单失败");
|
||||
}
|
||||
|
||||
// 修改检测订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
|
||||
$params = array();
|
||||
$params['detection_no'] = $order['order_no'];
|
||||
OrderDetection::editOrderDetection($params,$data);
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检测订单退款
|
||||
* @return void
|
||||
*/
|
||||
public function handleOrderDetectionRefund(): void
|
||||
{
|
||||
$params = array();
|
||||
$order_detection_refunds = OrderDetectionRefund::getList($params);
|
||||
if (empty($order_detection_refunds)){
|
||||
$this->line("无检测退款订单需要执行");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_detection_refunds as $order_detection_refund){
|
||||
$params = array();
|
||||
$params['order_no'] = $order_detection_refund['detection_no'];
|
||||
$order_refund = OrderRefund::getOne($params);
|
||||
if (!empty($order_refund)){
|
||||
// 已存在订单,跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_detection_refund['detection_no'];
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
// 已存在订单,跳过
|
||||
$this->line("无对应订单数据");
|
||||
continue;
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['patient_id'] = $order_detection_refund['patient_id'];
|
||||
$data['order_no'] = $order['order_no'];
|
||||
$data['refund_no'] = $order_detection_refund['detection_refund_no'];
|
||||
$data['refund_id'] = $order_detection_refund['refund_id'];
|
||||
$data['refund_status'] = $order_detection_refund['detection_refund_status'];
|
||||
$data['refund_total'] = $order_detection_refund['refund_total'];
|
||||
$data['refund_reason'] = $order_detection_refund['refund_reason'];
|
||||
$data['success_time'] = $order_detection_refund['success_time'];
|
||||
$order_refund = OrderRefund::addOrderRefund($data);
|
||||
if (empty($order_refund)) {
|
||||
Db::rollBack();
|
||||
$this->line("添加检测退款订单失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修正医生提现关联订单表数据
|
||||
* @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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ class ReportPreProductOrderCommand extends HyperfCommand
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
$this->line("开始");
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
*/
|
||||
#[Command]
|
||||
class editDoctorInquiryConfigCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
@ -11,6 +11,9 @@ use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
*/
|
||||
#[Command]
|
||||
class editDoctorQrCodeCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
@ -4,12 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\UserPatient;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderPrescriptionService;
|
||||
use App\Services\OrderProductService;
|
||||
use App\Services\OrderService;
|
||||
use App\Utils\Log;
|
||||
use Extend\Kuaidi100\Kuaidi;
|
||||
use Extend\Prescription\Prescription;
|
||||
@ -43,20 +45,20 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
|
||||
try {
|
||||
// 获取可查询商品订单
|
||||
$order_product_ids = $this->getSearchableProductOrder();
|
||||
if (empty($order_product_ids)){
|
||||
$order_products = $this->getSearchableProductOrder();
|
||||
if (empty($order_products)){
|
||||
$this->line("结束:无可执行的商品订单");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_product_ids as $item) {
|
||||
foreach ($order_products as $order_product) {
|
||||
Db::beginTransaction();
|
||||
|
||||
$this->line("本次请求订单号:" . $item['order_product_id']);
|
||||
$this->line("本次请求订单号:" . $order_product['order_product_id']);
|
||||
|
||||
// 获取药品订单处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $item['order_prescription_id'];
|
||||
$params['order_prescription_id'] = $order_product['order_prescription_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
Db::rollBack();
|
||||
@ -66,7 +68,7 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
|
||||
try {
|
||||
$Prescription = new Prescription();
|
||||
$result = $Prescription->getPrescription($item['order_product_no'],$order_prescription['prescription_code']);
|
||||
$result = $Prescription->getPrescription($order_product['order_product_no'],$order_prescription['prescription_code']);
|
||||
|
||||
$this->line("处方平台数据:" . json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
@ -86,7 +88,7 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
if ($result['status'] == "CFD03" || $result['status'] == "CFD04" || $result['status'] == "CFD06" || $result['status'] == "CFD07"){
|
||||
// 药师审核未通过/库存不足/已取消/申请退款
|
||||
// 检测药品订单数据
|
||||
$res = $this->checkPreFailedOrderStatus($item);
|
||||
$res = $this->checkPreFailedOrderStatus($order_product);
|
||||
if (!$res){
|
||||
Db::rollBack();
|
||||
continue;
|
||||
@ -94,22 +96,22 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
|
||||
// 修改失败时药品订单数据
|
||||
if ($result['status'] == "CFD03"){
|
||||
$this->savePreFailedOrderStatus($item,"复核失败");
|
||||
$this->savePreFailedOrderStatus($order_product,"复核失败");
|
||||
}elseif($result['status'] == "CFD04"){
|
||||
$this->savePreFailedOrderStatus($item,"库存不足");
|
||||
$this->savePreFailedOrderStatus($order_product,"库存不足");
|
||||
}else{
|
||||
$this->savePreFailedOrderStatus($item,"订单取消");
|
||||
$this->savePreFailedOrderStatus($order_product,"订单取消");
|
||||
}
|
||||
|
||||
// 执行退款
|
||||
$OrderProductService = new OrderProductService();
|
||||
$OrderProductService->OrderProductRefund($item['order_product_id'],"订单退款");
|
||||
$OrderService = new OrderService();
|
||||
$OrderService->orderRefund($order_product['order_product_no'],"订单退款");
|
||||
}
|
||||
|
||||
if ($result['status'] == "CFD05"){
|
||||
// 已发货/已取货
|
||||
// 检测成功时药品订单数据
|
||||
$res = $this->checkPreSuccessOrderStatus($item);
|
||||
$res = $this->checkPreSuccessOrderStatus($order_product);
|
||||
if (!$res){
|
||||
Db::rollBack();
|
||||
continue;
|
||||
@ -196,17 +198,7 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
|
||||
$order_product_status = [2,3];// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
|
||||
$fields = [
|
||||
'order_product_id',
|
||||
'order_product_no',
|
||||
'order_prescription_id',
|
||||
'patient_id',
|
||||
'order_product_status',
|
||||
'consignee_tel',
|
||||
'logistics_no',
|
||||
];
|
||||
|
||||
$order_product = OrderProduct::getStatusList($params,$order_product_status,$fields);
|
||||
$order_product = OrderProduct::getStatusList($params,$order_product_status);
|
||||
if (empty($order_product)){
|
||||
return [];
|
||||
}
|
||||
@ -276,8 +268,19 @@ class getPrescriptionOrderStatusCommand extends HyperfCommand
|
||||
* @param array|object $order_product
|
||||
* @param string $cancel_remarks
|
||||
*/
|
||||
protected function savePreFailedOrderStatus(array|object $order_product,string $cancel_remarks)
|
||||
protected function savePreFailedOrderStatus(array|object $order_product,string $cancel_remarks): void
|
||||
{
|
||||
// 取消订单
|
||||
$order_data = array();
|
||||
$order_data['cancel_status'] = 1;
|
||||
$order_data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$order_data['cancel_remarks'] = $cancel_remarks;
|
||||
$order_data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_id'] = $order_product['order_id'];
|
||||
Order::edit($params, $order_data);
|
||||
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
|
||||
@ -196,7 +196,7 @@ function inquiryCancelReasonToString(int|string $cancel_reason): string
|
||||
} elseif ($cancel_reason == 5) {
|
||||
$result = "支付超时";
|
||||
} else {
|
||||
$result = "未知";
|
||||
$result = NULL;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -245,6 +245,25 @@ function productCancelReasonToString(int|string $cancel_reason): string
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换检测订单取消原因-字符串
|
||||
* @param int|string $cancel_reason 取消订单原因(1:主动取消 2:客服取消 3:支付超时)
|
||||
* @return string
|
||||
*/
|
||||
function detectionCancelReasonToString(int|string $cancel_reason): string
|
||||
{
|
||||
if ($cancel_reason == 1) {
|
||||
$result = "主动取消";
|
||||
} elseif ($cancel_reason == 2) {
|
||||
$result = "客服取消";
|
||||
} elseif ($cancel_reason == 3) {
|
||||
$result = "支付超时";
|
||||
} else {
|
||||
$result = "";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换性别至字符串
|
||||
* @param string|int $sex
|
||||
@ -299,4 +318,90 @@ function couponScopeToString(int|string $application_scope): string
|
||||
$result = "";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换服务包订单类型为汉字
|
||||
* @param int|string $order_service_type 服务包类型(1:健康包 2:随访包)
|
||||
* @return string
|
||||
*/
|
||||
function orderServiceTypeToString(int|string $order_service_type): string
|
||||
{
|
||||
if ($order_service_type == 1) {
|
||||
$result = "健康包";
|
||||
} elseif ($order_service_type == 2) {
|
||||
$result = "随访包";
|
||||
} else {
|
||||
$result = "服务包";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换每月次数为汉字
|
||||
* @param int|string $monthly_frequency 服务包类型(1:健康包 2:随访包)
|
||||
* @return string
|
||||
*/
|
||||
function monthlyFrequencyToString(int|string $monthly_frequency): string
|
||||
{
|
||||
$result = $monthly_frequency;
|
||||
if ($monthly_frequency == 0) {
|
||||
$result = "不限";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换问诊订单订单接诊方式-字符串
|
||||
* @param int|string $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
* @return string
|
||||
*/
|
||||
function inquiryModeToString(int|string $inquiry_mode): string
|
||||
{
|
||||
if ($inquiry_mode == 1) {
|
||||
$result = "图文";
|
||||
} elseif ($inquiry_mode == 2) {
|
||||
$result = "视频";
|
||||
} elseif ($inquiry_mode == 3) {
|
||||
$result = "语音";
|
||||
} elseif ($inquiry_mode == 4) {
|
||||
$result = "电话";
|
||||
} elseif ($inquiry_mode == 5) {
|
||||
$result = "会员";
|
||||
} elseif ($inquiry_mode == 6) {
|
||||
$result = "疑难会诊";
|
||||
} elseif ($inquiry_mode == 7) {
|
||||
$result = "附赠";
|
||||
} elseif ($inquiry_mode == 8) {
|
||||
$result = "健康包";
|
||||
} elseif ($inquiry_mode == 9) {
|
||||
$result = "随访包";
|
||||
} else {
|
||||
$result = "未知";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换订单类型为汉字
|
||||
* @param int|string $order_type
|
||||
* @return string
|
||||
*/
|
||||
function orderTypeToString(int|string $order_type): string
|
||||
{
|
||||
if ($order_type == 1) {
|
||||
$result = "问诊订单";
|
||||
} elseif ($order_type == 2) {
|
||||
$result = "药品订单";
|
||||
} elseif ($order_type == 3) {
|
||||
$result = "检测订单";
|
||||
} elseif ($order_type == 4) {
|
||||
$result = "随访包";
|
||||
} elseif ($order_type == 5) {
|
||||
$result = "健康包";
|
||||
} else {
|
||||
$result = "未知";
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -50,21 +50,16 @@ class DoctorAccountController extends AbstractController
|
||||
/**
|
||||
* 获取提现数据
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getDoctorWithdrawalInfo(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorAccountRequest::class);
|
||||
$request->scene('getDoctorWithdrawalInfo')->validateResolved();
|
||||
|
||||
$DoctorAccountService = new DoctorAccountService();
|
||||
$data = $DoctorAccountService->getDoctorWithdrawalInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可提现问诊订单列表
|
||||
* 获取可提现订单列表
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDoctorWithdrawalOrderList(): ResponseInterface
|
||||
|
||||
@ -12,6 +12,22 @@ use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class DoctorInquiryConfigController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* 获取医生问诊服务开启状态
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getDoctorInquiryConfigOpenStatus(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('getDoctorInquiryConfigOpenStatus')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryConfigOpenStatus();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置
|
||||
* @return ResponseInterface
|
||||
@ -61,50 +77,111 @@ class DoctorInquiryConfigController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-服务设置
|
||||
* 获取医生问诊配置-疑难会诊-服务设置
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getInquiryServiceConfig(): ResponseInterface
|
||||
public function getDoctorInquiryDifficultConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('getInquiryServiceConfig')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getInquiryServiceConfig();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryDifficultConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增医生问诊配置-服务设置
|
||||
* 新增医生问诊配置-疑难会诊-服务设置
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addInquiryServiceConfig(): ResponseInterface
|
||||
public function addDoctorInquiryDifficultConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('addInquiryServiceConfig')->validateResolved();
|
||||
$request->scene('addDoctorInquiryDifficultConfig')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->addInquiryServiceConfig();
|
||||
$data = $DoctorInquiryService->addDoctorInquiryDifficultConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改医生问诊配置-服务设置
|
||||
* 修改医生问诊配置-疑难会诊-服务设置
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putInquiryServiceConfig(): ResponseInterface
|
||||
public function putDoctorInquiryDifficultConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('putInquiryServiceConfig')->validateResolved();
|
||||
$request->scene('putDoctorInquiryDifficultConfig')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->putInquiryServiceConfig();
|
||||
$data = $DoctorInquiryService->putDoctorInquiryDifficultConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-随访包
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDoctorInquiryFollowConfig(): ResponseInterface
|
||||
{
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryFollowConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-随访包-列表
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDoctorInquiryFollowItemConfig(): ResponseInterface
|
||||
{
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryFollowItemConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增医生问诊配置-随访包
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addDoctorInquiryFollowConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('addDoctorInquiryFollowConfig')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->addDoctorInquiryFollowConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改医生问诊配置-随访包
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putDoctorInquiryFollowConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(DoctorInquiryConfigRequest::class);
|
||||
$request->scene('putDoctorInquiryFollowConfig')->validateResolved();
|
||||
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->putDoctorInquiryFollowConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-健康包
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDoctorInquiryHealthConfig(): ResponseInterface
|
||||
{
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$data = $DoctorInquiryService->getDoctorInquiryHealthConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
}
|
||||
@ -173,4 +173,15 @@ class InquiryController extends AbstractController
|
||||
$data = $InquiryService->getInquiryVideoMessageBasic();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包关联问诊订单消息内页基础数据
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getInquiryServiceMessageBasic(): ResponseInterface
|
||||
{
|
||||
$InquiryService = new InquiryService();
|
||||
$data = $InquiryService->getInquiryServiceMessageBasic();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
72
app/Controller/OrderServicePackageController.php
Normal file
72
app/Controller/OrderServicePackageController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Request\OrderServicePackageRequest;
|
||||
use App\Request\PatientOrderRequest;
|
||||
use App\Request\UserPatientRequest;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Services\PatientOrderService;
|
||||
use App\Services\UserPatientService;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class OrderServicePackageController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* 获取患者已购买的某医生的服务包详情
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPatientBuyServiceDetail(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(OrderServicePackageRequest::class);
|
||||
$request->scene('getPatientBuyServiceDetail')->validateResolved();
|
||||
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$data = $OrderServicePackageService->getPatientBuyServiceDetail();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建服务包订单
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addPatientServiceOrder(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(OrderServicePackageRequest::class);
|
||||
$request->scene('addPatientServiceOrder')->validateResolved();
|
||||
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$data = $OrderServicePackageService->addPatientServiceOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建服务包问诊订单
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addServiceInquiryOrder(): ResponseInterface
|
||||
{
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$data = $OrderServicePackageService->addServiceInquiryOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测是否可创建服务包问诊订单
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getServicePackageInquiryCheck(): ResponseInterface
|
||||
{
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$data = $OrderServicePackageService->getServicePackageInquiryCheck();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -93,4 +93,26 @@ class PatientCaseController extends AbstractController
|
||||
$data = $PatientCaseService->sendCaseUnfilledFieldsToDoctor();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单病例详情-基础
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getPatientFamilyServiceCaseSimple(): ResponseInterface
|
||||
{
|
||||
$PatientCaseService = new PatientCaseService();
|
||||
$data = $PatientCaseService->getPatientFamilyServiceCaseSimple();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单病例详情
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getPatientFamilyServiceCase(): ResponseInterface
|
||||
{
|
||||
$PatientCaseService = new PatientCaseService();
|
||||
$data = $PatientCaseService->getPatientFamilyServiceCase();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -70,8 +70,6 @@ class PatientOrderController extends AbstractController
|
||||
/**
|
||||
* 问诊订单取消支付
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putPatientInquiryOrderCancelPay(): ResponseInterface
|
||||
{
|
||||
@ -110,6 +108,8 @@ class PatientOrderController extends AbstractController
|
||||
/**
|
||||
* 药品订单取消支付
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putPatientProductOrderCancelPay(): ResponseInterface
|
||||
{
|
||||
@ -149,7 +149,7 @@ class PatientOrderController extends AbstractController
|
||||
* 模拟支付成功-金额为0时使用
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface|GuzzleException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addPatientOrderPay(): ResponseInterface
|
||||
{
|
||||
@ -298,4 +298,75 @@ class PatientOrderController extends AbstractController
|
||||
$data = $PatientOrderService->putPatientDetectionOrderCancelPay();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务包订单取消支付-1未支付
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function putPatientServiceOrderCancelPay(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->putPatientServiceOrderCancelPay();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单取消支付-1未支付
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function putPatientOrderCancelPay(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->putPatientOrderCancelPay();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单-问诊/检测/服务包
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function putCancelPatientOrder(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->putCancelPatientOrder();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者服务包订单列表
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPatientServiceOrderList(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(PatientOrderRequest::class);
|
||||
$request->scene('getPatientServiceOrderList')->validateResolved();
|
||||
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientServiceOrderList();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者问诊订单详情
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getPatientServiceOrderInfo(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientServiceOrderInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者服务包订单服务权益详情
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getPatientServiceOrderDetailInfo(): ResponseInterface
|
||||
{
|
||||
$PatientOrderService = new PatientOrderService();
|
||||
$data = $PatientOrderService->getPatientServiceOrderDetailInfo();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -29,4 +29,20 @@ class SystemController extends AbstractController
|
||||
$data = $SystemService->getSystemInquiryTime();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统问诊配置
|
||||
* @return ResponseInterface
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getSystemInquiryConfig(): ResponseInterface
|
||||
{
|
||||
$request = $this->container->get(SystemRequest::class);
|
||||
$request->scene('getSystemInquiryConfig')->validateResolved();
|
||||
|
||||
$SystemService = new SystemService();
|
||||
$data = $SystemService->getSystemInquiryConfig();
|
||||
return $this->response->json($data);
|
||||
}
|
||||
}
|
||||
@ -7,16 +7,33 @@ use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Amqp\Producer\SendSmsMessageProducer;
|
||||
use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Factory\CacheFactory;
|
||||
use App\Factory\ProdRedisFactory;
|
||||
use App\Model\DoctorAccountDay;
|
||||
use App\Model\DoctorConfigFollowPackage;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
use App\Model\DoctorConfigHealthPackage;
|
||||
use App\Model\DoctorInquiryTime;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderCoupon;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionRefund;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\OrderProductRefund;
|
||||
use App\Model\OrderRefund;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\OrderServicePackageProduct;
|
||||
use App\Model\OrderServicePackageRefund;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\ReportRegulatory;
|
||||
use App\Model\User;
|
||||
@ -26,12 +43,16 @@ use App\Model\OrderPrescription;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Services\CouponService;
|
||||
use App\Services\ImService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\MessagePush;
|
||||
use App\Services\OrderPrescriptionService;
|
||||
use App\Services\OrderProductService;
|
||||
use App\Services\OrderService;
|
||||
use App\Services\OrderServicePackageService;
|
||||
use App\Services\PatientOrderService;
|
||||
use App\Services\UserCouponService;
|
||||
use App\Services\UserDoctorService;
|
||||
use App\Utils\Data;
|
||||
use App\Utils\Jwt;
|
||||
@ -44,12 +65,15 @@ use Extend\Kuaidi100\Kuaidi;
|
||||
use Extend\Prescription\Prescription;
|
||||
use Extend\RegulatoryPlatform\regulatoryPlatform;
|
||||
use Extend\TencentIm\RecentContact;
|
||||
use Extend\VerifyDun\IdCard;
|
||||
use Extend\Wechat\Wechat;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use GuzzleHttp\Client;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Cache\Cache;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Utils\Coroutine\Concurrent;
|
||||
use Intervention\Image\ImageManager;
|
||||
@ -164,15 +188,8 @@ class TestController extends AbstractController
|
||||
throw new BusinessException("处方药品数据错误4");
|
||||
}
|
||||
|
||||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||
$result = $OrderPrescriptionService->reportPrescription(
|
||||
$order_inquiry->toArray(),
|
||||
$order_prescription->toArray(),
|
||||
$order_prescription_product->toArray(),
|
||||
$order_product->toArray()
|
||||
);
|
||||
|
||||
dump($result);
|
||||
|
||||
}
|
||||
|
||||
// 上报监管平台
|
||||
@ -281,22 +298,6 @@ class TestController extends AbstractController
|
||||
dump($result);
|
||||
}
|
||||
|
||||
// 退款
|
||||
public function refund(){
|
||||
$out_trade_no = $this->request->input('out_trade_no');
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $out_trade_no;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 需退款
|
||||
$inquiryService = new InquiryService();
|
||||
$inquiryService->inquiryRefund($out_trade_no, "取消问诊");
|
||||
return success();
|
||||
}
|
||||
|
||||
// 获取云证书-线上
|
||||
public function test_14(){
|
||||
$CaOnline = new CaOnline();
|
||||
@ -368,6 +369,7 @@ class TestController extends AbstractController
|
||||
if (empty($doctor_pharmacist_cert)){
|
||||
return fail();
|
||||
}
|
||||
return 111;
|
||||
}
|
||||
|
||||
public function test_15(){
|
||||
@ -386,29 +388,29 @@ class TestController extends AbstractController
|
||||
public function test_16(){
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
// 测试医生
|
||||
// $data = array();
|
||||
// $data['user_id'] = "491925054435950592";
|
||||
// $data['mobile'] = "13028643897";
|
||||
// $data['card_name'] = "郝明明";
|
||||
// $data['card_num'] = "130582199202032038";
|
||||
// $data['orgDept'] = "科室名称";
|
||||
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||||
// $data['org_number'] = "91510106MABTJY4K9R";
|
||||
// $result = $CaOnline->getCloudCert($data);
|
||||
//
|
||||
// $data = array();
|
||||
// $data['user_id'] = "491925054435950592";
|
||||
// $data['type'] = 2;
|
||||
// $data['cert_base64'] = $result['certBase64'];
|
||||
// $data['cert_chain_p7'] = $result['certP7'];
|
||||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
// $data['ca_pin'] = "491925054435950592";
|
||||
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
||||
// if (empty($doctor_pharmacist_cert)){
|
||||
// return fail();
|
||||
// }
|
||||
// dump(111);
|
||||
// 测试医生
|
||||
$data = array();
|
||||
$data['user_id'] = "491925054435950592";
|
||||
$data['mobile'] = "13028643897";
|
||||
$data['card_name'] = "郝明明";
|
||||
$data['card_num'] = "130582199202032038";
|
||||
$data['orgDept'] = "科室名称";
|
||||
$data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||||
$data['org_number'] = "91510106MABTJY4K9R";
|
||||
$result = $CaOnline->getCloudCert($data);
|
||||
|
||||
$data = array();
|
||||
$data['user_id'] = "491925054435950592";
|
||||
$data['type'] = 2;
|
||||
$data['cert_base64'] = $result['certBase64'];
|
||||
$data['cert_chain_p7'] = $result['certP7'];
|
||||
$data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
$data['ca_pin'] = "491925054435950592";
|
||||
$doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
||||
if (empty($doctor_pharmacist_cert)){
|
||||
return fail();
|
||||
}
|
||||
dump(111);
|
||||
|
||||
// // 测试药师
|
||||
// $data = array();
|
||||
@ -431,94 +433,490 @@ class TestController extends AbstractController
|
||||
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
|
||||
// if (empty($doctor_pharmacist_cert)){
|
||||
// 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();
|
||||
$params['ca_pin'] = "491925054435950592";
|
||||
$params['type'] = "2";
|
||||
$user_ca_cert = UserCaCert::getOne($params);
|
||||
if (empty($user_ca_cert)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 测试医院
|
||||
$data = array();
|
||||
$data['user_id'] = "491925054435950592";
|
||||
$result = $CaOnline->renewCloudCert($data);
|
||||
|
||||
dump($result);
|
||||
|
||||
$data = array();
|
||||
$data['cert_base64'] = $result['certBase64'];
|
||||
$data['cert_chain_p7'] = $result['certP7'];
|
||||
$data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
$data['ca_pin'] = "491925054435950592";
|
||||
|
||||
$params = array();
|
||||
$params['cert_id'] = $user_ca_cert['cert_id'];
|
||||
$res = UserCaCert::edit($params,$data);
|
||||
if (empty($res)){
|
||||
return fail();
|
||||
}
|
||||
return 122;
|
||||
// // 测试医院
|
||||
// $data = array();
|
||||
// $data['user_id'] = "491925054435950592";
|
||||
// $result = $CaOnline->renewCloudCert($data);
|
||||
//
|
||||
// dump($result);
|
||||
//
|
||||
// $data = array();
|
||||
// $data['cert_base64'] = $result['certBase64'];
|
||||
// $data['cert_chain_p7'] = $result['certP7'];
|
||||
// $data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
// $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(){
|
||||
$expertise_id = $this->request->input('expertise_id');
|
||||
$province_id = $this->request->input('province_id');
|
||||
$city_id = $this->request->input('city_id');
|
||||
$sort_order = $this->request->input('sort_order',1);
|
||||
$keyword = $this->request->input('keyword',"");
|
||||
$is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0); // 是否参加公益图文问诊(0:否 1:是)
|
||||
$is_first_online = $this->request->input('is_first_online',0); // 是否优先在线(1:是)
|
||||
$page = $this->request->input('page',1);
|
||||
$per_page = $this->request->input('per_page',10);
|
||||
|
||||
// 组合条件
|
||||
$hospital_params = array();// 医院搜索
|
||||
$doctor_params = array();// 医生搜索
|
||||
$doctor_expertise_params = array();// 医生专长搜索
|
||||
}
|
||||
|
||||
// 省市区
|
||||
if (!empty($province_id)) {
|
||||
if (empty($city_id)) {
|
||||
// 省份存在时需和城市在一块
|
||||
return fail(HttpEnumCode::CLIENT_HTTP_ERROR);
|
||||
// 退款
|
||||
public function refund(){
|
||||
$order_no = $this->request->input('order_no');
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
$hospital_params[] = ['province_id', '=', $province_id];
|
||||
$hospital_params[] = ['city_id', '=', $city_id];
|
||||
|
||||
// 修改订单为取消
|
||||
$data = array();
|
||||
$data['cancel_status'] = 1;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_remarks'] = "主动取消"; // 取消订单备注
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
Order::edit($params, $data);
|
||||
|
||||
// 处理对应订单
|
||||
switch ($order['order_type']) {
|
||||
case 1: // 问诊订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $order_no;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
// 修改问诊订单为取消
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = 2; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
|
||||
break;
|
||||
case 3: // 检测订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['detection_no'] = $order_no;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
// 修改检测订单为取消
|
||||
$data = array();
|
||||
$data['detection_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = 1; // 取消订单原因(1:主动取消 2:客服取消 3:支付超时)
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
OrderDetection::editOrderDetection($params, $data);
|
||||
|
||||
break;
|
||||
case 4: // 健康包订单
|
||||
case 5: // 随访包订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
// 修改服务包订单为取消
|
||||
$data = array();
|
||||
$data['order_service_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
OrderServicePackage::edit($params, $data);
|
||||
|
||||
// 获取问诊订单数据-此处只会存在一个
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
$order_service_package_inquirys = OrderServicePackageInquiry::getList($params);
|
||||
if (empty($order_service_package_inquirys)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
foreach ($order_service_package_inquirys as $order_service_package_inquiry){
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $order_service_package_inquiry['inquiry_no'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
if (in_array($order_inquiry['inquiry_status'], [5, 6 , 7])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_refund_status'] == 1) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_refund_status'] == 2) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
continue;
|
||||
}
|
||||
|
||||
// 修改问诊订单为取消
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = 2; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未查询到对应订单数据");
|
||||
}
|
||||
|
||||
// 检测支付状态,判断是否需要退款处理
|
||||
if ($order['pay_status'] == 2 && $order['refund_status'] != 3) {
|
||||
// 系统退款编号
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
$refund_no = $generator->generate();
|
||||
|
||||
// 检测订单金额
|
||||
if ($order['payment_amount_total'] > 0) {
|
||||
// 发起退款
|
||||
$WechatPay = new WechatPay(1, $order['order_type']);
|
||||
|
||||
$options = array();
|
||||
$options['transaction_id'] = $order['escrow_trade_no'];
|
||||
$options['out_refund_no'] = (string)$refund_no;
|
||||
$options['reason'] = "主动取消";
|
||||
$options['amount'] = [
|
||||
'refund' => (int)round($order['payment_amount_total'] * 100),
|
||||
'total' => (int)round($order['payment_amount_total'] * 100),
|
||||
'currency' => "CNY",
|
||||
];
|
||||
|
||||
$refund_result = $WechatPay->refund($options);
|
||||
|
||||
// 处理订单退款状态
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$success_time = "";
|
||||
if ($refund_result['status'] == "SUCCESS") {
|
||||
// 退款成功
|
||||
$refund_status = 3;
|
||||
$success_time = $refund_result['success_time'];
|
||||
} elseif ($refund_result['status'] == "CLOSED") {
|
||||
// 退款关闭
|
||||
$refund_status = 5;
|
||||
} elseif ($refund_result['status'] == "PROCESSING") {
|
||||
// 退款处理中
|
||||
$refund_status = 2;
|
||||
} elseif ($refund_result['status'] == "ABNORMAL") {
|
||||
// 退款异常,此情况不处理,进行短信通知
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单退款状态异常");
|
||||
} else {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单退款状态异常");
|
||||
}
|
||||
|
||||
$refund_id = $refund_result['refund_id'];
|
||||
} else {
|
||||
// 模拟退款
|
||||
$refund_status = 3;
|
||||
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
$refund_id = "模拟退款:" . $generator->generate();
|
||||
$success_time = date("Y-m-d H:i:s", time());
|
||||
|
||||
// 模拟退款时手动退还优惠卷
|
||||
if (!empty($order['coupon_amount_total']) && $order['coupon_amount_total'] > 0) {
|
||||
// 获取该订单全部优惠卷数据
|
||||
$params = array();
|
||||
$params['order_id'] = $order['order_id'];
|
||||
$order_coupons = OrderCoupon::getList($params);
|
||||
if (!empty($order_coupons)) {
|
||||
$userCouponService = new UserCouponService();
|
||||
foreach ($order_coupons as $order_coupon) {
|
||||
// 退还优惠卷
|
||||
$userCouponService->returnUserCoupon($order_coupon['user_coupon_id']);
|
||||
|
||||
// 发送站内消息-优惠卷退还
|
||||
$MessagePush = new MessagePush($order_coupon['user_id']);
|
||||
$MessagePush->patientRefundCoupon($order_coupon['coupon_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 新增退款表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['patient_id'] = $order['patient_id'];
|
||||
$data['order_no'] = $order['order_no'];
|
||||
$data['refund_no'] = $refund_no;
|
||||
$data['inquiry_refund_no'] = $refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order['payment_amount_total'];
|
||||
$data['refund_reason'] = "主动取消";
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
$order_refund = OrderRefund::addOrderRefund($data);
|
||||
if (empty($order_refund)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加退款表失败");
|
||||
}
|
||||
|
||||
switch ($order['order_type']) {
|
||||
case 1: // 问诊订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $order_no;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
// 新增退款表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order['patient_id'];
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$data['inquiry_no'] = $order_inquiry['inquiry_no'];
|
||||
$data['inquiry_refund_no'] = $refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['inquiry_refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order_inquiry['payment_amount_total'];
|
||||
$data['refund_reason'] = "主动取消";
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
|
||||
$order_inquiry_refund = OrderInquiryRefund::addOrderInquiryRefund($data);
|
||||
if (empty($order_inquiry_refund)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改问诊订单表状态
|
||||
$data = array();
|
||||
$data['inquiry_refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
|
||||
break;
|
||||
case 2: // 药品订单
|
||||
// 获取药品订单数据
|
||||
$params = array();
|
||||
$params['order_product_no'] = $order['order_no'];
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['patient_id'] = $order_product['patient_id'];
|
||||
$data['order_product_id'] = $order_product['order_product_id'];
|
||||
$data['order_product_no'] = $order_product['order_product_no'];
|
||||
$data['product_refund_no'] = $refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['product_refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order_product['payment_amount_total'];
|
||||
$data['refund_reason'] = "主动取消";
|
||||
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
|
||||
$order_product_refund = OrderProductRefund::addOrderProductRefund($data);
|
||||
if (empty($order_product_refund)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改药品订单表状态
|
||||
$data = array();
|
||||
$data['refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
// 获取订单商品订单列表
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
$order_product_items = OrderProductItem::getList($params);
|
||||
if (empty($order_product_items)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
// 获取患者家庭成员进行中的服务包订单-健康包
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$order_service_package = $OrderServicePackageService->getPatientFamilyInProgressServicePackage($order_inquiry['user_id'],$order_inquiry['family_id'],$order_inquiry['doctor_id'],1);
|
||||
if (!empty($order_service_package)){
|
||||
// 回退服务包已使用药品数量
|
||||
foreach ($order_product_items as $order_product_item){
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
$params['order_product_id'] = $order_product_item['order_product_id'];
|
||||
$params['product_item_id'] = $order_product_item['product_item_id'];
|
||||
$params['product_id'] = $order_product_item['product_id'];
|
||||
$order_service_package_product = OrderServicePackageProduct::getOne($params);
|
||||
if (!empty($order_service_package_product)){
|
||||
$params = array();
|
||||
$params['service_product_id'] = $order_service_package_product['service_product_id'];
|
||||
|
||||
$data = array();
|
||||
$data['used_quantity'] = 0;
|
||||
OrderServicePackageProduct::edit($params,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: // 检测订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['detection_no'] = $order_no;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
// 新增退款表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order['patient_id'];
|
||||
$data['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
$data['detection_no'] = $order_detection['detection_no'];
|
||||
$data['detection_refund_no'] = $refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['detection_refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order_detection['payment_amount_total'];
|
||||
$data['refund_reason'] = "主动取消";
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
$order_detection_refund = OrderDetectionRefund::add($data);
|
||||
if (empty($order_detection_refund)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改问诊订单表状态
|
||||
$data = array();
|
||||
$data['detection_refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
OrderDetection::editOrderDetection($params, $data);
|
||||
|
||||
break;
|
||||
case 4: // 健康包订单
|
||||
case 5: // 随访包订单订单
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单数据为空");
|
||||
}
|
||||
|
||||
// 新增服务包退款表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order['patient_id'];
|
||||
$data['order_service_id'] = $order_service_package['order_service_id'];
|
||||
$data['order_service_no'] = $order_service_package['order_service_no'];
|
||||
$data['service_refund_no'] = $refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order_service_package['payment_amount_total'];
|
||||
$data['refund_reason'] = "主动取消";
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
$order_service_package_refund = OrderServicePackageRefund::addOrderServicePackageRefund($data);
|
||||
if (empty($order_service_package_refund)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改订单表状态
|
||||
$data = array();
|
||||
$data['refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
OrderServicePackage::edit($params, $data);
|
||||
|
||||
break;
|
||||
default:
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单类型错误");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
// 医生专长
|
||||
if (!empty($expertise_id)) {
|
||||
$doctor_expertise_params['expertise_id'] = $expertise_id;
|
||||
}
|
||||
|
||||
// 固定医生查询条件
|
||||
$doctor_params['status'] = 1; // 状态(0:禁用 1:正常 2:删除)
|
||||
|
||||
$doctor_params["iden_auth_status"] = 1;// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
$doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是)
|
||||
|
||||
$fields = [
|
||||
"doctor_id",
|
||||
"user_id",
|
||||
"user_name",
|
||||
"multi_point_status",
|
||||
"is_bind_bank",
|
||||
"is_recommend",
|
||||
"avatar",
|
||||
"doctor_title",
|
||||
"department_custom_id",
|
||||
"department_custom_name",
|
||||
"hospital_id",
|
||||
"served_patients_num",
|
||||
"praise_rate",
|
||||
"avg_response_time",
|
||||
"number_of_fans",
|
||||
"be_good_at",
|
||||
];
|
||||
|
||||
$user_doctors = UserDoctor::getInquiryDoctorPageTest($keyword,$hospital_params, $doctor_params,$doctor_expertise_params,$is_search_welfare_reception,$is_first_online, $sort_order, ['*'],$page,$per_page);
|
||||
return success($user_doctors);
|
||||
return success();
|
||||
}
|
||||
}
|
||||
@ -94,4 +94,5 @@ class UserPatientController extends AbstractController
|
||||
return $this->response->json($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -22,25 +22,29 @@ class LockRequestMiddleware implements MiddlewareInterface
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$user_info = $request->getAttribute("userInfo");
|
||||
if (empty($user_info)){
|
||||
return $handler->handle($request);
|
||||
}
|
||||
try {
|
||||
$user_info = $request->getAttribute("userInfo");
|
||||
if (empty($user_info)){
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
// 获取请求路径
|
||||
$path_info = $request->getUri()->getPath();
|
||||
if (empty($path_info)){
|
||||
return $handler->handle($request);
|
||||
}
|
||||
// 获取请求路径
|
||||
$path_info = $request->getUri()->getPath();
|
||||
if (empty($path_info)){
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$redis_key = "lock_request_" . $path_info . $user_info['user_id'];
|
||||
$redis_lock = $redis->setnx($redis_key,1);
|
||||
// 设置过期时间
|
||||
$redis->expire($redis_key,1);
|
||||
if (!$redis_lock){
|
||||
// 设置失败,表示已经设置该值
|
||||
sleep(1);
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$redis_key = "lock_request_" . $path_info . $user_info['user_id'];
|
||||
$redis_lock = $redis->setnx($redis_key,1);
|
||||
// 设置过期时间
|
||||
$redis->expire($redis_key,1);
|
||||
if (!$redis_lock){
|
||||
// 设置失败,表示已经设置该值
|
||||
sleep(1);
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
// 异常不进行处理
|
||||
}
|
||||
|
||||
return $handler->handle($request);
|
||||
|
||||
@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
@ -37,8 +38,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $reissue_interval_days 确认收货后的再次发放间隔天数(如果设置为 0,则表示不再次发放。当适用范围为商品时生效)
|
||||
* @property int $is_reissuable_after_expire 过期之后是否允许再次发放(0:否 1:是)
|
||||
* @property int $is_popup 是否首页弹窗(0:否 1:是)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class Coupon extends Model
|
||||
{
|
||||
@ -110,4 +111,16 @@ class Coupon extends Model
|
||||
->whereIn("distribution_object",[1,2])
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取购买服务包的用户可领取的优惠卷列表
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getOrderServicePackageCouponList(): Collection|array
|
||||
{
|
||||
return self::where("coupon_client",1)
|
||||
->where("coupon_status",1)
|
||||
->whereIn("distribution_object",[7])
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,9 +115,10 @@ class DoctorAccountDay extends Model
|
||||
*/
|
||||
public static function getDoctorMonth(array $params,array $fields = ['*']): \Hyperf\Collection\Collection
|
||||
{
|
||||
return self::select(['month',Db::raw('SUM(total_amount) AS `total_amount`')])
|
||||
return self::select(['year','month',Db::raw('SUM(total_amount) AS `total_amount`')])
|
||||
->where($params)
|
||||
->groupBy(['month'])
|
||||
->groupBy(['year','month'])
|
||||
->orderBy('year')
|
||||
->orderBy('month')
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
81
app/Model/DoctorConfigDifficultConsultation.php
Normal file
81
app/Model/DoctorConfigDifficultConsultation.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $difficult_consultation_id 主键id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property string $service_content 服务内容
|
||||
* @property string $service_process 服务流程
|
||||
* @property int $service_period 服务周期
|
||||
* @property int $service_rounds 服务回合数(0表示不限次)
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorConfigDifficultConsultation extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'doctor_config_difficult_consultation';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['difficult_consultation_id', 'doctor_id', 'service_content', 'service_process', 'service_period', 'service_rounds', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "difficult_consultation_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return DoctorConfigDifficultConsultation|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addDoctorConfigDifficultConsultation(array $data): \Hyperf\Database\Model\Model|DoctorConfigDifficultConsultation
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
78
app/Model/DoctorConfigFollowPackage.php
Normal file
78
app/Model/DoctorConfigFollowPackage.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $follow_package_id 主键id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $monthly_frequency 每月次数(0表示不限次)
|
||||
* @property int $service_rounds 服务回合数(0表示不限次)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorConfigFollowPackage extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'doctor_config_follow_package';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['follow_package_id', 'doctor_id', 'monthly_frequency', 'service_rounds', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "follow_package_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return DoctorConfigFollowPackage|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addDoctorConfigFollowPackage(array $data): \Hyperf\Database\Model\Model|DoctorConfigFollowPackage
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
89
app/Model/DoctorConfigFollowPackageItem.php
Normal file
89
app/Model/DoctorConfigFollowPackageItem.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $follow_package_item_id 主键id
|
||||
* @property int $follow_package_id 医生随访包id
|
||||
* @property int $service_period 服务周期(天)
|
||||
* @property string $service_price 服务价格
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorConfigFollowPackageItem extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'doctor_config_follow_package_item';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['follow_package_item_id', 'follow_package_id', 'service_period', 'service_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "follow_package_item_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return DoctorConfigFollowPackageItem|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addDoctorConfigFollowPackageItem(array $data): \Hyperf\Database\Model\Model|DoctorConfigFollowPackageItem
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param array $params
|
||||
* @return int|mixed
|
||||
*/
|
||||
public static function del(array $params): mixed
|
||||
{
|
||||
return self::where($params)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getOrderServicePeriodList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->orderBy('service_period')->get($fields);
|
||||
}
|
||||
}
|
||||
79
app/Model/DoctorConfigHealthPackage.php
Normal file
79
app/Model/DoctorConfigHealthPackage.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $health_package_id 主键id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $package_id 健康包配置id
|
||||
* @property string $service_price 服务价格(根据图文问诊价格计算)
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorConfigHealthPackage extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'doctor_config_health_package';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['health_package_id', 'doctor_id', 'package_id', 'service_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "health_package_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return DoctorConfigHealthPackage|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addDoctorConfigHealthPackage(array $data): \Hyperf\Database\Model\Model|DoctorConfigHealthPackage
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
81
app/Model/DoctorIncomeRecord.php
Normal file
81
app/Model/DoctorIncomeRecord.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $income_record_id 主键id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $order_id 订单id
|
||||
* @property string $start_time 开始时间
|
||||
* @property string $end_time 结束时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorIncomeRecord extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'doctor_income_record';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['income_record_id', 'doctor_id', 'order_id', 'start_time', 'end_time', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "income_record_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return DoctorIncomeRecord|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addDoctorIncomeRecord(array $data): \Hyperf\Database\Model\Model|DoctorIncomeRecord
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@ -17,8 +18,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $service_process 服务流程
|
||||
* @property int $service_period 服务周期
|
||||
* @property int $service_rounds 服务回合数(0表示不限次)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DoctorInquiryConfigService extends Model
|
||||
{
|
||||
|
||||
@ -12,6 +12,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $withdrawal_order_id 主键id
|
||||
* @property int $withdrawal_id 提现表id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $order_inquiry_id 订单-问诊id
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
@ -28,7 +29,7 @@ class DoctorWithdrawalOrder extends Model
|
||||
/**
|
||||
* 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";
|
||||
|
||||
@ -64,4 +65,15 @@ class DoctorWithdrawalOrder extends Model
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
81
app/Model/HealthPackage.php
Normal file
81
app/Model/HealthPackage.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $package_id 主键id
|
||||
* @property int $service_count 总服务次数
|
||||
* @property int $monthly_frequency 每月次数
|
||||
* @property string $effective_days 服务有效天数
|
||||
* @property string $service_rate 服务费率。100为满值,表示1,正常费率。
|
||||
* @property string $discount_product_total_amount 折扣商品总价格
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class HealthPackage extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'health_package';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['package_id', 'service_count', 'monthly_frequency', 'effective_days', 'service_rate', 'discount_product_total_amount', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "package_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return HealthPackage|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addHealthPackage(array $data): \Hyperf\Database\Model\Model|HealthPackage
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
81
app/Model/HealthPackageProduct.php
Normal file
81
app/Model/HealthPackageProduct.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $package_product_id 主键id
|
||||
* @property int $package_id 健康包id
|
||||
* @property int $product_id 商品id
|
||||
* @property string $product_name 商品名称
|
||||
* @property int $quantity 数量
|
||||
* @property string $discount_product_price 折扣商品价格
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class HealthPackageProduct extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'health_package_product';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['package_product_id', 'package_id', 'product_id', 'product_name', 'quantity', 'discount_product_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "package_product_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return HealthPackageProduct|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addHealthPackageProduct(array $data): \Hyperf\Database\Model\Model|HealthPackageProduct
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
83
app/Model/LogIdCard.php
Normal file
83
app/Model/LogIdCard.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $log_id 主键id
|
||||
* @property string $name 姓名
|
||||
* @property string $card_no 身份证号
|
||||
* @property int $status 认证结果,1-通过 2-不通过(原因见reasonType) 0-待定
|
||||
* @property string $data_id 用户侧唯一标识
|
||||
* @property string $task_id 服务侧唯一标识
|
||||
* @property string $content 返回内容,json格式
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class LogIdCard extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'log_id_card';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['log_id', 'name', 'card_no', 'status', 'data_id', 'task_id', 'content', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "log_id";
|
||||
|
||||
/**
|
||||
* 获取数据-单
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param array $params
|
||||
* @param array $data
|
||||
* @return int
|
||||
*/
|
||||
public static function edit(array $params = [], array $data = []): int
|
||||
{
|
||||
return self::where($params)->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return LogIdCard|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addLogIdCard(array $data): LogIdCard|\Hyperf\Database\Model\Model
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
}
|
||||
354
app/Model/Order.php
Normal file
354
app/Model/Order.php
Normal file
@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_id 主键id
|
||||
* @property int $user_id 用户id-患者
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $doctor_id 医生id(存在为null的情况)
|
||||
* @property int $order_type 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
* @property int $is_delete 删除状态(0:否 1:是)
|
||||
* @property int $pay_channel 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
* @property int $pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
* @property string $pay_time 支付时间
|
||||
* @property int $refund_status 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
* @property string $order_no 系统订单编号
|
||||
* @property string $escrow_trade_no 第三方支付流水号
|
||||
* @property string $amount_total 订单金额
|
||||
* @property string $coupon_amount_total 优惠卷总金额
|
||||
* @property string $payment_amount_total 实际付款金额
|
||||
* @property int $cancel_status 取消状态(0:否 1:是)
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property string $cancel_remarks 取消订单备注
|
||||
* @property string $order_remarks 订单备注
|
||||
* @property int $is_withdrawal 是否提现(0:否 1:是 2:提现中 3:无需提现)
|
||||
* @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
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order';
|
||||
|
||||
/**
|
||||
* 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', 'is_withdrawal', 'withdrawal_time', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_id";
|
||||
|
||||
/**
|
||||
* 关联问诊订单表
|
||||
*/
|
||||
public function OrderInquiry(): HasOne
|
||||
{
|
||||
return $this->hasOne(OrderInquiry::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联服务包订单表
|
||||
*/
|
||||
public function OrderServicePackage(): HasOne
|
||||
{
|
||||
return $this->hasOne(OrderServicePackage::class, 'order_id', 'order_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return Order|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrder(array $data): \Hyperf\Database\Model\Model|Order
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生某一时间段收益明细分页数据
|
||||
* @param string|int $doctor_id
|
||||
* @param array $date_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 getDoctorCreatedDateOrderInquiryPage(string|int $doctor_id, array $date_params,string|int $is_platform_deep_cooperation,array $fields = ["*"], int $page = null, ?int $per_page = 10): array
|
||||
{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
|
||||
$query = self::with(['OrderInquiry', 'OrderServicePackage'])
|
||||
->whereIn('order_type',[1,4,5])
|
||||
->where($params);
|
||||
|
||||
// 问诊订单
|
||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation,$doctor_id){
|
||||
$query->whereExists(function ($subQuery) use ($date_params,$is_platform_deep_cooperation,$doctor_id){
|
||||
$subQuery->from('order_inquiry');
|
||||
if ($is_platform_deep_cooperation == 1){
|
||||
$subQuery->whereNotIn('inquiry_type', [2,4]);
|
||||
}
|
||||
|
||||
$subQuery->where('doctor_id', $doctor_id)
|
||||
->whereNotIn('inquiry_mode', [7,8,9])
|
||||
->where('doctor_id', $doctor_id)
|
||||
->whereIn('inquiry_status', [6])
|
||||
->whereBetween('reception_time', $date_params)
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||
})
|
||||
->orWhereExists(function ($subQuery) use ($date_params,$doctor_id) {
|
||||
$subQuery->from('order_service_package');
|
||||
|
||||
$subQuery->where('doctor_id', $doctor_id)
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||
->whereIn('order_service_status', [3,4,5])
|
||||
->whereBetween('start_time', $date_params);
|
||||
});
|
||||
});
|
||||
|
||||
$result = $query->orderBy('created_at')->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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生当日预计的订单金额
|
||||
* @param array $params
|
||||
* @param array $date_params 时间区间
|
||||
* @param string|int $is_platform_deep_cooperation
|
||||
* @return 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)
|
||||
->whereIn('order_type',[1,4,5]);
|
||||
|
||||
// 问诊订单
|
||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
||||
$query->whereExists(function ($subQuery) use ($date_params,$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', [4,5])
|
||||
->whereBetween('reception_time', $date_params)
|
||||
->where('inquiry_refund_status', 0)
|
||||
->where('inquiry_pay_status', 2)
|
||||
->where('is_withdrawal', 0)
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||
})
|
||||
->orWhereExists(function ($subQuery) use ($date_params) {
|
||||
$subQuery->from('order_service_package')
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||
->whereIn('order_service_status', [3])
|
||||
->whereBetween('start_time', $date_params)
|
||||
->where('refund_status', 0)
|
||||
->where('pay_status', 2);
|
||||
});
|
||||
});
|
||||
|
||||
$result = $query->orderBy('created_at')
|
||||
->sum("amount_total");;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生当日已完成待入帐的订单金额
|
||||
* @param array $params
|
||||
* @param array $date_params 时间区间
|
||||
* @param string|int $is_platform_deep_cooperation
|
||||
* @return 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)
|
||||
->whereIn('order_type',[1,4,5]);
|
||||
|
||||
// 问诊订单
|
||||
$query = $query->where(function ($query) use ($date_params,$is_platform_deep_cooperation){
|
||||
$query->whereExists(function ($subQuery) use ($date_params,$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', [5])
|
||||
->whereBetween('reception_time', $date_params)
|
||||
->where('inquiry_refund_status', 0)
|
||||
->where('inquiry_pay_status', 2)
|
||||
->where('is_withdrawal', 0)
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_inquiry.order_id');
|
||||
})
|
||||
->orWhereExists(function ($subQuery) use ($date_params) {
|
||||
$subQuery->from('order_service_package')
|
||||
->whereRaw('gdxz_order.order_id = gdxz_order_service_package.order_id')
|
||||
->whereIn('order_service_status', [3])
|
||||
->where('finish_time','>', $date_params[0])
|
||||
->where('refund_status', 0)
|
||||
->where('pay_status', 2);
|
||||
});
|
||||
});
|
||||
|
||||
$result = $query->orderBy('created_at')
|
||||
->sum("amount_total");;
|
||||
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 getDoctorWithdrawalOrderPage(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)
|
||||
->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->orderBy('created_at')
|
||||
->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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可提现订单列表
|
||||
* @param array $params
|
||||
* @param string|int $is_platform_deep_cooperation
|
||||
* @param array $fields
|
||||
* @return array|Collection|\Hyperf\Collection\Collection
|
||||
*/
|
||||
public static function getDoctorWithdrawalOrderList(array $params, string|int $is_platform_deep_cooperation,array $fields = ["*"]): array|Collection|\Hyperf\Collection\Collection
|
||||
{
|
||||
$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)
|
||||
->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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return $query->orderBy('created_at')->get($fields);
|
||||
}
|
||||
}
|
||||
80
app/Model/OrderCoupon.php
Normal file
80
app/Model/OrderCoupon.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_coupon_id 主键id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $user_coupon_id 用户优惠卷表id
|
||||
* @property string $coupon_name 优惠卷名称
|
||||
* @property string $coupon_use_price 优惠卷使用金额
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderCoupon extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_coupon';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_coupon_id', 'order_id', 'user_coupon_id', 'coupon_name', 'coupon_use_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_coupon_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderCoupon|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderCoupon(array $data): \Hyperf\Database\Model\Model|OrderCoupon
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_detection_id 主键id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $user_id 用户id-患者
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $doctor_id 医生id
|
||||
@ -58,7 +59,7 @@ class OrderDetection extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_detection_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'detection_project_id', 'purpose_id', 'detection_organ_id', 'order_inquiry_id', 'detection_status', 'is_delete', 'detection_refund_status', 'detection_pay_channel', 'detection_pay_status', 'detection_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'detection_bar_code', 'detection_pic', 'detection_time', 'detection_result_pdf', 'detection_result_date', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_detection_id', 'order_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'detection_project_id', 'purpose_id', 'detection_organ_id', 'order_inquiry_id', 'detection_status', 'is_delete', 'detection_refund_status', 'detection_pay_channel', 'detection_pay_status', 'detection_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'detection_bar_code', 'detection_pic', 'detection_time', 'detection_result_pdf', 'detection_result_date', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_detection_id";
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Database\Query\Builder;
|
||||
@ -13,6 +14,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_inquiry_id 主键id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $user_id 用户id-患者
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $doctor_id 医生id(未分配时为null)
|
||||
@ -46,9 +48,9 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read UserDoctor|null $UserDoctor
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
* @property-read UserDoctor|null $UserDoctor
|
||||
* @property-read OrderInquiryCase|null $OrderInquiryCase
|
||||
*/
|
||||
class OrderInquiry extends Model
|
||||
@ -63,7 +65,7 @@ class OrderInquiry extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_inquiry_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'inquiry_type', 'inquiry_mode', 'inquiry_status', 'is_delete', 'inquiry_refund_status', 'inquiry_pay_channel', 'inquiry_pay_status', 'inquiry_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'reception_time', 'complete_time', 'finish_time', 'statistics_status', 'statistics_time', 'is_withdrawal', 'withdrawal_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'times_number', 'duration', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_inquiry_id', 'order_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'inquiry_type', 'inquiry_mode', 'inquiry_status', 'is_delete', 'inquiry_refund_status', 'inquiry_pay_channel', 'inquiry_pay_status', 'inquiry_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'reception_time', 'complete_time', 'finish_time', 'statistics_status', 'statistics_time', 'is_withdrawal', 'withdrawal_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'times_number', 'duration', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_inquiry_id";
|
||||
|
||||
@ -232,40 +234,13 @@ class OrderInquiry extends Model
|
||||
* 已结束
|
||||
* @param array $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 $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @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)
|
||||
->whereIn('inquiry_status', $inquiry_status_params)
|
||||
@ -290,11 +265,15 @@ class OrderInquiry extends Model
|
||||
* @param array $params
|
||||
* @param array $reception_time 接诊时间区间
|
||||
* @param array $inquiry_status_params inquiry_status字段搜索条件
|
||||
* @param array $inquiry_type_not_params
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getDoctorAmountTotal(array $params, array $reception_time, array $inquiry_status_params): mixed
|
||||
public static function getDoctorAmountTotal(array $params, array $reception_time, array $inquiry_status_params,array $inquiry_type_not_params = []): mixed
|
||||
{
|
||||
return self::where($params)
|
||||
->when($inquiry_type_not_params, function ($query, $inquiry_type_not_params) {
|
||||
$query->whereNotIn('inquiry_type', $inquiry_type_not_params);
|
||||
})
|
||||
->whereIn('inquiry_status', $inquiry_status_params)
|
||||
->whereBetween('reception_time', $reception_time)
|
||||
->orderBy('reception_time')
|
||||
@ -306,6 +285,7 @@ class OrderInquiry extends Model
|
||||
* @param array $params
|
||||
* @param array $reception_time 接诊时间区间
|
||||
* @param array $inquiry_status_params inquiry_status字段搜索条件
|
||||
* @param array $inquiry_type_not_params
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getCooperationDoctorAmountTotal(array $params, array $reception_time, array $inquiry_status_params,array $inquiry_type_not_params = []): mixed
|
||||
@ -611,4 +591,46 @@ class OrderInquiry extends Model
|
||||
->latest()
|
||||
->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者某一时间段问诊订单-创建时间
|
||||
* @param array $params
|
||||
* @param array $created_at 接诊时间区间
|
||||
* @param array $inquiry_status_params inquiry_status字段搜索条件
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getInquiryWithCreateTime(array $params, array $created_at, array $inquiry_status_params): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereIn('inquiry_status', $inquiry_status_params)
|
||||
->whereBetween('created_at', $created_at)
|
||||
->orderBy('created_at')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生每月账单数据
|
||||
* @param array $params
|
||||
* @param string $year
|
||||
* @param string|int $is_platform_deep_cooperation
|
||||
* @param array $fields
|
||||
* @return \Hyperf\Collection\Collection
|
||||
*/
|
||||
public static function getMonthlyGroupBill(array $params, string $year,string|int $is_platform_deep_cooperation,array $fields = ["*"]): \Hyperf\Collection\Collection
|
||||
{
|
||||
$query = self::select([Db::raw('YEAR(reception_time) AS `year`') ,Db::raw('MONTH(reception_time) AS `month`')])
|
||||
->where($params)
|
||||
->whereNotIn('inquiry_mode', [7,8,9])
|
||||
->whereIn('inquiry_status', [6])
|
||||
->where(Db::raw('YEAR(reception_time)'), $year);
|
||||
|
||||
if ($is_platform_deep_cooperation == 1){
|
||||
$query->whereNotIn('inquiry_type', [2,4]);
|
||||
}
|
||||
|
||||
$result = $query->groupBy([Db::raw('YEAR(reception_time)'),Db::raw('MONTH(reception_time)')])
|
||||
->get($fields);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasMany;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
@ -15,6 +16,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $order_product_id 主键id
|
||||
* @property int $order_inquiry_id 订单-问诊id
|
||||
* @property int $order_prescription_id 订单-处方id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $family_id 家庭成员id(就诊用户)
|
||||
@ -53,12 +55,12 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $consignee_name_mask 收货人姓名(掩码)
|
||||
* @property string $consignee_tel 收货人电话
|
||||
* @property string $consignee_tel_mask 收货人电话(掩码)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
* @property-read Collection|OrderProductItem[]|null $OrderProductItem
|
||||
* @property-read OrderPrescription|null $OrderPrescription
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderPrescriptionIcd[]|null $OrderPrescriptionIcd
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderProductItem[]|null $OrderProductItem
|
||||
* @property-read PatientFamily|null $PatientFamily
|
||||
* @property-read Collection|OrderPrescriptionIcd[]|null $OrderPrescriptionIcd
|
||||
*/
|
||||
class OrderProduct extends Model
|
||||
{
|
||||
@ -72,7 +74,7 @@ class OrderProduct extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'logistics_company_code', 'sub_logistics_status', 'delivery_time', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'report_pre_status', 'report_pre_time', 'report_pre_fail_reason', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'order_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'logistics_company_code', 'sub_logistics_status', 'delivery_time', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'report_pre_status', 'report_pre_time', 'report_pre_fail_reason', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_product_id";
|
||||
|
||||
@ -238,4 +240,20 @@ class OrderProduct extends Model
|
||||
return self::where($params)->whereIn('order_product_status',$order_product_status)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者某一时间段药品订单-创建时间
|
||||
* @param array $params
|
||||
* @param array $created_at 接诊时间区间
|
||||
* @param array $order_product_status
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getProductWithCreateTime(array $params, array $created_at,array $order_product_status): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereIn('order_product_status', $order_product_status)
|
||||
->whereBetween('created_at', $created_at)
|
||||
->orderBy('created_at')
|
||||
->get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
86
app/Model/OrderRefund.php
Normal file
86
app/Model/OrderRefund.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_refund_id 主键id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $patient_id 患者id
|
||||
* @property string $order_no 系统订单编号
|
||||
* @property string $refund_no 系统退款编号
|
||||
* @property string $refund_id 第三方退款单号
|
||||
* @property int $refund_status 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
* @property string $refund_total 退款金额
|
||||
* @property string $refund_reason 退款原因
|
||||
* @property string $success_time 退款成功时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderRefund extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_refund';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_refund_id', 'order_id', 'patient_id', 'order_no', 'refund_no', 'refund_id', 'refund_status', 'refund_total', 'refund_reason', 'success_time', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_refund_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderRefund|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderRefund(array $data): \Hyperf\Database\Model\Model|OrderRefund
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
239
app/Model/OrderServicePackage.php
Normal file
239
app/Model/OrderServicePackage.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_service_id 主键id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $user_id 用户id-患者
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $family_id 家庭成员id(就诊用户)
|
||||
* @property int $order_service_type 服务包类型(1:健康包 2:随访包)
|
||||
* @property int $order_service_status 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
* @property int $is_delete 删除状态(0:否 1:是)
|
||||
* @property int $refund_status 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
* @property int $pay_channel 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
* @property int $pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
* @property string $order_service_no 系统订单编号
|
||||
* @property string $escrow_trade_no 第三方支付流水号
|
||||
* @property string $amount_total 订单金额
|
||||
* @property string $coupon_amount_total 优惠卷总金额
|
||||
* @property string $payment_amount_total 实际付款金额
|
||||
* @property string $pay_time 支付时间
|
||||
* @property string $start_time 开始服务时间
|
||||
* @property string $finish_time 结束服务时间
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property int $cancel_reason 取消订单原因(1:医生未接受服务 2:主动取消 4:客服取消 5:支付超时)
|
||||
* @property string $cancel_remarks 取消订单备注
|
||||
* @property int $add_finish_status 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||||
* @property string $add_finish_time 添加完成订单延迟队列时间
|
||||
* @property string $add_finish_fail_reason 添加完成订单延迟队列失败原因
|
||||
* @property string $patient_name 患者姓名-就诊人
|
||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read OrderServicePackageCase|null $OrderServicePackageCase
|
||||
*/
|
||||
class OrderServicePackage extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_service_id', 'order_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'order_service_type', 'order_service_status', 'is_delete', 'refund_status', 'pay_channel', 'pay_status', 'order_service_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'start_time', 'finish_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'add_finish_status', 'add_finish_time', 'add_finish_fail_reason', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_service_id";
|
||||
|
||||
/**
|
||||
* 关联服务包病例表
|
||||
*/
|
||||
public function OrderServicePackageCase(): HasOne
|
||||
{
|
||||
return $this->hasOne(OrderServicePackageCase::class, 'order_service_id', 'order_service_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackage|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackage(array $data): \Hyperf\Database\Model\Model|OrderServicePackage
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某一状态下的订单-多条
|
||||
* @param array $params
|
||||
* @param array $order_service_status
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getStatusList(array $params = [],array $order_service_status = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->whereIn('order_service_status',$order_service_status)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某一状态下的订单-单条
|
||||
* @param array $params
|
||||
* @param array $order_service_status
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getStatusOne(array $params = [],array $order_service_status = [], array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->whereIn('order_service_status',$order_service_status)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单-分页
|
||||
* @param array $params
|
||||
* @param array $order_service_status_params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
* @return int|mixed|string
|
||||
*/
|
||||
public static function getPatientOrderServicePage(array $params, array $order_service_status_params, array $fields = ["*"], int $page = null, ?int $per_page = 10): mixed
|
||||
{
|
||||
$raw = self::with([
|
||||
'OrderServicePackageCase:order_service_case_id,order_service_id,disease_desc',
|
||||
])
|
||||
->where($params)
|
||||
->when($order_service_status_params, function ($query, $order_service_status_params) {
|
||||
$query->whereIn('order_service_status', $order_service_status_params);
|
||||
})
|
||||
->orderBy('created_at', '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 $order_service_status_params
|
||||
* @param array $finish_time_params 结束时间区间
|
||||
* @return 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生当日的服务包订单
|
||||
* @param array $params
|
||||
* @param array $order_service_status_params
|
||||
* @param array $start_time_params 开始时间区间
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getDoctorDayOrderServiceWithStartTime(array $params, array $order_service_status_params,array $start_time_params): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereIn('order_service_status',$order_service_status_params)
|
||||
->whereIn('refund_status',[0,4,5])
|
||||
->whereBetween('start_time', $start_time_params)
|
||||
->orderBy('start_time')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生当日未结束的服务包订单
|
||||
* @param array $params
|
||||
* @param array $order_service_status_params
|
||||
* @param string $finish_time_params 当前时间
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getDoctorDayNoFinishOrderService(array $params, array $order_service_status_params,string $finish_time_params): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereIn('order_service_status',$order_service_status_params)
|
||||
->whereIn('refund_status',[0,4,5])
|
||||
->where('finish_time','>', $finish_time_params)
|
||||
->orderBy('start_time')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生每月账单数据
|
||||
* @param array $params
|
||||
* @param string $year
|
||||
* @param array $fields
|
||||
* @return \Hyperf\Collection\Collection
|
||||
*/
|
||||
public static function getMonthlyGroupBill(array $params, string $year,array $fields = ["*"]): \Hyperf\Collection\Collection
|
||||
{
|
||||
return self::select([Db::raw('YEAR(start_time) AS `year`') ,Db::raw('MONTH(start_time) AS `month`')])
|
||||
->where($params)
|
||||
->whereIn('order_service_status', [3,4,5])
|
||||
->where(Db::raw('YEAR(start_time)'), $year)
|
||||
->groupBy([Db::raw('YEAR(start_time)'),Db::raw('MONTH(start_time)')])
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
97
app/Model/OrderServicePackageCase.php
Normal file
97
app/Model/OrderServicePackageCase.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_service_case_id 主键id
|
||||
* @property int $user_id 用户id
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $order_service_id 订单-服务包id
|
||||
* @property int $family_id 家庭成员id
|
||||
* @property int $disease_class_id 疾病分类id-系统
|
||||
* @property int $relation 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||||
* @property int $status 状态(1:正常 2:删除)
|
||||
* @property string $name 患者名称
|
||||
* @property int $sex 患者性别(0:未知 1:男 2:女)
|
||||
* @property int $age 患者年龄
|
||||
* @property string $disease_class_name 疾病名称-系统
|
||||
* @property string $diagnosis_date 确诊日期
|
||||
* @property string $disease_desc 病情描述(主诉)
|
||||
* @property string $diagnose_images 复诊凭证(多个使用逗号分隔)
|
||||
* @property int $is_allergy_history 是否存在过敏史(0:否 1:是)
|
||||
* @property string $allergy_history 过敏史描述
|
||||
* @property int $is_family_history 是否存在家族病史(0:否 1:是)
|
||||
* @property string $family_history 家族病史描述
|
||||
* @property int $is_pregnant 是否备孕、妊娠、哺乳期(0:否 1:是)
|
||||
* @property string $pregnant 备孕、妊娠、哺乳期描述
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderServicePackageCase extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package_case';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_service_case_id', 'user_id', 'patient_id', 'order_id', 'order_service_id', 'family_id', 'disease_class_id', 'relation', 'status', 'name', 'sex', 'age', 'disease_class_name', 'diagnosis_date', 'disease_desc', 'diagnose_images', 'is_allergy_history', 'allergy_history', 'is_family_history', 'family_history', 'is_pregnant', 'pregnant', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_service_case_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackageCase|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackageCase(array $data): \Hyperf\Database\Model\Model|OrderServicePackageCase
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
86
app/Model/OrderServicePackageDetail.php
Normal file
86
app/Model/OrderServicePackageDetail.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_service_detail_id 主键id
|
||||
* @property int $order_service_id 服务包订单id
|
||||
* @property int $order_id 订单id
|
||||
* @property int $package_id 健康包配置id(随访包时为空)
|
||||
* @property string $order_service_no 系统订单编号
|
||||
* @property int $service_period 服务周期(天)
|
||||
* @property int $service_count 总服务次数(0表示不限次)
|
||||
* @property int $monthly_frequency 每月次数(0表示不限次)
|
||||
* @property string $single_inquiry_price 单次图文问诊价格
|
||||
* @property string $service_price 总服务价格
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderServicePackageDetail extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package_detail';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_service_detail_id', 'order_service_id', 'order_id', 'package_id', 'order_service_no', 'service_period', 'service_count', 'monthly_frequency', 'single_inquiry_price', 'service_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_service_detail_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackageDetail|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackageDetail(array $data): \Hyperf\Database\Model\Model|OrderServicePackageDetail
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
80
app/Model/OrderServicePackageInquiry.php
Normal file
80
app/Model/OrderServicePackageInquiry.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $service_inquiry_id 主键id
|
||||
* @property int $order_service_id 订单-服务包id
|
||||
* @property int $order_inquiry_id 订单-问诊id
|
||||
* @property string $order_service_no 服务包系统订单编号
|
||||
* @property string $inquiry_no 问诊系统订单编号
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderServicePackageInquiry extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package_inquiry';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['service_inquiry_id', 'order_service_id', 'order_inquiry_id', 'order_service_no', 'inquiry_no', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "service_inquiry_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackageInquiry|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackageInquiry(array $data): \Hyperf\Database\Model\Model|OrderServicePackageInquiry
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
92
app/Model/OrderServicePackageProduct.php
Normal file
92
app/Model/OrderServicePackageProduct.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $service_product_id 主键id
|
||||
* @property int $order_service_id 订单-服务包id
|
||||
* @property int $order_product_id 订单-商品id
|
||||
* @property string $order_product_no 订单-商品系统编号
|
||||
* @property int $product_item_id 订单-商品明细id
|
||||
* @property int $product_id 商品id
|
||||
* @property int $used_quantity 订单使用数量
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderServicePackageProduct extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package_product';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['service_product_id', 'order_service_id', 'order_product_id', 'order_product_no', 'product_item_id', 'product_id', 'used_quantity', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "service_product_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackageProduct|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackageProduct(array $data): \Hyperf\Database\Model\Model|OrderServicePackageProduct
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param array $params
|
||||
* @return int|mixed
|
||||
*/
|
||||
public static function deleteOrderServicePackageProduct(array $params): mixed
|
||||
{
|
||||
return self::where($params)->delete();
|
||||
}
|
||||
}
|
||||
87
app/Model/OrderServicePackageRefund.php
Normal file
87
app/Model/OrderServicePackageRefund.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $service_refund_id 主键id
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $order_service_id 订单-服务包id
|
||||
* @property string $order_service_no 系统订单编号
|
||||
* @property string $service_refund_no 系统退款编号
|
||||
* @property string $refund_id 第三方退款单号
|
||||
* @property int $refund_status 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
* @property string $refund_total 退款金额
|
||||
* @property string $product_refund_total 药品退款金额
|
||||
* @property string $inquiry_refund_total 问诊退款金额
|
||||
* @property string $refund_reason 退款原因
|
||||
* @property string $success_time 退款成功时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderServicePackageRefund extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_service_package_refund';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['service_refund_id', 'patient_id', 'order_service_id', 'order_service_no', 'service_refund_no', 'refund_id', 'refund_status', 'refund_total', 'product_refund_total', 'inquiry_refund_total', 'refund_reason', 'success_time', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "service_refund_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderServicePackageRefund|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderServicePackageRefund(array $data): \Hyperf\Database\Model\Model|OrderServicePackageRefund
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
@ -29,8 +30,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $report_prescription_int 处方上报次数
|
||||
* @property string $report_prescription_time 处方上报时间
|
||||
* @property string $report_prescription_fail_reason 处方上报失败原因
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class ReportRegulatory extends Model
|
||||
{
|
||||
|
||||
@ -15,6 +15,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
* @property int $default_work_num_day 默认每日接诊数量
|
||||
* @property int $max_work_num_day 每日最大接诊数量
|
||||
* @property int $min_work_num_day 每日最小接诊数量
|
||||
* @property string $inquiry_price 接诊价格
|
||||
* @property string $min_inquiry_price 最低接诊价格(专家问诊)
|
||||
* @property string $max_inquiry_price 最高接诊价格(专家问诊)
|
||||
@ -35,12 +36,12 @@ class SystemInquiryConfig extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['system_inquiry_config_id', 'inquiry_type', 'inquiry_mode', 'default_work_num_day', 'max_work_num_day', 'inquiry_price', 'min_inquiry_price', 'max_inquiry_price', 'times_number', 'duration', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['system_inquiry_config_id', 'inquiry_type', 'inquiry_mode', 'default_work_num_day', 'max_work_num_day', 'min_work_num_day', 'inquiry_price', 'min_inquiry_price', 'max_inquiry_price', 'times_number', 'duration', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['system_inquiry_config_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'max_work_num_day' => 'integer', 'times_number' => 'integer', 'duration' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'default_work_num_day' => 'integer'];
|
||||
protected array $casts = ['system_inquiry_config_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'max_work_num_day' => 'integer', 'times_number' => 'integer', 'duration' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'default_work_num_day' => 'integer', 'min_work_num_day' => 'integer'];
|
||||
|
||||
protected string $primaryKey = "system_inquiry_config_id";
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
@ -19,8 +20,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $coupon_use_date 使用时间
|
||||
* @property string $valid_start_time 开始使用时间
|
||||
* @property string $valid_end_time 过期使用时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
* @property-read Coupon $Coupon
|
||||
*/
|
||||
class UserCoupon extends Model
|
||||
@ -61,7 +62,6 @@ class UserCoupon extends Model
|
||||
/**
|
||||
* 获取优惠卷信息-多条
|
||||
* @param array $params
|
||||
* @param array $coupon_params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
@ -132,7 +132,7 @@ class UserCoupon extends Model
|
||||
* @param array $fields 字段
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getUserProductUsableCoupon(string|int $user_id,array $coupon_product_datas,array $fields = ['*']): Collection|array
|
||||
public static function getUserProductUsableCoupon(string|int $user_id,array $coupon_product_datas = [],array $fields = ['*']): Collection|array
|
||||
{
|
||||
$params = array();
|
||||
$params[] = ['user_id', '=', $user_id];
|
||||
@ -144,12 +144,12 @@ class UserCoupon extends Model
|
||||
->whereHas('Coupon', function ($query) use ($coupon_product_datas) {
|
||||
$query->where("coupon_client",1)
|
||||
->where("coupon_status",1)
|
||||
->whereIn("application_scope",[1,3,4,5])
|
||||
->where(function ($query) use ($coupon_product_datas) {
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
|
||||
}
|
||||
});
|
||||
->whereIn("application_scope",[1,3,4,5,6]);
|
||||
// ->when(function ($query) use ($coupon_product_datas) {
|
||||
// foreach ($coupon_product_datas as $coupon_product_data){
|
||||
// $query->orwhere("product_id","=",$coupon_product_data['product_id']);
|
||||
// }
|
||||
// });
|
||||
})
|
||||
->where($params)
|
||||
->groupBy("coupon_id")
|
||||
@ -184,4 +184,45 @@ class UserCoupon extends Model
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者某一类型下的全部优惠卷
|
||||
* @param string|int $user_id
|
||||
* @param int $distribution_object
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getUserAllObjectTypeCoupon(string|int $user_id,int $distribution_object,array $fields = ['*']): Collection|array
|
||||
{
|
||||
$params = array();
|
||||
$params[] = ['user_id', '=', $user_id];
|
||||
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
||||
$params[] = ['valid_end_time', '>', date('Y-m-d H:i:s', time())]; // 过期使用时间
|
||||
|
||||
return self::with(['Coupon'])
|
||||
->whereHas('Coupon', function ($query) use ($distribution_object) {
|
||||
$query->where("coupon_client",1)
|
||||
->where("coupon_status",1)
|
||||
->where(function ($query) use ($distribution_object) {
|
||||
$query->orwhere("distribution_object",$distribution_object);
|
||||
});
|
||||
})
|
||||
->where($params)
|
||||
->groupBy("coupon_id")
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者今日过期优惠卷
|
||||
* @param array $params
|
||||
* @param array $valid_end_time
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getUserTodayExpiredCoupon(array $params,array $valid_end_time,array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
// ->where('valid_start_time',">=","2024-05-01 00:00:00") // 此处是为了区分于1.3版本上线前的优惠卷
|
||||
->whereBetween('valid_end_time', $valid_end_time)
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +282,6 @@ class UserDoctor extends Model
|
||||
// $query->where($params);
|
||||
// });
|
||||
|
||||
|
||||
if ($is_first_online == 1){
|
||||
$query->join('user as u', function ($query) {
|
||||
$query->on('user_doctor.user_id', '=', 'u.user_id');
|
||||
@ -291,49 +290,38 @@ class UserDoctor extends Model
|
||||
->orderBy('u.is_online', 'desc');
|
||||
}
|
||||
|
||||
if (!empty($sort_order)){
|
||||
// if (in_array($sort_order,[1,3,4])){
|
||||
// $query = $query->join('doctor_inquiry_config', function ($query) {
|
||||
// $query->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id')
|
||||
// ->whereIn('inquiry_type', [1, 3])
|
||||
// ->whereIn('inquiry_mode', [1,2,6,7])
|
||||
// ->orderBy('inquiry_price', 'desc')
|
||||
// ->take(1);
|
||||
// })
|
||||
// ->select("user_doctor.*")
|
||||
// ->groupBy("user_doctor.doctor_id");
|
||||
// }
|
||||
|
||||
// select doctor_id, min(price) price_min from price group by doctor_id
|
||||
if (in_array($sort_order,[1,3,4])){
|
||||
$raw = "inquiry_price as min_inquiry_price";
|
||||
if ($sort_order == 1){
|
||||
// 综合-价格从低到高
|
||||
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||
} elseif ($sort_order == 3){
|
||||
// 价格从低到高
|
||||
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||
} elseif ($sort_order == 4){
|
||||
// 价格从高到低
|
||||
$raw = "MAX(inquiry_price) as min_inquiry_price";
|
||||
}
|
||||
|
||||
$latestPosts = Db::table('doctor_inquiry_config')
|
||||
->select('doctor_inquiry_config.doctor_id', Db::raw($raw))
|
||||
->where('is_enable', 1);
|
||||
if (!empty($inquiry_type)){
|
||||
$latestPosts = $latestPosts->whereIn('inquiry_type', $inquiry_type)
|
||||
->whereIn('inquiry_mode',$inquiry_mode);
|
||||
}
|
||||
|
||||
$latestPosts = $latestPosts->groupBy(["doctor_inquiry_config.doctor_id"]);
|
||||
|
||||
$query = $query
|
||||
->joinSub($latestPosts, 'doctor_inquiry_config', function($join) {
|
||||
$join->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id');
|
||||
});
|
||||
// 问诊服务搜索
|
||||
// select doctor_id, min(price) price_min from price group by doctor_id
|
||||
$raw = "inquiry_price as min_inquiry_price";
|
||||
if (!empty($sort_order) && in_array($sort_order,[1,3,4])){
|
||||
if ($sort_order == 1){
|
||||
// 综合-价格从低到高
|
||||
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||
} elseif ($sort_order == 3){
|
||||
// 价格从低到高
|
||||
$raw = "MIN(inquiry_price) as min_inquiry_price";
|
||||
} elseif ($sort_order == 4){
|
||||
// 价格从高到低
|
||||
$raw = "MAX(inquiry_price) as min_inquiry_price";
|
||||
}
|
||||
}
|
||||
|
||||
$latestPosts = Db::table('doctor_inquiry_config')
|
||||
->select('doctor_inquiry_config.doctor_id', Db::raw($raw))
|
||||
->where('is_enable', 1);
|
||||
if (!empty($inquiry_type)){
|
||||
$latestPosts = $latestPosts->whereIn('inquiry_type', $inquiry_type)
|
||||
->whereIn('inquiry_mode',$inquiry_mode);
|
||||
}
|
||||
|
||||
$latestPosts = $latestPosts->groupBy(["doctor_inquiry_config.doctor_id"]);
|
||||
|
||||
$query = $query
|
||||
->joinSub($latestPosts, 'doctor_inquiry_config', function($join) {
|
||||
$join->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id');
|
||||
});
|
||||
|
||||
if (!empty($sort_order)){
|
||||
if ($sort_order == 1) {
|
||||
// 综合-价格从低到高
|
||||
$query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是)
|
||||
@ -403,7 +391,7 @@ class UserDoctor extends Model
|
||||
->get();
|
||||
|
||||
dump($doctors->toArray());
|
||||
return $doctors;
|
||||
return array();
|
||||
|
||||
// $query = self::orderBy('served_patients_num', 'desc');
|
||||
//
|
||||
|
||||
@ -19,11 +19,8 @@ class DoctorAccountRequest extends FormRequest
|
||||
'getDoctorWithdrawalRecordList' => [ // 获取医生提现记录列表
|
||||
'year',
|
||||
],
|
||||
'getDoctorWithdrawalInfo' => [ // 获取提现数据
|
||||
'order_inquiry_ids',
|
||||
],
|
||||
'addDoctorWithdrawal' => [ // 发起提现
|
||||
'order_inquiry_id',
|
||||
'order_no',
|
||||
'withdrawal_amount_total',
|
||||
'bank_card_id',
|
||||
],
|
||||
|
||||
@ -11,6 +11,10 @@ use Hyperf\Validation\Rule;
|
||||
class DoctorInquiryConfigRequest extends FormRequest
|
||||
{
|
||||
protected array $scenes = [
|
||||
'getDoctorInquiryConfigOpenStatus' => [ // 获取医生问诊服务开启状态
|
||||
'inquiry_type',
|
||||
'inquiry_mode',
|
||||
],
|
||||
'getDoctorInquiryConfig' => [ // 获取医生问诊配置
|
||||
'inquiry_type',
|
||||
'inquiry_mode',
|
||||
@ -26,22 +30,28 @@ class DoctorInquiryConfigRequest extends FormRequest
|
||||
'inquiry_price',
|
||||
'work_num_day',
|
||||
],
|
||||
'getInquiryServiceConfig' => [ // 获取医生问诊配置-服务设置
|
||||
'inquiry_type',
|
||||
'inquiry_mode',
|
||||
],
|
||||
'addInquiryServiceConfig' => [ // 新增医生问诊配置-服务设置
|
||||
'addDoctorInquiryDifficultConfig' => [ // 新增医生问诊配置-疑难会诊-服务设置
|
||||
'service_content',
|
||||
'service_process',
|
||||
'service_period',
|
||||
'service_rounds',
|
||||
],
|
||||
'putInquiryServiceConfig' => [ // 修改医生问诊配置-服务设置
|
||||
'putDoctorInquiryDifficultConfig' => [ // 修改医生问诊配置-疑难会诊-服务设置
|
||||
'service_content',
|
||||
'service_process',
|
||||
'service_period',
|
||||
'service_rounds',
|
||||
],
|
||||
'addDoctorInquiryFollowConfig' => [ // 新增医生问诊配置-随访包
|
||||
'monthly_frequency', // 每月次数(0表示不限次)
|
||||
'service_rounds', // 服务回合数(0表示不限次)
|
||||
'items', // 随访包内容列表数据
|
||||
],
|
||||
'putDoctorInquiryFollowConfig' => [ // 修改医生问诊配置-随访包
|
||||
'monthly_frequency', // 每月次数(0表示不限次)
|
||||
'service_rounds', // 服务回合数(0表示不限次)
|
||||
'items', // 随访包内容列表数据
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -59,7 +69,7 @@ class DoctorInquiryConfigRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'inquiry_type' => 'required|integer|min:1|max:3',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:6',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:9',
|
||||
'is_open' => "required|boolean",
|
||||
'inquiry_price' => "required|min:0|numeric",
|
||||
'work_num_day' => "required|min:0|numeric",
|
||||
@ -67,6 +77,8 @@ class DoctorInquiryConfigRequest extends FormRequest
|
||||
'service_process' => "required",
|
||||
'service_period' => "required|min:2|max:30|numeric",
|
||||
'service_rounds' => "required|min:0|max:300|numeric",
|
||||
'monthly_frequency' => "required|min:0|max:10|numeric",
|
||||
'items' => "required",
|
||||
];
|
||||
}
|
||||
|
||||
@ -103,6 +115,11 @@ class DoctorInquiryConfigRequest extends FormRequest
|
||||
'service_rounds.min' => "服务回合数最小值不可低于0",
|
||||
'service_rounds.max' => "服务回合数最大值不可超过300",
|
||||
'service_rounds.numeric' => "服务回合数填写错误",
|
||||
'monthly_frequency.required' => "请填写每月次数",
|
||||
'monthly_frequency.min' => "每月次数最小值不可低于0",
|
||||
'monthly_frequency.max' => "每月次数最大值不可超过10",
|
||||
'monthly_frequency.numeric' => "每月次数填写错误",
|
||||
'items.required' => "请填写服务内容",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
112
app/Request/OrderServicePackageRequest.php
Normal file
112
app/Request/OrderServicePackageRequest.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
use Hyperf\Validation\Rule;
|
||||
|
||||
class OrderServicePackageRequest extends FormRequest
|
||||
{
|
||||
protected array $scenes = [
|
||||
'getPatientBuyServiceDetail' => [ // 获取患者已购买的某医生的服务包详情
|
||||
'doctor_id',
|
||||
'family_id',
|
||||
'service_type', // 服务包类型(1:健康 2:随访)
|
||||
'follow_package_item_id',
|
||||
],
|
||||
'addPatientServiceOrder' => [ // 创建服务包订单
|
||||
'doctor_id',
|
||||
'service_type',
|
||||
'follow_package_item_id',
|
||||
'patient_id',
|
||||
'family_id',
|
||||
'disease_class_id',
|
||||
'diagnosis_date',
|
||||
'disease_desc',
|
||||
'is_allergy_history',// 过敏史
|
||||
'is_family_history', // 家族病史
|
||||
'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
'inquiry_mode', // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
'client_type', // 客户端类型(1:手机 2:电脑)
|
||||
'is_pregnant',// 备孕、妊娠、哺乳期
|
||||
],
|
||||
'addServiceInquiryOrder' => [ // 创建服务包问诊订单
|
||||
'order_no',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'inquiry_type' => 'required|integer|min:1|max:5',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:9',
|
||||
'patient_id' => 'required',
|
||||
'family_id' => 'required',
|
||||
'disease_class_id' => 'required',
|
||||
'diagnosis_date' => 'date',
|
||||
'disease_desc' => 'required',
|
||||
'is_allergy_history' => ['sometimes','numeric','min:0','max:1'],
|
||||
'is_family_history' => ['sometimes','numeric','min:0','max:1'],
|
||||
'is_pregnant' => ['sometimes',Rule::in([0,1,null])],
|
||||
'client_type' => 'required|integer|min:1|max:2',
|
||||
'service_type' => ['required','integer',Rule::in([1,2])],
|
||||
'doctor_id' => 'required',
|
||||
'order_no' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已定义验证规则的错误消息.
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'doctor_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_mode.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'disease_class_id.required' => "请您选择疾病",
|
||||
'diagnosis_date.date' => HttpEnumCode::getMessage(HttpEnumCode::DATE_FORMAT_ERROR),
|
||||
'disease_desc.required' => "请您输入病情主诉",
|
||||
'is_allergy_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_allergy_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_allergy_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_family_history.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'is_pregnant.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.in' => "服务包类型错误",
|
||||
'is_pregnant.in' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_no.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ namespace App\Request;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
use Hyperf\Validation\Rule;
|
||||
|
||||
class PatientOrderRequest extends FormRequest
|
||||
{
|
||||
@ -19,10 +20,11 @@ class PatientOrderRequest extends FormRequest
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
'getPatientOrderPayInfo' => [ // 获取患者订单支付数据
|
||||
"order_type", // 订单类型(1:问诊订单 2:药品订单 3:检测订单)
|
||||
"order_type", // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
"order_no"// 订单编号
|
||||
],
|
||||
'addPatientOrderPay' => [ // 模拟支付成功-金额为0时使用
|
||||
"order_type", // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
"order_no"// 订单编号
|
||||
],
|
||||
'addPatientProductOrder' => [ // 创建药品订单
|
||||
@ -37,6 +39,10 @@ class PatientOrderRequest extends FormRequest
|
||||
'detection_status',// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
'getPatientServiceOrderList' => [ // 获取患者服务包订单列表
|
||||
'order_service_status',// 订单状态(0:全部 1:待支付、2:待接诊 3:服务中 4:完成/取消)
|
||||
'family_id',// 家庭成员id(就诊用户)
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -53,8 +59,8 @@ class PatientOrderRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'inquiry_type' => 'required|integer|min:1|max:4',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:5',
|
||||
'inquiry_type' => 'required|integer|min:1|max:5',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:9',
|
||||
'patient_id' => 'required',
|
||||
'family_id' => 'required',
|
||||
'disease_class_id' => 'required',
|
||||
@ -64,6 +70,7 @@ class PatientOrderRequest extends FormRequest
|
||||
'is_family_history' => ['sometimes','numeric','min:0','max:1'],
|
||||
'is_pregnant' => ['sometimes','numeric','min:0','max:1'],
|
||||
'client_type' => 'required|integer|min:1|max:2',
|
||||
'service_type' => ['required','integer',Rule::in([1,2])],
|
||||
|
||||
'doctor_id' => 'required',
|
||||
'order_inquiry_id' => 'required',
|
||||
@ -73,13 +80,14 @@ class PatientOrderRequest extends FormRequest
|
||||
|
||||
'inquiry_status' => 'required|integer|min:0|max:4',
|
||||
|
||||
'order_type' => 'required|integer|min:1|max:3',
|
||||
'order_type' => 'required|integer|min:1|max:5',
|
||||
'order_no' => 'required',
|
||||
|
||||
'order_prescription_id' => 'required',
|
||||
'address_id' => 'required',
|
||||
'product_ids' => 'required|array|min:1',
|
||||
'detection_status' => 'required|integer|min:0|max:5',
|
||||
'order_service_status' => 'required|integer|min:0|max:4',
|
||||
];
|
||||
}
|
||||
|
||||
@ -89,6 +97,7 @@ class PatientOrderRequest extends FormRequest
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'doctor_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
@ -122,6 +131,11 @@ class PatientOrderRequest extends FormRequest
|
||||
'inquiry_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'inquiry_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'order_service_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_service_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
|
||||
'order_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'order_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
@ -136,6 +150,9 @@ class PatientOrderRequest extends FormRequest
|
||||
'detection_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'detection_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.in' => "服务包类型错误",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,11 @@ class SystemRequest extends FormRequest
|
||||
protected array $scenes = [
|
||||
'getSystemInquiryTime' => [ // 获取系统问诊配置 快速问诊-问诊购药
|
||||
'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
'inquiry_mode', // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
'inquiry_mode', // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
],
|
||||
'getSystemInquiryConfig' => [ // 获取系统问诊配置
|
||||
'inquiry_type', // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
'inquiry_mode', // 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
],
|
||||
];
|
||||
|
||||
@ -31,7 +35,7 @@ class SystemRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
'inquiry_type' => 'required|integer|min:1|max:4',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:5',
|
||||
'inquiry_mode' => 'required|integer|min:1|max:9',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace App\Request;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
use Hyperf\Validation\Rule;
|
||||
|
||||
class UserPatientRequest extends FormRequest
|
||||
{
|
||||
@ -17,6 +18,12 @@ class UserPatientRequest extends FormRequest
|
||||
'product_id',
|
||||
'shopping_cart_num',
|
||||
],
|
||||
'getPatientBuyServiceDetail' => [ // 获取患者已购买的某医生的服务包详情
|
||||
'doctor_id',
|
||||
'family_id',
|
||||
'service_type',
|
||||
'follow_package_item_id',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
@ -36,6 +43,9 @@ class UserPatientRequest extends FormRequest
|
||||
'user_coupon_status' => 'required|numeric|min:0|max:3',
|
||||
'product_id' => 'required',
|
||||
'shopping_cart_num' => 'required|numeric|min:0|max:999',
|
||||
'doctor_id' => 'required',
|
||||
'family_id' => 'required',
|
||||
'service_type' => ['required','integer',Rule::in([1,2])],
|
||||
];
|
||||
}
|
||||
|
||||
@ -55,6 +65,12 @@ class UserPatientRequest extends FormRequest
|
||||
'shopping_cart_num.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'shopping_cart_num.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'shopping_cart_num.max' => "请勿超出最大添加数量",
|
||||
|
||||
'doctor_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR),
|
||||
'service_type.integer' => "服务包类型错误",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,15 +51,15 @@ class CouponService extends BaseService
|
||||
}
|
||||
|
||||
// 判断用户是否已有该优惠卷
|
||||
$params = array();
|
||||
$params['user_id'] = $user_id;
|
||||
$params['coupon_id'] = $coupon['coupon_id'];
|
||||
$user_coupon = UserCoupon::getOne($params);
|
||||
if (!empty($user_coupon)){
|
||||
if ($user_coupon['user_coupon_status'] == 0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// $params = array();
|
||||
// $params['user_id'] = $user_id;
|
||||
// $params['coupon_id'] = $coupon['coupon_id'];
|
||||
// $user_coupon = UserCoupon::getOne($params);
|
||||
// if (!empty($user_coupon)){
|
||||
// if ($user_coupon['user_coupon_status'] == 0){
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 判断该优惠卷状态
|
||||
if ($coupon['coupon_status'] != 1){
|
||||
@ -68,14 +68,16 @@ class CouponService extends BaseService
|
||||
}
|
||||
|
||||
// 判断该优惠卷过期时间
|
||||
if ($coupon['valid_type'] == 1){
|
||||
// 绝对时效
|
||||
$valid_end_time = strtotime($coupon['valid_end_time']);
|
||||
if (!empty($coupon['valid_type'])){
|
||||
if ($coupon['valid_type'] == 1){
|
||||
// 绝对时效
|
||||
$valid_end_time = strtotime($coupon['valid_end_time']);
|
||||
|
||||
$date = time() + 60 * 10;
|
||||
if ($valid_end_time < $date){
|
||||
// 超出结束使用时间
|
||||
return true;
|
||||
$date = time() + 60 * 10;
|
||||
if ($valid_end_time < $date){
|
||||
// 超出结束使用时间
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,19 +132,24 @@ class CouponService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 添加优惠卷过期队列
|
||||
$valid_end_time = strtotime($user_coupon->valid_end_time);
|
||||
// 优惠卷过期时间
|
||||
$valid_end_time = strtotime($user_coupon['valid_end_time']);
|
||||
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
// 当天结束时间
|
||||
$day_end_time = strtotime(date('Y-m-d 23:59:59',time()));
|
||||
|
||||
$time = $valid_end_time - time();
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
if ($valid_end_time <= $day_end_time){
|
||||
$data = array();
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
|
||||
$time = $valid_end_time - time();
|
||||
$message = new UserCouponExpiredDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
||||
@ -150,20 +157,6 @@ class CouponService extends BaseService
|
||||
}
|
||||
|
||||
try {
|
||||
// 添加优惠卷即将过期提醒队列
|
||||
$time = floor($time * 0.75);
|
||||
|
||||
// 时间低于5小时,不进行过期提醒
|
||||
if ($time > 60 * 60 * 5){
|
||||
$message = new UserCouponExpiredNoticeDelayDirectProducer($data);
|
||||
$message->setDelayMs(1000 * $time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Log::getInstance("CouponService-GrantUserCoupon")->error("添加优惠卷即将过期提醒队列");
|
||||
}
|
||||
}
|
||||
|
||||
// 通知-患者-优惠卷发放
|
||||
$MessagePush = new MessagePush($user_id);
|
||||
$MessagePush->patientDistributeCoupon($coupon['coupon_name']);
|
||||
@ -198,4 +191,29 @@ class CouponService extends BaseService
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放购买服务包的关联优惠卷
|
||||
* @param string $user_id 用户id
|
||||
* @return bool
|
||||
*/
|
||||
public function GrantBuyOrderServicePackageCoupon(string $user_id): bool
|
||||
{
|
||||
// 获取购买服务包的用户可领取的优惠卷列表
|
||||
$coupons = Coupon::getOrderServicePackageCouponList();
|
||||
if (empty($coupons)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($coupons as $coupon){
|
||||
// 发放优惠卷
|
||||
$res = $this->GrantUserCoupon($coupon['coupon_id'],$user_id);
|
||||
if (!$res){
|
||||
// 发放失败
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ use App\Model\BasicNation;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\DetectionProjectPurpose;
|
||||
use App\Model\DiseaseClassDetection;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionCase;
|
||||
use App\Model\OrderDetectionRefund;
|
||||
@ -40,13 +41,13 @@ class DetectionService extends BaseService
|
||||
*/
|
||||
public function getDetectionProjectList(): array
|
||||
{
|
||||
$company_id = $this->request->input("company_id",1);
|
||||
$company_id = $this->request->input("company_id", 1);
|
||||
|
||||
// 获取合作公司数据
|
||||
$params = array();
|
||||
$params['company_id'] = $company_id;
|
||||
$basic_company = BasicCompany::getOne($params);
|
||||
if (empty($basic_company)){
|
||||
if (empty($basic_company)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -54,11 +55,11 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['company_id'] = $company_id;
|
||||
$detection_projects = DetectionProject::getList($params);
|
||||
if (empty($detection_projects)){
|
||||
if (empty($detection_projects)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
foreach ($detection_projects as &$value){
|
||||
foreach ($detection_projects as &$value) {
|
||||
$value['img_path'] = addAliyunOssWebsite($value['img_path']);
|
||||
}
|
||||
|
||||
@ -71,14 +72,14 @@ class DetectionService extends BaseService
|
||||
*/
|
||||
public function getDetectionProject(): array
|
||||
{
|
||||
$company_id = $this->request->input("company_id",1);
|
||||
$detection_project_id = $this->request->route('detection_project_id',1);
|
||||
$company_id = $this->request->input("company_id", 1);
|
||||
$detection_project_id = $this->request->route('detection_project_id', 1);
|
||||
|
||||
// 获取合作公司数据
|
||||
$params = array();
|
||||
$params['company_id'] = $company_id;
|
||||
$basic_company = BasicCompany::getOne($params);
|
||||
if (empty($basic_company)){
|
||||
if (empty($basic_company)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -86,7 +87,7 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['detection_project_id'] = $detection_project_id;
|
||||
$detection_project = DetectionProject::getOne($params);
|
||||
if (empty($detection_project)){
|
||||
if (empty($detection_project)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -102,7 +103,7 @@ class DetectionService extends BaseService
|
||||
public function getDetectionDoctorList(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$company_id = $this->request->input("company_id",1);
|
||||
$company_id = $this->request->input("company_id", 1);
|
||||
$province_id = $this->request->input("province_id");
|
||||
$city_id = $this->request->input("city_id");
|
||||
$county_id = $this->request->input("county_id");
|
||||
@ -111,43 +112,43 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['company_id'] = $company_id;
|
||||
$basic_company = BasicCompany::getOne($params);
|
||||
if (empty($basic_company)){
|
||||
if (empty($basic_company)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 搜索数据
|
||||
$hospital_params = array();
|
||||
|
||||
if (!empty($province_id)){
|
||||
if (!empty($province_id)) {
|
||||
$params = array();
|
||||
$params['area_id'] = $province_id;
|
||||
$params['area_type'] = 2;
|
||||
$area_province = Area::getOne($params);
|
||||
if (!empty($area_province)){
|
||||
if (!empty($area_province)) {
|
||||
// 搜索条件
|
||||
$hospital_params['province_id'] = $area_province['area_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($city_id)){
|
||||
if (!empty($city_id)) {
|
||||
$params = array();
|
||||
$params['area_id'] = $city_id;
|
||||
$params['parent_id'] = $province_id;
|
||||
$params['area_type'] = 3;
|
||||
$area_city = Area::getOne($params);
|
||||
if (!empty($area_city)){
|
||||
if (!empty($area_city)) {
|
||||
// 搜索条件
|
||||
$hospital_params['city_id'] = $area_city['area_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($county_id)){
|
||||
if (!empty($county_id)) {
|
||||
$params = array();
|
||||
$params['area_id'] = $county_id;
|
||||
$params['parent_id'] = $city_id;
|
||||
$params['area_type'] = 4;
|
||||
$area_county = Area::getOne($params);
|
||||
if (!empty($area_county)){
|
||||
if (!empty($area_county)) {
|
||||
// 搜索条件
|
||||
$hospital_params['county_id'] = $area_county['area_id'];
|
||||
}
|
||||
@ -168,10 +169,10 @@ class DetectionService extends BaseService
|
||||
"doctor_title",
|
||||
"hospital_id",
|
||||
];
|
||||
$user_doctors = UserDoctor::getDiagnoCoopDoctorList($params,$hospital_params,$fields);
|
||||
if (!empty($user_doctors)){
|
||||
foreach ($user_doctors as &$value){
|
||||
if (!empty($value['Hospital'])){
|
||||
$user_doctors = UserDoctor::getDiagnoCoopDoctorList($params, $hospital_params, $fields);
|
||||
if (!empty($user_doctors)) {
|
||||
foreach ($user_doctors as &$value) {
|
||||
if (!empty($value['Hospital'])) {
|
||||
$value['hospital_name'] = $value['Hospital']['hospital_name'];
|
||||
}
|
||||
|
||||
@ -190,13 +191,13 @@ class DetectionService extends BaseService
|
||||
*/
|
||||
public function getDetectionProjectPurposeList(): array
|
||||
{
|
||||
$detection_project_id = $this->request->input("detection_project_id",1);
|
||||
$detection_project_id = $this->request->input("detection_project_id", 1);
|
||||
|
||||
// 获取项目数据
|
||||
$params = array();
|
||||
$params['detection_project_id'] = $detection_project_id;
|
||||
$detection_project_purpose = DetectionProjectPurpose::getList($params);
|
||||
if (empty($detection_project_purpose)){
|
||||
if (empty($detection_project_purpose)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -215,7 +216,7 @@ class DetectionService extends BaseService
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "成功";
|
||||
$result['data'] = [
|
||||
"inquiry_no" => "",
|
||||
"order_no" => "",
|
||||
"order_detection_id" => "",
|
||||
];
|
||||
|
||||
@ -238,7 +239,7 @@ class DetectionService extends BaseService
|
||||
$params['family_id'] = $request_params['family_id'];
|
||||
$params['detection_project_id'] = $request_params['detection_project_id'];
|
||||
$order_detection = OrderDetection::getNotFinishedOrderDetectionOne($params);
|
||||
if (!empty($order_detection)){
|
||||
if (!empty($order_detection)) {
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "当前患者存在未完成的检测订单";
|
||||
$result['data']['order_no'] = $order_detection['detection_no'];
|
||||
@ -249,37 +250,37 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['nation_id'] = $request_params['nation_id'];
|
||||
$nation = BasicNation::getOne($params);
|
||||
if (empty($nation)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"民族选择错误");
|
||||
if (empty($nation)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "民族选择错误");
|
||||
}
|
||||
|
||||
// 检测疾病分类
|
||||
$detection_disease_class_ids = explode(',',$request_params['detection_disease_class_ids']);
|
||||
if (count($detection_disease_class_ids) > 3){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"既往病史最多可选三项");
|
||||
$detection_disease_class_ids = explode(',', $request_params['detection_disease_class_ids']);
|
||||
if (count($detection_disease_class_ids) > 3) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "既往病史最多可选三项");
|
||||
}
|
||||
|
||||
$detection_disease_class_names = "";
|
||||
|
||||
foreach ($detection_disease_class_ids as $value){
|
||||
foreach ($detection_disease_class_ids as $value) {
|
||||
$params = array();
|
||||
$params['id'] = $value;
|
||||
$disease_class_detection = DiseaseClassDetection::getOne($params);
|
||||
if (empty($disease_class_detection)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误");
|
||||
if (empty($disease_class_detection)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "既往病史错误");
|
||||
}
|
||||
|
||||
if ($disease_class_detection['status'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误");
|
||||
if ($disease_class_detection['status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "既往病史错误");
|
||||
}
|
||||
|
||||
if ($disease_class_detection['enable'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误");
|
||||
if ($disease_class_detection['enable'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "既往病史错误");
|
||||
}
|
||||
|
||||
if (empty($detection_disease_class_names)){
|
||||
if (empty($detection_disease_class_names)) {
|
||||
$detection_disease_class_names = $disease_class_detection['name'];
|
||||
}else{
|
||||
} else {
|
||||
$detection_disease_class_names = $detection_disease_class_names . ',' . $disease_class_detection['name'];
|
||||
}
|
||||
}
|
||||
@ -288,12 +289,12 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['detection_project_id'] = $request_params['detection_project_id'];
|
||||
$detection_project = DetectionProject::getOne($params);
|
||||
if (empty($detection_project)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"检测项目错误");
|
||||
if (empty($detection_project)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "检测项目错误");
|
||||
}
|
||||
|
||||
if ($detection_project['detection_project_price'] <= 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单金额错误");
|
||||
if ($detection_project['detection_project_price'] <= 0) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单金额错误");
|
||||
}
|
||||
|
||||
// 检测用途
|
||||
@ -301,7 +302,7 @@ class DetectionService extends BaseService
|
||||
$params['purpose_id'] = $request_params['purpose_id'];
|
||||
$params['detection_project_id'] = $request_params['detection_project_id'];
|
||||
$detection_project_purpose = DetectionProjectPurpose::getOne($params);
|
||||
if (empty($detection_project_purpose)){
|
||||
if (empty($detection_project_purpose)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -309,12 +310,12 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['doctor_id'] = $request_params['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"医生错误");
|
||||
if (empty($user_doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "医生错误");
|
||||
}
|
||||
|
||||
if ($user_doctor['is_sys_diagno_cooperation'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"医生错误");
|
||||
if ($user_doctor['is_sys_diagno_cooperation'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "医生错误");
|
||||
}
|
||||
|
||||
// 确定支付渠道
|
||||
@ -323,6 +324,8 @@ class DetectionService extends BaseService
|
||||
$detection_pay_channel = 1;
|
||||
} elseif ($request_params['client_type'] == 2) {
|
||||
$detection_pay_channel = 2;
|
||||
} else {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请选择正确的支付渠道");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
@ -330,26 +333,44 @@ class DetectionService extends BaseService
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
try {
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
$data['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$data['order_type'] = 3; // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
$data['inquiry_pay_channel'] = $detection_pay_channel;// 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||
$data['pay_status'] = 1;// 1:待支付
|
||||
$data['order_no'] = "D" . $generator->generate();// 订单编号
|
||||
$data['amount_total'] = $detection_project['detection_project_price'];// 订单金额
|
||||
$data['coupon_amount_total'] = 0;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = $detection_project['detection_project_price'];// 实际付款金额
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 新增检测订单
|
||||
$data = array();
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
$data['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$data['family_id'] = $patient_family['family_id'];
|
||||
$data['detection_project_id'] = $detection_project['detection_project_id'];
|
||||
$data['purpose_id'] = $detection_project_purpose['purpose_id'];
|
||||
$data['detection_status'] = 1; // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
$data['detection_pay_channel'] = $detection_pay_channel; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
$data['detection_no'] = "D" . $generator->generate(); // 系统订单编号
|
||||
$data['amount_total'] = $detection_project['detection_project_price']; // 订单金额
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
$data['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$data['family_id'] = $patient_family['family_id'];
|
||||
$data['detection_project_id'] = $detection_project['detection_project_id'];
|
||||
$data['purpose_id'] = $detection_project_purpose['purpose_id'];
|
||||
$data['detection_status'] = 1; // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
$data['detection_pay_channel'] = $detection_pay_channel; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
$data['detection_no'] = $order['order_no']; // 系统订单编号
|
||||
$data['amount_total'] = $detection_project['detection_project_price']; // 订单金额
|
||||
$data['coupon_amount_total'] = 0;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = $detection_project['detection_project_price']; // 实际付款金额
|
||||
$data['payment_amount_total'] = $detection_project['detection_project_price']; // 实际付款金额
|
||||
$data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人
|
||||
$data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码)
|
||||
$data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
$data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人
|
||||
$order_detection = OrderDetection::addOrderDetection($data);
|
||||
if (empty($order_detection)){
|
||||
if (empty($order_detection)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
@ -368,7 +389,7 @@ class DetectionService extends BaseService
|
||||
$data['detection_disease_class_ids'] = $request_params['detection_disease_class_ids']; // 疾病id-检测-逗号分隔
|
||||
$data['detection_disease_class_names'] = $detection_disease_class_names; // 疾病名称-检测-逗号分隔
|
||||
$order_detection_case = OrderDetectionCase::addOrderDetectionCase($data);
|
||||
if (empty($order_detection_case)){
|
||||
if (empty($order_detection_case)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
@ -388,7 +409,7 @@ class DetectionService extends BaseService
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
@ -416,7 +437,7 @@ class DetectionService extends BaseService
|
||||
$params['family_id'] = $family_id;
|
||||
$params['detection_project_id'] = $detection_project_id;
|
||||
$order_detection = OrderDetection::getNotFinishedOrderDetectionOne($params);
|
||||
if (!empty($order_detection)){
|
||||
if (!empty($order_detection)) {
|
||||
return success($order_detection['detection_no']);
|
||||
}
|
||||
|
||||
@ -439,62 +460,61 @@ class DetectionService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_detection_id'] = $order_detection_id;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)){
|
||||
if (empty($order_detection)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_detection['detection_status'] != 2){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误");
|
||||
if ($order_detection['detection_status'] != 2) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单状态错误");
|
||||
}
|
||||
|
||||
if ($order_detection['detection_pay_status'] != 2){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单未支付");
|
||||
if ($order_detection['detection_pay_status'] != 2) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单未支付");
|
||||
}
|
||||
|
||||
if (!empty($order_detection['detection_bar_code'])){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
||||
if (!empty($order_detection['detection_bar_code'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请勿重复绑定");
|
||||
}
|
||||
|
||||
if (!empty($order_detection['detection_pic']) && !empty($request_params['detection_pic'])){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
|
||||
if (!empty($order_detection['detection_pic']) && !empty($request_params['detection_pic'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请勿重复绑定");
|
||||
}
|
||||
|
||||
// 处理检测管图片
|
||||
if (!empty($request_params['detection_pic'])){
|
||||
if (!empty($request_params['detection_pic'])) {
|
||||
$detection_pic = implode(',', $request_params['detection_pic']);
|
||||
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 检测检测管编码是否已被使用
|
||||
$params = array();
|
||||
$params['detection_bar_code'] = $request_params['detection_bar_code'];
|
||||
$result = OrderDetection::getOne($params);
|
||||
if (!empty($result)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"检测管已被使用");
|
||||
if (!empty($result)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "检测管已被使用");
|
||||
}
|
||||
|
||||
// 获取检测码对应的检测所
|
||||
$detection_organ_code = substr($request_params['detection_bar_code'], 3, 1);
|
||||
if (!$detection_organ_code){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"检测码错误");
|
||||
if (!$detection_organ_code) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "检测码错误");
|
||||
}
|
||||
|
||||
// 获取检测所数据
|
||||
$params = array();
|
||||
$params['detection_organ_code'] = $detection_organ_code;
|
||||
$basic_detection_organ = BasicDetectionOrgan::getOne($params);
|
||||
if (empty($basic_detection_organ)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"检测码错误");
|
||||
if (empty($basic_detection_organ)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "检测码错误");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 修改检测订单
|
||||
$data = array();
|
||||
if (isset($detection_pic)){
|
||||
if (isset($detection_pic)) {
|
||||
$data['detection_pic'] = $detection_pic;
|
||||
}
|
||||
|
||||
@ -505,10 +525,10 @@ class DetectionService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection_id;
|
||||
$res = OrderDetection::editOrderDetection($params,$data);
|
||||
if (!$res){
|
||||
$res = OrderDetection::editOrderDetection($params, $data);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "绑定失败");
|
||||
}
|
||||
|
||||
// 上报数据
|
||||
@ -516,7 +536,7 @@ class DetectionService extends BaseService
|
||||
$wy->report($order_detection_id);
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage());
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
@ -546,26 +566,28 @@ class DetectionService extends BaseService
|
||||
$result = array();
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "成功";
|
||||
$result['data'] = "";
|
||||
$result['data']['order_inquiry_id'] = "";
|
||||
$result['data']['order_no'] = "";
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_detection_id'] = $order_detection_id;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)){
|
||||
if (empty($order_detection)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_detection['detection_status'] != 4){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误");
|
||||
if ($order_detection['detection_status'] != 4) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "订单状态错误");
|
||||
}
|
||||
|
||||
// 检测是否已经创建问诊订单
|
||||
if (!empty($order_detection['order_inquiry_id'])){
|
||||
if (!empty($order_detection['order_inquiry_id'])) {
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "成功";
|
||||
$result['data'] = (string)$order_detection['order_inquiry_id'];
|
||||
$result['data']['order_inquiry_id'] = (string)$order_detection['order_inquiry_id'];
|
||||
$result['data']['order_no'] = (string)$order_detection['detection_no'];
|
||||
|
||||
return success($result);
|
||||
}
|
||||
@ -574,47 +596,64 @@ class DetectionService extends BaseService
|
||||
try {
|
||||
// 检测当前医生是否和患者存在未完成问诊订单
|
||||
$InquiryService = new InquiryService();
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($order_detection['patient_id'],$order_detection['doctor_id']);
|
||||
if (!empty($order_inquiry)){
|
||||
if ($order_inquiry['inquiry_status'] == 1){
|
||||
$order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($order_detection['patient_id'], $order_detection['doctor_id']);
|
||||
if (!empty($order_inquiry)) {
|
||||
if ($order_inquiry['inquiry_status'] == 1) {
|
||||
// 待支付
|
||||
Db::rollBack();
|
||||
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "当前医生有您未支付的订单,点击“继续”将为您取消订单直接进入报告解读服务。";
|
||||
$result['data'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 3){
|
||||
if ($order_inquiry['inquiry_status'] == 3) {
|
||||
// 待接诊
|
||||
Db::rollBack();
|
||||
|
||||
$result['status'] = 3;
|
||||
$result['message'] = "当前医生有您待接诊的订单,点击“继续”将为您取消订单直接进入报告解读服务。";
|
||||
$result['data'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 4){
|
||||
if ($order_inquiry['inquiry_status'] == 4) {
|
||||
// 已接诊
|
||||
Db::rollBack();
|
||||
|
||||
$result['status'] = 4;
|
||||
$result['message'] = "当前医生有您问诊中的订单,点击“继续”将进入聊天详情。";
|
||||
$result['data'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$result['data']['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取患者家庭成员是否存在未支付的服务包订单
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$order_service_package = $OrderServicePackageService->getPatientFamilyNoPayServicePackage($user_info['user_id'], $order_detection['family_id'], $order_detection['doctor_id']);
|
||||
if (!empty($order_service_package)){
|
||||
// 待支付
|
||||
Db::rollBack();
|
||||
|
||||
$result['status'] = 5;
|
||||
$result['message'] = "您和当前医生存在未支付的服务包订单,点击“继续”将进入订单详情。";
|
||||
$result['data']['order_no'] = (string)$order_service_package['order_service_no'];
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_detection['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
if (empty($user_doctor)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
@ -623,7 +662,7 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
$order_detection_case = OrderDetectionCase::getOne($params);
|
||||
if (empty($order_detection_case)){
|
||||
if (empty($order_detection_case)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
@ -632,7 +671,7 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['detection_project_id'] = $order_detection['detection_project_id'];
|
||||
$detection_project = DetectionProject::getOne($params);
|
||||
if (empty($detection_project)){
|
||||
if (empty($detection_project)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
@ -649,8 +688,28 @@ class DetectionService extends BaseService
|
||||
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $order_detection['user_id'];
|
||||
$data['patient_id'] = $order_detection['patient_id'];
|
||||
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||
$data['order_type'] = 1; // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
$data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||
$data['pay_status'] = 2; // 1:待支付
|
||||
$data['order_no'] = "I" . $generator->generate(); // 订单编号
|
||||
$data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号
|
||||
$data['amount_total'] = 0; // 订单金额
|
||||
$data['coupon_amount_total'] = 0; // 优惠卷总金额
|
||||
$data['payment_amount_total'] = 0; // 实际付款金额
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 创建问诊订单
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['user_id'] = $order_detection['user_id'];
|
||||
$data['patient_id'] = $order_detection['patient_id'];
|
||||
$data['doctor_id'] = $order_detection['doctor_id'];
|
||||
@ -660,8 +719,8 @@ class DetectionService extends BaseService
|
||||
$data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
$data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||
$data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号
|
||||
$data['inquiry_no'] = $order['order_no'];// 订单编号
|
||||
$data['escrow_trade_no'] = $order['escrow_trade_no']; // 第三方支付流水号
|
||||
$data['amount_total'] = 0;// 订单金额
|
||||
$data['coupon_amount_total'] = 0;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = 0;// 实际付款金额
|
||||
@ -703,7 +762,7 @@ class DetectionService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
OrderDetection::editOrderDetection($params,$data);
|
||||
OrderDetection::editOrderDetection($params, $data);
|
||||
|
||||
// 添加自动完成队列
|
||||
$time = 1000 * 60 * 60 * 24 * 3;
|
||||
@ -734,6 +793,7 @@ class DetectionService extends BaseService
|
||||
$data = [
|
||||
"order_inquiry_id" => $order_inquiry['order_inquiry_id'],
|
||||
"inquiry_type" => $order_inquiry['inquiry_type'],
|
||||
"inquiry_mode" => $order_inquiry['inquiry_mode'],
|
||||
"detection_no" => $order_detection['detection_no'],
|
||||
"patient_name" => $order_detection['patient_name'],
|
||||
"patient_sex" => $order_detection['patient_sex'],
|
||||
@ -750,6 +810,7 @@ class DetectionService extends BaseService
|
||||
$data = [
|
||||
"order_inquiry_id" => $order_inquiry['order_inquiry_id'],
|
||||
"inquiry_type" => $order_inquiry['inquiry_type'],
|
||||
"inquiry_mode" => $order_inquiry['inquiry_mode'],
|
||||
"detection_no" => $order_detection['detection_no'],
|
||||
"doctor_name" => $user_doctor['user_name'],
|
||||
"patient_name" => $order_detection['patient_name'],
|
||||
@ -763,7 +824,7 @@ class DetectionService extends BaseService
|
||||
$imService->detectionTestReportStr($data);
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage());
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
@ -778,7 +839,7 @@ class DetectionService extends BaseService
|
||||
|
||||
/**
|
||||
* 取消未支付检测订单
|
||||
* @param string|int $order_no 订单编号
|
||||
* @param string|int $order_no
|
||||
* @param string|int $cancel_reason 取消订单原因(1:主动取消 2:客服取消 3:支付超时)
|
||||
* @param string|int $cancel_remarks 取消备注
|
||||
* @return array
|
||||
@ -793,24 +854,24 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['detection_no'] = $order_no;
|
||||
$order_detection = OrderDetection::getOne($params);
|
||||
if (empty($order_detection)){
|
||||
if (empty($order_detection)) {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的检测订单失败:未查询到对应订单数据";
|
||||
$result['message'] = "未查询到对应订单数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_detection['detection_status'] == 5) {
|
||||
// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的检测订单:订单已取消";
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已取消";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_detection['detection_status'] != 1) {
|
||||
// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的检测订单:订单状态为" . $order_detection['detection_status'] . "无法执行";
|
||||
$result['message'] = "订单取消失败";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -818,15 +879,15 @@ class DetectionService extends BaseService
|
||||
if (!in_array($order_detection['detection_refund_status'], [0, 4, 5])) {
|
||||
// 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的检测订单:订单正在退款中";
|
||||
$result['message'] = "订单正在退款中";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单支付状态
|
||||
if ($order_detection['detection_pay_status'] == 2) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的检测订单:订单已支付";
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已支付";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -834,14 +895,14 @@ class DetectionService extends BaseService
|
||||
if ($order_detection['is_delete'] == 1) {
|
||||
// 删除状态(0:否 1:是)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的检测订单:订单已被删除";
|
||||
$result['message'] = "订单已被删除";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 取消检测订单
|
||||
$data = array();
|
||||
$data['detection_status'] = 5; // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
if ($cancel_reason == 3){
|
||||
if ($cancel_reason == 3) {
|
||||
$data['detection_pay_status'] = 5; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
}
|
||||
|
||||
@ -852,7 +913,7 @@ class DetectionService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
OrderDetection::editOrderDetection($params,$data);
|
||||
OrderDetection::editOrderDetection($params, $data);
|
||||
|
||||
return $result;
|
||||
}
|
||||
@ -860,7 +921,7 @@ class DetectionService extends BaseService
|
||||
/**
|
||||
* 检测订单退款接口
|
||||
*/
|
||||
public function detectionRefund(string $order_detection_id, string $refund_reason)
|
||||
/*public function detectionRefund(string $order_detection_id, string $refund_reason): void
|
||||
{
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
@ -877,7 +938,7 @@ class DetectionService extends BaseService
|
||||
}
|
||||
|
||||
// 检测订单退款状态
|
||||
if (in_array($order_detection['detection_refund_status'], [2, 3, 5,6])) {
|
||||
if (in_array($order_detection['detection_refund_status'], [2, 3, 5, 6])) {
|
||||
// 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
throw new BusinessException("订单退款状态错误");
|
||||
}
|
||||
@ -893,7 +954,7 @@ class DetectionService extends BaseService
|
||||
$detection_refund_no = $generator->generate();
|
||||
|
||||
// 检测订单金额
|
||||
if ($order_detection['payment_amount_total'] > 0){
|
||||
if ($order_detection['payment_amount_total'] > 0) {
|
||||
// 发起退款
|
||||
$WechatPay = new WechatPay(1, 3);
|
||||
|
||||
@ -930,9 +991,9 @@ class DetectionService extends BaseService
|
||||
}
|
||||
|
||||
$refund_id = $result['refund_id'];
|
||||
}else{
|
||||
} else {
|
||||
$detection_refund_status = 3;
|
||||
$success_time = date('Y-m-d H:i:s',time());
|
||||
$success_time = date('Y-m-d H:i:s', time());
|
||||
$refund_id = $generator->generate();
|
||||
}
|
||||
|
||||
@ -963,7 +1024,7 @@ class DetectionService extends BaseService
|
||||
$params = array();
|
||||
$params['order_detection_id'] = $order_detection['order_detection_id'];
|
||||
OrderDetection::editOrderDetection($params, $data);
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 获取患者某一状态下的检测订单数量
|
||||
@ -971,7 +1032,7 @@ class DetectionService extends BaseService
|
||||
* @param int $detection_status 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
* @return int
|
||||
*/
|
||||
public function getPatientDetectionWithStatus(string $patient_id,int $detection_status): int
|
||||
public function getPatientDetectionWithStatus(string $patient_id, int $detection_status): int
|
||||
{
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
|
||||
@ -10,7 +10,12 @@ use App\Model\DoctorBankCard;
|
||||
use App\Model\DoctorWithdrawal;
|
||||
use App\Model\DoctorWithdrawalBank;
|
||||
use App\Model\DoctorWithdrawalOrder;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageRefund;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@ -30,73 +35,71 @@ class DoctorAccountService extends BaseService
|
||||
|
||||
$year = $this->request->input('date');
|
||||
|
||||
$date = date('Y-m-d',time());
|
||||
$date = date('Y-m-d', time());
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
if (empty($user_doctor)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$inquiryService = new InquiryService();
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
||||
// 获取医生当日接诊的订单金额
|
||||
$doctor_today_inquiry_total = $inquiryService->getDoctorDayAmountTotal($user_info['client_user_id'],$date);
|
||||
// 获取医生当日的接诊订单金额
|
||||
$doctor_today_inquiry_total = $inquiryService->getDoctorDayAmountTotal($user_doctor['doctor_id'], $date, $user_doctor['is_platform_deep_cooperation']);
|
||||
|
||||
// 获取医生当日已完成未结束的订单金额
|
||||
$doctor_day_completed_amount_total = $inquiryService->getDoctorDayCompletedAmountTotal($user_info['client_user_id'],$date);
|
||||
}else{
|
||||
// 获取医生当日接诊的订单金额-坐班医生
|
||||
$doctor_today_inquiry_total = $inquiryService->getCooperationDoctorDayAmountTotal($user_info['client_user_id'],$date);
|
||||
// 获取医生当日的服务包订单问诊金额-开始时间
|
||||
$doctor_today_service_package_total = $OrderServicePackageService->getDoctorDayAmountTotal($user_doctor['doctor_id'], $date);
|
||||
|
||||
// 获取医生当日已完成未结束的订单金额-坐班医生
|
||||
$doctor_day_completed_amount_total = $inquiryService->getCooperationDoctorCompletedAmountTotal($user_info['client_user_id'],$date);
|
||||
}
|
||||
// 医生当日的订单金额
|
||||
$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_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);
|
||||
|
||||
// 获取医生账户余额
|
||||
$balance_account = $this->getDoctorBalanceAccount($user_info['client_user_id']);
|
||||
|
||||
// // 获取医生月度余额
|
||||
// $amount_total_month = $this->getDoctorMonthAmountTotal($user_info['client_user_id'], $date);
|
||||
//
|
||||
// // 获取医生月度已提现金额-审核通过时间为准
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
//
|
||||
// $start_time = date('Y-m-01',strtotime($date));
|
||||
// $end_time = date('Y-m-t 24:00:00',strtotime($date));
|
||||
// $created_at = [$start_time,$end_time];
|
||||
// $doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params,$created_at,['*']);
|
||||
// if (empty($doctor_withdrawal)) {
|
||||
// $withdrawal_amount_month = 0;
|
||||
// } else {
|
||||
// $withdrawal_amount_month = $doctor_withdrawal['actual_withdrawal_amount'];
|
||||
// }
|
||||
|
||||
// 获取医生每月账单数据
|
||||
$bill = [];
|
||||
|
||||
$balance_account = 0;
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['year'] = $year;
|
||||
$doctor_account_days = DoctorAccountDay::getDoctorMonth($params);
|
||||
if (!empty($doctor_account_days)) {
|
||||
foreach ($doctor_account_days as $doctor_account_day) {
|
||||
$data = array();
|
||||
$data['total_amount'] = bcmul((string)$doctor_account_day['total_amount'],1,2);
|
||||
$data['month'] = $doctor_account_day['month'];
|
||||
$bill[] = $data;
|
||||
}
|
||||
unset($doctor_account_days);
|
||||
$doctor_account = DoctorAccount::getOne($params);
|
||||
if (!empty($doctor_account)) {
|
||||
$balance_account = $doctor_account['balance_account'];
|
||||
}
|
||||
|
||||
// 获取医生问诊每月账单数据
|
||||
// $bill = [];
|
||||
//
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
// $params['year'] = $year;
|
||||
// $doctor_account_days = DoctorAccountDay::getDoctorMonth($params);
|
||||
// if (!empty($doctor_account_days)) {
|
||||
// foreach ($doctor_account_days as $doctor_account_day) {
|
||||
// $data = array();
|
||||
// $data['total_amount'] = bcmul((string)$doctor_account_day['total_amount'], 1, 2);
|
||||
// $data['month'] = $doctor_account_day['month'];
|
||||
// $bill[] = $data;
|
||||
// }
|
||||
// unset($doctor_account_days);
|
||||
// }
|
||||
|
||||
// 获取医生服务包每月账单数据
|
||||
$year = date('Y',strtotime($year));
|
||||
$bill = $this->getDoctorMonthlyGroupBill($user_doctor,$year);
|
||||
|
||||
$result = array();
|
||||
$result['doctor_today_inquiry_total'] = bcmul((string)$doctor_today_inquiry_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['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['balance_account'] = bcmul((string)$balance_account, "1", 2); // 账户余额
|
||||
$result['bill'] = $bill; // 账单
|
||||
|
||||
return success($result);
|
||||
@ -118,7 +121,7 @@ class DoctorAccountService extends BaseService
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)){
|
||||
if (empty($user_doctor)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -129,58 +132,117 @@ class DoctorAccountService extends BaseService
|
||||
// 获取给定月份的下一个月的第一天,然后减去一天得到当月的最后一天
|
||||
$end_date = date("Y-m-d 23:59:59", strtotime("+1 month", strtotime($start_date)) - 1);
|
||||
|
||||
$reception_time = [$start_date, $end_date];
|
||||
$date_params = [$start_date, $end_date];
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
$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',
|
||||
'cancel_reason',
|
||||
'cancel_remarks',
|
||||
'created_at',
|
||||
];
|
||||
$results = Order::getDoctorCreatedDateOrderInquiryPage($user_doctor['doctor_id'], $date_params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||
if (!empty($results['data'])) {
|
||||
$OrderService = new OrderService();
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$inquiry_status_params = [4,5,6,7]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
|
||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $inquiry_status_params,[],$fields,$page,$per_page);
|
||||
}else{
|
||||
$order_inquiry = OrderInquiry:: getDoctorCreatedDateOrderInquiryPage($params, $reception_time, $inquiry_status_params,[2,4],$fields,$page,$per_page);
|
||||
}
|
||||
if (!empty($order_inquiry['data'])) {
|
||||
foreach ($order_inquiry['data'] as &$item) {
|
||||
$item['estimate_income'] = bcmul((string)$item['amount_total'],"0.75",2);
|
||||
|
||||
// 入账状态
|
||||
if ($item['inquiry_status'] == 4 || $item['inquiry_status'] == 5){
|
||||
$item['entry_status'] = 1;// 入账中
|
||||
}elseif ($item['inquiry_status'] == 6){
|
||||
$item['entry_status'] = 2;// 入账成功
|
||||
}elseif ($item['inquiry_status'] == 7){
|
||||
$item['entry_status'] = 3;// 入账失败
|
||||
if (!empty($item['cancel_reason'])){
|
||||
$item['cancel_reason'] = inquiryCancelReasonToPushString($item['cancel_reason']);
|
||||
foreach ($results['data'] as &$result) {
|
||||
// 填入字段
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||
}
|
||||
}else{
|
||||
$item['entry_status'] = 0;// 未知
|
||||
|
||||
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||
$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'];
|
||||
}
|
||||
|
||||
// 获取订单退款金额
|
||||
$result['refund_total'] = $OrderService->getOrderRefundAmount($result['order_no']);
|
||||
|
||||
// 获取订单可提现金额
|
||||
$result['expected_amount_total'] = $OrderService->getOrderWithdrawalAmount($result,$result['refund_total']);
|
||||
|
||||
// 处理问诊订单状态
|
||||
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;// 未知
|
||||
}
|
||||
|
||||
// 处理入账金额
|
||||
$result['estimate_income'] = bcmul((string)$result['amount_total'],"0.75",2);
|
||||
}
|
||||
|
||||
// 处理服务包订单状态
|
||||
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['payment_amount_total'] - $result['refund_total']) > 0){
|
||||
$result['entry_status'] = 2;// 入账成功
|
||||
}else{
|
||||
$result['entry_status'] = 3;// 入账失败
|
||||
}
|
||||
} else {
|
||||
$result['entry_status'] = 0;// 未知
|
||||
}
|
||||
|
||||
// 获取服务包详情表
|
||||
$params = array();
|
||||
$params['order_id'] = $result['order_id'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (empty($order_service_package_detail)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 处理入账金额
|
||||
if ($result['order_type'] == 5){
|
||||
$result['estimate_income'] = bcmul(
|
||||
bcmul(
|
||||
(string)$order_service_package_detail['single_inquiry_price'],
|
||||
(string)$order_service_package_detail['service_count'],
|
||||
2
|
||||
),
|
||||
"0.75",
|
||||
2
|
||||
);
|
||||
}else{
|
||||
$result['estimate_income'] = bcmul(
|
||||
(string)$order_service_package_detail['service_price'],
|
||||
"0.75",
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
unset($result['OrderInquiry']);
|
||||
unset($result['OrderServicePackage']);
|
||||
}
|
||||
}
|
||||
|
||||
return success($order_inquiry);
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,22 +253,11 @@ class DoctorAccountService extends BaseService
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_inquiry_ids = $this->request->input('order_inquiry_ids');
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_name',
|
||||
'iden_auth_status',
|
||||
'idcard_status',
|
||||
'multi_point_status',
|
||||
'avatar',
|
||||
'is_bind_bank',
|
||||
];
|
||||
$user_doctor = UserDoctor::getOne($params, $fields);
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||
}
|
||||
@ -218,7 +269,6 @@ class DoctorAccountService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||
}
|
||||
|
||||
|
||||
// 检测医生身份认证
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$res = $UserDoctorService->checkDoctorAuth($user_doctor);
|
||||
@ -247,59 +297,123 @@ class DoctorAccountService extends BaseService
|
||||
$bank['bank_card_name_mask'] = $user_doctor_info['card_name_mask'];
|
||||
|
||||
$amount_total = 0;
|
||||
$order_inquiry_id_array = [];
|
||||
// 获取医生账户余额
|
||||
if (!empty($order_inquiry_ids)){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_status'] = 6; // inquiry_status:问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$params['inquiry_refund_status'] = 0; // inquiry_refund_status:问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
|
||||
$in_params = explode(',',$order_inquiry_ids);
|
||||
$order_inquiry = OrderInquiry::getInList($params,$in_params);
|
||||
if (!empty($order_inquiry)){
|
||||
foreach ($order_inquiry as $value){
|
||||
$amount_total = bcadd((string)$amount_total,(string)$value["amount_total"],2);
|
||||
}
|
||||
}
|
||||
|
||||
$order_inquiry_id_array = $in_params;
|
||||
}else{
|
||||
$InquiryService = new InquiryService();
|
||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
||||
$order_inquiry = $InquiryService->getDoctorCanWithdrawalInquiryOrder($user_info['client_user_id']);
|
||||
}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);
|
||||
}
|
||||
$order_inquiry_id_array = array_column($order_inquiry,'order_inquiry_id');
|
||||
}
|
||||
// 获取医生账户总表
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_account = DoctorAccount::getOne($params);
|
||||
if (!empty($doctor_account)) {
|
||||
$amount_total = floor($doctor_account['balance_account'] * 100) / 100;
|
||||
}
|
||||
|
||||
$amount_total = bcmul((string)$amount_total,"0.75",2);
|
||||
/* // 获取可提现订单列表
|
||||
$orders = Order:: getDoctorWithdrawalOrderList($params, $user_doctor['is_platform_deep_cooperation'], ['*']);
|
||||
if (empty($orders)){
|
||||
// 无订单,账户余额强制赋0;
|
||||
$amount_total = 0;
|
||||
}
|
||||
|
||||
$OrderService = new OrderService();
|
||||
|
||||
// 可提现金额
|
||||
$expected_amount_total = 0;
|
||||
|
||||
// 订单号数据
|
||||
$order_nos = [];
|
||||
|
||||
foreach ($orders as $order){
|
||||
// 获取订单退款金额
|
||||
$refund_total = $OrderService->getOrderRefundAmount($order['order_no']);
|
||||
|
||||
// 获取订单可提现金额
|
||||
$expected_amount_total = bcadd(
|
||||
$expected_amount_total,
|
||||
$OrderService->getOrderWithdrawalAmount($order,$refund_total),
|
||||
2
|
||||
);
|
||||
|
||||
$order_nos[] = $order['order_no'];
|
||||
}
|
||||
|
||||
// 对比订单金额和账户金额;金额相差1元及以上返回错误
|
||||
$diff_amount_total = abs($amount_total - $expected_amount_total);
|
||||
if ($diff_amount_total >= 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "提现金额错误");
|
||||
}*/
|
||||
|
||||
// 计算医生个人所得税
|
||||
$income_tax = $this->computeIndividualIncomeTax($amount_total);
|
||||
|
||||
$withdrawal_amount = bcsub($amount_total,$income_tax,2);
|
||||
$withdrawal_amount = bcsub((string)$amount_total, (string)$income_tax, 2);
|
||||
|
||||
$income_tax = bcmul($income_tax,1,2);
|
||||
$income_tax = bcmul((string)$income_tax, 1, 2);
|
||||
|
||||
$result = array();
|
||||
$result['bank'] = $bank;//银行数据
|
||||
$result['bank'] = $bank; //银行数据
|
||||
$result['amount_total'] = $amount_total; // 账户余额
|
||||
$result['withdrawal_amount'] = $withdrawal_amount; // 提现金额
|
||||
$result['income_tax'] = $income_tax; // 个人所得税
|
||||
$result['order_inquiry_ids'] = $order_inquiry_id_array; // 订单合集
|
||||
|
||||
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
|
||||
@ -319,44 +433,53 @@ class DoctorAccountService extends BaseService
|
||||
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:退款关闭)
|
||||
$params['is_withdrawal'] = 0;
|
||||
|
||||
$inquiry_status_params = [6]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$results = Order:: getDoctorWithdrawalOrderPage($params, $user_doctor['is_platform_deep_cooperation'], ['*'], $page, $per_page);
|
||||
|
||||
if (!empty($results['data'])) {
|
||||
$OrderService = new OrderService();
|
||||
|
||||
if ($user_doctor['is_platform_deep_cooperation'] == 0){
|
||||
$order_inquiry = OrderInquiry:: getDoctorOrderInquiryPage($params,$inquiry_status_params, $fields,$page,$per_page);
|
||||
}else{
|
||||
$inquiry_type_not_params = [2,4];
|
||||
$order_inquiry = OrderInquiry:: getCooperationDoctorOrderInquiryPage($params,$inquiry_status_params,$inquiry_type_not_params, $fields,$page,$per_page);
|
||||
}
|
||||
foreach ($results['data'] as &$result) {
|
||||
// 填入字段
|
||||
if (!empty($result['OrderInquiry'])) {
|
||||
if (!empty($result['OrderInquiry']['cancel_reason'])) {
|
||||
$result['cancel_remarks'] = inquiryCancelReasonToPushString($result['OrderInquiry']['cancel_reason']);
|
||||
}
|
||||
|
||||
if (!empty($order_inquiry['data'])) {
|
||||
foreach ($order_inquiry['data'] as &$item) {
|
||||
$item['expected_amount_total'] = floor($item['amount_total'] * 0.75 * 100) / 100;
|
||||
$result['patient_name'] = $result['OrderInquiry']['patient_name'];
|
||||
$result['patient_name_mask'] = $result['OrderInquiry']['patient_name_mask'];
|
||||
$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'];
|
||||
}
|
||||
|
||||
// 获取订单退款金额
|
||||
$result['refund_total'] = $OrderService->getOrderRefundAmount($result['order_no']);
|
||||
|
||||
// 获取订单可提现金额
|
||||
$result['expected_amount_total'] = $OrderService->getOrderWithdrawalAmount($result,$result['refund_total']);
|
||||
|
||||
unset($result['OrderInquiry']);
|
||||
unset($result['OrderServicePackage']);
|
||||
}
|
||||
}
|
||||
|
||||
return success($order_inquiry);
|
||||
return success($results);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,21 +491,21 @@ class DoctorAccountService extends BaseService
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$year = $this->request->input('year');
|
||||
$page = $this->request->input('page',1);
|
||||
$per_page = $this->request->input('per_page',10);
|
||||
$page = $this->request->input('page', 1);
|
||||
$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];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params,$created_at_params,['*'],$page,$per_page);
|
||||
if (empty($doctor_withdrawal['data'])){
|
||||
$doctor_withdrawal = DoctorWithdrawal::getDatePage($params, $created_at_params, ['*'], $page, $per_page);
|
||||
if (empty($doctor_withdrawal['data'])) {
|
||||
return success();
|
||||
}
|
||||
|
||||
@ -398,20 +521,20 @@ class DoctorAccountService extends BaseService
|
||||
{
|
||||
$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');
|
||||
$bank_card_id = $this->request->input('bank_card_id');
|
||||
|
||||
$order_inquiry_id = explode(',',$order_inquiry_id);
|
||||
if (empty($order_inquiry_id)){
|
||||
$order_nos = explode(',', $order_no);
|
||||
if (empty($order_nos)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$app_env = config('app_env');
|
||||
if ($app_env != "dev"){
|
||||
if ($app_env != "dev") {
|
||||
// 正式环境高于300元才可以提现
|
||||
if ($withdrawal_amount_total < 300){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"提现金额小于300元");
|
||||
if ($withdrawal_amount_total < 300) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "提现金额小于300元");
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,46 +542,137 @@ class DoctorAccountService extends BaseService
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$start_time = date('Y-m-01',time());
|
||||
$end_time = date('Y-m-t 24:00:00',time());
|
||||
$created_at = [$start_time,$end_time];
|
||||
$start_time = date('Y-m-01', time());
|
||||
$end_time = date('Y-m-t 24:00:00', time());
|
||||
$created_at = [$start_time, $end_time];
|
||||
|
||||
$doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params,$created_at,['*'],);
|
||||
if (!empty($doctor_withdrawal)){
|
||||
$doctor_withdrawal = DoctorWithdrawal::getOneLatestTime($params, $created_at, ['*'],);
|
||||
if (!empty($doctor_withdrawal)) {
|
||||
return fail("每月只允许提现一次");
|
||||
}
|
||||
|
||||
$amount_total = 0;
|
||||
foreach ($order_inquiry_id as $value){
|
||||
foreach ($order_nos as $order_no) {
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $value;
|
||||
$params['order_no'] = $order_no;
|
||||
$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,"提现失败");
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "存在不可提现订单");
|
||||
}
|
||||
|
||||
// 验证订单提现状态
|
||||
if ($order_inquiry['is_withdrawal'] != 0){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"存在已提现订单");
|
||||
if ($order['is_withdrawal'] != 0) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "存在已提现订单");
|
||||
}
|
||||
|
||||
// 验证订单支付状态
|
||||
if ($order_inquiry['inquiry_pay_status'] != 2){
|
||||
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'];
|
||||
$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);
|
||||
@ -466,28 +680,28 @@ class DoctorAccountService extends BaseService
|
||||
// 实际提现金额
|
||||
$withdrawal_amount = $amount_total - $income_tax;
|
||||
|
||||
if ($withdrawal_amount > 0){
|
||||
if ($withdrawal_amount > 0) {
|
||||
$withdrawal_amount = floor($withdrawal_amount * 100) / 100;
|
||||
}
|
||||
|
||||
if ($withdrawal_amount_total != $withdrawal_amount){
|
||||
return fail(HttpEnumCode::SERVER_ERROR,"金额不符合");
|
||||
if ($withdrawal_amount_total != $withdrawal_amount) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "金额不符合");
|
||||
}
|
||||
|
||||
// 检测提现银行卡
|
||||
$params = array();
|
||||
$params['bank_card_id'] = $bank_card_id;
|
||||
$doctor_bank_card = DoctorBankCard::getOne($params);
|
||||
if (empty($doctor_bank_card)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"银行卡错误");
|
||||
if (empty($doctor_bank_card)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "银行卡错误");
|
||||
}
|
||||
|
||||
// 获取银行数据
|
||||
$params = array();
|
||||
$params['bank_id'] = $doctor_bank_card['bank_id'];
|
||||
$basic_bank = BasicBank::getOne($params);
|
||||
if (empty($basic_bank)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"银行卡错误");
|
||||
if (empty($basic_bank)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "银行卡错误");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
@ -498,16 +712,16 @@ class DoctorAccountService extends BaseService
|
||||
$data['account_name'] = $basic_bank['bank_name'];
|
||||
$data['bank_card_code'] = $doctor_bank_card['bank_card_code'];
|
||||
$data['bank_card_code_four'] = substr($doctor_bank_card['bank_card_code'], -4);
|
||||
if ($amount_total > 0){
|
||||
$data['applied_withdrawal_amount'] = floor($amount_total * 100) / 100; // 提现金额
|
||||
if ($amount_total > 0) {
|
||||
$data['applied_withdrawal_amount'] = floor($amount_total * 100) / 100; // 提现金额
|
||||
}
|
||||
$data['actual_withdrawal_amount'] = $withdrawal_amount; // 实际提现金额
|
||||
if ($income_tax > 0){
|
||||
$data['income_tax'] = floor($income_tax * 100) / 100; // 提现所得税金额
|
||||
if ($income_tax > 0) {
|
||||
$data['income_tax'] = floor($income_tax * 100) / 100; // 提现所得税金额
|
||||
}
|
||||
$data['examine_status'] = 1; // 审核状态(1:审核中 2:审核通过 3:审核未通过)
|
||||
$doctor_withdrawal = DoctorWithdrawal::addDoctorWithdrawal($data);
|
||||
if (empty($doctor_withdrawal)){
|
||||
if (empty($doctor_withdrawal)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
@ -524,53 +738,71 @@ class DoctorAccountService extends BaseService
|
||||
$data['county_id'] = $doctor_bank_card['county_id'];
|
||||
$data['county'] = $doctor_bank_card['county'];
|
||||
$doctor_withdrawal_bank = DoctorWithdrawalBank::addDoctorWithdrawalBank($data);
|
||||
if (empty($doctor_withdrawal_bank)){
|
||||
if (empty($doctor_withdrawal_bank)) {
|
||||
Db::rollBack();
|
||||
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['withdrawal_id'] = $doctor_withdrawal['withdrawal_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);
|
||||
if (empty($doctor_withdrawal_order)){
|
||||
if (empty($doctor_withdrawal_order)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 修改问诊订单提现状态
|
||||
// 修改订单提现状态
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $value;
|
||||
$params['order_no'] = $order_no;
|
||||
|
||||
$data = array();
|
||||
$data['is_withdrawal'] = 2;
|
||||
$data['withdrawal_time'] = date('Y-m-d H:i:s',time());
|
||||
OrderInquiry::edit($params,$data);
|
||||
$data['withdrawal_time'] = date('Y-m-d H:i:s', time());
|
||||
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['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();
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR,$e->getMessage());
|
||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,7 +862,7 @@ class DoctorAccountService extends BaseService
|
||||
}
|
||||
|
||||
// 实际纳税金额
|
||||
if ($income > 4000){
|
||||
if ($income > 4000) {
|
||||
$income = $income * 0.8;
|
||||
}
|
||||
|
||||
@ -649,4 +881,41 @@ class DoctorAccountService extends BaseService
|
||||
|
||||
return $income_tax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生每月账单数据
|
||||
* @param array|object $user_doctor
|
||||
* @param string $year
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorMonthlyGroupBill(array|object $user_doctor,string $year): array
|
||||
{
|
||||
// 获取医生服务包每月账单数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];
|
||||
$order_service_package = OrderServicePackage::getMonthlyGroupBill($params,$year);
|
||||
if (!empty($order_service_package)){
|
||||
$order_service_package = $order_service_package->toArray();
|
||||
}
|
||||
|
||||
// 获取医生问诊每月账单数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_doctor['doctor_id'];;
|
||||
$order_inquiry = OrderInquiry::getMonthlyGroupBill($params,$year,$user_doctor['is_platform_deep_cooperation']);
|
||||
if (!empty($order_inquiry)){
|
||||
$order_inquiry = $order_inquiry->toArray();
|
||||
}
|
||||
|
||||
// 处理月账单数据
|
||||
// 合并两个数组
|
||||
$merged = array_merge($order_service_package, $order_inquiry);
|
||||
|
||||
// 去除重复的元素
|
||||
$bill = array_unique($merged, SORT_REGULAR);
|
||||
|
||||
// 重新索引数组
|
||||
$bill = array_values($bill);
|
||||
|
||||
return $bill;
|
||||
}
|
||||
}
|
||||
@ -122,12 +122,13 @@ class DoctorAuthService extends BaseService
|
||||
// 网易易盾认证
|
||||
// 实人认证-生产环境开启
|
||||
$app_env = config('app_env','dev');
|
||||
if ($app_env != "dev"){
|
||||
if ($app_env == "dev"){
|
||||
$IdCard = new IdCard();
|
||||
|
||||
$params = array();
|
||||
$params['name'] = $card_name;
|
||||
$params['cardNo'] = $card_num;
|
||||
$params['dataId'] = $doctor['user_id'];
|
||||
$res = $IdCard->checkIdCard($params);
|
||||
if (!empty($res)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
|
||||
@ -4,9 +4,14 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DoctorConfigDifficultConsultation;
|
||||
use App\Model\DoctorConfigFollowPackage;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
use App\Model\DoctorConfigHealthPackage;
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\DoctorInquiryConfigService;
|
||||
use App\Model\DoctorInquiryPriceRecord;
|
||||
use App\Model\HealthPackage;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\UserDoctor;
|
||||
use Hyperf\DbConnection\Db;
|
||||
@ -16,6 +21,64 @@ use Hyperf\DbConnection\Db;
|
||||
*/
|
||||
class DoctorInquiryService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 获取医生问诊服务开启状态
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorInquiryConfigOpenStatus(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
}
|
||||
|
||||
if ($doctor['is_bind_bank'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
// 接诊开关
|
||||
$is_open = 0;
|
||||
|
||||
// 系统问诊配置表
|
||||
$params = array();
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (empty($system_inquiry_config)) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 医生接诊配置表
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (!empty($doctor_inquiry_config)) {
|
||||
if ($doctor_inquiry_config['is_enable'] == 1) {
|
||||
$is_open = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return success($is_open);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置
|
||||
* @return array
|
||||
@ -25,7 +88,7 @@ class DoctorInquiryService extends BaseService
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
@ -49,14 +112,10 @@ class DoctorInquiryService extends BaseService
|
||||
|
||||
// 返回数据
|
||||
$result = array();
|
||||
$info = array();
|
||||
$config = array();
|
||||
|
||||
// 接诊开关
|
||||
$is_open = 0;
|
||||
|
||||
// 接诊价格
|
||||
$info['inquiry_price'] = 0;
|
||||
$result['inquiry_price'] = "";
|
||||
$result['work_num_day'] = "";
|
||||
|
||||
// 系统问诊配置表
|
||||
$params = array();
|
||||
@ -73,67 +132,138 @@ class DoctorInquiryService extends BaseService
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)) {
|
||||
if (!empty($doctor_inquiry_config)) {
|
||||
// 接诊价格
|
||||
$info['inquiry_price'] = $system_inquiry_config['inquiry_price'] ?: 0;
|
||||
if ($inquiry_type == 3) {
|
||||
// 公益问诊,存在价格档次,默认第一档
|
||||
$inquiry_price = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
|
||||
$info['inquiry_price'] = $inquiry_price[0];
|
||||
}
|
||||
|
||||
// 默认接诊人数
|
||||
$info['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0;
|
||||
} else {
|
||||
// 接诊价格
|
||||
$info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0;
|
||||
if ($inquiry_type == 2) {
|
||||
$result['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0;
|
||||
if ($inquiry_type == 2 && $inquiry_mode == 1) {
|
||||
// 快速-系统配置
|
||||
$info['inquiry_price'] = $system_inquiry_config['inquiry_price'];
|
||||
$result['inquiry_price'] = $system_inquiry_config['inquiry_price'];
|
||||
}
|
||||
|
||||
$info['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0;
|
||||
|
||||
// 接诊开关
|
||||
if ($doctor_inquiry_config['is_enable'] == 1){
|
||||
$is_open = 1;
|
||||
}
|
||||
$result['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0;
|
||||
}
|
||||
|
||||
// 接诊开关
|
||||
$info['is_open'] = $is_open;
|
||||
|
||||
// 每日最大接诊数量
|
||||
$config['max_work_num_day'] = $system_inquiry_config['max_work_num_day'];
|
||||
|
||||
// 最低接诊价格(专家问诊)
|
||||
$config['min_inquiry_price'] = $system_inquiry_config['min_inquiry_price'] ?: 0;
|
||||
|
||||
// 最高接诊价格(专家问诊)
|
||||
$config['max_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0;
|
||||
|
||||
// 默认价格
|
||||
$config['default_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0;
|
||||
|
||||
// 沟通次数(0为不限制次数)
|
||||
$config['times_number'] = $system_inquiry_config['times_number'];
|
||||
|
||||
// 沟通时长(分钟,0为不限制时长)
|
||||
$config['duration'] = $system_inquiry_config['duration'];
|
||||
|
||||
// 系统价格(公益问诊)
|
||||
$config['system_inquiry_price'] = [];
|
||||
if ($inquiry_type == 3) {
|
||||
$config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
}
|
||||
|
||||
$result['info'] = $info;
|
||||
$result['config'] = $config;
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置
|
||||
* @return array
|
||||
*/
|
||||
// public function getDoctorInquiryConfig(): array
|
||||
// {
|
||||
// $user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
//
|
||||
// $inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
// $inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
//
|
||||
// // 获取医生信息
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
// $doctor = UserDoctor::getOne($params);
|
||||
// if (empty($doctor)) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
// }
|
||||
//
|
||||
// if ($doctor['idcard_status'] != 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
// }
|
||||
//
|
||||
// if ($doctor['iden_auth_status'] != 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
// }
|
||||
//
|
||||
// if ($doctor['is_bind_bank'] != 1) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
// }
|
||||
//
|
||||
// // 返回数据
|
||||
// $result = array();
|
||||
// $info = array();
|
||||
// $config = array();
|
||||
//
|
||||
// // 接诊开关
|
||||
// $is_open = 0;
|
||||
//
|
||||
// // 接诊价格
|
||||
// $info['inquiry_price'] = 0;
|
||||
//
|
||||
// // 系统问诊配置表
|
||||
// $params = array();
|
||||
// $params['inquiry_type'] = $inquiry_type;
|
||||
// $params['inquiry_mode'] = $inquiry_mode;
|
||||
// $system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
// if (empty($system_inquiry_config)) {
|
||||
// return fail(HttpEnumCode::SERVER_ERROR);
|
||||
// }
|
||||
//
|
||||
// // 医生接诊配置表
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
// $params['inquiry_type'] = $inquiry_type;
|
||||
// $params['inquiry_mode'] = $inquiry_mode;
|
||||
// $doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
// if (empty($doctor_inquiry_config)) {
|
||||
// // 接诊价格
|
||||
// $info['inquiry_price'] = $system_inquiry_config['inquiry_price'] ?: 0;
|
||||
// if ($inquiry_type == 3) {
|
||||
// // 公益问诊,存在价格档次,默认第一档
|
||||
// $inquiry_price = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
//
|
||||
// $info['inquiry_price'] = $inquiry_price[0];
|
||||
// }
|
||||
//
|
||||
// // 默认接诊人数
|
||||
// $info['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0;
|
||||
// } else {
|
||||
// // 接诊价格
|
||||
// $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?: 0;
|
||||
// if ($inquiry_type == 2) {
|
||||
// // 快速-系统配置
|
||||
// $info['inquiry_price'] = $system_inquiry_config['inquiry_price'];
|
||||
// }
|
||||
//
|
||||
// $info['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0;
|
||||
//
|
||||
// // 接诊开关
|
||||
// if ($doctor_inquiry_config['is_enable'] == 1){
|
||||
// $is_open = 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 接诊开关
|
||||
// $info['is_open'] = $is_open;
|
||||
//
|
||||
// // 每日最大接诊数量
|
||||
// $config['max_work_num_day'] = $system_inquiry_config['max_work_num_day'];
|
||||
//
|
||||
// // 最低接诊价格(专家问诊)
|
||||
// $config['min_inquiry_price'] = $system_inquiry_config['min_inquiry_price'] ?: 0;
|
||||
//
|
||||
// // 最高接诊价格(专家问诊)
|
||||
// $config['max_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0;
|
||||
//
|
||||
// // 默认价格
|
||||
// $config['default_inquiry_price'] = $system_inquiry_config['max_inquiry_price'] ?: 0;
|
||||
//
|
||||
// // 沟通次数(0为不限制次数)
|
||||
// $config['times_number'] = $system_inquiry_config['times_number'];
|
||||
//
|
||||
// // 沟通时长(分钟,0为不限制时长)
|
||||
// $config['duration'] = $system_inquiry_config['duration'];
|
||||
//
|
||||
// // 系统价格(公益问诊)
|
||||
// $config['system_inquiry_price'] = [];
|
||||
// if ($inquiry_type == 3) {
|
||||
// $config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
// }
|
||||
//
|
||||
// $result['info'] = $info;
|
||||
// $result['config'] = $config;
|
||||
//
|
||||
// return success($result);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 医生问诊开关
|
||||
* @return array
|
||||
@ -143,7 +273,7 @@ class DoctorInquiryService extends BaseService
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
$is_open = $this->request->input('is_open');// 是否开启(1:开启 0:关闭)
|
||||
|
||||
// 获取医生信息
|
||||
@ -166,6 +296,27 @@ class DoctorInquiryService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
// 判断对应信息是否存在
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 6) {
|
||||
// 疑难会诊
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if (empty($doctor_config_difficult_consultation)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请设置服务价格后开启");
|
||||
}
|
||||
}
|
||||
|
||||
// 随访包
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 9) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (empty($doctor_config_follow_package)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请添加服务内容后开启");
|
||||
}
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
@ -176,6 +327,17 @@ class DoctorInquiryService extends BaseService
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)) {
|
||||
if ($inquiry_type == 1 || $inquiry_type == 3){
|
||||
if ($inquiry_mode != 8 && $inquiry_mode != 9){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
// 此处两个参数都默认设置为0,随访包以及健康包使用不到
|
||||
$work_num_day = 0; // 每日接诊数量
|
||||
$inquiry_price = null; // 接诊价格(专家问诊-公益问诊)
|
||||
|
||||
// 获取系统问诊配置表
|
||||
$params = array();
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
@ -186,6 +348,12 @@ class DoctorInquiryService extends BaseService
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 获取系统问诊配置表
|
||||
if ($inquiry_mode != 8 && $inquiry_mode != 9){
|
||||
$work_num_day = $system_inquiry_config['default_work_num_day'] ?: 0;
|
||||
$inquiry_price = $system_inquiry_config['inquiry_price'];
|
||||
}
|
||||
|
||||
// 快速问诊,需创建
|
||||
$data = array();
|
||||
$data['doctor_id'] = $user_info['client_user_id'];
|
||||
@ -194,15 +362,50 @@ class DoctorInquiryService extends BaseService
|
||||
$data['inquiry_mode'] = $inquiry_mode;
|
||||
$data['is_enable'] = 1; // 是否启用(0:否 1:是)
|
||||
$data['last_enable_method'] = 1; // 最后开启方式(1:自己 2:后台)
|
||||
$data['work_num_day'] = $system_inquiry_config['default_work_num_day'] ?: 0;
|
||||
$data['inquiry_price'] = $system_inquiry_config['inquiry_price'];
|
||||
|
||||
$data['work_num_day'] = $work_num_day;
|
||||
$data['inquiry_price'] = $inquiry_price;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::addInquiryConfig($data);
|
||||
if (empty($doctor_inquiry_config)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
}else{
|
||||
|
||||
// 处理医生健康包
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 8){
|
||||
// 获取健康包配置
|
||||
$params = array();
|
||||
$health_package = HealthPackage::getOne($params);
|
||||
if (empty($health_package)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 获取专家图文问诊价格
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开启");
|
||||
}
|
||||
|
||||
// 价格计算(专家图文问诊价格*费率+30盒35元的干爽颗粒)
|
||||
$service_price = $doctor_inquiry_config['inquiry_price'] * $health_package['service_rate'] / 100 * 6 + $health_package['discount_product_total_amount'];
|
||||
|
||||
// 创建医生健康包
|
||||
$data = array();
|
||||
$data['doctor_id'] = $user_info['client_user_id'];
|
||||
$data['package_id'] = $health_package['package_id'];
|
||||
$data['service_price'] = $service_price;
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::addDoctorConfigHealthPackage($data);
|
||||
if (empty($doctor_config_health_package)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "开启失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 已存在问诊配置,进行修改
|
||||
$params = array();
|
||||
$params['inquiry_config_id'] = $doctor_inquiry_config["inquiry_config_id"];
|
||||
@ -210,11 +413,54 @@ class DoctorInquiryService extends BaseService
|
||||
$data = array();
|
||||
$data['is_enable'] = $is_open;
|
||||
$data['last_enable_method'] = 1;
|
||||
DoctorInquiryConfig::editInquiryConfig($params,$data);
|
||||
DoctorInquiryConfig::editInquiryConfig($params, $data);
|
||||
|
||||
// 处理医生健康包
|
||||
if ($inquiry_mode == 8 && $is_open == 1){
|
||||
// 获取健康包配置
|
||||
$params = array();
|
||||
$health_package = HealthPackage::getOne($params);
|
||||
if (empty($health_package)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
// 获取医生健康包
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::getOne($params);
|
||||
if (empty($doctor_config_health_package)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请添加服务内容后开启");
|
||||
}
|
||||
|
||||
// 获取专家图文问诊价格
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需设置图文问诊的价格,才可开启");
|
||||
}
|
||||
|
||||
// 重新价格计算(专家图文问诊价格*费率+30盒35元的干爽颗粒)
|
||||
$service_price = $doctor_inquiry_config['inquiry_price'] * $health_package['service_rate'] / 100 * 6 + $health_package['discount_product_total_amount'];
|
||||
|
||||
if ($doctor_config_health_package['service_price'] != $service_price){
|
||||
// 修改医生服务包
|
||||
$params = array();
|
||||
$params['health_package_id'] = $doctor_config_health_package['health_package_id'];
|
||||
|
||||
$data = array();
|
||||
$data['service_price'] = $service_price;
|
||||
DoctorConfigHealthPackage::edit($params,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
@ -388,7 +634,7 @@ class DoctorInquiryService extends BaseService
|
||||
* @param string|int $inquiry_mode 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||||
* @param string|int $doctor_id 医生id
|
||||
*/
|
||||
public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id):float
|
||||
public function getDoctorInquiryPrice(string|int $inquiry_type, string|int $inquiry_mode, string|int $doctor_id): float
|
||||
{
|
||||
// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
if ($inquiry_type == 1 || $inquiry_type == 3) {
|
||||
@ -425,17 +671,10 @@ class DoctorInquiryService extends BaseService
|
||||
* 获取医生问诊配置-服务设置
|
||||
* @return array
|
||||
*/
|
||||
public function getInquiryServiceConfig(): array
|
||||
public function getDoctorInquiryDifficultConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊)
|
||||
|
||||
if ($inquiry_mode != 6){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
@ -458,21 +697,19 @@ class DoctorInquiryService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
|
||||
if (empty($doctor_inquiry_config_service)){
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if (empty($doctor_config_difficult_consultation)) {
|
||||
return success(null);
|
||||
}else{
|
||||
return success($doctor_inquiry_config_service->toArray());
|
||||
} else {
|
||||
return success($doctor_config_difficult_consultation->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增医生问诊配置-服务设置
|
||||
* 新增医生问诊配置-疑难会诊-服务设置
|
||||
* @return array
|
||||
*/
|
||||
public function addInquiryServiceConfig(): array
|
||||
public function addDoctorInquiryDifficultConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
@ -503,23 +740,19 @@ class DoctorInquiryService extends BaseService
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 6;
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
|
||||
if (!empty($doctor_inquiry_config_service)){
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if (!empty($doctor_config_difficult_consultation)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "已存在服务设置,请勿重复设置");
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['doctor_id'] = $doctor['doctor_id'];
|
||||
$data['inquiry_type'] = 1;
|
||||
$data['inquiry_mode'] = 6;
|
||||
$data['service_content'] = $service_content;
|
||||
$data['service_process'] =$service_process;
|
||||
$data['service_period'] =$service_period;
|
||||
$data['service_rounds'] =$service_rounds;
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::addDoctorInquiryConfigService($data);
|
||||
if (empty($doctor_inquiry_config_service)){
|
||||
$data['service_process'] = $service_process;
|
||||
$data['service_period'] = $service_period;
|
||||
$data['service_rounds'] = $service_rounds;
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::addDoctorConfigDifficultConsultation($data);
|
||||
if (empty($doctor_config_difficult_consultation)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -527,14 +760,14 @@ class DoctorInquiryService extends BaseService
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改医生问诊配置-服务设置
|
||||
* 修改医生问诊配置-疑难会诊-服务设置
|
||||
* @return array
|
||||
*/
|
||||
public function putInquiryServiceConfig(): array
|
||||
public function putDoctorInquiryDifficultConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$config_service_id = $this->request->route('config_service_id');
|
||||
$difficult_consultation_id = $this->request->route('difficult_consultation_id');
|
||||
|
||||
$service_content = $this->request->input('service_content');
|
||||
$service_process = $this->request->input('service_process');
|
||||
@ -562,39 +795,380 @@ class DoctorInquiryService extends BaseService
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['config_service_id'] = $config_service_id;
|
||||
$params['difficult_consultation_id'] = $difficult_consultation_id;
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
|
||||
if (empty($doctor_inquiry_config_service)){
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if (empty($doctor_config_difficult_consultation)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$data = array();
|
||||
if ($doctor_inquiry_config_service['service_content'] != $service_content){
|
||||
if ($doctor_config_difficult_consultation['service_content'] != $service_content) {
|
||||
$data['service_content'] = $service_content;
|
||||
}
|
||||
|
||||
if ($doctor_inquiry_config_service['service_process'] != $service_process){
|
||||
if ($doctor_config_difficult_consultation['service_process'] != $service_process) {
|
||||
$data['service_process'] = $service_process;
|
||||
}
|
||||
|
||||
if ($doctor_inquiry_config_service['service_period'] != $service_period){
|
||||
if ($doctor_config_difficult_consultation['service_period'] != $service_period) {
|
||||
$data['service_period'] = $service_period;
|
||||
}
|
||||
|
||||
if ($doctor_inquiry_config_service['service_rounds'] != $service_rounds){
|
||||
if ($doctor_config_difficult_consultation['service_rounds'] != $service_rounds) {
|
||||
$data['service_rounds'] = $service_rounds;
|
||||
}
|
||||
|
||||
if (!empty($data)){
|
||||
if (!empty($data)) {
|
||||
$params = array();
|
||||
$params['config_service_id'] = $doctor_inquiry_config_service['config_service_id'];
|
||||
$res = DoctorInquiryConfigService::edit($params,$data);
|
||||
if (!$res){
|
||||
$params['difficult_consultation_id'] = $doctor_config_difficult_consultation['difficult_consultation_id'];
|
||||
$res = DoctorConfigDifficultConsultation::edit($params, $data);
|
||||
if (!$res) {
|
||||
return fail();
|
||||
}
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-随访包
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorInquiryFollowConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
}
|
||||
|
||||
if ($doctor['is_bind_bank'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (empty($doctor_config_follow_package)) {
|
||||
return success(null);
|
||||
} else {
|
||||
return success($doctor_config_follow_package->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-随访包-列表
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorInquiryFollowItemConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$doctor_id = $this->request->route('doctor_id');
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
$result = array();
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (!empty($doctor_config_follow_package)) {
|
||||
$params = array();
|
||||
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
$doctor_config_follow_package_items = DoctorConfigFollowPackageItem::getOrderServicePeriodList($params);
|
||||
if (!empty($doctor_config_follow_package_items)) {
|
||||
foreach ($doctor_config_follow_package_items as &$doctor_config_follow_package_item){
|
||||
$doctor_config_follow_package_item['monthly_frequency'] = $doctor_config_follow_package['monthly_frequency'];
|
||||
$result[] = $doctor_config_follow_package_item->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增医生问诊配置-随访包
|
||||
* @return array
|
||||
*/
|
||||
public function addDoctorInquiryFollowConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$monthly_frequency = $this->request->input('monthly_frequency'); // 每月次数(0表示不限次)
|
||||
$service_rounds = $this->request->input('service_rounds'); // 服务回合数(0表示不限次)
|
||||
$items = $this->request->input('items'); // 随访包内容数据
|
||||
|
||||
if ($service_rounds != 0) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "服务回合数只允许为无限次");
|
||||
}
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
}
|
||||
|
||||
if ($doctor['is_bind_bank'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (!empty($doctor_config_follow_package)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "已存在随访包配置,请勿重复设置");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
$data = array();
|
||||
$data['doctor_id'] = $doctor['doctor_id'];
|
||||
$data['monthly_frequency'] = $monthly_frequency;
|
||||
$data['service_rounds'] = $service_rounds;
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::addDoctorConfigFollowPackage($data);
|
||||
if (empty($doctor_config_follow_package)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "添加失败");
|
||||
}
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (empty($item['service_period'])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
|
||||
}
|
||||
|
||||
if (!in_array($item['service_period'], [30, 90, 180, 360])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
|
||||
}
|
||||
|
||||
if (empty($item['service_price'])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格");
|
||||
}
|
||||
|
||||
if ($item['service_price'] < 10 || $item['service_price'] > 9999) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内");
|
||||
}
|
||||
|
||||
// 新增医生配置-随访包明细
|
||||
$data = array();
|
||||
$data['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
$data['service_period'] = $item['service_period'];
|
||||
$data['service_price'] = $item['service_price'];
|
||||
$doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data);
|
||||
if (empty($doctor_config_follow_package_item)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改医生问诊配置-随访包
|
||||
* @return array
|
||||
*/
|
||||
public function putDoctorInquiryFollowConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$monthly_frequency = $this->request->input('monthly_frequency'); // 每月次数(0表示不限次)
|
||||
$service_rounds = $this->request->input('service_rounds'); // 服务回合数(0表示不限次)
|
||||
$items = $this->request->input('items'); // 随访包内容数据
|
||||
|
||||
if ($service_rounds != 0) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "服务回合数只允许为无限次");
|
||||
}
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
}
|
||||
|
||||
if ($doctor['is_bind_bank'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (empty($doctor_config_follow_package)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请添加后再修改");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 修改随访包数据
|
||||
$follow_package_data = array();
|
||||
if ($doctor_config_follow_package['monthly_frequency'] != $monthly_frequency) {
|
||||
$follow_package_data['monthly_frequency'] = $monthly_frequency;
|
||||
}
|
||||
|
||||
if ($doctor_config_follow_package['service_rounds'] != $service_rounds) {
|
||||
$follow_package_data['service_rounds'] = $service_rounds;
|
||||
}
|
||||
|
||||
if (!empty($follow_package_data)) {
|
||||
$params = array();
|
||||
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
DoctorConfigFollowPackage::edit($params, $follow_package_data);
|
||||
}
|
||||
|
||||
// 删除随访包内容明细
|
||||
$params = array();
|
||||
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
DoctorConfigFollowPackageItem::del($params);
|
||||
|
||||
// 新增随访包内容明细
|
||||
foreach ($items as $item) {
|
||||
if (empty($item['service_period'])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
|
||||
}
|
||||
|
||||
if (!in_array($item['service_period'], [30, 90, 180, 360])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务周期");
|
||||
}
|
||||
|
||||
if (empty($item['service_price'])) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请填写服务价格");
|
||||
}
|
||||
|
||||
if ($item['service_price'] < 10 || $item['service_price'] > 9999) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "服务价格只允许设置在10-9999范围内");
|
||||
}
|
||||
|
||||
// 新增医生配置-随访包明细
|
||||
$data = array();
|
||||
$data['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
$data['service_period'] = $item['service_period'];
|
||||
$data['service_price'] = $item['service_price'];
|
||||
$doctor_config_follow_package_item = DoctorConfigFollowPackageItem::addDoctorConfigFollowPackageItem($data);
|
||||
if (empty($doctor_config_follow_package_item)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取医生问诊配置-健康包
|
||||
* @return array
|
||||
*/
|
||||
public function getDoctorInquiryHealthConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行实名认证");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行身份认证");
|
||||
}
|
||||
|
||||
if ($doctor['is_bind_bank'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡");
|
||||
}
|
||||
|
||||
if ($doctor['multi_point_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "本服务需开处方,您还未做多点执业认证,是否前往?");
|
||||
}
|
||||
|
||||
// 获取专家图文问诊价格
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = 1;
|
||||
$params['inquiry_mode'] = 1;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (empty($doctor_inquiry_config)){
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 获取健康包配置
|
||||
$params = array();
|
||||
$health_package = HealthPackage::getOne($params);
|
||||
if (empty($health_package)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['service_count'] = $health_package['service_count']; // 总服务次数
|
||||
$result['service_rate'] = $health_package['service_rate']; // 服务费率。100为满值,表示1,正常费率。
|
||||
$result['inquiry_price'] = $doctor_inquiry_config['inquiry_price']; // 专家问诊-图文接诊价格
|
||||
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,9 @@ use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageProduct;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserPatient;
|
||||
@ -282,6 +285,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -290,6 +294,15 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 1;
|
||||
@ -318,6 +331,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -326,12 +340,36 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 1;
|
||||
$message_content_data['title'] = "—等待医生接诊—";
|
||||
if ($order_inquiry['inquiry_type'] == 1) {
|
||||
$message_content_data['desc'] = "温馨提示:当前服务为专家问诊,医师接诊后可以在24小时内和医生沟通20个回合。医生繁忙请耐心等待,医生接诊会后第一时间短信通知您。";
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
$message_content_data['desc'] = "温馨提示:医生繁忙请耐心等待,医生接诊后会第一时间通知您。医生接诊后,服务有效期开始计算。";
|
||||
}else{
|
||||
$message_content_data['desc'] = "温馨提示:医生繁忙请耐心等待,医生接诊后会第一时间通知您。";
|
||||
}
|
||||
}else{
|
||||
$message_content_data['desc'] = "温馨提示:当前服务为专家问诊,医师接诊后可以在24小时内和医生沟通20个回合。医生繁忙请耐心等待,医生接诊会后第一时间短信通知您。";
|
||||
}
|
||||
} elseif ($order_inquiry['inquiry_type'] == 2) {
|
||||
$message_content_data['desc'] = "温馨提示:请耐心等待,您可继续补充病情,便于医生接诊后更快确认病情。";
|
||||
} elseif ($order_inquiry['inquiry_type'] == 3) {
|
||||
@ -363,6 +401,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -370,6 +409,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
@ -383,7 +430,84 @@ class ImService extends BaseService
|
||||
}
|
||||
|
||||
$message_content_data['title'] = "—问诊已开始,本次问诊可持续{$time}—";
|
||||
$message_content_data['desc'] = "医生已接诊,为提高沟通效率,您可一次性如实补充病情(具体症状,患病时长,用药情况及想咨询的问题等)。线上咨询不能代替面诊,医生建议仅供参考。";
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)){
|
||||
throw new BusinessException("im消息发送失败");
|
||||
}
|
||||
|
||||
// 获取服务包订单详情
|
||||
$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)){
|
||||
throw new BusinessException("im消息发送失败");
|
||||
}
|
||||
|
||||
// 转换服务包订单类型为汉字
|
||||
$order_type = orderServiceTypeToString($order_service_package['order_service_type']);
|
||||
|
||||
$start_time = date('Y年m月d日 H时i分',strtotime($order_service_package['start_time']));
|
||||
$finish_time = date('Y年m月d日 H时i分',strtotime($order_service_package['finish_time']));
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
|
||||
// 获取服务包当月剩余问诊次数
|
||||
if ($order_service_package_detail['monthly_frequency'] != 0 && !empty($order_service_package['start_time'])) {
|
||||
if ($is_first){
|
||||
// 首次必定只问诊了一次
|
||||
$month_inquiry_count = 1;
|
||||
}else{
|
||||
$month_inquiry_count = $OrderServicePackageService->getCurrentMonthInquiryCount($order_service_package['pay_time'],$order_service_package['order_service_type'],$order_service_package['user_id'], $order_service_package['doctor_id']);
|
||||
}
|
||||
|
||||
$remaining_inquiry_count = $order_service_package_detail['monthly_frequency'] - $month_inquiry_count;
|
||||
if ($remaining_inquiry_count < 0){
|
||||
$remaining_inquiry_count = 0;
|
||||
}
|
||||
}else{
|
||||
$remaining_inquiry_count = "不限";
|
||||
}
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
if ($is_first){
|
||||
$message_content_data['desc'] = "医生已接诊,{$order_type}服务开始,服务周期为:{$start_time}~{$finish_time},线上咨询不能代表面诊,医生的回复仅为建议。";
|
||||
}else{
|
||||
// 健康包
|
||||
if ($order_inquiry['inquiry_mode'] == 8){
|
||||
$remaining_quantity = 0;
|
||||
if ($order_service_package['order_service_type'] == 1){
|
||||
// 获取服务包内所有药品
|
||||
$health_package_products = $OrderServicePackageService->getOrderServiceProduct($order_service_package_detail['package_id']);
|
||||
foreach ($health_package_products as $health_package_product) {
|
||||
// 获取服务包内某一药品的剩余数量
|
||||
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'],$health_package_product['product_id'],$health_package_product['quantity']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($remaining_quantity > 0){
|
||||
$message_content_data['desc'] = "医生已接诊,健康包服务本月剩余{$remaining_inquiry_count}次问诊,且还剩余{$remaining_quantity}盒肝爽颗粒,提醒医生开具处方。";
|
||||
}else{
|
||||
$message_content_data['desc'] = "医生已接诊,健康包服务本月剩余{$remaining_inquiry_count}次问诊,服务周期为:{$start_time}~{$finish_time},线上咨询不能代表面诊,医生的回复仅为建议。";
|
||||
}
|
||||
}
|
||||
|
||||
// 随访包
|
||||
if ($order_inquiry['inquiry_mode'] == 9){
|
||||
$message_content_data['desc'] = "医生已接诊,{$order_type}服务本月剩余{$remaining_inquiry_count}次,服务周期为:{$start_time}~{$finish_time},线上咨询不能代表面诊,医生的回复仅为建议。";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$message_content_data['desc'] = "医生已接诊,为提高沟通效率,您可一次性如实补充病情(具体症状,患病时长,用药情况及想咨询的问题等)。线上咨询不能代替面诊,医生建议仅供参考。";
|
||||
}
|
||||
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
@ -408,6 +532,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -416,11 +541,48 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 1;
|
||||
$message_content_data['title'] = "—医生未接诊—";
|
||||
$message_content_data['desc'] = "医生因工作繁忙未能及时接诊,请您谅解。所支付金额会在24小时内原路退回,再次感谢您的支持";
|
||||
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)){
|
||||
throw new BusinessException("im消息发送失败");
|
||||
}
|
||||
|
||||
// 转换服务包订单类型为汉字
|
||||
$order_type = orderServiceTypeToString($order_service_package['order_service_type']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
$message_content_data['title'] = "—医生未接诊—";
|
||||
$message_content_data['desc'] = "温馨提示:医生因工作繁忙未能及时进行接诊,请您见谅。{$order_type}订单金额会在24小时内原路退回,感谢您的支持。";
|
||||
}else{
|
||||
$message_content_data['title'] = "—医生未接诊—";
|
||||
$message_content_data['desc'] = "温馨提示:医生因工作繁忙未能及时进行接诊,请您见谅;稍后请再次发起问诊。";
|
||||
}
|
||||
}else{
|
||||
$message_content_data['title'] = "—医生未接诊—";
|
||||
$message_content_data['desc'] = "医生因工作繁忙未能及时接诊,请您谅解。所支付金额会在24小时内原路退回,再次感谢您的支持";
|
||||
}
|
||||
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
@ -448,6 +610,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -456,6 +619,15 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = $message_type;
|
||||
@ -464,7 +636,8 @@ class ImService extends BaseService
|
||||
$message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$message_content_data['data']['order_prescription_id'] = $order_prescription_id;
|
||||
$message_content_data['data']['product_name'] = $product_name ?? "药品";
|
||||
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s', time());;
|
||||
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s', time());
|
||||
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
@ -489,6 +662,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -496,12 +670,37 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 1;
|
||||
$message_content_data['title'] = "—问诊退款—";
|
||||
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
$message_content_data['title'] = "—服务退款—";
|
||||
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
|
||||
}else{
|
||||
$message_content_data['title'] = "—问诊退款—";
|
||||
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
|
||||
}
|
||||
}else{
|
||||
$message_content_data['title'] = "—问诊退款—";
|
||||
$message_content_data['desc'] = "平台已自动发起退款,请注意查看账户信息。";
|
||||
}
|
||||
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
@ -525,6 +724,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -532,11 +732,18 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 - 患者-医生
|
||||
$message_content_data = array();
|
||||
$message_content_data['message_type'] = 2; // 订单结束评价弹出
|
||||
// $message_content_data['title'] = "评价";
|
||||
$message_content_data['desc'] = "";
|
||||
$message_content_data['data']['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
|
||||
@ -545,7 +752,6 @@ class ImService extends BaseService
|
||||
];
|
||||
|
||||
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -563,6 +769,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -570,6 +777,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
@ -580,7 +795,6 @@ class ImService extends BaseService
|
||||
$message_content_data['data']['order_prescription_id'] = $order_prescription_id;
|
||||
$message_content_data['data']['product_name'] = $product_name ?: "药品";
|
||||
$message_content_data['data']['pharmacist_verify_time'] = date('Y-m-d H:i:s', time());;
|
||||
|
||||
$message_content = [
|
||||
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
@ -604,6 +818,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -611,6 +826,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
@ -639,6 +862,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -646,6 +870,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3) {
|
||||
// 专家、公益
|
||||
@ -755,6 +987,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -762,6 +995,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
@ -796,6 +1037,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -803,6 +1045,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
@ -838,6 +1088,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -845,6 +1096,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容
|
||||
$message_content_data = array();
|
||||
@ -882,6 +1141,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -922,6 +1182,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -929,6 +1190,14 @@ class ImService extends BaseService
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
// 消息内容 医生-患者
|
||||
$message_content_data = array();
|
||||
@ -959,6 +1228,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -998,6 +1268,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -1037,6 +1308,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -1076,6 +1348,7 @@ class ImService extends BaseService
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
@ -1100,4 +1373,44 @@ class ImService extends BaseService
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多点医生接诊后,自动回复消息
|
||||
* @param array|object $order_inquiry 问诊订单数据
|
||||
* @param string $doctor_user_id 医生用户id
|
||||
* @param string $patient_user_id 患者用户id
|
||||
* @return void
|
||||
*/
|
||||
public function multiPointDoctorInquiryAutoReply(array|object $order_inquiry, string $doctor_user_id, string $patient_user_id): void
|
||||
{
|
||||
try {
|
||||
// 发送消息
|
||||
$cloud_custom_data = array();
|
||||
$cloud_custom_data['order_inquiry_id'] = (string)$order_inquiry['order_inquiry_id'];
|
||||
$cloud_custom_data['order_no'] = (string)$order_inquiry['inquiry_no'];
|
||||
$cloud_custom_data['is_system'] = 1;
|
||||
$cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$cloud_custom_data['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
$cloud_custom_data['message_rounds'] = 0;
|
||||
$cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name'];
|
||||
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex'];
|
||||
$cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age'];
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取im消息推送中,服务包订单相关的自定义参数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$result = $OrderServicePackageService->getImServicePackageCloudCustomData($order_inquiry['inquiry_no']);
|
||||
if (!empty($result)){
|
||||
$cloud_custom_data = array_merge($cloud_custom_data,$result);
|
||||
}
|
||||
}
|
||||
|
||||
$message_content = [
|
||||
'Text' => "您好,已查看您提交的病情信息,您可以继续补充病情信息以便更好为您提供服务。如有购药需求,将按照病情及需要开具处方,需要您确认。",
|
||||
];
|
||||
|
||||
$this->sendMessage($doctor_user_id, $patient_user_id, $message_content, "TIMTextElem", $cloud_custom_data);
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
164
app/Services/MessagePushInquiryService.php
Normal file
164
app/Services/MessagePushInquiryService.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\SendStationMessageProducer;
|
||||
use App\Amqp\Producer\SendSubMessageProducer;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
/**
|
||||
* 消息推送业务类-问诊
|
||||
*/
|
||||
class MessagePushInquiryService extends BaseService
|
||||
{
|
||||
// 被推送者用户数据
|
||||
public ?array $user = null;
|
||||
|
||||
// 订单数据
|
||||
public ?array $order = null;
|
||||
|
||||
/**
|
||||
* 患者-通知患者医生已接诊
|
||||
* @return void
|
||||
*/
|
||||
public function patientDoctorAcceptedInquiry(): void
|
||||
{
|
||||
try {
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $this->order['order_no'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error("问诊订单数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $this->order['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error("医生数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 站内
|
||||
$station_data = array();
|
||||
$station_data['user_id'] = $this->user['user_id'];
|
||||
$station_data['notice_type'] = 3;
|
||||
$station_data['notice_system_type'] = 1;
|
||||
$station_data['from_name'] = "肝胆小秘书";
|
||||
$station_data['notice_brief_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情。";
|
||||
$station_data['notice_title'] = "{$user_doctor['user_name']}医生已接诊,请尽快和医生进行沟通交流病情,点击查看详情。";
|
||||
$station_data['notice_content'] = "{$user_doctor['user_name']}医生已接诊,请您尽快和医生进行沟通交流病情,您可以点击问诊详情进行交流。";
|
||||
$station_data['link_type'] = 1;// 聊天详情页
|
||||
|
||||
$link_params = array();
|
||||
$link_params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$link_params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$link_params['doctor_user_id'] = $user_doctor['user_id'];
|
||||
$link_params['patient_user_id'] = $order_inquiry['user_id'];
|
||||
$station_data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||
$station_data['button_type'] = 6; // 问诊详情
|
||||
|
||||
$message = new SendStationMessageProducer($station_data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error(json_encode($station_data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 订阅
|
||||
// 获取问诊订单关联病例
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error("病例数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 问诊内容-病情主诉
|
||||
$disease_desc = $order_inquiry_case['disease_desc'];
|
||||
if (!empty($disease_desc)) {
|
||||
if (strlen($disease_desc) > 15) {
|
||||
$disease_desc = mb_substr($disease_desc, 0, 15);
|
||||
if ($disease_desc) {
|
||||
$disease_desc = $disease_desc . "...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sub_data = array();
|
||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||
$sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒
|
||||
$sub_data['params']['page'] = "patient/pages/orderDetail/orderDetail?order_inquiry_id={$order_inquiry['order_inquiry_id']}";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => (string)$disease_desc,// 问诊内容-病情主诉
|
||||
"thing2" => "医生已接诊,请您尽快和医生沟通交流病情",// 提醒内容
|
||||
"name3" => (string)$user_doctor['user_name'],// 问诊医生
|
||||
"thing4" => "点击查看问诊订单详情",// 提示说明
|
||||
];
|
||||
|
||||
$subscription_data = array();
|
||||
$subscription_data['sub_data'] = $sub_data;
|
||||
$subscription_data['sms_data'] = array();
|
||||
|
||||
$message = new SendSubMessageProducer($subscription_data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error(json_encode($subscription_data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 短信
|
||||
// 获取系统接诊配置
|
||||
$params = array();
|
||||
$params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$params['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (empty($system_inquiry_config)) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error("获取系统接诊配置失败");
|
||||
return;
|
||||
}
|
||||
|
||||
// 问诊时长
|
||||
$duration = $system_inquiry_config['duration'];
|
||||
if ($duration <= 0) {
|
||||
$duration = "不限制";
|
||||
} else {
|
||||
$duration = $duration . "分钟";
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['template_code'] = "SMS_271955088";
|
||||
$data['scene_desc'] = "通知患者医生已接诊";
|
||||
$data['phone'] = $this->user['mobile'];
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
|
||||
$template_param = array();
|
||||
$template_param['type'] = inquiryTypeToString($order_inquiry['inquiry_type']);
|
||||
$template_param['name'] = $user_doctor['user_name'];
|
||||
$template_param['duration'] = $duration; // 服务时长
|
||||
$data['template_param'] = $template_param;
|
||||
|
||||
$message = new SendStationMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("MessagePushInquiryService-patientDoctorAcceptedInquiry")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
58
app/Services/MessagePushService.php
Normal file
58
app/Services/MessagePushService.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Order;
|
||||
use App\Model\User;
|
||||
|
||||
class MessagePushService extends BaseService
|
||||
{
|
||||
private MessagePushServicePackageService|MessagePushInquiryService $strategy;
|
||||
|
||||
/**
|
||||
* @param string $to_user_id 用户id(存在被推送者时存在,否则为空)
|
||||
* @param string $order_no 问诊订单系统订单编号
|
||||
*/
|
||||
public function __construct(string $to_user_id, string $order_no){
|
||||
$params = array();
|
||||
$params['user_id'] = $to_user_id;
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)){
|
||||
throw new BusinessException("订单数据错误");
|
||||
}
|
||||
|
||||
if ($order['order_type'] == 4 || $order['order_type'] == 5){
|
||||
$this->strategy = new MessagePushServicePackageService($order_no);
|
||||
}else{
|
||||
$this->strategy = new MessagePushInquiryService();
|
||||
}
|
||||
|
||||
$this->strategy->order = $order->toArray();
|
||||
$this->strategy->user = $user->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者-通知患者医生已接诊
|
||||
* @return void
|
||||
*/
|
||||
public function patientDoctorAcceptedInquiry(): void
|
||||
{
|
||||
$this->strategy->patientDoctorAcceptedInquiry();
|
||||
}
|
||||
|
||||
// 医生-服务包待接诊
|
||||
// 仅限于患者购买服务包后,首次发起问诊后使用
|
||||
public function doctorWaitInquiry(): void
|
||||
{
|
||||
$this->strategy->doctorWaitInquiry();
|
||||
}
|
||||
}
|
||||
195
app/Services/MessagePushServicePackageService.php
Normal file
195
app/Services/MessagePushServicePackageService.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\SendStationMessageProducer;
|
||||
use App\Amqp\Producer\SendSubMessageProducer;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
|
||||
/**
|
||||
* 消息推送业务类-服务包问诊订单
|
||||
*/
|
||||
class MessagePushServicePackageService extends BaseService
|
||||
{
|
||||
// 被推送者用户数据
|
||||
public ?array $user = null;
|
||||
|
||||
// 订单数据
|
||||
public ?array $order = null;
|
||||
|
||||
// 服务包订单数据
|
||||
public ?array $order_service_package = null;
|
||||
|
||||
// 问诊订单数据
|
||||
public ?array $order_inquiry = null;
|
||||
|
||||
public function __construct(string $order_no){
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)){
|
||||
throw new BusinessException("订单数据错误");
|
||||
}
|
||||
|
||||
$this->order_service_package = $order_service_package->toArray();
|
||||
|
||||
$params = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* 患者-通知患者医生已接诊
|
||||
* @return void
|
||||
*/
|
||||
public function patientDoctorAcceptedInquiry(): void
|
||||
{
|
||||
try {
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $this->order['order_no'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("问诊订单数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $this->order['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("医生数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 站内
|
||||
// 获取服务包订单详情
|
||||
$params = array();
|
||||
$params['order_service_no'] = $this->order['order_no'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (empty($order_service_package_detail)){
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error("服务包订单数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 转换服务包订单类型为汉字
|
||||
$order_type = orderServiceTypeToString($this->order_service_package['order_service_type']);
|
||||
|
||||
// 转换每月次数为汉字
|
||||
$monthly_frequency = monthlyFrequencyToString($order_service_package_detail['monthly_frequency']);
|
||||
|
||||
$start_time = date('Y年m月d日 H时i分',strtotime($this->order_service_package['start_time']));
|
||||
$finish_time = date('Y年m月d日 H时i分',strtotime($this->order_service_package['finish_time']));
|
||||
|
||||
// 站内
|
||||
$data = array();
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
$data['notice_type'] = 3;
|
||||
$data['notice_system_type'] = 1;
|
||||
$data['from_name'] = "肝胆小秘书";
|
||||
$data['notice_brief_title'] = "您购买的{$order_type},医生已接诊,点击查看详情。";
|
||||
$data['notice_title'] = "您购买的{$order_type},{$user_doctor['user_name']}医生已接诊,每次问诊不限制沟通回合数,您可以点击【问诊详情】进行交流。";
|
||||
$data['notice_content'] = "您购买的{$order_type},{$user_doctor['user_name']}医生已接诊,每次问诊不限制沟通回合数,您可以点击【问诊详情】进行交流。";
|
||||
$data['link_type'] = 1;// 聊天详情页
|
||||
|
||||
$link_params = array();
|
||||
$link_params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$link_params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$link_params['doctor_user_id'] = $user_doctor['user_id'];
|
||||
$link_params['patient_user_id'] = $order_inquiry['user_id'];
|
||||
$data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||
$data['button_type'] = 6; // 问诊详情
|
||||
|
||||
$message = new SendStationMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 订阅
|
||||
$sub_data = array();
|
||||
$sub_data['push_user_id'] = $this->user['user_id'];
|
||||
$sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒
|
||||
$sub_data['params']['page'] = "patient/pages/orderDetail/orderDetail?order_inquiry_id={$order_inquiry['order_inquiry_id']}";
|
||||
$sub_data['params']['data'] = [
|
||||
"thing1" => $order_type . "服务",
|
||||
"thing2" => "医生已接诊",// 提醒内容
|
||||
"name3" => (string)$user_doctor['user_name'],// 问诊医生
|
||||
"thing4" => "点击查看详情",// 提示说明
|
||||
];
|
||||
|
||||
$subscription_data = array();
|
||||
$subscription_data['sub_data'] = $sub_data;
|
||||
$subscription_data['sms_data'] = array();
|
||||
|
||||
$message = new SendSubMessageProducer($subscription_data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error(json_encode($subscription_data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 短信
|
||||
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("MessagePushServicePackageService-patientDoctorAcceptedInquiry")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 医生-服务包待接诊
|
||||
// 仅限于患者购买服务包后,首次发起问诊后使用
|
||||
public function doctorWaitInquiry()
|
||||
{
|
||||
try {
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $this->order['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
Log::getInstance("MessagePushServicePackageService-doctorWaitInquiry")->error("医生数据为空");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 站内
|
||||
$data = array();
|
||||
$data['user_id'] = $this->user['user_id'];
|
||||
$data['notice_type'] = 1;
|
||||
$data['inquiry_type'] = 1; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
$data['from_name'] = "肝胆小秘书";
|
||||
$data['notice_brief_title'] = "您有新的问诊咨询,请及时处理。";
|
||||
$data['notice_title'] = "您有新的问诊咨询,请及时处理。";
|
||||
$data['notice_content'] = "您有新的问诊咨询,请及时处理。";
|
||||
$data['link_type'] = 3; // 问诊消息列表页
|
||||
|
||||
$link_params = array();
|
||||
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||
$link_params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
|
||||
$link_params['doctor_user_id'] = $user_doctor['user_id'];
|
||||
$link_params['patient_user_id'] = $this->order_inquiry['user_id'];
|
||||
$data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||
|
||||
$message = new SendStationMessageProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("MessagePushServicePackageService-doctorWaitInquiry")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -469,13 +469,13 @@ class OrderPrescriptionService extends BaseService
|
||||
|
||||
OrderPrescription::edit($params, $data);
|
||||
|
||||
// 医生-开具的处方审核未通过
|
||||
/*// 医生-开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($doctor_user_id, $order_inquiry_id);
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription_id);
|
||||
|
||||
// 患者-处方审核未通过
|
||||
$MessagePush = new MessagePush($patient_user_id, $order_inquiry_id);
|
||||
$MessagePush->patientPrescriptionVerifyFail();
|
||||
$MessagePush->patientPrescriptionVerifyFail();*/
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\OrderPrescription;
|
||||
@ -12,6 +13,9 @@ use App\Model\OrderProduct;
|
||||
use App\Model\OrderProductCoupon;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\OrderProductRefund;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\OrderServicePackageProduct;
|
||||
use App\Model\Product;
|
||||
use App\Model\ProductPlatformAmount;
|
||||
use App\Model\UserPatient;
|
||||
@ -40,12 +44,10 @@ class OrderProductService extends BaseService
|
||||
/**
|
||||
* 取消未支付的药品订单
|
||||
* 外层需加事物
|
||||
* @param string|int $order_no 系统订单编号
|
||||
* @param string|int $order_no 订单编号
|
||||
* @param string|int $cancel_reason 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时
|
||||
* @param string $cancel_remarks 订单取消原因
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function cancelUnpayProductOrder(string|int $order_no,string|int $cancel_reason,string $cancel_remarks): array
|
||||
{
|
||||
@ -59,36 +61,36 @@ class OrderProductService extends BaseService
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单数据";
|
||||
$result['message'] = "未查询到对应订单数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_product['order_product_status'] == 5){
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的问诊订单:订单已取消";
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已取消";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_product['order_product_status'] != 1){
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单:订单状态为" . $order_product['order_product_status'] . "无法执行";
|
||||
$result['message'] = "订单取消失败";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!in_array($order_product['refund_status'],[0,4,5])) {
|
||||
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单:订单正在退款中";
|
||||
$result['message'] = "订单正在退款中";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_product['pay_status'] == 2) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的问诊订单:订单已支付";
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已支付";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -98,7 +100,17 @@ class OrderProductService extends BaseService
|
||||
$user_patient = UserPatient::getOne($params);
|
||||
if (empty($user_patient)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应用户数据";
|
||||
$result['message'] = "未查询到对应用户数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "未查询到对应订单数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -125,7 +137,7 @@ class OrderProductService extends BaseService
|
||||
$order_product_item = OrderProductItem::getList($params);
|
||||
if (empty($order_product_item)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单商品订单列表";
|
||||
$result['message'] = "未查询到对应订单商品订单列表";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -136,7 +148,7 @@ class OrderProductService extends BaseService
|
||||
$product = Product::getOne($params);
|
||||
if (empty($product)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单商品订单列表";
|
||||
$result['message'] = "未查询到对应订单商品订单列表";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -145,7 +157,7 @@ class OrderProductService extends BaseService
|
||||
$product_platform_amount = ProductPlatformAmount::getSharedLockOne($params);
|
||||
if (empty($product_platform_amount)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:无商品库存数据";
|
||||
$result['message'] = "无商品库存数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -153,6 +165,27 @@ class OrderProductService extends BaseService
|
||||
$params = array();
|
||||
$params['amount_id'] = $product_platform_amount['amount_id'];
|
||||
ProductPlatformAmount::inc($params, 'stock', (float)$item['amount']);
|
||||
|
||||
// 获取患者家庭成员进行中的服务包订单-健康包
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$order_service_package = $OrderServicePackageService->getPatientFamilyInProgressServicePackage($order_inquiry['user_id'],$order_inquiry['family_id'],$order_inquiry['doctor_id'],1);
|
||||
if (!empty($order_service_package)){
|
||||
// 回退服务包已使用药品数量
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
$params['order_product_id'] = $item['order_product_id'];
|
||||
$params['product_item_id'] = $item['product_item_id'];
|
||||
$params['product_id'] = $item['product_id'];
|
||||
$order_service_package_product = OrderServicePackageProduct::getOne($params);
|
||||
if (!empty($order_service_package_product)){
|
||||
$params = array();
|
||||
$params['service_product_id'] = $order_service_package_product['service_product_id'];
|
||||
|
||||
$data = array();
|
||||
$data['used_quantity'] = 0;
|
||||
OrderServicePackageProduct::edit($params,$data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取处方数据
|
||||
@ -161,7 +194,7 @@ class OrderProductService extends BaseService
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)){
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单处方";
|
||||
$result['message'] = "未查询到对应订单处方";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -181,7 +214,7 @@ class OrderProductService extends BaseService
|
||||
$order_prescription_product = OrderPrescriptionProduct::getList($params);
|
||||
if (empty($order_prescription_product)) {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单处方商品数据";
|
||||
$result['message'] = "未查询到对应订单处方商品数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -225,7 +258,7 @@ class OrderProductService extends BaseService
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function OrderProductRefund(string $order_product_id, string $refund_reason): void
|
||||
/*public function OrderProductRefund(string $order_product_id, string $refund_reason): void
|
||||
{
|
||||
// 获取药品订单数据
|
||||
$params = array();
|
||||
@ -344,6 +377,99 @@ class OrderProductService extends BaseService
|
||||
$data = array();
|
||||
$data['refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 药品订单退款
|
||||
* @param string $order_product_id 药品订单id
|
||||
* @param string $refund_reason 退款原因
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function OrderProductRefund(string $order_product_id, string $refund_reason): void
|
||||
{
|
||||
// 获取药品订单数据
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
throw new BusinessException("订单数据为空");
|
||||
}
|
||||
|
||||
// 系统退款编号
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
$product_refund_no = $generator->generate();
|
||||
|
||||
// 检测订单金额
|
||||
if ($order_product['payment_amount_total'] <= 0){
|
||||
throw new BusinessException("订单金额错误");
|
||||
}
|
||||
|
||||
// 发起退款
|
||||
$WechatPay = new WechatPay(1, 2);
|
||||
|
||||
$options = array();
|
||||
$options['transaction_id'] = $order_product['escrow_trade_no'];
|
||||
$options['out_refund_no'] = (string)$product_refund_no;
|
||||
$options['reason'] = $refund_reason;
|
||||
$options['amount'] = [
|
||||
'refund' => (int)($order_product['payment_amount_total'] * 100),
|
||||
'total' => (int)($order_product['payment_amount_total'] * 100),
|
||||
'currency' => "CNY",
|
||||
];
|
||||
|
||||
$result = $WechatPay->refund($options);
|
||||
|
||||
// 处理订单退款状态
|
||||
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
$success_time = "";
|
||||
if ($result['status'] == "SUCCESS") {
|
||||
// 退款成功
|
||||
$refund_status = 3;
|
||||
$success_time = $result['success_time'];
|
||||
} elseif ($result['status'] == "CLOSED") {
|
||||
// 退款关闭
|
||||
$refund_status = 5;
|
||||
} elseif ($result['status'] == "PROCESSING") {
|
||||
// 退款处理中
|
||||
$refund_status = 2;
|
||||
} elseif ($result['status'] == "ABNORMAL") {
|
||||
// 退款异常,此情况不处理,进行短信通知
|
||||
throw new BusinessException("订单退款状态异常");
|
||||
} else {
|
||||
throw new BusinessException("订单退款状态错误");
|
||||
}
|
||||
|
||||
$refund_id = $result['refund_id'];
|
||||
|
||||
// 新增退款表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order_product['patient_id'];
|
||||
$data['order_product_id'] = $order_product['order_product_id'];
|
||||
$data['order_product_no'] = $order_product['order_product_no'];
|
||||
$data['product_refund_no'] = $product_refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['product_refund_status'] = $refund_status;
|
||||
$data['refund_total'] = $order_product['payment_amount_total'];
|
||||
$data['refund_reason'] = $refund_reason;
|
||||
|
||||
if ($refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
|
||||
$order_product_refund = OrderProductRefund::addOrderProductRefund($data);
|
||||
if (empty($order_product_refund)) {
|
||||
throw new BusinessException("添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改药品订单表状态
|
||||
$data = array();
|
||||
$data['refund_status'] = $refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
1131
app/Services/OrderService.php
Normal file
1131
app/Services/OrderService.php
Normal file
File diff suppressed because it is too large
Load Diff
1754
app/Services/OrderServicePackageService.php
Normal file
1754
app/Services/OrderServicePackageService.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,12 +7,15 @@ use App\Model\BasicJob;
|
||||
use App\Model\BasicNation;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\InquiryCaseProduct;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageCase;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\PatientFamilyHealth;
|
||||
use App\Model\PatientFamilyPersonal;
|
||||
@ -630,4 +633,90 @@ class PatientCaseService extends BaseService
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单病例详情-基础
|
||||
* @return array
|
||||
*/
|
||||
public function getPatientFamilyServiceCaseSimple(): array
|
||||
{
|
||||
$order_no = $this->request->route('order_no');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_id'] = $order['order_id'];
|
||||
$order_service_package_case = OrderServicePackageCase::getOne($params);
|
||||
if (empty($order_service_package_case)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['patient_name'] = $order_service_package['patient_name'];
|
||||
$result['patient_sex'] = $order_service_package['patient_sex'];
|
||||
$result['patient_age'] = $order_service_package['patient_age'];
|
||||
$result['disease_desc'] = $order_service_package_case['disease_desc'];
|
||||
$result['created_at'] = $order_service_package['created_at']; // 创建时间
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务包订单病例详情
|
||||
* @return array
|
||||
*/
|
||||
public function getPatientFamilyServiceCase(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$order_no = $this->request->route('order_no');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_id'] = $order['order_id'];
|
||||
$order_service_package_case = OrderServicePackageCase::getOne($params);
|
||||
if (empty($order_service_package_case)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
$order_service_package_case = $order_service_package_case->toArray();
|
||||
|
||||
// 复诊凭证
|
||||
if (!empty($order_service_package_case['diagnose_images'])) {
|
||||
$diagnose_images = explode(',', $order_service_package_case['diagnose_images']);
|
||||
foreach ($diagnose_images as &$item) {
|
||||
$item = addAliyunOssWebsite($item);
|
||||
}
|
||||
|
||||
$order_service_package_case['diagnose_images'] = $diagnose_images;
|
||||
}
|
||||
|
||||
return success($order_service_package_case);
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,9 @@ namespace App\Services;
|
||||
use App\Constants\DoctorTitleCode;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\DiseaseClassExpertise;
|
||||
use App\Model\DoctorConfigFollowPackage;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
use App\Model\DoctorConfigHealthPackage;
|
||||
use App\Model\DoctorExpertise;
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\DoctorInquiryConfig as DoctorInquiryConfigModel;
|
||||
@ -129,6 +132,43 @@ class PatientDoctorService extends BaseService
|
||||
|
||||
// 头像
|
||||
$user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
|
||||
// 问诊配置
|
||||
foreach ($user_doctor['DoctorInquiryConfig'] as $key => $doctor_inquiry_config){
|
||||
// 随访包
|
||||
if ($doctor_inquiry_config['inquiry_type'] == 1 && $doctor_inquiry_config['inquiry_mode'] == 9){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_inquiry_config['doctor_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (!empty($doctor_config_follow_package)) {
|
||||
$params = array();
|
||||
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
$doctor_config_follow_package_items = DoctorConfigFollowPackageItem::getList($params);
|
||||
if (!empty($doctor_config_follow_package_items)) {
|
||||
foreach ($doctor_config_follow_package_items as $k => $doctor_config_follow_package_item){
|
||||
if ($k == 0){
|
||||
$user_doctor['DoctorInquiryConfig'][$key]['inquiry_price'] = $doctor_config_follow_package_item['service_price'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($doctor_config_follow_package_item['service_price'] < $user_doctor['DoctorInquiryConfig'][$key]['inquiry_price']){
|
||||
$user_doctor['DoctorInquiryConfig'][$key]['inquiry_price'] = $doctor_config_follow_package_item['service_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 健康包
|
||||
if ($doctor_inquiry_config['inquiry_type'] == 1 && $doctor_inquiry_config['inquiry_mode'] == 8){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_inquiry_config['doctor_id'];
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::getOne($params);
|
||||
if (!empty($doctor_config_health_package)){
|
||||
$user_doctor['DoctorInquiryConfig'][$key]['inquiry_price'] = $doctor_config_health_package['service_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return success($user_doctors);
|
||||
@ -290,8 +330,9 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 检测公益问诊-当前患者问诊次数(24小时内两次公益问诊)
|
||||
if ($inquiry_type == 4){
|
||||
// 公益问诊
|
||||
if ($inquiry_type == 3){
|
||||
// 检测公益问诊-当前患者问诊次数(24小时内两次公益问诊)
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
@ -307,12 +348,14 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 检测当前是否符合系统问诊时间
|
||||
$inquiryService = new InquiryService();
|
||||
$is_system_time_pass = $inquiryService->checkSystemInquiryTime($inquiry_type);
|
||||
if (!$is_system_time_pass){
|
||||
// 非坐班时间
|
||||
if ($inquiry_type == 4){
|
||||
// 问诊购药
|
||||
$is_system_time_pass = false;
|
||||
if ($inquiry_type == 4){
|
||||
// 检测当前是否符合系统问诊时间
|
||||
$inquiryService = new InquiryService();
|
||||
$is_system_time_pass = $inquiryService->checkSystemInquiryTime($inquiry_type);
|
||||
if (!$is_system_time_pass){
|
||||
// 非坐班时间
|
||||
// 问诊购药非坐班时间不允许接诊
|
||||
$result['status'] = 3;
|
||||
$result['data'] = "";
|
||||
@ -321,7 +364,7 @@ class PatientDoctorService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
// 检测快速、购药问诊是否由可分配医生
|
||||
// 检测快速、购药问诊是否有可分配医生
|
||||
if ($inquiry_type == 2 || $inquiry_type == 4){
|
||||
$UserDoctorService = new UserDoctorService();
|
||||
$doctor_id = $UserDoctorService->getInquiryAssignDoctor($inquiry_type,$user_info['client_user_id'],$is_system_time_pass);
|
||||
@ -334,7 +377,7 @@ class PatientDoctorService extends BaseService
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
}catch(\Throwable $e){
|
||||
// 错误不做处理,此处只是检测
|
||||
return success($result);
|
||||
}
|
||||
|
||||
@ -174,15 +174,14 @@ class PatientFamilyService extends BaseService
|
||||
}
|
||||
|
||||
// 实人认证-生产环境开启
|
||||
|
||||
|
||||
$app_env = config('app_env', 'dev');
|
||||
if ($app_env != "dev") {
|
||||
if ($app_env == "dev") {
|
||||
$IdCard = new IdCard();
|
||||
|
||||
$params = array();
|
||||
$params['name'] = $request_params['card_name'];
|
||||
$params['cardNo'] = $request_params['id_number'];
|
||||
$params['dataId'] = $user_info['user_id'];
|
||||
$res = $IdCard->checkIdCard($params);
|
||||
if (!empty($res)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\SystemInquiryTime;
|
||||
use App\Model\UserDoctor;
|
||||
|
||||
/**
|
||||
* 系统配置
|
||||
@ -80,4 +83,35 @@ class SystemService extends BaseService
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统问诊配置
|
||||
* @return array
|
||||
*/
|
||||
public function getSystemInquiryConfig(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$inquiry_type = $this->request->input('inquiry_type');// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊)
|
||||
$inquiry_mode = $this->request->input('inquiry_mode');// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员 6:疑难会诊 7:附赠 8:健康包 9:随访包)
|
||||
|
||||
// 系统问诊配置表
|
||||
$params = array();
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (empty($system_inquiry_config)) {
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
$system_inquiry_config = $system_inquiry_config->toArray();
|
||||
|
||||
// 系统价格(公益问诊)
|
||||
$system_inquiry_config['system_inquiry_price'] = [];
|
||||
if ($inquiry_type == 3) {
|
||||
$system_inquiry_config['system_inquiry_price'] = explode(',', $system_inquiry_config['inquiry_price']);
|
||||
}
|
||||
|
||||
return success($system_inquiry_config);
|
||||
}
|
||||
}
|
||||
@ -97,6 +97,169 @@ class UserCouponService extends BaseService
|
||||
return $coupon_total_price;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者购药可用的优惠卷
|
||||
* @param string|int $user_id
|
||||
* @param array $coupon_product_datas
|
||||
* @return array
|
||||
*/
|
||||
// public function getUserProductUsableCoupon(string|int $user_id, array $coupon_product_datas): array
|
||||
// {
|
||||
// $user_coupons = UserCoupon::getUserProductUsableCoupon($user_id);
|
||||
// if (empty($user_coupons)) {
|
||||
// return array();
|
||||
// }
|
||||
//
|
||||
// $user_coupons = $user_coupons->toArray();
|
||||
//
|
||||
// $coupons = array();
|
||||
// foreach ($user_coupons as $user_coupon){
|
||||
// $user_coupon['coupon']['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
// $coupons[] = $user_coupon['coupon'];
|
||||
// }
|
||||
//
|
||||
// // 选中的优惠卷
|
||||
// $selected_coupons = array();
|
||||
//
|
||||
// // 优惠卷最高金额
|
||||
// $coupon_high_price = 0;
|
||||
//
|
||||
// // 是否存在互斥卷
|
||||
// $is_mutex = 0;
|
||||
//
|
||||
// // 新增字段
|
||||
// foreach ($coupons as $key => $coupon) {
|
||||
// $coupons[$key]['is_can_use'] = 1;// 是否可使用
|
||||
// $coupons[$key]['cannot_use_coupon_reason'] = ""; // 不可使用原因
|
||||
// }
|
||||
//
|
||||
// // 处理优惠卷数量限制问题
|
||||
// foreach ($coupons as $key => $coupon) {
|
||||
// // 处理数量优惠卷
|
||||
// if ($coupon['coupon_type'] == 3){
|
||||
// // 数量是否足够标识字段
|
||||
// $quantity_quantity = 0;
|
||||
//
|
||||
// foreach ($coupon_product_datas as $coupon_product_data){
|
||||
// // 存在指定商品的情况,如该优惠卷不包含此商品,跳过
|
||||
// if (!empty($coupon['product_id'])){
|
||||
// if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])){
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 判断商品数量是否满足
|
||||
// if($coupon['min_usable_number'] > $coupon_product_data['product_num']){
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // 标记为数量足够
|
||||
// $quantity_quantity = 1;
|
||||
// }
|
||||
//
|
||||
// if ($quantity_quantity == 0){
|
||||
// // 此优惠卷无商品能达到规定最小数量
|
||||
// $coupons[$key]['is_can_use'] = 0;
|
||||
// $coupons[$key]['cannot_use_coupon_reason'] = "商品不足" . $coupon['min_usable_number'] . "盒,不满足使用优惠卷条件";
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 处理满减金额/无门槛优惠卷
|
||||
// if ($coupon['coupon_type'] == 2 || $coupon['coupon_type'] == 1){
|
||||
// // 可共用一个优惠卷的商品金额问题
|
||||
// $product_price = 0;
|
||||
//
|
||||
// foreach ($coupon_product_datas as $coupon_product_data) {
|
||||
// // 如该优惠卷不包含此商品,跳过
|
||||
// if (!empty($coupon['product_id'])){
|
||||
// if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $product_price = bcadd($product_price,
|
||||
// bcmul( // 商品价格*数量
|
||||
// $coupon_product_data['product_price'],
|
||||
// $coupon_product_data['product_num'],
|
||||
// 2
|
||||
// ),
|
||||
// 2
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// // 满减金额优惠卷
|
||||
// if ($coupon['coupon_type'] == 2){
|
||||
// if ($coupon['with_amount'] > $product_price){
|
||||
// // 此优惠卷因商品金额不足,无法使用
|
||||
// $coupons[$key]['is_can_use'] = 0;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 无门槛优惠卷
|
||||
// if ($coupon['coupon_type'] == 1){
|
||||
// if ($product_price <= 0){
|
||||
// // 商品总金额已经为0,不使用优惠卷
|
||||
// $coupons[$key]['is_can_use'] = 0;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 判断品牌是否符合-暂无品牌
|
||||
// //
|
||||
// }
|
||||
//
|
||||
// // 可选择优惠卷中是否存在互斥卷
|
||||
// foreach ($coupons as $coupon) {
|
||||
// if ($coupon['is_can_use'] == 0){
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if ($coupon['is_mutex'] == 1) {
|
||||
// $is_mutex = 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 处理存在互斥卷情况
|
||||
// foreach ($coupons as $coupon) {
|
||||
// if ($coupon['is_can_use'] == 0){
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if (empty($selected_coupons)) {
|
||||
// $selected_coupons[] = $coupon; // 选中的优惠卷数据
|
||||
//
|
||||
// $coupon_high_price = $coupon['coupon_price'];
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// // 处理存在互斥卷情况
|
||||
// if ($is_mutex == 1) {
|
||||
// // 选择金额最高的为选中
|
||||
// if ($coupon['coupon_price'] < $coupon_high_price){
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// if ($coupon['coupon_price'] > $coupon_high_price) {
|
||||
// $coupon_high_price = $coupon['coupon_price'];
|
||||
//
|
||||
// // 选中的优惠卷数据置空
|
||||
// $selected_coupons = array();
|
||||
// $selected_coupons[] = $coupon;
|
||||
//
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $selected_coupons[] = $coupon; // 选中的优惠卷数据
|
||||
// }
|
||||
//
|
||||
// return $selected_coupons;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取患者购药可用的优惠卷
|
||||
* @param string|int $user_id
|
||||
@ -105,7 +268,7 @@ class UserCouponService extends BaseService
|
||||
*/
|
||||
public function getUserProductUsableCoupon(string|int $user_id, array $coupon_product_datas): array
|
||||
{
|
||||
$user_coupons = UserCoupon::getUserProductUsableCoupon($user_id,$coupon_product_datas);
|
||||
$user_coupons = UserCoupon::getUserProductUsableCoupon($user_id);
|
||||
if (empty($user_coupons)) {
|
||||
return array();
|
||||
}
|
||||
@ -133,20 +296,57 @@ class UserCouponService extends BaseService
|
||||
$coupons[$key]['cannot_use_coupon_reason'] = ""; // 不可使用原因
|
||||
}
|
||||
|
||||
// 处理优惠卷数量限制问题
|
||||
foreach ($coupons as $key => $coupon) {
|
||||
if ($coupon['coupon_type'] == 3 && !empty($coupon['product_id'])){
|
||||
// 优惠卷类型(1:无门槛 2:满减 3:数量)
|
||||
if ($coupon['coupon_type'] == 3){
|
||||
// 数量是否足够标识字段
|
||||
$quantity_quantity = 0;
|
||||
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
// 如该优惠卷不包含此商品,跳过
|
||||
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])){
|
||||
continue;
|
||||
// 品牌
|
||||
if ($coupon['application_scope'] == 3){
|
||||
// 获取商品品牌
|
||||
// 计算相同品牌的商品总数量
|
||||
// 标记为数量足够
|
||||
continue;
|
||||
}
|
||||
|
||||
// 类别
|
||||
if ($coupon['application_scope'] == 4){
|
||||
// 获取商品类别
|
||||
// 计算相同类别的商品总数量
|
||||
// 标记为数量足够
|
||||
continue;
|
||||
}
|
||||
|
||||
// 单品使用
|
||||
if ($coupon['application_scope'] == 5){
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 判断商品数量是否满足
|
||||
if($coupon['min_usable_number'] > $coupon_product_data['actual_quantity']){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 标记为数量足够
|
||||
$quantity_quantity = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 全场通用/全品类药品
|
||||
if ($coupon['application_scope'] == 1 || $coupon['application_scope'] == 6){
|
||||
// 获取总商品数量
|
||||
$actual_quantity = 0;
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
$actual_quantity = $actual_quantity + $coupon_product_data['actual_quantity'];
|
||||
}
|
||||
|
||||
// 判断商品数量是否满足
|
||||
if($coupon['min_usable_number'] > $coupon_product_data['product_num']){
|
||||
if($coupon['min_usable_number'] > $actual_quantity){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -158,37 +358,82 @@ class UserCouponService extends BaseService
|
||||
// 此优惠卷无商品能达到规定最小数量
|
||||
$coupons[$key]['is_can_use'] = 0;
|
||||
$coupons[$key]['cannot_use_coupon_reason'] = "商品不足" . $coupon['min_usable_number'] . "盒,不满足使用优惠卷条件";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理满减金额问题
|
||||
if ($coupon['coupon_type'] == 2 && !empty($coupon['product_id'])){
|
||||
// 可共用一个优惠卷的商品金额问题
|
||||
// 满减金额/无门槛优惠卷
|
||||
if ($coupon['coupon_type'] == 2 || $coupon['coupon_type'] == 1){
|
||||
// 获取商品总金额
|
||||
$product_price = 0;
|
||||
|
||||
foreach ($coupon_product_datas as $coupon_product_data) {
|
||||
// 如该优惠卷不包含此商品,跳过
|
||||
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])) {
|
||||
// 品牌
|
||||
if ($coupon['application_scope'] == 3){
|
||||
// 获取商品品牌
|
||||
// 计算相同品牌的商品总金额
|
||||
continue;
|
||||
}
|
||||
|
||||
// 类别
|
||||
if ($coupon['application_scope'] == 4){
|
||||
// 获取商品类别
|
||||
// 计算相同类别的商品总金额
|
||||
continue;
|
||||
}
|
||||
|
||||
// 单品使用
|
||||
if ($coupon['application_scope'] == 5){
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])){
|
||||
continue;
|
||||
}
|
||||
|
||||
$product_price = bcadd(
|
||||
(string)$product_price,
|
||||
bcmul( // 商品价格*实际数量数量
|
||||
(string)$coupon_product_data['product_price'],
|
||||
(string)$coupon_product_data['actual_quantity'],
|
||||
2
|
||||
),
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 全场通用/全品类药品
|
||||
if ($coupon['application_scope'] == 1 || $coupon['application_scope'] == 6){
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
// 计算商品总金额
|
||||
$product_price = bcadd(
|
||||
(string)$product_price,
|
||||
bcmul( // 商品价格*数量
|
||||
(string)$coupon_product_data['product_price'],
|
||||
(string)$coupon_product_data['actual_quantity'],
|
||||
2
|
||||
),
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 满减金额优惠卷
|
||||
if ($coupon['coupon_type'] == 2){
|
||||
if ($coupon['with_amount'] > $product_price){
|
||||
// 此优惠卷因商品金额不足,无法使用
|
||||
$coupons[$key]['is_can_use'] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
$product_price = bcadd($product_price,
|
||||
bcmul( // 商品价格*数量
|
||||
$coupon_product_data['product_price'],
|
||||
$coupon_product_data['product_num'],
|
||||
2
|
||||
),
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
if ($coupon['with_amount'] > $product_price){
|
||||
// 此优惠卷因商品金额不足,无法使用
|
||||
$coupons[$key]['is_can_use'] = 0;
|
||||
// 无门槛优惠卷
|
||||
if ($coupon['coupon_type'] == 1){
|
||||
if ($product_price <= 0){
|
||||
// 商品总金额已经为0,不使用优惠卷
|
||||
$coupons[$key]['is_can_use'] = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断品牌是否符合-暂无品牌
|
||||
}
|
||||
|
||||
// 可选择优惠卷中是否存在互斥卷
|
||||
@ -216,7 +461,6 @@ class UserCouponService extends BaseService
|
||||
continue;
|
||||
}
|
||||
|
||||
dump($coupon_high_price);
|
||||
// 处理存在互斥卷情况
|
||||
if ($is_mutex == 1) {
|
||||
// 选择金额最高的为选中
|
||||
@ -224,15 +468,13 @@ class UserCouponService extends BaseService
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($coupon['coupon_price'] > $coupon_high_price) {
|
||||
$coupon_high_price = $coupon['coupon_price'];
|
||||
$coupon_high_price = $coupon['coupon_price'];
|
||||
|
||||
// 选中的优惠卷数据置空
|
||||
$selected_coupons = array();
|
||||
$selected_coupons[] = $coupon;
|
||||
// 选中的优惠卷数据置空
|
||||
$selected_coupons = array();
|
||||
$selected_coupons[] = $coupon;
|
||||
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$selected_coupons[] = $coupon; // 选中的优惠卷数据
|
||||
|
||||
@ -15,6 +15,10 @@ use App\Model\DiseaseClassExpertise;
|
||||
use App\Model\DiseaseClassIcd;
|
||||
use App\Model\DoctorAccount;
|
||||
use App\Model\DoctorBankCard;
|
||||
use App\Model\DoctorConfigDifficultConsultation;
|
||||
use App\Model\DoctorConfigFollowPackage;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
use App\Model\DoctorConfigHealthPackage;
|
||||
use App\Model\DoctorExpertise;
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\DoctorInquiryConfig as DoctorInquiryConfigModel;
|
||||
@ -31,6 +35,9 @@ use App\Model\OrderPrescriptionFile;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\OrderServicePackageDetail;
|
||||
use App\Model\OrderServicePackageInquiry;
|
||||
use App\Model\PatientFollow;
|
||||
use App\Model\PatientHistoryInquiry;
|
||||
use App\Model\PatientHistoryInquiry as PatientHistoryInquiryModel;
|
||||
@ -1088,217 +1095,215 @@ class UserDoctorService extends BaseService
|
||||
* 修改处方
|
||||
* 暂时去除修改处方
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function putPrescription(): array
|
||||
{
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "操作失败");
|
||||
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_prescription_id = $this->request->input('order_prescription_id');
|
||||
$prescription_icd = $this->request->input('prescription_icd');
|
||||
$doctor_advice = $this->request->input('doctor_advice');
|
||||
$prescription_product = $this->request->input('prescription_product');
|
||||
|
||||
// 获取医生信息
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||
}
|
||||
|
||||
$res = $this->checkDoctorAuth($user_doctor);
|
||||
if ($res !== true) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
}
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测处方状态
|
||||
if ($order_prescription['prescription_status'] == 4) {
|
||||
// 已使用
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "处方已使用,无法更改");
|
||||
}
|
||||
|
||||
if ($order_prescription['is_delete'] == 1) {
|
||||
// 已使用
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "处方已删除,无法更改");
|
||||
}
|
||||
|
||||
if ($order_prescription['prescription_status'] == 1 && $order_prescription['pharmacist_audit_status'] == 0) {
|
||||
// 已使用
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "处方审核中,不允许修改");
|
||||
}
|
||||
|
||||
// 获取处方订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 5){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已完成,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 6){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已结束,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 7){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊已取消,无法重开处方");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] != 4){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"问诊状态错误,无法重开处方");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 删除订单-处方关联疾病表
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
OrderPrescriptionIcd::deleteOrderPrescriptionIcd($params);
|
||||
|
||||
// 处方疾病数据
|
||||
foreach ($prescription_icd as $item) {
|
||||
// 获取疾病信息
|
||||
$params = array();
|
||||
$params['icd_id'] = $item;
|
||||
$disease_class_icd = DiseaseClassIcd::getOne($params);
|
||||
if (empty($disease_class_icd)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 新增处方疾病
|
||||
$data = array();
|
||||
$data['order_prescription_id'] = $order_prescription_id;
|
||||
$data['icd_id'] = $item;
|
||||
$data['icd_name'] = $disease_class_icd['icd_name'];
|
||||
$data['icd_code'] = $disease_class_icd['icd_code'];
|
||||
$order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data);
|
||||
if (empty($order_prescription_icd)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
unset($disease_class_icd);
|
||||
}
|
||||
|
||||
// 删除订单-处方药品表
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params);
|
||||
|
||||
// 处方商品数据
|
||||
$product_name = "";
|
||||
foreach ($prescription_product as $item) {
|
||||
// 获取商品数据
|
||||
$params = array();
|
||||
$params['product_id'] = $item['product_id'];
|
||||
$product = Product::getWithAmountOne($params);
|
||||
if (empty($product)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
if (empty($product['ProductPlatformAmount'])) {
|
||||
// 无药品库存数据
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测药品库存数据
|
||||
if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['stock']) {
|
||||
// 库存不足
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足");
|
||||
}
|
||||
|
||||
// 新增订单-处方药品表
|
||||
$data = array();
|
||||
$data['order_prescription_id'] = $order_prescription_id;
|
||||
$data['product_id'] = $item['product_id'];
|
||||
$data['prescription_product_num'] = $item['prescription_product_num'];
|
||||
$data['product_name'] = $product['product_name'];
|
||||
$data['product_spec'] = $product['product_spec'];
|
||||
$data['license_number'] = $product['license_number'];
|
||||
$data['manufacturer'] = $product['manufacturer'];
|
||||
$data['single_unit'] = $item['single_unit'] ?? $product['single_unit'];
|
||||
$data['single_use'] = $item['single_use'] ?? $product['single_use'];
|
||||
$data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit'];
|
||||
$data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use'];
|
||||
$data['available_days'] = $item['available_days'] ?? $product['available_days'];
|
||||
$order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data);
|
||||
if (empty($order_prescription_product)) {
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
$product_name = $product_name . ";" . $product['product_name'];
|
||||
unset($product);
|
||||
}
|
||||
|
||||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||
$prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']);
|
||||
if (empty($prescription_open_result['prescription_img_url'])){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败");
|
||||
}
|
||||
|
||||
// 修改处方表
|
||||
$data = array();
|
||||
$data['prescription_img'] = $prescription_open_result['prescription_img_url'];
|
||||
$data['doctor_created_time'] = date('Y-m-d H:i:s',time());
|
||||
$data['prescription_status'] = 1; // 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||
$data['pharmacist_audit_status'] = 0; // 药师审核驳回原因
|
||||
$data['pharmacist_fail_reason'] = ""; // 药师审核驳回原因
|
||||
$data['platform_audit_status'] = 0; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
$data['platform_fail_reason'] = ""; // 处方平台驳回原因
|
||||
$data['doctor_created_time'] = date('Y-m-d H:i:s',time());
|
||||
if ($order_prescription['doctor_advice'] != $doctor_advice) {
|
||||
$data['doctor_advice'] = $doctor_advice; // 医嘱
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
OrderPrescription::edit($params,$data);
|
||||
|
||||
// 发送IM消息-处方已开具
|
||||
$imService = new ImService();
|
||||
$imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],6);
|
||||
|
||||
// 加入分配药师队列
|
||||
$data = array();
|
||||
$data['order_prescription_id'] = $order_prescription_id;
|
||||
|
||||
$message = new AssignPharmacistProducer($data);
|
||||
$producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
$result = $producer->produce($message);
|
||||
if (!$result) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
}
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "操作失败");
|
||||
//
|
||||
// $user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
//
|
||||
// $order_prescription_id = $this->request->input('order_prescription_id');
|
||||
// $prescription_icd = $this->request->input('prescription_icd');
|
||||
// $doctor_advice = $this->request->input('doctor_advice');
|
||||
// $prescription_product = $this->request->input('prescription_product');
|
||||
//
|
||||
// // 获取医生信息
|
||||
// $params = array();
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
//
|
||||
// $user_doctor = UserDoctor::getOne($params);
|
||||
// if (empty($user_doctor)) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "非法医生");
|
||||
// }
|
||||
//
|
||||
// $res = $this->checkDoctorAuth($user_doctor);
|
||||
// if ($res !== true) {
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, $res);
|
||||
// }
|
||||
//
|
||||
// // 获取处方数据
|
||||
// $params = array();
|
||||
// $params['order_prescription_id'] = $order_prescription_id;
|
||||
// $params['doctor_id'] = $user_info['client_user_id'];
|
||||
// $order_prescription = OrderPrescription::getOne($params);
|
||||
// if (empty($order_prescription)) {
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// // 检测处方状态
|
||||
// if ($order_prescription['prescription_status'] == 4) {
|
||||
// // 已使用
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "处方已使用,无法更改");
|
||||
// }
|
||||
//
|
||||
// if ($order_prescription['is_delete'] == 1) {
|
||||
// // 已使用
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "处方已删除,无法更改");
|
||||
// }
|
||||
//
|
||||
// if ($order_prescription['prescription_status'] == 1 && $order_prescription['pharmacist_audit_status'] == 0) {
|
||||
// // 已使用
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "处方审核中,不允许修改");
|
||||
// }
|
||||
//
|
||||
// // 获取处方订单数据
|
||||
// $params = array();
|
||||
// $params['order_inquiry_id'] = $order_prescription['order_inquiry_id'];
|
||||
// $order_inquiry = OrderInquiry::getOne($params);
|
||||
// if (empty($order_inquiry)){
|
||||
// return fail(HttpEnumCode::SERVER_ERROR,"问诊订单数据为空");
|
||||
// }
|
||||
//
|
||||
// if ($order_inquiry['inquiry_status'] == 5){
|
||||
// return fail(HttpEnumCode::HTTP_ERROR,"问诊已完成,无法重开处方");
|
||||
// }
|
||||
//
|
||||
// if ($order_inquiry['inquiry_status'] == 6){
|
||||
// return fail(HttpEnumCode::HTTP_ERROR,"问诊已结束,无法重开处方");
|
||||
// }
|
||||
//
|
||||
// if ($order_inquiry['inquiry_status'] == 7){
|
||||
// return fail(HttpEnumCode::HTTP_ERROR,"问诊已取消,无法重开处方");
|
||||
// }
|
||||
//
|
||||
// if ($order_inquiry['inquiry_status'] != 4){
|
||||
// return fail(HttpEnumCode::HTTP_ERROR,"问诊状态错误,无法重开处方");
|
||||
// }
|
||||
//
|
||||
// Db::beginTransaction();
|
||||
//
|
||||
// try {
|
||||
// // 删除订单-处方关联疾病表
|
||||
// $params = array();
|
||||
// $params['order_prescription_id'] = $order_prescription_id;
|
||||
// OrderPrescriptionIcd::deleteOrderPrescriptionIcd($params);
|
||||
//
|
||||
// // 处方疾病数据
|
||||
// foreach ($prescription_icd as $item) {
|
||||
// // 获取疾病信息
|
||||
// $params = array();
|
||||
// $params['icd_id'] = $item;
|
||||
// $disease_class_icd = DiseaseClassIcd::getOne($params);
|
||||
// if (empty($disease_class_icd)) {
|
||||
// Db::rollBack();
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// // 新增处方疾病
|
||||
// $data = array();
|
||||
// $data['order_prescription_id'] = $order_prescription_id;
|
||||
// $data['icd_id'] = $item;
|
||||
// $data['icd_name'] = $disease_class_icd['icd_name'];
|
||||
// $data['icd_code'] = $disease_class_icd['icd_code'];
|
||||
// $order_prescription_icd = OrderPrescriptionIcd::addOrderPrescriptionIcd($data);
|
||||
// if (empty($order_prescription_icd)) {
|
||||
// Db::rollBack();
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// unset($disease_class_icd);
|
||||
// }
|
||||
//
|
||||
// // 删除订单-处方药品表
|
||||
// $params = array();
|
||||
// $params['order_prescription_id'] = $order_prescription_id;
|
||||
// OrderPrescriptionProduct::deleteOrderPrescriptionProduct($params);
|
||||
//
|
||||
// // 处方商品数据
|
||||
// $product_name = "";
|
||||
// foreach ($prescription_product as $item) {
|
||||
// // 获取商品数据
|
||||
// $params = array();
|
||||
// $params['product_id'] = $item['product_id'];
|
||||
// $product = Product::getWithAmountOne($params);
|
||||
// if (empty($product)) {
|
||||
// Db::rollBack();
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// if (empty($product['ProductPlatformAmount'])) {
|
||||
// // 无药品库存数据
|
||||
// Db::rollBack();
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// // 检测药品库存数据
|
||||
// if ($item['prescription_product_num'] > $product['ProductPlatformAmount']['stock']) {
|
||||
// // 库存不足
|
||||
// Db::rollBack();
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "药品" . $product['product_name'] . "库存不足");
|
||||
// }
|
||||
//
|
||||
// // 新增订单-处方药品表
|
||||
// $data = array();
|
||||
// $data['order_prescription_id'] = $order_prescription_id;
|
||||
// $data['product_id'] = $item['product_id'];
|
||||
// $data['prescription_product_num'] = $item['prescription_product_num'];
|
||||
// $data['product_name'] = $product['product_name'];
|
||||
// $data['product_spec'] = $product['product_spec'];
|
||||
// $data['license_number'] = $product['license_number'];
|
||||
// $data['manufacturer'] = $product['manufacturer'];
|
||||
// $data['single_unit'] = $item['single_unit'] ?? $product['single_unit'];
|
||||
// $data['single_use'] = $item['single_use'] ?? $product['single_use'];
|
||||
// $data['packaging_unit'] = $item['packaging_unit'] ?? $product['packaging_unit'];
|
||||
// $data['frequency_use'] = $item['frequency_use'] ?? $product['frequency_use'];
|
||||
// $data['available_days'] = $item['available_days'] ?? $product['available_days'];
|
||||
// $order_prescription_product = OrderPrescriptionProduct::addOrderPrescriptionProduct($data);
|
||||
// if (empty($order_prescription_product)) {
|
||||
// Db::rollBack();
|
||||
// return fail();
|
||||
// }
|
||||
//
|
||||
// $product_name = $product_name . ";" . $product['product_name'];
|
||||
// unset($product);
|
||||
// }
|
||||
//
|
||||
// $OrderPrescriptionService = new OrderPrescriptionService();
|
||||
// $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']);
|
||||
// if (empty($prescription_open_result['prescription_img_url'])){
|
||||
// Db::rollBack();
|
||||
// return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败");
|
||||
// }
|
||||
//
|
||||
// // 修改处方表
|
||||
// $data = array();
|
||||
// $data['prescription_img'] = $prescription_open_result['prescription_img_url'];
|
||||
// $data['doctor_created_time'] = date('Y-m-d H:i:s',time());
|
||||
// $data['prescription_status'] = 1; // 处方状态(1:待审核 3:待使用 4:已失效 5:已使用)
|
||||
// $data['pharmacist_audit_status'] = 0; // 药师审核驳回原因
|
||||
// $data['pharmacist_fail_reason'] = ""; // 药师审核驳回原因
|
||||
// $data['platform_audit_status'] = 0; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
// $data['platform_fail_reason'] = ""; // 处方平台驳回原因
|
||||
// $data['doctor_created_time'] = date('Y-m-d H:i:s',time());
|
||||
// if ($order_prescription['doctor_advice'] != $doctor_advice) {
|
||||
// $data['doctor_advice'] = $doctor_advice; // 医嘱
|
||||
// }
|
||||
//
|
||||
// $params = array();
|
||||
// $params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
// OrderPrescription::edit($params,$data);
|
||||
//
|
||||
// // 发送IM消息-处方已开具
|
||||
// $imService = new ImService();
|
||||
// $imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],6);
|
||||
//
|
||||
// // 加入分配药师队列
|
||||
// $data = array();
|
||||
// $data['order_prescription_id'] = $order_prescription_id;
|
||||
//
|
||||
// $message = new AssignPharmacistProducer($data);
|
||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
// $result = $producer->produce($message);
|
||||
// if (!$result) {
|
||||
// Db::rollBack();
|
||||
// return fail(HttpEnumCode::SERVER_ERROR);
|
||||
// }
|
||||
//
|
||||
// Db::commit();
|
||||
// } catch (\Exception $e) {
|
||||
// Db::rollBack();
|
||||
// return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
// }
|
||||
|
||||
return success();
|
||||
}
|
||||
@ -1778,21 +1783,49 @@ class UserDoctorService extends BaseService
|
||||
'patient_sex',
|
||||
'patient_age',
|
||||
'inquiry_status',
|
||||
'inquiry_type',
|
||||
'inquiry_mode',
|
||||
'inquiry_no',
|
||||
];
|
||||
|
||||
$params =array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
$order_inquiry = OrderInquiry::getInList($params,$order_inquiry_ids,$fields);
|
||||
if (empty($order_inquiry)){
|
||||
$order_inquirys = OrderInquiry::getInList($params,$order_inquiry_ids,$fields);
|
||||
if (empty($order_inquirys)){
|
||||
return success();
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($order_inquiry as $value){
|
||||
$result[] = $value;
|
||||
foreach ($order_inquirys as &$order_inquiry){
|
||||
// 处理未接诊取消时间
|
||||
if ($order_inquiry['inquiry_status'] == 3){
|
||||
if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){
|
||||
$order_inquiry['no_inquiry_cancel_time'] = 24 * 60;
|
||||
|
||||
// 服务包特殊处理
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
$order_inquiry['no_inquiry_cancel_time'] = 60 * 24 * 3;
|
||||
}else{
|
||||
$order_inquiry['no_inquiry_cancel_time'] = 60 * 24;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4){
|
||||
$order_inquiry['no_inquiry_cancel_time'] = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success($result);
|
||||
return success($order_inquirys->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1816,21 +1849,6 @@ class UserDoctorService extends BaseService
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||
}
|
||||
|
||||
try {
|
||||
$redis = $this->container->get(Redis::class);
|
||||
$redis_key = "order_inquiry_lock_" . $order_inquiry_id;
|
||||
$redis_lock = $redis->setnx($redis_key,1);
|
||||
if (!$redis_lock){
|
||||
// 设置失败,表示已经设置该值
|
||||
return fail(HttpEnumCode::HTTP_SUCCESS,"请您稍后重试");
|
||||
}
|
||||
|
||||
// 设置过期时间
|
||||
$redis->expire($redis_key,3);
|
||||
}catch (\Throwable $e){
|
||||
return fail(HttpEnumCode::HTTP_SUCCESS,"请您稍后重试");
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] == 4) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
return success();
|
||||
@ -1887,23 +1905,73 @@ class UserDoctorService extends BaseService
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
OrderInquiry::edit($params,$data);
|
||||
|
||||
/**
|
||||
* 获取订单结束周期
|
||||
* 疑难问诊为自己配置周期。
|
||||
*/
|
||||
// 疑难问诊
|
||||
// 处理服务包订单
|
||||
if ($order_inquiry['inquiry_type'] == 1){
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
// 获取关联服务包订单
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_service_package_inquiry = OrderServicePackageInquiry::getOne($params);
|
||||
if (empty($order_service_package_inquiry)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||
}
|
||||
|
||||
// 获取服务包订单详情
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_package_inquiry['order_service_no'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (empty($order_service_package_detail)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||
}
|
||||
|
||||
// 开始服务时间
|
||||
$start_time = date('Y-m-d H:i:s',time());
|
||||
|
||||
// 结束服务时间
|
||||
$finish_time = date('Y-m-d H:i:s', strtotime("+{$order_service_package_detail['service_period']} days", strtotime($start_time)));
|
||||
|
||||
// 修改服务包
|
||||
$data = array();
|
||||
$data['order_service_status'] = 3; // 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
$data['start_time'] = $start_time;
|
||||
$data['finish_time'] = $finish_time;
|
||||
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package_inquiry['order_service_id'];
|
||||
OrderServicePackage::edit($params,$data);
|
||||
|
||||
// 健康包订单发放优惠卷
|
||||
if ($order_inquiry['inquiry_mode'] == 8){
|
||||
// 检测问诊次数
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_package_inquiry['order_service_no']);
|
||||
if ($is_first){
|
||||
// 发放优惠卷
|
||||
$CouponService = new CouponService();
|
||||
$res = $CouponService->GrantBuyOrderServicePackageCoupon($order_inquiry['user_id']);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取订单持续时长
|
||||
if ($order_inquiry['inquiry_type'] == 1 && $order_inquiry['inquiry_mode'] == 6){
|
||||
// 疑难问诊为自己配置周期。
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$params['inquiry_type'] = $order_inquiry['inquiry_type'];
|
||||
$params['inquiry_mode'] = $order_inquiry['inquiry_mode'];
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
|
||||
if(empty($doctor_inquiry_config_service)){
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if(empty($doctor_config_difficult_consultation)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||
}
|
||||
|
||||
$time = $doctor_inquiry_config_service['service_period'] * 24 * 60 * 60;
|
||||
$time = $doctor_config_difficult_consultation['service_period'] * 24 * 60 * 60;
|
||||
}else{
|
||||
$time = $system_inquiry_config['duration'] * 60;
|
||||
}
|
||||
@ -1917,11 +1985,9 @@ class UserDoctorService extends BaseService
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "接诊失败");
|
||||
}
|
||||
|
||||
// 删除锁
|
||||
$redis->del($redis_key);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
@ -1934,7 +2000,8 @@ class UserDoctorService extends BaseService
|
||||
$params['doctor_id'] = $order_inquiry['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
return success([],HttpEnumCode::HTTP_SUCCESS,"医生数据错误");
|
||||
Log::getInstance('UserDoctorService-addDoctorInquiry')->error("医生数据错误");
|
||||
return success();
|
||||
}
|
||||
|
||||
// 获取病例数据
|
||||
@ -1942,7 +2009,8 @@ class UserDoctorService extends BaseService
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)){
|
||||
return success([],HttpEnumCode::HTTP_SUCCESS,"患者病例错误");
|
||||
Log::getInstance('UserDoctorService-addDoctorInquiry')->error("患者病例错误");
|
||||
return success();
|
||||
}
|
||||
|
||||
// 发送IM消息-医生接诊
|
||||
@ -1952,11 +2020,76 @@ class UserDoctorService extends BaseService
|
||||
// 发送IM消息-患者病例
|
||||
$imService->patientCase($order_inquiry,$user_doctor['user_id'],$order_inquiry_case['disease_desc']);
|
||||
|
||||
// 发送站内、订阅、短信消息-医生已接诊
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->patientAcceptedInquiry();
|
||||
// 处理可处方字段
|
||||
$userDoctorService = new UserDoctorService();
|
||||
$multi_point_enable = $userDoctorService->getDoctorMultiPointEnable($user_doctor["doctor_id"]);
|
||||
|
||||
// 多点医生接诊后,自动回复消息
|
||||
if ($user_doctor['multi_point_status'] == 1 && $multi_point_enable == 1){
|
||||
$imService->multiPointDoctorInquiryAutoReply($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']);
|
||||
}
|
||||
|
||||
// 处理服务包情况
|
||||
if ($order_inquiry['inquiry_mode'] == 8 || $order_inquiry['inquiry_mode'] == 9){
|
||||
$OrderServicePackageService = new OrderServicePackageService();
|
||||
|
||||
// 获取服务包订单编号-通过问诊订单id
|
||||
$order_service_no = $OrderServicePackageService->getOrderServiceNoByOrderInquiryId($order_inquiry['inquiry_no']);
|
||||
|
||||
// 获取服务包订单
|
||||
$params = array();
|
||||
$params['order_service_no'] = $order_service_no;
|
||||
$order_service_package = OrderServicePackage::getOne($params);
|
||||
if (empty($order_service_package)){
|
||||
Log::getInstance('UserDoctorService-addDoctorInquiry')->error("服务包订单错误");
|
||||
return success();
|
||||
}
|
||||
|
||||
// 获取服务包订单详情
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||
if (empty($order_service_package_detail)){
|
||||
Log::getInstance('UserDoctorService-addDoctorInquiry')->error("服务包订单详情错误");
|
||||
return success();
|
||||
}
|
||||
|
||||
// 检测问诊是否服务包首次问诊
|
||||
$is_first = $OrderServicePackageService->isFirstInquiryServicePackage($order_service_no);
|
||||
if ($is_first){
|
||||
// 患者-通知患者医生已接受服务包服务
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_service_package['order_service_no']);
|
||||
$MessagePush->patientAcceptedServicePackage();
|
||||
}else{
|
||||
// 患者-通知患者医生已接诊服务包相关问诊订单
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientAcceptedServicePackageInquiry();
|
||||
|
||||
if ($order_service_package['order_service_type'] == 1){
|
||||
$remaining_quantity = 0;
|
||||
|
||||
// 获取服务包内所有药品
|
||||
$health_package_products = $OrderServicePackageService->getOrderServiceProduct($order_service_package_detail['package_id']);
|
||||
foreach ($health_package_products as $health_package_product) {
|
||||
// 获取服务包内某一药品的剩余数量
|
||||
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'],$health_package_product['product_id'],$health_package_product['quantity']);
|
||||
}
|
||||
|
||||
if ($remaining_quantity > 0){
|
||||
// 患者-通知患者服务包药品未使用完
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientServicePackageHaveProduct($remaining_quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// 发送站内、订阅、短信消息-医生已接诊
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientAcceptedInquiry();
|
||||
}
|
||||
}catch(\Exception $e){
|
||||
return success([],HttpEnumCode::HTTP_SUCCESS,$e->getMessage());
|
||||
Log::getInstance('UserDoctorService-addDoctorInquiry')->error($e->getMessage());
|
||||
return success();
|
||||
}
|
||||
|
||||
return success();
|
||||
@ -2329,19 +2462,15 @@ class UserDoctorService extends BaseService
|
||||
if ($value['inquiry_mode'] == 6){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_type'] = $value['inquiry_type'];
|
||||
$params['inquiry_mode'] = $value['inquiry_mode'];
|
||||
$doctor_inquiry_config_service = DoctorInquiryConfigService::getOne($params);
|
||||
if (empty($doctor_inquiry_config_service)){
|
||||
return fail();
|
||||
$doctor_config_difficult_consultation = DoctorConfigDifficultConsultation::getOne($params);
|
||||
if (!empty($doctor_config_difficult_consultation)){
|
||||
$value['times_number'] = $doctor_config_difficult_consultation['service_rounds']; // 服务回合数(0表示不限次)
|
||||
$value['duration'] = $doctor_config_difficult_consultation['service_period']; // 服务周期(天,不存在0的情况)
|
||||
$value['service_content'] = $doctor_config_difficult_consultation['service_content'];// 服务内容
|
||||
$value['service_process'] = $doctor_config_difficult_consultation['service_process'];// 服务流程
|
||||
|
||||
unset($doctor_config_difficult_consultation);
|
||||
}
|
||||
|
||||
$value['times_number'] = $doctor_inquiry_config_service['service_rounds']; // 服务回合数(0表示不限次)
|
||||
$value['duration'] = $doctor_inquiry_config_service['service_period']; // 服务周期(天,不存在0的情况)
|
||||
$value['service_content'] = $doctor_inquiry_config_service['service_content'];// 服务内容
|
||||
$value['service_process'] = $doctor_inquiry_config_service['service_process'];// 服务流程
|
||||
|
||||
unset($doctor_inquiry_config_service);
|
||||
}else{
|
||||
// 获取系统问诊配置
|
||||
$fields = [
|
||||
@ -2363,6 +2492,40 @@ class UserDoctorService extends BaseService
|
||||
|
||||
unset($system_inquiry_config);
|
||||
}
|
||||
|
||||
// 随访包
|
||||
if ($value['inquiry_type'] == 1 && $value['inquiry_mode'] == 9){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $value['doctor_id'];
|
||||
$doctor_config_follow_package = DoctorConfigFollowPackage::getOne($params);
|
||||
if (!empty($doctor_config_follow_package)) {
|
||||
$params = array();
|
||||
$params['follow_package_id'] = $doctor_config_follow_package['follow_package_id'];
|
||||
$doctor_config_follow_package_items = DoctorConfigFollowPackageItem::getList($params);
|
||||
if (!empty($doctor_config_follow_package_items)) {
|
||||
foreach ($doctor_config_follow_package_items as $k => $doctor_config_follow_package_item){
|
||||
if ($k == 0){
|
||||
$value['inquiry_price'] = $doctor_config_follow_package_item['service_price'];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($doctor_config_follow_package_item['service_price'] < $value['inquiry_price']){
|
||||
$value['inquiry_price'] = $doctor_config_follow_package_item['service_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 健康包
|
||||
if ($value['inquiry_type'] == 1 && $value['inquiry_mode'] == 8){
|
||||
$params = array();
|
||||
$params['doctor_id'] = $value['doctor_id'];
|
||||
$doctor_config_health_package = DoctorConfigHealthPackage::getOne($params);
|
||||
if (!empty($doctor_config_health_package)){
|
||||
$value['inquiry_price'] = $doctor_config_health_package['service_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2583,19 +2746,29 @@ class UserDoctorService extends BaseService
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$system_inquiry_config = SystemInquiryConfig::getOne($params);
|
||||
if (!empty($system_inquiry_config)){
|
||||
$max_work_num_day = $system_inquiry_config['max_work_num_day'];
|
||||
}
|
||||
}else{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (!empty($doctor_inquiry_config)){
|
||||
$max_work_num_day = $doctor_inquiry_config['work_num_day'];
|
||||
return $system_inquiry_config['max_work_num_day'];
|
||||
}
|
||||
}
|
||||
|
||||
// 健康包
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 9){
|
||||
return 9999;
|
||||
}
|
||||
|
||||
// 随访包
|
||||
if ($inquiry_type == 1 && $inquiry_mode == 8){
|
||||
return 9999;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['inquiry_type'] = $inquiry_type;
|
||||
$params['inquiry_mode'] = $inquiry_mode;
|
||||
$doctor_inquiry_config = DoctorInquiryConfig::getOne($params);
|
||||
if (!empty($doctor_inquiry_config)){
|
||||
return $doctor_inquiry_config['work_num_day'];
|
||||
}
|
||||
|
||||
return $max_work_num_day;
|
||||
}
|
||||
|
||||
@ -2751,7 +2924,6 @@ class UserDoctorService extends BaseService
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取医生是否可处方图标展示状态
|
||||
* @param string $doctor_id 医生id
|
||||
|
||||
@ -4,7 +4,10 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\Coupon;
|
||||
use App\Model\DoctorConfigFollowPackageItem;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderServicePackage;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\PatientHistoryInquiry;
|
||||
use App\Model\Product;
|
||||
use App\Model\ProductPlatformAmount;
|
||||
|
||||
@ -257,12 +257,12 @@ class UserPharmacistService extends BaseService
|
||||
$imService->prescriptionIssued($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id'],$product_name,(string)$order_prescription['order_prescription_id'],7);
|
||||
|
||||
// 发送站内、短信消息-患者的处方被药师审核通过
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->patientPrescriptionVerifyPass();
|
||||
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核通过
|
||||
// 发送目标不同,重新实例化
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->prescriptionVerifySuccess();
|
||||
|
||||
// 添加处方过期队列
|
||||
@ -279,7 +279,7 @@ class UserPharmacistService extends BaseService
|
||||
}
|
||||
}else{
|
||||
// 站内、订阅失败发送短信-医生开具的处方审核未通过
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']);
|
||||
$MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['inquiry_no']);
|
||||
$MessagePush->prescriptionVerifyFail($order_prescription['order_prescription_id']);
|
||||
}
|
||||
|
||||
|
||||
@ -763,7 +763,7 @@ class UserService extends BaseService
|
||||
/**
|
||||
* 通过user_id获取用户openid
|
||||
* @param string|int $user_id
|
||||
* @param int $user_type
|
||||
* @param int|string $user_type
|
||||
* @return string
|
||||
*/
|
||||
public function getOpenIdWithUserId(string|int $user_id, int|string $user_type): string
|
||||
@ -876,6 +876,13 @@ class UserService extends BaseService
|
||||
return true;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$message = "您有一条新的问诊消息";
|
||||
// 判断消息类型
|
||||
if (isset($msg_body[0]['MsgType'])){
|
||||
@ -907,7 +914,7 @@ class UserService extends BaseService
|
||||
}
|
||||
}
|
||||
|
||||
$MessagePush = new MessagePush($user_id, $order_inquiry_id);
|
||||
$MessagePush = new MessagePush($user_id, $order_inquiry['inquiry_no']);
|
||||
|
||||
if ($user['user_type'] == 1){
|
||||
// 患者
|
||||
|
||||
@ -30,13 +30,15 @@ class Auth
|
||||
"/callback/wxpay/product/refund" => "post", // 微信药品退款回调
|
||||
"/callback/wxpay/detection/success" => "post", // 微信检测订单支付回调
|
||||
"/callback/wxpay/detection/refund" => "post", // 微信检测订单退款回调
|
||||
"/callback/wxpay/service/success" => "post", // 微信服务包订单支付回调
|
||||
"/callback/wxpay/service/refund" => "post", // 微信服务包订单退款回调
|
||||
"/callback/im" => "post", // im回调
|
||||
"/callback/platform/logistics" => "post", // 处方平台物流回调
|
||||
"/callback/logistics" => "post", // 快递100订阅回调
|
||||
"/popup" => "get", // 获取弹窗数据
|
||||
"/basic/keyword/search" => "get", // 获取热门搜索关键词
|
||||
"/test/uninquiry" => "get", // 获取未接诊的医生
|
||||
"/test/refund" => "get", // 测试退款
|
||||
"/test/refund" => "post", // 测试退款
|
||||
"/test" => "get", // 测试
|
||||
"/callback/detection" => "post", // 检测所结果回调
|
||||
"/callback/video/trtc" => "post", // 音视频回调
|
||||
|
||||
48
app/Utils/Utils.php
Normal file
48
app/Utils/Utils.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* @property $container
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* 检测执行次数
|
||||
* @param string $redis_key
|
||||
* @return bool
|
||||
*/
|
||||
public function checkHandleNumber(string $redis_key): bool
|
||||
{
|
||||
try {
|
||||
$redis = ApplicationContext::getContainer()->get(Redis::class);
|
||||
|
||||
$redis_value = $redis->get($redis_key);
|
||||
if (empty($redis_value)) {
|
||||
$redis->set($redis_key, 1, 60 * 60 * 24 * 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 问诊订单执行退款次数过多
|
||||
if ($redis_value > 3) {
|
||||
// 加入短信队列,通知管理员
|
||||
|
||||
// 返回false,删除掉缓存
|
||||
$redis->del($redis_key);
|
||||
return false;
|
||||
}
|
||||
|
||||
$redis->incr($redis_key);
|
||||
} catch (\Throwable $e) {
|
||||
Log::getInstance("Utils-checkHandleNumber")->error($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -48,6 +48,8 @@ return [
|
||||
"product_refund_notify_url" => env('PATIENT_WECHAT_PRODUCT_REFUND_NOTIFY_URL', 'callback/wxpay/product/refund'),
|
||||
"detection_pay_notify_url" => env('PATIENT_WECHAT_DETECTION_PAY_NOTIFY_URL', 'callback/wxpay/detection/success'),
|
||||
"detection_refund_notify_url" => env('PATIENT_WECHAT_DETECTION_REFUND_NOTIFY_URL', 'callback/wxpay/detection/refund'),
|
||||
"service_pay_notify_url" => env('PATIENT_WECHAT_SERVICE_PAY_NOTIFY_URL', 'callback/wxpay/service/success'),
|
||||
"service_refund_notify_url" => env('PATIENT_WECHAT_SERVICE_REFUND_NOTIFY_URL', 'callback/wxpay/service/refund'),
|
||||
],
|
||||
"pharmacist" => [
|
||||
"app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'),
|
||||
|
||||
@ -22,6 +22,7 @@ use App\Controller\InquiryController;
|
||||
use App\Controller\LoginController;
|
||||
use App\Controller\CodeController;
|
||||
use App\Controller\MessageNoticeController;
|
||||
use App\Controller\OrderServicePackageController;
|
||||
use App\Controller\PatientCaseController;
|
||||
use App\Controller\PatientDoctorController;
|
||||
use App\Controller\PatientFamilyController;
|
||||
@ -100,23 +101,53 @@ Router::addGroup('/doctor', function () {
|
||||
Router::addGroup('/inquiry', function () {
|
||||
// 问诊配置
|
||||
Router::addGroup('/config', function () {
|
||||
// 问诊服务开关
|
||||
Router::addGroup('/open', function () {
|
||||
// 获取医生问诊服务开启状态
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryConfigOpenStatus']);
|
||||
|
||||
// 医生问诊开关
|
||||
Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryOpen']);
|
||||
});
|
||||
|
||||
// 获取医生问诊配置
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryConfig']);
|
||||
|
||||
// 修改医生问诊配置
|
||||
Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryConfig']);
|
||||
|
||||
// 医生问诊开关
|
||||
Router::put('/open', [DoctorInquiryConfigController::class, 'putDoctorInquiryOpen']);
|
||||
// 疑难会诊
|
||||
Router::addGroup('/difficult', function () {
|
||||
// 获取医生问诊配置-疑难会诊-服务设置
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryDifficultConfig']);
|
||||
|
||||
// 获取医生问诊配置-疑难会诊-服务设置
|
||||
Router::get('/service', [DoctorInquiryConfigController::class, 'getInquiryServiceConfig']);
|
||||
// 新增医生问诊配置-疑难会诊-服务设置
|
||||
Router::post('', [DoctorInquiryConfigController::class, 'addDoctorInquiryDifficultConfig']);
|
||||
|
||||
// 新增医生问诊配置-疑难会诊-服务设置
|
||||
Router::post('/service', [DoctorInquiryConfigController::class, 'addInquiryServiceConfig']);
|
||||
// 修改医生问诊配置-疑难会诊-服务设置
|
||||
Router::put('/{difficult_consultation_id:\d+}', [DoctorInquiryConfigController::class, 'putDoctorInquiryDifficultConfig']);
|
||||
});
|
||||
|
||||
// 修改医生问诊配置-疑难会诊-服务设置
|
||||
Router::put('/service/{config_service_id:\d+}', [DoctorInquiryConfigController::class, 'putInquiryServiceConfig']);
|
||||
// 随访包
|
||||
Router::addGroup('/follow', function () {
|
||||
// 获取医生问诊配置-随访包
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryFollowConfig']);
|
||||
|
||||
// 新增医生问诊配置-随访包
|
||||
Router::post('', [DoctorInquiryConfigController::class, 'addDoctorInquiryFollowConfig']);
|
||||
|
||||
// 获取医生问诊配置-随访包-列表
|
||||
Router::get('/item', [DoctorInquiryConfigController::class, 'getDoctorInquiryFollowItemConfig']);
|
||||
|
||||
// 修改医生问诊配置-随访包
|
||||
Router::put('', [DoctorInquiryConfigController::class, 'putDoctorInquiryFollowConfig']);
|
||||
});
|
||||
|
||||
// 健康包
|
||||
Router::addGroup('/health', function () {
|
||||
// 获取医生问诊配置-健康包
|
||||
Router::get('', [DoctorInquiryConfigController::class, 'getDoctorInquiryHealthConfig']);
|
||||
});
|
||||
});
|
||||
|
||||
// 获取医生问诊消息列表
|
||||
@ -126,7 +157,11 @@ Router::addGroup('/doctor', function () {
|
||||
Router::post('/message/attr', [UserDoctorController::class, 'getDoctorMessageAttrList']);
|
||||
|
||||
// 医生接诊
|
||||
Router::post('/{order_inquiry_id:\d+}', [UserDoctorController::class, 'addDoctorInquiry']);
|
||||
Router::post('/{order_inquiry_id:\d+}', [UserDoctorController::class, 'addDoctorInquiry'],
|
||||
[
|
||||
'middleware' => [LockRequestMiddleware::class] // 锁定重复请求
|
||||
]
|
||||
);
|
||||
|
||||
// 结束问诊会话列表
|
||||
Router::get('/finish/message', [InquiryController::class, 'getDoctorFinishMessageList']);
|
||||
@ -182,7 +217,7 @@ Router::addGroup('/doctor', function () {
|
||||
// 获取提现数据
|
||||
Router::post('/info', [DoctorAccountController::class, 'getDoctorWithdrawalInfo']);
|
||||
|
||||
// 获取可提现问诊订单列表
|
||||
// 获取可提现订单列表
|
||||
Router::get('/order', [DoctorAccountController::class, 'getDoctorWithdrawalOrderList']);
|
||||
|
||||
// 获取医生提现记录列表
|
||||
@ -441,6 +476,7 @@ Router::addGroup('/patient', function () {
|
||||
|
||||
// 订单
|
||||
Router::addGroup('/order', function () {
|
||||
// 问诊订单
|
||||
Router::addGroup('/inquiry', function () {
|
||||
// 获取患者问诊订单列表
|
||||
Router::get('', [PatientOrderController::class, 'getPatientInquiryOrderList']);
|
||||
@ -512,11 +548,32 @@ Router::addGroup('/patient', function () {
|
||||
Router::put('/cancel-pay/{order_detection_id:\d+}', [PatientOrderController::class, 'putPatientDetectionOrderCancelPay']);
|
||||
});
|
||||
|
||||
// 服务包订单
|
||||
Router::addGroup('/service', function () {
|
||||
// 服务包订单取消支付-1未支付
|
||||
Router::put('/cancel-pay/{order_no}', [PatientOrderController::class, 'putPatientServiceOrderCancelPay']);
|
||||
|
||||
// 获取患者服务包订单列表
|
||||
Router::get('', [PatientOrderController::class, 'getPatientServiceOrderList']);
|
||||
|
||||
// 获取患者服务包订单详情
|
||||
Router::get('/{order_no}', [PatientOrderController::class, 'getPatientServiceOrderInfo']);
|
||||
|
||||
// 获取患者服务包订单服务权益详情
|
||||
Router::get('/detail/{order_no}', [PatientOrderController::class, 'getPatientServiceOrderDetailInfo']);
|
||||
});
|
||||
|
||||
// 获取患者订单支付数据
|
||||
Router::get('/pay', [PatientOrderController::class, 'getPatientOrderPayInfo']);
|
||||
|
||||
// 模拟支付成功-金额为0时使用
|
||||
Router::post('/pay', [PatientOrderController::class, 'addPatientOrderPay']);
|
||||
|
||||
// 订单取消支付-1未支付
|
||||
Router::put('/cancel-pay/{order_no}', [PatientOrderController::class, 'putPatientOrderCancelPay']);
|
||||
|
||||
// 取消订单-问诊/检测/服务包
|
||||
Router::put('/cancel/{order_no}', [PatientOrderController::class, 'putCancelPatientOrder']);
|
||||
});
|
||||
|
||||
// 消息通知
|
||||
@ -548,6 +605,21 @@ Router::addGroup('/patient', function () {
|
||||
// 删除家庭成员病情记录
|
||||
Router::delete('/{pathography_id:\d+}', [PatientPathographyController::class, 'deleteFamilyPathography']);
|
||||
});
|
||||
|
||||
// 服务包
|
||||
Router::addGroup('/service', function () {
|
||||
// 获取患者已购买的某医生的服务包详情
|
||||
Router::get('/detail', [OrderServicePackageController::class, 'getPatientBuyServiceDetail']);
|
||||
|
||||
// 创建服务包订单
|
||||
Router::post('', [OrderServicePackageController::class, 'addPatientServiceOrder']);
|
||||
|
||||
// 创建服务包问诊订单
|
||||
Router::post('/inquiry/{order_no}', [OrderServicePackageController::class, 'addServiceInquiryOrder']);
|
||||
|
||||
// 检测是否可创建服务包问诊订单
|
||||
Router::get('/check/{order_no}', [OrderServicePackageController::class, 'getServicePackageInquiryCheck']);
|
||||
});
|
||||
});
|
||||
|
||||
// 药师端api
|
||||
@ -692,6 +764,9 @@ Router::addGroup('/system', function () {
|
||||
Router::addGroup('/inquiry', function () {
|
||||
// 获取系统问诊时间 快速问诊-问诊购药
|
||||
Router::get('/time', [SystemController::class, 'getSystemInquiryTime']);
|
||||
|
||||
// 获取系统问诊配置
|
||||
Router::get('/config', [SystemController::class, 'getSystemInquiryConfig']);
|
||||
});
|
||||
});
|
||||
|
||||
@ -725,6 +800,15 @@ Router::addGroup('/callback', function () {
|
||||
// 退款回调
|
||||
Router::post('/refund', [CallBackController::class, 'wxPayDetectionRefundCallBack']);
|
||||
});
|
||||
|
||||
// 服务包
|
||||
Router::addGroup('/service', function () {
|
||||
// 支付成功回调
|
||||
Router::post('/success', [CallBackController::class, 'wxPayServiceSuccessCallBack']);
|
||||
|
||||
// 退款回调
|
||||
Router::post('/refund', [CallBackController::class, 'wxPayServiceRefundCallBack']);
|
||||
});
|
||||
});
|
||||
|
||||
// im聊天回调
|
||||
@ -787,6 +871,12 @@ Router::addGroup('/case', function () {
|
||||
// 获取问诊订单病例详情
|
||||
Router::get('/inquiry', [PatientCaseController::class, 'getPatientFamilyInquiryCase']);
|
||||
|
||||
// 获取服务包订单病例详情-基础
|
||||
Router::get('/service/simple/{order_no}', [PatientCaseController::class, 'getPatientFamilyServiceCaseSimple']);
|
||||
|
||||
// 获取服务包订单病例详情
|
||||
Router::get('/service/{order_no}', [PatientCaseController::class, 'getPatientFamilyServiceCase']);
|
||||
|
||||
// 病例未填字段
|
||||
Router::addGroup('/fields', function () {
|
||||
// 获取问诊订单病例缺少字段
|
||||
@ -802,12 +892,12 @@ Router::addGroup('/case', function () {
|
||||
|
||||
// 测试使用
|
||||
Router::addGroup('/test', function () {
|
||||
Router::get('', [TestController::class, 'test_17']);
|
||||
Router::get('', [TestController::class, 'test']);
|
||||
|
||||
//
|
||||
// Router::get('/uninquiry', [TestController::class, 'uninquiry']);
|
||||
// 模拟退款
|
||||
// Router::get('/refund', [TestController::class, 'refund']);
|
||||
// Router::post('/refund', [TestController::class, 'refund']);
|
||||
|
||||
});
|
||||
|
||||
@ -867,6 +957,9 @@ Router::addGroup('/im', function () {
|
||||
|
||||
// 获取视频问诊消息内页基础数据
|
||||
Router::get('/video/{order_inquiry_id:\d+}', [InquiryController::class, 'getInquiryVideoMessageBasic']);
|
||||
|
||||
// 获取服务包关联问诊订单消息内页基础数据
|
||||
Router::get('/service/{order_inquiry_id:\d+}', [InquiryController::class, 'getInquiryServiceMessageBasic']);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -900,6 +993,18 @@ Router::addGroup('/doctor', function () {
|
||||
Router::get('/inquiry/{doctor_id:\d+}', [UserDoctorController::class, 'getDoctorInfoInquiry']);
|
||||
});
|
||||
|
||||
// 获取医生开启的服务列表
|
||||
Router::get('/inquiry/service/{doctor_id:\d+}', [UserDoctorController::class, 'getDoctorOpenInquiryService']);
|
||||
// 问诊
|
||||
Router::addGroup('/inquiry', function () {
|
||||
// 服务
|
||||
Router::addGroup('/service', function () {
|
||||
// 获取医生开启的服务列表
|
||||
Router::get('/{doctor_id:\d+}', [UserDoctorController::class, 'getDoctorOpenInquiryService']);
|
||||
|
||||
// 随访包
|
||||
Router::addGroup('/follow', function () {
|
||||
// 获取医生问诊配置-随访包-列表
|
||||
Router::get('/item/{doctor_id:\d+}', [DoctorInquiryConfigController::class, 'getDoctorInquiryFollowItemConfig']);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -180,7 +180,7 @@ class Prescription
|
||||
}
|
||||
|
||||
return $response['data'];
|
||||
} catch (GuzzleException $e) {
|
||||
} catch (\Throwable $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -189,6 +189,8 @@ class Prescription
|
||||
* 上报处方
|
||||
* @param array $arg
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function reportPrescription(array $arg): array
|
||||
{
|
||||
@ -252,9 +254,11 @@ class Prescription
|
||||
/**
|
||||
* 请求封装
|
||||
* @param string $path
|
||||
* @param array $option
|
||||
* @param array $arg
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws GuzzleException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
protected function httpRequest(string $path,array $arg = []): array
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@ namespace Extend\VerifyDun;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\LogIdCard;
|
||||
use App\Utils\HttpRequest;
|
||||
use App\Utils\Log;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
@ -35,6 +36,10 @@ class IdCard extends Base
|
||||
$this->options["form_params"] = $this->params;
|
||||
|
||||
$result = $this->httpRuest->postRequest($api_url,$this->options);
|
||||
|
||||
// 记录日志,ca认证要求
|
||||
Log::getInstance("VerifyDun-IdCard-checkIdCard")->info(json_encode($result,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (empty($result)){
|
||||
return "身份证认证失败";
|
||||
}
|
||||
@ -50,22 +55,21 @@ class IdCard extends Base
|
||||
return "身份证认证失败";
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
$this->recordLog($params['dataId'],$params['name'],$params['cardNo'],$result);
|
||||
|
||||
// 处理不通过情况
|
||||
if ($result['result']['status'] == 2){
|
||||
switch ($result['result']['reasonType']) {
|
||||
case 2:
|
||||
return "输入姓名和身份证号不一致";
|
||||
break;
|
||||
case 3:
|
||||
return "查无此身份证";
|
||||
break;
|
||||
case 4:
|
||||
return "身份证照片信息与输入信息不一致";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "身份证认证失败";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,4 +83,28 @@ class IdCard extends Base
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录日志
|
||||
* @param string $data_id
|
||||
* @param string $name
|
||||
* @param string $card_no
|
||||
* @param array $result
|
||||
* @return void
|
||||
*/
|
||||
public function recordLog(string $data_id,string $name,string $card_no,array $result): void
|
||||
{
|
||||
try {
|
||||
$data = array();
|
||||
$data['name'] = $name;
|
||||
$data['card_no'] = $card_no;
|
||||
$data['status'] = $result['result']['status'];
|
||||
$data['data_id'] = $data_id;
|
||||
$data['task_id'] = $result['result']['taskId'];
|
||||
$data['content'] = json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
LogIdCard::addLogIdCard($data);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("VerifyDun-IdCard-checkIdCard")->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@ class WechatPay
|
||||
|
||||
/**
|
||||
* @param string $user_type 用户类型(1:患者端 2:专家端 3:药师端)
|
||||
* @param int $order_type 订单类型(1:问诊订单 2:药品订单 3:检测订单)
|
||||
* @param int $order_type 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:健康包订单 5:随访包订单)
|
||||
*/
|
||||
public function __construct(string $user_type,int $order_type)
|
||||
{
|
||||
@ -44,7 +44,7 @@ class WechatPay
|
||||
throw new BusinessException("系统配置错误", HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
if (!in_array($order_type,[1,2,3])){
|
||||
if (!in_array($order_type,[1,2,3,4,5])){
|
||||
throw new BusinessException("订单类型错误", HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ -69,6 +69,20 @@ class WechatPay
|
||||
$this->pay_config = config("we_chat.applets.pay.1636644248");
|
||||
}
|
||||
|
||||
if ($order_type == 4){
|
||||
$this->pay_notify_url = $this->config['service_pay_notify_url'];
|
||||
$this->refund_notify_url = $this->config['service_refund_notify_url'];
|
||||
|
||||
$this->pay_config = config("we_chat.applets.pay.1659662936");
|
||||
}
|
||||
|
||||
if ($order_type == 5){
|
||||
$this->pay_notify_url = $this->config['service_pay_notify_url'];
|
||||
$this->refund_notify_url = $this->config['service_refund_notify_url'];
|
||||
|
||||
$this->pay_config = config("we_chat.applets.pay.1659662936");
|
||||
}
|
||||
|
||||
$app_env = config('app_env','dev');
|
||||
if ($app_env == "prod"){
|
||||
$this->domain_name = env('DOMAIN_NAME_PROD','https://prod.hospital.applets.igandanyiyuan.com/');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user