42 lines
1.7 KiB
PHP
42 lines
1.7 KiB
PHP
<?php
|
|
class erpDailyUcoTargetMapper
|
|
{
|
|
public static function map($payload)
|
|
{
|
|
$after = $payload['after'] ?? [];
|
|
|
|
return [
|
|
"cduDate" => self::date($after['u_date'] ?? null),
|
|
"cduExternalDriverId" => $after['u_druid'] ?? null, // employee_external_map 참조
|
|
"cduTargetQty" => isset($after['u_target_qty']) ? (float)$after['u_target_qty'] : null,
|
|
"cduTargetVisitCnt" => isset($after['u_target_visit_cnt']) ? (int)$after['u_target_visit_cnt'] : null,
|
|
"cduTargetSyncedAt" => self::datetime($after['u_synced_at'] ?? null),
|
|
"cduExternalCreatedBy" => $after['u_createruid'] ?? null, // employee_external_map 참조
|
|
"cduExternalUpdatedBy" => $after['u_createruid'] ?? null,
|
|
"cduLoginUser" => $after['u_createruid'] ?? null,
|
|
];
|
|
}
|
|
|
|
private static function date($yyyymmdd)
|
|
{
|
|
if (empty($yyyymmdd) || strlen($yyyymmdd) != 8) {
|
|
return null;
|
|
}
|
|
return substr($yyyymmdd,0,4)."-".
|
|
substr($yyyymmdd,4,2)."-".
|
|
substr($yyyymmdd,6,2);
|
|
}
|
|
|
|
private static function datetime($yyyymmddhhmiss)
|
|
{
|
|
if (empty($yyyymmddhhmiss) || strlen($yyyymmddhhmiss) != 14) {
|
|
return null;
|
|
}
|
|
return substr($yyyymmddhhmiss,0,4)."-".
|
|
substr($yyyymmddhhmiss,4,2)."-".
|
|
substr($yyyymmddhhmiss,6,2)."T".
|
|
substr($yyyymmddhhmiss,8,2).":".
|
|
substr($yyyymmddhhmiss,10,2).":".
|
|
substr($yyyymmddhhmiss,12,2);
|
|
}
|
|
} |