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
4a29e6ba
Commit
4a29e6ba
authored
Mar 09, 2022
by
jianshuqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加功能:同步Amazon仓储费
parent
5f22b997
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
169 additions
and
5 deletions
+169
-5
flowing_sales_fee_detail.cs
Bailun.DC.Models/DataWareHouse/flowing_sales_fee_detail.cs
+5
-0
PlatformOrderFeeServices.cs
Bailun.DC.Services/DataWareHouse/PlatformOrderFeeServices.cs
+149
-3
PlatformOrderController.cs
...reas/DataWareHouse/Controllers/PlatformOrderController.cs
+15
-2
No files found.
Bailun.DC.Models/DataWareHouse/flowing_sales_fee_detail.cs
View file @
4a29e6ba
...
@@ -53,6 +53,11 @@ namespace Bailun.DC.Models.DataWareHouse
...
@@ -53,6 +53,11 @@ namespace Bailun.DC.Models.DataWareHouse
public
decimal
amount_usd
{
get
;
set
;
}
public
decimal
amount_usd
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 数据来源分类
/// </summary>
public
int
data_type
{
get
;
set
;
}
/// <summary>
/// 是否删除
/// 是否删除
/// </summary>
/// </summary>
public
bool
delstatus
{
get
;
set
;
}
public
bool
delstatus
{
get
;
set
;
}
...
...
Bailun.DC.Services/DataWareHouse/PlatformOrderFeeServices.cs
View file @
4a29e6ba
...
@@ -838,7 +838,121 @@ namespace Bailun.DC.Services.DataWareHouse
...
@@ -838,7 +838,121 @@ namespace Bailun.DC.Services.DataWareHouse
return
result
;
return
result
;
}
}
public
ResultDTO
BeforeSaveFlowingSalesFee
(
flowing_sales_fee
entity
)
public
ResultDTO
SyncFlowingSalesFeeDetail
(
string
platform
,
string
month
,
string
datacenterCol
)
{
ResultDTO
result
=
this
.
BeforeSyncFlowingSalesFeeDetail
(
platform
,
month
,
datacenterCol
);
if
(
result
.
Result
)
{
using
(
var
db
=
new
MySqlConnection
(
GlobalConfig
.
ConnectionString_DW
))
{
if
(
db
.
State
==
ConnectionState
.
Closed
)
{
db
.
Open
();
}
string
sql
=
"select * from exchange_rate_finance where month = @month and code in @code"
;
IList
<
exchange_rate_finance
>
listRate
=
db
.
Query
<
exchange_rate_finance
>(
sql
,
new
{
month
=
month
,
code
=
new
string
[]
{
"CNY"
,
"USD"
}
}).
ToList
();
if
(
listRate
?.
Count
>
0
)
{
sql
=
$@"SELECT
id AS fee_id
,'
{
platform
}
' AS platform
,'
{((
new
string
[]
{
"佣金及平台费-亚马逊非FBA"
,
"佣金及平台费-其他平台"
}).
Contains
(
datacenterCol
)
?
"平台费"
:
"FBA费"
)}
' AS fee_type
,datatime AS date
,amountval * IF(platform = '亚马逊',-1,1) AS amount
,currency AS currency
,amountval_rmb * IF(platform = '亚马逊',-1,1) AS amount_cny
,0 AS amount_usd
,1 AS data_type
,now() AS create_time
,now() AS update_time
FROM order_fee_value_amazon t1
WHERE t1.`month` = @month
AND t1.order_fee_config_id in (
SELECT id FROM order_fee_config WHERE datacenter_col = @datacenterCol
)
AND platform = @platform"
;
if
(
datacenterCol
==
"佣金及平台费-其他平台"
)
{
sql
+=
" AND amountval < 0 "
;
}
else
if
(
datacenterCol
==
"佣金及平台费-亚马逊非FBA"
)
{
sql
+=
" AND amountval > 0 "
;
}
IList
<
flowing_sales_fee_detail
>
list
=
db
.
Query
<
flowing_sales_fee_detail
>(
sql
,
new
{
platform
=
platform
.
Equals
(
"Walmart"
,
StringComparison
.
OrdinalIgnoreCase
)
?
"Walmart"
:
"亚马逊"
,
month
=
month
,
datacenterCol
=
datacenterCol
}).
ToList
();
if
(
list
?.
Count
>
0
)
{
//开启事务
using
(
MySqlTransaction
transaction
=
db
.
BeginTransaction
())
{
try
{
foreach
(
flowing_sales_fee_detail
entity
in
list
)
{
if
(
entity
.
amount_cny
==
0
)
{
if
(
entity
.
currency
.
Equals
(
"CNY"
,
StringComparison
.
OrdinalIgnoreCase
))
{
entity
.
amount_cny
=
entity
.
amount
;
}
else
{
exchange_rate_finance
rate_cny
=
listRate
.
FirstOrDefault
(
l
=>
l
.
code
.
Equals
(
entity
.
currency
,
StringComparison
.
OrdinalIgnoreCase
));
if
(
rate_cny
!=
null
)
{
entity
.
amount_cny
=
Math
.
Round
(
entity
.
amount
/
rate_cny
.
exchange_rate
,
2
);
}
}
}
if
(
entity
.
currency
.
Equals
(
"USD"
,
StringComparison
.
OrdinalIgnoreCase
))
{
entity
.
amount_usd
=
entity
.
amount
;
}
else
{
exchange_rate_finance
rate_usd
=
listRate
.
FirstOrDefault
(
l
=>
l
.
code
.
Equals
(
"USD"
,
StringComparison
.
OrdinalIgnoreCase
));
if
(
rate_usd
!=
null
)
{
entity
.
amount_usd
=
Math
.
Round
(
entity
.
amount_cny
*
rate_usd
.
exchange_rate
,
2
);
}
}
sql
=
$"update flowing_sales_fee_detail set platform = @platform, date = @date,amount = @amount,currency = @currency,amount_cny = @amount_cny,amount_usd = @amount_usd,update_time = @update_time where fee_id = @fee_id and data_type = @data_type"
;
int
count
=
db
.
Execute
(
sql
,
entity
);
if
(
count
==
0
)
{
entity
.
id
=
db
.
Insert
(
entity
)
??
0
;
}
}
transaction
.
Commit
();
}
catch
(
Exception
ex
)
{
//回滚事务
transaction
.
Rollback
();
result
.
Message
=
ex
.
Message
;
result
.
Result
=
false
;
}
}
}
else
{
result
.
Message
=
"没有数据需要同步"
;
result
.
Result
=
false
;
}
}
else
{
result
.
Message
=
"没有汇率信息"
;
result
.
Result
=
false
;
}
}
}
return
result
;
}
private
ResultDTO
BeforeSaveFlowingSalesFee
(
flowing_sales_fee
entity
)
{
{
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
if
(
entity
==
null
)
if
(
entity
==
null
)
...
@@ -872,7 +986,7 @@ namespace Bailun.DC.Services.DataWareHouse
...
@@ -872,7 +986,7 @@ namespace Bailun.DC.Services.DataWareHouse
return
result
;
return
result
;
}
}
p
ublic
ResultDTO
BeforeSaveFlowingSalesFeeDetail
(
flowing_sales_fee_detail
entity
)
p
rivate
ResultDTO
BeforeSaveFlowingSalesFeeDetail
(
flowing_sales_fee_detail
entity
)
{
{
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
if
(
entity
==
null
)
if
(
entity
==
null
)
...
@@ -906,7 +1020,7 @@ namespace Bailun.DC.Services.DataWareHouse
...
@@ -906,7 +1020,7 @@ namespace Bailun.DC.Services.DataWareHouse
return
result
;
return
result
;
}
}
p
ublic
ResultDTO
BeforeDelete
(
int
[]
id
)
p
rivate
ResultDTO
BeforeDelete
(
int
[]
id
)
{
{
ResultDTO
result
=
new
ResultDTO
();
ResultDTO
result
=
new
ResultDTO
();
if
(
id
==
null
||
id
.
Length
==
0
||
id
.
Contains
(
0
))
if
(
id
==
null
||
id
.
Length
==
0
||
id
.
Contains
(
0
))
...
@@ -920,5 +1034,37 @@ namespace Bailun.DC.Services.DataWareHouse
...
@@ -920,5 +1034,37 @@ namespace Bailun.DC.Services.DataWareHouse
return
result
;
return
result
;
}
}
private
ResultDTO
BeforeSyncFlowingSalesFeeDetail
(
string
platform
,
string
month
,
string
datacenterCol
)
{
ResultDTO
result
=
new
ResultDTO
();
if
(
string
.
IsNullOrWhiteSpace
(
platform
))
{
result
.
Message
=
"平台不能为空"
;
}
else
if
(
string
.
IsNullOrWhiteSpace
(
month
))
{
result
.
Message
=
"年月"
;
}
else
if
(
string
.
IsNullOrWhiteSpace
(
datacenterCol
))
{
result
.
Message
=
"费用类型不能为空"
;
}
else
if
(!
platform
.
Equals
(
"Walmart"
,
StringComparison
.
OrdinalIgnoreCase
)
&&
!
platform
.
Equals
(
"FBA"
,
StringComparison
.
OrdinalIgnoreCase
)
&&
!
platform
.
Equals
(
"Amazon"
,
StringComparison
.
OrdinalIgnoreCase
))
{
result
.
Message
=
"平台不在同步范围"
;
}
else
if
(!(
new
string
[]
{
"佣金及平台费-亚马逊非FBA"
,
"仓储费-平台"
,
"佣金及平台费-其他平台"
}).
Contains
(
datacenterCol
))
{
result
.
Message
=
"费用类型不在同步范围"
;
}
else
{
result
.
Result
=
true
;
}
return
result
;
}
}
}
}
}
Bailun.DC.Web/Areas/DataWareHouse/Controllers/PlatformOrderController.cs
View file @
4a29e6ba
...
@@ -1570,10 +1570,23 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
...
@@ -1570,10 +1570,23 @@ namespace Bailun.DC.Web.Areas.DataWareHouse.Controllers
return
Json
(
result
);
return
Json
(
result
);
}
}
#
endregion
[
HttpPost
]
public
JsonResult
SyncFlowingSalesFeeDetail
(
string
platform
,
string
month
,
string
datacenterCol
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
{
result
=
new
Services
.
DataWareHouse
.
PlatformOrderFeeServices
().
SyncFlowingSalesFeeDetail
(
platform
,
month
,
datacenterCol
);
}
catch
(
Exception
ex
)
{
result
=
new
ResultDTO
()
{
Message
=
ex
.
Message
};
}
return
Json
(
result
);
}
#
endregion
}
}
}
}
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