|
@@ -206,15 +206,19 @@ class OrderCgClearClass extends BaseClass
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 采购单关联的已销结账单(只认本采购单 cgId,绝不回退到 saleId)
|
|
* 采购单关联的已销结账单(只认本采购单 cgId,绝不回退到 saleId)
|
|
|
- * 说明:若按 saleId 查,会把该关联销售单的客户结账一并带出,采购详情「结账信息」会错混销售结账。
|
|
|
|
|
|
|
+ * 说明1:若按 saleId 查,会把该关联销售单的客户结账一并带出,采购详情「结账信息」会错混销售结账。
|
|
|
|
|
+ * 说明2:xhOrderCgClear.cgId 在不同结账场景下可能指向不同表的主键(如供货商自身采购
|
|
|
|
|
+ * bizGhs\order\classes\PurchaseOrderClass 与花店采购 bizHd\purchase\classes\PurchaseClass),
|
|
|
|
|
+ * 两边自增 id 存在撞号可能。仅按 cgId 过滤仍可能混入其它业务线的结账记录,
|
|
|
|
|
+ * 必须再按 xhClear.clearStyle 精确限定属于哪种结账方式,才能确认是「同一个」采购单。
|
|
|
*
|
|
*
|
|
|
|
|
+ * @param int $purchaseId 采购单/cgId
|
|
|
|
|
+ * @param int|null $clearStyle 限定的结账方式(dict clearStyle),传 null 则不按结账方式过滤
|
|
|
* @return array<int, array{clearId:int, clearSn:string, amount:string}>
|
|
* @return array<int, array{clearId:int, clearSn:string, amount:string}>
|
|
|
*/
|
|
*/
|
|
|
- public static function listPaidClearRecordsForPurchase($purchaseId, $saleOrderId = 0)
|
|
|
|
|
|
|
+ public static function listPaidClearRecordsForPurchase($purchaseId, $clearStyle = null)
|
|
|
{
|
|
{
|
|
|
$purchaseId = intval($purchaseId);
|
|
$purchaseId = intval($purchaseId);
|
|
|
- // $saleOrderId 保留入参兼容旧调用,采购结账列表不再使用,避免混入销售单结账
|
|
|
|
|
- unset($saleOrderId);
|
|
|
|
|
|
|
|
|
|
if ($purchaseId <= 0) {
|
|
if ($purchaseId <= 0) {
|
|
|
return [];
|
|
return [];
|
|
@@ -225,6 +229,25 @@ class OrderCgClearClass extends BaseClass
|
|
|
'status' => self::STATUS_HAS_PAY,
|
|
'status' => self::STATUS_HAS_PAY,
|
|
|
], 'id asc', '*', null, true);
|
|
], 'id asc', '*', null, true);
|
|
|
|
|
|
|
|
|
|
+ if (empty($cgList)) {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($clearStyle !== null) {
|
|
|
|
|
+ $clearIds = array_values(array_unique(array_filter(array_map(function ($item) {
|
|
|
|
|
+ return intval(is_object($item) ? ($item->clearId ?? 0) : ($item['clearId'] ?? 0));
|
|
|
|
|
+ }, $cgList))));
|
|
|
|
|
+ $allowedClearIds = empty($clearIds) ? [] : ClearClass::getAllByCondition([
|
|
|
|
|
+ 'id' => ['in', $clearIds],
|
|
|
|
|
+ 'clearStyle' => intval($clearStyle),
|
|
|
|
|
+ ], null, 'id', null);
|
|
|
|
|
+ $allowedClearIds = array_flip(array_map('intval', array_column($allowedClearIds, 'id')));
|
|
|
|
|
+ $cgList = array_values(array_filter($cgList, function ($item) use ($allowedClearIds) {
|
|
|
|
|
+ $clearId = intval(is_object($item) ? ($item->clearId ?? 0) : ($item['clearId'] ?? 0));
|
|
|
|
|
+ return isset($allowedClearIds[$clearId]);
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return self::mapPaidClearRecordRows($cgList);
|
|
return self::mapPaidClearRecordRows($cgList);
|
|
|
}
|
|
}
|
|
|
|
|
|