新增药品订单接口
This commit is contained in:
@@ -7,7 +7,9 @@ use App\Constants\HttpEnumCode;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\UserDoctor;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
@@ -277,6 +279,7 @@ class PatientOrderService extends BaseService
|
||||
$inquiryService->inquiryRefund($order_inquiry['order_inquiry_id'],"取消问诊");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
@@ -287,6 +290,9 @@ class PatientOrderService extends BaseService
|
||||
|
||||
/**
|
||||
* 删除问诊订单
|
||||
* 支付超时
|
||||
* 取消问诊
|
||||
* 问诊结束
|
||||
* @return array
|
||||
*/
|
||||
public function deletePatientInquiryOrder(): array
|
||||
@@ -306,16 +312,11 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if (!in_array($order_inquiry['inquiry_status'],[1,5])) {
|
||||
if (!in_array($order_inquiry['inquiry_status'],[6,7])) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单正在退款中");
|
||||
}
|
||||
|
||||
// 修改订单删除状态
|
||||
$data = array();
|
||||
$data['is_delete'] = 1;
|
||||
@@ -349,9 +350,9 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if (!in_array($order_inquiry['inquiry_status'],[1])) {
|
||||
if ($order_inquiry['inquiry_status'] != 1) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法取消支付");
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])) {
|
||||
@@ -359,12 +360,12 @@ class PatientOrderService extends BaseService
|
||||
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['cancel_remarks'] = "未支付取消";
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
@@ -447,12 +448,157 @@ class PatientOrderService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderInquiry::getOne($params);
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['order_product_id'] = $order_product['order_product_id'];
|
||||
$order_product_item = OrderProductItem::getList($params);
|
||||
if (empty($order_product_item)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 处理商品图片
|
||||
foreach ($order_product_item as &$item){
|
||||
$item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']);
|
||||
}
|
||||
|
||||
if (!empty($order_product['doctor_id'])){
|
||||
// 获取问诊医生数据
|
||||
$fields = [
|
||||
'doctor_id',
|
||||
'user_name',
|
||||
'multi_point_status',
|
||||
'avatar',
|
||||
'doctor_title',
|
||||
'department_custom_name',
|
||||
'be_good_at',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_product['doctor_id'];
|
||||
$user_doctor = UserDoctor::getWithHospitalOne($params,$fields);
|
||||
if (empty($user_doctor)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
}
|
||||
|
||||
$user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['user_doctor'] = $user_doctor ?? [];
|
||||
$result['order_product'] = $order_product;
|
||||
$result['order_product_item'] = $order_product_item;
|
||||
|
||||
return success($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 药品订单取消支付
|
||||
* @return array
|
||||
*/
|
||||
public function putPatientProductOrderCancelPay(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_product_id = $this->request->route('order_product_id');
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
try {
|
||||
// 获取药品订单数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
Db::rollBack();
|
||||
return fail();
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_product['order_product_status'] != 1) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if ($order_product['pay_status'] != 1) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
if (!in_array($order_product['refund_status'],[0,4,5])) {
|
||||
Db::rollBack();
|
||||
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单正在退款中");
|
||||
}
|
||||
|
||||
// 修改订单状态
|
||||
$data = array();
|
||||
$data['order_product_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_reason'] = 1; // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除药品订单
|
||||
* 已收货
|
||||
* 取消订单
|
||||
* @return array
|
||||
*/
|
||||
public function deletePatientProductOrder(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
|
||||
$order_product_id = $this->request->route('order_product_id');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['order_product_id'] = $order_product_id;
|
||||
$params['is_delete'] = 0;
|
||||
$order_product = OrderProduct::getOne($params);
|
||||
if (empty($order_product)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
if (!in_array($order_product['order_product_status'],[4,5])) {
|
||||
Db::rollBack();
|
||||
// 订单状态(1:待支付 2:待发货 3:已发货 4:已签收 5:已取消)
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"订单无法删除");
|
||||
}
|
||||
|
||||
// 修改订单状态
|
||||
$data = array();
|
||||
$data['order_product_status'] = 5;
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s",time());
|
||||
$data['cancel_reason'] = 1; // 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时
|
||||
$data['cancel_remarks'] = "主动取消";
|
||||
$data['updated_at'] = date("Y-m-d H:i:s",time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_product['order_inquiry_id'];
|
||||
OrderProduct::edit($params,$data);
|
||||
|
||||
return success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user