From 04d9e37123d0a0e841a1f4136dd0910cb5aab932 Mon Sep 17 00:00:00 2001 From: chfei Date: Thu, 8 Oct 2026 15:58:19 +0800 Subject: [PATCH] =?UTF-8?q?BuyerOrderInfo=20=E5=A2=9E=E5=8A=A0id=20?= =?UTF-8?q?=E5=92=8C=E9=80=80=E6=AC=BE=20id=20=EF=BC=8C=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=20=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B9=B0=E6=89=8B=E9=80=80=E6=AC=BE=E6=88=90=E5=8A=9Fapi?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E9=80=80=E6=AC=BE=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/WX/BuyerController.cs | 40 ++++++++++++++ KJD_WebService/KJD_WebService.csproj | 2 + .../Model/WxModel/ShopRevenueStatistics.cs | 7 ++- .../Shops/ShopOrderDetailResponse.cs | 1 + KJD_WebService/Services/Buyer/BuyerService.cs | 52 +++++++++++++++++++ .../Shops/ShopRevenueStatisticsService.cs | 6 +++ KJD_WebService/Services/Shops/ShopService.cs | 15 +++++- 7 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 KJD_WebService/Controllers/WX/BuyerController.cs create mode 100644 KJD_WebService/Services/Buyer/BuyerService.cs diff --git a/KJD_WebService/Controllers/WX/BuyerController.cs b/KJD_WebService/Controllers/WX/BuyerController.cs new file mode 100644 index 0000000..ac3133f --- /dev/null +++ b/KJD_WebService/Controllers/WX/BuyerController.cs @@ -0,0 +1,40 @@ +using KJD_Web.Services.Buyer; +using Store.Framework.Base; +using Store.Framework.Dtos; +using Store.Framework.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace KJD_Web.Controllers.WX; + +[RoutePrefix("wxxd_buyer")] +[Route("{action}")] + +public class BuyerController : ApiControllerBase +{ + private readonly BuyerService _buyerService; + + public BuyerController(BuyerService buyerService) + { + _buyerService = buyerService; + } + [HttpPost] + public IHttpActionResult UpdateBuyerRefundStatsu(SignRequestBase request, long id) + { + ApiResultBase ret; + try + { + var v = _buyerService.UpdateBuyerRefundStatus(request.UserName, id); + ret = ApiResult.Success(v); + } + catch (Exception ex) + { + ret = ApiResult.Fail("更新失败"); + } + return Ok(ret); + } + +} \ No newline at end of file diff --git a/KJD_WebService/KJD_WebService.csproj b/KJD_WebService/KJD_WebService.csproj index ec8511b..13dcd29 100644 --- a/KJD_WebService/KJD_WebService.csproj +++ b/KJD_WebService/KJD_WebService.csproj @@ -193,6 +193,7 @@ + @@ -273,6 +274,7 @@ + diff --git a/KJD_WebService/Model/WxModel/ShopRevenueStatistics.cs b/KJD_WebService/Model/WxModel/ShopRevenueStatistics.cs index 8deef6c..718c014 100644 --- a/KJD_WebService/Model/WxModel/ShopRevenueStatistics.cs +++ b/KJD_WebService/Model/WxModel/ShopRevenueStatistics.cs @@ -147,6 +147,11 @@ public class ShopRevenueStatistics /// public class BuyerOrderInfo : StatisticsBase { + public long Id { get; set; } + /// + /// 采购类型 + /// + public PurchaseType PurchaseType { get; set; } /// /// 买手订单 /// @@ -163,7 +168,7 @@ public class ShopRevenueStatistics - + public long RefundId { get; set; } /// /// 退款金额(分) /// diff --git a/KJD_WebService/Responses/Shops/ShopOrderDetailResponse.cs b/KJD_WebService/Responses/Shops/ShopOrderDetailResponse.cs index 3aa2edd..31b2a81 100644 --- a/KJD_WebService/Responses/Shops/ShopOrderDetailResponse.cs +++ b/KJD_WebService/Responses/Shops/ShopOrderDetailResponse.cs @@ -13,6 +13,7 @@ namespace KJD_Web.Responses.Shops; /// public class ShopOrderDetailResponse { + public long Id { get; set; } /// /// 店铺ID /// diff --git a/KJD_WebService/Services/Buyer/BuyerService.cs b/KJD_WebService/Services/Buyer/BuyerService.cs new file mode 100644 index 0000000..f30b8a8 --- /dev/null +++ b/KJD_WebService/Services/Buyer/BuyerService.cs @@ -0,0 +1,52 @@ +using KJD_Web.Services.Shops; +using MAX.Core.DependencyInjection; +using MAX.Core.Logger; +using Store.Contracts.Order.Entitys; +using Store.Contracts.User.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace KJD_Web.Services.Buyer; + +public class BuyerService : ITransientDependency +{ + private readonly IFreeSql _freeSql; + private readonly ILoggerFacade _logger; + private readonly IUserService _userService; + private readonly ShopService _shopService; + + public BuyerService(IFreeSql freeSql, ILoggerFacade logger, ShopService shopService) + { + _freeSql = freeSql; + _logger = logger; + _shopService = shopService; + } + /// + /// 修改买手退款状态 + /// 更改为退款成功 + /// + + public bool UpdateBuyerRefundStatus(string userName, long id) + { + var item = _freeSql.Select() + .Where(a => a.Id == id) + .First(); + if (item == null) return false; + + var shopId = _freeSql.Select() + .Where(a => a.OrderId == item.WxOrderId) + .ToOne(a => a.ShopId); + var ret = _shopService.IsShopOwnedByUser(shopId, userName); + if (ret == true) + { + var affrows = _freeSql.Update() + .Set(a => a.StatusText, "退款成功") + .Where(a => a.Id == id) + .ExecuteAffrows(); + return affrows == 1; + } + return false; + } +} \ No newline at end of file diff --git a/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs b/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs index 91636b7..b3facab 100644 --- a/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs +++ b/KJD_WebService/Services/Shops/ShopRevenueStatisticsService.cs @@ -532,6 +532,8 @@ public class ShopRevenueStatisticsService : ITransientDependency .OrderBy(a => a.Id) // .ToList(a => new BuyerOrderInfo { + Id = a.Id, + PurchaseType = PurchaseType.FromWarehouse, OrderId = a.OrderNo, SkuId = a.OrderSkuId, OutOrderSn = a.OutOrderNo, @@ -553,6 +555,8 @@ public class ShopRevenueStatisticsService : ITransientDependency .Where(a => batch.Contains(a.WxOrderId)) .ToList(a => new BuyerOrderInfo { + Id = a.Id, + PurchaseType = PurchaseType.DirectPurchase, OrderId = a.WxOrderId, SkuId = a.WxSkuId, OutOrderSn = a.OrderSn, @@ -587,6 +591,7 @@ public class ShopRevenueStatisticsService : ITransientDependency .OrderBy(a => a.Id) .ToList(a => new BuyerOrderInfo { + RefundId = a.Id, OrderId = a.WxOrderId, SkuId = a.WxSkuId, OutOrderSn = a.OrderSn, @@ -605,6 +610,7 @@ public class ShopRevenueStatisticsService : ITransientDependency var buyerOrder = o.BuyerOrders.FirstOrDefault(a => a.OutOrderSn == r.OutOrderSn); if (buyerOrder != null)//补充退款信息 { + buyerOrder.RefundId = r.RefundId; buyerOrder.RefundAmount = r.RefundAmount; buyerOrder.RefundStatusText = r.RefundStatusText; } diff --git a/KJD_WebService/Services/Shops/ShopService.cs b/KJD_WebService/Services/Shops/ShopService.cs index 4349b63..6184f33 100644 --- a/KJD_WebService/Services/Shops/ShopService.cs +++ b/KJD_WebService/Services/Shops/ShopService.cs @@ -1,5 +1,6 @@ using MAX.Core.DependencyInjection; using MAX.Core.Logger; +using Org.BouncyCastle.Utilities; using Store.Contracts.Shops; using Store.Contracts.User.Interfaces; using System; @@ -25,7 +26,17 @@ public class ShopService : ITransientDependency { return _freeSql.Select().Count(); } - + /// + /// 当前商铺是否属于当前用户 + /// + /// + /// + /// + public bool IsShopOwnedByUser(long shopId, string userName) + { + var shopIds = GetShopIds(userName); + return shopIds.Contains(shopId); + } /// /// 修改商铺永不过期 /// @@ -47,7 +58,7 @@ public class ShopService : ITransientDependency public List GetShops(string userName) { return _freeSql.Select() - .Where(a => a.UserName == userName) + .Where(a => a.UserName == userName || a.SubUserName.Contains(userName)) .ToList(); }