Commit b3beabf2 authored by 吴春's avatar 吴春

提交收益核算手续费

parent 93e212e0
...@@ -14,7 +14,7 @@ namespace Mall.Model.Query ...@@ -14,7 +14,7 @@ namespace Mall.Model.Query
[DB(ConnectionName = "DefaultConnection")] [DB(ConnectionName = "DefaultConnection")]
public class OrderStatistics_Query public class OrderStatistics_Query
{ {
public string Ids { get; set; }
public int Id { get; set; } public int Id { get; set; }
public int OrderId { get; set; } public int OrderId { get; set; }
...@@ -323,7 +323,10 @@ namespace Mall.Model.Query ...@@ -323,7 +323,10 @@ namespace Mall.Model.Query
/// </summary> /// </summary>
public decimal ServiceCharge { get; set; } public decimal ServiceCharge { get; set; }
/// <summary>
/// 订单手续费
/// </summary>
public decimal ReturnServiceCharge { get; set; }
/// <summary> /// <summary>
/// 保险收入 /// 保险收入
/// </summary> /// </summary>
......
...@@ -185,6 +185,30 @@ namespace Mall.Module.MarketingCenter ...@@ -185,6 +185,30 @@ namespace Mall.Module.MarketingCenter
return list; return list;
} }
/// <summary>
/// 售后订单
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<OrderStatistics_Query> GetFXAllAftersaleOrderProfitLossList(OrderStatistics_Query dmodel)
{
var list = orderRepository.GetFXAllAftersaleOrderProfitLossList(dmodel);
return list;
}
/// <summary>
/// 取消订单
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<OrderStatistics_Query> GetFXAllCancelOrderProfitLossList(OrderStatistics_Query dmodel)
{
var list = orderRepository.GetFXAllCancelOrderProfitLossList(dmodel);
return list;
}
public List<RB_Goods_OrderCommission_Extend> GetByOrderDetailId(RB_Goods_OrderCommission_Extend model) public List<RB_Goods_OrderCommission_Extend> GetByOrderDetailId(RB_Goods_OrderCommission_Extend model)
{ {
......
...@@ -989,8 +989,8 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id ...@@ -989,8 +989,8 @@ LEFT JOIN rb_member_user as c on b.UserId=c.Id
} }
if (dmodel.OrderStatus == 1 || dmodel.OrderStatus == 0) if (dmodel.OrderStatus == 1 || dmodel.OrderStatus == 0)
{ {
where += $" and (a.OrderStatus in(2,3,4,5,6) or (a.OrderStatus=7 and a.PaymentTime is not NULL and a.CancelTime is not NULL and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(a.CancelTime,'%Y-%m-%d' ) ) )"; where += $" and (a.OrderStatus in(2,3,4,5,6) or (a.OrderStatus=7 and a.PaymentTime is not NULL and a.CancelTime is not NULL and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(a.CancelTime,'%Y-%m-%d' ) ) )";
payMemerNumWhere = $"and (OrderStatus in(2,3,4,5,6) or (OrderStatus=7 and PaymentTime is not NULL and CancelTime is not NULL and DATE_FORMAT(PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(CancelTime,'%Y-%m-%d' ) ) ) "; payMemerNumWhere = $"and (OrderStatus in(2,3,4,5,6) or (OrderStatus=7 and PaymentTime is not NULL and CancelTime is not NULL and DATE_FORMAT(PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(CancelTime,'%Y-%m-%d' ) ) ) ";
} }
else if (dmodel.OrderStatus == 2) else if (dmodel.OrderStatus == 2)
{ {
...@@ -1065,7 +1065,7 @@ as t GROUP BY t.CreateDate desc"; ...@@ -1065,7 +1065,7 @@ as t GROUP BY t.CreateDate desc";
/// <returns></returns> /// <returns></returns>
public List<RB_Goods_Order_Extend> GetOrderByUserIds(DataStatistics_Query dmodel) public List<RB_Goods_Order_Extend> GetOrderByUserIds(DataStatistics_Query dmodel)
{ {
string payMemerNumWhere = " where 1=1 "; string payMemerNumWhere = " where 1=1 ";
if (dmodel.TenantId > 0) if (dmodel.TenantId > 0)
{ {
...@@ -1473,35 +1473,163 @@ GROUP BY b.Id order by b.Id asc"; ...@@ -1473,35 +1473,163 @@ GROUP BY b.Id order by b.Id asc";
} }
} }
string sql = $@" SELECT a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney+IFNULL(b.InsuranceMoney,0)) as AllPrice ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,oa.RefundActual,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
from rb_goods_orderdetail as b
LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
LEFT JOIN rb_member_user as muser on muser.id=b.CompanyId
left join rb_goods_orderaftersale oa on b.ID= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where}
GROUP BY b.Id order by b.Id asc";
return Get<OrderStatistics_Query>(sql, parameters).ToList();
}
/// <summary>
/// 取消订单
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<OrderStatistics_Query> GetFXAllCancelOrderProfitLossList(OrderStatistics_Query dmodel)
{
string where = "where 1=1 and (a.OrderStatus=7 and a.PaymentTime is not NULL and a.CancelTime is not NULL and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(a.CancelTime,'%Y-%m-%d' ) ) ";
DynamicParameters parameters = new DynamicParameters();
if (dmodel != null)
{
if (!string.IsNullOrWhiteSpace(dmodel.OrderNo))
{
where += $" and a.OrderNo like @OrderNo ";
parameters.Add("OrderNo", "%" + dmodel.OrderNo.Trim() + "%");
}
if (dmodel.TenantId > 0)
{
where += $" and a.TenantId={dmodel.TenantId} ";
}
if (dmodel.MallBaseId > 0)
{
where += $" and a.MallBaseId={dmodel.MallBaseId} ";
}
if (dmodel.SupplierId > 0)
{
where += $" and b.SupplierId={dmodel.SupplierId} ";
}
if (dmodel.OneUserId > 0)
{
where += $" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
}
if (dmodel.GoodsID > 0)
{
where += $" and b.GoodsId={dmodel.GoodsID} ";
}
if (dmodel.CompanyId > 0)
{
where += $" and b.CompanyId={dmodel.CompanyId} ";
}
if (!string.IsNullOrWhiteSpace(dmodel.Ids))
{
where += $" and b.Id in({dmodel.Ids}) ";
}
if (!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where += $" and DATE_FORMAT(a.CancelTime,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
if (!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where += $" and DATE_FORMAT(a.CancelTime,'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' ) ";
}
}
string sql = $@" SELECT a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney+IFNULL(b.InsuranceMoney,0)) as AllPrice ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
from rb_goods_orderdetail as b
LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
LEFT JOIN rb_member_user as muser on muser.id=b.CompanyId {where}
GROUP BY b.Id order by b.Id asc";
return Get<OrderStatistics_Query>(sql, parameters).ToList();
}
// string sql = $@" SELECT B.Id,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
//SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney) as AllPrice ,
//SUM(IFNULL(b.CostMoney,0)*b.Number) as CostMoney,0 as PackingMoney, 0 as CostFreight,0 as GoodsFreight,
//0 as OtherPrice,e.FXCommission,f.RemitFXCommission,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid
//from rb_goods_orderdetail as b
//LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
//LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
//LEFT JOIN (SELECT SUM(Commission) as FXCommission,OrderDetailId from All_Commission GROUP BY OrderDetailId ) as e on b.Id=e.OrderDetailId
//LEFT JOIN (SELECT SUM(Commission) as RemitFXCommission,OrderDetailId from All_Commission where IsRemit=1 GROUP BY OrderDetailId ) as f on b.Id=f.OrderDetailId
//left join rb_goods_orderaftersale oa on b.ID= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where}
//GROUP BY b.Id ";
/// <summary>
/// 售后订单
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<OrderStatistics_Query> GetFXAllAftersaleOrderProfitLossList(OrderStatistics_Query dmodel)
{
string where = " and (a.OrderStatus in(2,3,4,5,6) or (a.OrderStatus=7 and a.PaymentTime is not NULL and a.CancelTime is not NULL and DATE_FORMAT(a.PaymentTime,'%Y-%m-%d' )<DATE_FORMAT(a.CancelTime,'%Y-%m-%d' ) ) ) ";
DynamicParameters parameters = new DynamicParameters();
if (dmodel != null)
{
if (!string.IsNullOrWhiteSpace(dmodel.OrderNo))
{
where += $" and a.OrderNo like @OrderNo ";
parameters.Add("OrderNo", "%" + dmodel.OrderNo.Trim() + "%");
}
if (dmodel.TenantId > 0)
{
where += $" and a.TenantId={dmodel.TenantId} ";
}
if (dmodel.MallBaseId > 0)
{
where += $" and a.MallBaseId={dmodel.MallBaseId} ";
}
if (dmodel.SupplierId > 0)
{
where += $" and b.SupplierId={dmodel.SupplierId} ";
}
if (dmodel.OneUserId > 0)
{
where += $" and c.OneUserId={dmodel.OneUserId} and d.TwoUserId={dmodel.OneUserId} ";
}
if (dmodel.GoodsID > 0)
{
where += $" and b.GoodsId={dmodel.GoodsID} ";
}
if (dmodel.CompanyId > 0)
{
where += $" and b.CompanyId={dmodel.CompanyId} ";
}
if (!string.IsNullOrWhiteSpace(dmodel.Ids))
{
where += $" and b.Id in({dmodel.Ids}) ";
}
if (!string.IsNullOrWhiteSpace(dmodel.StartDate))
{
where += $" and DATE_FORMAT(oa.FinishTime,'%Y-%m-%d' )>=DATE_FORMAT('{dmodel.StartDate}','%Y-%m-%d' ) ";
}
if (!string.IsNullOrWhiteSpace(dmodel.EndDate))
{
where += $" and DATE_FORMAT(oa.FinishTime,'%Y-%m-%d' )<= DATE_FORMAT('{dmodel.EndDate}','%Y-%m-%d' ) ";
}
}
string sql = $@" SELECT a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName, string sql = $@" SELECT a.OrderStatus,sum(b.InsuranceCostMoney) as InsuranceCostMoney,sum(b.InsuranceMoney) as InsuranceMoney,b.CarType,a.OrderClassify,B.Id,b.ServiceCharge,SUM(b.PaidCostMoney) as PaidCostMoney,MAX(b.OrderId) as OrderId,MAX( a.OrderNo) as OrderNo,MAX(b.GoodsName) as GoodsName,b.Specification,MAX(b.Unit_Price) as Unit_Price,SUM(b.Number) as Number,f.`Name` as SupplierName,
SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney+IFNULL(b.InsuranceMoney,0)) as AllPrice , SUM(b.Final_Price) as Final_Price,SUM(b.FreightMoney) as FreightMoney,SUM(b.Final_Price+b.FreightMoney+IFNULL(b.InsuranceMoney,0)) as AllPrice ,
(IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight, (IFNULL(b.CostMoney,0)) as CostMoney,0 as PackingMoney, 0 as CostFreight,sum(b.FreightCostMoney) as GoodsFreight,
0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,oa.RefundActual,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney 0 as OtherPrice,b.LiveCommission,b.LiveFinanceIds,b.LivePeopleNum,0 as Paid,oa.RefundActual,b.CouponMoney,b.CompanyProfitRate,b.CompanyId,muser.`Name` as CompanyName,b.YSMoney,b.RealMoney,b.YFMoney,b.PayMoney
from rb_goods_orderdetail as b from rb_goods_orderaftersale as oa
LEFT JOIN rb_goods_orderdetail as b on b.ID= oa.OrderDetialId
LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId LEFT JOIN rb_goods_order as A on a.OrderId=b.OrderId
LEFT JOIN rb_supplier as f on f.ID=b.SupplierId LEFT JOIN rb_supplier as f on f.ID=b.SupplierId
LEFT JOIN rb_member_user as muser on muser.id=b.CompanyId LEFT JOIN rb_member_user as muser on muser.id=b.CompanyId
left join rb_goods_orderaftersale oa on b.ID= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where} where oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (2,3,4,5) {where}
GROUP BY b.Id order by b.Id asc"; GROUP BY b.Id order by b.Id asc";
return Get<OrderStatistics_Query>(sql, parameters).ToList(); return Get<OrderStatistics_Query>(sql, parameters).ToList();
} }
/// <summary> /// <summary>
/// 获取用户 订单下的商品数量 /// 获取用户 订单下的商品数量
/// </summary> /// </summary>
......
...@@ -158,12 +158,18 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -158,12 +158,18 @@ namespace Mall.WebApi.Controllers.AppletWeChat
item.LiveCommission = 0; item.LiveCommission = 0;
item.RemitFXCommission = 0; item.RemitFXCommission = 0;
item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice; item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice;
// item.ServiceCharge = item.ServiceCharge * (-1);
}
if (item.RefundActual > 0)
{
//decimal totalPrice = goodsDetailList.Where(x => x.OrderId == goodsDetailGroupItem.Key).Sum(x => (x.FreightMoney ?? 0) + (x.Final_Price ?? 0) + (x.InsuranceMoney ?? 0)) * (Convert.ToDecimal(Config.SettlementRate) / 100);
item.ServiceCharge = (item.AllPrice - item.RefundActual) * (Convert.ToDecimal(Config.SettlementRate) / 100) * (-1);
} }
item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number)); item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number));
item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney; item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney;
item.NoPaid = item.ALLCommission; item.NoPaid = item.ALLCommission;
item.RemitFXCommission = item.RemitFXCommission + (!string.IsNullOrWhiteSpace(item.LiveFinanceIds) ? item.LiveCommission : 0); item.RemitFXCommission = item.RemitFXCommission + (!string.IsNullOrWhiteSpace(item.LiveFinanceIds) ? item.LiveCommission : 0);
item.Paid = item.RefundActual + item.RemitFXCommission + item.CostMoney + item.GoodsFreight + item.PayMoney; item.Paid = item.RefundActual + item.RemitFXCommission + item.CostMoney + item.GoodsFreight + item.PayMoney;
item.GrossProfit = item.AllPrice + item.YSMoney - item.ALLCommission; item.GrossProfit = item.AllPrice + item.YSMoney - item.ALLCommission;
if (item.AllPrice == 0) if (item.AllPrice == 0)
...@@ -362,10 +368,14 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -362,10 +368,14 @@ namespace Mall.WebApi.Controllers.AppletWeChat
demodel.TenantId = requestParm.TenantId; demodel.TenantId = requestParm.TenantId;
demodel.MallBaseId = requestParm.MallBaseId; demodel.MallBaseId = requestParm.MallBaseId;
List<OrderStatistics_Query> list = new List<OrderStatistics_Query>(); List<OrderStatistics_Query> list = new List<OrderStatistics_Query>();
List<OrderStatistics_Query> listCancel = new List<OrderStatistics_Query>();
List<OrderStatistics_Query> listAftersale = new List<OrderStatistics_Query>();
if (demodel.IsFxCommission == 1) if (demodel.IsFxCommission == 1)
{ {
demodel.IsSelectOrderCommission = 1; demodel.IsSelectOrderCommission = 1;
list = statisticsModule.GetFXAllOrderProfitLossList(demodel); list = statisticsModule.GetFXAllOrderProfitLossList(demodel);
listCancel = statisticsModule.GetFXAllCancelOrderProfitLossList(demodel);
listAftersale = statisticsModule.GetFXAllAftersaleOrderProfitLossList(demodel);
} }
foreach (var item in list) foreach (var item in list)
{ {
...@@ -376,12 +386,23 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -376,12 +386,23 @@ namespace Mall.WebApi.Controllers.AppletWeChat
item.RemitFXCommission = 0; item.RemitFXCommission = 0;
item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice; item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice;
} }
if (item.RefundActual > 0)//判断当前的订单是否存在在售后获取取消中
{
if (listCancel != null && listCancel.Any(x => x.Id == item.Id))//存在取消中
{
item.ReturnServiceCharge = item.ServiceCharge;
}
else if (listAftersale != null && listAftersale.Any(x => x.Id == item.Id))//存在取消中
{
item.ReturnServiceCharge = Math.Round((item.RefundActual * (Convert.ToDecimal(Config.SettlementRate) / 100)), 2, MidpointRounding.AwayFromZero);
}
}
item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number)); item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number));
item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney; item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney;
// item.ALLCommission = item.CostMoney + item.GoodsFreight + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney; // item.ALLCommission = item.CostMoney + item.GoodsFreight + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney;
item.NoPaid = item.ALLCommission; item.NoPaid = item.ALLCommission;
item.RemitFXCommission = item.RemitFXCommission + (!string.IsNullOrWhiteSpace(item.LiveFinanceIds) ? item.LiveCommission : 0); item.RemitFXCommission = item.RemitFXCommission + (!string.IsNullOrWhiteSpace(item.LiveFinanceIds) ? item.LiveCommission : 0);
item.Paid = item.RefundActual + item.RemitFXCommission + item.CostMoney + item.GoodsFreight + item.PayMoney; item.Paid = item.RefundActual + item.RemitFXCommission + item.CostMoney + item.GoodsFreight + item.PayMoney;
item.GrossProfit = item.AllPrice + item.YSMoney - item.ALLCommission; item.GrossProfit = item.AllPrice + item.YSMoney - item.ALLCommission;
if (item.AllPrice == 0) if (item.AllPrice == 0)
...@@ -416,14 +437,14 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -416,14 +437,14 @@ namespace Mall.WebApi.Controllers.AppletWeChat
datarow.ExcelRows.Add(new ExcelColumn(value: item.AllPrice.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.AllPrice.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.YSMoney.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.YSMoney.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: (item.AllPrice + item.YSMoney).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: (item.AllPrice + item.YSMoney).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.ServiceCharge.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: (item.ServiceCharge-item.ReturnServiceCharge).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.CostMoney.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.CostMoney.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.GoodsFreight.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.GoodsFreight.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.InsuranceCostMoney.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.InsuranceCostMoney.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.FXCommission.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.FXCommission.ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: item.RemitFXCommission.ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: item.RemitFXCommission.ToString("#0.00")) { });
string commissionInfo = ""; string commissionInfo = "";
if (item.OrderCommissionList != null && item.OrderCommissionList.Any()&&item.OrderStatus!=7) if (item.OrderCommissionList != null && item.OrderCommissionList.Any() && item.OrderStatus != 7)
{ {
foreach (var itemCommi in item.OrderCommissionList) foreach (var itemCommi in item.OrderCommissionList)
{ {
...@@ -462,7 +483,20 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -462,7 +483,20 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{ {
GrossProfitRate = (Math.Round((list.Sum(x => x.GrossProfit) / list.Sum(x => x.AllPrice + x.YSMoney)), 4, MidpointRounding.AwayFromZero) * 100); GrossProfitRate = (Math.Round((list.Sum(x => x.GrossProfit) / list.Sum(x => x.AllPrice + x.YSMoney)), 4, MidpointRounding.AwayFromZero) * 100);
} }
decimal totalReturn = 0;
if (listCancel != null && listCancel.Any())
{
totalReturn += listCancel.Sum(x => x.AllPrice);
}
if (listAftersale != null && listAftersale.Any())
{
totalReturn += listAftersale.Sum(x => x.RefundActual);
}
if (totalReturn > 0)
{
totalReturn = Math.Round((totalReturn * (Convert.ToDecimal(Config.SettlementRate) / 100)), 2, MidpointRounding.AwayFromZero);
}
ExcelDataSource datarow = new ExcelDataSource() ExcelDataSource datarow = new ExcelDataSource()
{ {
ExcelRows = new List<ExcelColumn>(30) { ExcelRows = new List<ExcelColumn>(30) {
...@@ -481,8 +515,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -481,8 +515,8 @@ namespace Mall.WebApi.Controllers.AppletWeChat
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.AllPrice).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.AllPrice).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.YSMoney).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.YSMoney).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.AllPrice + x.YSMoney).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.AllPrice + x.YSMoney).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.ServiceCharge).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: (list.Sum(x => x.ServiceCharge)-totalReturn).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.CostMoney).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.CostMoney).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.GoodsFreight).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.GoodsFreight).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.InsuranceCostMoney).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.InsuranceCostMoney).ToString("#0.00")) { });
datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.FXCommission).ToString("#0.00")) { }); datarow.ExcelRows.Add(new ExcelColumn(value: list.Sum(x => x.FXCommission).ToString("#0.00")) { });
...@@ -566,9 +600,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -566,9 +600,13 @@ namespace Mall.WebApi.Controllers.AppletWeChat
demodel.TenantId = requestParm.TenantId; demodel.TenantId = requestParm.TenantId;
demodel.MallBaseId = requestParm.MallBaseId; demodel.MallBaseId = requestParm.MallBaseId;
List<OrderStatistics_Query> list = new List<OrderStatistics_Query>(); List<OrderStatistics_Query> list = new List<OrderStatistics_Query>();
List<OrderStatistics_Query> listCancel = new List<OrderStatistics_Query>();
List<OrderStatistics_Query> listAftersale = new List<OrderStatistics_Query>();
if (demodel.IsFxCommission == 1) if (demodel.IsFxCommission == 1)
{ {
list = statisticsModule.GetFXAllOrderProfitLossList(demodel); list = statisticsModule.GetFXAllOrderProfitLossList(demodel);
listCancel = statisticsModule.GetFXAllCancelOrderProfitLossList(demodel);
listAftersale = statisticsModule.GetFXAllAftersaleOrderProfitLossList(demodel);
} }
else if (demodel.IsFxCommission == 0) else if (demodel.IsFxCommission == 0)
{ {
...@@ -584,6 +622,17 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -584,6 +622,17 @@ namespace Mall.WebApi.Controllers.AppletWeChat
item.RemitFXCommission = 0; item.RemitFXCommission = 0;
item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice; item.RefundActual = item.RefundActual > 0 ? item.RefundActual : item.AllPrice;
} }
if (item.RefundActual > 0)//判断当前的订单是否存在在售后获取取消中
{
if (listCancel != null && listCancel.Any(x => x.Id == item.Id))//存在取消中
{
item.ReturnServiceCharge = item.ServiceCharge;
}
else if (listAftersale != null && listAftersale.Any(x => x.Id == item.Id))//存在取消中
{
item.ReturnServiceCharge = Math.Round((item.RefundActual * (Convert.ToDecimal(Config.SettlementRate) / 100)), 2, MidpointRounding.AwayFromZero);
}
}
item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number)); item.CostMoney = ((item.OrderClassify == 1 && item.CarType != 5) ? item.CostMoney : (item.CostMoney * item.Number));
item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney; item.ALLCommission = item.CostMoney + item.GoodsFreight + item.InsuranceCostMoney + item.FXCommission + item.LiveCommission + item.RefundActual + item.YFMoney;
item.NoPaid = item.ALLCommission; item.NoPaid = item.ALLCommission;
...@@ -607,9 +656,24 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -607,9 +656,24 @@ namespace Mall.WebApi.Controllers.AppletWeChat
{ {
GrossProfitRate = (Math.Round((list.Sum(x => x.GrossProfit) / list.Sum(x => x.AllPrice + x.YSMoney)), 4, MidpointRounding.AwayFromZero) * 100); GrossProfitRate = (Math.Round((list.Sum(x => x.GrossProfit) / list.Sum(x => x.AllPrice + x.YSMoney)), 4, MidpointRounding.AwayFromZero) * 100);
} }
var retult = new
decimal totalReturn = 0;
if (listCancel != null && listCancel.Any())
{
totalReturn += listCancel.Sum(x => x.AllPrice);
}
if (listAftersale != null && listAftersale.Any())
{
totalReturn += listAftersale.Sum(x => x.RefundActual);
}
if (totalReturn > 0)
{ {
totalReturn= Math.Round((totalReturn * (Convert.ToDecimal(Config.SettlementRate) / 100)), 2, MidpointRounding.AwayFromZero);
}
var retult = new
{
OrderNo = "", OrderNo = "",
GoodsName = "", GoodsName = "",
Unit_Price = list.Sum(x => x.Unit_Price),//单价 Unit_Price = list.Sum(x => x.Unit_Price),//单价
...@@ -619,6 +683,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat ...@@ -619,6 +683,7 @@ namespace Mall.WebApi.Controllers.AppletWeChat
FreightMoney = list.Sum(x => !string.IsNullOrWhiteSpace(x.FreightMoney) ? Convert.ToDecimal(x.FreightMoney) : 0), FreightMoney = list.Sum(x => !string.IsNullOrWhiteSpace(x.FreightMoney) ? Convert.ToDecimal(x.FreightMoney) : 0),
AllPrice = list.Sum(x => x.AllPrice), AllPrice = list.Sum(x => x.AllPrice),
ServiceCharge = list.Sum(x => x.ServiceCharge), ServiceCharge = list.Sum(x => x.ServiceCharge),
ReturnServiceCharge = totalReturn,
CostMoney = list.Sum(x => x.CostMoney), CostMoney = list.Sum(x => x.CostMoney),
PackingMoney = list.Sum(x => x.PackingMoney), PackingMoney = list.Sum(x => x.PackingMoney),
GoodsFreight = list.Sum(x => x.GoodsFreight), GoodsFreight = list.Sum(x => x.GoodsFreight),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment