更新
This commit is contained in:
@@ -10,7 +10,6 @@ use app\common\model\OrderDetail;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\tcm\PrescriptionOrder;
|
||||
use app\common\model\tcm\PrescriptionOrderPayOrder;
|
||||
use app\common\service\wechat\WechatWorkExternalPayService;
|
||||
use think\facade\Db;
|
||||
@@ -1300,7 +1299,7 @@ class OrderLogic
|
||||
|
||||
/**
|
||||
* 某诊单下可关联的支付单(待支付/已支付),供关联业务订单多选(主管/诊单医助看该诊单全部;否则仅本人创建)
|
||||
* 已占用(关联到未撤回/未取消的业务订单)的支付单会排除;编辑某业务订单时传 $exceptPrescriptionOrderId 以保留当前单已选中的项
|
||||
* 已关联到未删除业务订单的支付单会排除;编辑时保留当前单已选中的项
|
||||
* 列表仅含 2026-04-20 及之后创建的支付单(已关联到当前编辑业务订单的除外)
|
||||
*
|
||||
* @return array<int, array<string, mixed>>
|
||||
@@ -1332,15 +1331,8 @@ class OrderLogic
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$activePoIds = PrescriptionOrder::whereNull('delete_time')
|
||||
->where('fulfillment_status', '<>', 4)
|
||||
->column('id');
|
||||
$busyPayIds = [];
|
||||
if ($activePoIds !== []) {
|
||||
$busyPayIds = PrescriptionOrderPayOrder::whereIn('prescription_order_id', $activePoIds)
|
||||
->column('pay_order_id');
|
||||
$busyPayIds = array_unique(array_map('intval', $busyPayIds));
|
||||
}
|
||||
$busyPayIds = $rows === [] ? [] : array_map('intval', self::prescriptionOrderReceiptLinks(array_column($rows, 'id'))
|
||||
->column('link.pay_order_id'));
|
||||
$whiteList = [];
|
||||
if ($exceptPrescriptionOrderId !== null && $exceptPrescriptionOrderId > 0) {
|
||||
$whiteList = array_map(
|
||||
@@ -1372,8 +1364,17 @@ class OrderLogic
|
||||
return $out;
|
||||
}
|
||||
|
||||
/** @param int[] $payOrderIds */
|
||||
public static function prescriptionOrderReceiptLinks(array $payOrderIds): \think\db\Query
|
||||
{
|
||||
return Db::name('tcm_prescription_order_pay_order')->alias('link')
|
||||
->join('tcm_prescription_order po', 'po.id = link.prescription_order_id')
|
||||
->whereIn('link.pay_order_id', $payOrderIds)
|
||||
->whereNull('po.delete_time');
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验支付单均可关联到指定诊单(已支付、归属与权限)
|
||||
* 校验支付单均可关联到指定诊单(已支付、归属与权限),调用方须持有事务
|
||||
* 默认仅允许关联 2026-04-20 及之后创建的支付单;编辑业务订单时传入 $prescriptionOrderIdForDateGrace,已关联到该业务订单的旧单除外
|
||||
*
|
||||
* @param int[] $ids zyt_order.id
|
||||
@@ -1402,7 +1403,7 @@ class OrderLogic
|
||||
$assistantId = (int) Diagnosis::where('id', $diagnosisId)->value('assistant_id');
|
||||
$isDiagAssistant = $assistantId === $adminId;
|
||||
|
||||
$orders = Order::whereIn('id', $ids)->whereNull('delete_time')->select();
|
||||
$orders = Order::whereIn('id', $ids)->whereNull('delete_time')->order('id', 'asc')->lock(true)->select();
|
||||
if (count($orders) !== count($ids)) {
|
||||
return '部分支付单不存在或已删除';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user