{"data":{"exception":"InvalidOperationException","message":"The instance of entity type 'EcommerceOrder' cannot be tracked because another instance with the key value '{Id: 552}' is already being tracked. When attaching existing entities, ensure that only one entity instance with a given key value is attached.","helpLink":null,"data":{},"source":"Microsoft.EntityFrameworkCore","stackTrace":" at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.ThrowIdentityConflict(InternalEntityEntry entry)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.Add(TKey key, InternalEntityEntry entry, Boolean updateDuplicate)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges, Boolean modifyProperties)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction(EntityEntryGraphNode`1 node)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph[TState](EntityEntryGraphNode`1 node, Func`2 handleNode)\n at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph(InternalEntityEntry rootEntry, EntityState targetState, EntityState storeGeneratedWithKeySetTargetState, Boolean forceStateWhenUnknownKey)\n at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.Attach(TEntity entity)\n at Redsand.Site.Services.OrderService.EcommerceUpdateInventoryAsync(EcommerceOrder order, String message, Boolean reInclude, ApplicationDbContext _db) in E:\\redsand\\BaseV2-Net6\\Services\\Order\\OrderService.cs:line 398\n at Redsand.Site.Api.OrdersEcommerceController.Update(Int32 id, EcommerceOrderBody model) in E:\\redsand\\BaseV2-Net6\\Api\\EcommerceOrder\\OrderController.cs:line 3382\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)","inner":null},"status":400,"statusText":"","headers":{"access-control-allow-origin":"*","cache-control":"no-store","content-type":"application/json; charset=utf-8","date":"Sun, 11 Jan 2026 03:50:11 GMT","expires":"0","pragma":"no-cache","server":"nginx/1.28.0"},"config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http","fetch"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json","Content-Type":"application/json","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjUiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiMDkzNjg3ODk5NyIsIkFzcE5ldC5JZGVudGl0eS5TZWN1cml0eVN0YW1wIjoiVUxaRkxWRTdEMjRUVlM0M0RHU1I0NktWREVDSVpUTjYiLCJzdWIiOiIwOTM2ODc4OTk3IiwianRpIjoiOWUxNzIxNjItYWRhYi00Y2FiLTg4NTktZDRlMzE4YzJkZWY2IiwiaWF0IjoxNzY4MDk0ODE5LCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL3dzLzIwMDgvMDYvaWRlbnRpdHkvY2xhaW1zL3JvbGUiOiJBZG1pbmlzdHJhdG9ycyIsIm5iZiI6MTc2ODA5NDgxOSwiZXhwIjoxNzY4MTgxMjE5LCJpc3MiOiJSUyIsImF1ZCI6IlJTIn0.kEuTWY_7oN5T4sQRsw9-T-86GoN7SOACndxRWcTqLPE","ContentType":"application/json","x-hour-offset":"7","BranchId":"1","Locale":"vi"},"baseURL":"https://tratienlau.nobi.pro","paramsSerializer":{},"method":"put","url":"/api/orders/552","data":"{\"invoice\":{\"type\":1,\"customerId\":949,\"isDiscountPrice\":true,\"relatedCustomerId\":null,\"id\":557,\"code\":\"XB000552\",\"userId\":5,\"couponCode\":null,\"discount\":0,\"createDate\":\"2026-01-11T03:49:47.177479Z\",\"notes\":\"đóng gói 100g tặng 50g trà 800k\",\"reason\":null,\"vat\":0,\"cod\":0,\"posOrderId\":null,\"posSyncDate\":null,\"warehouseId\":1,\"branchId\":1,\"depositAmount\":null,\"shippingFee\":24000,\"shippingFeeX\":24000,\"transferAmount\":null,\"total\":550000,\"insuranceValue\":550000,\"status\":1,\"branchName\":\"Đồ Gỗ Mỹ Nghệ Văn Sáu\",\"isEmpty\":false,\"ecommerceDetails\":[{\"id\":663,\"productId\":40,\"nProductId\":null,\"price\":250000,\"quantity\":1,\"discount\":0,\"isDiscountPrice\":true,\"notes\":null,\"inventory\":-12.499999,\"weight\":1000,\"isCombo\":false,\"product\":{\"id\":40,\"sku\":null,\"unit\":\"Kg\",\"name\":\"Trà búp loại 2\",\"code\":\"BUP2\",\"weight\":1000,\"length\":null,\"width\":null,\"height\":null,\"primaryImage\":null,\"inventories\":[{\"warehouseId\":1,\"inventory\":-12.499999}],\"metas\":[],\"model_id\":null,\"item_id\":null},\"length\":null,\"width\":null,\"height\":null,\"totalAmount\":250000,\"quantityX\":1},{\"id\":664,\"productId\":39,\"nProductId\":null,\"price\":300000,\"quantity\":1,\"discount\":0,\"isDiscountPrice\":true,\"notes\":null,\"inventory\":-29.6,\"weight\":1000,\"isCombo\":false,\"product\":{\"id\":39,\"sku\":null,\"unit\":\"Kg\",\"name\":\"Trà búp loại 1\",\"code\":\"BUP1\",\"weight\":1000,\"length\":null,\"width\":null,\"height\":null,\"primaryImage\":null,\"inventories\":[{\"warehouseId\":1,\"inventory\":-29.6}],\"metas\":[],\"model_id\":null,\"item_id\":null},\"length\":null,\"width\":null,\"height\":null,\"totalAmount\":300000,\"quantityX\":1}],\"returnFee\":0,\"coupons\":[],\"details\":null},\"customer\":null,\"sourceId\":4,\"transporter\":\"ViettelPost\",\"id\":552,\"createDate\":\"2026-01-11T03:49:47.166715Z\",\"campaignId\":2,\"campaignName\":\"Test 1\",\"code\":\"DH000552\",\"invoiceId\":557,\"salerId\":5,\"shop\":null,\"status\":20,\"customerName\":\"Chi Cuong\",\"customerNotes\":\"đóng gói 100g tặng 50g trà 800k\",\"customerPhoneNumber\":\"0988231346\",\"buyerPriceTotal\":550000,\"customerAvatar\":null,\"customerPageScopeId\":\"\",\"deliveringNote\":null,\"totalAmount\":550000,\"discountTotal\":0,\"priceTotal\":550000,\"country\":null,\"wardId\":\"9595431825\",\"provinceId\":\"95\",\"districtId\":\"95954\",\"shippingAddress\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\",\"provinceName\":\"Bạc Liêu\",\"addressLevel4\":null,\"wardName\":\"Phường 1\",\"shippingStatus\":1,\"packageId\":null,\"totalVat\":0,\"transporterId\":1,\"transporterServiceId\":\"VCBO\",\"trackingCode\":null,\"sendTransporterDate\":null,\"expectedDeliveryTime\":null,\"customerReceivedDate\":null,\"isFreeShipping\":true,\"transportType\":0,\"weight\":2000,\"length\":null,\"height\":null,\"width\":null,\"adId\":null,\"conversationId\":null,\"checkingPolicy\":2,\"orderFee\":{\"id\":552,\"discountVoucher\":0,\"discountVoucherPlatform\":0,\"discountShopeeCoin\":0,\"discountWallet\":0,\"shippingFeeSeller\":0,\"shippingFeePlatform\":0,\"originalShippingFee\":0,\"priceExcel\":0,\"transactionFee\":0,\"affiliateCommission\":0,\"platformCommission\":0,\"previousRevenue\":0,\"settlementRevenue\":null,\"tikTokDiscountFee\":0,\"settlementAmount\":0,\"settlementInfo\":null,\"settlementInfoObj\":null,\"salePrice\":526000,\"customerPrice\":550000,\"customerPriceCod\":null},\"orderAddress\":{\"id\":552,\"shippingAddress\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"provinceId\":\"95\",\"districtId\":\"95954\",\"wardId\":\"9595431825\",\"wardName\":\"Phường 1\",\"provinceName\":\"Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\"},\"orderExtra\":{\"id\":552,\"userCrossCheckedId\":null,\"userCrossChecked\":null,\"userConfirmReturnedId\":null,\"userConfirmReturned\":null,\"cancelReason\":null,\"crossCheckedStatus\":null,\"currentWarehouseName\":null,\"numberOfPackages\":null,\"isInfoFromChat\":false,\"unLockDate\":null,\"sendTransporterDate\":null,\"expectedDeliveryTime\":null,\"customerReceivedDate\":null,\"lastUpdateTime\":null,\"cancelTime\":null,\"confirmReturnedDate\":null,\"crossCheckedDate\":null,\"flags\":{},\"flagsStr\":\"{}\",\"sortLine\":null,\"weight\":2000},\"type\":4,\"flags\":{\"isFood\":false,\"isFragile\":false,\"isSealBox\":false,\"noStack\":false,\"arranged\":false,\"bbseco\":false,\"partialDelivery\":false,\"orderServiceAdd\":null},\"transporterName\":\"ViettelPost\",\"isCustomFee\":false,\"sourceName\":\"CSKH Phương\",\"salerName\":\"Trần T Phương\",\"salerPhoneNumber\":\"0936878997\",\"customerBuy\":{\"address\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"fullName\":\"Chi Cuong\",\"phone\":\"0988231346\",\"location\":{\"provinceId\":null,\"districtId\":null,\"wardId\":null,\"wardName\":\"Phường 1\",\"provinceName\":\"Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\"}},\"tags\":[],\"couponIds\":[],\"orderAddressId\":552,\"orderExtraId\":552,\"orderFeeId\":552}"},"request":{}}
"{\"invoice\":{\"type\":1,\"customerId\":949,\"isDiscountPrice\":true,\"relatedCustomerId\":null,\"id\":557,\"code\":\"XB000552\",\"userId\":5,\"couponCode\":null,\"discount\":0,\"createDate\":\"2026-01-11T03:49:47.177479Z\",\"notes\":\"đóng gói 100g tặng 50g trà 800k\",\"reason\":null,\"vat\":0,\"cod\":0,\"posOrderId\":null,\"posSyncDate\":null,\"warehouseId\":1,\"branchId\":1,\"depositAmount\":null,\"shippingFee\":24000,\"shippingFeeX\":24000,\"transferAmount\":null,\"total\":550000,\"insuranceValue\":550000,\"status\":1,\"branchName\":\"Đồ Gỗ Mỹ Nghệ Văn Sáu\",\"isEmpty\":false,\"ecommerceDetails\":[{\"id\":663,\"productId\":40,\"nProductId\":null,\"price\":250000,\"quantity\":1,\"discount\":0,\"isDiscountPrice\":true,\"notes\":null,\"inventory\":-12.499999,\"weight\":1000,\"isCombo\":false,\"product\":{\"id\":40,\"sku\":null,\"unit\":\"Kg\",\"name\":\"Trà búp loại 2\",\"code\":\"BUP2\",\"weight\":1000,\"length\":null,\"width\":null,\"height\":null,\"primaryImage\":null,\"inventories\":[{\"warehouseId\":1,\"inventory\":-12.499999}],\"metas\":[],\"model_id\":null,\"item_id\":null},\"length\":null,\"width\":null,\"height\":null,\"totalAmount\":250000,\"quantityX\":1},{\"id\":664,\"productId\":39,\"nProductId\":null,\"price\":300000,\"quantity\":1,\"discount\":0,\"isDiscountPrice\":true,\"notes\":null,\"inventory\":-29.6,\"weight\":1000,\"isCombo\":false,\"product\":{\"id\":39,\"sku\":null,\"unit\":\"Kg\",\"name\":\"Trà búp loại 1\",\"code\":\"BUP1\",\"weight\":1000,\"length\":null,\"width\":null,\"height\":null,\"primaryImage\":null,\"inventories\":[{\"warehouseId\":1,\"inventory\":-29.6}],\"metas\":[],\"model_id\":null,\"item_id\":null},\"length\":null,\"width\":null,\"height\":null,\"totalAmount\":300000,\"quantityX\":1}],\"returnFee\":0,\"coupons\":[],\"details\":null},\"customer\":null,\"sourceId\":4,\"transporter\":\"ViettelPost\",\"id\":552,\"createDate\":\"2026-01-11T03:49:47.166715Z\",\"campaignId\":2,\"campaignName\":\"Test 1\",\"code\":\"DH000552\",\"invoiceId\":557,\"salerId\":5,\"shop\":null,\"status\":20,\"customerName\":\"Chi Cuong\",\"customerNotes\":\"đóng gói 100g tặng 50g trà 800k\",\"customerPhoneNumber\":\"0988231346\",\"buyerPriceTotal\":550000,\"customerAvatar\":null,\"customerPageScopeId\":\"\",\"deliveringNote\":null,\"totalAmount\":550000,\"discountTotal\":0,\"priceTotal\":550000,\"country\":null,\"wardId\":\"9595431825\",\"provinceId\":\"95\",\"districtId\":\"95954\",\"shippingAddress\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\",\"provinceName\":\"Bạc Liêu\",\"addressLevel4\":null,\"wardName\":\"Phường 1\",\"shippingStatus\":1,\"packageId\":null,\"totalVat\":0,\"transporterId\":1,\"transporterServiceId\":\"VCBO\",\"trackingCode\":null,\"sendTransporterDate\":null,\"expectedDeliveryTime\":null,\"customerReceivedDate\":null,\"isFreeShipping\":true,\"transportType\":0,\"weight\":2000,\"length\":null,\"height\":null,\"width\":null,\"adId\":null,\"conversationId\":null,\"checkingPolicy\":2,\"orderFee\":{\"id\":552,\"discountVoucher\":0,\"discountVoucherPlatform\":0,\"discountShopeeCoin\":0,\"discountWallet\":0,\"shippingFeeSeller\":0,\"shippingFeePlatform\":0,\"originalShippingFee\":0,\"priceExcel\":0,\"transactionFee\":0,\"affiliateCommission\":0,\"platformCommission\":0,\"previousRevenue\":0,\"settlementRevenue\":null,\"tikTokDiscountFee\":0,\"settlementAmount\":0,\"settlementInfo\":null,\"settlementInfoObj\":null,\"salePrice\":526000,\"customerPrice\":550000,\"customerPriceCod\":null},\"orderAddress\":{\"id\":552,\"shippingAddress\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"provinceId\":\"95\",\"districtId\":\"95954\",\"wardId\":\"9595431825\",\"wardName\":\"Phường 1\",\"provinceName\":\"Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\"},\"orderExtra\":{\"id\":552,\"userCrossCheckedId\":null,\"userCrossChecked\":null,\"userConfirmReturnedId\":null,\"userConfirmReturned\":null,\"cancelReason\":null,\"crossCheckedStatus\":null,\"currentWarehouseName\":null,\"numberOfPackages\":null,\"isInfoFromChat\":false,\"unLockDate\":null,\"sendTransporterDate\":null,\"expectedDeliveryTime\":null,\"customerReceivedDate\":null,\"lastUpdateTime\":null,\"cancelTime\":null,\"confirmReturnedDate\":null,\"crossCheckedDate\":null,\"flags\":{},\"flagsStr\":\"{}\",\"sortLine\":null,\"weight\":2000},\"type\":4,\"flags\":{\"isFood\":false,\"isFragile\":false,\"isSealBox\":false,\"noStack\":false,\"arranged\":false,\"bbseco\":false,\"partialDelivery\":false,\"orderServiceAdd\":null},\"transporterName\":\"ViettelPost\",\"isCustomFee\":false,\"sourceName\":\"CSKH Phương\",\"salerName\":\"Trần T Phương\",\"salerPhoneNumber\":\"0936878997\",\"customerBuy\":{\"address\":\"Đường nguyễn tất thành, P.1, TP.Bạc Liêu, T.Bạc Liêu\",\"fullName\":\"Chi Cuong\",\"phone\":\"0988231346\",\"location\":{\"provinceId\":null,\"districtId\":null,\"wardId\":null,\"wardName\":\"Phường 1\",\"provinceName\":\"Bạc Liêu\",\"districtName\":\"Thành phố Bạc Liêu\"}},\"tags\":[],\"couponIds\":[],\"orderAddressId\":552,\"orderExtraId\":552,\"orderFeeId\":552}"