feat: add article and production modules

This commit is contained in:
2026-08-31 13:16:46 +08:00
parent ac3da246b2
commit 5c586a1a95
334 changed files with 34419 additions and 1 deletions
@@ -0,0 +1,72 @@
<?php
declare(strict_types=1);
namespace plugin\produce\app\dao;
use core\base\BaseDao;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use plugin\produce\app\model\ExceptionRecord;
class ExceptionRecordDao extends BaseDao
{
protected function setModel(): string
{
return ExceptionRecord::class;
}
protected function getKeywordFields(): array
{
return ['order_no', 'user_code', 'reporter', 'type_name', 'reason_name', 'issue_name', 'remark'];
}
public function selectList(
array $where,
string|array $field = '*',
int $page = 0,
int $limit = 0,
string $order = '',
array $with = [],
bool $search = false,
?array $withoutScopes = null
): ?Collection {
$with = array_unique(array_merge($with, ['createds']));
$order = $order ?: 'reported_at desc, id desc';
return parent::selectList($where, $field, $page, $limit, $order, $with, $search, $withoutScopes);
}
public function handleSearch(array $where, bool $isPage = true): Builder
{
$query = $this->query();
if (($where['keyword'] ?? '') !== '') {
$keyword = '%' . $where['keyword'] . '%';
$query->where(function (Builder $builder) use ($keyword) {
$builder->where('order_no', 'like', $keyword)
->orWhere('user_code', 'like', $keyword)
->orWhere('reporter', 'like', $keyword)
->orWhere('type_name', 'like', $keyword)
->orWhere('reason_name', 'like', $keyword)
->orWhere('issue_name', 'like', $keyword)
->orWhere('remark', 'like', $keyword);
});
}
foreach (['type_code', 'reason_code', 'issue_code', 'status'] as $field) {
if (($where[$field] ?? '') !== '') {
$query->where($field, $where[$field]);
}
}
if (!empty($where['reported_at_range']) && is_array($where['reported_at_range']) && count($where['reported_at_range']) === 2) {
$query->whereBetween('reported_at', [
strtotime((string) $where['reported_at_range'][0] . ' 00:00:00'),
strtotime((string) $where['reported_at_range'][1] . ' 23:59:59'),
]);
}
return $query;
}
}