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
0d452021
Commit
0d452021
authored
Aug 07, 2021
by
zhouminghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑月利润
parent
0fd6611a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
196 additions
and
1 deletion
+196
-1
DapperHelper.cs
Bailun.DC.DB/Base/DapperHelper.cs
+16
-0
UpdateMonthSalseProfitInput.cs
Bailun.DC.Models/WebApiModels/UpdateMonthSalseProfitInput.cs
+22
-0
FinanceService.cs
Bailun.DC.Services/WebApiService/FinanceService.cs
+130
-0
FinanceController.cs
Bailun.DC.WebApi/Controllers/FinanceController.cs
+28
-1
No files found.
Bailun.DC.DB/Base/DapperHelper.cs
View file @
0d452021
...
@@ -702,6 +702,22 @@ namespace Dapper
...
@@ -702,6 +702,22 @@ namespace Dapper
return
result
;
return
result
;
}
}
/// <summary>
/// 执行sql
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="sql"></param>
/// <param name="param"></param>
/// <param name="connection"></param>
public
static
int
ExecuteSql
(
string
sql
,
string
connection
,
object
param
=
null
)
{
using
(
MySql
.
Data
.
MySqlClient
.
MySqlConnection
con
=
new
MySql
.
Data
.
MySqlClient
.
MySqlConnection
(
connection
))
{
var
count
=
con
.
Execute
(
sql
,
param
);
con
.
Dispose
();
return
count
;
}
}
//build update statement based on list on an entity
//build update statement based on list on an entity
private
static
void
BuildUpdateSet
<
T
>(
T
entityToUpdate
,
StringBuilder
sb
)
private
static
void
BuildUpdateSet
<
T
>(
T
entityToUpdate
,
StringBuilder
sb
)
...
...
Bailun.DC.Models/WebApiModels/UpdateMonthSalseProfitInput.cs
0 → 100644
View file @
0d452021
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.DC.Models.WebApiModels
{
public
class
UpdateMonthSalseProfitInput
{
/// <summary>
/// 修改后的值
/// </summary>
public
string
Value
{
get
;
set
;
}
/// <summary>
/// 修改字段
/// </summary>
public
string
Key
{
get
;
set
;
}
/// <summary>
/// 月份
/// </summary>
public
string
Month
{
get
;
set
;
}
}
}
Bailun.DC.Services/WebApiService/FinanceService.cs
View file @
0d452021
...
@@ -13,6 +13,7 @@ using System.Collections.Generic;
...
@@ -13,6 +13,7 @@ using System.Collections.Generic;
using
System.Data
;
using
System.Data
;
using
System.Linq
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Net.Http
;
using
System.Reflection
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -539,6 +540,135 @@ and s1.management_cost_name = @managementcostname";
...
@@ -539,6 +540,135 @@ and s1.management_cost_name = @managementcostname";
sqlText
.
Append
(
" ORDER BY t1.createtime DESC "
);
sqlText
.
Append
(
" ORDER BY t1.createtime DESC "
);
return
sqlText
.
ToString
();
return
sqlText
.
ToString
();
}
}
public
bool
UpdateMonthSalseProfit
(
UpdateMonthSalseProfitInput
input
,
int
userId
,
string
userName
)
{
using
(
var
cn
=
new
MySqlConnection
(
Common
.
GlobalConfig
.
ConnectionString
))
{
if
(
cn
.
State
==
ConnectionState
.
Closed
)
{
cn
.
Open
();
}
input
.
Month
=
input
.
Month
.
Replace
(
"月份"
,
""
);
var
sql
=
$"select * from dc_month_sales_profit where isedit = 1 and month = '
{
input
.
Month
}
'"
;
var
obj
=
SimpleCRUD
.
Query
<
dc_month_sales_profit
>(
sql
,
null
,
GlobalConfig
.
ConnectionString
).
FirstOrDefault
();
if
(
obj
==
null
)
{
obj
=
new
dc_month_sales_profit
{
month
=
input
.
Month
,
amount_sales
=
0
,
amount_sales_dianzi
=
0
,
amount_sales_fuzhuang
=
0
,
amount_sales_jiaju
=
0
,
amount_sales_jingyou
=
0
,
amount_sales_meirongmj
=
0
,
actual_profit
=
0
,
amount_withdraw
=
0
,
fee_platform_and_refund
=
0
,
fee_fba
=
0
,
fee_finance
=
0
,
fee_logistics_direct
=
0
,
fee_logistics_first
=
0
,
fee_logistics_tail
=
0
,
fee_logistics_storage
=
0
,
fee_paycash_sales
=
0
,
fee_platform
=
0
,
fee_refund
=
0
,
fee_sales_count
=
0
,
fee_storage
=
0
,
fee_storage_incidentals
=
0
,
fee_ad
=
0
,
cost_fuzhuang
=
0
,
cost
=
0
,
cost_dianzi
=
0
,
cost_jiaju
=
0
,
cost_jingyou
=
0
,
cost_meirongmj
=
0
,
createtime
=
DateTime
.
Now
,
managercost_chengpincang
=
0
,
managercost_count
=
0
,
managecost_bl_gz
=
0
,
managecost_bl_xg
=
0
,
managecost_meijia
=
0
,
managercost_yangshan
=
0
,
managercost_dizhi
=
0
,
managercost_meijiashengchan
=
0
,
dividend
=
0
,
incoming_non_operating
=
0
,
incoming_other
=
0
,
incoming_refundtax
=
0
,
isedit
=
1
,
profit_sales
=
0
,
pay_non_operating
=
0
,
rate_profit_sales
=
0
,
profit
=
0
,
profit_balance
=
0
,
rate_profit
=
0
,
rate_profit_actual
=
0
,
amount_sales_other
=
0
,
cost_other
=
0
,
managercost_xinhuilan
=
0
,
impairment_assets
=
0
,
};
}
var
type
=
obj
.
GetType
();
object
change
=
Convert
.
ChangeType
(
input
.
Value
,
type
.
GetProperty
(
input
.
Key
).
PropertyType
);
type
.
GetProperty
(
input
.
Key
).
SetValue
(
obj
,
change
,
null
);
//销售额=家居用品类+服装类+电子产品类+精油类+美容美甲类+其他
obj
.
amount_sales
=
obj
.
amount_sales_dianzi
+
obj
.
amount_sales_fuzhuang
+
obj
.
amount_sales_jiaju
+
obj
.
amount_sales_jingyou
+
obj
.
amount_sales_meirongmj
+
obj
.
amount_sales_other
;
//产品成本=家居用品类+服装类+电子产品类+精油类+美容美甲类+其他类型成本
obj
.
cost
=
obj
.
cost_dianzi
+
obj
.
cost_fuzhuang
+
obj
.
cost_jiaju
+
obj
.
cost_jingyou
+
obj
.
cost_meirongmj
+
obj
.
cost_other
;
//平台扣费及退款
obj
.
fee_platform_and_refund
=
obj
.
fee_platform
+
obj
.
fee_fba
+
obj
.
fee_refund
+
obj
.
fee_ad
;
//物流仓储费用 = 头程运输+直邮物流费+尾程物流费+海外仓仓储+海外仓杂费
obj
.
fee_logistics_storage
=
obj
.
fee_logistics_first
+
obj
.
fee_logistics_direct
+
obj
.
fee_logistics_tail
+
obj
.
fee_storage
+
obj
.
fee_storage_incidentals
;
//销售费用合计=平台扣费及退款+物流仓储费用+付现销售费用
obj
.
fee_sales_count
=
obj
.
fee_platform_and_refund
+
obj
.
fee_logistics_storage
+
obj
.
fee_paycash_sales
;
//销售利润=销售额-产品成本-销售费用合计
obj
.
profit_sales
=
obj
.
amount_sales
-
obj
.
cost
-
obj
.
fee_sales_count
;
//销售毛利率=销售利润/销售额
obj
.
rate_profit_sales
=
obj
.
amount_sales
>
0
?
obj
.
profit_sales
/
obj
.
amount_sales
:
0
;
//管理成本=香港百伦+广州百伦+美容美甲店+杨杉+信荟蓝+成品仓+迪致+广州美甲生产仓
obj
.
managercost_count
=
obj
.
managecost_bl_gz
+
obj
.
managecost_bl_xg
+
obj
.
managecost_meijia
+
obj
.
managercost_chengpincang
+
obj
.
managercost_xinhuilan
+
obj
.
managercost_yangshan
+
obj
.
managercost_dizhi
+
obj
.
managercost_meijiashengchan
;
//营业利润=销售利润-管理成本合计-财务费用
obj
.
profit
=
obj
.
profit_sales
-
obj
.
managercost_count
-
obj
.
fee_finance
;
//营业毛利率=营业利润/销售额
obj
.
rate_profit
=
obj
.
amount_sales
>
0
?
obj
.
profit
/
obj
.
amount_sales
:
0
;
//实际利润=营业利润+其他收入+营业外收入-营业外支出-资产减值
obj
.
actual_profit
=
obj
.
profit
+
obj
.
incoming_other
+
obj
.
incoming_non_operating
-
obj
.
pay_non_operating
-
(
obj
.
impairment_assets
??
0
);
//利润结余=实际利润-分红
obj
.
profit_balance
=
obj
.
actual_profit
-
obj
.
dividend
;
//净利率 = 利润结余/销售额
obj
.
rate_profit_actual
=
obj
.
amount_sales
>
0
?
obj
.
profit_balance
/
obj
.
amount_sales
:
0
;
obj
.
lastupdatetime
=
DateTime
.
Now
;
obj
.
lastupdateuserid
=
userId
;
obj
.
lastupdateusername
=
userName
;
if
(
obj
.
id
>
0
)
{
var
result
=
cn
.
Update
(
obj
);
return
result
>
0
?
true
:
false
;
}
else
{
var
result
=
cn
.
Insert
(
obj
);
return
(
result
??
0
)
>
0
?
true
:
false
;
}
}
}
#
endregion
#
endregion
}
}
}
}
Bailun.DC.WebApi/Controllers/FinanceController.cs
View file @
0d452021
...
@@ -4,6 +4,7 @@ using Bailun.DC.Models.WebApiModels;
...
@@ -4,6 +4,7 @@ using Bailun.DC.Models.WebApiModels;
using
Bailun.DC.Services.WebApiService
;
using
Bailun.DC.Services.WebApiService
;
using
Bailun.DC.WebApi.Models
;
using
Bailun.DC.WebApi.Models
;
using
Bailun.ServiceFabric.Authorize
;
using
Bailun.ServiceFabric.Authorize
;
using
Bailun.ServiceFabric.Core.Extension
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System
;
...
@@ -172,7 +173,7 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -172,7 +173,7 @@ namespace Bailun.DC.WebApi.Controllers
{
{
if
(
item
.
KeyName
==
"id"
||
item
.
KeyName
==
"month"
)
continue
;
if
(
item
.
KeyName
==
"id"
||
item
.
KeyName
==
"month"
)
continue
;
var
isFirst
=
firstList
.
Count
(
x
=>
x
.
ParentName
.
ToString
()
==
item
.
KeyName
)
>
0
?
1
:
0
;
var
isFirst
=
firstList
.
Count
(
x
=>
x
.
ParentName
.
ToString
()
==
item
.
KeyName
)
>
0
?
1
:
0
;
jsonStr
.
Append
(
"{\"Item\":\""
+
item
.
DisplayName
+
"\",\"IsFirst\":"
+
isFirst
+
",\"FirstId\":\""
+
(
int
)
item
.
ParentName
+
"\","
);
jsonStr
.
Append
(
"{\"Item
Name\":\""
+
item
.
KeyName
+
"\",\"Item
\":\""
+
item
.
DisplayName
+
"\",\"IsFirst\":"
+
isFirst
+
",\"FirstId\":\""
+
(
int
)
item
.
ParentName
+
"\","
);
excelItemStr
=
item
.
DisplayName
+
"|"
;
excelItemStr
=
item
.
DisplayName
+
"|"
;
foreach
(
var
subItem
in
dataList
)
foreach
(
var
subItem
in
dataList
)
{
{
...
@@ -365,6 +366,32 @@ namespace Bailun.DC.WebApi.Controllers
...
@@ -365,6 +366,32 @@ namespace Bailun.DC.WebApi.Controllers
return
File
(
ms
,
"text/csv"
,
"月销售利润表明细.csv"
);
return
File
(
ms
,
"text/csv"
,
"月销售利润表明细.csv"
);
}
}
/// <summary>
/// 更新调整数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[
HttpPost
(
"updateMonthSalseProfit"
)]
public
CommonApiResponseDto
<
string
>
UpdateMonthSalseProfit
(
UpdateMonthSalseProfitInput
input
)
{
try
{
var
user
=
HttpContext
.
User
;
//var user = HttpContextHelper.Current?.User;
var
userId
=
user
.
GetUid
();
var
userName
=
user
.
GetUserName
();
var
output
=
new
FinanceService
().
UpdateMonthSalseProfit
(
input
,
userId
,
userName
);
if
(
output
)
{
return
new
CommonApiResponseDto
<
string
>();
}
return
new
CommonApiResponseDto
<
string
>()
{
IsSuccess
=
false
,
Data
=
"操作失败!请与管理员联系~"
};
}
catch
(
Exception
e
)
{
return
new
CommonApiResponseDto
<
string
>()
{
IsSuccess
=
false
,
Data
=
e
.
Message
};
}
}
#
endregion
#
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