fix: [entertainment,welfare] 바로빌 조인 컬럼명 및 심야 시간 파싱 수정
- approval_no → approval_num 컬럼명 수정
- use_time 심야 판별: HOUR() → SUBSTRING 문자열 파싱으로 변경
- whereNotNull('bct.use_time') 조건 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -125,7 +125,7 @@ private function getWeekendLateNightRisk(int $tenantId, string $startDate, strin
|
||||
// 심야 사용 (barobill 카드 거래 내역에서 시간 확인)
|
||||
$lateNightResult = DB::table('expense_accounts as ea')
|
||||
->leftJoin('barobill_card_transactions as bct', function ($join) {
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_no')
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_num')
|
||||
->on('ea.tenant_id', '=', 'bct.tenant_id');
|
||||
})
|
||||
->where('ea.tenant_id', $tenantId)
|
||||
@@ -133,9 +133,10 @@ private function getWeekendLateNightRisk(int $tenantId, string $startDate, strin
|
||||
->whereBetween('ea.expense_date', [$startDate, $endDate])
|
||||
->whereNull('ea.deleted_at')
|
||||
->whereRaw('DAYOFWEEK(ea.expense_date) NOT IN (1, 7)') // 주말 제외 (중복 방지)
|
||||
->whereNotNull('bct.use_time')
|
||||
->where(function ($q) {
|
||||
$q->whereRaw('HOUR(bct.use_time) >= ?', [self::LATE_NIGHT_START])
|
||||
->orWhereRaw('HOUR(bct.use_time) < ?', [self::LATE_NIGHT_END]);
|
||||
$q->whereRaw('CAST(SUBSTRING(bct.use_time, 1, 2) AS UNSIGNED) >= ?', [self::LATE_NIGHT_START])
|
||||
->orWhereRaw('CAST(SUBSTRING(bct.use_time, 1, 2) AS UNSIGNED) < ?', [self::LATE_NIGHT_END]);
|
||||
})
|
||||
->selectRaw('COUNT(*) as count, COALESCE(SUM(ea.amount), 0) as total')
|
||||
->first();
|
||||
@@ -154,7 +155,7 @@ private function getProhibitedBizTypeRisk(int $tenantId, string $startDate, stri
|
||||
{
|
||||
$result = DB::table('expense_accounts as ea')
|
||||
->join('barobill_card_transactions as bct', function ($join) {
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_no')
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_num')
|
||||
->on('ea.tenant_id', '=', 'bct.tenant_id');
|
||||
})
|
||||
->where('ea.tenant_id', $tenantId)
|
||||
|
||||
@@ -177,7 +177,7 @@ private function getPrivateUseRisk(int $tenantId, string $startDate, string $end
|
||||
// 심야 사용 (barobill 조인)
|
||||
$lateNightResult = DB::table('expense_accounts as ea')
|
||||
->leftJoin('barobill_card_transactions as bct', function ($join) {
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_no')
|
||||
$join->on('ea.receipt_no', '=', 'bct.approval_num')
|
||||
->on('ea.tenant_id', '=', 'bct.tenant_id');
|
||||
})
|
||||
->where('ea.tenant_id', $tenantId)
|
||||
@@ -185,9 +185,10 @@ private function getPrivateUseRisk(int $tenantId, string $startDate, string $end
|
||||
->whereBetween('ea.expense_date', [$startDate, $endDate])
|
||||
->whereNull('ea.deleted_at')
|
||||
->whereRaw('DAYOFWEEK(ea.expense_date) NOT IN (1, 7)')
|
||||
->whereNotNull('bct.use_time')
|
||||
->where(function ($q) {
|
||||
$q->whereRaw('HOUR(bct.use_time) >= 22')
|
||||
->orWhereRaw('HOUR(bct.use_time) < 6');
|
||||
$q->whereRaw('CAST(SUBSTRING(bct.use_time, 1, 2) AS UNSIGNED) >= 22')
|
||||
->orWhereRaw('CAST(SUBSTRING(bct.use_time, 1, 2) AS UNSIGNED) < 6');
|
||||
})
|
||||
->selectRaw('COUNT(*) as count, COALESCE(SUM(ea.amount), 0) as total')
|
||||
->first();
|
||||
|
||||
Reference in New Issue
Block a user