Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bltdc
DataCenter_Core2.1_20190520
Commits
cb59d780
Commit
cb59d780
authored
Aug 21, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
e1a7d1d0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
173 additions
and
149 deletions
+173
-149
FinanceService.cs
Bailun.DC.Services/WebApiService/FinanceService.cs
+172
-148
FinanceController.cs
Bailun.DC.WebApi/Controllers/FinanceController.cs
+1
-1
No files found.
Bailun.DC.Services/WebApiService/FinanceService.cs
View file @
cb59d780
...
@@ -1109,178 +1109,202 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
...
@@ -1109,178 +1109,202 @@ AND financecategoryname LIKE '{financecategory.Replace("产品", "")}%' ";
/// <summary>
/// <summary>
/// 拉取旧的dc_month_sales_profit表数据到新表,生成新的汇总数据
/// 拉取旧的dc_month_sales_profit表数据到新表,生成新的汇总数据
/// </summary>
/// </summary>
public
bool
SyncMonthSalesProfit
(
DateTime
?
date
)
public
bool
SyncMonthSalesProfit
(
string
date
)
{
{
try
try
{
{
//拉取旧表数据
//拉取旧表数据
var
time
=
string
.
Empty
;
var
time
=
string
.
Empty
;
if
(
date
.
HasValue
)
if
(
!
string
.
IsNullOrWhiteSpace
(
date
)
)
{
{
time
=
date
.
Value
.
ToString
(
"yyyy-MM"
);
time
=
Convert
.
ToDateTime
(
date
)
.
ToString
(
"yyyy-MM"
);
}
}
else
else
{
{
time
=
DateTime
.
Now
.
AddMonths
(-
1
).
ToString
(
"yyyy-MM"
);
time
=
DateTime
.
Now
.
AddMonths
(-
1
).
ToString
(
"yyyy-MM"
);
}
}
var
falg
=
false
;
Console
.
WriteLine
(
$"
{
DateTime
.
Now
}
开始生成利润报表汇总数据"
);
var
sql
=
$"select * from dc_month_sales_profit_v2 where isedit != 1 and month = '
{
time
}
'"
;
var
sql
=
$"select * from dc_month_sales_profit_v2 where isedit != 1 and month = '
{
time
}
'"
;
var
oldData
=
SimpleCRUD
.
Query
<
dc_month_sales_profit_v2
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
FirstOrDefault
()
??
new
dc_month_sales_profit_v2
();
var
oldData
=
SimpleCRUD
.
Query
<
dc_month_sales_profit_v2
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
FirstOrDefault
();
//对旧表数据进行赋值新数据
if
(
oldData
==
null
)
//var field = new MonthSalesProfitDto();
{
//var name = field.amount_sales_jingyou.GetType().GetCustomAttribute<System.ComponentModel.DisplayNameAttribute>().DisplayName;
falg
=
true
;
//销售额
sql
=
$"select * from dc_month_sales_profit where isedit != 1 and month = '
{
time
}
'"
;
oldData
.
amount_sales_jingyou
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"精油产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
oldData
=
SimpleCRUD
.
Query
<
dc_month_sales_profit_v2
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
FirstOrDefault
();
oldData
.
amount_sales_dianzi
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"电子产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
}
oldData
.
amount_sales_jiaju
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"家居产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
if
(
oldData
!=
null
)
oldData
.
amount_sales_meirongmj
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"美容美甲产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
{
oldData
.
amount_sales_fuzhuang
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"服装"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
//对旧表数据进行赋值新数据
oldData
.
amount_sales_other
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"其他"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
//var field = new MonthSalesProfitDto();
oldData
.
fee_refund
=
Math
.
Abs
(
Math
.
Round
(
GetMonthProfitPlatformPlatformSummary
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
}).
Data
.
Sum
(
x
=>
x
.
RefundRmb
.
Value
),
2
))
*
(-
1
);
//var name = field.amount_sales_jingyou.GetType().GetCustomAttribute<System.ComponentModel.DisplayNameAttribute>().DisplayName;
//总销售额
//销售额
oldData
.
amount_sales
=
Math
.
Round
(
oldData
.
amount_sales_dianzi
+
oldData
.
amount_sales_fuzhuang
+
oldData
.
amount_sales_jiaju
oldData
.
amount_sales_jingyou
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"精油产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
+
oldData
.
amount_sales_jingyou
+
oldData
.
amount_sales_meirongmj
+
oldData
.
amount_sales_other
+
oldData
.
fee_refund
,
2
);
oldData
.
amount_sales_dianzi
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"电子产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
//成本
oldData
.
amount_sales_jiaju
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"家居产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
oldData
.
cost_jingyou
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"精油产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
amount_sales_meirongmj
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"美容美甲产品"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
oldData
.
cost_dianzi
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"电子产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
amount_sales_fuzhuang
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"服装"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
oldData
.
cost_jiaju
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"家居产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
amount_sales_other
=
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"其他"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
);
oldData
.
cost_meirongmj
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"美容美甲产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
fee_refund
=
Math
.
Abs
(
Math
.
Round
(
GetMonthProfitPlatformPlatformSummary
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
}).
Data
.
Sum
(
x
=>
x
.
RefundRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
cost_fuzhuang
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"服装"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
//总销售额
oldData
.
cost_other
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"其他"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
amount_sales
=
Math
.
Round
(
oldData
.
amount_sales_dianzi
+
oldData
.
amount_sales_fuzhuang
+
oldData
.
amount_sales_jiaju
//总成本
+
oldData
.
amount_sales_jingyou
+
oldData
.
amount_sales_meirongmj
+
oldData
.
amount_sales_other
+
oldData
.
fee_refund
,
2
);
oldData
.
cost
=
Math
.
Round
(
oldData
.
cost_jingyou
+
oldData
.
cost_dianzi
+
oldData
.
cost_jiaju
//成本
+
oldData
.
cost_meirongmj
+
oldData
.
cost_fuzhuang
+
oldData
.
cost_other
,
2
);
oldData
.
cost_jingyou
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"精油产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
//平台费用
oldData
.
cost_dianzi
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"电子产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
cost_jiaju
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"家居产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
cost_meirongmj
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"美容美甲产品"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
cost_fuzhuang
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"服装"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
oldData
.
cost_other
=
Math
.
Abs
(
Math
.
Round
(
GetMonthSalesProfiOrderSummary
(
time
,
"其他"
,
"成本"
).
Sum
(
x
=>
x
.
total_amount_sales
),
2
))
*
(-
1
);
//总成本
oldData
.
cost
=
Math
.
Round
(
oldData
.
cost_jingyou
+
oldData
.
cost_dianzi
+
oldData
.
cost_jiaju
+
oldData
.
cost_meirongmj
+
oldData
.
cost_fuzhuang
+
oldData
.
cost_other
,
2
);
//平台费用
//oldData.fee_ad = Math.Round(SyncMonthProfitFeePlatformFeeSummary(
//oldData.fee_ad = Math.Round(SyncMonthProfitFeePlatformFeeSummary(
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" }), 2);
// new GetMonthProfitPlatformDetailInput { Month = time, FeeName = "广告及宣传费" }), 2);
oldData
.
fee_ad
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_ad
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"广告及宣传费"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"广告及宣传费"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_fba
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_fba
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-亚马逊FBA"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-亚马逊FBA"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_nofba
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_nofba
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-亚马逊非FBA"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-亚马逊非FBA"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_ebay
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_ebay
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-Ebay"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-Ebay"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_ohtre
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_ohtre
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-其他平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"佣金及平台费-其他平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
//总平台费
//总平台费
oldData
.
fee_platform
=
Math
.
Round
(
oldData
.
fee_ad
+
oldData
.
fee_fba
+
oldData
.
fee_nofba
+
oldData
.
fee_ebay
+
oldData
.
fee_ohtre
,
2
);
oldData
.
fee_platform
=
Math
.
Round
(
oldData
.
fee_ad
+
oldData
.
fee_fba
+
oldData
.
fee_nofba
+
oldData
.
fee_ebay
+
oldData
.
fee_ohtre
,
2
);
//物流仓储费用
//物流仓储费用
oldData
.
fee_logistics_first
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_logistics_first
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"头程运输-平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"头程运输-平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_nologistics_first
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_nologistics_first
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"头程运输-非平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"头程运输-非平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_logistics_tail
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_logistics_tail
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"尾程物流费-平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"尾程物流费-平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_nologistics_tail
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_nologistics_tail
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"尾程物流费-非平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"尾程物流费-非平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_logistics_direct
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_logistics_direct
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"直邮物流费-平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"直邮物流费-平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_nologistics_direct
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_nologistics_direct
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"直邮物流费-非平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"直邮物流费-非平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_storage
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_storage
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"仓储费-平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"仓储费-平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
oldData
.
fee_nostorage
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_nostorage
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"仓储费-非平台"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"仓储费-非平台"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
//总物流仓储费
//总物流仓储费
oldData
.
fee_logistics_storage
=
Math
.
Round
(
oldData
.
fee_logistics_first
+
oldData
.
fee_nologistics_first
+
oldData
.
fee_logistics_tail
+
oldData
.
fee_nologistics_tail
oldData
.
fee_logistics_storage
=
Math
.
Round
(
oldData
.
fee_logistics_first
+
oldData
.
fee_nologistics_first
+
oldData
.
fee_logistics_tail
+
oldData
.
fee_nologistics_tail
+
oldData
.
fee_logistics_direct
+
oldData
.
fee_nologistics_direct
+
oldData
.
fee_storage
+
oldData
.
fee_nostorage
,
2
);
+
oldData
.
fee_logistics_direct
+
oldData
.
fee_nologistics_direct
+
oldData
.
fee_storage
+
oldData
.
fee_nostorage
,
2
);
//加:营业外收入
//加:营业外收入
oldData
.
incoming_non_operating
=
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
incoming_non_operating
=
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"营业外收入"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"营业外收入"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
);
//减:营业外支出
//减:营业外支出
oldData
.
pay_non_operating
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
pay_non_operating
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"营业外支出"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"营业外支出"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
//销售费用-税金
//销售费用-税金
oldData
.
fee_sales_taxes
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
oldData
.
fee_sales_taxes
=
Math
.
Abs
(
Math
.
Round
(
ExportMonthProfitFeePlatformFeeDetail
(
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"税金"
})
new
GetMonthProfitPlatformDetailInput
{
Month
=
time
,
FeeName
=
"税金"
})
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
.
Where
(
m
=>
m
.
AmountValRmb
!=
null
).
Sum
(
x
=>
x
.
AmountValRmb
.
Value
),
2
))
*
(-
1
);
//其中:歌戈儿收入
//其中:歌戈儿收入
var
operating
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"其中:歌戈儿收入"
).
Data
;
var
operating
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"其中:歌戈儿收入"
).
Data
;
oldData
.
incoming_gogirl
=
Math
.
Round
(
operating
.
Count
==
0
?
0
:
operating
.
Last
().
AmountRmb
.
Value
,
2
);
oldData
.
incoming_gogirl
=
Math
.
Round
(
operating
.
Count
==
0
?
0
:
operating
.
Last
().
AmountRmb
.
Value
,
2
);
//管理成本
//管理成本
var
bl_xg
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"香港百伦科技有限公司"
).
Data
;
var
bl_xg
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"香港百伦科技有限公司"
).
Data
;
var
bl_gz
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州百伦供应链科技有限公司"
).
Data
;
var
bl_gz
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州百伦供应链科技有限公司"
).
Data
;
var
meijia
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州歌戈儿生活科技有限公司"
).
Data
;
var
meijia
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州歌戈儿生活科技有限公司"
).
Data
;
var
yangshan
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"深圳前海扬杉创新科技有限公司"
).
Data
;
var
yangshan
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"深圳前海扬杉创新科技有限公司"
).
Data
;
var
xinhuilan
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州信荟蓝科技有限公司"
).
Data
;
var
xinhuilan
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州信荟蓝科技有限公司"
).
Data
;
var
gzdz
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州电子服装仓"
).
Data
;
var
gzdz
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州电子服装仓"
).
Data
;
var
ys
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"阳山仓"
).
Data
;
var
ys
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"阳山仓"
).
Data
;
var
dizhi
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州迪致美容科技有限公司"
).
Data
;
var
dizhi
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州迪致美容科技有限公司"
).
Data
;
var
gzlk
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州灵酷跨境科技有限公司"
).
Data
;
var
gzlk
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州灵酷跨境科技有限公司"
).
Data
;
var
gzcy
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州崇瑜信息技术咨询有限公司"
).
Data
;
var
gzcy
=
GetMonthProfitFeeManagementCostDetail
(
time
,
"广州崇瑜信息技术咨询有限公司"
).
Data
;
oldData
.
managecost_bl_xg
=
Math
.
Abs
(
Math
.
Round
(
bl_xg
.
Count
==
0
?
0
:
bl_xg
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managecost_bl_xg
=
Math
.
Abs
(
Math
.
Round
(
bl_xg
.
Count
==
0
?
0
:
bl_xg
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managecost_bl_gz
=
Math
.
Abs
(
Math
.
Round
(
bl_gz
.
Count
==
0
?
0
:
bl_gz
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managecost_bl_gz
=
Math
.
Abs
(
Math
.
Round
(
bl_gz
.
Count
==
0
?
0
:
bl_gz
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managecost_meijia
=
Math
.
Abs
(
Math
.
Round
(
meijia
.
Count
==
0
?
0
:
meijia
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managecost_meijia
=
Math
.
Abs
(
Math
.
Round
(
meijia
.
Count
==
0
?
0
:
meijia
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_yangshan
=
Math
.
Abs
(
Math
.
Round
(
yangshan
.
Count
==
0
?
0
:
yangshan
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_yangshan
=
Math
.
Abs
(
Math
.
Round
(
yangshan
.
Count
==
0
?
0
:
yangshan
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_xinhuilan
=
Math
.
Abs
(
Math
.
Round
(
xinhuilan
.
Count
==
0
?
0
:
xinhuilan
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_xinhuilan
=
Math
.
Abs
(
Math
.
Round
(
xinhuilan
.
Count
==
0
?
0
:
xinhuilan
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzdz
=
Math
.
Abs
(
Math
.
Round
(
gzdz
.
Count
==
0
?
0
:
gzdz
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzdz
=
Math
.
Abs
(
Math
.
Round
(
gzdz
.
Count
==
0
?
0
:
gzdz
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_ys
=
Math
.
Abs
(
Math
.
Round
(
ys
.
Count
==
0
?
0
:
ys
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_ys
=
Math
.
Abs
(
Math
.
Round
(
ys
.
Count
==
0
?
0
:
ys
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_dizhi
=
Math
.
Abs
(
Math
.
Round
(
dizhi
.
Count
==
0
?
0
:
dizhi
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_dizhi
=
Math
.
Abs
(
Math
.
Round
(
dizhi
.
Count
==
0
?
0
:
dizhi
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzlk
=
Math
.
Abs
(
Math
.
Round
(
gzlk
.
Count
==
0
?
0
:
gzlk
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzlk
=
Math
.
Abs
(
Math
.
Round
(
gzlk
.
Count
==
0
?
0
:
gzlk
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzcy
=
Math
.
Abs
(
Math
.
Round
(
gzcy
.
Count
==
0
?
0
:
gzcy
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
oldData
.
managercost_gzcy
=
Math
.
Abs
(
Math
.
Round
(
gzcy
.
Count
==
0
?
0
:
gzcy
.
Last
().
AmountRmb
.
Value
,
2
))
*
(-
1
);
//总管理成本
//总管理成本
oldData
.
managercost_count
=
Math
.
Round
(
oldData
.
managecost_bl_xg
+
oldData
.
managecost_bl_gz
+
oldData
.
managecost_meijia
+
oldData
.
managercost_yangshan
oldData
.
managercost_count
=
Math
.
Round
(
oldData
.
managecost_bl_xg
+
oldData
.
managecost_bl_gz
+
oldData
.
managecost_meijia
+
oldData
.
managercost_yangshan
+
oldData
.
managercost_xinhuilan
+
oldData
.
managercost_gzdz
+
oldData
.
managercost_ys
+
oldData
.
managercost_dizhi
+
oldData
.
managercost_gzlk
+
oldData
.
managercost_xinhuilan
+
oldData
.
managercost_gzdz
+
oldData
.
managercost_ys
+
oldData
.
managercost_dizhi
+
oldData
.
managercost_gzlk
+
oldData
.
managercost_gzcy
,
2
);
+
oldData
.
managercost_gzcy
,
2
);
//oldData.profit_sales = Math.Round(GetMonthSalesProfitDetail(new MonthProfitOrderDetailPageInputDto { Month = time }, false)
//oldData.profit_sales = Math.Round(GetMonthSalesProfitDetail(new MonthProfitOrderDetailPageInputDto { Month = time }, false)
//.Data.Data.Sum(x => x.sale_profit), 2);
//.Data.Data.Sum(x => x.sale_profit), 2);
//销售费用合计》平台费用+物流仓储费+税金
//销售费用合计》平台费用+物流仓储费+税金
oldData
.
fee_sales_count
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
fee_platform
)
+
Math
.
Abs
(
oldData
.
fee_logistics_storage
)
+
Math
.
Abs
(
oldData
.
fee_sales_taxes
),
2
);
oldData
.
fee_sales_count
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
fee_platform
)
+
Math
.
Abs
(
oldData
.
fee_logistics_storage
)
+
Math
.
Abs
(
oldData
.
fee_sales_taxes
),
2
);
//销售利润》总销售额-总成本-销售费用合计
//销售利润》总销售额-总成本-销售费用合计
oldData
.
profit_sales
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
amount_sales
)
-
Math
.
Abs
(
oldData
.
cost
)
-
Math
.
Abs
(
oldData
.
fee_sales_count
),
2
);
oldData
.
profit_sales
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
amount_sales
)
-
Math
.
Abs
(
oldData
.
cost
)
-
Math
.
Abs
(
oldData
.
fee_sales_count
),
2
);
//销售毛利润》销售利润/总销售额
//销售毛利润》销售利润/总销售额
oldData
.
rate_profit_sales
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
profit_sales
)
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
oldData
.
rate_profit_sales
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
profit_sales
)
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
//营业利润》销售利润-总管理成本
//营业利润》销售利润-总管理成本
oldData
.
profit
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
profit_sales
)
-
Math
.
Abs
(
oldData
.
managercost_count
),
2
);
oldData
.
profit
=
Math
.
Round
(
Math
.
Abs
(
oldData
.
profit_sales
)
-
Math
.
Abs
(
oldData
.
managercost_count
),
2
);
//营业毛利率》营业利润/总销售额
//营业毛利率》营业利润/总销售额
oldData
.
rate_profit
=
Math
.
Round
(
oldData
.
profit
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
oldData
.
rate_profit
=
Math
.
Round
(
oldData
.
profit
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
//实际利润》营业利润+加:其他收入+加:营业外收入+减:营业外支出
//实际利润》营业利润+加:其他收入+加:营业外收入+减:营业外支出
oldData
.
actual_profit
=
Math
.
Round
(
oldData
.
profit
+
Math
.
Abs
(
oldData
.
incoming_other
)
+
Math
.
Abs
(
oldData
.
incoming_non_operating
)
+
Math
.
Abs
(
oldData
.
pay_non_operating
),
2
);
oldData
.
actual_profit
=
Math
.
Round
(
oldData
.
profit
+
Math
.
Abs
(
oldData
.
incoming_other
)
+
Math
.
Abs
(
oldData
.
incoming_non_operating
)
+
Math
.
Abs
(
oldData
.
pay_non_operating
),
2
);
//净利润》实际利润/总销售额
//净利润》实际利润/总销售额
oldData
.
rate_profit_actual
=
Math
.
Round
(
oldData
.
actual_profit
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
oldData
.
rate_profit_actual
=
Math
.
Round
(
oldData
.
actual_profit
/
Math
.
Abs
(
oldData
.
amount_sales
),
2
);
//保存
//保存
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
if
(
cn
.
State
==
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
if
(
oldData
.
id
>
0
)
{
oldData
.
lastupdatetime
=
DateTime
.
Now
;
cn
.
Update
(
oldData
);
}
else
{
{
oldData
.
createtime
=
DateTime
.
Now
;
if
(
cn
.
State
==
ConnectionState
.
Closed
)
oldData
.
lastupdatetime
=
DateTime
.
Now
;
{
cn
.
Insert
(
oldData
);
cn
.
Open
();
}
if
(
falg
)
{
oldData
.
createtime
=
DateTime
.
Now
;
oldData
.
lastupdatetime
=
DateTime
.
Now
;
cn
.
Insert
(
oldData
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
}
触发了新增操作"
);
}
else
{
if
(
oldData
.
id
>
0
)
{
oldData
.
lastupdatetime
=
DateTime
.
Now
;
cn
.
Update
(
oldData
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
}
触发了更新操作"
);
}
else
{
oldData
.
createtime
=
DateTime
.
Now
;
oldData
.
lastupdatetime
=
DateTime
.
Now
;
cn
.
Insert
(
oldData
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
}
触发了新增操作"
);
}
}
}
}
Console
.
WriteLine
(
$"
{
DateTime
.
Now
}
开始生成利润报表汇总数据"
);
}
}
return
true
;
return
true
;
}
}
...
...
Bailun.DC.WebApi/Controllers/FinanceController.cs
View file @
cb59d780
...
@@ -547,7 +547,7 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -547,7 +547,7 @@ namespace Bailun.DC.WebApi.Controllers
/// <param name="time"></param>
/// <param name="time"></param>
/// <returns></returns>
/// <returns></returns>
[
HttpGet
(
"syncMonthSalesProfit"
)]
[
HttpGet
(
"syncMonthSalesProfit"
)]
public
bool
SyncMonthSalesProfit
(
DateTime
?
time
)
public
bool
SyncMonthSalesProfit
(
string
time
)
{
{
return
new
FinanceService
().
SyncMonthSalesProfit
(
time
);
return
new
FinanceService
().
SyncMonthSalesProfit
(
time
);
//var sql = "select * from dc_month_sales_profit_orderdetail limit 1";
//var sql = "select * from dc_month_sales_profit_orderdetail limit 1";
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment