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
4c56af02
Commit
4c56af02
authored
Oct 29, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增控制器
parent
133096d7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1953 additions
and
4 deletions
+1953
-4
ConvertHelper.cs
Mall.Common/Plugin/ConvertHelper.cs
+26
-0
RB_Goods.cs
Mall.Model/Entity/Product/RB_Goods.cs
+15
-0
RB_Stores.cs
Mall.Model/Entity/User/RB_Stores.cs
+10
-0
RB_Goods_Extend.cs
Mall.Model/Extend/Product/RB_Goods_Extend.cs
+10
-0
RB_Stores_Extend.cs
Mall.Model/Extend/User/RB_Stores_Extend.cs
+20
-0
Mall.Module.Reserve.csproj
Mall.Module.Reserve/Mall.Module.Reserve.csproj
+1
-0
OfflineGoodsModule.cs
Mall.Module.Reserve/OfflineGoodsModule.cs
+1126
-0
ContentModule.cs
Mall.Module.User/ContentModule.cs
+13
-0
RB_StoresRepository.cs
Mall.Repository/User/RB_StoresRepository.cs
+110
-4
OSGoodsController.cs
Mall.WebApi/Controllers/Reserve/OSGoodsController.cs
+622
-0
No files found.
Mall.Common/Plugin/ConvertHelper.cs
View file @
4c56af02
...
...
@@ -129,6 +129,32 @@ namespace Mall.Common
return
ConvertTo
<
int
>(
obj
);
}
/// <summary>
/// 字符串状态List<int>
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public
static
List
<
int
>
ConvertToListInt
(
object
obj
)
{
List
<
int
>
result
=
new
List
<
int
>();
if
(
obj
!=
null
&&
!
string
.
IsNullOrWhiteSpace
(
obj
.
ToString
()))
{
var
tempArray
=
obj
.
ToString
().
Split
(
','
);
if
(
tempArray
!=
null
&&
tempArray
.
Length
>
0
)
{
foreach
(
var
item
in
tempArray
)
{
Int32
.
TryParse
(
item
,
out
int
NewValue
);
if
(
NewValue
>
0
)
{
result
.
Add
(
NewValue
);
}
}
}
}
return
result
;
}
/// <summary>
/// 转Int
/// </summary>
...
...
Mall.Model/Entity/Product/RB_Goods.cs
View file @
4c56af02
...
...
@@ -553,5 +553,20 @@ namespace Mall.Model.Entity.Product
/// 课程标签
/// </summary>
public
string
CourseLable
{
get
;
set
;
}
/// <summary>
/// 定金
/// </summary>
public
decimal
DepositMoney
{
get
;
set
;
}
/// <summary>
/// 是否选择服务人员(0-不选,1-选择)
/// </summary>
public
int
IsChooseServicePerson
{
get
;
set
;
}
/// <summary>
/// 门店编号
/// </summary>
public
string
StoresIds
{
get
;
set
;
}
}
}
Mall.Model/Entity/User/RB_Stores.cs
View file @
4c56af02
...
...
@@ -161,5 +161,15 @@ namespace Mall.Model.Entity.User
/// 服务项目
/// </summary>
public
string
ServiceProject
{
get
;
set
;
}
/// <summary>
/// 经度
/// </summary>
public
float
Lng
{
get
;
set
;
}
/// <summary>
/// 纬度
/// </summary>
public
float
Lat
{
get
;
set
;
}
}
}
Mall.Model/Extend/Product/RB_Goods_Extend.cs
View file @
4c56af02
...
...
@@ -339,5 +339,15 @@ namespace Mall.Model.Extend.Product
/// </summary>
public
object
ERPGoodObj
{
get
;
set
;
}
/// <summary>
/// 门店列表
/// </summary>
public
List
<
int
>
StoresList
{
get
{
return
Common
.
ConvertHelper
.
ConvertToListInt
(
this
.
StoresIds
);
}
}
}
}
Mall.Model/Extend/User/RB_Stores_Extend.cs
View file @
4c56af02
...
...
@@ -13,5 +13,25 @@ namespace Mall.Model.Entity.User
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Stores_Extend
:
Model
.
Entity
.
User
.
RB_Stores
{
/// <summary>
/// 排序(1-名称,2-距离,3-热度)
/// </summary>
public
int
OrderByType
{
get
;
set
;
}
/// <summary>
/// 当前经度纬度
/// </summary>
public
string
CurrentPosition
{
get
;
set
;
}
/// <summary>
/// 距离公里数
/// </summary>
public
decimal
KM
{
get
;
set
;
}
}
}
Mall.Module.Reserve/Mall.Module.Reserve.csproj
View file @
4c56af02
...
...
@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Mall.AOP\Mall.AOP.csproj" />
<ProjectReference Include="..\Mall.Repository\Mall.Repository.csproj" />
</ItemGroup>
...
...
Mall.Module.Reserve/OfflineGoodsModule.cs
0 → 100644
View file @
4c56af02
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
Mall.AOP.CustomerAttribute
;
using
Mall.Common.API
;
using
Mall.Common.Enum.Goods
;
using
Mall.Common.Plugin
;
using
Mall.Model.Entity.BaseSetUp
;
using
Mall.Model.Entity.GuideCar
;
using
Mall.Model.Entity.Product
;
using
Mall.Model.Entity.User
;
using
Mall.Model.Extend.BaseSetUp
;
using
Mall.Model.Extend.GuideCar
;
using
Mall.Model.Extend.Product
;
using
Mall.Model.Extend.User
;
using
Mall.Model.Query
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.GuideCar
;
using
Mall.Repository.MarketingCenter
;
using
Mall.Repository.Product
;
using
Mall.Repository.User
;
using
Newtonsoft.Json
;
using
VT.FW.DB
;
namespace
Mall.Module.Product
{
/// <summary>
/// 线下服务商品管理
/// </summary>
public
class
OfflineGoodsModule
{
/// <summary>
/// 素材分组
/// </summary>
private
readonly
RB_Material_GroupRepository
material_GroupRepository
=
new
RB_Material_GroupRepository
();
/// <summary>
/// 素材管理
/// </summary>
private
readonly
RB_Material_InfoRepository
material_InfoRepository
=
new
RB_Material_InfoRepository
();
/// <summary>
/// 商品分类
/// </summary>
private
readonly
RB_Product_CategoryRepository
product_CategoryRepository
=
new
RB_Product_CategoryRepository
();
/// <summary>
/// 商品
/// </summary>
private
readonly
RB_GoodsRepository
goodsRepository
=
new
RB_GoodsRepository
();
/// <summary>
/// 商品可预定日期
/// </summary>
private
readonly
RB_Goods_TargetDateRepository
goods_TargetDateRepository
=
new
RB_Goods_TargetDateRepository
();
/// <summary>
/// 商品日志
/// </summary>
private
readonly
RB_Goods_LogRepository
goods_LogRepository
=
new
RB_Goods_LogRepository
();
/// <summary>
/// 商品区域
/// </summary>
private
readonly
RB_Goods_AreaRepository
goods_AreaRepository
=
new
RB_Goods_AreaRepository
();
/// <summary>
/// 商品分类
/// </summary>
private
readonly
RB_Goods_CategoryRepository
goods_CategoryRepository
=
new
RB_Goods_CategoryRepository
();
/// <summary>
/// 分销商等级
/// </summary>
private
readonly
RB_Distributor_GradeRepository
distributor_GradeRepository
=
new
RB_Distributor_GradeRepository
();
/// <summary>
/// 分销商
/// </summary>
private
readonly
RB_Distributor_InfoRepository
distributor_InfoRepository
=
new
RB_Distributor_InfoRepository
();
/// <summary>
/// 分销基础配置
/// </summary>
private
readonly
RB_Distributor_BasicsRepository
distributor_BasicsRepository
=
new
RB_Distributor_BasicsRepository
();
/// <summary>
/// 会员等级
/// </summary>
private
readonly
RB_Member_GradeRepository
member_GradeRepository
=
new
RB_Member_GradeRepository
();
/// <summary>
/// 用户管理
/// </summary>
private
readonly
RB_Member_UserRepository
member_UserRepository
=
new
RB_Member_UserRepository
();
/// <summary>
/// 商品分销佣金
/// </summary>
private
readonly
RB_Goods_DistributionCommissionRepository
goods_DistributionCommissionRepository
=
new
RB_Goods_DistributionCommissionRepository
();
/// <summary>
/// 商品会员价格
/// </summary>
private
readonly
RB_Goods_MemberPriceRepository
goods_MemberPriceRepository
=
new
RB_Goods_MemberPriceRepository
();
/// <summary>
/// 商户仓储层对象
/// </summary>
private
Mall
.
Repository
.
User
.
RB_MiniProgramRepository
programRepository
=
new
Repository
.
User
.
RB_MiniProgramRepository
();
/// <summary>
/// 商品收藏
/// </summary>
private
readonly
RB_Member_CollectionRepository
member_CollectionRepository
=
new
RB_Member_CollectionRepository
();
/// <summary>
/// 收货地址
/// </summary>
private
readonly
RB_Member_ShippingAddressRepository
member_ShippingAddressRepository
=
new
RB_Member_ShippingAddressRepository
();
/// <summary>
/// 订单商品
/// </summary>
private
readonly
RB_Goods_OrderRepository
goods_OrderRepository
=
new
RB_Goods_OrderRepository
();
/// <summary>
/// 订单明细
/// </summary>
private
readonly
RB_Goods_OrderDetailRepository
goods_OrderDetailRepository
=
new
RB_Goods_OrderDetailRepository
();
/// <summary>
/// 商品评论
/// </summary>
private
readonly
RB_Goods_CommentRepository
goods_CommentRepository
=
new
RB_Goods_CommentRepository
();
/// <summary>
/// 地区处理
/// </summary>
private
readonly
Rb_destinationRepository
destinationRepository
=
new
Rb_destinationRepository
();
/// <summary>
/// 商品分销
/// </summary>
private
readonly
RB_MiniProgram_GoodPosterRepository
miniProgram_GoodPosterRepository
=
new
RB_MiniProgram_GoodPosterRepository
();
/// <summary>
/// 粉象返佣
/// </summary>
private
readonly
RB_Distributor_FXGradeRepository
distributor_FXGradeRepository
=
new
RB_Distributor_FXGradeRepository
();
/// <summary>
/// 粉象VIP返佣比例
/// </summary>
private
readonly
RB_Distributor_FXCommissionRepository
distributor_FXCommissionRepository
=
new
RB_Distributor_FXCommissionRepository
();
/// <summary>
/// 微店基础
/// </summary>
private
RB_SmallShops_CustomRepository
smallShops_CustomRepository
=
new
RB_SmallShops_CustomRepository
();
/// <summary>
/// 微店
/// </summary>
private
RB_SmallShops_InfoRepository
smallShops_InfoRepository
=
new
RB_SmallShops_InfoRepository
();
/// <summary>
/// 微店商品价格
/// </summary>
private
RB_SmallShops_PriceRepository
smallShops_PriceRepository
=
new
RB_SmallShops_PriceRepository
();
/// <summary>
/// 司导站点
/// </summary>
private
RB_GuideCar_SiteRepository
SiteRepository
=
new
RB_GuideCar_SiteRepository
();
/// <summary>
/// 司导站点地区
/// </summary>
private
RB_GuideCar_SiteRegionRepository
SiteRegionRepository
=
new
RB_GuideCar_SiteRegionRepository
();
/// <summary>
/// 司导基础配置
/// </summary>
private
RB_GuideCar_BaseRepository
guideCar_BaseRepository
=
new
RB_GuideCar_BaseRepository
();
/// <summary>
/// 司导基础配置
/// </summary>
private
RB_GuideCar_GuideRepository
GuideRepository
=
new
RB_GuideCar_GuideRepository
();
/// <summary>
/// 车辆
/// </summary>
private
RB_GuideCar_CarRepository
GuideCarRepository
=
new
RB_GuideCar_CarRepository
();
/// <summary>
/// 车辆颜色
/// </summary>
private
RB_GuideCar_CarColorRepository
CarColorRepository
=
new
RB_GuideCar_CarColorRepository
();
/// <summary>
/// 积分规则
/// </summary>
private
readonly
RB_Integral_SettingsRepository
integral_SettingsRepository
=
new
RB_Integral_SettingsRepository
();
/// <summary>
/// 小程序基础
/// </summary>
private
readonly
RB_MallBaseRepository
mallBaseRepository
=
new
RB_MallBaseRepository
();
/// <summary>
/// 小程序
/// </summary>
private
readonly
RB_MiniProgramRepository
miniProgramRepository
=
new
RB_MiniProgramRepository
();
/// <summary>
/// 运费
/// </summary>
private
readonly
RB_Logistics_RulesRepository
logistics_RulesRepository
=
new
RB_Logistics_RulesRepository
();
private
readonly
RB_Logistics_RulesRegionRepository
logistics_RulesRegionRepository
=
new
RB_Logistics_RulesRegionRepository
();
/// <summary>
/// 优惠卷
/// </summary>
private
readonly
RB_Member_CouponRepository
member_CouponRepository
=
new
RB_Member_CouponRepository
();
private
readonly
RB_DiscountCouponRepository
discountCouponRepository
=
new
RB_DiscountCouponRepository
();
private
readonly
RB_DiscountCoupon_ProductRepository
discountCoupon_ProductRepository
=
new
RB_DiscountCoupon_ProductRepository
();
/// <summary>
/// 车辆搜索模块
/// </summary>
private
RB_GuideCar_CarSearchSearchRepository
carSearchSearchRepository
=
new
RB_GuideCar_CarSearchSearchRepository
();
/// <summary>
/// 车辆搜索模块
/// </summary>
private
RB_GuideCar_CarBrandRepository
carBrandRepository
=
new
RB_GuideCar_CarBrandRepository
();
/// <summary>
/// 用户积分
/// </summary>
private
readonly
RB_Member_IntegralRepository
member_IntegralRepository
=
new
RB_Member_IntegralRepository
();
/// <summary>
/// 获取会员等级列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public
List
<
RB_Member_Grade_Extend
>
GetMemberGradeList
(
RB_Member_Grade_Extend
dmodel
)
{
var
list
=
member_GradeRepository
.
GetList
(
dmodel
);
return
list
;
}
/// <summary>
/// 获取分销等级列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Distributor_Grade_Extend
>
GetDistributorGradeList
(
RB_Distributor_Grade_Extend
demodel
)
{
var
list
=
distributor_GradeRepository
.
GetList
(
demodel
);
return
list
;
}
#
region
商品管理
/// <summary>
/// 获取后台商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Goods_Extend
>
GetOfflineProductGoodsPageList
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Goods_Extend
demodel
)
{
var
list
=
goodsRepository
.
GetPageListForCommission
(
pageIndex
,
pageSize
,
out
count
,
demodel
,
3
);
if
(
list
.
Any
())
{
//查询分类
string
ids
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
clist
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsIds
=
ids
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
olist
=
goods_OrderRepository
.
GetGoodsOrderNum
(
ids
);
foreach
(
var
item
in
list
)
{
item
.
CategoryList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
//轮播图
item
.
CoverImage
=
""
;
item
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
//轮播图
foreach
(
var
qitem
in
CarouselIdList
)
{
item
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
0
,
Name
=
""
,
Path
=
qitem
});
}
}
item
.
GoodsBuyNum
=
olist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
FirstOrDefault
()?.
OrderNum
??
0
;
}
}
return
list
;
}
/// <summary>
/// 获取后台商品分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Goods_Extend
>
GetProductGoodsPageListToExcel
(
int
pageIndex
,
int
pageSize
,
out
long
count
,
RB_Goods_Extend
demodel
)
{
var
list
=
goodsRepository
.
GetPageListForCommission
(
pageIndex
,
pageSize
,
out
count
,
demodel
,
3
);
if
(
list
.
Any
())
{
//查询分类
string
ids
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
clist
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsIds
=
ids
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
olist
=
goods_OrderRepository
.
GetGoodsOrderNum
(
ids
);
//区域
var
AreaList
=
new
List
<
RB_Goods_Area_Extend
>();
if
(
list
.
Where
(
x
=>
x
.
IsAreaBuy
==
1
).
Any
())
{
string
goodssid
=
string
.
Join
(
","
,
list
.
Where
(
x
=>
x
.
IsAreaBuy
==
1
).
Select
(
x
=>
x
.
Id
));
AreaList
=
goods_AreaRepository
.
GetList
(
new
RB_Goods_Area_Extend
()
{
GoodsIds
=
goodssid
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
#
region
查询司导信息
string
siteIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
SiteId
));
var
sitelist
=
SiteRepository
.
GetGuideCarSiteList
(
new
RB_GuideCar_Site_Extend
()
{
SiteIds
=
siteIds
});
string
guideIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
GuideId
));
var
guidelist
=
GuideRepository
.
GetGuideCarGuideList
(
new
RB_GuideCar_Guide_Extend
()
{
GuideIds
=
guideIds
});
string
carids
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
CarId
));
var
carlist
=
GuideCarRepository
.
GetGuideCarCarList
(
new
RB_GuideCar_Car_Extend
()
{
GuideCarIds
=
carids
});
string
colorIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
CarColorId
));
var
carcolorlist
=
CarColorRepository
.
GetCarColorList
(
new
RB_GuideCar_CarColor_Extend
()
{
CarColorIds
=
colorIds
});
#
endregion
foreach
(
var
item
in
list
)
{
item
.
CategoryList
=
clist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
//轮播图
item
.
CoverImage
=
""
;
item
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
//轮播图
foreach
(
var
qitem
in
CarouselIdList
)
{
item
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
0
,
Name
=
""
,
Path
=
qitem
});
}
}
item
.
GoodsBuyNum
=
olist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
FirstOrDefault
()?.
OrderNum
??
0
;
item
.
SiteName
=
sitelist
.
Where
(
x
=>
x
.
ID
==
item
.
SiteId
).
FirstOrDefault
()?.
SiteName
??
""
;
item
.
GuideName
=
guidelist
.
Where
(
x
=>
x
.
ID
==
item
.
GuideId
).
FirstOrDefault
()?.
Name
??
""
;
item
.
CarName
=
carlist
.
Where
(
x
=>
x
.
ID
==
item
.
CarId
).
FirstOrDefault
()?.
Name
??
""
;
item
.
CarColorName
=
carcolorlist
.
Where
(
x
=>
x
.
ID
==
item
.
CarColorId
).
FirstOrDefault
()?.
ColorName
??
""
;
item
.
AreaList
=
new
List
<
RB_Goods_Area_Extend
>();
if
(
item
.
IsAreaBuy
==
1
)
{
item
.
AreaList
=
AreaList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
}
}
}
return
list
;
}
/// <summary>
/// 获取商品详情
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
public
RB_Goods_Extend
GetProductGoodsInfo
(
int
goodsId
,
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
.
CategoryList
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
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
>();
model
.
DistributionCommissionTreeList
=
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
});
if
(
model
.
DistributionCommissionList
.
Any
())
{
int
SortNum
=
1
;
//获取分销商启用等级
var
dgradeList
=
distributor_GradeRepository
.
GetList
(
new
RB_Distributor_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
dgradeList
.
Add
(
new
RB_Distributor_Grade_Extend
()
{
Grade
=
0
,
Name
=
"默认等级"
,
Id
=
0
});
string
zdgradeStr
=
string
.
Join
(
","
,
dgradeList
.
Select
(
x
=>
x
.
Id
).
OrderBy
(
x
=>
x
));
string
ndgradeStr
=
string
.
Join
(
","
,
model
.
DistributionCommissionList
.
Select
(
x
=>
x
.
DistributorGrade
).
Distinct
().
OrderBy
(
x
=>
x
));
var
KeyList
=
model
.
DistributionCommissionList
.
Select
(
x
=>
x
.
SpecificationSort
??
""
).
Distinct
().
ToList
();
if
(
zdgradeStr
==
ndgradeStr
)
{
foreach
(
var
qitem
in
KeyList
)
{
var
treemodel
=
model
.
DistributionCommissionList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
FirstOrDefault
();
treemodel
.
GradeCommissionList
=
model
.
DistributionCommissionList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
ToList
();
if
(
model
.
SeparateDistributionType
==
2
)
{
if
(!
string
.
IsNullOrEmpty
(
qitem
))
{
var
ssarr
=
qitem
.
Split
(
':'
);
int
Sort
=
Convert
.
ToInt32
(
ssarr
[
0
]);
string
pic_url
=
model
.
SpecificationList
[
0
].
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Sort
).
FirstOrDefault
()?.
ImagePath
;
List
<
object
>
AttrList
=
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
();
AttrList
.
Add
(
new
{
SName
=
smodel
.
Name
,
SId
=
smodel
.
Id
,
SVId
=
svmodel
.
Sort
,
SVName
=
svmodel
.
Name
});
}
treemodel
.
AttrList
=
AttrList
;
}
}
treemodel
.
Sort
=
SortNum
;
treemodel
.
GradeCommissionList
=
treemodel
.
GradeCommissionList
.
OrderBy
(
x
=>
x
.
DistributorGrade
).
ToList
();
model
.
DistributionCommissionTreeList
.
Add
(
treemodel
);
}
}
else
{
//分销商等级有变更
foreach
(
var
qitem
in
KeyList
)
{
var
treemodel
=
model
.
DistributionCommissionList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
FirstOrDefault
();
treemodel
.
GradeCommissionList
=
new
List
<
RB_Goods_DistributionCommission_Extend
>();
var
gradeCommList
=
model
.
DistributionCommissionList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
ToList
();
dgradeList
=
dgradeList
.
OrderByDescending
(
x
=>
x
.
Grade
).
ToList
();
foreach
(
var
grade
in
dgradeList
)
{
var
gradeMList
=
gradeCommList
.
Where
(
x
=>
x
.
DistributorGrade
==
grade
.
Id
&&
x
.
SpecificationSort
==
qitem
);
if
(
gradeMList
.
Any
())
{
treemodel
.
GradeCommissionList
.
AddRange
(
gradeMList
);
}
else
{
//表示新的
treemodel
.
GradeCommissionList
.
Add
(
new
RB_Goods_DistributionCommission_Extend
()
{
DistributorGrade
=
grade
.
Id
,
OneCommission
=
0
,
TwoCommission
=
0
,
ThreeCommission
=
0
});
}
}
if
(
model
.
SeparateDistributionType
==
2
)
{
if
(!
string
.
IsNullOrEmpty
(
qitem
))
{
var
ssarr
=
qitem
.
Split
(
':'
);
int
Sort
=
Convert
.
ToInt32
(
ssarr
[
0
]);
string
pic_url
=
model
.
SpecificationList
[
0
].
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Sort
).
FirstOrDefault
()?.
ImagePath
;
List
<
object
>
AttrList
=
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
();
AttrList
.
Add
(
new
{
SName
=
smodel
.
Name
,
SId
=
smodel
.
Id
,
SVId
=
svmodel
.
Sort
,
SVName
=
svmodel
.
Name
});
}
treemodel
.
AttrList
=
AttrList
;
}
}
treemodel
.
Sort
=
SortNum
;
treemodel
.
GradeCommissionList
=
treemodel
.
GradeCommissionList
.
OrderBy
(
x
=>
x
.
DistributorGrade
).
ToList
();
model
.
DistributionCommissionTreeList
.
Add
(
treemodel
);
}
}
SortNum
++;
if
(
model
.
DistributionCommissionTreeList
.
Any
())
{
//倒序排一次
model
.
DistributionCommissionTreeList
=
model
.
DistributionCommissionTreeList
.
OrderByDescending
(
x
=>
x
.
Sort
).
ToList
();
}
}
}
model
.
MemberPriceList
=
new
List
<
RB_Goods_MemberPrice_Extend
>();
model
.
MemberPriceTreeList
=
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
});
if
(
model
.
MemberPriceList
.
Any
())
{
int
SortNum
=
1
;
var
mgradeList
=
member_GradeRepository
.
GetList
(
new
RB_Member_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
1
,
MallBaseId
=
1
});
string
zdgradeStr
=
string
.
Join
(
","
,
mgradeList
.
Select
(
x
=>
x
.
Id
).
OrderBy
(
x
=>
x
));
string
ndgradeStr
=
string
.
Join
(
","
,
model
.
MemberPriceList
.
Select
(
x
=>
x
.
MemberGrade
).
Distinct
().
OrderBy
(
x
=>
x
));
if
(
zdgradeStr
==
ndgradeStr
)
{
var
KeyList
=
model
.
MemberPriceList
.
Select
(
x
=>
x
.
SpecificationSort
??
""
).
Distinct
().
ToList
();
foreach
(
var
qitem
in
KeyList
)
{
var
treemodel
=
model
.
MemberPriceList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
FirstOrDefault
();
treemodel
.
GradePriceList
=
model
.
MemberPriceList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
ToList
();
if
(!
string
.
IsNullOrEmpty
(
qitem
))
{
var
ssarr
=
qitem
.
Split
(
':'
);
int
Sort
=
Convert
.
ToInt32
(
ssarr
[
0
]);
string
pic_url
=
model
.
SpecificationList
[
0
].
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Sort
).
FirstOrDefault
()?.
ImagePath
;
List
<
object
>
AttrList
=
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
();
AttrList
.
Add
(
new
{
SName
=
smodel
.
Name
,
SId
=
smodel
.
Id
,
SVId
=
svmodel
.
Sort
,
SVName
=
svmodel
.
Name
});
}
treemodel
.
AttrList
=
AttrList
;
}
treemodel
.
Sort
=
SortNum
;
treemodel
.
GradePriceList
=
treemodel
.
GradePriceList
.
OrderBy
(
x
=>
x
.
MemberGrade
).
ToList
();
model
.
MemberPriceTreeList
.
Add
(
treemodel
);
}
}
else
{
//会员等级有变更
var
KeyList
=
model
.
MemberPriceList
.
Select
(
x
=>
x
.
SpecificationSort
??
""
).
Distinct
().
ToList
();
foreach
(
var
qitem
in
KeyList
)
{
var
treemodel
=
model
.
MemberPriceList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
FirstOrDefault
();
treemodel
.
GradePriceList
=
new
List
<
RB_Goods_MemberPrice_Extend
>()
{
};
var
gradePrice
=
model
.
MemberPriceList
.
Where
(
x
=>
(
x
.
SpecificationSort
??
""
)
==
qitem
).
ToList
();
mgradeList
=
mgradeList
.
OrderByDescending
(
x
=>
x
.
Grade
).
ToList
();
foreach
(
var
grade
in
mgradeList
)
{
var
gradeMList
=
gradePrice
.
Where
(
x
=>
x
.
MemberGrade
==
grade
.
Id
&&
x
.
SpecificationSort
==
qitem
);
if
(
gradeMList
.
Any
())
{
treemodel
.
GradePriceList
.
AddRange
(
gradeMList
);
}
else
{
//表示新的
treemodel
.
GradePriceList
.
Add
(
new
RB_Goods_MemberPrice_Extend
()
{
MemberGrade
=
grade
.
Id
,
MemberPrice
=
0
,
});
}
}
if
(!
string
.
IsNullOrEmpty
(
qitem
))
{
var
ssarr
=
qitem
.
Split
(
':'
);
int
Sort
=
Convert
.
ToInt32
(
ssarr
[
0
]);
string
pic_url
=
model
.
SpecificationList
[
0
].
SpecificationValueList
.
Where
(
x
=>
x
.
Sort
==
Sort
).
FirstOrDefault
()?.
ImagePath
;
List
<
object
>
AttrList
=
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
();
AttrList
.
Add
(
new
{
SName
=
smodel
.
Name
,
SId
=
smodel
.
Id
,
SVId
=
svmodel
.
Sort
,
SVName
=
svmodel
.
Name
});
}
treemodel
.
AttrList
=
AttrList
;
}
treemodel
.
Sort
=
SortNum
;
treemodel
.
GradePriceList
=
treemodel
.
GradePriceList
.
OrderBy
(
x
=>
x
.
MemberGrade
).
ToList
();
model
.
MemberPriceTreeList
.
Add
(
treemodel
);
}
}
SortNum
++;
if
(
model
.
MemberPriceTreeList
.
Any
())
{
//倒序排一次
model
.
MemberPriceTreeList
=
model
.
MemberPriceTreeList
.
OrderByDescending
(
x
=>
x
.
Sort
).
ToList
();
}
}
}
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
;
#
region
可预定日期
model
.
TargetDateList
=
goods_TargetDateRepository
.
GetList
(
new
RB_Goods_TargetDate_Extend
()
{
GoodsId
=
goodsId
});
#
endregion
if
(!
string
.
IsNullOrEmpty
(
model
.
LineDescription
)
&&
model
.
LineDescription
!=
"[]"
)
{
model
.
LineDescriptionList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
model
.
LineDescription
);
}
return
model
;
}
/// <summary>
/// 新增修改商品信息
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
[
TransactionCallHandler
]
public
virtual
bool
SetProductGoodsInfo
(
RB_Goods_Extend
demodel
)
{
bool
flag
=
false
;
demodel
.
GoodsClassify
=
3
;
try
{
if
(
demodel
.
Id
>
0
)
{
//修改
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
Name
),
demodel
.
Name
},
{
nameof
(
RB_Goods
.
CarouselImage
),
demodel
.
CarouselImage
},
{
nameof
(
RB_Goods
.
VideoAddress
),
demodel
.
VideoAddress
},
{
nameof
(
RB_Goods
.
CustomShareTitles
),
demodel
.
CustomShareTitles
},
{
nameof
(
RB_Goods
.
CustomShareImage
),
demodel
.
CustomShareImage
},
{
nameof
(
RB_Goods
.
GoodsStatus
),
demodel
.
GoodsStatus
},
{
nameof
(
RB_Goods
.
InventoryNum
),
demodel
.
InventoryNum
},
{
nameof
(
RB_Goods
.
DefaultSpecificationName
),
demodel
.
DefaultSpecificationName
},
{
nameof
(
RB_Goods
.
IsCustomSpecification
),
demodel
.
IsCustomSpecification
},
{
nameof
(
RB_Goods
.
Sort
),
demodel
.
Sort
},
{
nameof
(
RB_Goods
.
SellingPrice
),
demodel
.
SellingPrice
},
{
nameof
(
RB_Goods
.
OriginalPrice
),
demodel
.
OriginalPrice
},
{
nameof
(
RB_Goods
.
Unit
),
demodel
.
Unit
},
{
nameof
(
RB_Goods
.
CostPrice
),
demodel
.
CostPrice
},
{
nameof
(
RB_Goods
.
IsGoodsNegotiable
),
demodel
.
IsGoodsNegotiable
},
{
nameof
(
RB_Goods
.
SalesNum
),
demodel
.
SalesNum
},
{
nameof
(
RB_Goods
.
GoodsNumbers
),
demodel
.
GoodsNumbers
},
{
nameof
(
RB_Goods
.
GoodsWeight
),
demodel
.
GoodsWeight
},
{
nameof
(
RB_Goods
.
IsDefaultService
),
demodel
.
IsDefaultService
},
{
nameof
(
RB_Goods
.
GoodsService
),
demodel
.
GoodsService
},
{
nameof
(
RB_Goods
.
FreightId
),
demodel
.
FreightId
},
{
nameof
(
RB_Goods
.
FormsId
),
demodel
.
FormsId
},
{
nameof
(
RB_Goods
.
LimitBuyGoodsNum
),
demodel
.
LimitBuyGoodsNum
},
{
nameof
(
RB_Goods
.
LimitBuyOrderNum
),
demodel
.
LimitBuyOrderNum
},
{
nameof
(
RB_Goods
.
FullNumPinkage
),
demodel
.
FullNumPinkage
},
{
nameof
(
RB_Goods
.
FullMoneyPinkage
),
demodel
.
FullMoneyPinkage
},
{
nameof
(
RB_Goods
.
IsAreaBuy
),
demodel
.
IsAreaBuy
},
{
nameof
(
RB_Goods
.
IntegralPresent
),
demodel
.
IntegralPresent
},
{
nameof
(
RB_Goods
.
IntegralPresentType
),
demodel
.
IntegralPresentType
},
{
nameof
(
RB_Goods
.
PointsDeduction
),
demodel
.
PointsDeduction
},
{
nameof
(
RB_Goods
.
PointsDeductionType
),
demodel
.
PointsDeductionType
},
{
nameof
(
RB_Goods
.
IsMultipleDeduction
),
demodel
.
IsMultipleDeduction
},
{
nameof
(
RB_Goods
.
GoodsDetails
),
demodel
.
GoodsDetails
},
{
nameof
(
RB_Goods
.
UpdateDate
),
demodel
.
UpdateDate
},
{
nameof
(
RB_Goods
.
SeparateDistribution
),
demodel
.
SeparateDistribution
},
{
nameof
(
RB_Goods
.
SeparateDistributionType
),
demodel
.
SeparateDistributionType
},
{
nameof
(
RB_Goods
.
SeparateDistributionMoneyType
),
demodel
.
SeparateDistributionMoneyType
},
{
nameof
(
RB_Goods
.
EnjoyMember
),
demodel
.
EnjoyMember
},
{
nameof
(
RB_Goods
.
SeparateSetMember
),
demodel
.
SeparateSetMember
},
{
nameof
(
RB_Goods
.
IsQuickBuy
),
demodel
.
IsQuickBuy
},
{
nameof
(
RB_Goods
.
SupplierId
),
demodel
.
SupplierId
},
{
nameof
(
RB_Goods
.
IsProxy
),
demodel
.
IsProxy
},
{
nameof
(
RB_Goods
.
ProxyType
),
demodel
.
ProxyType
},
{
nameof
(
RB_Goods
.
ProxyRises
),
demodel
.
ProxyRises
},
{
nameof
(
RB_Goods
.
ProxyMoney
),
demodel
.
ProxyMoney
},
{
nameof
(
RB_Goods
.
Commission
),
demodel
.
Commission
},
{
nameof
(
RB_Goods
.
PresentFXGrade
),
demodel
.
PresentFXGrade
},
{
nameof
(
RB_Goods
.
PresentFXMonth
),
demodel
.
PresentFXMonth
},
{
nameof
(
RB_Goods
.
Advertising
),
demodel
.
Advertising
},
{
nameof
(
RB_Goods
.
SubName
),
demodel
.
SubName
},
{
nameof
(
RB_Goods
.
MarketingLogo
),
demodel
.
MarketingLogo
},
{
nameof
(
RB_Goods
.
IsLiveGoods
),
demodel
.
IsLiveGoods
},
{
nameof
(
RB_Goods
.
ShelvesDate
),
demodel
.
ShelvesDate
},
{
nameof
(
RB_Goods
.
DownDate
),
demodel
.
DownDate
},
{
nameof
(
RB_Goods
.
SendArea
),
demodel
.
SendArea
},
{
nameof
(
RB_Goods
.
SiteId
),
demodel
.
SiteId
},
{
nameof
(
RB_Goods
.
GuideId
),
demodel
.
GuideId
},
{
nameof
(
RB_Goods
.
CarId
),
demodel
.
CarId
},
{
nameof
(
RB_Goods
.
CarColorId
),
demodel
.
CarColorId
},
{
nameof
(
RB_Goods
.
CarNumber
),
demodel
.
CarNumber
},
{
nameof
(
RB_Goods
.
CarBuyYear
),
demodel
.
CarBuyYear
},
{
nameof
(
RB_Goods
.
CarType
),
demodel
.
CarType
},
{
nameof
(
RB_Goods
.
UseDay
),
demodel
.
UseDay
},
{
nameof
(
RB_Goods
.
LineName
),
demodel
.
LineName
},
{
nameof
(
RB_Goods
.
LineDescription
),
demodel
.
LineDescription
},
{
nameof
(
RB_Goods
.
IsSpell
),
demodel
.
IsSpell
},
{
nameof
(
RB_Goods
.
RideNum
),
demodel
.
RideNum
},
{
nameof
(
RB_Goods
.
AdvanceDay
),
demodel
.
AdvanceDay
},
{
nameof
(
RB_Goods
.
VideoType
),
demodel
.
VideoType
},
{
nameof
(
RB_Goods
.
IntegralComment
),
demodel
.
IntegralComment
},
{
nameof
(
RB_Goods
.
IntegralCommentType
),
demodel
.
IntegralCommentType
},
{
nameof
(
RB_Goods
.
GoodsType
),
demodel
.
GoodsType
},
{
nameof
(
RB_Goods
.
GoodsPageType
),
demodel
.
GoodsPageType
},
{
nameof
(
RB_Goods
.
DepositMoney
),
demodel
.
DepositMoney
},
{
nameof
(
RB_Goods
.
IsChooseServicePerson
),
demodel
.
IsChooseServicePerson
},
{
nameof
(
RB_Goods
.
StoresIds
),
demodel
.
StoresIds
},
{
nameof
(
RB_Goods
.
Remark
),
demodel
.
Remark
},
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(
nameof
(
RB_Goods
.
Id
),
demodel
.
Id
)
,
new
WhereHelper
(
nameof
(
RB_Goods
.
TenantId
),
demodel
.
TenantId
)
,
new
WhereHelper
(
nameof
(
RB_Goods
.
MallBaseId
),
demodel
.
MallBaseId
)
};
flag
=
goodsRepository
.
Update
(
keyValues
,
wheres
);
if
(
flag
)
{
#
region
修改可预定日期
var
tdlist
=
goods_TargetDateRepository
.
GetList
(
new
RB_Goods_TargetDate_Extend
()
{
GoodsId
=
demodel
.
Id
});
var
tdinsertList
=
demodel
.
TargetDateList
.
Where
(
x
=>
!
tdlist
.
Select
(
y
=>
y
.
Date
).
Contains
(
x
.
Date
)).
ToList
();
var
tddeleteList
=
tdlist
.
Where
(
x
=>
!
demodel
.
TargetDateList
.
Select
(
y
=>
y
.
Date
).
Contains
(
x
.
Date
)).
ToList
();
foreach
(
var
item
in
tdinsertList
)
{
goods_TargetDateRepository
.
Insert
(
new
RB_Goods_TargetDate
()
{
Id
=
0
,
GoodsId
=
demodel
.
Id
,
Date
=
item
.
Date
,
IsReserve
=
1
,
ReserveNum
=
0
});
}
foreach
(
var
item
in
tddeleteList
)
{
goods_TargetDateRepository
.
Delete
(
item
);
}
#
endregion
#
region
修改分类
var
clist
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsId
=
demodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
insertList
=
demodel
.
CategoryList
.
Where
(
x
=>
!
clist
.
Select
(
y
=>
y
.
CategoryId
).
Contains
(
x
.
CategoryId
)).
ToList
();
var
deleteList
=
clist
.
Where
(
x
=>
!
demodel
.
CategoryList
.
Select
(
y
=>
y
.
CategoryId
).
Contains
(
x
.
CategoryId
)).
ToList
();
foreach
(
var
item
in
insertList
)
{
goods_CategoryRepository
.
Insert
(
new
RB_Goods_Category
()
{
CategoryId
=
item
.
CategoryId
,
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
demodel
.
Id
,
Id
=
0
,
MallBaseId
=
demodel
.
MallBaseId
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
});
}
foreach
(
var
item
in
deleteList
)
{
goods_CategoryRepository
.
Delete
(
item
.
Id
);
}
#
endregion
#
region
修改区域
var
alist
=
goods_AreaRepository
.
GetList
(
new
RB_Goods_Area_Extend
()
{
GoodsId
=
demodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
insertList1
=
demodel
.
AreaList
.
Where
(
x
=>
!
alist
.
Select
(
y
=>
y
.
AreaId
).
Contains
(
x
.
AreaId
)).
ToList
();
var
deleteList1
=
alist
.
Where
(
x
=>
!
demodel
.
AreaList
.
Select
(
y
=>
y
.
AreaId
).
Contains
(
x
.
AreaId
)).
ToList
();
foreach
(
var
item
in
insertList1
)
{
goods_AreaRepository
.
Insert
(
new
RB_Goods_Area
()
{
AreaId
=
item
.
AreaId
,
AreaType
=
item
.
AreaType
,
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
demodel
.
Id
,
Id
=
0
,
MallBaseId
=
demodel
.
MallBaseId
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
});
}
foreach
(
var
item
in
deleteList1
)
{
goods_AreaRepository
.
Delete
(
item
.
Id
);
}
#
endregion
#
region
修改分销佣金
if
(
demodel
.
SeparateDistribution
==
1
)
{
//价格新增/更新
var
dclist
=
goods_DistributionCommissionRepository
.
GetList
(
new
RB_Goods_DistributionCommission_Extend
()
{
GoodsId
=
demodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
dclist
.
Count
()
!=
demodel
.
DistributionCommissionList
.
Count
()
||
dclist
.
Count
()
!=
demodel
.
DistributionCommissionList
.
Where
(
x
=>
dclist
.
Select
(
y
=>
y
.
SpecificationSort
).
Contains
(
x
.
SpecificationSort
)).
Count
()
||
dclist
.
Select
(
x
=>
x
.
DistributorGrade
).
Distinct
().
Count
()
!=
demodel
.
DistributionCommissionList
.
Select
(
x
=>
x
.
DistributorGrade
).
Distinct
().
Count
()
||
dclist
.
Select
(
x
=>
x
.
DistributorGrade
).
Distinct
().
Count
()
!=
dclist
.
Select
(
x
=>
x
.
DistributorGrade
).
Distinct
().
Where
(
x
=>
demodel
.
DistributionCommissionList
.
Select
(
y
=>
y
.
DistributorGrade
).
Distinct
().
Contains
(
x
)).
Count
())
{
goods_DistributionCommissionRepository
.
DeleteBatch
(
dclist
);
foreach
(
var
item
in
demodel
.
DistributionCommissionList
)
{
goods_DistributionCommissionRepository
.
Insert
(
new
RB_Goods_DistributionCommission
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
demodel
.
Id
,
Id
=
0
,
DistributorGrade
=
item
.
DistributorGrade
,
OneCommission
=
item
.
OneCommission
,
ThreeCommission
=
item
.
ThreeCommission
,
TwoCommission
=
item
.
TwoCommission
,
MallBaseId
=
demodel
.
MallBaseId
,
SpecificationSort
=
item
.
SpecificationSort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
demodel
.
UpdateDate
});
}
}
else
{
foreach
(
var
item
in
dclist
)
{
var
pupmodel
=
demodel
.
DistributionCommissionList
.
Where
(
x
=>
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
DistributorGrade
==
item
.
DistributorGrade
).
FirstOrDefault
();
if
(
item
.
OneCommission
!=
pupmodel
.
OneCommission
||
item
.
TwoCommission
!=
pupmodel
.
TwoCommission
||
item
.
ThreeCommission
!=
pupmodel
.
ThreeCommission
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_DistributionCommission
.
OneCommission
),
pupmodel
.
OneCommission
},
{
nameof
(
RB_Goods_DistributionCommission
.
TwoCommission
),
pupmodel
.
TwoCommission
},
{
nameof
(
RB_Goods_DistributionCommission
.
ThreeCommission
),
pupmodel
.
ThreeCommission
}
};
goods_DistributionCommissionRepository
.
Update
(
keyValues1
,
new
WhereHelper
(
nameof
(
RB_Goods_DistributionCommission
.
Id
),
item
.
Id
));
}
}
}
}
#
endregion
#
region
修改会员价格
if
(
demodel
.
EnjoyMember
==
1
&&
demodel
.
SeparateSetMember
==
1
)
{
var
mplist
=
goods_MemberPriceRepository
.
GetList
(
new
RB_Goods_MemberPrice_Extend
()
{
GoodsId
=
demodel
.
Id
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
mplist
.
Count
()
!=
demodel
.
MemberPriceList
.
Count
()
||
mplist
.
Count
()
!=
demodel
.
MemberPriceList
.
Where
(
x
=>
mplist
.
Select
(
y
=>
y
.
SpecificationSort
).
Contains
(
x
.
SpecificationSort
)).
Count
()
||
mplist
.
Select
(
x
=>
x
.
MemberGrade
).
Distinct
().
Count
()
!=
demodel
.
MemberPriceList
.
Select
(
x
=>
x
.
MemberGrade
).
Distinct
().
Count
()
||
mplist
.
Select
(
x
=>
x
.
MemberGrade
).
Distinct
().
Count
()
!=
mplist
.
Select
(
x
=>
x
.
MemberGrade
).
Distinct
().
Where
(
x
=>
demodel
.
MemberPriceList
.
Select
(
y
=>
y
.
MemberGrade
).
Distinct
().
Contains
(
x
)).
Count
())
{
goods_MemberPriceRepository
.
DeleteBatch
(
mplist
);
foreach
(
var
item
in
demodel
.
MemberPriceList
)
{
goods_MemberPriceRepository
.
Insert
(
new
RB_Goods_MemberPrice
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
demodel
.
Id
,
Id
=
0
,
MemberGrade
=
item
.
MemberGrade
,
MemberPrice
=
item
.
MemberPrice
,
MallBaseId
=
demodel
.
MallBaseId
,
SpecificationSort
=
item
.
SpecificationSort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
demodel
.
UpdateDate
});
}
}
else
{
foreach
(
var
item
in
mplist
)
{
var
pupmodel
=
demodel
.
MemberPriceList
.
Where
(
x
=>
x
.
SpecificationSort
==
item
.
SpecificationSort
&&
x
.
MemberGrade
==
item
.
MemberGrade
).
FirstOrDefault
();
if
(
item
.
MemberPrice
!=
pupmodel
.
MemberPrice
)
{
Dictionary
<
string
,
object
>
keyValues1
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods_MemberPrice
.
MemberPrice
),
pupmodel
.
MemberPrice
}
};
goods_MemberPriceRepository
.
Update
(
keyValues1
,
new
WhereHelper
(
nameof
(
RB_Goods_MemberPrice
.
Id
),
item
.
Id
));
}
}
}
}
#
endregion
}
}
else
{
int
Id
=
goodsRepository
.
Insert
(
demodel
);
flag
=
Id
>
0
;
if
(
flag
)
{
//插入可预定日期
if
(
demodel
.
TargetDateList
!=
null
&&
demodel
.
TargetDateList
.
Count
>
0
)
{
foreach
(
var
item
in
demodel
.
TargetDateList
)
{
goods_TargetDateRepository
.
Insert
(
new
RB_Goods_TargetDate
()
{
Id
=
0
,
GoodsId
=
Id
,
Date
=
item
.
Date
,
IsReserve
=
1
,
ReserveNum
=
0
});
}
}
//插入分类
if
(
demodel
.
CategoryList
!=
null
&&
demodel
.
CategoryList
.
Count
>
0
)
{
foreach
(
var
item
in
demodel
.
CategoryList
)
{
goods_CategoryRepository
.
Insert
(
new
RB_Goods_Category
()
{
CategoryId
=
item
.
CategoryId
,
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
MallBaseId
=
demodel
.
MallBaseId
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
});
}
}
//插入区域
if
(
demodel
.
AreaList
!=
null
&&
demodel
.
AreaList
.
Count
>
0
)
{
foreach
(
var
item
in
demodel
.
AreaList
)
{
goods_AreaRepository
.
Insert
(
new
RB_Goods_Area
()
{
AreaId
=
item
.
AreaId
,
AreaType
=
item
.
AreaType
,
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
MallBaseId
=
demodel
.
MallBaseId
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
});
}
}
//插入分销佣金
if
(
demodel
.
SeparateDistribution
==
1
)
{
if
(
demodel
.
DistributionCommissionList
!=
null
&&
demodel
.
DistributionCommissionList
.
Count
>
0
)
{
foreach
(
var
item
in
demodel
.
DistributionCommissionList
)
{
goods_DistributionCommissionRepository
.
Insert
(
new
RB_Goods_DistributionCommission
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
DistributorGrade
=
item
.
DistributorGrade
,
OneCommission
=
item
.
OneCommission
,
ThreeCommission
=
item
.
ThreeCommission
,
TwoCommission
=
item
.
TwoCommission
,
MallBaseId
=
demodel
.
MallBaseId
,
SpecificationSort
=
item
.
SpecificationSort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
demodel
.
UpdateDate
});
}
}
}
//插入会员价格
if
(
demodel
.
EnjoyMember
==
1
&&
demodel
.
SeparateSetMember
==
1
)
{
if
(
demodel
.
MemberPriceList
!=
null
&&
demodel
.
MemberPriceList
.
Count
>
0
)
{
foreach
(
var
item
in
demodel
.
MemberPriceList
)
{
goods_MemberPriceRepository
.
Insert
(
new
RB_Goods_MemberPrice
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
MemberGrade
=
item
.
MemberGrade
,
MemberPrice
=
item
.
MemberPrice
,
MallBaseId
=
demodel
.
MallBaseId
,
SpecificationSort
=
item
.
SpecificationSort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
demodel
.
UpdateDate
});
}
}
}
}
}
flag
=
true
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetProductGoodsInfoSD:"
+
Common
.
Plugin
.
JsonHelper
.
Serialize
(
demodel
));
}
return
flag
;
}
/// <summary>
/// 删除商品
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
bool
DelProcudtGoodsInfo
(
int
goodsId
,
int
tenantId
,
int
mallBaseId
)
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
Status
),
1
},
{
nameof
(
RB_Goods
.
UpdateDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(
nameof
(
RB_Goods
.
Id
),
goodsId
)
,
new
WhereHelper
(
nameof
(
RB_Goods
.
TenantId
),
tenantId
)
,
new
WhereHelper
(
nameof
(
RB_Goods
.
MallBaseId
),
mallBaseId
)
};
return
goodsRepository
.
Update
(
keyValues
,
wheres
);
}
/// <summary>
/// 设置商品上下架
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
bool
SetGoodsStatusInfo
(
int
goodsId
,
int
tenantId
,
int
mallBaseId
)
{
var
goodsModel
=
goodsRepository
.
GetEntity
(
goodsId
);
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
GoodsStatus
),(
goodsModel
?.
GoodsStatus
??
0
)==
1
?
2
:
1
},
{
nameof
(
RB_Goods
.
UpdateDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(
nameof
(
RB_Goods
.
Id
),
goodsId
),
new
WhereHelper
(
nameof
(
RB_Goods
.
TenantId
),
tenantId
),
new
WhereHelper
(
nameof
(
RB_Goods
.
MallBaseId
),
mallBaseId
)
};
return
goodsRepository
.
Update
(
keyValues
,
wheres
);
}
/// <summary>
/// 设置商品上下架
/// </summary>
/// <param name="goodsIds"></param>
/// <param name="Type"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
bool
SetGoodsBatchStatusInfo
(
string
goodsIds
,
int
Type
,
int
tenantId
,
int
mallBaseId
)
{
var
list
=
goodsRepository
.
GetSingleListForCommission
(
new
RB_Goods_Extend
()
{
GoodsIds
=
goodsIds
},
1
);
foreach
(
var
goodsModel
in
list
)
{
Dictionary
<
string
,
object
>
keyValues
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Goods
.
GoodsStatus
),
Type
},
{
nameof
(
RB_Goods
.
UpdateDate
),
DateTime
.
Now
}
};
List
<
WhereHelper
>
wheres
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(
nameof
(
RB_Goods
.
Id
),
goodsModel
.
Id
),
new
WhereHelper
(
nameof
(
RB_Goods
.
TenantId
),
tenantId
),
new
WhereHelper
(
nameof
(
RB_Goods
.
MallBaseId
),
mallBaseId
),
};
goodsRepository
.
Update
(
keyValues
,
wheres
);
}
return
true
;
}
#
endregion
#
region
添加订单评论返积分
/// <summary>
/// 订单评论返积分
/// </summary>
/// <param name="memberIntegralModel"></param>
/// <returns></returns>
public
bool
AddMemberIntegral
(
RB_Member_Integral
memberIntegralModel
)
{
if
(
memberIntegralModel
.
Id
==
0
)
{
bool
result
=
member_IntegralRepository
.
Insert
(
memberIntegralModel
)
>
0
;
if
(
result
&&
memberIntegralModel
.
UserId
>
0
)
//更新当前用户的积分
{
try
{
var
memberUserModel
=
member_UserRepository
.
GetEntity
(
memberIntegralModel
.
UserId
);
memberUserModel
.
Integral
+=
(
memberIntegralModel
.
Integral
??
0
);
//更新订单商品为已评价
Dictionary
<
string
,
object
>
keyValuesCar
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_Member_User
.
Integral
),
memberUserModel
.
Integral
}
};
List
<
WhereHelper
>
wheresCar
=
new
List
<
WhereHelper
>()
{
new
WhereHelper
(
nameof
(
RB_Member_User
.
Id
),
memberIntegralModel
.
UserId
)
};
member_UserRepository
.
Update
(
keyValuesCar
,
wheresCar
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"AddMemberIntegral"
);
}
}
return
result
;
}
return
false
;
}
#
endregion
}
}
\ No newline at end of file
Mall.Module.User/ContentModule.cs
View file @
4c56af02
...
...
@@ -275,6 +275,17 @@ namespace Mall.Module.User
public
bool
SetStoresModule
(
RB_Stores_Extend
extModel
)
{
bool
flag
;
if
(!
string
.
IsNullOrEmpty
(
extModel
.
LngLat
))
{
var
tempArray
=
extModel
.
LngLat
.
Split
(
","
);
if
(
tempArray
!=
null
&&
tempArray
.
Length
==
2
)
{
float
.
TryParse
(
tempArray
[
0
],
out
float
Lng
);
extModel
.
Lng
=
Lng
;
float
.
TryParse
(
tempArray
[
1
],
out
float
Lat
);
extModel
.
Lat
=
Lat
;
}
}
if
(
extModel
.
Id
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
...
...
@@ -291,6 +302,8 @@ namespace Mall.Module.User
{
nameof
(
RB_Stores_Extend
.
EndTime
),
extModel
.
EndTime
},
{
nameof
(
RB_Stores_Extend
.
IsAllDay
),
extModel
.
IsAllDay
},
{
nameof
(
RB_Stores_Extend
.
ServiceProject
),
extModel
.
ServiceProject
},
{
nameof
(
RB_Stores_Extend
.
Lng
),
extModel
.
Lng
},
{
nameof
(
RB_Stores_Extend
.
Lat
),
extModel
.
Lat
},
};
flag
=
storesRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Stores_Extend
.
Id
),
extModel
.
Id
));
}
...
...
Mall.Repository/User/RB_StoresRepository.cs
View file @
4c56af02
...
...
@@ -23,7 +23,25 @@ namespace Mall.Repository.User
public
List
<
RB_Stores_Extend
>
GetStoresPageListRepository
(
int
pageIndex
,
int
pageSize
,
out
long
rowCount
,
RB_Stores_Extend
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@" SELECT * FROM RB_Stores WHERE 1=1 AND Status=0 "
);
float
lng
=
0
;
float
lat
=
0
;
if
(!
string
.
IsNullOrEmpty
(
query
.
CurrentPosition
))
{
var
tempArray
=
query
.
CurrentPosition
.
Split
(
','
);
if
(
tempArray
!=
null
&&
tempArray
.
Length
==
2
)
{
float
.
TryParse
(
tempArray
[
0
],
out
lng
);
float
.
TryParse
(
tempArray
[
1
],
out
lat
);
}
}
builder
.
AppendFormat
(
@" SELECT * "
);
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
@",lat_lng_distance(Lng,Lat,{0},{1}) AS KM "
,
lng
,
lat
);
}
builder
.
AppendFormat
(
@"
FROM RB_Stores
WHERE 1 = 1 AND Status = 0 "
);
if
(
query
.
TenantId
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Stores_Extend
.
TenantId
),
query
.
TenantId
);
...
...
@@ -40,7 +58,42 @@ namespace Mall.Repository.User
{
builder
.
AppendFormat
(
" AND {0} LIKE '%{1}%' "
,
nameof
(
RB_Stores_Extend
.
Name
),
query
.
Name
.
Trim
());
}
builder
.
Append
(
" ORDER BY Id DESC "
);
if
(
query
.
OrderByType
==
1
)
{
builder
.
Append
(
" ORDER BY Name ASC "
);
}
else
if
(
query
.
OrderByType
==
2
)
{
builder
.
Append
(
" ORDER BY Name DESC "
);
}
else
if
(
query
.
OrderByType
==
3
)
{
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
" ORDER BY lat_lng_distance(Lng,Lat,{0},{1}) ASC "
,
lng
,
lat
);
}
}
else
if
(
query
.
OrderByType
==
4
)
{
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
" ORDER BY lat_lng_distance(Lng,Lat,{0},{1}) DESC "
,
lng
,
lat
);
}
}
else
if
(
query
.
OrderByType
==
5
)
{
builder
.
Append
(
" ORDER BY Score ASC "
);
}
else
if
(
query
.
OrderByType
==
6
)
{
builder
.
Append
(
" ORDER BY Score DESC "
);
}
else
{
builder
.
Append
(
" ORDER BY Id DESC "
);
}
return
GetPage
<
RB_Stores_Extend
>(
pageIndex
,
pageSize
,
out
rowCount
,
builder
.
ToString
()).
ToList
();
}
...
...
@@ -52,7 +105,26 @@ namespace Mall.Repository.User
public
List
<
RB_Stores_Extend
>
GetStoresListRepository
(
RB_Stores_Extend
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@" SELECT * FROM RB_Stores WHERE 1=1 AND Status=0 "
);
float
lng
=
0
;
float
lat
=
0
;
if
(!
string
.
IsNullOrEmpty
(
query
.
CurrentPosition
))
{
var
tempArray
=
query
.
CurrentPosition
.
Split
(
','
);
if
(
tempArray
!=
null
&&
tempArray
.
Length
==
2
)
{
float
.
TryParse
(
tempArray
[
0
],
out
lng
);
float
.
TryParse
(
tempArray
[
1
],
out
lat
);
}
}
builder
.
AppendFormat
(
@" SELECT * "
);
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
@",lat_lng_distance(Lng,Lat,{0},{1}) AS KM "
,
lng
,
lat
);
}
builder
.
AppendFormat
(
@"
FROM RB_Stores
WHERE 1 = 1 AND Status = 0 "
);
if
(
query
.
TenantId
>
0
)
{
builder
.
AppendFormat
(
" AND {0}={1} "
,
nameof
(
RB_Stores_Extend
.
TenantId
),
query
.
TenantId
);
...
...
@@ -69,7 +141,41 @@ namespace Mall.Repository.User
{
builder
.
AppendFormat
(
" AND {0} LIKE '%{1}%' "
,
nameof
(
RB_Stores_Extend
.
Name
),
query
.
Name
.
Trim
());
}
builder
.
Append
(
" ORDER BY Id DESC "
);
if
(
query
.
OrderByType
==
1
)
{
builder
.
Append
(
" ORDER BY Name ASC "
);
}
else
if
(
query
.
OrderByType
==
2
)
{
builder
.
Append
(
" ORDER BY Name DESC "
);
}
else
if
(
query
.
OrderByType
==
3
)
{
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
" ORDER BY lat_lng_distance(Lng,Lat,{0},{1}) ASC "
,
lng
,
lat
);
}
}
else
if
(
query
.
OrderByType
==
4
)
{
if
(
lng
>
0
&&
lat
>
0
)
{
builder
.
AppendFormat
(
" ORDER BY lat_lng_distance(Lng,Lat,{0},{1}) DESC "
,
lng
,
lat
);
}
}
else
if
(
query
.
OrderByType
==
5
)
{
builder
.
Append
(
" ORDER BY Score ASC "
);
}
else
if
(
query
.
OrderByType
==
6
)
{
builder
.
Append
(
" ORDER BY Score DESC "
);
}
else
{
builder
.
Append
(
" ORDER BY Id DESC "
);
}
return
Get
<
RB_Stores_Extend
>(
builder
.
ToString
()).
ToList
();
}
}
...
...
Mall.WebApi/Controllers/Reserve/OSGoodsController.cs
0 → 100644
View file @
4c56af02
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Mall.AOP
;
using
Mall.Common.API
;
using
Mall.Common.Enum.Goods
;
using
Mall.Common.Plugin
;
using
Mall.Model.Extend.Product
;
using
Mall.Module.Product
;
using
Mall.WebApi.Filter
;
using
Microsoft.AspNetCore.Cors
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
Mall.WebApi.Controllers.Reserve
{
/// <summary>
/// 线下服务商品控制器
/// </summary>
[
Route
(
"api/[controller]/[action]"
)]
[
ApiExceptionFilter
]
[
ApiController
]
[
EnableCors
(
"AllowCors"
)]
public
class
OSGoodsController
:
BaseController
{
/// <summary>
/// 线下服务商品处理类对象
/// </summary>
private
readonly
OfflineGoodsModule
offlineGoodsModule
=
AOPHelper
.
CreateAOPObject
<
OfflineGoodsModule
>();
/// <summary>
/// 商品后台分页列表
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetOfflineGoodsPageList
()
{
var
parms
=
RequestParm
;
ResultPageModel
pagelist
=
JsonConvert
.
DeserializeObject
<
ResultPageModel
>(
parms
.
msg
.
ToString
());
JObject
parameters
=
JObject
.
Parse
(
RequestParm
.
msg
.
ToString
());
RB_Goods_Extend
demodel
=
new
RB_Goods_Extend
()
{
Name
=
parameters
.
GetStringValue
(
"Name"
),
GoodsStatus
=
parameters
.
GetInt
(
"GoodsStatus"
),
CategoryIds
=
parameters
.
GetStringValue
(
"CategoryIds"
),
Id
=
parameters
.
GetInt
(
"Id"
),
StartTime
=
parameters
.
GetStringValue
(
"StartTime"
),
EndTime
=
parameters
.
GetStringValue
(
"EndTime"
),
OrderBy
=
parameters
.
GetInt
(
"OrderBy"
)
};
demodel
.
TenantId
=
parms
.
TenantId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
offlineGoodsModule
.
GetOfflineProductGoodsPageList
(
pagelist
.
pageIndex
,
pagelist
.
pageSize
,
out
long
count
,
demodel
);
pagelist
.
count
=
Convert
.
ToInt32
(
count
);
pagelist
.
pageData
=
list
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
Name
,
x
.
Sort
,
x
.
CoverImage
,
CategoryList
=
x
.
CategoryList
.
Select
(
y
=>
new
{
y
.
Id
,
y
.
CategoryName
}),
x
.
SellingPrice
,
x
.
GoodsBuyNum
,
x
.
GoodsStatus
,
x
.
TenantId
,
x
.
MallBaseId
,
CreateDate
=
x
.
CreateDate
.
HasValue
?
x
.
CreateDate
.
Value
.
ToString
(
"yyyy-MM-dd HH:mm:ss"
)
:
""
});
return
ApiResult
.
Success
(
""
,
pagelist
);
}
/// <summary>
/// 商品导出
/// </summary>
[
HttpPost
]
public
FileContentResult
GetProductGoodsListToExcel
()
{
var
parms
=
RequestParm
;
RB_Goods_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Goods_Extend
>(
parms
.
msg
.
ToString
());
string
ExcelName
=
"司导商品列表"
+
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmss"
)
+
".xls"
;
List
<
ExcelDataSource
>
slist
=
new
List
<
ExcelDataSource
>();
ExcelDataSource
header
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
"序号"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"商品名称"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"原价"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"成本价"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"商品详情"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"商品缩略图"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"商品轮播图"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"商品视频"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"售价"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"赠送积分"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"赠送积分类型"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"可抵扣积分"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"可抵扣积分类型"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"允许多件累计折扣"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"自定义分享图片"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"自定义分享标题"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"排序"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"是否单独区域购买"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"区域限购详情"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"站点"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"导游"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"车辆"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"车辆颜色"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"车牌号"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"是否拼座"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"乘坐人数"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
},
new
ExcelColumn
(
value
:
"提前预定时间"
)
{
CellWidth
=
15
,
HAlignmentEnum
=
HAlignmentEnum
.
CENTER
,
VAlignmentEnum
=
VAlignmentEnum
.
CENTER
}
}
};
slist
.
Add
(
header
);
try
{
demodel
.
TenantId
=
parms
.
TenantId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
offlineGoodsModule
.
GetProductGoodsPageListToExcel
(
1
,
10000
,
out
long
count
,
demodel
);
#
region
组装数据
int
Num
=
0
;
foreach
(
var
item
in
list
)
{
Num
++;
string
AreaList
=
""
;
if
(
item
.
IsAreaBuy
==
1
)
{
AreaList
=
JsonConvert
.
SerializeObject
(
item
.
AreaList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
GoodsId
,
x
.
AreaId
,
x
.
AreaName
,
x
.
AreaType
}));
}
ExcelDataSource
datarow
=
new
ExcelDataSource
()
{
ExcelRows
=
new
List
<
ExcelColumn
>(
30
)
{
new
ExcelColumn
(
value
:
Num
.
ToString
()){
},
new
ExcelColumn
(
value
:
item
.
Name
){
},
new
ExcelColumn
(
value
:(
item
.
OriginalPrice
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
CostPrice
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:
item
.
GoodsDetails
){
},
new
ExcelColumn
(
value
:
item
.
CoverImage
){
},
new
ExcelColumn
(
value
:
item
.
CarouselImage
){
},
new
ExcelColumn
(
value
:
item
.
VideoAddress
){
},
new
ExcelColumn
(
value
:(
item
.
SellingPrice
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IntegralPresent
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IntegralPresentType
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
PointsDeduction
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
PointsDeductionType
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsMultipleDeduction
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:
item
.
CustomShareImage
??
""
){
},
new
ExcelColumn
(
value
:
item
.
CustomShareTitles
??
""
){
},
new
ExcelColumn
(
value
:(
item
.
Sort
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsAreaBuy
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:
AreaList
.
ToString
()){
},
new
ExcelColumn
(
value
:
item
.
SiteName
){
},
new
ExcelColumn
(
value
:
item
.
GuideName
){
},
new
ExcelColumn
(
value
:
item
.
CarName
){
},
new
ExcelColumn
(
value
:
item
.
CarColorName
){
},
new
ExcelColumn
(
value
:
item
.
CarNumber
){
},
new
ExcelColumn
(
value
:
item
.
IsSpell
==
1
?
"是"
:
"否"
){
},
new
ExcelColumn
(
value
:(
item
.
RideNum
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
AdvanceDay
??
0
).
ToString
()+
"天"
){
},
}
,
ColumnHight
=
30
};
slist
.
Add
(
datarow
);
}
#
endregion
var
byteData
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData
,
"application/octet-stream"
,
ExcelName
);
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
string
.
Format
(
"GetFileFromWebApi_requestData: {0}"
,
JsonHelper
.
Serialize
(
RequestParm
)));
var
byteData1
=
ExcelTempLateHelper
.
ToExcelExtend
(
slist
);
return
File
(
byteData1
,
"application/octet-stream"
,
ExcelName
);
}
}
/// <summary>
/// 获取商品详情
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
GetGoodsInfo
()
{
var
req
=
RequestParm
;
JObject
prams
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GoodsId
=
prams
.
GetInt
(
"GoodsId"
,
0
);
if
(
GoodsId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
var
model
=
offlineGoodsModule
.
GetProductGoodsInfo
(
GoodsId
,
req
.
TenantId
,
req
.
MallBaseId
);
return
ApiResult
.
Success
(
""
,
new
{
model
?.
Id
,
model
?.
Name
,
model
?.
CarouselImageList
,
model
?.
VideoAddress
,
model
?.
CustomShareTitles
,
model
?.
CustomShareImage
,
model
?.
GoodsStatus
,
model
?.
Sort
,
model
?.
SellingPrice
,
model
?.
OriginalPrice
,
model
?.
CostPrice
,
model
?.
IsAreaBuy
,
model
?.
IntegralPresent
,
model
?.
IntegralPresentType
,
model
?.
PointsDeduction
,
model
?.
PointsDeductionType
,
model
?.
IsMultipleDeduction
,
model
?.
GoodsDetails
,
model
?.
SeparateDistribution
,
model
?.
SeparateDistributionType
,
model
?.
SeparateDistributionMoneyType
,
model
?.
EnjoyMember
,
model
?.
SeparateSetMember
,
model
?.
SupplierId
,
model
?.
Commission
,
model
?.
IsLiveGoods
,
CategoryList
=
model
?.
CategoryList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
CategoryId
,
x
.
CategoryName
}),
AreaList
=
model
?.
AreaList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
AreaId
,
x
.
AreaName
,
x
.
AreaType
}),
DistributionCommissionList
=
model
?.
DistributionCommissionList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
DistributorGrade
,
x
.
OneCommission
,
x
.
SpecificationSort
,
x
.
ThreeCommission
,
x
.
TwoCommission
}),
DistributionCommissionTreeList
=
model
?.
DistributionCommissionTreeList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
SpecificationSort
,
x
.
AttrList
,
GradeCommissionList
=
x
.
GradeCommissionList
.
Select
(
y
=>
new
{
y
.
DistributorGrade
,
y
.
OneCommission
,
y
.
ThreeCommission
,
y
.
TwoCommission
})
}),
MemberPriceList
=
model
?.
MemberPriceList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
MemberGrade
,
x
.
MemberPrice
,
x
.
SpecificationSort
}),
MemberPriceTreeList
=
model
?.
MemberPriceTreeList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
SpecificationSort
,
x
.
AttrList
,
GradePriceList
=
x
.
GradePriceList
.
Select
(
y
=>
new
{
y
.
MemberGrade
,
y
.
MemberPrice
})
}),
model
?.
Advertising
,
model
?.
SubName
,
model
?.
MarketingLogo
,
model
?.
SiteId
,
model
?.
GuideId
,
model
?.
CarId
,
model
?.
CarColorId
,
model
?.
CarNumber
,
model
?.
CarBuyYear
,
model
?.
CarType
,
CarTypeName
=
model
?.
CarType
.
GetEnumName
(),
model
?.
UseDay
,
model
?.
LineName
,
model
?.
LineDescriptionList
,
model
?.
IsSpell
,
model
?.
RideNum
,
model
?.
AdvanceDay
,
model
?.
TargetDateList
,
model
?.
IntegralComment
,
model
?.
IntegralCommentType
,
model
?.
GoodsPageType
,
GoodsPageTypeName
=
model
?.
GoodsPageType
.
GetEnumName
()
??
""
,
DepositMoney
=
model
?.
DepositMoney
??
0
,
model
?.
IsChooseServicePerson
,
model
?.
StoresIds
,
StoresList
=
model
?.
StoresList
??
new
List
<
int
>
(),
model
?.
ShelvesDate
,
model
?.
DownDate
,
model
?.
Unit
,
model
?.
SalesNum
,
model
?.
Remark
,
model
?.
VideoType
,
model
?.
LimitBuyGoodsNum
,
});
}
/// <summary>
/// 新增修改商品信息
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetGoodsInfo
()
{
var
parms
=
RequestParm
;
RB_Goods_Extend
demodel
=
JsonConvert
.
DeserializeObject
<
RB_Goods_Extend
>(
parms
.
msg
.
ToString
());
demodel
.
TenantId
=
parms
.
TenantId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
if
(
string
.
IsNullOrEmpty
(
demodel
.
Name
))
{
return
ApiResult
.
ParamIsNull
(
"请输入商品名称"
);
}
if
(
demodel
.
CarouselImageList
==
null
||
!
demodel
.
CarouselImageList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请添加商品轮播图"
);
}
demodel
.
CarouselImage
=
JsonConvert
.
SerializeObject
(
demodel
.
CarouselImageList
.
Select
(
x
=>
x
.
Path
));
if
((
demodel
.
SellingPrice
??
0
)
<
0
)
{
return
ApiResult
.
ParamIsNull
(
"请输入售价"
);
}
if
((
demodel
.
OriginalPrice
??
0
)
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请输入原价"
);
}
demodel
.
IsSpell
??=
1
;
demodel
.
AdvanceDay
??=
0
;
demodel
.
IsCustomSpecification
??=
2
;
demodel
.
DefaultSpecificationName
=
"默认"
;
demodel
.
InventoryNum
??=
0
;
List
<
Model
.
Extend
.
User
.
RB_Distributor_Grade_Extend
>
DGradeList
=
null
;
List
<
Model
.
Extend
.
User
.
RB_Member_Grade_Extend
>
MGradeList
=
null
;
demodel
.
VideoAddress
??=
""
;
demodel
.
CustomShareTitles
??=
""
;
demodel
.
CustomShareImage
??=
""
;
demodel
.
GoodsStatus
??=
2
;
demodel
.
Sort
??=
0
;
demodel
.
CostPrice
??=
0
;
demodel
.
IsGoodsNegotiable
??=
2
;
demodel
.
SalesNum
??=
0
;
demodel
.
GoodsNumbers
??=
""
;
demodel
.
GoodsWeight
??=
0
;
demodel
.
IsDefaultService
??=
1
;
if
(
demodel
.
IsDefaultService
==
2
)
{
if
(
demodel
.
ServiceList
==
null
||
!
demodel
.
ServiceList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请选择商品服务"
);
}
demodel
.
GoodsService
=
JsonConvert
.
SerializeObject
(
demodel
.
ServiceList
.
Select
(
x
=>
x
.
Id
));
}
else
{
demodel
.
GoodsService
=
"[]"
;
}
demodel
.
FreightId
??=
0
;
demodel
.
FormsId
??=
0
;
demodel
.
LimitBuyGoodsNum
??=
-
1
;
demodel
.
LimitBuyOrderNum
??=
-
1
;
demodel
.
FullNumPinkage
??=
0
;
demodel
.
FullMoneyPinkage
??=
0
;
demodel
.
IsAreaBuy
??=
2
;
if
(
demodel
.
IsAreaBuy
==
1
)
{
if
(
demodel
.
AreaList
==
null
||
!
demodel
.
AreaList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请选择区域"
);
}
}
demodel
.
IntegralPresent
??=
0
;
demodel
.
IntegralPresentType
??=
1
;
demodel
.
PointsDeduction
??=
0
;
demodel
.
PointsDeductionType
??=
1
;
demodel
.
IsMultipleDeduction
??=
2
;
demodel
.
Status
=
0
;
demodel
.
CreateDate
=
DateTime
.
Now
;
demodel
.
UpdateDate
=
DateTime
.
Now
;
demodel
.
SeparateDistribution
??=
2
;
demodel
.
SeparateDistributionType
??=
1
;
if
(
demodel
.
SeparateDistribution
==
1
)
{
//获取所有分销商等级
if
(
DGradeList
==
null
)
{
DGradeList
=
offlineGoodsModule
.
GetDistributorGradeList
(
new
Model
.
Extend
.
User
.
RB_Distributor_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
DGradeList
.
Add
(
new
Model
.
Extend
.
User
.
RB_Distributor_Grade_Extend
()
{
Grade
=
0
,
Name
=
"默认等级"
,
Id
=
0
});
}
if
(
demodel
.
SeparateDistributionType
==
1
)
{
if
(
demodel
.
DistributionCommissionList
==
null
||
!
demodel
.
DistributionCommissionList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递分销佣金列表"
);
}
//转换
List
<
RB_Goods_DistributionCommission_Extend
>
Rlist
=
new
List
<
RB_Goods_DistributionCommission_Extend
>();
foreach
(
var
item
in
demodel
.
DistributionCommissionList
)
{
if
(
item
.
GradeCommissionList
==
null
||
!
item
.
GradeCommissionList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递分销佣金列表"
);
}
foreach
(
var
qitem
in
item
.
GradeCommissionList
)
{
Rlist
.
Add
(
new
RB_Goods_DistributionCommission_Extend
()
{
DistributorGrade
=
qitem
.
DistributorGrade
,
Id
=
0
,
SpecificationSort
=
item
.
SpecificationSort
,
OneCommission
=
qitem
.
OneCommission
,
TwoCommission
=
qitem
.
TwoCommission
,
ThreeCommission
=
qitem
.
ThreeCommission
});
}
}
if
(
Rlist
.
Any
())
{
demodel
.
DistributionCommissionList
=
Rlist
;
}
//普通设置 直接根据等级验证数量
if
(
DGradeList
.
Count
()
!=
demodel
.
DistributionCommissionList
.
Count
())
{
return
ApiResult
.
ParamIsNull
(
"分销佣金列表数量不正确"
);
}
foreach
(
var
item
in
DGradeList
)
{
var
defaultModel
=
demodel
.
DistributionCommissionList
.
Where
(
x
=>
x
.
DistributorGrade
==
item
.
Id
).
FirstOrDefault
();
if
(
defaultModel
==
null
)
{
return
ApiResult
.
ParamIsNull
(
"分销佣金"
+
item
.
Name
+
"不存在"
);
}
defaultModel
.
OneCommission
??=
0
;
defaultModel
.
TwoCommission
??=
0
;
defaultModel
.
ThreeCommission
??=
0
;
defaultModel
.
SpecificationSort
=
""
;
}
}
else
{
if
(
demodel
.
IsCustomSpecification
!=
1
)
{
return
ApiResult
.
ParamIsNull
(
"无法开启详细设置"
);
}
}
}
demodel
.
SeparateDistributionMoneyType
??=
1
;
demodel
.
EnjoyMember
??=
2
;
demodel
.
SeparateSetMember
??=
2
;
if
(
demodel
.
EnjoyMember
==
1
&&
demodel
.
SeparateSetMember
==
1
)
{
//获取所有会员等级
if
(
MGradeList
==
null
)
{
MGradeList
=
offlineGoodsModule
.
GetMemberGradeList
(
new
Model
.
Extend
.
User
.
RB_Member_Grade_Extend
()
{
Enabled
=
1
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
if
(!
MGradeList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"单独设置会员价需先添加会员等级"
);
}
if
(
demodel
.
IsCustomSpecification
==
2
)
{
if
(
demodel
.
MemberPriceList
==
null
||
!
demodel
.
MemberPriceList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递会员价格列表"
);
}
//转换
List
<
RB_Goods_MemberPrice_Extend
>
Rlist
=
new
List
<
RB_Goods_MemberPrice_Extend
>();
foreach
(
var
item
in
demodel
.
MemberPriceList
)
{
if
(
item
.
GradePriceList
==
null
||
!
item
.
GradePriceList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请传递会员价格列表"
);
}
foreach
(
var
qitem
in
item
.
GradePriceList
)
{
Rlist
.
Add
(
new
RB_Goods_MemberPrice_Extend
()
{
MemberGrade
=
qitem
.
MemberGrade
,
Id
=
0
,
SpecificationSort
=
item
.
SpecificationSort
,
MemberPrice
=
qitem
.
MemberPrice
});
}
}
if
(
Rlist
.
Any
())
{
demodel
.
MemberPriceList
=
Rlist
;
}
if
(
MGradeList
.
Count
()
!=
demodel
.
MemberPriceList
.
Count
())
{
return
ApiResult
.
ParamIsNull
(
"会员价格列表数量不正确"
);
}
foreach
(
var
item
in
MGradeList
)
{
var
defaultModel
=
demodel
.
MemberPriceList
.
Where
(
x
=>
x
.
MemberGrade
==
item
.
Id
).
FirstOrDefault
();
if
(
defaultModel
==
null
)
{
return
ApiResult
.
ParamIsNull
(
"会员价格"
+
item
.
Name
+
"不存在"
);
}
defaultModel
.
MemberPrice
??=
0
;
defaultModel
.
SpecificationSort
=
""
;
}
}
}
demodel
.
IsQuickBuy
??=
2
;
demodel
.
IsSellWell
??=
2
;
demodel
.
GoodsType
??=
Common
.
Enum
.
Goods
.
OrderTypeEnum
.
SDGoods
;
demodel
.
GoodsStatus
??=
2
;
demodel
.
IsProxy
??=
2
;
demodel
.
ProxyType
??=
1
;
demodel
.
ProxyRises
??=
0
;
demodel
.
ProxyMoney
??=
0
;
demodel
.
IsProcurement
=
2
;
//新增时
demodel
.
PresentFXGrade
??=
0
;
//赠送粉象等级
demodel
.
PresentFXMonth
??=
0
;
demodel
.
Advertising
??=
""
;
//广告词
demodel
.
SubName
??=
""
;
//副标题
demodel
.
IsLiveGoods
??=
2
;
//是否直播商品 1是 2否
demodel
.
SendArea
??=
""
;
//发货地
demodel
.
GoodsClassify
=
1
;
demodel
.
IntegralComment
??=
0
;
//评论反积分
demodel
.
IntegralCommentType
??=
1
;
demodel
.
GoodsPageType
??=
GoodsPageTypeEnum
.
All
;
bool
flag
=
offlineGoodsModule
.
SetProductGoodsInfo
(
demodel
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 删除商品
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
DelGoodsInfo
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GoodsId
=
parms
.
GetInt
(
"GoodsId"
,
0
);
if
(
GoodsId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
bool
flag
=
offlineGoodsModule
.
DelProcudtGoodsInfo
(
GoodsId
,
req
.
TenantId
,
req
.
MallBaseId
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 上下架商品
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetGoodsStatusInfo
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
int
GoodsId
=
parms
.
GetInt
(
"GoodsId"
,
0
);
if
(
GoodsId
<=
0
)
{
return
ApiResult
.
ParamIsNull
();
}
bool
flag
=
offlineGoodsModule
.
SetGoodsStatusInfo
(
GoodsId
,
req
.
TenantId
,
req
.
MallBaseId
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
/// <summary>
/// 批量上下架商品
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetGoodsBatchStatusInfo
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
GoodsIds
=
parms
.
GetStringValue
(
"GoodsIds"
);
int
Type
=
parms
.
GetInt
(
"Type"
,
1
);
//类型 1上架 2下架
if
(
string
.
IsNullOrEmpty
(
GoodsIds
))
{
return
ApiResult
.
ParamIsNull
();
}
bool
flag
=
offlineGoodsModule
.
SetGoodsBatchStatusInfo
(
GoodsIds
,
Type
,
req
.
TenantId
,
req
.
MallBaseId
);
return
flag
?
ApiResult
.
Success
()
:
ApiResult
.
Failed
();
}
}
}
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