11 changed files with 513 additions and 17 deletions
@ -0,0 +1,26 @@ |
|||
using BBWY.Client.Models; |
|||
using BBWY.Common.Http; |
|||
using BBWY.Common.Models; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Net.Http; |
|||
|
|||
namespace BBWY.Client.APIServices |
|||
{ |
|||
public class BillCorrectionService : BaseApiService, IDenpendency |
|||
{ |
|||
public BillCorrectionService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) |
|||
{ |
|||
} |
|||
|
|||
public ApiResponse<IList<BillCorrectionOrderResponse>> GetBillCorrectionOrderList(IList<long> shopIds, DateTime startTime, DateTime endTime) |
|||
{ |
|||
return SendRequest<IList<BillCorrectionOrderResponse>>(globalContext.BBYWApiHost, "api/billCorrection/GetBillCorrectionOrderList", new |
|||
{ |
|||
shopIds, |
|||
startTime, |
|||
endTime |
|||
}, null, HttpMethod.Post); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,74 @@ |
|||
using System; |
|||
|
|||
namespace BBWY.Client.Models |
|||
{ |
|||
public class BillCorrectionOrderResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 订单号
|
|||
/// </summary>
|
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单状态
|
|||
/// </summary>
|
|||
public OrderState? OrderState { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单开始日期
|
|||
/// </summary>
|
|||
public DateTime? StartTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货类型
|
|||
/// </summary>
|
|||
public StorageType? StorageType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 销售运费
|
|||
/// </summary>
|
|||
public decimal DeliveryExpressFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// Sku成本(商品成本)
|
|||
/// </summary>
|
|||
public decimal SkuAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 采购运费
|
|||
/// </summary>
|
|||
public decimal PurchaseFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 头程运费
|
|||
/// </summary>
|
|||
public decimal FirstFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 入仓操作费
|
|||
/// </summary>
|
|||
public decimal InStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 出仓操作费
|
|||
/// </summary>
|
|||
public decimal OutStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 耗材费
|
|||
/// </summary>
|
|||
public decimal ConsumableAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 仓储费
|
|||
/// </summary>
|
|||
public decimal StorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 售后费用
|
|||
/// </summary>
|
|||
public decimal AfterTotalCost { get; set; } |
|||
|
|||
public string WaybillNo { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,88 @@ |
|||
using System; |
|||
|
|||
namespace BBWY.Client.Models |
|||
{ |
|||
public class BillCorrectionOrder : NotifyObject |
|||
{ |
|||
private string changedContent; |
|||
|
|||
private decimal newDeliveryExpressFreight; |
|||
|
|||
/// <summary>
|
|||
/// 订单号
|
|||
/// </summary>
|
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单状态
|
|||
/// </summary>
|
|||
public OrderState? OrderState { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单开始日期
|
|||
/// </summary>
|
|||
public DateTime? StartTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货类型
|
|||
/// </summary>
|
|||
public StorageType? StorageType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 销售运费
|
|||
/// </summary>
|
|||
public decimal DeliveryExpressFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// Sku成本(商品成本)
|
|||
/// </summary>
|
|||
public decimal SkuAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 采购运费
|
|||
/// </summary>
|
|||
public decimal PurchaseFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 头程运费
|
|||
/// </summary>
|
|||
public decimal FirstFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 入仓操作费
|
|||
/// </summary>
|
|||
public decimal InStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 出仓操作费
|
|||
/// </summary>
|
|||
public decimal OutStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 耗材费
|
|||
/// </summary>
|
|||
public decimal ConsumableAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 仓储费
|
|||
/// </summary>
|
|||
public decimal StorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 售后费用
|
|||
/// </summary>
|
|||
public decimal AfterTotalCost { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 矫正内容
|
|||
/// </summary>
|
|||
public string ChangedContent { get => changedContent; set { Set(ref changedContent, value); } } |
|||
|
|||
/// <summary>
|
|||
/// 新销售运费
|
|||
/// </summary>
|
|||
public decimal NewDeliveryExpressFreight { get => newDeliveryExpressFreight; set { Set(ref newDeliveryExpressFreight, value); } } |
|||
|
|||
public string WaybillNo { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
using BBWY.Server.Business; |
|||
using BBWY.Server.Model.Dto; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace BBWY.Server.API.Controllers |
|||
{ |
|||
public class BillCorrectionController : BaseApiController |
|||
{ |
|||
private BillCorrectionBusiness billCorrectionBusiness; |
|||
public BillCorrectionController(IHttpContextAccessor httpContextAccessor, BillCorrectionBusiness billCorrectionBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.billCorrectionBusiness = billCorrectionBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取待矫正费用订单
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public IList<BillCorrectionOrderResponse> GetBillCorrectionOrderList([FromBody] QueryBillCorrectionOrderRequest request) |
|||
{ |
|||
return billCorrectionBusiness.GetBillCorrectionOrderList(request); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,77 @@ |
|||
using BBWY.Common.Models; |
|||
using BBWY.Server.Model.Db; |
|||
using BBWY.Server.Model.Dto; |
|||
using System.Collections.Generic; |
|||
using Yitter.IdGenerator; |
|||
using System.Linq; |
|||
|
|||
namespace BBWY.Server.Business |
|||
{ |
|||
public class BillCorrectionBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
public BillCorrectionBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public IList<BillCorrectionOrderResponse> GetBillCorrectionOrderList(QueryBillCorrectionOrderRequest request) |
|||
{ |
|||
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1); |
|||
var orderList = fsql.Select<Order>() |
|||
.Where(o => request.ShopIds.Contains(o.ShopId) && o.StartTime >= request.StartTime && o.StartTime <= request.EndTime) |
|||
.OrderBy(o => o.StartTime) |
|||
.ToList(o => new BillCorrectionOrderResponse |
|||
{ |
|||
OrderId = o.Id, |
|||
StartTime = o.StartTime, |
|||
StorageType = o.StorageType, |
|||
OrderState = o.OrderState, |
|||
WaybillNo = o.WaybillNo |
|||
}); |
|||
|
|||
var orderIds = orderList.Select(o => o.OrderId).ToList(); |
|||
|
|||
var orderCostDetailList = fsql.Select<OrderCostDetail>() |
|||
.Where(ocd => orderIds.Contains(ocd.OrderId)) |
|||
.GroupBy(ocd => ocd.OrderId) |
|||
.ToList(g => new |
|||
{ |
|||
OrderId = g.Key, |
|||
DeliveryExpressFreight = g.Sum(g.Value.DeliveryExpressFreight), |
|||
SkuAmount = g.Sum(g.Value.SkuAmount), |
|||
PurchaseFreight = g.Sum(g.Value.PurchaseFreight), |
|||
FirstFreight = g.Sum(g.Value.FirstFreight), |
|||
InStorageAmount = g.Sum(g.Value.InStorageAmount), |
|||
OutStorageAmount = g.Sum(g.Value.OutStorageAmount), |
|||
ConsumableAmount = g.Sum(g.Value.ConsumableAmount), |
|||
StorageAmount = g.Sum(g.Value.StorageAmount) |
|||
}); |
|||
|
|||
var afterOrderList = fsql.Select<AfterSaleOrder>() |
|||
.Where(aso => orderIds.Contains(aso.OrderId)) |
|||
.GroupBy(aso => aso.OrderId) |
|||
.ToList(g => new |
|||
{ |
|||
OrderId = g.Key, |
|||
AfterTotalCost = g.Sum(g.Value.AfterTotalCost) |
|||
}); |
|||
|
|||
foreach (var order in orderList) |
|||
{ |
|||
var orderCostDetail = orderCostDetailList.FirstOrDefault(ocd => ocd.OrderId == order.OrderId); |
|||
var afterOrder = afterOrderList.FirstOrDefault(aso => aso.OrderId == order.OrderId); |
|||
|
|||
order.DeliveryExpressFreight = orderCostDetail?.DeliveryExpressFreight ?? 0M; |
|||
order.SkuAmount = orderCostDetail?.SkuAmount ?? 0M; |
|||
order.PurchaseFreight = orderCostDetail?.PurchaseFreight ?? 0M; |
|||
order.FirstFreight = orderCostDetail?.FirstFreight ?? 0M; |
|||
order.InStorageAmount = orderCostDetail?.InStorageAmount ?? 0M; |
|||
order.OutStorageAmount = orderCostDetail?.OutStorageAmount ?? 0M; |
|||
order.ConsumableAmount = orderCostDetail?.ConsumableAmount ?? 0M; |
|||
order.StorageAmount = orderCostDetail?.StorageAmount ?? 0M; |
|||
order.AfterTotalCost = afterOrder?.AfterTotalCost ?? 0M; |
|||
} |
|||
return orderList; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace BBWY.Server.Model.Dto |
|||
{ |
|||
public class QueryBillCorrectionOrderRequest |
|||
{ |
|||
public IList<long> ShopIds { get; set; } |
|||
|
|||
public DateTime StartTime { get; set; } |
|||
|
|||
public DateTime EndTime { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,74 @@ |
|||
using System; |
|||
|
|||
namespace BBWY.Server.Model.Dto |
|||
{ |
|||
public class BillCorrectionOrderResponse |
|||
{ |
|||
/// <summary>
|
|||
/// 订单号
|
|||
/// </summary>
|
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单状态
|
|||
/// </summary>
|
|||
public Enums.OrderState? OrderState { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 订单开始日期
|
|||
/// </summary>
|
|||
public DateTime? StartTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货类型
|
|||
/// </summary>
|
|||
public Enums.StorageType? StorageType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 销售运费
|
|||
/// </summary>
|
|||
public decimal DeliveryExpressFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// Sku成本(商品成本)
|
|||
/// </summary>
|
|||
public decimal SkuAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 采购运费
|
|||
/// </summary>
|
|||
public decimal PurchaseFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 头程运费
|
|||
/// </summary>
|
|||
public decimal FirstFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 入仓操作费
|
|||
/// </summary>
|
|||
public decimal InStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 出仓操作费
|
|||
/// </summary>
|
|||
public decimal OutStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 耗材费
|
|||
/// </summary>
|
|||
public decimal ConsumableAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 仓储费
|
|||
/// </summary>
|
|||
public decimal StorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 售后费用
|
|||
/// </summary>
|
|||
public decimal AfterTotalCost { get; set; } |
|||
|
|||
public string WaybillNo { get; set; } |
|||
} |
|||
} |
Loading…
Reference in new issue