parent
b1c1c54a44
commit
b25e55d1be
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,25 @@ while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
|
||||||
switch ($entity) {
|
switch ($entity) {
|
||||||
// DAILY
|
// DAILY
|
||||||
case 'DAILY':
|
case 'DAILY':
|
||||||
|
$action = strtoupper(trim($payload['action'] ?? ''));
|
||||||
|
|
||||||
|
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);
|
$body = erpDailyOrderMapper::map($payload);
|
||||||
$method = 'POST';
|
$method = 'POST';
|
||||||
$url = $serverUrl . "/crm-rest-api/customer-daily-order";
|
$url = $serverUrl . "/crm-rest-api/customer-daily-order";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// CUSTOMER
|
// CUSTOMER
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue