Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
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
黄奎
mall.oytour.com
Commits
bc33739d
Commit
bc33739d
authored
Jun 02, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
和平分销暂存+商品详情调整
parent
97a54957
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1304 additions
and
258 deletions
+1304
-258
RB_Distributor_HPCommission.cs
Mall.Model/Entity/User/RB_Distributor_HPCommission.cs
+4
-0
RB_Distributor_HPGradeInfo.cs
Mall.Model/Entity/User/RB_Distributor_HPGradeInfo.cs
+4
-0
RB_Distributor_HPCommission_Extend.cs
Mall.Model/Extend/User/RB_Distributor_HPCommission_Extend.cs
+5
-1
RB_Distributor_HPGradeInfo_Extend.cs
Mall.Model/Extend/User/RB_Distributor_HPGradeInfo_Extend.cs
+4
-1
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+316
-214
ProductModule.cs
Mall.Module.Product/ProductModule.cs
+831
-22
UserModule.cs
Mall.Module.User/UserModule.cs
+32
-0
RB_Distributor_HPGradeInfoRepository.cs
Mall.Repository/User/RB_Distributor_HPGradeInfoRepository.cs
+4
-0
AppletGoodsController.cs
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
+54
-20
UserController.cs
Mall.WebApi/Controllers/User/UserController.cs
+50
-0
No files found.
Mall.Model/Entity/User/RB_Distributor_HPCommission.cs
View file @
bc33739d
...
...
@@ -47,6 +47,10 @@ namespace Mall.Model.Entity.User
set
;
}
/// <summary>
/// 是否通用返佣 1是 2否
/// </summary>
public
int
?
IsCommon
{
get
;
set
;
}
/// <summary>
/// 删除状态
/// </summary>
public
int
?
Status
{
get
;
set
;
}
...
...
Mall.Model/Entity/User/RB_Distributor_HPGradeInfo.cs
View file @
bc33739d
...
...
@@ -70,5 +70,9 @@ namespace Mall.Model.Entity.User
/// UpdateDate
/// </summary>
public
DateTime
?
UpdateDate
{
get
;
set
;
}
/// <summary>
/// 是否直客等级
/// </summary>
public
int
?
IsGuest
{
get
;
set
;
}
}
}
Mall.Model/Extend/User/RB_Distributor_HPCommission_Extend.cs
View file @
bc33739d
...
...
@@ -23,7 +23,7 @@ namespace Mall.Model.Extend.User
public
string
CategoryIds
{
get
;
set
;
}
/// <summary>
/// 分类ids
/// 分类ids
(包含不限)
/// </summary>
public
string
CategoryIdsT
{
get
;
set
;
}
/// <summary>
...
...
@@ -34,5 +34,9 @@ namespace Mall.Model.Extend.User
/// 比例列表
/// </summary>
public
List
<
RB_Distributor_HPGradeRatio_Extend
>
RatioList
{
get
;
set
;
}
/// <summary>
/// 是否通用
/// </summary>
public
int
?
IsCommon
{
get
;
set
;
}
}
}
Mall.Model/Extend/User/RB_Distributor_HPGradeInfo_Extend.cs
View file @
bc33739d
...
...
@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.User
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Distributor_HPGradeInfo_Extend
:
RB_Distributor_HPGradeInfo
{
/// <summary>
/// ids
/// </summary>
public
string
GradeIds
{
get
;
set
;
}
}
}
Mall.Module.Product/OrderModule.cs
View file @
bc33739d
...
...
@@ -173,6 +173,14 @@ namespace Mall.Module.Product
/// 小程序基础
/// </summary>
private
readonly
RB_MallBaseRepository
mallBaseRepository
=
new
RB_MallBaseRepository
();
/// <summary>
/// 和平返佣
/// </summary>
private
readonly
RB_Distributor_HPCommissionRepository
distributor_HPCommissionRepository
=
new
RB_Distributor_HPCommissionRepository
();
/// <summary>
/// 和平返佣比例
/// </summary>
private
readonly
RB_Distributor_HPGradeRatioRepository
distributor_HPGradeRatioRepository
=
new
RB_Distributor_HPGradeRatioRepository
();
#
region
购物车
...
...
@@ -2512,166 +2520,193 @@ namespace Mall.Module.Product
var
trans
=
goods_OrderCommissionRepository
.
DbTransaction
;
try
{
var
dcList
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
basicModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
}).
FirstOrDefault
();
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
//判断是否开启和平返佣
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission_Extend
.
Status
),
FiledValue
=
0
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission_Extend
.
Enabled
),
FiledValue
=
1
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission_Extend
.
TenantId
),
FiledValue
=
demodel
.
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission_Extend
.
MallBaseId
),
FiledValue
=
demodel
.
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
if
(
distributor_HPCommissionRepository
.
Exists
(
wheres
))
{
#
region
分销商
id
+
分销商等级
int
OneUserId
=
0
,
TwoUserId
=
0
,
ThreeUserId
=
0
;
int
OneDistributorGrade
=
0
,
TwoDistributorGrade
=
0
,
ThreeDistributorGrade
=
0
;
//获取多级 分销商id
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
int
OneUserId
=
umodel
.
SuperiorId
??
0
;
//获取分销商信息
var
disModel
=
new
RB_Distributor_Info_Extend
();
if
((
basicModel
?.
InPurchasing
??
2
)
==
1
)
{
for
(
int
i
=
1
;
i
<
basicModel
.
DistributorTier
+
1
;
i
++)
disModel
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
umodel
.
Id
,
AuditStatus
=
Common
.
Enum
.
User
.
DistributorAuditStatusEnum
.
Audited
}).
FirstOrDefault
();
if
(
disModel
!=
null
||
(
disModel
.
HPGradeId
??
0
)
>
0
)
{
switch
(
i
)
{
case
1
:
if
(
umodel
.
IsDistributor
!=
1
||
basicModel
.
InPurchasing
!=
1
)
{
OneUserId
=
umodel
.
SuperiorId
??
0
;
}
else
{
OneUserId
=
umodel
.
Id
;
OneUserId
=
umodel
.
Id
;
//设置了分销内购 并且自己是分销商 并且设置了和平等级 , 那么就是自购返佣
}
}
if
(
OneUserId
!=
umodel
.
Id
)
{
//求其上级
disModel
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
OneUserId
,
AuditStatus
=
Common
.
Enum
.
User
.
DistributorAuditStatusEnum
.
Audited
}).
FirstOrDefault
();
if
(
disModel
!=
null
||
(
disModel
.
HPGradeId
??
0
)
>
0
)
{
OneUserId
=
umodel
.
SuperiorId
??
0
;
//其上级可返佣
}
else
{
OneUserId
=
0
;
}
}
if
(
OneUserId
>
0
)
{
foreach
(
var
item
in
demodel
.
DetailList
)
{
if
(
item
.
CostMoney
>
0
)
{
//成本价格大于0的才进行返佣
string
categoryids
=
string
.
Join
(
","
,
item
.
CategoryIdList
);
var
hpcList
=
distributor_HPCommissionRepository
.
GetList
(
new
RB_Distributor_HPCommission_Extend
()
{
CategoryIdsT
=
categoryids
});
if
(
hpcList
.
Any
())
{
RB_Distributor_HPCommission_Extend
hpcModel
;
if
(
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
Any
())
{
//有使用非通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
FirstOrDefault
();
}
break
;
case
2
:
if
(
OneUserId
>
0
)
else
{
if
(
umodel
.
IsDistributor
!=
1
||
basicModel
.
InPurchasing
!=
1
)
{
TwoUserId
=
member_UserRepository
.
GetEntity
(
OneUserId
).
SuperiorId
??
0
;
}
else
{
TwoUserId
=
umodel
.
SuperiorId
??
0
;
}
//查询通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
==
1
).
FirstOrDefault
();
}
//查询所有返佣比例
var
gList
=
distributor_HPGradeRatioRepository
.
GetList
(
new
RB_Distributor_HPGradeRatio_Extend
()
{
CommissionId
=
hpcModel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
ratioModel
=
gList
.
Where
(
x
=>
x
.
GradeId
==
disModel
.
HPGradeId
).
FirstOrDefault
();
decimal
MPrice
=
(
item
.
CostMoney
??
0
)
/
(
1
-
((
ratioModel
.
CommissionRatio
??
0
)
/
100
));
if
(
hpcModel
.
DecimalType
==
1
)
{
MPrice
=
Math
.
Ceiling
(
MPrice
);
}
break
;
case
3
:
if
(
TwoUserId
>
0
)
else
if
(
hpcModel
.
DecimalType
==
2
)
{
ThreeUserId
=
member_UserRepository
.
GetEntity
(
TwoUserId
).
SuperiorId
??
0
;
MPrice
=
Math
.
Ceiling
(
MPrice
*
100
)
/
10
0
;
}
break
;
//model.MaxShare = MaxSellMoney - MPrice > 0 ? MaxSellMoney - MPrice : 0;
}
}
}
}
if
(
OneUserId
>
0
)
}
else
{
var
dcList
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsIds
=
GoodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
{
if
(
OneUserId
>
0
)
{
OneDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
OneUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
TwoUserId
>
0
)
{
TwoDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
TwoUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
ThreeUserId
>
0
)
{
ThreeDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
ThreeUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
#
endregion
#
region
分销商等级列表
List
<
int
>
gradeIdlist
=
new
List
<
int
>();
if
(
OneDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
OneDistributorGrade
);
}
if
(
TwoDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
TwoDistributorGrade
);
}
if
(
ThreeDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
ThreeDistributorGrade
);
}
List
<
RB_Distributor_Grade_Extend
>
dgradeList
=
new
List
<
RB_Distributor_Grade_Extend
>();
if
(
gradeIdlist
.
Any
())
#
region
分销商
id
+
分销商等级
int
OneUserId
=
0
,
TwoUserId
=
0
,
ThreeUserId
=
0
;
int
OneDistributorGrade
=
0
,
TwoDistributorGrade
=
0
,
ThreeDistributorGrade
=
0
;
//获取多级 分销商id
if
(
basicModel
!=
null
&&
basicModel
.
DistributorTier
>
0
)
{
dgradeList
=
distributor_GradeRepository
.
GetList
(
new
RB_Distributor_Grade_Extend
()
{
GradeIds
=
string
.
Join
(
","
,
gradeIdlist
),
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
#
endregion
foreach
(
var
item
in
demodel
.
DetailList
)
{
//返佣
List
<
RB_Goods_OrderCommission
>
gocList
=
new
List
<
RB_Goods_OrderCommission
>();
for
(
int
i
=
1
;
i
<
basicModel
.
DistributorTier
+
1
;
i
++)
{
switch
(
i
)
{
case
1
:
decimal
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
if
(
umodel
.
IsDistributor
!=
1
||
basicModel
.
InPurchasing
!=
1
)
{
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
OneCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
OneCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
OneUserId
=
umodel
.
SuperiorId
??
0
;
}
else
{
//获取分销商等级
if
(
OneDistributorGrade
>
0
)
OneUserId
=
umodel
.
Id
;
}
break
;
case
2
:
if
(
OneUserId
>
0
)
{
if
(
umodel
.
IsDistributor
!=
1
||
basicModel
.
InPurchasing
!=
1
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
OneDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
OneCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
TwoUserId
=
member_UserRepository
.
GetEntity
(
OneUserId
).
SuperiorId
??
0
;
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
OneCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
TwoUserId
=
umodel
.
SuperiorId
??
0
;
}
}
if
(
TwoUserId
==
0
&&
basicModel
.
IsCommissionResidue
==
1
)
{
//表示其为一级分销商 把后面的佣金都提完
TwoUserId
=
OneUserId
;
TwoDistributorGrade
=
OneDistributorGrade
;
}
RB_Goods_OrderCommission
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
umodel
.
IsDistributor
==
1
?
0
:
1
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
OneUserId
};
gocList
.
Add
(
gocModel
);
break
;
case
2
:
case
3
:
if
(
TwoUserId
>
0
)
{
DcommionMoney
=
0
;
ThreeUserId
=
member_UserRepository
.
GetEntity
(
TwoUserId
).
SuperiorId
??
0
;
}
break
;
}
}
}
if
(
OneUserId
>
0
)
{
if
(
OneUserId
>
0
)
{
OneDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
OneUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
TwoUserId
>
0
)
{
TwoDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
TwoUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
if
(
ThreeUserId
>
0
)
{
ThreeDistributorGrade
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
UserId
=
ThreeUserId
})?.
FirstOrDefault
()?.
GradeId
??
0
;
}
#
endregion
#
region
分销商等级列表
List
<
int
>
gradeIdlist
=
new
List
<
int
>();
if
(
OneDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
OneDistributorGrade
);
}
if
(
TwoDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
TwoDistributorGrade
);
}
if
(
ThreeDistributorGrade
>
0
)
{
gradeIdlist
.
Add
(
ThreeDistributorGrade
);
}
List
<
RB_Distributor_Grade_Extend
>
dgradeList
=
new
List
<
RB_Distributor_Grade_Extend
>();
if
(
gradeIdlist
.
Any
())
{
dgradeList
=
distributor_GradeRepository
.
GetList
(
new
RB_Distributor_Grade_Extend
()
{
GradeIds
=
string
.
Join
(
","
,
gradeIdlist
),
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
#
endregion
foreach
(
var
item
in
demodel
.
DetailList
)
{
//返佣
List
<
RB_Goods_OrderCommission
>
gocList
=
new
List
<
RB_Goods_OrderCommission
>();
for
(
int
i
=
1
;
i
<
basicModel
.
DistributorTier
+
1
;
i
++)
{
switch
(
i
)
{
case
1
:
decimal
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
Two
Commission
??
0
;
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
One
Commission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
Two
Commission
??
0
;
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
OneDistributorGrade
).
FirstOrDefault
()?.
One
Commission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
...
...
@@ -2681,10 +2716,10 @@ namespace Mall.Module.Product
else
{
//获取分销商等级
if
(
Two
DistributorGrade
>
0
)
if
(
One
DistributorGrade
>
0
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
Two
DistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
Two
Commission
??
0
;
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
One
DistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
One
Commission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
...
...
@@ -2693,7 +2728,7 @@ namespace Mall.Module.Product
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
Two
Commission
??
0
;
DcommionMoney
=
basicModel
.
One
Commission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
...
...
@@ -2701,19 +2736,19 @@ namespace Mall.Module.Product
}
}
if
(
T
hree
UserId
==
0
&&
basicModel
.
IsCommissionResidue
==
1
)
if
(
T
wo
UserId
==
0
&&
basicModel
.
IsCommissionResidue
==
1
)
{
//表示其为
二
级分销商 把后面的佣金都提完
T
hreeUserId
=
Two
UserId
;
T
hreeDistributorGrade
=
Two
DistributorGrade
;
//表示其为
一
级分销商 把后面的佣金都提完
T
woUserId
=
One
UserId
;
T
woDistributorGrade
=
One
DistributorGrade
;
}
gocModel
=
new
RB_Goods_OrderCommission
()
RB_Goods_OrderCommission
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
umodel
.
IsDistributor
==
1
?
TwoUserId
==
OneUserId
?
0
:
1
:
2
,
Grade
=
umodel
.
IsDistributor
==
1
?
0
:
1
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
...
...
@@ -2721,121 +2756,188 @@ namespace Mall.Module.Product
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
Two
UserId
UserId
=
One
UserId
};
gocList
.
Add
(
gocModel
);
}
break
;
case
3
:
if
(
ThreeUserId
>
0
)
{
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
break
;
case
2
:
if
(
TwoUserId
>
0
)
{
if
(
item
.
SeparateDistributionType
==
1
)
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
TwoCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
TwoDistributorGrade
).
FirstOrDefault
()?.
TwoCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
//获取分销商等级
if
(
TwoDistributorGrade
>
0
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
TwoDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
TwoCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
TwoCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
if
(
item
.
SeparateDistributionMoneyTyp
e
==
1
)
if
(
ThreeUserId
==
0
&&
basicModel
.
IsCommissionResidu
e
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
//表示其为二级分销商 把后面的佣金都提完
ThreeUserId
=
TwoUserId
;
ThreeDistributorGrade
=
TwoDistributorGrade
;
}
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
umodel
.
IsDistributor
==
1
?
TwoUserId
==
OneUserId
?
0
:
1
:
2
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
TwoUserId
};
gocList
.
Add
(
gocModel
);
}
else
break
;
case
3
:
if
(
ThreeUserId
>
0
)
{
//获取分销商等级
if
(
ThreeDistributorGrade
>
0
)
DcommionMoney
=
0
;
if
(
item
.
SeparateDistribution
==
1
)
{
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
ThreeDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
ThreeCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
if
(
item
.
SeparateDistributionType
==
1
)
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
}
else
{
DcommionMoney
=
dcList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
GoodsId
&&
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
ThreeDistributorGrade
).
FirstOrDefault
()?.
ThreeCommission
??
0
;
}
if
(
item
.
SeparateDistributionMoneyType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
ThreeCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
//获取分销商等级
if
(
ThreeDistributorGrade
>
0
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
var
dgradeModel
=
dgradeList
.
Where
(
x
=>
x
.
Id
==
ThreeDistributorGrade
).
FirstOrDefault
();
DcommionMoney
=
dgradeModel
?.
ThreeCommission
??
0
;
if
(
dgradeModel
.
DistributionCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
//默认分销商等级 读取基本配置的返佣
DcommionMoney
=
basicModel
.
ThreeCommission
??
0
;
if
(
basicModel
.
DistributorCommissionType
==
1
)
{
DcommionMoney
=
Math
.
Round
((
item
.
Final_Price
??
0
)
*
DcommionMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
}
#
region
获取返佣等级
int
Grade
=
0
;
if
(
OneUserId
==
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
0
;
}
else
if
(
OneUserId
!=
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
1
;
}
else
{
Grade
=
2
;
}
if
(
umodel
.
IsDistributor
!=
1
)
{
Grade
++;
}
#
endregion
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
Grade
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
ThreeUserId
};
gocList
.
Add
(
gocModel
);
}
#
region
获取返佣等级
int
Grade
=
0
;
if
(
OneUserId
==
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
0
;
}
else
if
(
OneUserId
!=
TwoUserId
&&
TwoUserId
==
ThreeUserId
)
{
Grade
=
1
;
}
else
{
Grade
=
2
;
}
if
(
umodel
.
IsDistributor
!=
1
)
{
Grade
++;
}
#
endregion
gocModel
=
new
RB_Goods_OrderCommission
()
{
Id
=
0
,
Commission
=
DcommionMoney
,
CommissionState
=
1
,
CreateDate
=
DateTime
.
Now
,
Grade
=
Grade
,
IsGoodsDistribution
=
item
.
SeparateDistribution
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailId
=
item
.
Id
,
OrderId
=
OrderId
,
Remark
=
""
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
DateTime
.
Now
,
UserId
=
ThreeUserId
};
gocList
.
Add
(
gocModel
);
}
break
;
break
;
}
}
}
List
<
RB_Goods_OrderCommission
>
gocfulList
=
gocList
;
//gocList 合并用户金额
if
(
basicModel
.
IsCommissionResidue
==
1
)
{
gocfulList
=
new
List
<
RB_Goods_OrderCommission
>();
if
(
gocList
.
Count
()
!=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
Count
())
List
<
RB_Goods_OrderCommission
>
gocfulList
=
gocList
;
//gocList 合并用户金额
if
(
basicModel
.
IsCommissionResidue
==
1
)
{
//说明有用户可以合并
var
userIdList
=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
ToList
();
foreach
(
var
qitem
in
userIdList
)
gocfulList
=
new
List
<
RB_Goods_OrderCommission
>();
if
(
gocList
.
Count
()
!=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
Count
())
{
var
gocModel
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
FirstOrDefault
();
if
(
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Count
()
>
1
)
//说明有用户可以合并
var
userIdList
=
gocList
.
Select
(
x
=>
x
.
UserId
).
Distinct
().
ToList
();
foreach
(
var
qitem
in
userIdList
)
{
decimal
tcommission
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Sum
(
x
=>
x
.
Commission
??
0
);
gocModel
.
Commission
=
tcommission
;
gocModel
.
Remark
=
"多级全额返佣"
;
var
gocModel
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
FirstOrDefault
();
if
(
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Count
()
>
1
)
{
decimal
tcommission
=
gocList
.
Where
(
x
=>
x
.
UserId
==
qitem
).
Sum
(
x
=>
x
.
Commission
??
0
);
gocModel
.
Commission
=
tcommission
;
gocModel
.
Remark
=
"多级全额返佣"
;
}
gocfulList
.
Add
(
gocModel
);
}
gocfulList
.
Add
(
gocModel
);
}
}
}
if
(
gocfulList
.
Any
())
{
foreach
(
var
qitem
in
gocfulList
)
if
(
gocfulList
.
Any
())
{
goods_OrderCommissionRepository
.
Insert
(
qitem
,
trans
);
foreach
(
var
qitem
in
gocfulList
)
{
goods_OrderCommissionRepository
.
Insert
(
qitem
,
trans
);
}
}
}
}
...
...
Mall.Module.Product/ProductModule.cs
View file @
bc33739d
...
...
@@ -7,6 +7,7 @@ using Mall.Common;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Model.Entity.Product
;
using
Mall.Model.Entity.User
;
using
Mall.Model.Extend.Product
;
using
Mall.Model.Extend.User
;
using
Mall.Model.Query
;
...
...
@@ -134,6 +135,15 @@ namespace Mall.Module.Product
/// </summary>
private
readonly
Rb_destinationRepository
destinationRepository
=
new
Rb_destinationRepository
();
/// <summary>
/// 和平返佣
/// </summary>
private
readonly
RB_Distributor_HPCommissionRepository
distributor_HPCommissionRepository
=
new
RB_Distributor_HPCommissionRepository
();
/// <summary>
/// 和平返佣比例
/// </summary>
private
readonly
RB_Distributor_HPGradeRatioRepository
distributor_HPGradeRatioRepository
=
new
RB_Distributor_HPGradeRatioRepository
();
#
region
小程序接口
...
...
@@ -735,67 +745,866 @@ namespace Mall.Module.Product
var
disModel
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
,
UserId
=
UserId
,
AuditStatus
=
Common
.
Enum
.
User
.
DistributorAuditStatusEnum
.
Audited
}).
FirstOrDefault
();
if
(
disModel
!=
null
)
{
var
BasicsModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
}).
FirstOrDefault
();
if
(
model
.
SeparateDistribution
==
1
)
//判断是否开启和平返佣
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
Status
),
FiledValue
=
0
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
Enabled
),
FiledValue
=
1
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
TenantId
),
FiledValue
=
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
MallBaseId
),
FiledValue
=
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
if
(
distributor_HPCommissionRepository
.
Exists
(
wheres
))
{
//获取和平分销返佣
if
(
disModel
.
HPGradeId
>
0
&&
model
.
CostPrice
>
0
)
{
string
categoryids
=
string
.
Join
(
","
,
model
.
CategoryList
.
Select
(
x
=>
x
.
CategoryId
));
var
hpcList
=
distributor_HPCommissionRepository
.
GetList
(
new
RB_Distributor_HPCommission_Extend
()
{
CategoryIdsT
=
categoryids
});
if
(
hpcList
.
Any
())
{
RB_Distributor_HPCommission_Extend
hpcModel
;
if
(
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
Any
())
{
//有使用非通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
FirstOrDefault
();
}
else
{
//查询通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
==
1
).
FirstOrDefault
();
}
//查询所有返佣比例
var
gList
=
distributor_HPGradeRatioRepository
.
GetList
(
new
RB_Distributor_HPGradeRatio_Extend
()
{
CommissionId
=
hpcModel
.
Id
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
var
ratioModel
=
gList
.
Where
(
x
=>
x
.
GradeId
==
disModel
.
HPGradeId
).
FirstOrDefault
();
decimal
MPrice
=
(
model
.
CostPrice
??
0
)
/
(
1
-
((
ratioModel
.
CommissionRatio
??
0
)
/
100
));
if
(
hpcModel
.
DecimalType
==
1
)
{
MPrice
=
Math
.
Ceiling
(
MPrice
);
}
else
if
(
hpcModel
.
DecimalType
==
2
)
{
MPrice
=
Math
.
Ceiling
(
MPrice
*
100
)
/
100
;
}
model
.
MaxShare
=
MaxSellMoney
-
MPrice
>
0
?
MaxSellMoney
-
MPrice
:
0
;
}
}
}
else
{
var
dcList
=
model
.
DistributionCommissionList
.
Where
(
x
=>
x
.
DistributorGrade
==
disModel
.
GradeId
).
ToLis
t
();
if
(
(
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
var
BasicsModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
}).
FirstOrDefaul
t
();
if
(
model
.
SeparateDistribution
==
1
)
{
model
.
MaxShare
=
dcList
.
Max
(
x
=>
(
x
.
OneCommission
??
0
)
+
(
x
.
TwoCommission
??
0
)
+
(
x
.
ThreeCommission
??
0
));
var
dcList
=
model
.
DistributionCommissionList
.
Where
(
x
=>
x
.
DistributorGrade
==
disModel
.
GradeId
).
ToList
();
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
dcList
.
Max
(
x
=>
(
x
.
OneCommission
??
0
)
+
(
x
.
TwoCommission
??
0
)
+
(
x
.
ThreeCommission
??
0
));
}
else
{
model
.
MaxShare
=
dcList
.
Max
(
x
=>
x
.
OneCommission
??
0
);
}
// 这里需注意,可能需要分销 是否提所有返佣控制
if
(
model
.
SeparateDistributionMoneyType
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
{
model
.
MaxShare
=
dcList
.
Max
(
x
=>
x
.
OneCommission
??
0
);
if
(
disModel
.
GradeId
==
0
)
{
//拿分销基础配置
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
(
BasicsModel
?.
OneCommission
??
0
)
+
(
BasicsModel
?.
TwoCommission
??
0
)
+
(
BasicsModel
?.
ThreeCommission
??
0
);
}
else
{
model
.
MaxShare
=
BasicsModel
?.
OneCommission
??
0
;
}
if
((
BasicsModel
?.
DistributorCommissionType
??
2
)
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
if
(
disModel
.
GradeId
>
0
)
{
//获取分销商等级
var
disgradeModel
=
distributor_GradeRepository
.
GetEntity
(
disModel
.
GradeId
);
if
(
disgradeModel
!=
null
)
{
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
(
disgradeModel
?.
OneCommission
??
0
)
+
(
disgradeModel
?.
TwoCommission
??
0
)
+
(
disgradeModel
?.
ThreeCommission
??
0
);
}
else
{
model
.
MaxShare
=
disgradeModel
?.
OneCommission
??
0
;
}
if
((
disgradeModel
?.
DistributionCommissionType
??
2
)
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
}
}
}
}
#
endregion
return
model
;
}
/// <summary>
/// 获取小程序商品详情
/// </summary>
/// <param name="goodsId"></param>
/// <param name="UserId"></param>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <returns></returns>
public
object
GetAppletGoodsInfo_V2
(
int
goodsId
,
int
UserId
,
int
TenantId
,
int
MallBaseId
)
{
var
model
=
goodsRepository
.
GetEntity
(
goodsId
).
RefMapperTo
<
RB_Goods_Extend
>();
if
(
model
==
null
||
model
.
TenantId
!=
TenantId
||
model
.
MallBaseId
!=
MallBaseId
)
{
return
null
;
}
//小程序名称
model
.
MallName
=
programRepository
.
GetEntity
(
model
.
MallBaseId
)?.
MallName
??
""
;
#
region
基本信息
//查询分类
model
.
CategoryList
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
//最大售价
decimal
MaxSellMoney
=
model
.
SellingPrice
??
0
;
model
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
model
.
SpecificationPriceList
=
new
List
<
RB_Goods_SpecificationPrice_Extend
>();
if
(
model
.
IsCustomSpecification
==
1
)
{
model
.
SpecificationList
=
goods_SpecificationRepository
.
GetList
(
new
RB_Goods_Specification_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
if
(
model
.
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
svlist
)
{
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
model
.
SpecificationList
)
{
item
.
SpecificationValueList
=
svlist
.
Where
(
x
=>
x
.
SpecificationId
==
item
.
Id
).
ToList
();
}
}
model
.
SpecificationPriceList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
MaxSellMoney
=
model
.
SpecificationPriceList
.
Max
(
x
=>
x
.
SellingPrice
??
0
);
}
//区域
model
.
AreaList
=
new
List
<
RB_Goods_Area_Extend
>();
if
(
model
.
IsAreaBuy
==
1
)
{
model
.
AreaList
=
goods_AreaRepository
.
GetList
(
new
RB_Goods_Area_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
}
//返佣
model
.
DistributionCommissionList
=
new
List
<
RB_Goods_DistributionCommission_Extend
>();
if
(
model
.
SeparateDistribution
==
1
)
{
model
.
DistributionCommissionList
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
}
//会员价格
model
.
MemberPriceList
=
new
List
<
RB_Goods_MemberPrice_Extend
>();
if
(
model
.
EnjoyMember
==
1
&&
model
.
SeparateSetMember
==
1
)
{
model
.
MemberPriceList
=
goods_MemberPriceRepository
.
GetList
(
new
RB_Goods_MemberPrice_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
}
//轮播
model
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
model
.
CarouselImage
)
&&
model
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
model
.
CarouselImage
);
//轮播图
foreach
(
var
item
in
CarouselIdList
)
{
model
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
0
,
Name
=
""
,
Path
=
item
});
}
}
model
.
CustomShareImagePath
=
model
.
CustomShareImage
;
//服务列表
model
.
ServiceList
=
new
List
<
RB_ImageCommonModel
>();
if
(
model
.
IsDefaultService
==
2
)
{
if
(!
string
.
IsNullOrEmpty
(
model
.
GoodsService
)
&&
model
.
GoodsService
!=
"[]"
)
{
List
<
int
>
ServiceIds
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
model
.
GoodsService
);
var
slist
=
product_ServiceRepository
.
GetList
(
new
RB_Product_Service_Extend
()
{
ServiceIds
=
string
.
Join
(
","
,
ServiceIds
),
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
slist
)
{
model
.
ServiceList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
item
.
Id
,
Name
=
item
.
Name
});
}
}
}
else
if
(
model
.
IsDefaultService
==
1
)
{
var
slist
=
product_ServiceRepository
.
GetList
(
new
RB_Product_Service_Extend
()
{
IsDefault
=
1
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
slist
)
{
model
.
ServiceList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
item
.
Id
,
Name
=
item
.
Name
});
}
}
//表单
if
(
model
.
FormsId
>
0
)
{
model
.
FormsName
=
"未建表"
;
}
else
{
model
.
FormsName
=
"默认表单"
;
}
#
endregion
#
region
是否收藏
model
.
Favorite
=
false
;
if
(
UserId
>
0
)
{
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Collection_Extend
.
UserId
),
FiledValue
=
UserId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Collection_Extend
.
GoodsId
),
FiledValue
=
goodsId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Collection_Extend
.
TenantId
),
FiledValue
=
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Member_Collection_Extend
.
MallBaseId
),
FiledValue
=
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
};
if
(
member_CollectionRepository
.
Exists
(
wheres
))
{
model
.
Favorite
=
true
;
}
}
#
endregion
#
region
快递费用
//运费
Model
.
Entity
.
BaseSetUp
.
RB_Logistics_Rules
rulesModel
=
new
Model
.
Entity
.
BaseSetUp
.
RB_Logistics_Rules
();
if
(
model
.
FreightId
>
0
)
{
rulesModel
=
logistics_RulesRepository
.
GetEntity
(
model
.
FreightId
);
model
.
FreightName
=
rulesModel
?.
RulesName
??
""
;
}
else
{
model
.
FreightName
=
"默认运费"
;
}
model
.
Express
=
0
;
if
(
UserId
>
0
&&
model
.
FreightId
>=
0
)
{
int
FreightId
=
0
;
if
(
model
.
FreightId
==
0
)
{
//查询默认
FreightId
=
logistics_RulesRepository
.
GetLogisticsRulesList
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_Rules_Extend
()
{
IsDefault
=
1
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
}).
FirstOrDefault
()?.
ID
??
0
;
}
if
(
FreightId
>
0
)
{
var
samodel
=
member_ShippingAddressRepository
.
GetList
(
new
RB_Member_ShippingAddress_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
,
UserId
=
UserId
,
IsDefault
=
1
}).
FirstOrDefault
();
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
>
priceList1
=
logistics_RulesPriceRepository
.
GetListRepository
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesPrice_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
,
RulesId
=
FreightId
});
if
(
priceList1
.
Any
()
&&
samodel
!=
null
)
{
string
priceIds
=
string
.
Join
(
","
,
priceList1
.
Select
(
x
=>
x
.
ID
));
var
regionList
=
logistics_RulesRegionRepository
.
GetListRepository
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Logistics_RulesRegion_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
,
PriceIds
=
priceIds
});
List
<
int
>
disList
=
new
List
<
int
>();
disList
.
Add
(
samodel
.
Province
??
0
);
disList
.
Add
(
samodel
.
City
??
0
);
disList
.
Add
(
samodel
.
District
??
0
);
var
regionModel
=
regionList
.
Where
(
x
=>
disList
.
Contains
(
x
.
RegionId
)).
FirstOrDefault
();
if
(
regionModel
!=
null
)
{
var
pmodel
=
priceList1
.
Where
(
x
=>
x
.
ID
==
regionModel
.
RulesPriceId
).
FirstOrDefault
();
if
(
pmodel
!=
null
&&
rulesModel
!=
null
)
{
if
(
rulesModel
.
ChargeMode
==
Common
.
Enum
.
MallBase
.
ChargeModeEnum
.
Num
)
{
model
.
Express
=
pmodel
.
FirstPrice
;
}
else
{
//重量计费
int
TotalW
=
model
.
GoodsWeight
??
0
;
if
(
TotalW
<=
pmodel
.
First
)
{
model
.
Express
=
pmodel
.
FirstPrice
;
}
else
{
if
(
pmodel
.
Second
>
0
)
{
if
((
TotalW
-
pmodel
.
First
)
%
pmodel
.
Second
==
0
)
{
model
.
Express
=
pmodel
.
FirstPrice
+
((
TotalW
-
pmodel
.
First
)
/
pmodel
.
Second
)
*
pmodel
.
SecondPrice
;
}
else
{
model
.
Express
=
pmodel
.
FirstPrice
+
((
TotalW
-
pmodel
.
First
)
/
pmodel
.
Second
+
1
)
*
pmodel
.
SecondPrice
;
}
}
else
{
model
.
Express
=
pmodel
.
FirstPrice
;
}
}
}
}
}
// 这里需注意,可能需要分销 是否提所有返佣控制
if
(
model
.
SeparateDistributionMoneyType
==
1
)
}
}
}
#
endregion
#
region
最高返佣
model
.
MaxShare
=
0
;
if
(
UserId
>
0
)
{
//获取分销商信息
var
disModel
=
distributor_InfoRepository
.
GetList
(
new
RB_Distributor_Info_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
,
UserId
=
UserId
,
AuditStatus
=
Common
.
Enum
.
User
.
DistributorAuditStatusEnum
.
Audited
}).
FirstOrDefault
();
if
(
disModel
!=
null
)
{
//判断是否开启和平返佣
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
Status
),
FiledValue
=
0
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
Enabled
),
FiledValue
=
1
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
TenantId
),
FiledValue
=
TenantId
,
OperatorEnum
=
OperatorEnum
.
Equal
},
new
WhereHelper
(){
FiledName
=
nameof
(
RB_Distributor_HPCommission
.
MallBaseId
),
FiledValue
=
MallBaseId
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
if
(
distributor_HPCommissionRepository
.
Exists
(
wheres
))
{
//获取和平分销返佣
if
(
disModel
.
HPGradeId
>
0
&&
model
.
CostPrice
>
0
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
string
categoryids
=
string
.
Join
(
","
,
model
.
CategoryList
.
Select
(
x
=>
x
.
CategoryId
));
var
hpcList
=
distributor_HPCommissionRepository
.
GetList
(
new
RB_Distributor_HPCommission_Extend
()
{
CategoryIdsT
=
categoryids
});
if
(
hpcList
.
Any
())
{
RB_Distributor_HPCommission_Extend
hpcModel
;
if
(
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
Any
())
{
//有使用非通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
!=
1
).
FirstOrDefault
();
}
else
{
//查询通用返佣
hpcModel
=
hpcList
.
Where
(
x
=>
x
.
IsCommon
==
1
).
FirstOrDefault
();
}
//查询所有返佣比例
var
gList
=
distributor_HPGradeRatioRepository
.
GetList
(
new
RB_Distributor_HPGradeRatio_Extend
()
{
CommissionId
=
hpcModel
.
Id
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
var
ratioModel
=
gList
.
Where
(
x
=>
x
.
GradeId
==
disModel
.
HPGradeId
).
FirstOrDefault
();
decimal
MPrice
=
(
model
.
CostPrice
??
0
)
/
(
1
-
((
ratioModel
.
CommissionRatio
??
0
)
/
100
));
if
(
hpcModel
.
DecimalType
==
1
)
{
MPrice
=
Math
.
Ceiling
(
MPrice
);
}
else
if
(
hpcModel
.
DecimalType
==
2
)
{
MPrice
=
Math
.
Ceiling
(
MPrice
*
100
)
/
100
;
}
model
.
MaxShare
=
MaxSellMoney
-
MPrice
>
0
?
MaxSellMoney
-
MPrice
:
0
;
}
}
}
else
{
if
(
disModel
.
GradeId
==
0
)
var
BasicsModel
=
distributor_BasicsRepository
.
GetList
(
new
RB_Distributor_Basics_Extend
()
{
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
}).
FirstOrDefault
();
if
(
model
.
SeparateDistribution
==
1
)
{
//拿分销基础配置
var
dcList
=
model
.
DistributionCommissionList
.
Where
(
x
=>
x
.
DistributorGrade
==
disModel
.
GradeId
).
ToList
();
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
(
BasicsModel
?.
OneCommission
??
0
)
+
(
BasicsModel
?.
TwoCommission
??
0
)
+
(
BasicsModel
?.
ThreeCommission
??
0
);
model
.
MaxShare
=
dcList
.
Max
(
x
=>
(
x
.
OneCommission
??
0
)
+
(
x
.
TwoCommission
??
0
)
+
(
x
.
ThreeCommission
??
0
)
);
}
else
{
model
.
MaxShare
=
BasicsModel
?.
OneCommission
??
0
;
model
.
MaxShare
=
dcList
.
Max
(
x
=>
x
.
OneCommission
??
0
)
;
}
if
((
BasicsModel
?.
DistributorCommissionType
??
2
)
==
1
)
// 这里需注意,可能需要分销 是否提所有返佣控制
if
(
model
.
SeparateDistributionMoneyType
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
if
(
disModel
.
GradeId
>
0
)
else
{
//获取分销商等级
var
disgradeModel
=
distributor_GradeRepository
.
GetEntity
(
disModel
.
GradeId
);
if
(
disgradeModel
!=
null
)
if
(
disModel
.
GradeId
==
0
)
{
//拿分销基础配置
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
(
disgradeModel
?.
OneCommission
??
0
)
+
(
disgradeModel
?.
TwoCommission
??
0
)
+
(
disgrade
Model
?.
ThreeCommission
??
0
);
model
.
MaxShare
=
(
BasicsModel
?.
OneCommission
??
0
)
+
(
BasicsModel
?.
TwoCommission
??
0
)
+
(
Basics
Model
?.
ThreeCommission
??
0
);
}
else
{
model
.
MaxShare
=
disgrade
Model
?.
OneCommission
??
0
;
model
.
MaxShare
=
Basics
Model
?.
OneCommission
??
0
;
}
if
((
disgradeModel
?.
Distribution
CommissionType
??
2
)
==
1
)
if
((
BasicsModel
?.
Distributor
CommissionType
??
2
)
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
else
if
(
disModel
.
GradeId
>
0
)
{
//获取分销商等级
var
disgradeModel
=
distributor_GradeRepository
.
GetEntity
(
disModel
.
GradeId
);
if
(
disgradeModel
!=
null
)
{
if
((
BasicsModel
?.
IsCommissionResidue
??
2
)
==
1
)
{
model
.
MaxShare
=
(
disgradeModel
?.
OneCommission
??
0
)
+
(
disgradeModel
?.
TwoCommission
??
0
)
+
(
disgradeModel
?.
ThreeCommission
??
0
);
}
else
{
model
.
MaxShare
=
disgradeModel
?.
OneCommission
??
0
;
}
if
((
disgradeModel
?.
DistributionCommissionType
??
2
)
==
1
)
{
model
.
MaxShare
=
Math
.
Round
(
model
.
MaxShare
*
MaxSellMoney
/
100
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
}
}
}
}
}
#
endregion
return
model
;
#
region
最外层组装参数
RB_Member_User_Extend
userModel
=
new
RB_Member_User_Extend
();
List
<
RB_Member_Grade_Extend
>
memeberList
=
new
List
<
RB_Member_Grade_Extend
>();
if
(
UserId
>
0
)
{
userModel
=
GetMemberUserInfo
(
UserId
);
if
(
userModel
.
MemberGrade
>
0
)
{
memeberList
=
GetMemberGradeList
(
new
RB_Member_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
}
}
#
region
组装价格
List
<
object
>
priceList
=
new
List
<
object
>();
if
(
model
.
IsCustomSpecification
==
1
)
{
if
(
model
.
SpecificationPriceList
.
Any
()
&&
model
.
SpecificationList
.
Any
())
{
foreach
(
var
item
in
model
.
SpecificationPriceList
)
{
var
ssarr
=
item
.
SpecificationSort
.
Split
(
':'
);
int
Sort
=
Convert
.
ToInt32
(
ssarr
[
0
]);
string
pic_url
=
model
.
SpecificationList
[
0
].
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Sort
).
FirstOrDefault
()?.
ImagePath
;
List
<
object
>
attr_list
=
new
List
<
object
>();
for
(
int
i
=
0
;
i
<
ssarr
.
Length
;
i
++)
{
var
smodel
=
model
.
SpecificationList
[
i
];
var
svmodel
=
smodel
.
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Convert
.
ToInt32
(
ssarr
[
i
])).
FirstOrDefault
();
attr_list
.
Add
(
new
{
attr_group_name
=
smodel
.
Name
,
attr_group_id
=
smodel
.
Sort
,
attr_id
=
svmodel
.
Id
,
attr_name
=
svmodel
.
Name
});
}
decimal
price_member
=
item
.
SellingPrice
??
0
;
//未设会员价格的话 就为销售价格
List
<
object
>
member_price_list
=
new
List
<
object
>();
if
(
model
.
EnjoyMember
==
1
&&
model
.
SeparateSetMember
==
1
)
{
if
(
model
.
MemberPriceList
.
Any
())
{
var
mlist
=
model
.
MemberPriceList
.
Where
(
x
=>
x
.
SpecificationSort
==
item
.
SpecificationSort
).
ToList
();
foreach
(
var
qitem
in
mlist
)
{
member_price_list
.
Add
(
new
{
member_grade
=
qitem
.
MemberGrade
,
member_price
=
qitem
.
MemberPrice
});
}
if
(
UserId
>
0
&&
userModel
.
MemberGrade
>
0
)
{
var
gmodel
=
mlist
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
gmodel
.
MemberPrice
??
0
;
}
else
{
price_member
=
mlist
.
Max
(
x
=>
x
.
MemberPrice
??
0
);
}
}
}
else
{
//根据会员等级查找会员价格
foreach
(
var
qitem
in
memeberList
)
{
var
mprice
=
Math
.
Round
((
item
.
SellingPrice
??
0
)
*
(
qitem
.
Discount
??
0
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
member_price_list
.
Add
(
new
{
member_grade
=
qitem
.
Grade
,
member_price
=
mprice
});
}
if
(
UserId
>
0
&&
userModel
.
MemberGrade
>
0
&&
memeberList
.
Any
())
{
var
gmodel
=
memeberList
.
Where
(
x
=>
x
.
Grade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
gmodel
?.
Discount
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
else
if
(
memeberList
.
Any
())
{
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
memeberList
.
Max
(
x
=>
x
.
Discount
)
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
priceList
.
Add
(
new
{
id
=
item
.
Id
,
goods_id
=
model
.
Id
,
sign_id
=
item
.
SpecificationSort
,
stock
=
item
.
InventoryNum
,
price
=
item
.
SellingPrice
,
no
=
item
.
GoodsNumbers
,
weight
=
item
.
GoodsWeight
,
pic_url
,
is_delete
=
item
.
Status
,
attr_list
,
price_member
,
member_price_list
});
}
}
}
else
{
decimal
price_member
=
model
.
SellingPrice
??
0
;
//未设会员价格的话 就为销售价格
List
<
object
>
member_price_list
=
new
List
<
object
>();
if
(
model
.
EnjoyMember
==
1
&&
model
.
SeparateSetMember
==
1
)
{
if
(
model
.
MemberPriceList
.
Any
())
{
var
mlist
=
model
.
MemberPriceList
;
foreach
(
var
qitem
in
mlist
)
{
member_price_list
.
Add
(
new
{
member_grade
=
qitem
.
MemberGrade
,
member_price
=
qitem
.
MemberPrice
});
}
if
(
UserId
>
0
&&
userModel
.
MemberGrade
>
0
)
{
var
gmodel
=
mlist
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
gmodel
.
MemberPrice
??
0
;
}
else
{
price_member
=
mlist
.
Max
(
x
=>
x
.
MemberPrice
??
0
);
}
}
}
else
{
//根据会员等级查找会员价格
foreach
(
var
qitem
in
memeberList
)
{
var
mprice
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
qitem
.
Discount
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
member_price_list
.
Add
(
new
{
member_grade
=
qitem
.
Grade
,
member_price
=
mprice
});
}
if
(
UserId
>
0
&&
userModel
.
MemberGrade
>
0
&&
memeberList
.
Any
())
{
var
gmodel
=
memeberList
.
Where
(
x
=>
x
.
Grade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
gmodel
?.
Discount
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
else
if
(
memeberList
.
Any
())
{
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
memeberList
.
Max
(
x
=>
x
.
Discount
)
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
priceList
.
Add
(
new
{
id
=
0
,
goods_id
=
model
.
Id
,
sign_id
=
""
,
stock
=
model
.
InventoryNum
,
price
=
model
.
SellingPrice
??
0
,
no
=
model
.
GoodsNumbers
,
weight
=
model
.
GoodsWeight
,
pic_url
=
""
,
is_delete
=
0
,
attr_list
=
new
List
<
object
>(){
new
{
attr_group_name
=
"规格"
,
attr_group_id
=
0
,
attr_id
=
0
,
attr_name
=
model
.
DefaultSpecificationName
}
},
price_member
,
member_price_list
});
}
#
endregion
#
region
赠送积分
int
Integral
=
0
;
if
(
model
.
IntegralPresent
>
0
)
{
Integral
=
model
.
IntegralPresent
??
0
;
if
(
model
.
IntegralPresentType
==
2
)
{
Integral
=
Convert
.
ToInt32
(
Math
.
Floor
((
model
.
SellingPrice
??
0
)
*
(
model
.
IntegralPresent
??
0
)
/
100
));
}
}
#
endregion
#
region
会员价格
decimal
price_member_max
=
0
,
price_member_min
=
0
,
price_min
=
0
,
price_max
=
0
;
if
(
model
.
EnjoyMember
==
1
&&
model
.
SeparateSetMember
==
1
&&
model
.
MemberPriceList
.
Any
())
{
price_member_min
=
model
.
MemberPriceList
.
Min
(
x
=>
x
.
MemberPrice
??
0
);
price_member_max
=
model
.
MemberPriceList
.
Max
(
x
=>
x
.
MemberPrice
??
0
);
if
(
userModel
.
MemberGrade
>
0
)
{
price_min
=
model
.
MemberPriceList
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
Min
(
x
=>
x
.
MemberPrice
??
0
);
price_max
=
model
.
MemberPriceList
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
Max
(
x
=>
x
.
MemberPrice
??
0
);
}
}
else
{
if
(
model
.
IsCustomSpecification
==
1
)
{
price_member_min
=
price_min
=
model
.
SpecificationPriceList
.
Min
(
x
=>
x
.
SellingPrice
??
0
);
price_member_max
=
price_max
=
model
.
SpecificationPriceList
.
Max
(
x
=>
x
.
SellingPrice
??
0
);
}
else
{
price_member_min
=
price_member_max
=
price_min
=
price_max
=
model
.
SellingPrice
??
0
;
}
if
(
memeberList
.
Any
())
{
List
<
decimal
>
pricelist
=
new
List
<
decimal
>();
foreach
(
var
item
in
memeberList
)
{
pricelist
.
Add
(
price_member_min
*
(
item
.
Discount
??
10
)
/
10
);
pricelist
.
Add
(
price_member_max
*
(
item
.
Discount
??
10
)
/
10
);
}
price_member_min
=
pricelist
.
Min
(
x
=>
x
);
price_member_max
=
pricelist
.
Max
(
x
=>
x
);
if
(
userModel
.
MemberGrade
>
0
)
{
if
(
price_min
>
(
model
.
SellingPrice
??
0
))
{
price_min
=
model
.
SellingPrice
??
0
;
}
if
(
price_max
<
(
model
.
SellingPrice
??
0
))
{
price_max
=
model
.
SellingPrice
??
0
;
}
price_min
=
price_member_min
*
(
memeberList
.
Where
(
x
=>
x
.
Id
==
userModel
.
MemberGrade
).
FirstOrDefault
()?.
Discount
??
10
)
/
10
;
price_max
=
price_member_max
*
(
memeberList
.
Where
(
x
=>
x
.
Id
==
userModel
.
MemberGrade
).
FirstOrDefault
()?.
Discount
??
10
)
/
10
;
}
}
}
price_member_max
=
Math
.
Round
(
price_member_max
,
2
,
MidpointRounding
.
AwayFromZero
);
price_member_min
=
Math
.
Round
(
price_member_min
,
2
,
MidpointRounding
.
AwayFromZero
);
price_min
=
Math
.
Round
(
price_min
,
2
,
MidpointRounding
.
AwayFromZero
);
price_max
=
Math
.
Round
(
price_max
,
2
,
MidpointRounding
.
AwayFromZero
);
#
endregion
#
region
订单信息
int
payment_people
=
0
,
payment_num
=
0
,
payment_order
=
0
;
//订单用户 商品数量 订单数量
decimal
payment_amount
=
0
;
//订单总金额
GetGoodsOrderPeopleInfo
(
out
payment_amount
,
out
payment_num
,
out
payment_order
,
out
payment_people
,
goodsId
);
#
endregion
#
region
返回参数
return
new
{
goods
=
new
{
id
=
model
.
Id
,
mall_id
=
model
.
MallBaseId
,
mch_id
=
model
.
TenantId
,
//暂 商户id
//goods_warehouse_id = 0,//
status
=
model
.
GoodsStatus
,
price
=
model
.
SellingPrice
,
use_attr
=
model
.
IsCustomSpecification
,
attr_groups
=
model
.
SpecificationList
.
Select
(
x
=>
new
{
attr_group_id
=
x
.
Sort
,
attr_group_name
=
x
.
Name
,
attr_list
=
x
.
SpecificationValueList
.
Select
(
z
=>
new
{
attr_id
=
z
.
Sort
,
attr_name
=
z
.
Name
,
pic_url
=
z
.
ImagePath
})
}),
goods_stock
=
model
.
InventoryNum
,
virtual_sales
=
model
.
SalesNum
,
confine_count
=
model
.
LimitBuyGoodsNum
,
pieces
=
model
.
FullNumPinkage
,
//满件包邮
forehead
=
model
.
FullMoneyPinkage
,
//满额包邮
freight_id
=
model
.
FreightId
,
give_integral
=
model
.
IntegralPresent
,
give_integral_type
=
model
.
IntegralPresentType
,
forehead_integral
=
model
.
PointsDeduction
,
//暂 积分抵扣
forehead_integral_type
=
model
.
PointsDeductionType
,
//暂 积分抵扣类型
accumulative
=
model
.
IsMultipleDeduction
,
//多件抵扣
individual_share
=
userModel
?.
IsDistributor
??
2
,
// 是否分销商
attr_setting_type
=
model
.
SeparateDistributionType
,
//分销类型
is_level
=
model
.
EnjoyMember
,
//是否销售会员价格
is_level_alone
=
model
.
SeparateSetMember
,
//是否单独设置会员价
share_type
=
model
.
SeparateDistributionMoneyType
,
//分销佣金类型
//sign = "",
app_share_pic
=
model
.
CustomShareImagePath
,
app_share_title
=
model
.
CustomShareTitles
,
is_default_services
=
model
.
IsDefaultService
,
sort
=
model
.
Sort
,
created_at
=
model
.
CreateDate
.
HasValue
?
model
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
updated_at
=
model
.
UpdateDate
.
HasValue
?
model
.
UpdateDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
,
//deleted_at = "",
is_delete
=
model
.
Status
,
payment_people
,
//用户数量
payment_num
,
//商品数量
payment_amount
,
//销售总额
payment_order
,
//订单数量
confine_order_count
=
model
.
LimitBuyOrderNum
,
is_area_limit
=
model
.
IsAreaBuy
,
area_limit
=
new
List
<
object
>()
{
new
{
list
=
model
.
AreaList
.
Select
(
x
=>
new
{
area_id
=
x
.
AreaId
,
area_name
=
x
.
AreaName
,
area_type
=
x
.
AreaType
})
}
},
form_id
=
model
.
FormsId
,
sales
=
model
.
SalesNum
+
payment_num
,
//已售出数量 + 订单商品数量//
name
=
model
.
Name
,
original_price
=
model
.
OriginalPrice
,
cover_pic
=
model
.
CoverImage
,
unit
=
model
.
Unit
,
detail
=
model
.
GoodsDetails
,
video_url
=
model
.
VideoAddress
,
level_show
=
(
userModel
?.
MemberGrade
??
0
)
>
0
?
1
:
2
,
//是否显示会员价
is_sales
=
model
.
GoodsStatus
==
1
&&
model
.
InventoryNum
>
0
?
1
:
2
,
//是否可购买
attr
=
priceList
,
//goods_num = model.InventoryNum,
goods_no
=
model
.
GoodsNumbers
,
goods_weight
=
model
.
GoodsWeight
,
services
=
model
.
ServiceList
.
Select
(
x
=>
new
{
id
=
x
.
Id
,
name
=
x
.
Name
}),
price_min
,
price_max
,
pic_url
=
model
.
CarouselImageList
.
Select
(
x
=>
new
{
id
=
x
.
Id
,
pic_url
=
x
.
Path
}),
share
=
model
.
MaxShare
,
//分销佣金
favorite
=
model
.
Favorite
,
//是否收藏
//goods_marketing = new
//{
// limit = "",
// pickup = "",
// shipping = ""
//},
goods_marketing_award
=
new
{
integral
=
new
{
title
=
"购买可得"
+
Integral
+
"积分"
}
},
//plugin_extra = new List<object>(),
express
=
model
.
Express
,
//快递费用 读取默认收货地址 如果没有为0 如果有 根据商品运费匹配 找出快递费用
price_member_max
,
price_member_min
,
extra_quick_share
=
new
{
share_pic
=
model
.
CarouselImageList
.
Select
(
x
=>
new
{
id
=
x
.
Id
,
pic_url
=
x
.
Path
}),
share_text
=
model
.
Name
,
mall_name
=
model
.
MallName
,
format_time
=
model
.
UpdateDate
.
HasValue
?
model
.
UpdateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
)
:
""
},
is_quick_shop
=
model
.
IsQuickBuy
,
is_sell_well
=
model
.
IsSellWell
,
is_negotiable
=
model
.
IsGoodsNegotiable
,
cats
=
model
.
CategoryList
.
Select
(
x
=>
new
{
x
.
CategoryId
,
x
.
CategoryName
})
//分类
},
delivery
=
""
};
#
endregion
#
endregion
}
/// <summary>
...
...
Mall.Module.User/UserModule.cs
View file @
bc33739d
...
...
@@ -1137,6 +1137,13 @@ namespace Mall.Module.User
{
GradeList
=
distributor_GradeRepository
.
GetList
(
new
RB_Distributor_Grade_Extend
()
{
GradeIds
=
gradeIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
//查询和平分销等级
string
hpgradeIds
=
string
.
Join
(
","
,
list
.
Where
(
x
=>
x
.
HPGradeId
>
0
).
Select
(
x
=>
x
.
HPGradeId
??
0
).
Distinct
());
List
<
RB_Distributor_HPGradeInfo_Extend
>
HPGradeList
=
new
List
<
RB_Distributor_HPGradeInfo_Extend
>();
if
(!
string
.
IsNullOrEmpty
(
gradeIds
))
{
HPGradeList
=
distributor_HPGradeInfoRepository
.
GetList
(
new
RB_Distributor_HPGradeInfo_Extend
()
{
GradeIds
=
gradeIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
//查询推荐人列表
string
tjrIds
=
string
.
Join
(
","
,
list
.
Where
(
x
=>
x
.
SuperiorId
>
0
).
Select
(
x
=>
x
.
SuperiorId
??
0
).
Distinct
());
List
<
RB_Member_User_Extend
>
UserList
=
new
List
<
RB_Member_User_Extend
>();
...
...
@@ -1162,6 +1169,15 @@ namespace Mall.Module.User
{
item
.
GradeName
=
GradeList
.
Where
(
x
=>
x
.
Id
==
item
.
GradeId
).
FirstOrDefault
()?.
Name
??
""
;
}
if
(
item
.
HPGradeId
==
0
)
{
item
.
HPGradeName
=
"默认等级"
;
}
else
if
(
item
.
HPGradeId
>
0
)
{
item
.
HPGradeName
=
HPGradeList
.
Where
(
x
=>
x
.
Id
==
item
.
HPGradeId
).
FirstOrDefault
()?.
GradeName
??
""
;
}
if
(
item
.
SuperiorId
==
0
)
{
item
.
SuperiorName
=
"总店"
;
...
...
@@ -3042,6 +3058,22 @@ namespace Mall.Module.User
return
list
;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="commissionId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
RB_Distributor_HPCommission_Extend
GetHpdistributorInfo
(
int
commissionId
,
int
tenantId
,
int
mallBaseId
)
{
var
model
=
distributor_HPCommissionRepository
.
GetEntity
<
RB_Distributor_HPCommission_Extend
>(
commissionId
);
model
.
CategoryList
=
distributor_HPCategoryRepository
.
GetList
(
new
RB_Distributor_HPCategory_Extend
()
{
CommissionId
=
commissionId
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
//查询所有比例
model
.
RatioList
=
distributor_HPGradeRatioRepository
.
GetList
(
new
RB_Distributor_HPGradeRatio_Extend
()
{
CommissionId
=
commissionId
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
return
model
;
}
/// <summary>
/// 新增修改和平分销
/// </summary>
...
...
Mall.Repository/User/RB_Distributor_HPGradeInfoRepository.cs
View file @
bc33739d
...
...
@@ -64,6 +64,10 @@ namespace Mall.Repository.User
{
where
+=
$@" and
{
nameof
(
RB_Distributor_HPGradeInfo
.
Id
)}
=
{
dmodel
.
Id
}
"
;
}
if
(!
string
.
IsNullOrEmpty
(
dmodel
.
GradeIds
))
{
where
+=
$@" and
{
nameof
(
RB_Distributor_HPGradeInfo
.
Id
)}
in(
{
dmodel
.
GradeIds
}
)"
;
}
if
(
dmodel
.
Grade
>
0
)
{
where
+=
$@" and
{
nameof
(
RB_Distributor_HPGradeInfo
.
Grade
)}
=
{
dmodel
.
Grade
}
"
;
...
...
Mall.WebApi/Controllers/Product/AppletGoodsController.cs
View file @
bc33739d
...
...
@@ -361,11 +361,37 @@ namespace Mall.WebApi.Controllers.MallBase
return
ApiResult
.
ParamIsNull
();
}
int
UserId
=
prams
.
GetInt
(
"UserId"
,
0
);
var
Robj
=
productModule
.
GetAppletGoodsInfo_V2
(
GoodsId
,
UserId
,
req
.
TenantId
,
req
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
Robj
);
}
/// <summary>
/// 获取小程序商品详情备份
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetAppletGoodsInfoBack
(
object
requestMsg
)
{
var
req
=
JsonConvert
.
DeserializeObject
<
RequestParm
>(
requestMsg
.
ToString
());
if
(
req
.
MallBaseId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GoodsId
=
prams
.
GetInt
(
"GoodsId"
,
0
);
if
(
GoodsId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
int
UserId
=
prams
.
GetInt
(
"UserId"
,
0
);
RB_Member_User_Extend
userModel
=
new
RB_Member_User_Extend
();
List
<
RB_Member_Grade_Extend
>
memeberList
=
new
List
<
RB_Member_Grade_Extend
>();
if
(
UserId
>
0
)
{
if
(
UserId
>
0
)
{
userModel
=
productModule
.
GetMemberUserInfo
(
UserId
);
if
(
userModel
.
MemberGrade
>
0
)
{
if
(
userModel
.
MemberGrade
>
0
)
{
memeberList
=
productModule
.
GetMemberGradeList
(
new
RB_Member_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
req
.
TenantId
,
MallBaseId
=
req
.
MallBaseId
});
}
}
...
...
@@ -422,9 +448,11 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
}
else
{
else
{
//根据会员等级查找会员价格
foreach
(
var
qitem
in
memeberList
)
{
foreach
(
var
qitem
in
memeberList
)
{
var
mprice
=
Math
.
Round
((
item
.
SellingPrice
??
0
)
*
(
qitem
.
Discount
??
0
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
member_price_list
.
Add
(
new
{
...
...
@@ -460,7 +488,8 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
}
else
{
else
{
decimal
price_member
=
model
.
SellingPrice
??
0
;
//未设会员价格的话 就为销售价格
List
<
object
>
member_price_list
=
new
List
<
object
>();
if
(
model
.
EnjoyMember
==
1
&&
model
.
SeparateSetMember
==
1
)
...
...
@@ -481,7 +510,8 @@ namespace Mall.WebApi.Controllers.MallBase
var
gmodel
=
mlist
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
gmodel
.
MemberPrice
??
0
;
}
else
{
else
{
price_member
=
mlist
.
Max
(
x
=>
x
.
MemberPrice
??
0
);
}
}
...
...
@@ -503,13 +533,13 @@ namespace Mall.WebApi.Controllers.MallBase
var
gmodel
=
memeberList
.
Where
(
x
=>
x
.
Grade
==
userModel
.
MemberGrade
).
FirstOrDefault
();
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
gmodel
?.
Discount
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
else
if
(
memeberList
.
Any
())
else
if
(
memeberList
.
Any
())
{
price_member
=
Math
.
Round
((
model
.
SellingPrice
??
0
)
*
(
memeberList
.
Max
(
x
=>
x
.
Discount
)
??
10
)
/
10
,
2
,
MidpointRounding
.
AwayFromZero
);
}
}
priceList
.
Add
(
new
{
id
=
0
,
...
...
@@ -519,9 +549,9 @@ namespace Mall.WebApi.Controllers.MallBase
price
=
model
.
SellingPrice
??
0
,
no
=
model
.
GoodsNumbers
,
weight
=
model
.
GoodsWeight
,
pic_url
=
""
,
pic_url
=
""
,
is_delete
=
0
,
attr_list
=
new
List
<
object
>(){
new
attr_list
=
new
List
<
object
>(){
new
{
attr_group_name
=
"规格"
,
attr_group_id
=
0
,
...
...
@@ -535,9 +565,11 @@ namespace Mall.WebApi.Controllers.MallBase
#
endregion
#
region
赠送积分
int
Integral
=
0
;
if
(
model
.
IntegralPresent
>
0
)
{
if
(
model
.
IntegralPresent
>
0
)
{
Integral
=
model
.
IntegralPresent
??
0
;
if
(
model
.
IntegralPresentType
==
2
)
{
if
(
model
.
IntegralPresentType
==
2
)
{
Integral
=
Convert
.
ToInt32
(
Math
.
Floor
((
model
.
SellingPrice
??
0
)
*
(
model
.
IntegralPresent
??
0
)
/
100
));
}
}
...
...
@@ -554,14 +586,16 @@ namespace Mall.WebApi.Controllers.MallBase
price_max
=
model
.
MemberPriceList
.
Where
(
x
=>
x
.
MemberGrade
==
userModel
.
MemberGrade
).
Max
(
x
=>
x
.
MemberPrice
??
0
);
}
}
else
{
else
{
if
(
model
.
IsCustomSpecification
==
1
)
{
price_member_min
=
price_min
=
model
.
SpecificationPriceList
.
Min
(
x
=>
x
.
SellingPrice
??
0
);
price_member_max
=
price_max
=
model
.
SpecificationPriceList
.
Max
(
x
=>
x
.
SellingPrice
??
0
);
}
else
{
else
{
price_member_min
=
price_member_max
=
price_min
=
price_max
=
model
.
SellingPrice
??
0
;
}
if
(
memeberList
.
Any
())
...
...
@@ -581,7 +615,7 @@ namespace Mall.WebApi.Controllers.MallBase
price_min
=
price_member_min
*
(
memeberList
.
Where
(
x
=>
x
.
Id
==
userModel
.
MemberGrade
).
FirstOrDefault
()?.
Discount
??
10
)
/
10
;
price_max
=
price_member_max
*
(
memeberList
.
Where
(
x
=>
x
.
Id
==
userModel
.
MemberGrade
).
FirstOrDefault
()?.
Discount
??
10
)
/
10
;
}
}
}
}
price_member_max
=
Math
.
Round
(
price_member_max
,
2
,
MidpointRounding
.
AwayFromZero
);
price_member_min
=
Math
.
Round
(
price_member_min
,
2
,
MidpointRounding
.
AwayFromZero
);
...
...
@@ -590,7 +624,7 @@ namespace Mall.WebApi.Controllers.MallBase
#
endregion
#
region
订单信息
int
payment_people
=
0
,
payment_num
=
0
,
payment_order
=
0
;
//订单用户 商品数量 订单数量
int
payment_people
=
0
,
payment_num
=
0
,
payment_order
=
0
;
//订单用户 商品数量 订单数量
decimal
payment_amount
=
0
;
//订单总金额
productModule
.
GetGoodsOrderPeopleInfo
(
out
payment_amount
,
out
payment_num
,
out
payment_order
,
out
payment_people
,
GoodsId
);
#
endregion
...
...
@@ -628,7 +662,7 @@ namespace Mall.WebApi.Controllers.MallBase
forehead_integral
=
model
.
PointsDeduction
,
//暂 积分抵扣
forehead_integral_type
=
model
.
PointsDeductionType
,
//暂 积分抵扣类型
accumulative
=
model
.
IsMultipleDeduction
,
//多件抵扣
individual_share
=
userModel
?.
IsDistributor
??
2
,
// 是否分销商
individual_share
=
userModel
?.
IsDistributor
??
2
,
// 是否分销商
attr_setting_type
=
model
.
SeparateDistributionType
,
//分销类型
is_level
=
model
.
EnjoyMember
,
//是否销售会员价格
is_level_alone
=
model
.
SeparateSetMember
,
//是否单独设置会员价
...
...
@@ -661,7 +695,7 @@ namespace Mall.WebApi.Controllers.MallBase
unit
=
model
.
Unit
,
detail
=
model
.
GoodsDetails
,
video_url
=
model
.
VideoAddress
,
level_show
=
(
userModel
?.
MemberGrade
??
0
)>
0
?
1
:
2
,
//是否显示会员价
level_show
=
(
userModel
?.
MemberGrade
??
0
)
>
0
?
1
:
2
,
//是否显示会员价
is_sales
=
model
.
GoodsStatus
==
1
&&
model
.
InventoryNum
>
0
?
1
:
2
,
//是否可购买
attr
=
priceList
,
//goods_num = model.InventoryNum,
...
...
@@ -712,7 +746,7 @@ namespace Mall.WebApi.Controllers.MallBase
is_quick_shop
=
model
.
IsQuickBuy
,
is_sell_well
=
model
.
IsSellWell
,
is_negotiable
=
model
.
IsGoodsNegotiable
,
cats
=
model
.
CategoryList
.
Select
(
x
=>
new
{
cats
=
model
.
CategoryList
.
Select
(
x
=>
new
{
x
.
CategoryId
,
x
.
CategoryName
})
//分类
...
...
Mall.WebApi/Controllers/User/UserController.cs
View file @
bc33739d
...
...
@@ -1391,6 +1391,8 @@ namespace Mall.WebApi.Controllers.User
x
.
ThreeNum
,
x
.
GradeId
,
x
.
GradeName
,
x
.
HPGradeId
,
x
.
HPGradeName
,
x
.
AuditStatus
,
AuditStatusName
=
x
.
AuditStatus
.
GetEnumName
(),
x
.
Remark
,
...
...
@@ -2206,6 +2208,7 @@ namespace Mall.WebApi.Controllers.User
x
.
Id
,
x
.
Grade
,
x
.
GradeName
,
x
.
IsGuest
,
UpdateDate
=
x
.
UpdateDate
.
HasValue
?
x
.
UpdateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
)
:
""
});
return
ApiResult
.
Success
(
""
,
pagelist
);
...
...
@@ -2227,6 +2230,7 @@ namespace Mall.WebApi.Controllers.User
return
ApiResult
.
Success
(
""
,
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Grade
,
x
.
GradeName
}));
}
...
...
@@ -2249,6 +2253,7 @@ namespace Mall.WebApi.Controllers.User
demodel
.
TenantId
=
req
.
TenantId
;
demodel
.
MallBaseId
=
req
.
MallBaseId
;
demodel
.
Status
=
0
;
demodel
.
IsGuest
??=
2
;
demodel
.
CreateDate
=
DateTime
.
Now
;
demodel
.
UpdateDate
=
DateTime
.
Now
;
bool
flag
=
userModule
.
SetHpDistributorGradeInfo
(
demodel
);
...
...
@@ -2304,6 +2309,7 @@ namespace Mall.WebApi.Controllers.User
x
.
Name
,
x
.
DecimalType
,
x
.
Enabled
,
x
.
IsCommon
,
CategoryList
=
x
.
CategoryList
.
Select
(
y
=>
new
{
y
.
Id
,
y
.
CategoryId
,
...
...
@@ -2320,6 +2326,46 @@ namespace Mall.WebApi.Controllers.User
return
ApiResult
.
Success
(
""
,
pagelist
);
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetHpdistributorInfo
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
CommissionId
=
parms
.
GetInt
(
"CommissionId"
,
0
);
if
(
CommissionId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
var
model
=
userModule
.
GetHpdistributorInfo
(
CommissionId
,
req
.
TenantId
,
req
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
new
{
model
.
Id
,
model
.
Name
,
model
.
DecimalType
,
model
.
Enabled
,
model
.
IsCommon
,
CategoryList
=
model
.
CategoryList
.
Select
(
y
=>
new
{
y
.
Id
,
y
.
CategoryId
,
y
.
CategoryName
}),
RatioList
=
model
.
RatioList
.
Select
(
z
=>
new
{
z
.
Id
,
z
.
GradeId
,
z
.
GradeName
,
z
.
CommissionRatio
}),
UpdateDate
=
model
.
UpdateDate
.
HasValue
?
model
.
UpdateDate
.
Value
.
ToString
(
"yyyy-MM-dd"
)
:
""
});
}
/// <summary>
/// 新增修改和平分销返佣
/// </summary>
...
...
@@ -2348,6 +2394,10 @@ namespace Mall.WebApi.Controllers.User
return
ApiResult
.
ParamIsNull
(
"返佣比例有误,不能大于100"
);
}
}
demodel
.
IsCommon
=
2
;
if
(
demodel
.
CategoryList
==
null
&&
!
demodel
.
CategoryList
.
Any
())
{
demodel
.
IsCommon
=
1
;
//通用
}
demodel
.
TenantId
=
req
.
TenantId
;
demodel
.
MallBaseId
=
req
.
MallBaseId
;
...
...
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