| | |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.SquareCabin; |
| | | using WIDESEA_ISquareCabinRepository; |
| | | using WIDESEA_ISquareCabinServices; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.SquareCabin; |
| | | using WIDESEA_SquareCabinRepository; |
| | | using static WIDESEA_DTO.SquareCabin.OrderDto; |
| | | using static WIDESEA_DTO.SquareCabin.TowcsDto; |
| | | |
| | | namespace WIDESEA_SquareCabinServices |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// wcsåä¼ ç»æ |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <returns></returns> |
| | | public ApiResponse<Dt_Inventory> OrderFeedback(EdiOrderCallbackRequest request) |
| | | { |
| | | try |
| | | { |
| | | if (request == null || request.details == null || !request.details.Any()) |
| | | { |
| | | return new ApiResponse<Dt_Inventory> { code ="500",msg = "请æ±åæ°æ æ" }; |
| | | } |
| | | BaseDal.Db.Ado.BeginTran();//å¼å¯äºå¡ |
| | | foreach (var detail in request.details) |
| | | { |
| | | // å
æ¥åºåæ¯å¦åå¨ï¼æç
§äº§åç¼å·åæ¹æ¬¡æ¥å¯»æ¾ï¼ |
| | | var entity = BaseDal.Db.Queryable<Dt_Inventory>() |
| | | .First(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo); |
| | | //å°éåä¸çæ°éè¿è¡ç´¯å |
| | | // å®å
¨è½¬æ¢ |
| | | |
| | | //æ£å¸¸åºå
¥åº |
| | | decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? q : 0) ?? 0; |
| | | //çç¹çäº |
| | | decimal diffQty = detail.stocktakingDetails?.Sum(x => Convert.ToDecimal(x.differenceQuantity)) ?? 0; |
| | | if (entity == null) |
| | | { |
| | | // 妿ä¸åå¨ï¼æ°å»ºä¸æ¡ |
| | | entity = new Dt_Inventory |
| | | { |
| | | Goods_no = detail.productCode ?? detail.productName, |
| | | Reservoirarea = "é»è®¤åºåº", |
| | | Batch_num = detail.batchNo, |
| | | //ä¸å¡åºå |
| | | Business_qty = 0, |
| | | //å®é
åºå |
| | | Actual_qty = 0 |
| | | }; |
| | | } |
| | | |
| | | switch (request.orderType) |
| | | { |
| | | case "1": // å
¥åº |
| | | entity.Business_qty += orderQty; |
| | | entity.Actual_qty += orderQty; |
| | | break; |
| | | |
| | | case "2": // åºåº |
| | | entity.Business_qty -= orderQty; |
| | | entity.Actual_qty -= orderQty; |
| | | if (entity.Business_qty < 0) entity.Business_qty = 0; // å¯éï¼é²æ¢è´æ° |
| | | if (entity.Actual_qty < 0) entity.Actual_qty = 0; |
| | | break; |
| | | |
| | | case "3": // çç¹ |
| | | if (detail.stocktakingDetails != null && detail.stocktakingDetails.Any()) |
| | | { |
| | | foreach (var stock in detail.stocktakingDetails) |
| | | { |
| | | //æ¯æ¬¡é½åªæ¿ä¸æ¡æç»ä¸çæ°é |
| | | decimal diff = Convert.ToDecimal(stock.differenceQuantity); |
| | | if (stock.IsProfit == "1") // çç |
| | | { |
| | | entity.Business_qty += diff;//妿ççäºå¤äºï¼å°±å°ä¸å¡æ°é+ï¼çäºåç¸å |
| | | } |
| | | else // çäº |
| | | { |
| | | entity.Business_qty -= diff; |
| | | //if (entity.Business_qty < 0) entity.Business_qty = 0; |
| | | } |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // ä¿åæ°æ® |
| | | if (entity.Id == 0) // æ°å»º |
| | | BaseDal.Db.Insertable(entity).ExecuteCommand(); |
| | | else // æ´æ° |
| | | BaseDal.Db.Updateable(entity).ExecuteCommand(); |
| | | } |
| | | BaseDal.Db.Ado.CommitTran(); // æäº¤äºå¡ |
| | | return new ApiResponse<Dt_Inventory> {code = "0", msg = "æå" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | BaseDal.Db.Ado.RollbackTran();//åæ»äºå¡ |
| | | return new ApiResponse<Dt_Inventory> { code = "500", msg = ex.Message }; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¨éå¼å¸¸ä¿¡æ¯ç»ä¸æ¸¸ç³»ç»1.å
¥åºåæ¥å£ï¼2.å
¥åºåæ¥å®ææ¥å£ï¼3.åºåºåæ¥å£ï¼4.åºåºæ¥å®ææ¥å£ï¼5.è¯ååºç¡ä¿¡æ¯åæ¥æ¥å£ï¼6.ä¾åºåä¿¡æ¯æ¥å£ï¼7.客æ·ä¿¡æ¯æ¥å£ï¼8.åºå |
| | | /// </summary> |