- [ORDER] Delete 동기화 버그 수정.
This commit is contained in:
Hyojin Ahn 2026-06-14 10:52:35 -04:00
parent b1c1c54a44
commit b25e55d1be
2 changed files with 22 additions and 5 deletions

View File

@ -3,7 +3,8 @@ class erpDailyOrderMapper
{ {
public static function map($payload) public static function map($payload)
{ {
$after = $payload['after']; $data = $payload['after'] ?? $payload['before'] ?? [];
$isDelete = strtoupper($payload['action'] ?? '') === 'DELETED';
return [ return [
@ -18,7 +19,7 @@ class erpDailyOrderMapper
"cdoPaymentType" => $after['d_paymenttype'] ?? null, "cdoPaymentType" => $after['d_paymenttype'] ?? null,
"cdoCycle" => $after['d_cycle'] ?? null, "cdoCycle" => $after['d_cycle'] ?? null,
"cdoRate" => isset($after['d_rate']) ? (float)$after['d_rate'] : null, "cdoRate" => isset($after['d_rate']) ? (float)$after['d_rate'] : null,
"cdoStatus" => $after['d_status'] ?? 'A', "cdoStatus" => $isDelete ? 'D' : ($data['d_status'] ?? 'A'),
"cdoVisitFlag" => $after['d_visit'] ?? 'N', "cdoVisitFlag" => $after['d_visit'] ?? 'N',
"cdoEstimatedQty" => isset($after['d_estquantity']) ? (float)$after['d_estquantity'] : null, "cdoEstimatedQty" => isset($after['d_estquantity']) ? (float)$after['d_estquantity'] : null,
"cdoPickupAt" => ($after['d_status'] ?? '') === 'F' ? self::datetime($after['d_modifydate'] ?? null) : null, "cdoPickupAt" => ($after['d_status'] ?? '') === 'F' ? self::datetime($after['d_modifydate'] ?? null) : null,

View File

@ -107,9 +107,25 @@ while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
switch ($entity) { switch ($entity) {
// DAILY // DAILY
case 'DAILY': case 'DAILY':
$body = erpDailyOrderMapper::map($payload); $action = strtoupper(trim($payload['action'] ?? ''));
$method = 'POST';
$url = $serverUrl . "/crm-rest-api/customer-daily-order"; if ($action === 'DELETED') {
$key = $payload['key'];
$od = preg_replace('/[^0-9]/', '', $key['d_orderdate']);
$orderDateIso = substr($od,0,4)."-".substr($od,4,2)."-".substr($od,6,2);
$method = 'DELETE';
$url = $serverUrl
. "/crm-rest-api/customer-daily-order"
. "/customer/" . urlencode($key['d_accountno'])
. "/date/" . urlencode($orderDateIso)
. "/jobtype/" . urlencode($key['d_jobtype']);
$body = null; // DELETE 는 바디 불필요
} else {
$body = erpDailyOrderMapper::map($payload);
$method = 'POST';
$url = $serverUrl . "/crm-rest-api/customer-daily-order";
}
break; break;
// CUSTOMER // CUSTOMER