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
5fafa576
Commit
5fafa576
authored
Aug 17, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增修改
parent
dd751dcf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
444 additions
and
145 deletions
+444
-145
GroupBuyActivityModule.cs
Mall.Module.Product/GroupBuyActivityModule.cs
+444
-145
No files found.
Mall.Module.Product/GroupBuyActivityModule.cs
View file @
5fafa576
...
...
@@ -375,6 +375,13 @@ namespace Mall.Module.Product
public
virtual
bool
SetGroupbuyActivityModule
(
RB_Groupbuy_Activity_Extend
extModel
)
{
bool
flag
=
false
;
var
oldModel
=
GetGroupbuyActivityEntityModule
(
new
RB_Groupbuy_Activity_Extend
()
{
ActivityId
=
extModel
.
ActivityId
},
isGetSpec
:
false
);
int
oldSeparateDistributionType
=
0
;
if
(
oldModel
!=
null
)
{
oldSeparateDistributionType
=
oldModel
?.
SeparateDistributionType
??
0
;
}
if
(
extModel
.
ActivityId
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
...
...
@@ -429,9 +436,8 @@ namespace Mall.Module.Product
}
if
(
flag
)
{
flag
=
SetGoodsSpecificationModule
(
extModel
);
flag
=
SetGoodGroupStepModule
(
extModel
);
flag
=
SetGoodsSpecificationModule
(
extModel
,
out
bool
isChange
);
flag
=
SetGoodGroupStepModule
(
extModel
,
isChange
,
oldSeparateDistributionType
);
}
return
flag
;
}
...
...
@@ -440,67 +446,225 @@ namespace Mall.Module.Product
/// 添加修改商品规格
/// </summary>
/// <param name="extModel"></param>
/// <param name="isChange">是否规格有改变</param>
/// <returns></returns>
private
bool
SetGoodsSpecificationModule
(
RB_Groupbuy_Activity_Extend
extModel
)
private
bool
SetGoodsSpecificationModule
(
RB_Groupbuy_Activity_Extend
extModel
,
out
bool
isChange
)
{
isChange
=
false
;
bool
flag
=
true
;
var
old_SpecificationList
=
groupbuy_Activity_SpecificationRepository
.
GetGroupbuyActivitySpecificationListRepository
(
new
RB_Groupbuy_Activity_Specification_Extend
()
{
GoodsId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
if
(
extModel
.
IsCustomSpecification
==
1
)
{
//判断规格条数是否变动
if
(
old_SpecificationList
.
Count
()
!=
extModel
.
SpecificationList
.
Count
()
||
old_SpecificationList
.
Count
()
!=
extModel
.
SpecificationList
.
Where
(
x
=>
x
.
Id
>
0
).
Count
())
{
isChange
=
true
;
//删除规格
groupbuy_Activity_SpecificationRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Specification_Extend
.
GoodsId
),
extModel
.
GoodId
));
//删除规格值
groupbuy_Activity_SpecificationValueRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Specificationvalue_Extend
.
GoodsId
),
extModel
.
GoodId
));
//删除规格价格
groupbuy_Activity_SpecificationPriceRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Specificationprice_Extend
.
GoodsId
),
extModel
.
GoodId
));
//新增规格和规格值
foreach
(
var
specItem
in
extModel
.
SpecificationList
)
{
specItem
.
TenantId
=
extModel
.
TenantId
;
specItem
.
MallBaseId
=
extModel
.
MallBaseId
;
specItem
.
GoodsId
=
extModel
.
GoodId
;
specItem
.
Status
=
0
;
specItem
.
CreateDate
=
DateTime
.
Now
;
if
(
specItem
.
Id
>
0
)
//新增规格
var
specModel
=
new
RB_Groupbuy_Activity_Specification_Extend
()
{
CreateDate
=
DateTime
.
Now
,
EnabledImage
=
specItem
.
EnabledImage
,
GoodsId
=
extModel
.
GoodId
,
Id
=
0
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
,
Status
=
0
,
Name
=
specItem
.
Name
,
Sort
=
specItem
.
Sort
,
};
var
newSpecId
=
groupbuy_Activity_SpecificationRepository
.
Insert
(
specModel
);
specModel
.
Id
=
newSpecId
;
flag
=
newSpecId
>
0
;
//新增规格值
if
(
specItem
.
SpecificationValueList
!=
null
&&
specItem
.
SpecificationValueList
.
Count
>
0
)
{
foreach
(
var
specValueItem
in
specItem
.
SpecificationValueList
)
{
var
specValueModel
=
new
RB_Groupbuy_Activity_Specificationvalue_Extend
()
{
flag
=
groupbuy_Activity_SpecificationRepository
.
Update
(
specItem
);
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
,
SpecificationId
=
specModel
.
Id
,
GoodsId
=
extModel
.
GoodId
,
CreateDate
=
DateTime
.
Now
,
Status
=
0
,
Id
=
0
,
Image
=
specValueItem
.
Image
,
Name
=
specValueItem
.
Name
,
Sort
=
specValueItem
.
Sort
,
};
var
specValueId
=
groupbuy_Activity_SpecificationValueRepository
.
Insert
(
specValueModel
);
specValueModel
.
Id
=
specValueId
;
flag
=
specValueId
>
0
;
}
}
}
//新增规格价格
foreach
(
var
priceItem
in
extModel
.
SpecificationPriceList
)
{
var
priceModel
=
new
RB_Groupbuy_Activity_Specificationprice_Extend
()
{
Id
=
0
,
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
,
GoodsId
=
extModel
.
GoodId
,
Status
=
0
,
CreateDate
=
DateTime
.
Now
,
UpdateDate
=
DateTime
.
Now
,
GoodsNumbers
=
priceItem
.
GoodsNumbers
,
GoodsWeight
=
priceItem
.
GoodsWeight
,
InventoryNum
=
priceItem
.
InventoryNum
,
SellingPrice
=
priceItem
.
SellingPrice
,
SpecificationSort
=
priceItem
.
SpecificationSort
,
Commission
=
priceItem
.
Commission
,
CostMoney
=
priceItem
.
CostMoney
};
flag
=
groupbuy_Activity_SpecificationPriceRepository
.
Insert
(
priceModel
)
>
0
;
}
}
else
{
var
newSpecId
=
groupbuy_Activity_SpecificationRepository
.
Insert
(
specItem
);
specItem
.
Id
=
newSpecId
;
flag
=
newSpecId
>
0
;
var
specValuelist
=
groupbuy_Activity_SpecificationValueRepository
.
GetGroupbuyActivitySpecificationValueListRepository
(
new
RB_Groupbuy_Activity_Specificationvalue_Extend
()
{
GoodsId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
var
specPricelist
=
groupbuy_Activity_SpecificationPriceRepository
.
GetGroupbuyActivitySpecificationpriceListRepository
(
new
RB_Groupbuy_Activity_Specificationprice_Extend
()
{
GoodsId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
foreach
(
var
item
in
old_SpecificationList
)
{
var
supmodel
=
extModel
.
SpecificationList
.
Where
(
x
=>
x
.
Id
==
item
.
Id
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_Specification
.
EnabledImage
),
supmodel
.
EnabledImage
},
{
nameof
(
RB_Goods_Specification
.
Name
),
supmodel
.
Name
},
{
nameof
(
RB_Goods_Specification
.
Sort
),
supmodel
.
Sort
}
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
()
{
FiledName
=
nameof
(
RB_Goods_Specification
.
Id
),
FiledValue
=
item
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
if
(
specItem
.
SpecificationValueList
!=
null
&&
specItem
.
SpecificationValueList
.
Count
>
0
)
};
flag
=
groupbuy_Activity_SpecificationRepository
.
Update
(
keyValues1
,
wheres1
);
if
(
flag
)
{
foreach
(
var
specValueItem
in
specItem
.
SpecificationValueList
)
var
sv2list
=
specValuelist
.
Where
(
x
=>
x
.
SpecificationId
==
item
.
Id
).
ToList
();
if
(
sv2list
.
Count
()
!=
supmodel
.
SpecificationValueList
.
Count
()
||
sv2list
.
Count
()
!=
supmodel
.
SpecificationValueList
.
Where
(
x
=>
x
.
Id
>
0
).
Count
())
{
isChange
=
true
;
groupbuy_Activity_SpecificationValueRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Specificationvalue_Extend
.
GoodsId
),
extModel
.
GoodId
));
foreach
(
var
specValueItem
in
supmodel
.
SpecificationValueList
)
{
specValueItem
.
MallBaseId
=
extModel
.
MallBaseId
;
specValueItem
.
TenantId
=
extModel
.
TenantId
;
specValueItem
.
SpecificationId
=
specItem
.
Id
;
specValueItem
.
GoodsId
=
extModel
.
GoodId
;
specValueItem
.
CreateDate
=
DateTime
.
Now
;
specValueItem
.
Status
=
0
;
if
(
specValueItem
.
Id
>
0
)
flag
=
groupbuy_Activity_SpecificationValueRepository
.
Insert
(
new
RB_Groupbuy_Activity_Specificationvalue_Extend
()
{
flag
=
groupbuy_Activity_SpecificationValueRepository
.
Update
(
specValueItem
);
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
,
SpecificationId
=
supmodel
.
Id
,
GoodsId
=
extModel
.
GoodId
,
CreateDate
=
DateTime
.
Now
,
Status
=
0
,
Id
=
0
,
Image
=
specValueItem
.
Image
,
Name
=
specValueItem
.
Name
,
Sort
=
specValueItem
.
Sort
,
})
>
0
;
}
}
else
{
var
specValueId
=
groupbuy_Activity_SpecificationValueRepository
.
Insert
(
specValueItem
);
specValueItem
.
Id
=
specValueId
;
flag
=
specValueId
>
0
;
foreach
(
var
qitem
in
sv2list
)
{
var
supModel1
=
supmodel
.
SpecificationValueList
.
Where
(
x
=>
x
.
Id
==
qitem
.
Id
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
keyValues2
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_SpecificationValue
.
Image
),
supModel1
.
Image
},
{
nameof
(
RB_Goods_SpecificationValue
.
Name
),
supModel1
.
Name
},
{
nameof
(
RB_Goods_SpecificationValue
.
Sort
),
supModel1
.
Sort
}
};
List
<
WhereHelper
>
wheres2
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
()
{
FiledName
=
nameof
(
RB_Goods_Specification
.
Id
),
FiledValue
=
qitem
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
groupbuy_Activity_SpecificationValueRepository
.
Update
(
keyValues2
,
wheres2
);
}
}
}
}
//规格价格处理
if
(
specPricelist
.
Count
()
!=
extModel
.
SpecificationPriceList
.
Count
()
||
specPricelist
.
Count
()
!=
extModel
.
SpecificationPriceList
.
Where
(
x
=>
specPricelist
.
Select
(
y
=>
y
.
SpecificationSort
).
Contains
(
x
.
SpecificationSort
)).
Count
())
{
isChange
=
true
;
//删除规格价格
groupbuy_Activity_SpecificationPriceRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Specificationprice_Extend
.
GoodsId
),
extModel
.
GoodId
));
foreach
(
var
priceItem
in
extModel
.
SpecificationPriceList
)
{
priceItem
.
MallBaseId
=
extModel
.
MallBaseId
;
priceItem
.
TenantId
=
extModel
.
TenantId
;
priceItem
.
GoodsId
=
extModel
.
GoodId
;
priceItem
.
Status
=
0
;
priceItem
.
CreateDate
=
DateTime
.
Now
;
priceItem
.
UpdateDate
=
DateTime
.
Now
;
if
(
priceItem
.
Id
>
0
)
var
priceModel
=
new
RB_Groupbuy_Activity_Specificationprice_Extend
()
{
flag
=
groupbuy_Activity_SpecificationPriceRepository
.
Update
(
priceItem
);
Id
=
0
,
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
,
GoodsId
=
extModel
.
GoodId
,
Status
=
0
,
CreateDate
=
DateTime
.
Now
,
UpdateDate
=
DateTime
.
Now
,
GoodsNumbers
=
priceItem
.
GoodsNumbers
,
GoodsWeight
=
priceItem
.
GoodsWeight
,
InventoryNum
=
priceItem
.
InventoryNum
,
SellingPrice
=
priceItem
.
SellingPrice
,
SpecificationSort
=
priceItem
.
SpecificationSort
,
Commission
=
priceItem
.
Commission
,
CostMoney
=
priceItem
.
CostMoney
};
flag
=
groupbuy_Activity_SpecificationPriceRepository
.
Insert
(
priceModel
)
>
0
;
}
}
else
{
flag
=
groupbuy_Activity_SpecificationPriceRepository
.
Insert
(
priceItem
)
>
0
;
foreach
(
var
item
in
specPricelist
)
{
var
pupmodel
=
extModel
.
SpecificationPriceList
.
Where
(
x
=>
x
.
SpecificationSort
==
item
.
SpecificationSort
).
FirstOrDefault
();
if
(
item
.
Commission
!=
pupmodel
.
Commission
||
item
.
CostMoney
!=
pupmodel
.
CostMoney
||
item
.
SellingPrice
!=
pupmodel
.
SellingPrice
||
item
.
InventoryNum
!=
pupmodel
.
InventoryNum
||
item
.
GoodsNumbers
!=
pupmodel
.
GoodsNumbers
||
item
.
GoodsWeight
!=
pupmodel
.
GoodsWeight
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_SpecificationPrice
.
SellingPrice
),
pupmodel
.
SellingPrice
},
{
nameof
(
RB_Goods_SpecificationPrice
.
InventoryNum
),
pupmodel
.
InventoryNum
},
{
nameof
(
RB_Goods_SpecificationPrice
.
GoodsWeight
),
pupmodel
.
GoodsWeight
},
{
nameof
(
RB_Goods_SpecificationPrice
.
GoodsNumbers
),
pupmodel
.
GoodsNumbers
},
{
nameof
(
RB_Goods_SpecificationPrice
.
Commission
),
pupmodel
.
Commission
},
{
nameof
(
RB_Goods_SpecificationPrice
.
CostMoney
),
pupmodel
.
CostMoney
},
};
List
<
WhereHelper
>
wheres1
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
()
{
FiledName
=
nameof
(
RB_Goods_SpecificationPrice
.
Id
),
FiledValue
=
item
.
Id
,
OperatorEnum
=
OperatorEnum
.
Equal
}
};
flag
=
groupbuy_Activity_SpecificationPriceRepository
.
Update
(
keyValues1
,
wheres1
);
}
}
}
}
}
...
...
@@ -511,49 +675,173 @@ namespace Mall.Module.Product
/// 新增修改阶梯团价
/// </summary>
/// <param name="extModel"></param>
/// <param name="isChange"></param>
/// <param name="oldSeparateDistributionType"></param>
/// <returns></returns>
private
bool
SetGoodGroupStepModule
(
RB_Groupbuy_Activity_Extend
extModel
)
private
bool
SetGoodGroupStepModule
(
RB_Groupbuy_Activity_Extend
extModel
,
bool
isChange
,
int
oldSeparateDistributionType
)
{
bool
flag
=
true
;
if
(
extModel
.
GroupList
!=
null
&&
extModel
.
GroupList
.
Count
>
0
)
var
stepList
=
stepRepository
.
GetGroupBuyActivityListRepository
(
new
RB_Groupbuy_Activity_Step_Extend
()
{
GoodId
=
extModel
.
GoodId
,
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
});
if
(
isChange
||
(
stepList
.
Count
()
!=
extModel
.
GroupList
.
Count
()
||
stepList
.
Count
()
!=
extModel
.
GroupList
.
Where
(
qitem
=>
qitem
.
StepId
>
0
).
Count
()))
{
stepRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
GoodId
),
extModel
.
GoodId
));
groupbuy_Activity_Step_PriceRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Step_Price_Extend
.
GoodId
),
extModel
.
GoodId
));
groupBuy_DistributioncommissionRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
GoodsId
),
extModel
.
GoodId
));
groupbuy_MemberpriceRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Memberprice_Extend
.
GoodsId
),
extModel
.
GoodId
));
foreach
(
var
groupItem
in
extModel
.
GroupList
)
{
groupItem
.
TenantId
=
extModel
.
TenantId
;
groupItem
.
MallBaseId
=
extModel
.
MallBaseId
;
groupItem
.
GoodId
=
extModel
.
GoodId
;
if
(
groupItem
.
StepId
>
0
)
{
flag
=
stepRepository
.
Update
(
groupItem
);
}
else
var
groupModel
=
new
RB_Groupbuy_Activity_Step_Extend
()
{
var
newStepId
=
stepRepository
.
Insert
(
groupItem
);
groupItem
.
StepId
=
newStepId
;
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
,
GoodId
=
extModel
.
GoodId
,
People_Num
=
groupItem
.
People_Num
,
Preferential_Price
=
groupItem
.
Preferential_Price
,
Pintuan_Time
=
groupItem
.
Pintuan_Time
,
Group_Num
=
groupItem
.
Group_Num
,
};
var
newStepId
=
stepRepository
.
Insert
(
groupModel
);
groupModel
.
StepId
=
newStepId
;
flag
=
newStepId
>
0
;
}
if
(
group
Item
.
StepId
>
0
)
if
(
group
Model
.
StepId
>
0
)
{
if
(
groupItem
.
StepPriceList
!=
null
&&
groupItem
.
StepPriceList
.
Count
>
0
)
{
//添加会员价格
foreach
(
var
subItem
in
groupItem
.
StepPriceList
)
{
subItem
.
MallBaseId
=
extModel
.
MallBaseId
;
subItem
.
TenantId
=
extModel
.
TenantId
;
subItem
.
GoodId
=
extModel
.
GoodId
;
subItem
.
StepId
=
groupItem
.
StepId
;
if
(
subItem
.
Id
>
0
)
var
stepPriceModel
=
new
RB_Groupbuy_Activity_Step_Price_Extend
()
{
MallBaseId
=
extModel
.
MallBaseId
,
TenantId
=
extModel
.
TenantId
,
GoodId
=
extModel
.
GoodId
,
StepId
=
groupModel
.
StepId
,
PinTuanPrice
=
subItem
.
PinTuanPrice
,
PinTuanStock
=
subItem
.
PinTuanStock
,
SpecificationSort
=
subItem
.
SpecificationSort
,
SortNum
=
subItem
.
SortNum
,
};
flag
=
groupbuy_Activity_Step_PriceRepository
.
Insert
(
stepPriceModel
)
>
0
;
}
}
//设置分销佣金
SetDistributioncommissionModule
(
extModel
,
groupItem
,
groupModel
.
StepId
,
isCreate
:
true
);
//会员价设置
if
(
groupItem
.
MemberpriceList
!=
null
&&
groupItem
.
MemberpriceList
.
Count
>
0
)
{
foreach
(
var
subItem
in
groupItem
.
MemberpriceList
)
{
if
(
subItem
.
GradeMemberPriceList
!=
null
&&
subItem
.
GradeMemberPriceList
.
Count
>
0
)
{
foreach
(
var
childItem
in
subItem
.
GradeMemberPriceList
)
{
var
memberModel
=
new
RB_Groupbuy_Memberprice_Extend
()
{
flag
=
groupbuy_Activity_Step_PriceRepository
.
Update
(
subItem
);
SpecificationSort
=
subItem
.
SpecificationSort
,
GoodsId
=
extModel
.
GoodId
,
Status
=
0
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
,
StepId
=
groupModel
.
StepId
,
CreateDate
=
DateTime
.
Now
,
UpdateDate
=
DateTime
.
Now
,
MemberGrade
=
childItem
.
MemberGrade
,
MemberPrice
=
childItem
.
MemberPrice
,
};
var
newMemberId
=
groupbuy_MemberpriceRepository
.
Insert
(
memberModel
);
memberModel
.
Id
=
newMemberId
;
flag
=
newMemberId
>
0
;
}
}
}
}
}
}
}
else
{
flag
=
groupbuy_Activity_Step_PriceRepository
.
Insert
(
subItem
)
>
0
;
var
stepPriceList
=
groupbuy_Activity_Step_PriceRepository
.
GetGroupbuyActivitySpecificationpriceListRepository
(
new
RB_Groupbuy_Activity_Step_Price_Extend
()
{
GoodId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
var
memberPriceList
=
groupbuy_MemberpriceRepository
.
GetGroupBuyMemberpriceRepository
(
new
RB_Groupbuy_Memberprice_Extend
()
{
GoodsId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
foreach
(
var
item
in
stepList
)
{
var
stepModel
=
extModel
.
GroupList
.
Where
(
qitem
=>
qitem
.
StepId
==
item
.
StepId
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
stepFileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
People_Num
),
stepModel
.
People_Num
},
{
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
Preferential_Price
),
stepModel
.
Preferential_Price
},
{
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
Pintuan_Time
),
stepModel
.
Pintuan_Time
},
{
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
Group_Num
),
stepModel
.
Group_Num
},
};
flag
=
stepRepository
.
Update
(
stepFileds
,
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Step_Extend
.
StepId
),
item
.
StepId
));
//更新价格和库存
foreach
(
var
subItem
in
stepModel
.
StepPriceList
)
{
var
subPriceModel
=
stepPriceList
.
Where
(
qitem
=>
qitem
.
StepId
==
item
.
StepId
&&
qitem
.
SpecificationSort
==
subItem
.
SpecificationSort
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
stepPriceFileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Groupbuy_Activity_Step_Price_Extend
.
PinTuanPrice
),
subItem
.
PinTuanPrice
},
{
nameof
(
RB_Groupbuy_Activity_Step_Price_Extend
.
PinTuanStock
),
subItem
.
PinTuanStock
},
{
nameof
(
RB_Groupbuy_Activity_Step_Price_Extend
.
SortNum
),
subItem
.
SortNum
},
};
flag
=
groupbuy_Activity_Step_PriceRepository
.
Update
(
stepPriceFileds
,
new
WhereHelper
(
nameof
(
RB_Groupbuy_Activity_Step_Price_Extend
),
subItem
.
Id
));
}
//更新会员价
foreach
(
var
subItem
in
stepModel
.
MemberpriceList
)
{
foreach
(
var
childItem
in
subItem
.
GradeMemberPriceList
)
{
var
memberPriceModel
=
memberPriceList
.
Where
(
qitem
=>
qitem
.
StepId
==
item
.
StepId
&&
qitem
.
SpecificationSort
==
subItem
.
SpecificationSort
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
memberPriceFileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Groupbuy_Memberprice_Extend
.
MemberGrade
),
childItem
.
MemberGrade
},
{
nameof
(
RB_Groupbuy_Memberprice_Extend
.
MemberPrice
),
childItem
.
MemberPrice
},
};
flag
=
groupbuy_MemberpriceRepository
.
Update
(
memberPriceFileds
,
new
WhereHelper
(
nameof
(
RB_Groupbuy_Memberprice_Extend
),
childItem
.
Id
));
}
}
if
(
oldSeparateDistributionType
!=
extModel
.
SeparateDistributionType
)
{
groupbuy_MemberpriceRepository
.
Delete
(
new
WhereHelper
(
nameof
(
RB_Groupbuy_Memberprice_Extend
.
GoodsId
),
extModel
.
GoodId
));
//设置分销佣金
SetDistributioncommissionModule
(
extModel
,
stepModel
,
item
.
StepId
,
isCreate
:
true
);
}
else
{
//设置分销佣金
SetDistributioncommissionModule
(
extModel
,
stepModel
,
item
.
StepId
,
isCreate
:
false
);
}
}
}
return
flag
;
}
/// <summary>
/// 添加修改分销佣金
/// </summary>
/// <param name="extModel"></param>
/// <param name="groupItem"></param>
/// <param name="StepId"></param>
/// <returns></returns>
private
bool
SetDistributioncommissionModule
(
RB_Groupbuy_Activity_Extend
extModel
,
RB_Groupbuy_Activity_Step_Extend
groupItem
,
int
StepId
,
bool
isCreate
=
true
)
{
bool
flag
=
false
;
//新增分销佣金
if
(
isCreate
)
{
//普通设置
if
(
extModel
.
SeparateDistributionType
==
1
)
{
...
...
@@ -562,26 +850,26 @@ namespace Mall.Module.Product
{
foreach
(
var
subItem
in
groupItem
.
DistributioncommissionList
)
{
subItem
.
GoodsId
=
extModel
.
GoodId
;
subItem
.
Status
=
0
;
subItem
.
TenantId
=
extModel
.
TenantId
;
subItem
.
MallBaseId
=
extModel
.
MallBaseId
;
subItem
.
StepId
=
groupItem
.
StepId
;
if
(
subItem
.
Id
>
0
)
{
subItem
.
UpdateDate
=
DateTime
.
Now
;
flag
=
groupBuy_DistributioncommissionRepository
.
Update
(
subItem
);
}
else
var
commissionModel
=
new
RB_GroupBuy_Distributioncommission_Extend
()
{
subItem
.
CreateDate
=
DateTime
.
Now
;
subItem
.
UpdateDate
=
DateTime
.
Now
;
var
newDistriId
=
groupBuy_DistributioncommissionRepository
.
Insert
(
subItem
);
subItem
.
Id
=
newDistriId
;
GoodsId
=
extModel
.
GoodId
,
Status
=
0
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
,
StepId
=
StepId
,
UpdateDate
=
DateTime
.
Now
,
CreateDate
=
DateTime
.
Now
,
SpecificationSort
=
subItem
.
SpecificationSort
,
DistributorGrade
=
subItem
.
DistributorGrade
,
OneCommission
=
subItem
.
OneCommission
,
TwoCommission
=
subItem
.
TwoCommission
,
ThreeCommission
=
subItem
.
ThreeCommission
,
};
var
newDistriId
=
groupBuy_DistributioncommissionRepository
.
Insert
(
commissionModel
);
commissionModel
.
Id
=
newDistriId
;
flag
=
newDistriId
>
0
;
}
}
}
}
//详细设置
else
if
(
extModel
.
SeparateDistributionType
==
2
)
{
...
...
@@ -593,63 +881,74 @@ namespace Mall.Module.Product
{
foreach
(
var
childItem
in
subItem
.
GradeCommissionList
)
{
childItem
.
SpecificationSort
=
subItem
.
SpecificationSort
;
childItem
.
GoodsId
=
extModel
.
GoodId
;
childItem
.
Status
=
0
;
childItem
.
TenantId
=
extModel
.
TenantId
;
childItem
.
MallBaseId
=
extModel
.
MallBaseId
;
childItem
.
StepId
=
groupItem
.
StepId
;
if
(
childItem
.
Id
>
0
)
{
childItem
.
UpdateDate
=
DateTime
.
Now
;
flag
=
groupBuy_DistributioncommissionRepository
.
Update
(
childItem
);
}
else
var
commissionModel
=
new
RB_GroupBuy_Distributioncommission_Extend
()
{
childItem
.
CreateDate
=
DateTime
.
Now
;
childItem
.
UpdateDate
=
DateTime
.
Now
;
var
newDistriId
=
groupBuy_DistributioncommissionRepository
.
Insert
(
childItem
);
childItem
.
Id
=
newDistriId
;
GoodsId
=
extModel
.
GoodId
,
Status
=
0
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
,
StepId
=
StepId
,
UpdateDate
=
DateTime
.
Now
,
CreateDate
=
DateTime
.
Now
,
SpecificationSort
=
subItem
.
SpecificationSort
,
DistributorGrade
=
childItem
.
DistributorGrade
,
OneCommission
=
childItem
.
OneCommission
,
TwoCommission
=
childItem
.
TwoCommission
,
ThreeCommission
=
childItem
.
ThreeCommission
,
};
var
newDistriId
=
groupBuy_DistributioncommissionRepository
.
Insert
(
commissionModel
);
commissionModel
.
Id
=
newDistriId
;
flag
=
newDistriId
>
0
;
}
}
}
}
}
}
//会员价设置
if
(
groupItem
.
MemberpriceList
!=
null
&&
groupItem
.
MemberpriceList
.
Count
>
0
)
//修改分销佣金
else
{
foreach
(
var
subItem
in
groupItem
.
MemberpriceList
)
var
distributionList
=
groupBuy_DistributioncommissionRepository
.
GetGroupBuyCommissionRepository
(
new
RB_GroupBuy_Distributioncommission_Extend
(
)
{
if
(
subItem
.
GradeMemberPriceList
!=
null
&&
subItem
.
GradeMemberPriceList
.
Count
>
0
)
GoodsId
=
extModel
.
GoodId
,
TenantId
=
extModel
.
TenantId
,
MallBaseId
=
extModel
.
MallBaseId
});
//普通设置
if
(
extModel
.
SeparateDistributionType
==
1
)
{
foreach
(
var
childItem
in
subItem
.
GradeMemberPrice
List
)
foreach
(
var
item
in
distribution
List
)
{
childItem
.
SpecificationSort
=
subItem
.
SpecificationSort
;
childItem
.
GoodsId
=
extModel
.
GoodId
;
childItem
.
Status
=
0
;
childItem
.
TenantId
=
extModel
.
TenantId
;
childItem
.
MallBaseId
=
extModel
.
MallBaseId
;
childItem
.
StepId
=
groupItem
.
StepId
;
if
(
childItem
.
Id
>
0
)
var
defaultModel
=
groupItem
.
DistributioncommissionList
.
Where
(
qitem
=>
qitem
.
StepId
==
item
.
StepId
&&
qitem
.
SpecificationSort
==
item
.
SpecificationSort
&&
qitem
.
DistributorGrade
==
item
.
DistributorGrade
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
comFileds
=
new
Dictionary
<
string
,
object
>()
{
childItem
.
UpdateDate
=
DateTime
.
Now
;
flag
=
groupbuy_MemberpriceRepository
.
Update
(
childItem
);
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
OneCommission
),
defaultModel
.
OneCommission
},
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
TwoCommission
),
defaultModel
.
TwoCommission
},
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
ThreeCommission
),
defaultModel
.
ThreeCommission
},
};
flag
=
groupBuy_DistributioncommissionRepository
.
Update
(
comFileds
,
new
WhereHelper
(
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
Id
),
defaultModel
.
Id
));
}
else
}
//详细设置
else
if
(
extModel
.
SeparateDistributionType
==
2
)
{
childItem
.
CreateDate
=
DateTime
.
Now
;
childItem
.
UpdateDate
=
DateTime
.
Now
;
var
newMemberId
=
groupbuy_MemberpriceRepository
.
Insert
(
childItem
);
childItem
.
Id
=
newMemberId
;
flag
=
newMemberId
>
0
;
}
}
if
(
groupItem
.
DistributionCommissionTreeList
!=
null
&&
groupItem
.
DistributionCommissionTreeList
.
Count
>
0
)
{
foreach
(
var
subItem
in
groupItem
.
DistributionCommissionTreeList
)
{
if
(
subItem
.
GradeCommissionList
!=
null
&&
subItem
.
GradeCommissionList
.
Count
>
0
)
{
foreach
(
var
childItem
in
subItem
.
GradeCommissionList
)
{
var
oldModel
=
distributionList
.
Where
(
qitem
=>
qitem
.
StepId
==
childItem
.
StepId
&&
qitem
.
SpecificationSort
==
subItem
.
SpecificationSort
&&
qitem
.
DistributorGrade
==
childItem
.
DistributorGrade
).
FirstOrDefault
();
var
defaultModel
=
groupItem
.
DistributioncommissionList
.
Where
(
qitem
=>
qitem
.
StepId
==
childItem
.
StepId
&&
qitem
.
SpecificationSort
==
subItem
.
SpecificationSort
&&
qitem
.
DistributorGrade
==
childItem
.
DistributorGrade
).
FirstOrDefault
();
Dictionary
<
string
,
object
>
comFileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
OneCommission
),
defaultModel
.
OneCommission
},
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
TwoCommission
),
defaultModel
.
TwoCommission
},
{
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
ThreeCommission
),
defaultModel
.
ThreeCommission
},
};
flag
=
groupBuy_DistributioncommissionRepository
.
Update
(
comFileds
,
new
WhereHelper
(
nameof
(
RB_GroupBuy_Distributioncommission_Extend
.
Id
),
oldModel
.
Id
));
}
}
}
}
...
...
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