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
ebb575d5
Commit
ebb575d5
authored
Aug 06, 2021
by
zhoujinhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增月销售利润报表接口
parent
7d4be65e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
746 additions
and
25 deletions
+746
-25
ParentNameAttribute.cs
...n.DC.Models/WebApiModels/Attribute/ParentNameAttribute.cs
+102
-0
MonthSalesProfitDto.cs
Bailun.DC.Models/WebApiModels/MonthSalesProfitDto.cs
+307
-0
FinanceService.cs
Bailun.DC.Services/WebApiService/FinanceService.cs
+19
-0
BaseController.cs
Bailun.DC.WebApi/Controllers/BaseController.cs
+2
-1
FinanceController.cs
Bailun.DC.WebApi/Controllers/FinanceController.cs
+222
-24
MonthSalesProfitResponse.cs
Bailun.DC.WebApi/Models/Finance/MonthSalesProfitResponse.cs
+94
-0
No files found.
Bailun.DC.Models/WebApiModels/Attribute/ParentNameAttribute.cs
0 → 100644
View file @
ebb575d5
using
System.ComponentModel
;
namespace
Bailun.DC.Models.WebApiModels
{
/// <summary>
/// 上级名称特性
/// </summary>
public
class
ParentNameAttribute
:
DisplayNameAttribute
{
/// <summary>
///
/// </summary>
public
override
string
DisplayName
{
get
;
}
/// <summary>
/// 上级名称
/// </summary>
public
ParentNameEnum
?
ParentName
{
get
;
}
/// <summary>
///
/// </summary>
/// <param name="displayName"></param>
public
ParentNameAttribute
(
string
displayName
)
{
DisplayName
=
displayName
;
}
/// <summary>
///
/// </summary>
/// <param name="displayName"></param>
/// <param name="parentName"></param>
public
ParentNameAttribute
(
string
displayName
,
ParentNameEnum
parentName
)
{
DisplayName
=
displayName
;
ParentName
=
parentName
;
}
}
/// <summary>
///
/// </summary>
public
enum
ParentNameEnum
{
None
=
0
,
/// <summary>
/// 销售额
/// </summary>
[
Description
(
"销售额"
)]
amount_sales
=
1
,
/// <summary>
/// 成本
/// </summary>
[
Description
(
"成本"
)]
cost
=
2
,
/// <summary>
/// 平台费
/// </summary>
[
Description
(
"平台费"
)]
fee_platform
=
3
,
/// <summary>
/// 仓储费
/// </summary>
[
Description
(
"仓储费"
)]
fee_logistics_storage
=
4
,
/// <summary>
/// 销售费用合计
/// </summary>
[
Description
(
"销售费用合计"
)]
fee_sales_count
=
5
,
/// <summary>
/// 管理成本合计
/// </summary>
[
Description
(
"管理成本合计"
)]
managercost_count
=
6
,
/// <summary>
/// 营业利润
/// </summary>
[
Description
(
"营业利润"
)]
profit
=
7
,
/// <summary>
/// 实际利润
/// </summary>
[
Description
(
"实际利润"
)]
actual_profit
=
8
,
/// <summary>
/// 净利率
/// </summary>
[
Description
(
"净利率"
)]
rate_profit_actual
=
9
}
}
Bailun.DC.Models/WebApiModels/MonthSalesProfitDto.cs
0 → 100644
View file @
ebb575d5
using
System.ComponentModel
;
namespace
Bailun.DC.Models.WebApiModels
{
/// <summary>
/// 预计销售利润表
/// </summary>
public
class
MonthSalesProfitDto
{
/// <summary>
/// auto_increment
/// </summary>
[
ParentName
(
"id"
)]
public
int
id
{
get
;
set
;
}
/// <summary>
/// 月份
/// </summary>
[
ParentName
(
"月份"
)]
public
string
month
{
get
;
set
;
}
/// <summary>
/// 总销售额
/// </summary>
[
ParentName
(
"销售额"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales
{
get
;
set
;
}
/// <summary>
/// 销售额-精油
/// </summary>
[
ParentName
(
"精油产品"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_jingyou
{
get
;
set
;
}
/// <summary>
/// 销售额-电子
/// </summary>
[
ParentName
(
"电子产品"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_dianzi
{
get
;
set
;
}
/// <summary>
/// 销售额-家居产品
/// </summary>
[
ParentName
(
"家居产品"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_jiaju
{
get
;
set
;
}
/// <summary>
/// 销售额-美容美甲产品
/// </summary>
[
ParentName
(
"美容美甲产品"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_meirongmj
{
get
;
set
;
}
/// <summary>
/// 销售额-服装
/// </summary>
[
ParentName
(
"服装"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_fuzhuang
{
get
;
set
;
}
/// <summary>
/// 销售额-其他
/// </summary>
[
ParentName
(
"其他"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
amount_sales_other
{
get
;
set
;
}
/// 平台退款
/// </summary>
[
ParentName
(
"退款"
,
ParentNameEnum
.
amount_sales
)]
public
decimal
fee_refund
{
get
;
set
;
}
/// <summary>
/// 总成本
/// </summary>
[
ParentName
(
"成本"
,
ParentNameEnum
.
cost
)]
public
decimal
cost
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 精油成本
/// </summary>
[
ParentName
(
"精油产品"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_jingyou
{
get
;
set
;
}
/// <summary>
/// 电子成本
/// </summary>
[
ParentName
(
"电子产品"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_dianzi
{
get
;
set
;
}
/// <summary>
/// 家居成本
/// </summary>
[
ParentName
(
"家居产品"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_jiaju
{
get
;
set
;
}
/// <summary>
/// 美容美甲产品成本
/// </summary>
[
ParentName
(
"美容美甲产品"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_meirongmj
{
get
;
set
;
}
/// <summary>
/// 服装成本
/// </summary>
[
ParentName
(
"服装"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_fuzhuang
{
get
;
set
;
}
/// <summary>
/// 其他成本
/// </summary>
[
ParentName
(
"其它"
,
ParentNameEnum
.
cost
)]
public
decimal
cost_other
{
get
;
set
;
}
/// <summary>
/// 平台费
/// </summary>
[
ParentName
(
"平台费用"
,
ParentNameEnum
.
fee_platform
)]
public
decimal
fee_platform
{
get
;
set
;
}
/// <summary>
/// 平台扣费及退款
/// </summary>
[
ParentName
(
"平台费"
,
ParentNameEnum
.
fee_platform
)]
public
decimal
fee_platform_and_refund
{
get
;
set
;
}
/// <summary>
/// FBA费
/// </summary>
[
ParentName
(
"FBA费"
,
ParentNameEnum
.
fee_platform
)]
public
decimal
fee_fba
{
get
;
set
;
}
/// <summary>
/// 广告及宣传费用
/// </summary>
[
ParentName
(
"广告及宣传费"
,
ParentNameEnum
.
fee_platform
)]
public
decimal
fee_ad
{
get
;
set
;
}
/// <summary>
/// 物流仓储费用
/// </summary>
[
ParentName
(
"物流仓储费用"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_logistics_storage
{
get
;
set
;
}
///// <summary>
///// 平台提现回款
///// </summary>
//public decimal amount_withdraw { get; set; }
/// <summary>
/// 头程费
/// </summary>
[
ParentName
(
"头程费"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_logistics_first
{
get
;
set
;
}
/// <summary>
/// 直邮物流费 国内发货
/// </summary>
[
ParentName
(
"直邮物流费"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_logistics_direct
{
get
;
set
;
}
/// <summary>
/// 尾程费 国外发货
/// </summary>
[
ParentName
(
"尾程物流费"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_logistics_tail
{
get
;
set
;
}
/// <summary>
/// 海外仓仓储
/// </summary>
[
ParentName
(
"海外仓仓储费"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_storage
{
get
;
set
;
}
/// <summary>
/// 海外仓其他杂费
/// </summary>
[
ParentName
(
"海外仓其他杂费"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_storage_incidentals
{
get
;
set
;
}
/// <summary>
/// 付现销售费用
/// </summary>
[
ParentName
(
"付现销售费用"
,
ParentNameEnum
.
fee_logistics_storage
)]
public
decimal
fee_paycash_sales
{
get
;
set
;
}
/// <summary>
/// 销售费用合计
/// </summary>
[
ParentName
(
"销售费用合计"
,
ParentNameEnum
.
fee_sales_count
)]
public
decimal
fee_sales_count
{
get
;
set
;
}
/// <summary>
/// 销售利润
/// </summary>
[
ParentName
(
"销售利润"
,
ParentNameEnum
.
fee_sales_count
)]
public
decimal
profit_sales
{
get
;
set
;
}
/// <summary>
/// 销售毛利率
/// </summary>
[
ParentName
(
"销售毛利率"
,
ParentNameEnum
.
fee_sales_count
)]
public
decimal
rate_profit_sales
{
get
;
set
;
}
/// <summary>
/// 财务费用
/// </summary>
[
ParentName
(
"财务费用"
,
ParentNameEnum
.
fee_sales_count
)]
public
decimal
fee_finance
{
get
;
set
;
}
/// <summary>
/// 管理成本合计
/// </summary>
[
ParentName
(
"管理成本合计"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managercost_count
{
get
;
set
;
}
///// <summary>
///// 管理成本-香港百伦
///// </summary>
//[ParentName("香港百伦科技有限公司")]
//public decimal managecost_bl_xg { get; set; }
/// <summary>
/// 管理成本-广州百伦
/// </summary>
[
ParentName
(
"广州百伦供应链科技有限公司"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managecost_bl_gz
{
get
;
set
;
}
/// <summary>
/// 管理成本-美容美甲店
/// </summary>
[
ParentName
(
"广州歌戈儿生活科技有限公司"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managecost_meijia
{
get
;
set
;
}
/// <summary>
/// 管理成本-杨杉
/// </summary>
[
ParentName
(
"深圳前海扬杉创新科技有限公司"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managercost_yangshan
{
get
;
set
;
}
/// <summary>
/// 管理成本-成品仓
/// </summary>
[
ParentName
(
"广州电子服装仓&阳山"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managercost_chengpincang
{
get
;
set
;
}
/// <summary>
/// 管理成本-信荟蓝
/// </summary>
[
ParentName
(
"广州信荟蓝科技有限公司"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managercost_xinhuilan
{
get
;
set
;
}
/// <summary>
/// 迪致美容
/// </summary>
[
ParentName
(
"广州迪致美容科技有限公司"
,
ParentNameEnum
.
managercost_count
)]
public
decimal
managercost_dizhi
{
get
;
set
;
}
///// <summary>
///// 广州美甲生产仓
///// </summary>
//public decimal managercost_meijiashengchan { get; set; }
/// <summary>
/// 营业利润
/// </summary>
[
ParentName
(
"营业利润"
,
ParentNameEnum
.
profit
)]
public
decimal
profit
{
get
;
set
;
}
/// <summary>
/// 营业毛利率
/// </summary>
[
ParentName
(
"营业毛利率"
,
ParentNameEnum
.
profit
)]
public
decimal
rate_profit
{
get
;
set
;
}
/// <summary>
/// 加:其他收入
/// </summary>
[
ParentName
(
"加:其他收入"
,
ParentNameEnum
.
profit
)]
public
decimal
incoming_other
{
get
;
set
;
}
/// <summary>
/// 加:出口退税收入
/// </summary>
[
ParentName
(
"其中:出口退税收入"
,
ParentNameEnum
.
profit
)]
public
decimal
incoming_refundtax
{
get
;
set
;
}
/// <summary>
/// 加:歌戈尔收入
/// </summary>
[
ParentName
(
"其中:歌戈儿收入"
,
ParentNameEnum
.
profit
)]
public
decimal
incoming_gogirl
{
get
;
set
;
}
/// <summary>
/// 加:营业外收入
/// </summary>
[
ParentName
(
"加:营业外收入"
,
ParentNameEnum
.
profit
)]
public
decimal
incoming_non_operating
{
get
;
set
;
}
/// <summary>
/// 减:营业外支出
/// </summary>
[
ParentName
(
"减:营业外支出"
,
ParentNameEnum
.
profit
)]
public
decimal
pay_non_operating
{
get
;
set
;
}
/// <summary>
/// 减:资产减值损失
/// </summary>
[
ParentName
(
"减:资产减值损失"
,
ParentNameEnum
.
profit
)]
public
decimal
?
impairment_assets
{
get
;
set
;
}
/// <summary>
/// 实际利润
/// </summary>
[
ParentName
(
"实际利润"
,
ParentNameEnum
.
actual_profit
)]
public
decimal
actual_profit
{
get
;
set
;
}
/// <summary>
/// 净利润率
/// </summary>
[
ParentName
(
"净利率"
,
ParentNameEnum
.
rate_profit_actual
)]
public
decimal
rate_profit_actual
{
get
;
set
;
}
///// <summary>
///// 减:分红
///// </summary>
//public decimal dividend { get; set; }
///// <summary>
///// 利润结余
///// </summary>
//public decimal profit_balance { get; set; }
/// <summary>
/// 是否编辑的版本,1:是,0:否, 2 汇总
/// </summary>
public
int
isedit
{
get
;
set
;
}
}
}
Bailun.DC.Services/WebApiService/FinanceService.cs
View file @
ebb575d5
...
@@ -10,6 +10,7 @@ using MySql.Data.MySqlClient;
...
@@ -10,6 +10,7 @@ using MySql.Data.MySqlClient;
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Net.Http
;
using
System.Text
;
using
System.Text
;
...
@@ -436,5 +437,23 @@ and s1.management_cost_name = @managementcostname";
...
@@ -436,5 +437,23 @@ and s1.management_cost_name = @managementcostname";
jsonStr
+=
"]"
;
jsonStr
+=
"]"
;
return
(
colList
,
jsonStr
);
return
(
colList
,
jsonStr
);
}
}
/// <summary>
/// 月度利润报表
/// </summary>
/// <param name="start">开始月份</param>
/// <param name="end">结束月份</param>
/// <returns></returns>
public
List
<
MonthSalesProfitDto
>
ListMonthSaleProfitNew
(
string
start
,
string
end
)
{
var
sql
=
$"select * from dc_month_sales_profit where month>='
{
start
}
' "
;
if
(!
string
.
IsNullOrEmpty
(
end
))
{
sql
+=
(
" and month<='"
+
end
+
"'"
);
}
var
data
=
SimpleCRUD
.
Query
<
MonthSalesProfitDto
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
ToList
();
return
data
;
}
}
}
}
}
Bailun.DC.WebApi/Controllers/BaseController.cs
View file @
ebb575d5
...
@@ -15,7 +15,8 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -15,7 +15,8 @@ namespace Bailun.DC.WebApi.Controllers
/// <param name="list"></param>
/// <param name="list"></param>
/// <param name="columns"></param>
/// <param name="columns"></param>
/// <param name="tbName"></param>
/// <param name="tbName"></param>
public
void
ToCSV
(
List
<
string
>
list
,
List
<
string
>
columns
,
string
tbName
,
string
filePath
)
[
NonAction
]
protected
void
ToCSV
(
List
<
string
>
list
,
List
<
string
>
columns
,
string
tbName
,
string
filePath
)
{
{
var
strb
=
string
.
Empty
;
var
strb
=
string
.
Empty
;
...
...
Bailun.DC.WebApi/Controllers/FinanceController.cs
View file @
ebb575d5
using
Bailun.DC.Models
;
using
Bailun.DC.Models.Common
;
using
Bailun.DC.Models.Common
;
using
Bailun.DC.Models.Common.Page
;
using
Bailun.DC.Models.Dtos.Finance
;
using
Bailun.DC.Models.Dtos.Finance
;
using
Bailun.DC.
Service
s
;
using
Bailun.DC.
Models.WebApiModel
s
;
using
Bailun.DC.Services.WebApiService
;
using
Bailun.DC.Services.WebApiService
;
using
Bailun.DC.WebApi.
Attribute
;
using
Bailun.DC.WebApi.
Models
;
using
Bailun.ServiceFabric.Authorize
;
using
Bailun.ServiceFabric.Authorize
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
namespace
Bailun.DC.WebApi.Controllers
namespace
Bailun.DC.WebApi.Controllers
{
{
...
@@ -29,19 +30,6 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -29,19 +30,6 @@ namespace Bailun.DC.WebApi.Controllers
}
}
/// <summary>
/// <summary>
/// 测试
/// </summary>
/// <returns></returns>
[
BailunAuthentication
(
LoginMode
.
Enforce
)]
[
HttpPost
]
[
BrowseLog
(
"Bailun_data"
,
"访问【百伦数据中心】->【财务报表】->【资产负债表】->【查询】页面"
,
0
)]
public
CommonApiResponseDto
<
List
<
dc_base_finance_fee
>>
Test
()
{
var
list
=
new
Services
.
FinanceReportServices
().
ListFinanceFee
(
DateTime
.
Now
.
AddDays
(-
5
),
DateTime
.
Now
,
""
,
""
,
""
,
null
,
null
);
return
new
CommonApiResponseDto
<
List
<
dc_base_finance_fee
>>
{
Data
=
list
,
IsSuccess
=
true
};
}
/// <summary>
/// 获取付现流水报表
/// 获取付现流水报表
/// </summary>
/// </summary>
/// <param name="input"></param>
/// <param name="input"></param>
...
@@ -78,11 +66,11 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -78,11 +66,11 @@ namespace Bailun.DC.WebApi.Controllers
var
list
=
new
List
<
string
>();
var
list
=
new
List
<
string
>();
foreach
(
var
item
in
dataList
)
foreach
(
var
item
in
dataList
)
{
{
list
.
Add
(
item
.
cost_no
+
"|"
+
item
.
company_name
+
"|"
+
item
.
type_name
+
"|"
+
item
.
amount
+
"|"
+
item
.
amount_rmb
+
"|"
+
item
.
cost_reason
+
"|"
+
list
.
Add
(
item
.
cost_no
+
"|"
+
item
.
company_name
+
"|"
+
item
.
type_name
+
"|"
+
item
.
amount
+
"|"
+
item
.
amount_rmb
+
"|"
+
item
.
cost_reason
+
"|"
+
item
.
type_name
+
"|"
+
item
.
kind_name
+
"|"
+
item
.
bank_card_user
+
"|"
+
item
.
bank_company
+
"|"
+
item
.
accounting_subject_name
+
"|"
+
item
.
type_name
+
"|"
+
item
.
kind_name
+
"|"
+
item
.
bank_card_user
+
"|"
+
item
.
bank_company
+
"|"
+
item
.
accounting_subject_name
+
"|"
+
item
.
audit_time
+
"|"
+(
item
.
pay_time
.
HasValue
?
item
.
pay_time
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
):
string
.
Empty
)
+
"|"
+
item
.
audit_time
+
"|"
+
(
item
.
pay_time
.
HasValue
?
item
.
pay_time
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
string
.
Empty
)
+
"|"
+
(
item
.
last_modify_date
.
HasValue
?
item
.
last_modify_date
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
string
.
Empty
)
+
"|"
+
(
item
.
last_modify_date
.
HasValue
?
item
.
last_modify_date
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
string
.
Empty
)
+
"|"
+
item
.
department_name
+
"|"
+
item
.
create_username
+
"|"
+
(
item
.
create_time
.
HasValue
?
item
.
create_time
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
string
.
Empty
));
item
.
department_name
+
"|"
+
item
.
create_username
+
"|"
+
(
item
.
create_time
.
HasValue
?
item
.
create_time
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
string
.
Empty
));
}
}
var
guid
=
Guid
.
NewGuid
().
ToString
();
var
guid
=
Guid
.
NewGuid
().
ToString
();
var
filepath
=
_hostingEnvironment
.
WebRootPath
+
"\\Files\\Report\\"
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
)
+
"\\"
;
var
filepath
=
_hostingEnvironment
.
WebRootPath
+
"\\Files\\Report\\"
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
)
+
"\\"
;
...
@@ -114,5 +102,215 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -114,5 +102,215 @@ namespace Bailun.DC.WebApi.Controllers
[
HttpPost
(
"getManagementCost"
)]
[
HttpPost
(
"getManagementCost"
)]
public
CommonApiResponseDto
<
FinanceDto
>
GetManagementCost
(
GetCashFlowStatementInput
input
)
public
CommonApiResponseDto
<
FinanceDto
>
GetManagementCost
(
GetCashFlowStatementInput
input
)
=>
new
FinanceService
().
GetManagementCost
(
input
);
=>
new
FinanceService
().
GetManagementCost
(
input
);
#
region
月销售利润
/// <summary>
/// 获取月销售利润
/// </summary>
/// <param name="month"></param>
/// <returns></returns>
[
HttpPost
(
"getListMonthSaleProfit"
)]
public
CommonApiResponseDto
<
MonthSalesProfitResponse
>
GetListMonthSaleProfit
(
string
month
)
{
var
result
=
new
CommonApiResponseDto
<
MonthSalesProfitResponse
>
{
Data
=
new
MonthSalesProfitResponse
()
};
if
(
string
.
IsNullOrWhiteSpace
(
month
))
{
result
.
Message
=
"月份不能空"
;
result
.
IsSuccess
=
false
;
return
result
;
}
var
newList
=
new
List
<
MonthSalesProfitDto
>();
var
dataList
=
new
FinanceService
().
ListMonthSaleProfitNew
(
month
,
null
);
var
noEditList
=
dataList
.
Where
(
x
=>
x
.
isedit
==
0
).
ToList
();
result
.
Data
.
Col
.
Add
(
new
MonthSalesProfitColumnsModel
{
Title
=
"项目"
,
Key
=
"Item"
});
foreach
(
var
item
in
noEditList
)
{
result
.
Data
.
Col
.
Add
(
new
MonthSalesProfitColumnsModel
{
Title
=
$"
{
item
.
month
}
月份"
,
Key
=
Guid
.
NewGuid
().
ToString
(
"N"
),
Children
=
new
List
<
MonthSalesProfitColumnsChildren
>
{
new
MonthSalesProfitColumnsChildren
{
Key
=
item
.
month
+
"-0"
,
Title
=
"月份基础数据"
},
new
MonthSalesProfitColumnsChildren
{
Key
=
item
.
month
+
"-1"
,
Title
=
$"月份调整数据"
},
new
MonthSalesProfitColumnsChildren
{
Key
=
item
.
month
+
"-2"
,
Title
=
$"月份合计数据"
}
}
});
newList
.
Add
(
item
);
MonthSaleProfitSupplement
(
newList
,
dataList
,
item
);
}
result
.
Data
.
DataJson
=
GetMonthSalesProfitDataJson
(
newList
,
out
List
<
string
>
excelList
);
return
result
;
}
/// <summary>
/// 生成json
/// </summary>
/// <param name="dataList"></param>
/// <param name="excelList"></param>
/// <returns></returns>
private
string
GetMonthSalesProfitDataJson
(
List
<
MonthSalesProfitDto
>
dataList
,
out
List
<
string
>
excelList
)
{
excelList
=
new
List
<
string
>();
if
(
dataList
.
Count
<=
0
)
return
"[]"
;
var
months
=
dataList
.
Where
(
x
=>
x
.
isedit
==
0
).
GroupBy
(
x
=>
x
.
month
).
ToList
();
StringBuilder
jsonStr
=
new
StringBuilder
();
string
excelItemStr
=
string
.
Empty
;
jsonStr
.
Append
(
"["
);
List
<
KeyDisplayNameModel
>
displayNameList
=
new
List
<
KeyDisplayNameModel
>();
PropertyInfo
[]
properties
=
dataList
.
First
().
GetType
().
GetProperties
(
BindingFlags
.
Instance
|
BindingFlags
.
Public
);
foreach
(
var
item
in
properties
)
{
var
displayName
=
item
.
GetCustomAttribute
<
ParentNameAttribute
>()?.
DisplayName
;
var
parentName
=
item
.
GetCustomAttribute
<
ParentNameAttribute
>()?.
ParentName
;
if
(
string
.
IsNullOrWhiteSpace
(
displayName
))
continue
;
displayNameList
.
Add
(
new
KeyDisplayNameModel
{
DisplayName
=
displayName
,
KeyName
=
item
.
Name
,
ParentName
=
parentName
});
}
var
firstList
=
displayNameList
.
Where
(
x
=>
x
.
KeyName
==
x
.
ParentName
.
ToString
()).
Distinct
().
ToList
();
var
str
=
string
.
Empty
;
foreach
(
var
item
in
displayNameList
)
{
if
(
item
.
KeyName
==
"id"
||
item
.
KeyName
==
"month"
)
continue
;
var
isFirst
=
firstList
.
Count
(
x
=>
x
.
ParentName
.
ToString
()
==
item
.
KeyName
)
>
0
?
1
:
0
;
jsonStr
.
Append
(
"{\"Item\":\""
+
item
.
DisplayName
+
"\",\"IsFirst\":"
+
isFirst
+
",\"FirstId\":\""
+
(
int
)
item
.
ParentName
+
"\","
);
excelItemStr
=
item
.
DisplayName
+
"|"
;
foreach
(
var
subItem
in
dataList
)
{
PropertyInfo
[]
propertiesValue
=
subItem
.
GetType
().
GetProperties
(
BindingFlags
.
Instance
|
BindingFlags
.
Public
);
var
amount_sales
=
propertiesValue
.
Where
(
x
=>
x
.
CustomAttributes
.
GetType
()
==
typeof
(
ParentNameAttribute
)
&&
x
.
GetCustomAttribute
<
ParentNameAttribute
>().
ParentName
==
ParentNameEnum
.
amount_sales
).
ToList
();
foreach
(
var
proItem
in
propertiesValue
)
{
if
(
proItem
.
Name
!=
item
.
KeyName
)
continue
;
object
value
=
proItem
.
GetValue
(
subItem
,
null
);
jsonStr
.
Append
(
"\""
+
subItem
.
month
+
"-"
+
subItem
.
isedit
+
"\": \""
+
value
+
"\","
);
excelItemStr
+=
value
+
"|"
;
}
}
excelItemStr
=
excelItemStr
.
TrimEnd
(
'|'
);
str
=
jsonStr
.
ToString
().
TrimEnd
(
','
);
jsonStr
.
Clear
();
jsonStr
.
Append
(
str
);
jsonStr
.
Append
(
"},"
);
excelList
.
Add
(
excelItemStr
);
}
str
=
jsonStr
.
ToString
().
TrimEnd
(
','
);
jsonStr
.
Clear
();
jsonStr
.
Append
(
str
);
jsonStr
.
Append
(
"]"
);
return
jsonStr
.
ToString
();
}
/// <summary>
/// 补充月销售利润空数据及合并计算
/// </summary>
/// <param name="newList"></param>
/// <param name="dataList"></param>
/// <param name="item"></param>
private
void
MonthSaleProfitSupplement
(
List
<
MonthSalesProfitDto
>
newList
,
List
<
MonthSalesProfitDto
>
dataList
,
MonthSalesProfitDto
item
)
{
var
editModel
=
dataList
.
Where
(
x
=>
x
.
month
==
item
.
month
&&
x
.
isedit
==
1
).
FirstOrDefault
();
if
(
editModel
==
null
)
{
newList
.
Add
(
new
MonthSalesProfitDto
{
month
=
item
.
month
,
isedit
=
1
});
newList
.
Add
(
new
MonthSalesProfitDto
{
month
=
item
.
month
,
isedit
=
2
});
return
;
}
newList
.
Add
(
editModel
);
newList
.
Add
(
new
MonthSalesProfitDto
{
month
=
item
.
month
,
amount_sales
=
editModel
.
amount_sales
+
item
.
amount_sales
,
amount_sales_jingyou
=
editModel
.
amount_sales_jingyou
+
item
.
amount_sales_jingyou
,
amount_sales_dianzi
=
editModel
.
amount_sales_dianzi
+
item
.
amount_sales_dianzi
,
amount_sales_jiaju
=
editModel
.
amount_sales_jiaju
+
item
.
amount_sales_jiaju
,
amount_sales_meirongmj
=
editModel
.
amount_sales_meirongmj
+
item
.
amount_sales_meirongmj
,
amount_sales_fuzhuang
=
editModel
.
amount_sales_fuzhuang
+
item
.
amount_sales_fuzhuang
,
amount_sales_other
=
editModel
.
amount_sales_other
+
item
.
amount_sales_other
,
fee_refund
=
editModel
.
fee_refund
+
item
.
fee_refund
,
cost
=
editModel
.
cost
+
item
.
cost
,
cost_jingyou
=
editModel
.
cost_jingyou
+
item
.
cost_jingyou
,
cost_dianzi
=
editModel
.
cost_dianzi
+
item
.
cost_dianzi
,
cost_jiaju
=
editModel
.
cost_jiaju
+
item
.
cost_jiaju
,
cost_meirongmj
=
editModel
.
cost_meirongmj
+
item
.
cost_meirongmj
,
cost_fuzhuang
=
editModel
.
cost_fuzhuang
+
item
.
cost_fuzhuang
,
cost_other
=
editModel
.
cost_other
+
item
.
cost_other
,
fee_platform
=
editModel
.
fee_platform
+
item
.
fee_platform
,
fee_platform_and_refund
=
editModel
.
fee_platform_and_refund
+
item
.
fee_platform_and_refund
,
fee_fba
=
editModel
.
fee_fba
+
item
.
fee_fba
,
fee_ad
=
editModel
.
fee_ad
+
item
.
fee_ad
,
fee_logistics_storage
=
editModel
.
fee_logistics_storage
+
item
.
fee_logistics_storage
,
fee_logistics_first
=
editModel
.
fee_logistics_first
+
item
.
fee_logistics_first
,
fee_logistics_direct
=
editModel
.
fee_logistics_direct
+
item
.
fee_logistics_direct
,
fee_logistics_tail
=
editModel
.
fee_logistics_tail
+
item
.
fee_logistics_tail
,
fee_storage
=
editModel
.
fee_storage
+
item
.
fee_storage
,
fee_storage_incidentals
=
editModel
.
fee_storage_incidentals
+
item
.
fee_storage_incidentals
,
fee_paycash_sales
=
editModel
.
fee_paycash_sales
+
item
.
fee_paycash_sales
,
fee_sales_count
=
editModel
.
fee_sales_count
+
item
.
fee_sales_count
,
profit_sales
=
editModel
.
profit_sales
+
item
.
profit_sales
,
rate_profit_sales
=
editModel
.
rate_profit_sales
+
item
.
rate_profit_sales
,
fee_finance
=
editModel
.
fee_finance
+
item
.
fee_finance
,
managercost_count
=
editModel
.
managercost_count
+
item
.
managercost_count
,
managecost_bl_gz
=
editModel
.
managecost_bl_gz
+
item
.
managecost_bl_gz
,
managecost_meijia
=
editModel
.
managecost_meijia
+
item
.
managecost_meijia
,
managercost_yangshan
=
editModel
.
managercost_yangshan
+
item
.
managercost_yangshan
,
managercost_chengpincang
=
editModel
.
managercost_chengpincang
+
item
.
managercost_chengpincang
,
managercost_xinhuilan
=
editModel
.
managercost_xinhuilan
+
item
.
managercost_xinhuilan
,
managercost_dizhi
=
editModel
.
managercost_dizhi
+
item
.
managercost_dizhi
,
profit
=
editModel
.
profit
+
item
.
profit
,
rate_profit
=
editModel
.
rate_profit
+
item
.
rate_profit
,
incoming_other
=
editModel
.
incoming_other
+
item
.
incoming_other
,
incoming_refundtax
=
editModel
.
incoming_refundtax
+
item
.
incoming_refundtax
,
incoming_gogirl
=
editModel
.
incoming_gogirl
+
item
.
incoming_gogirl
,
incoming_non_operating
=
editModel
.
incoming_non_operating
+
item
.
incoming_non_operating
,
pay_non_operating
=
editModel
.
pay_non_operating
+
item
.
pay_non_operating
,
impairment_assets
=
editModel
.
impairment_assets
+
item
.
impairment_assets
,
actual_profit
=
editModel
.
actual_profit
+
item
.
actual_profit
,
rate_profit_actual
=
editModel
.
rate_profit_actual
+
item
.
rate_profit_actual
,
isedit
=
2
});
}
/// <summary>
/// 导出月销售利润
/// </summary>
/// <param name="month"></param>
/// <returns></returns>
[
HttpPost
(
"exportListMonthSaleProfit"
)]
public
ActionResult
ExportListMonthSaleProfit
(
string
month
)
{
var
result
=
new
CommonApiResponseDto
<
bool
>();
if
(
string
.
IsNullOrWhiteSpace
(
month
))
{
result
.
Message
=
"月份不能空"
;
result
.
IsSuccess
=
false
;
return
Ok
(
result
);
}
var
newList
=
new
List
<
MonthSalesProfitDto
>();
var
dataList
=
new
FinanceService
().
ListMonthSaleProfitNew
(
month
,
null
);
var
noEditList
=
dataList
.
Where
(
x
=>
x
.
isedit
==
0
).
ToList
();
var
colNames
=
new
List
<
string
>();
colNames
.
Add
(
"项目"
);
foreach
(
var
item
in
noEditList
)
{
colNames
.
Add
(
$"
{
item
.
month
}
月份基础数据"
);
colNames
.
Add
(
$"
{
item
.
month
}
月份调整数据"
);
colNames
.
Add
(
$"
{
item
.
month
}
月份合计数据"
);
newList
.
Add
(
item
);
MonthSaleProfitSupplement
(
newList
,
dataList
,
item
);
}
GetMonthSalesProfitDataJson
(
newList
,
out
List
<
string
>
excelList
);
var
guid
=
Guid
.
NewGuid
().
ToString
();
var
filename
=
"月销售利润报表"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
);
var
filepath
=
_hostingEnvironment
.
WebRootPath
+
"\\Files\\Report\\"
+
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd"
)
+
"\\"
;
ToCSV
(
excelList
,
colNames
,
guid
,
filepath
);
var
ms
=
new
System
.
IO
.
MemoryStream
();
using
(
var
f
=
new
System
.
IO
.
FileStream
(
filepath
+
guid
+
".csv"
,
System
.
IO
.
FileMode
.
Open
))
{
f
.
CopyTo
(
ms
);
}
ms
.
Position
=
0
;
return
File
(
ms
,
"text/csv"
,
$"
{
filename
}
.csv"
);
}
#
endregion
}
}
}
}
Bailun.DC.WebApi/Models/Finance/MonthSalesProfitResponse.cs
0 → 100644
View file @
ebb575d5
using
Bailun.DC.Models.WebApiModels
;
using
System.Collections.Generic
;
namespace
Bailun.DC.WebApi.Models
{
/// <summary>
/// 月销售利润
/// </summary>
public
class
MonthSalesProfitResponse
{
public
MonthSalesProfitResponse
()
{
Col
=
new
List
<
MonthSalesProfitColumnsModel
>();
}
/// <summary>
/// json字符串
/// </summary>
public
string
DataJson
{
get
;
set
;
}
/// <summary>
/// 表头
/// </summary>
public
List
<
MonthSalesProfitColumnsModel
>
Col
{
get
;
set
;
}
}
/// <summary>
/// 表头
/// </summary>
public
class
MonthSalesProfitColumnsModel
{
/// <summary>
/// 显示名称
/// </summary>
public
string
Title
{
get
;
set
;
}
/// <summary>
/// Key
/// </summary>
public
string
Key
{
get
;
set
;
}
/// <summary>
/// 宽度
/// </summary>
public
int
Width
{
get
;
set
;
}
=
200
;
/// <summary>
///
/// </summary>
public
List
<
MonthSalesProfitColumnsChildren
>
Children
{
get
;
set
;
}
}
/// <summary>
///
/// </summary>
public
class
MonthSalesProfitColumnsChildren
{
/// <summary>
/// 显示名称
/// </summary>
public
string
Title
{
get
;
set
;
}
/// <summary>
/// Key
/// </summary>
public
string
Key
{
get
;
set
;
}
/// <summary>
/// 宽度
/// </summary>
public
int
Width
{
get
;
set
;
}
=
150
;
}
/// <summary>
///
/// </summary>
public
class
KeyDisplayNameModel
{
/// <summary>
///
/// </summary>
public
string
DisplayName
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
KeyName
{
get
;
set
;
}
/// <summary>
/// 上级名称
/// </summary>
public
ParentNameEnum
?
ParentName
{
get
;
set
;
}
}
}
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