From 9afa97b18406835408ce30be6449258d40429947 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Wed, 5 Jul 2023 20:41:15 +0800 Subject: [PATCH] 1 --- BBWYB.Client/APIServices/TestApiService.cs | 25 ++++++++++++++ .../Controllers/OrderController.cs | 10 ++++++ BBWYB.Server.Business/Order/OrderBusiness.cs | 33 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 BBWYB.Client/APIServices/TestApiService.cs diff --git a/BBWYB.Client/APIServices/TestApiService.cs b/BBWYB.Client/APIServices/TestApiService.cs new file mode 100644 index 0000000..8df625b --- /dev/null +++ b/BBWYB.Client/APIServices/TestApiService.cs @@ -0,0 +1,25 @@ +using BBWYB.Common.Http; +using BBWYB.Common.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BBWYB.Client.APIServices +{ + public class TestApiService : BaseApiService, IDenpendency + { + public TestApiService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) + { + } + + public ApiResponse BatchManualSign() + { + return SendRequest(globalContext.BBWYApiHost, "Api/PurchaseOrder/BatchManualSign", new + { + wayBillNoList = new string[] { "ceshi123456" } + }, null, System.Net.Http.HttpMethod.Post); + } + } +} diff --git a/BBWYB.Server.API/Controllers/OrderController.cs b/BBWYB.Server.API/Controllers/OrderController.cs index fcb1178..eb83425 100644 --- a/BBWYB.Server.API/Controllers/OrderController.cs +++ b/BBWYB.Server.API/Controllers/OrderController.cs @@ -114,6 +114,16 @@ namespace BBWYB.Server.API.Controllers orderBusiness.CheckSku(request); } + /// + /// 核算订单 + /// + /// + [HttpPost("{orderId}")] + public void CheckComputationOrder([FromRoute]string orderId) + { + orderBusiness.CheckComputationOrder(orderId); + } + /// /// 齐库推送打包费 /// diff --git a/BBWYB.Server.Business/Order/OrderBusiness.cs b/BBWYB.Server.Business/Order/OrderBusiness.cs index c5d4530..b89c2b6 100644 --- a/BBWYB.Server.Business/Order/OrderBusiness.cs +++ b/BBWYB.Server.Business/Order/OrderBusiness.cs @@ -542,5 +542,38 @@ namespace BBWYB.Server.Business updateOrder?.ExecuteAffrows(); }); } + + public void CheckComputationOrder(string orderId) + { + var order = fsql.Select(orderId).ToOne(); + if (order == null) + throw new BusinessException("未查询到订单"); + if (order.OrderState != Enums.OrderState.待核算) + throw new BusinessException("订单状态不正确,只有待核算的订单才允许核算"); + var orderCost = fsql.Select(orderId).ToOne(); + if (orderCost == null) + throw new BusinessException("未查询到订单成本"); + if (Math.Abs(orderCost.Profit ?? 0) > 1M) + throw new BusinessException("订单利润绝对值不能大于1"); + + fsql.Update(orderId).Set(o => o.OrderState, Enums.OrderState.已完成).ExecuteAffrows(); + SendPurchaseOrderStateToC(orderId, Enums.OrderState.已完成); + } + + private void SendPurchaseOrderStateToC(string orderId, Enums.OrderState orderState) + { + try + { + restApiService.SendRequest("https://bbwy.qiyue666.com", "api/BatchPurchase/UpdatePurchaseOrderState", new + { + OrderId = orderId, + PurchaseOrderState = orderState + }, null, HttpMethod.Post); + } + catch + { + + } + } } }