parent
537aa8d21e
commit
fb3845ec64
@ -16,6 +16,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
class AfterSalesCostRowRepository
|
||||
{
|
||||
private const TABLE = 'ops_after_sales_cost_rows';
|
||||
private const INTERNAL_ORDER_MAX_PREFIX_LENGTH = 11;
|
||||
|
||||
private ?bool $available = null;
|
||||
|
||||
@ -316,7 +317,12 @@ class AfterSalesCostRowRepository
|
||||
$ids = [];
|
||||
|
||||
foreach (['online_order_no', 'internal_order_no'] as $field) {
|
||||
$query = $this->orderNumberBranch($baseFilters, $field, $values)
|
||||
$fieldValues = self::orderValuesForField($field, $values);
|
||||
if ($fieldValues === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$query = $this->orderNumberBranch($baseFilters, $field, $fieldValues)
|
||||
->select('id')
|
||||
->limit($cap);
|
||||
|
||||
@ -358,7 +364,9 @@ class AfterSalesCostRowRepository
|
||||
|
||||
$baseFilters = array_replace($filters, ['order_no' => '']);
|
||||
foreach (['online_order_no', 'internal_order_no'] as $field) {
|
||||
if ($this->orderNumberBranch($baseFilters, $field, $values)->limit(1)->exists()) {
|
||||
$fieldValues = self::orderValuesForField($field, $values);
|
||||
if ($fieldValues !== []
|
||||
&& $this->orderNumberBranch($baseFilters, $field, $fieldValues)->limit(1)->exists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -496,6 +504,19 @@ class AfterSalesCostRowRepository
|
||||
return str_replace(['!', '%', '_'], ['!!', '!%', '!_'], trim($value)) . '%';
|
||||
}
|
||||
|
||||
/** @param list<string> $values @return list<string> */
|
||||
private static function orderValuesForField(string $field, array $values): array
|
||||
{
|
||||
if ($field !== 'internal_order_no') {
|
||||
return $values;
|
||||
}
|
||||
|
||||
return array_values(array_filter(
|
||||
$values,
|
||||
static fn (string $value): bool => mb_strlen($value) <= self::INTERNAL_ORDER_MAX_PREFIX_LENGTH,
|
||||
));
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private static function batchValues(string $value): array
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user