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
});
}
......
......@@ -12,7 +12,7 @@
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>请选择月份</label>
<input id="month" name="month" class="form-control" style="width:130px;" placeholder="年.月" />
<input id="month" name="month" class="form-control" style="width:130px;" placeholder="年.月" value="@(DateTime.Now.AddMonths(-1).ToString("yyyy-MM"))" />
</div>
<div class="form-group">
<label>&nbsp;</label>
......@@ -22,22 +22,342 @@
</div>
</form>
</div>
<div class="ibox-contentc">
<table id="roletable"></table>
<div class="ibox-content m-b-sm border-bottom">
<h2 id="lbl_title" style="text-align:center;">X月份销售利润表</h2>
<div class="bootstrap-table">
<div class="fixed-table-container">
<div class="fixed-table-body">
<table style="table-layout: fixed;" class="table table-border table-bordered table-hover table-bg table-sort form-inline">
<tbody>
<tr>
<td style="width:420px;">项目</td>
<td>金额</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">销售额</td>
<td>
<span class="lbl_amount_sale">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">成本</td>
<td>
<span class="lbl_cost_sale">0</span>
<a class="cost_sale_" onclick="Edit('cost_sale_','成本')" val="">编辑</a>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">平台扣费及退款</td>
<td>
<span class="lbl_pt_count">0</span>
</td>
</tr>
<tr>
<td>平台费</td>
<td>
<span class="lbl_pt_platformfee">0</span>
</td>
</tr>
<tr>
<td>ebay刊登费</td>
<td>
<span class="lbl_pt_ebay_postingfee">0</span>
</td>
</tr>
<tr>
<td>paypal费用</td>
<td>
<span class="lbl_pt_paypal_fee">0</span>
</td>
</tr>
<tr>
<td>平台的物流费</td>
<td>
<span class="lbl_pt_platform_logistics_fee">0</span>
<a class="pt_platform_logistics_fee_" onclick="Edit('pt_platform_logistics_fee_','平台的物流费')" val="">编辑</a>
</td>
</tr>
<tr>
<td>广告及宣传费-订阅费</td>
<td>
<span class="lbl_pt_platform_ad_subscribe_fee">0</span>
<a class="pt_platform_ad_subscribe_fee_" onclick="Edit('pt_platform_ad_subscribe_fee_','广告及宣传费-订阅费')" val="">编辑</a>
</td>
</tr>
<tr>
<td>平台的仓储费</td>
<td>
<span class="lbl_pt_platform_storage_fee">0</span>
<a class="pt_platform_storage_fee" onclick="Edit('pt_platform_storage_fee','平台的仓储费')" val="">编辑</a>
</td>
</tr>
<tr>
<td>退款</td>
<td>
<span class="lbl_pt_refund_amount">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;">回款</td>
<td>
<span class="lbl_pt_incoming">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">物流仓储费用</td>
<td>
<span class="lbl_ls_count">0</span>
</td>
</tr>
<tr>
<td>头程运输</td>
<td>
<span class="lbl_ls_head_cost">0</span>
<a class="ls_head_cost_" onclick="Edit('ls_head_cost_','头程运输')" val="">编辑</a>
</td>
</tr>
<tr>
<td>尾程物流</td>
<td>
<span class="lbl_ls_tail_cost">0</span>
<a class="ls_tail_cost_" onclick="Edit('ls_tail_cost_','尾程物流')" val="">编辑</a>
</td>
</tr>
<tr>
<td>海外仓的仓储费</td>
<td>
<span class="lbl_ls_oversea_storage">0</span>
<a class="ls_oversea_storage" onclick="Edit('ls_oversea_storage','海外仓的仓储费')" val="">编辑</a>
</td>
</tr>
<tr>
<td>平台操作费</td>
<td>
<span class="lbl_ls_platform_operation_fee">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">销售费用合计</td>
<td>
<span class="lbl_sale_fee_count">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">销售利润</td>
<td>
<span class="lbl_sale_profit">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">销售毛利率</td>
<td>
<span class="lbl_sale_profit_rate">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">销售相关的管理成本</td>
<td>
<span class="lbl_sale_manager_cost">0</span>
</td>
</tr>
<tr>
<td>处理费</td>
<td>
<span class="lbl_handlingcharges">0</span>
<a class="handlingcharges" onclick="Edit('handlingcharges','处理费')" val="">编辑</a>
</td>
</tr>
<tr>
<td>直接支付的与销售平台相关费用</td>
<td>
<span class="lbl_payfor_platform_related_fee">0</span>
<a class="payfor_platform_related_fee" onclick="Edit('payfor_platform_related_fee','直接支付的与销售平台相关费用')" val="">编辑</a>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">直接管理成本</td>
<td>
<span class="lbl_direct_manager_cost">0</span>
</td>
</tr>
<tr>
<td>管理成本-香港百伦(不含直接支付的与销售平台相关的费用)</td>
<td>
<span class="lbl_manager_cost_hkbailun">0</span>
<a class="manager_cost_hkbailun" onclick="Edit('manager_cost_hkbailun','管理成本-香港百伦(不含直接支付的与销售平台相关的费用)')" val="">编辑</a>
</td>
</tr>
<tr>
<td>管理成本-广州百伦</td>
<td>
<span class="lbl_manager_cost_gzbailun">0</span>
<a class="manager_cost_gzbailun" onclick="Edit('manager_cost_gzbailun','管理成本-广州百伦')" val="">编辑</a>
</td>
</tr>
<tr>
<td>管理成本-成品仓(不含直接支付的与销售平台相关的费用)</td>
<td>
<span class="lbl_manager_cost_finish_wh">0</span>
<a class="manager_cost_finish_wh" onclick="Edit('manager_cost_finish_wh','管理成本-成品仓(不含直接支付的与销售平台相关的费用)')" val="">编辑</a>
</td>
</tr>
<tr>
<td>财务费用</td>
<td>
<span class="lbl_finance_fee">0</span>
<a class="finance_fee" onclick="Edit('finance_fee','财务费用')" val="">编辑</a>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">管理成本合计</td>
<td>
<span class="lbl_manager_cost_count">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">营业利润</td>
<td>
<span class="lbl_business_profit">0</span>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">营业毛利率</td>
<td>
<span class="lbl_business_profit_rate">0</span>
</td>
</tr>
<tr>
<td>加:其他收入</td>
<td>
<span class="lbl_other_incoming">0</span>
<a class="other_incoming" onclick="Edit('other_incoming','加:其他收入')" val="">编辑</a>
</td>
</tr>
<tr>
<td>加:营业外收入</td>
<td>
<span class="lbl_nonbusiness_income">0</span>
<a class="nonbusiness_income" onclick="Edit('nonbusiness_income','加:营业外收入')" val="">编辑</a>
</td>
</tr>
<tr>
<td>减:营业外支出</td>
<td>
<span class="lbl_nonbusiness_pay">0</span>
<a class="nonbusiness_pay" onclick="Edit('nonbusiness_pay','减:营业外支出')" val="">编辑</a>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">实际利润</td>
<td>
<span class="lbl_actual_profit">0</span>
</td>
</tr>
<tr>
<td>减:分红</td>
<td>
<span class="lbl_participation_in_profit">0</span>
<a class="participation_in_profit" onclick="Edit('participation_in_profit','减:营业外支出')" val="">编辑</a>
</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:center;">利润结余</td>
<td>
<span class="lbl_balance_of_profit">0</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@section css{
<style>
a {margin-left:10px;}
</style>
}
@section scripts{
<script src="~/css/Layer-2.1/extend/layer.ext.js"></script>
<script type="text/javascript">
$(document).ready(function () {
laydate.render({ elem: '#month', type: 'month' });
list();
})
function list() {
$.submit({
url: '@Url.Content("~/Reports/Finance/ListMonthSaleProfit")',
type:'POST',
paramData: $("#toolbar").serialize(),
func: function (result) {
if (result.success) {
if (result.data.length > 0) {
var obj = result.data[0];
$('#lbl_title').html($('#month').val() + '月销售利润表');
for (var i in obj) {
var _temp = i.substr(i.length - 1, 1);
if (_temp == '_') {
$('.' + i).attr('val', obj[i]);
}
else {
$('.lbl_' + i).html(obj[i]);
try {
$('.' + i).attr('val', obj[i]);
} catch (e) {
}
}
}
}
else {
layer.msg('没有' + $('#month').val()+'月份的销售利润数据。');
}
}
else {
layer.msg(result.msg);
}
return false;
}
})
}
function Edit(col, name) {
var v = $('.' + col).attr('val');
layer.prompt({ title: '编辑' + name, value:v}, function (text, index) {
layer.close(index);
Save(col, text);
});
}
function Save(col, val) {
$.submit({
url: '@Url.Content("~/Reports/Finance/SaveMonthSaleProfit")',
paramData: 'month=' + $('#month').val()+'&'+col+'='+val,
type:'POST',
func: function (result) {
if (result.success) {
layer.msg('提交成功');
setTimeout(function () {
list();
}, 1.5 * 1000);
}
else {
layer.msg(result.msg);
}
}
})
}
function exportxls() {
......
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