修改 取消支付/上报后,处方平台审核失败情况下健康包订单的药品使用数量问题

This commit is contained in:
wucongxing8150 2024-04-30 10:42:39 +08:00
parent d6220dbd5f
commit bf94959b06
2 changed files with 57 additions and 8 deletions

View File

@ -13,6 +13,7 @@ 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;
@ -165,13 +166,25 @@ class OrderProductService extends BaseService
$params['amount_id'] = $product_platform_amount['amount_id'];
ProductPlatformAmount::inc($params, 'stock', (float)$item['amount']);
// 回退服务包已使用药品数量
if ($order_inquiry['inquiry_type'] == 1 && $order_inquiry['inquiry_mode'] == 8){
// 获取患者家庭成员进行中的服务包订单-健康包
$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'];
OrderServicePackageProduct::deleteOrderServicePackageProduct($params);
$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);
}
}
}

View File

@ -12,11 +12,13 @@ use App\Model\OrderInquiry;
use App\Model\OrderInquiryCoupon;
use App\Model\OrderInquiryRefund;
use App\Model\OrderProduct;
use App\Model\OrderProductItem;
use App\Model\OrderProductRefund;
use App\Model\OrderRefund;
use App\Model\OrderServicePackage;
use App\Model\OrderServicePackageDetail;
use App\Model\OrderServicePackageInquiry;
use App\Model\OrderServicePackageProduct;
use App\Model\OrderServicePackageRefund;
use App\Utils\Log;
use Extend\Wechat\WechatPay;
@ -212,11 +214,6 @@ class OrderService extends BaseService
$refund_id = $refund_result['refund_id'];
} else {
// 药品订单不存在模拟退款
if ($order['order_type'] == 2){
throw new BusinessException("订单金额错误");
}
// 模拟退款
$refund_status = 3;
@ -337,6 +334,45 @@ class OrderService extends BaseService
$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)){
throw new BusinessException("未查询到对应问诊订单数据");
}
// 获取订单商品订单列表
$params = array();
$params['order_product_id'] = $order_product['order_product_id'];
$order_product_items = OrderProductItem::getList($params);
if (empty($order_product_items)){
throw new BusinessException("未查询到对应订单商品订单列表");
}
// 获取患者家庭成员进行中的服务包订单-健康包
$OrderServicePackageService = new OrderServicePackageService();
$order_service_package = $OrderServicePackageService->getPatientFamilyInProgressServicePackage($order_product['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: // 检测订单
// 获取订单数据