debug
This commit is contained in:
@@ -200,43 +200,32 @@ trait PersonalStatsScopeTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一天 + 同一渠道全局唯一(不分录入人):避免重复汇总。
|
||||
* 命中时返回首个已存在记录的录入人姓名,便于前端提示。
|
||||
*
|
||||
* @return array{conflict: bool, creator_name: string}
|
||||
* 同一录入人 + 同一天 + 同一渠道唯一(不同录入人可同日同渠道各录一条)。
|
||||
*/
|
||||
protected static function findYejiConflict(string $yejiDate, string $mediaSource, int $excludeId = 0): array
|
||||
protected static function isYejiDuplicate(int $creatorId, string $yejiDate, string $mediaSource, int $excludeId = 0): bool
|
||||
{
|
||||
$query = PersonalYeji::where('yeji_date', $yejiDate)
|
||||
$query = PersonalYeji::where('creator_id', $creatorId)
|
||||
->where('yeji_date', $yejiDate)
|
||||
->where('media_source', $mediaSource);
|
||||
if ($excludeId > 0) {
|
||||
$query->where('id', '<>', $excludeId);
|
||||
}
|
||||
$row = $query->field('id, creator_name')->find();
|
||||
if (!$row) {
|
||||
return ['conflict' => false, 'creator_name' => ''];
|
||||
}
|
||||
|
||||
return ['conflict' => true, 'creator_name' => (string) ($row['creator_name'] ?? '')];
|
||||
return $query->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同一天 + 同一渠道全局唯一(不分录入人):避免重复汇总。
|
||||
*
|
||||
* @return array{conflict: bool, creator_name: string}
|
||||
* 同一录入人 + 同一天 + 同一渠道唯一(不同录入人可同日同渠道各录一条)。
|
||||
*/
|
||||
protected static function findCostConflict(string $costDate, string $mediaSource, int $excludeId = 0): array
|
||||
protected static function isCostDuplicate(int $creatorId, string $costDate, string $mediaSource, int $excludeId = 0): bool
|
||||
{
|
||||
$query = PersonalAccountCost::where('cost_date', $costDate)
|
||||
$query = PersonalAccountCost::where('creator_id', $creatorId)
|
||||
->where('cost_date', $costDate)
|
||||
->where('media_source', $mediaSource);
|
||||
if ($excludeId > 0) {
|
||||
$query->where('id', '<>', $excludeId);
|
||||
}
|
||||
$row = $query->field('id, creator_name')->find();
|
||||
if (!$row) {
|
||||
return ['conflict' => false, 'creator_name' => ''];
|
||||
}
|
||||
|
||||
return ['conflict' => true, 'creator_name' => (string) ($row['creator_name'] ?? '')];
|
||||
return $query->count() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user