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
9c804350
Commit
9c804350
authored
Aug 30, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export fix
parent
9ae0e188
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
172 additions
and
10 deletions
+172
-10
FinanceService.cs
Bailun.DC.Services/WebApiService/FinanceService.cs
+172
-10
No files found.
Bailun.DC.Services/WebApiService/FinanceService.cs
View file @
9c804350
...
...
@@ -1263,7 +1263,7 @@ t1.exchange_rate AS ExchangeRate,t1.amountval_rmb AS AmountValRmb,t1.month AS Mo
}
public
CommonApiResponseDto
ExprotAccountSubject
(
AccountingSubjectInput
query
)
{
var
sql
=
BuildAccountingSubjectFlowSql
(
query
,
out
DynamicParameters
param
,
false
,
tru
e
);
var
sql
=
BuildAccountingSubjectFlowSql
(
query
,
out
DynamicParameters
param
,
false
,
fals
e
);
var
data
=
SimpleCRUD
.
Query
<
MonthPlatformProfitDto
>(
sql
,
param
,
GlobalConfig
.
ConnectionString_DW
).
ToList
();
var
table
=
new
DataTable
();
table
.
Columns
.
Add
(
"平台"
);
...
...
@@ -1697,15 +1697,38 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
UpateExprotTask
(
exprotTask
.
id
,
2
,
""
,
DateTime
.
Now
);
//TODO:根据任务进行区分生成文件到服务器
var
result
=
new
CommonApiResponseDto
();
switch
(
exprotTask
.
task_type
)
//task_type和前端约定好的
//task_type和前端约定好的
//TODO:上传文件到七牛云
if
(
exprotTask
.
task_type
==
"会计流水"
)
{
var
json
=
JsonConvert
.
DeserializeObject
<
AccountingSubjectInput
>(
exprotTask
.
task_json
);
result
=
ExprotAccountSubject
(
json
);
}
else
if
(
exprotTask
.
task_type
.
Contains
(
"平台费用"
))
{
var
json
=
JsonConvert
.
DeserializeObject
<
GetMonthProfitPlatformDetailInput
>(
exprotTask
.
task_json
);
result
=
SyncExportMonthProfitFeePlatformFeeDetail
(
json
,
exprotTask
.
task_title
);
}
else
if
(
exprotTask
.
task_type
.
Contains
(
"物流仓储费用"
))
{
var
json
=
JsonConvert
.
DeserializeObject
<
GetMonthProfitPlatformDetailInput
>(
exprotTask
.
task_json
);
result
=
SyncExportMonthProfitFeePlatformFeeDetail
(
json
,
exprotTask
.
task_title
);
}
else
if
(
exprotTask
.
task_type
.
Contains
(
"销售额"
))
{
var
json
=
JsonConvert
.
DeserializeObject
<
MonthProfitOrderDetailPageInputDto
>(
exprotTask
.
task_json
);
result
=
SyncExportMonthProfitOrderDetail
(
json
,
exprotTask
.
task_title
,
false
);
}
else
if
(
exprotTask
.
task_type
.
Contains
(
"成本"
))
{
var
json
=
JsonConvert
.
DeserializeObject
<
MonthProfitOrderDetailPageInputDto
>(
exprotTask
.
task_json
);
result
=
SyncExportMonthProfitOrderDetail
(
json
,
exprotTask
.
task_title
,
true
);
}
else
if
(
exprotTask
.
task_type
.
Contains
(
"退款"
))
{
//TODO:上传文件到七牛云
case
"会计流水"
:
var
json
=
JsonConvert
.
DeserializeObject
<
AccountingSubjectInput
>(
exprotTask
.
task_json
);
result
=
ExprotAccountSubject
(
json
);
break
;
default
:
break
;
var
json
=
JsonConvert
.
DeserializeObject
<
GetMonthProfitPlatformDetailInput
>(
exprotTask
.
task_json
);
result
=
SyncExportMonthProfitFeeReFundDetail
(
json
,
exprotTask
.
task_title
);
}
//TODO:保存七牛云返回的链接到导出任务并更新任务为执行完成状态
if
(
result
.
Code
==
200
)
...
...
@@ -1720,7 +1743,7 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
}
else
{
Console
.
WriteLine
(
"
不存在需要导出的任务!"
);
Console
.
WriteLine
(
$"
{
DateTime
.
Now
.
ToString
(
"yyyy - MM - dd HH: mm:ss"
)}
不存在需要导出的任务!"
);
}
}
catch
(
Exception
e
)
...
...
@@ -1760,12 +1783,151 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
sql
.
Append
(
$" Where id =
{
id
}
"
);
SimpleCRUD
.
ExecuteSql
(
sql
.
ToString
(),
GlobalConfig
.
ConnectionString
,
param
);
}
/// <summary>
/// 导出任务分页
/// </summary>
/// <returns></returns>
public
CommonApiResponseDto
<
List
<
dc_export_task
>>
GetExportTaskPage
()
{
var
sql
=
"SELECT * FROM dc_export_task order by create_date desc "
;
var
data
=
SimpleCRUD
.
Query
<
dc_export_task
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
ToList
();
return
new
CommonApiResponseDto
<
List
<
dc_export_task
>>
{
Data
=
data
};
}
/// <summary>
/// 导出平台费用和物流仓储费用
/// </summary>
/// <param name="input"></param>
/// <param name="name"></param>
/// <returns></returns>
private
CommonApiResponseDto
SyncExportMonthProfitFeePlatformFeeDetail
(
GetMonthProfitPlatformDetailInput
input
,
string
name
)
{
var
data
=
ExportMonthProfitFeePlatformFeeDetail
(
input
);
var
table
=
new
DataTable
();
table
.
Columns
.
Add
(
"平台"
);
table
.
Columns
.
Add
(
"站点"
);
table
.
Columns
.
Add
(
"账单时间"
);
table
.
Columns
.
Add
(
"单号"
);
table
.
Columns
.
Add
(
"币种"
);
table
.
Columns
.
Add
(
"原币金额"
);
table
.
Columns
.
Add
(
"汇率"
);
table
.
Columns
.
Add
(
"RMB金额"
);
table
.
Columns
.
Add
(
"费用字段说明"
);
table
.
Columns
.
Add
(
"财务分类归集说明"
);
table
.
Columns
.
Add
(
"数据中心费用类型"
);
table
.
Columns
.
Add
(
"会计科目编码"
);
table
.
Columns
.
Add
(
"项目编码"
);
foreach
(
var
item
in
data
)
{
table
.
Rows
.
Add
(
item
.
PlatForm
,
item
.
WebSite
,
item
.
DataTime
,
item
.
Orderno
,
item
.
Currency
,
item
.
AmountVal
,
item
.
ExchangeRate
,
item
.
AmountValRmb
,
item
.
FeeType
,
item
.
FinanceCategory
,
item
.
DatacenterCol
,
item
.
Subjectcode
,
item
.
ProjectCode
);
}
var
filename
=
$"
{
name
}
"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xlsx"
;
var
result
=
UploadFile
(
table
,
filename
);
if
(
result
.
Code
==
200
)
{
return
new
CommonApiResponseDto
{
Message
=
$"http://dcfile.blsct.com/
{
filename
}
"
};
}
return
new
CommonApiResponseDto
{
IsSuccess
=
false
,
Message
=
result
.
RefText
+
"_"
+
result
.
Text
};
}
/// <summary>
/// 导出销售额和成本
/// </summary>
/// <param name="input"></param>
/// <param name="name"></param>
/// <param name="IsCost"></param>
/// <returns></returns>
private
CommonApiResponseDto
SyncExportMonthProfitOrderDetail
(
MonthProfitOrderDetailPageInputDto
input
,
string
name
,
bool
IsCost
)
{
input
.
IsPages
=
false
;
var
data
=
GetMonthProfitOrderDetailPage
(
input
).
Data
.
Items
;
var
table
=
new
DataTable
();
table
.
Columns
.
Add
(
"财务分类"
);
table
.
Columns
.
Add
(
"平台类型"
);
table
.
Columns
.
Add
(
"订单号"
);
table
.
Columns
.
Add
(
"SKU"
);
if
(
IsCost
)
{
table
.
Columns
.
Add
(
"成本"
);
table
.
Columns
.
Add
(
"总成本"
);
}
else
{
table
.
Columns
.
Add
(
"销售额(原币)"
);
table
.
Columns
.
Add
(
"销售额RMB"
);
}
table
.
Columns
.
Add
(
"汇率"
);
table
.
Columns
.
Add
(
"发货量"
);
table
.
Columns
.
Add
(
"发货时间"
);
table
.
Columns
.
Add
(
"创建时间"
);
foreach
(
var
item
in
data
)
{
table
.
Rows
.
Add
(
item
.
financecategoryname
,
item
.
platform_type
,
item
.
origin_order_id
,
item
.
bailun_sku
,
IsCost
?
item
.
cost_product
:
item
.
amount_sales
,
IsCost
?
item
.
cost_product_total
:
item
.
amount_sales_rmb
,
item
.
seller_order_exchange_rate
,
item
.
quantity_shipped
,
item
.
shipping_time
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
),
item
.
createtime
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
));
}
var
filename
=
$"
{
name
}
"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xlsx"
;
var
result
=
UploadFile
(
table
,
filename
);
if
(
result
.
Code
==
200
)
{
return
new
CommonApiResponseDto
{
Message
=
$"http://dcfile.blsct.com/
{
filename
}
"
};
}
return
new
CommonApiResponseDto
{
IsSuccess
=
false
,
Message
=
result
.
RefText
+
"_"
+
result
.
Text
};
}
/// <summary>
/// 导出退款
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private
CommonApiResponseDto
SyncExportMonthProfitFeeReFundDetail
(
GetMonthProfitPlatformDetailInput
input
,
string
name
)
{
var
data
=
ExportMonthProfitFeeReFundDetail
(
input
);
var
table
=
new
DataTable
();
table
.
Columns
.
Add
(
"平台"
);
table
.
Columns
.
Add
(
"订单号"
);
table
.
Columns
.
Add
(
"站点"
);
table
.
Columns
.
Add
(
"卖家账号"
);
table
.
Columns
.
Add
(
"退款金额"
);
table
.
Columns
.
Add
(
"退款USD"
);
table
.
Columns
.
Add
(
"退款时间"
);
foreach
(
var
item
in
data
)
{
table
.
Rows
.
Add
(
item
.
PlatformType
,
item
.
OriginOrderId
,
item
.
WebSite
,
item
.
BailunAccount
,
item
.
RefundRmb
,
item
.
RefundUsd
,
item
.
RefundTime
);
}
var
filename
=
$"
{
name
}
"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xlsx"
;
var
result
=
UploadFile
(
table
,
filename
);
if
(
result
.
Code
==
200
)
{
return
new
CommonApiResponseDto
{
Message
=
$"http://dcfile.blsct.com/
{
filename
}
"
};
}
return
new
CommonApiResponseDto
{
IsSuccess
=
false
,
Message
=
result
.
RefText
+
"_"
+
result
.
Text
};
}
#
endregion
#
region
Upload
private
Qiniu
.
Http
.
HttpResult
UploadFile
(
DataTable
table
,
string
filename
)
...
...
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