u
This commit is contained in:
@@ -36,16 +36,30 @@ void handle_order(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/) {
|
||||
|
||||
try {
|
||||
nlohmann::json created = order::create_order(order);
|
||||
logc::success("order %s (kAuftrag=%s) created for externalId=%s",
|
||||
created.value("orderNumber", "").c_str(),
|
||||
created.value("orderId", "").c_str(),
|
||||
externalOrderId.c_str());
|
||||
results.push_back({
|
||||
{"status", "OK"},
|
||||
{"externalOrderId", externalOrderId},
|
||||
{"message", ""}
|
||||
});
|
||||
++successful;
|
||||
if (created.value("alreadyExists", false)) {
|
||||
std::string msg = "order already mapped, skipped save (kAuftrag="
|
||||
+ created.value("orderId", "") + ", "
|
||||
+ created.value("orderNumber", "") + ")";
|
||||
logc::error("order externalId=%s skipped: %s",
|
||||
externalOrderId.c_str(), msg.c_str());
|
||||
results.push_back({
|
||||
{"status", "ERROR"},
|
||||
{"externalOrderId", externalOrderId},
|
||||
{"message", msg}
|
||||
});
|
||||
++failed;
|
||||
} else {
|
||||
logc::success("order %s (kAuftrag=%s) created for externalId=%s",
|
||||
created.value("orderNumber", "").c_str(),
|
||||
created.value("orderId", "").c_str(),
|
||||
externalOrderId.c_str());
|
||||
results.push_back({
|
||||
{"status", "OK"},
|
||||
{"externalOrderId", externalOrderId},
|
||||
{"message", ""}
|
||||
});
|
||||
++successful;
|
||||
}
|
||||
} catch (const std::exception& ex) {
|
||||
logc::error("order externalId=%s failed: %s", externalOrderId.c_str(), ex.what());
|
||||
results.push_back({
|
||||
@@ -57,7 +71,8 @@ void handle_order(HttpRequest& req, HttpResponse& resp, RouteContext& /*ctx*/) {
|
||||
}
|
||||
}
|
||||
|
||||
resp.send_json(200, results);
|
||||
int http_status = (failed > 0) ? 500 : 200;
|
||||
resp.send_json(http_status, results);
|
||||
|
||||
if (orders.empty()) {
|
||||
logc::info("POST /v1/order: no orders in body");
|
||||
|
||||
Reference in New Issue
Block a user