Commit 56fbc946 by guanzhenshan

完善每月销售利润报表

parent e9d3fe84
......@@ -30,6 +30,11 @@ namespace Bailun.DC.Models
public decimal cost_sale { get; set; }
/// <summary>
/// 成本(导入)
/// </summary>
public decimal cost_sale_ { get; set; }
/// <summary>
/// 平台扣费及退款
/// </summary>
public decimal pt_count { get; set; }
......@@ -55,11 +60,21 @@ namespace Bailun.DC.Models
public decimal pt_platform_logistics_fee { get; set; }
/// <summary>
/// 平台的物流费(导入)
/// </summary>
public decimal pt_platform_logistics_fee_ { get; set; }
/// <summary>
/// 广告及宣传费-订阅费
/// </summary>
public decimal pt_platform_ad_subscribe_fee { get; set; }
/// <summary>
/// 广告及宣传费-订阅费(导入)
/// </summary>
public decimal pt_platform_ad_subscribe_fee_ { get; set; }
/// <summary>
/// 平台的仓储费
/// </summary>
public decimal pt_platform_storage_fee { get; set; }
......@@ -85,11 +100,22 @@ namespace Bailun.DC.Models
public decimal ls_head_cost { get; set; }
/// <summary>
/// 头程运输(导入)
/// </summary>
public decimal ls_head_cost_ { get; set; }
/// <summary>
/// 尾程运输
/// </summary>
public decimal ls_tail_cost { get; set; }
/// <summary>
/// 尾程运输(导入)
/// </summary>
public decimal ls_tail_cost_ { get; set; }
/// <summary>
/// 海外仓仓储费
/// </summary>
public decimal ls_oversea_storage { get; set; }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models
{
/// <summary>
/// 月销售利润报表参数
/// </summary>
public class mMonthSaleProfit_Input
{
/// <summary>
/// 月份
/// </summary>
public string month { get; set; }
/// <summary>
/// 成本
/// </summary>
public decimal? cost_sale_ { get; set; }
/// <summary>
/// 平台的物流费
/// </summary>
public decimal? pt_platform_logistics_fee_ { get; set; }
/// <summary>
/// 广告及宣传费-订阅费
/// </summary>
public decimal? pt_platform_ad_subscribe_fee_ { get; set; }
/// <summary>
/// 平台的仓储费
/// </summary>
public decimal? pt_platform_storage_fee { get; set; }
/// <summary>
/// 头程费
/// </summary>
public decimal? ls_head_cost_ { get; set; }
/// <summary>
/// 尾程费
/// </summary>
public decimal? ls_tail_cost_ { get; set; }
/// <summary>
/// 海外仓的仓储费
/// </summary>
public decimal? ls_oversea_storage { get; set; }
/// <summary>
/// 处理费
/// </summary>
public decimal? handlingcharges { get; set; }
/// <summary>
/// 直接支付的与销售平台相关费用
/// </summary>
public decimal? payfor_platform_related_fee { get; set; }
/// <summary>
/// 管理成本-香港百伦(不含直接支付的与销售平台相关的费用)
/// </summary>
public decimal? manager_cost_hkbailun { get; set; }
/// <summary>
/// 管理成本-广州百伦
/// </summary>
public decimal? manager_cost_gzbailun { get; set; }
/// <summary>
/// 管理成本-成品仓(不含直接支付的与销售平台相关的费用)
/// </summary>
public decimal? manager_cost_finish_wh { get; set; }
/// <summary>
/// 财务费用
/// </summary>
public decimal? finance_fee { get; set; }
/// <summary>
/// 加:其他收入
/// </summary>
public decimal? other_incoming { get; set; }
/// <summary>
/// 加:营业外收入
/// </summary>
public decimal? nonbusiness_income { get; set; }
/// <summary>
/// 减:营业外支出
/// </summary>
public decimal? nonbusiness_pay { get; set; }
/// <summary>
/// 减:分红
/// </summary>
public decimal? participation_in_profit { get; set; }
}
}
......@@ -3569,6 +3569,157 @@ group by currency";
}
}
/// <summary>
/// 更新月度利润报表
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
public string UpdateMonthSaleProfit(mMonthSaleProfit_Input m,int uid,string username)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirstOrDefault<dc_month_sale_profit>("select * from dc_month_sale_profit where month='" + m.month + "'");
if (obj == null)
{
return "找不到该月份的利润数据。";
}
if (m.cost_sale_.HasValue)
{
obj.cost_sale_ = m.cost_sale_.Value;
}
if (m.finance_fee.HasValue)
{
obj.finance_fee = m.finance_fee.Value;
}
if (m.handlingcharges.HasValue)
{
obj.handlingcharges = m.handlingcharges.Value;
}
if (m.ls_head_cost_.HasValue)
{
obj.ls_head_cost_ = m.ls_head_cost_.Value;
}
if (m.ls_oversea_storage.HasValue)
{
obj.ls_oversea_storage = m.ls_oversea_storage.Value;
}
if (m.ls_tail_cost_.HasValue)
{
obj.ls_tail_cost_ = m.ls_tail_cost_.Value;
}
if (m.manager_cost_finish_wh.HasValue)
{
obj.manager_cost_finish_wh = m.manager_cost_finish_wh.Value;
}
if (m.manager_cost_gzbailun.HasValue)
{
obj.manager_cost_gzbailun = m.manager_cost_gzbailun.Value;
}
if (m.manager_cost_hkbailun.HasValue)
{
obj.manager_cost_hkbailun = m.manager_cost_hkbailun.Value;
}
if (m.nonbusiness_income.HasValue)
{
obj.nonbusiness_income = m.nonbusiness_income.Value;
}
if(m.nonbusiness_pay.HasValue)
{
obj.nonbusiness_pay = m.nonbusiness_pay.Value;
}
if (m.other_incoming.HasValue)
{
obj.other_incoming = m.other_incoming.Value;
}
if (m.participation_in_profit.HasValue)
{
obj.participation_in_profit = m.participation_in_profit.Value;
}
if (m.payfor_platform_related_fee.HasValue)
{
obj.payfor_platform_related_fee = m.payfor_platform_related_fee.Value;
}
if (m.pt_platform_ad_subscribe_fee_.HasValue)
{
obj.pt_platform_ad_subscribe_fee_ = m.pt_platform_ad_subscribe_fee_.Value;
}
if (m.pt_platform_logistics_fee_.HasValue)
{
obj.pt_platform_logistics_fee_ = m.pt_platform_logistics_fee_.Value;
}
if(m.pt_platform_storage_fee.HasValue)
{
obj.pt_platform_storage_fee = m.pt_platform_storage_fee.Value;
}
//平台扣费及退款=平台费+ebay刊登费+paypal费用+平台物流费+广告及宣传费|订阅费+平台仓储费+退款
obj.pt_count = obj.pt_platformfee + obj.pt_ebay_postingfee + obj.pt_paypal_fee + (obj.pt_platform_logistics_fee + obj.pt_platform_logistics_fee_) + (obj.pt_platform_ad_subscribe_fee + obj.pt_platform_ad_subscribe_fee_) + obj.pt_platform_storage_fee + obj.pt_refund_amount;
//回款=销售额-平台扣费及退款
obj.pt_incoming = obj.amount_sale - obj.pt_count;
//物流仓储费用=头程运输+尾程物流+海外仓的仓储费+平台操作费
obj.ls_count = (obj.ls_head_cost + obj.ls_head_cost_) + (obj.ls_tail_cost + obj.ls_tail_cost_) + obj.ls_oversea_storage + obj.ls_platform_operation_fee;
//销售费用合计=平台扣费及退款+物流仓储费用
obj.sale_fee_count = obj.pt_count + obj.ls_count;
//销售利润=销售额-成本-销售费用合计
obj.sale_profit = obj.amount_sale - (obj.cost_sale + obj.cost_sale_) - obj.sale_fee_count;
//销售毛利率 = 销售利润/销售额
obj.sale_profit_rate = obj.sale_profit / obj.amount_sale;
//销售相关的管理成本=处理费+直接支付的与销售平台相关费用
obj.sale_manager_cost = obj.handlingcharges + obj.payfor_platform_related_fee;
//直接管理成本=管理成本香港百伦+管理成本广州百伦+管理成本成品仓+财务费用
obj.direct_manager_cost = obj.manager_cost_hkbailun + obj.manager_cost_gzbailun + obj.manager_cost_finish_wh+obj.finance_fee;
//管理成本合计=直接管理成本+销售相关的管理成本
obj.manager_cost_count = obj.direct_manager_cost + obj.sale_manager_cost;
//营业利润=销售利润-管理成本合计
obj.business_profit = obj.sale_profit - obj.manager_cost_count;
//营业毛利率=营业利润/销售额
obj.business_profit_rate = obj.business_profit / obj.amount_sale;
//实际利润=营业利润+其他收入+营业外收入-营业外支出
obj.actual_profit = obj.business_profit + obj.other_incoming + obj.nonbusiness_income - obj.nonbusiness_pay;
//利润结余=实际利润-分红
obj.balance_of_profit = obj.actual_profit - obj.participation_in_profit;
obj.lastupdatetime = DateTime.Now;
var result = cn.Update<dc_month_sale_profit>(obj);
return result > 0 ? "" : "更新失败,请重试";
}
}
#endregion
......
......@@ -5535,12 +5535,97 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
[HttpPost]
public JsonResult ListMonthSaleProfit(string month)
{
try
{
var obj = new Services.FinanceReportServices().ListMonthSaleProfit(month, month);
var list = obj.Select(a => new
{
amount_sale = a.amount_sale.ToString("N2"),
cost_sale = (a.cost_sale+a.cost_sale_).ToString("N2"),
cost_sale_ = a.cost_sale_.ToString("N2"),
pt_count = a.pt_count.ToString("N2"), //(a.pt_platformfee+a.pt_ebay_postingfee+a.pt_paypal_fee+a.pt_platform_logistics_fee+a.pt_platform_ad_subscribe_fee + a.pt_platform_storage_fee+a.pt_refund_amount).ToString("N2"),
pt_platformfee = a.pt_platformfee.ToString("N2"),
pt_ebay_postingfee = a.pt_ebay_postingfee.ToString("N2"),
pt_paypal_fee = a.pt_paypal_fee.ToString("N2"),
pt_platform_logistics_fee = (a.pt_platform_logistics_fee+a.pt_platform_logistics_fee_).ToString("N2"),
pt_platform_logistics_fee_ = a.pt_platform_logistics_fee_.ToString("N2"),
pt_platform_ad_subscribe_fee = (a.pt_platform_ad_subscribe_fee+a.pt_platform_ad_subscribe_fee_).ToString("N2"),
pt_platform_ad_subscribe_fee_ = a.pt_platform_ad_subscribe_fee_.ToString("N2"),
pt_platform_storage_fee = a.pt_platform_storage_fee.ToString("N2"),
pt_refund_amount = a.pt_refund_amount.ToString("N2"),
pt_incoming = a.pt_incoming.ToString("N2"),
ls_count = a.ls_count.ToString("N2"),
ls_head_cost = (a.ls_head_cost+a.ls_head_cost_).ToString("N2"),
ls_head_cost_ = a.ls_head_cost_.ToString("N2"),
ls_tail_cost = (a.ls_tail_cost+a.ls_tail_cost_).ToString("N2"),
ls_tail_cost_ = a.ls_tail_cost_.ToString("N2"),
ls_oversea_storage = a.ls_oversea_storage.ToString("N2"),
ls_platform_operation_fee = a.ls_platform_operation_fee.ToString("N2"),
sale_fee_count = a.sale_fee_count.ToString("N2"),
sale_profit = a.sale_profit.ToString("N2"),
sale_profit_rate = (a.sale_profit_rate*100).ToString("N2"),
sale_manager_cost = a.sale_manager_cost.ToString("N2"),
handlingcharges = a.handlingcharges.ToString("N2"),
payfor_platform_related_fee = a.payfor_platform_related_fee.ToString("N2"),
direct_manager_cost = a.direct_manager_cost.ToString("N2"),
manager_cost_hkbailun = a.manager_cost_hkbailun.ToString("N2"),
manager_cost_gzbailun = a.manager_cost_gzbailun.ToString("N2"),
manager_cost_finish_wh = a.manager_cost_finish_wh.ToString("N2"),
finance_fee = a.finance_fee.ToString("N2"),
manager_cost_count = a.manager_cost_count.ToString("N2"),
business_profit = a.business_profit.ToString("N2"),
business_profit_rate = a.business_profit_rate.ToString("N2"),
other_incoming = a.other_incoming.ToString("N2"),
nonbusiness_income = a.nonbusiness_income.ToString("N2"),
nonbusiness_pay = a.nonbusiness_pay.ToString("N2"),
actual_profit = a.actual_profit.ToString("N2"),
participation_in_profit = a.participation_in_profit.ToString("N2"),
balance_of_profit = a.balance_of_profit.ToString("N2"),
a.month
});
return Json(new {
success = true,
msg = "",
data = list
});
}
catch (Exception ex)
{
return Json(new {
success = false,
msg = "出现异常,异常信息:"+ex.Message
});
}
}
var obj = new Services.FinanceReportServices().ListMonthSaleProfit(month, month);
/// <summary>
/// 更新月度销售利润报表
/// </summary>
/// <param name="m"></param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
public JsonResult SaveMonthSaleProfit(mMonthSaleProfit_Input m)
{
var user = HttpContextHelper.Current?.User;
var _service = new Services.FinanceReportServices();
var result = _service.UpdateMonthSaleProfit(m,user!=null?user.GetUid():0,user!=null?user.GetUserName():"");
return Json("");
return Json(new {
success = string.IsNullOrEmpty(result),
msg = result
});
}
......
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