目录
1 Himall商城BillingApplication
1.1 分页获取待结算订单列表
1.2 根据订单ID获取结算详情(传入shopId防止跨店铺调用)
1.3 根据订单ID获取结算详情(传入shopId防止跨店铺调用)
public static List
{
QueryPageModel
var models = _iBillingService.GetPendingSettlementOrdersNoPage(query);
var result = Mapper.Map, List
var settlementCycle = SiteSettingApplication.GetSiteSettings().WeekSettlement;
var end = _iBillingService.GetLastSettlementTime();
var CurrentSettlementCycle = GetDateBilingTime(settlementCycle, end, DateTime.Now); //节省一次查询
foreach (var m in result)
{
m.DistributorCommission = m.DistributorCommission - m.DistributorCommissionReturn;
m.PlatCommission = m.PlatCommission - m.PlatCommissionReturn;
if (m.OrderFinshTime < CurrentSettlementCycle.StartTime) //如果订单完成时间不在当前结算周期之内
{
var cycle = GetDateBilingTime(settlementCycle, end, m.OrderFinshTime);
m.SettlementCycle = "此订单为" + cycle.StartTime.ToString("yyyy-MM-dd HH:mm:ss") + "至" + cycle.EndTime.ToString("yyyy-MM-dd HH:mm:ss") + "周期内订单";
}
}
return result;
}
public static OrderSettlementDetail GetPendingOrderSettlementDetail(long orderId, long? shopId = null)
{
var model = _iBillingService.GetPendingSettlementOrderDetail(orderId);
if (shopId.HasValue && shopId.Value != model.ShopId)
{
throw new Core.HimallException("找不到该店铺的结算详情");
}
var order = OrderApplication.GetOrder(orderId);
var refund = RefundApplication.GetOrderRefundList(orderId);
OrderSettlementDetail detail = new OrderSettlementDetail();
detail.Freight = model.FreightAmount;
detail.RefundAmount = model.RefundAmount;
detail.DistributorCommission = model.DistributorCommission;
detail.DistributorCommissionReturn = model.DistributorCommissionReturn;
detail.PlatCommission = model.PlatCommission;
detail.PlatCommissionReturn = model.PlatCommissionReturn;
detail.ProductsTotal = model.ProductsAmount;
detail.OrderPayTime = order.PayDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
if (refund != null && refund.Count > 0)
{
detail.OrderRefundTime = refund.FirstOrDefault().ManagerConfirmDate.ToString("yyyy-MM-dd HH:mm:ss");
}
return detail;
}
public static OrderSettlementDetail GetOrderSettlementDetail(long orderId, long? shopId = null)
{
var model = _iBillingService.GetSettlementOrderDetail(orderId);
if (shopId.HasValue && shopId.Value != model.ShopId)
{
throw new Core.HimallException("找不到该店铺的结算详情");
}
var order = OrderApplication.GetOrder(orderId);
var refund = RefundApplication.GetOrderRefundList(orderId);
OrderSettlementDetail detail = new OrderSettlementDetail();
detail.Freight = model.FreightAmount;
detail.RefundAmount = model.RefundTotalAmount;
detail.DistributorCommission = model.BrokerageAmount;
detail.DistributorCommissionReturn = model.ReturnBrokerageAmount;
detail.PlatCommission = model.CommissionAmount;
detail.PlatCommissionReturn = model.RefundCommisAmount;
detail.ProductsTotal = model.ProductActualPaidAmount;
detail.OrderPayTime = order.PayDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
if (refund != null && refund.Count > 0)
{
detail.OrderRefundTime = refund.FirstOrDefault().ManagerConfirmDate.ToString("yyyy-MM-dd HH:mm:ss");
}
return detail;
}