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();
}