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
6f79776f
Commit
6f79776f
authored
May 27, 2020
by
liudong1993
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商品导入
parent
6a6ff417
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1203 additions
and
180 deletions
+1203
-180
Mall.Common.csproj
Mall.Common/Mall.Common.csproj
+3
-0
CSVHelper.cs
Mall.Common/Plugin/CSVHelper.cs
+76
-0
GoodsBetchDataHelper.cs
Mall.DataHelper/Import/GoodsBetchDataHelper.cs
+180
-0
RB_Goods.cs
Mall.Model/Entity/Product/RB_Goods.cs
+1
-1
RB_Goods_OrderDetail.cs
Mall.Model/Entity/Product/RB_Goods_OrderDetail.cs
+1
-1
RB_Goods_SpecificationValue.cs
Mall.Model/Entity/Product/RB_Goods_SpecificationValue.cs
+1
-1
RB_Destination_Extend.cs
Mall.Model/Extend/BaseSetUp/RB_Destination_Extend.cs
+5
-0
RB_Goods_Extend.cs
Mall.Model/Extend/Product/RB_Goods_Extend.cs
+12
-0
GoodsImport.cs
Mall.Model/Query/GoodsImport.cs
+130
-0
OrderModule.cs
Mall.Module.Product/OrderModule.cs
+26
-48
ProductModule.cs
Mall.Module.Product/ProductModule.cs
+607
-100
UserModule.cs
Mall.Module.User/UserModule.cs
+4
-23
RB_DestinationRepository.cs
Mall.Repository/BaseSetUp/RB_DestinationRepository.cs
+3
-0
ProductController.cs
Mall.WebApi/Controllers/Product/ProductController.cs
+154
-6
No files found.
Mall.Common/Mall.Common.csproj
View file @
6f79776f
...
...
@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LumenWorksX.Framework.IO" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.1" />
...
...
@@ -12,6 +13,8 @@
<PackageReference Include="NPOI" Version="2.4.1" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.1" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
</ItemGroup>
</Project>
Mall.Common/Plugin/CSVHelper.cs
0 → 100644
View file @
6f79776f
using
LumenWorks.Framework.IO.Csv
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
System.Text.Encodings
;
namespace
Mall.Common
{
public
class
CSVHelper
{
/// <summary>
/// 获取路径下的.csv文件
/// </summary>
/// <param name="FilePath"></param>
/// <returns></returns>
public
DataTable
GetStream
(
string
FilePath
)
{
FileStream
fileStream
=
new
FileStream
(
FilePath
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
Read
);
byte
[]
bytes
=
new
byte
[
fileStream
.
Length
];
fileStream
.
Read
(
bytes
,
0
,
bytes
.
Length
);
fileStream
.
Close
();
Stream
stream
=
new
MemoryStream
(
bytes
);
Encoding
.
RegisterProvider
(
CodePagesEncodingProvider
.
Instance
);
return
GetData
(
stream
,
Encoding
.
GetEncoding
(
"GB2312"
));
}
/// <summary>
/// 将.csv文件转换成DataTable
/// </summary>
/// <param name="stream"></param>
/// <returns></returns>
private
DataTable
GetData
(
Stream
stream
,
Encoding
enc
)
{
using
(
stream
)
{
using
(
StreamReader
input
=
new
StreamReader
(
stream
,
enc
))
{
using
(
CsvReader
csv
=
new
CsvReader
(
input
,
true
))
{
DataTable
dt
=
new
DataTable
();
//第一行字段数量
int
columnCount
=
csv
.
FieldCount
;
//标题数组
string
[]
headers
=
csv
.
GetFieldHeaders
();
//循环添加标题行
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
dt
.
Columns
.
Add
(
headers
[
i
]);
}
//循环添加列数据
while
(
csv
.
ReadNextRecord
())
{
DataRow
dr
=
dt
.
NewRow
();
for
(
int
i
=
0
;
i
<
columnCount
;
i
++)
{
if
(!
string
.
IsNullOrWhiteSpace
(
csv
[
i
]))
{
dr
[
i
]
=
csv
[
i
];
}
}
dt
.
Rows
.
Add
(
dr
);
}
return
dt
;
}
}
}
}
}
}
Mall.DataHelper/Import/GoodsBetchDataHelper.cs
0 → 100644
View file @
6f79776f
using
Mall.Common
;
using
Mall.Model.Extend.Product
;
using
System
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Linq
;
namespace
Mall.DataHelper
{
/// <summary>
/// 商品导入
/// </summary>
public
class
GoodsBetchDataHelper
{
/// <summary>
/// 导入模板
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public
static
List
<
RB_Goods_Extend
>
ImportClaimData
(
string
fileName
)
{
List
<
RB_Goods_Extend
>
list
=
new
List
<
RB_Goods_Extend
>();
var
dt
=
new
DataTable
();
if
(
fileName
.
Contains
(
".csv"
))
{
dt
=
new
CSVHelper
().
GetStream
(
fileName
);
}
else
{
dt
=
Mall
.
Common
.
Plugin
.
NPOIHelper
.
ImportExceltoDt
(
fileName
,
0
,
0
,
true
);
}
if
(
dt
!=
null
&&
dt
.
Rows
.
Count
>
0
)
{
foreach
(
DataRow
dr
in
dt
.
Rows
)
{
list
.
Add
(
DataRowToModel
(
dr
));
}
}
return
list
;
}
/// <summary>
/// DataRow转实体
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
public
static
RB_Goods_Extend
DataRowToModel
(
DataRow
dr
)
{
RB_Goods_Extend
model
=
new
RB_Goods_Extend
();
if
(
dr
!=
null
)
{
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品名称"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品名称"
].
ToString
().
Trim
()))
{
model
.
Name
=
dr
[
"商品名称"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"原价"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"原价"
].
ToString
().
Trim
()))
{
model
.
OriginalPrice
=
Convert
.
ToDecimal
(
dr
[
"原价"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"成本价"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"成本价"
].
ToString
().
Trim
()))
{
model
.
CostPrice
=
Convert
.
ToDecimal
(
dr
[
"成本价"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品详情"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品详情"
].
ToString
().
Trim
()))
{
model
.
GoodsDetails
=
dr
[
"商品详情"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品缩略图"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品缩略图"
].
ToString
().
Trim
()))
{
model
.
CoverImage
=
dr
[
"商品缩略图"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品轮播图"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品轮播图"
].
ToString
().
Trim
()))
{
model
.
CarouselImage
=
dr
[
"商品轮播图"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品视频"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品视频"
].
ToString
().
Trim
()))
{
model
.
VideoAddress
=
dr
[
"商品视频"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"单位"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"单位"
].
ToString
().
Trim
()))
{
model
.
Unit
=
dr
[
"单位"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"售价"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"售价"
].
ToString
().
Trim
()))
{
model
.
SellingPrice
=
Convert
.
ToDecimal
(
dr
[
"售价"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"是否使用规格"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"是否使用规格"
].
ToString
().
Trim
()))
{
model
.
IsCustomSpecification
=
Convert
.
ToInt32
(
dr
[
"是否使用规格"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"规格组"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"规格组"
].
ToString
().
Trim
()))
{
model
.
SpecificationImport
=
dr
[
"规格组"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"商品库存"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"商品库存"
].
ToString
().
Trim
()))
{
model
.
InventoryNum
=
Convert
.
ToInt32
(
dr
[
"商品库存"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"虚拟销量"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"虚拟销量"
].
ToString
().
Trim
()))
{
model
.
SalesNum
=
Convert
.
ToInt32
(
dr
[
"虚拟销量"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"购物数量限制"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"购物数量限制"
].
ToString
().
Trim
()))
{
model
.
LimitBuyGoodsNum
=
Convert
.
ToInt32
(
dr
[
"购物数量限制"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"单品满件包邮"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"单品满件包邮"
].
ToString
().
Trim
()))
{
model
.
FullNumPinkage
=
Convert
.
ToInt32
(
dr
[
"单品满件包邮"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"单品满额包邮"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"单品满额包邮"
].
ToString
().
Trim
()))
{
model
.
FullMoneyPinkage
=
Convert
.
ToDecimal
(
dr
[
"单品满额包邮"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"赠送积分"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"赠送积分"
].
ToString
().
Trim
()))
{
model
.
IntegralPresent
=
Convert
.
ToInt32
(
dr
[
"赠送积分"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"赠送积分类型"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"赠送积分类型"
].
ToString
().
Trim
()))
{
model
.
IntegralPresentType
=
Convert
.
ToInt32
(
dr
[
"赠送积分类型"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"可抵扣积分"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"可抵扣积分"
].
ToString
().
Trim
()))
{
model
.
PointsDeduction
=
Convert
.
ToDecimal
(
dr
[
"可抵扣积分"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"可抵扣积分类型"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"可抵扣积分类型"
].
ToString
().
Trim
()))
{
model
.
PointsDeductionType
=
Convert
.
ToInt32
(
dr
[
"可抵扣积分类型"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"允许多件累计折扣"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"允许多件累计折扣"
].
ToString
().
Trim
()))
{
model
.
IsMultipleDeduction
=
Convert
.
ToInt32
(
dr
[
"允许多件累计折扣"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"自定义分享图片"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"自定义分享图片"
].
ToString
().
Trim
()))
{
model
.
CustomShareImage
=
dr
[
"自定义分享图片"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"自定义分享标题"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"自定义分享标题"
].
ToString
().
Trim
()))
{
model
.
CustomShareTitles
=
dr
[
"自定义分享标题"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"排序"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"排序"
].
ToString
().
Trim
()))
{
model
.
Sort
=
Convert
.
ToInt32
(
dr
[
"排序"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"限购订单"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"限购订单"
].
ToString
().
Trim
()))
{
model
.
LimitBuyOrderNum
=
Convert
.
ToInt32
(
dr
[
"限购订单"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"是否单独区域购买"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"是否单独区域购买"
].
ToString
().
Trim
()))
{
model
.
IsAreaBuy
=
Convert
.
ToInt32
(
dr
[
"是否单独区域购买"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"区域限购详情"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"区域限购详情"
].
ToString
().
Trim
()))
{
model
.
AreaImport
=
dr
[
"区域限购详情"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"规格详情"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"规格详情"
].
ToString
().
Trim
()))
{
model
.
SpecificationPriceImport
=
dr
[
"规格详情"
].
ToString
();
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"是否快速购买"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"是否快速购买"
].
ToString
().
Trim
()))
{
model
.
IsQuickBuy
=
Convert
.
ToInt32
(
dr
[
"是否快速购买"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"是否热销"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"是否热销"
].
ToString
().
Trim
()))
{
model
.
IsSellWell
=
Convert
.
ToInt32
(
dr
[
"是否热销"
].
ToString
());
}
if
(
dr
.
Table
.
Columns
.
Contains
(
"是否面议"
)
&&
!
string
.
IsNullOrEmpty
(
dr
[
"是否面议"
].
ToString
().
Trim
()))
{
model
.
IsGoodsNegotiable
=
Convert
.
ToInt32
(
dr
[
"是否面议"
].
ToString
());
}
}
return
model
;
}
}
}
\ No newline at end of file
Mall.Model/Entity/Product/RB_Goods.cs
View file @
6f79776f
...
...
@@ -58,7 +58,7 @@ namespace Mall.Model.Entity.Product
/// <summary>
/// 自定义分享图片
/// </summary>
public
int
?
CustomShareImage
public
string
CustomShareImage
{
get
;
set
;
...
...
Mall.Model/Entity/Product/RB_Goods_OrderDetail.cs
View file @
6f79776f
...
...
@@ -58,7 +58,7 @@ namespace Mall.Model.Entity.Product
/// <summary>
/// 封面图
/// </summary>
public
int
?
CoverImage
public
string
CoverImage
{
get
;
set
;
...
...
Mall.Model/Entity/Product/RB_Goods_SpecificationValue.cs
View file @
6f79776f
...
...
@@ -49,7 +49,7 @@ namespace Mall.Model.Entity.Product
/// <summary>
/// 规格图片
/// </summary>
public
int
?
Image
public
string
Image
{
get
;
set
;
...
...
Mall.Model/Extend/BaseSetUp/RB_Destination_Extend.cs
View file @
6f79776f
...
...
@@ -75,5 +75,10 @@ namespace Mall.Model.Extend.BaseSetUp
/// ID查询字符串
/// </summary>
public
string
QIds
{
get
;
set
;
}
/// <summary>
/// 批量name查询
/// </summary>
public
string
NameStr
{
get
;
set
;
}
}
}
Mall.Model/Extend/Product/RB_Goods_Extend.cs
View file @
6f79776f
...
...
@@ -96,10 +96,18 @@ namespace Mall.Model.Extend.Product
/// </summary>
public
List
<
RB_Goods_Area_Extend
>
AreaList
{
get
;
set
;
}
/// <summary>
/// 区域购买导入
/// </summary>
public
string
AreaImport
{
get
;
set
;
}
/// <summary>
/// 规格名列表
/// </summary>
public
List
<
RB_Goods_Specification_Extend
>
SpecificationList
{
get
;
set
;
}
/// <summary>
/// 规格组导入
/// </summary>
public
string
SpecificationImport
{
get
;
set
;
}
/// <summary>
/// 规格值名称列表
/// </summary>
public
List
<
string
>
SpecificationNameList
{
get
;
set
;
}
...
...
@@ -108,6 +116,10 @@ namespace Mall.Model.Extend.Product
/// </summary>
public
List
<
RB_Goods_SpecificationPrice_Extend
>
SpecificationPriceList
{
get
;
set
;
}
/// <summary>
/// 规格价格详情导入
/// </summary>
public
string
SpecificationPriceImport
{
get
;
set
;
}
/// <summary>
/// 分销佣金列表
/// </summary>
public
List
<
RB_Goods_DistributionCommission_Extend
>
DistributionCommissionList
{
get
;
set
;
}
...
...
Mall.Model/Query/GoodsImport.cs
0 → 100644
View file @
6f79776f
using
Mall.Common.AOP
;
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Mall.Model.Query
{
/// <summary>
/// 赞羊商品轮播
/// </summary>
[
Serializable
]
public
class
GoodsCarouselImport
{
/// <summary>
/// id
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 图片地址
/// </summary>
public
string
pic_url
{
get
;
set
;
}
}
/// <summary>
/// 赞羊规格
/// </summary>
[
Serializable
]
public
class
GoodsSpecificationImport
{
/// <summary>
/// attr_group_id
/// </summary>
public
int
attr_group_id
{
get
;
set
;
}
/// <summary>
/// 规格名称
/// </summary>
public
string
attr_group_name
{
get
;
set
;
}
/// <summary>
/// 子集
/// </summary>
public
List
<
GoodsSpecificationValueImport
>
attr_list
{
get
;
set
;
}
}
/// <summary>
/// 赞羊规格值
/// </summary>
[
Serializable
]
public
class
GoodsSpecificationValueImport
{
/// <summary>
/// attr_id
/// </summary>
public
int
attr_id
{
get
;
set
;
}
/// <summary>
/// 图片地址
/// </summary>
public
string
attr_name
{
get
;
set
;
}
/// <summary>
/// 图片地址
/// </summary>
public
string
pic_url
{
get
;
set
;
}
}
/// <summary>
/// 赞羊规格价格
/// </summary>
[
Serializable
]
public
class
GoodsSpecificationPriceImport
{
/// <summary>
/// id
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 商品id
/// </summary>
public
int
goods_id
{
get
;
set
;
}
/// <summary>
/// key
/// </summary>
public
string
sign_id
{
get
;
set
;
}
/// <summary>
/// 库存
/// </summary>
public
int
stock
{
get
;
set
;
}
/// <summary>
/// 价格
/// </summary>
public
decimal
price
{
get
;
set
;
}
/// <summary>
/// 货号
/// </summary>
public
string
no
{
get
;
set
;
}
/// <summary>
/// 重量
/// </summary>
public
int
weight
{
get
;
set
;
}
/// <summary>
/// 图片地址
/// </summary>
public
string
pic_url
{
get
;
set
;
}
}
/// <summary>
/// 赞羊区域导入
/// </summary>
[
Serializable
]
public
class
GoodsAreaListImport
{
/// <summary>
/// 列表
/// </summary>
public
List
<
GoodsAreaImport
>
list
{
get
;
set
;
}
}
/// <summary>
/// 赞羊区域详情
/// </summary>
[
Serializable
]
public
class
GoodsAreaImport
{
/// <summary>
/// id
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 名称
/// </summary>
public
string
name
{
get
;
set
;
}
}
}
Mall.Module.Product/OrderModule.cs
View file @
6f79776f
...
...
@@ -416,15 +416,9 @@ namespace Mall.Module.Product
{
//查询订单明细
var
dlist
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
OrderId
))
});
//查询图片
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
foreach
(
var
item
in
dlist
)
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
}
item
.
CoverImagePath
=
item
.
CoverImage
;
}
string
areaIds1
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Province
??
0
).
Distinct
());
string
areaIds2
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
City
??
0
).
Distinct
());
...
...
@@ -495,16 +489,13 @@ namespace Mall.Module.Product
}
//查询订单明细
var
dlist
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
OrderId
=
orderId
});
//查询图片
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
string
orderDetailIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
Id
));
var
oasList
=
goods_OrderAfterSaleRepository
.
GetList
(
new
RB_Goods_OrderAfterSale_Extend
()
{
OrderDetailIds
=
orderDetailIds
,
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
});
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
item
.
IsApplyForAfterSale
=
2
;
if
(
oasList
.
Where
(
x
=>
x
.
OrderDetialId
==
item
.
Id
).
Any
())
{
item
.
IsApplyForAfterSale
=
1
;
...
...
@@ -573,14 +564,11 @@ namespace Mall.Module.Product
{
//查询订单明细
var
dlist
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
OrderId
=
orderId
});
//查询图片
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
//物流
...
...
@@ -626,7 +614,7 @@ namespace Mall.Module.Product
if
(
dModel
==
null
)
{
return
ApiResult
.
Failed
(
"未查询到订单商品信息"
);
}
dModel
.
CoverImagePath
=
material_InfoRepository
.
GetEntity
(
dModel
.
CoverImage
)?.
Path
??
""
;
dModel
.
CoverImagePath
=
dModel
.
CoverImage
;
return
ApiResult
.
Success
(
""
,
new
{
DetailId
=
dModel
.
Id
,
...
...
@@ -714,9 +702,9 @@ namespace Mall.Module.Product
gmodel
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
gmodel
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//封面图
gmodel
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
gmodel
.
CoverImage
=
CarouselIdList
[
0
]
;
}
int
GoodsWeight
=
gmodel
.
GoodsWeight
??
0
;
//商品重量
#
region
规格
...
...
@@ -1045,23 +1033,21 @@ namespace Mall.Module.Product
gmodel
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
gmodel
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//封面图
//gmodel.CoverImage = material_InfoRepository.GetEntity(CarouselIdList[0])?.Path ?? "";
//轮播图
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
string
.
Join
(
","
,
CarouselIdList
),
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
foreach
(
var
qitem
in
CarouselIdList
)
{
var
cmodel
=
mlist
.
Where
(
x
=>
x
.
Id
==
qitem
).
FirstOrDefault
();
{
gmodel
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
qitem
,
Name
=
cmodel
?.
Name
??
""
,
Path
=
cmodel
?.
Path
??
""
Id
=
0
,
Name
=
""
,
Path
=
qitem
});
}
//封面图
gmodel
.
CoverImage
=
mlist
.
Where
(
x
=>
x
.
Id
==
CarouselIdList
[
0
]).
FirstOrDefault
()?.
Path
??
""
;
gmodel
.
CoverImage
=
CarouselIdList
[
0
]
;
}
#
endregion
...
...
@@ -2050,10 +2036,10 @@ namespace Mall.Module.Product
}
item
.
OrderType
=
gmodel
.
GoodsType
;
item
.
GoodsName
=
gmodel
.
Name
;
item
.
CoverImage
=
0
;
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
gmodel
.
CarouselImage
)
&&
gmodel
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
gmodel
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
gmodel
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
}
...
...
@@ -2981,7 +2967,7 @@ namespace Mall.Module.Product
if
(
detailmodel
==
null
)
{
return
ApiResult
.
Failed
(
"订单不存在,请联系管理员"
);
}
string
ImagePath
=
material_InfoRepository
.
GetEntity
(
detailmodel
.
CoverImage
)?.
Path
??
""
;
string
ImagePath
=
detailmodel
.
CoverImage
;
return
ApiResult
.
Success
(
""
,
new
{
omodel
.
ReOrderId
,
...
...
@@ -3068,7 +3054,7 @@ namespace Mall.Module.Product
{
return
ApiResult
.
ParamIsNull
(
"订单明细不存在"
);
}
odModel
.
CoverImagePath
=
material_InfoRepository
.
GetEntity
(
odModel
.
CoverImage
)?.
Path
??
""
;
odModel
.
CoverImagePath
=
odModel
.
CoverImage
;
//物流信息
List
<
object
>
TExpressList
=
new
List
<
object
>();
...
...
@@ -3153,10 +3139,9 @@ namespace Mall.Module.Product
var
gdList
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailIds
=
orderDetilIds
});
if
(
gdList
.
Any
())
{
var
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
gdList
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
gdList
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
...
...
@@ -3248,10 +3233,9 @@ namespace Mall.Module.Product
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
item
.
IsBindExpress
=
erList
.
Where
(
x
=>
x
.
OrderDetailId
==
item
.
Id
).
Any
()
?
1
:
2
;
}
}
...
...
@@ -3301,10 +3285,9 @@ namespace Mall.Module.Product
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
string
areaIds1
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Province
??
0
).
Distinct
());
...
...
@@ -3375,10 +3358,9 @@ namespace Mall.Module.Product
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
...
...
@@ -3413,10 +3395,9 @@ namespace Mall.Module.Product
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
string
areaIds1
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Province
??
0
).
Distinct
());
...
...
@@ -3485,10 +3466,9 @@ namespace Mall.Module.Product
var
gdList
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
OrderDetailIds
=
orderDetilIds
});
if
(
gdList
.
Any
())
{
var
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
gdList
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
gdList
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
string
areaIds1
=
string
.
Join
(
","
,
gList
.
Select
(
x
=>
x
.
Province
??
0
).
Distinct
());
...
...
@@ -3572,7 +3552,7 @@ namespace Mall.Module.Product
if
(
odModel
==
null
)
{
return
ApiResult
.
ParamIsNull
(
"订单明细不存在"
);
}
odModel
.
CoverImagePath
=
material_InfoRepository
.
GetEntity
(
odModel
.
CoverImage
)?.
Path
??
""
;
odModel
.
CoverImagePath
=
odModel
.
CoverImage
;
var
slList
=
goods_OrderAfterSaleLogRepository
.
GetList
(
new
RB_Goods_OrderAfterSaleLog_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
ReOrderId
=
reOrderId
});
var
uModel
=
member_UserRepository
.
GetEntity
(
model
.
UserId
);
...
...
@@ -4510,10 +4490,9 @@ namespace Mall.Module.Product
dlist
=
goods_OrderDetailRepository
.
GetOrderDetailList
(
new
RB_Goods_OrderDetail_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
OrderDetailIds
=
string
.
Join
(
","
,
erlist
.
Select
(
x
=>
x
.
OrderDetailId
))
});
if
(
dlist
.
Any
())
{
var
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
}
}
orderModel
=
goods_OrderRepository
.
GetEntity
(
erlist
.
FirstOrDefault
()?.
OrderId
);
...
...
@@ -4562,10 +4541,9 @@ namespace Mall.Module.Product
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
dlist
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
tenantId
,
MallBaseId
=
mallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
dlist
.
Select
(
x
=>
x
.
CoverImage
))
});
foreach
(
var
item
in
dlist
)
{
item
.
CoverImagePath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
item
.
CoverImage
).
FirstOrDefault
()?.
Path
??
""
;
item
.
CoverImagePath
=
item
.
CoverImage
;
item
.
IsBindExpress
=
erList
.
Where
(
x
=>
x
.
OrderDetailId
==
item
.
Id
).
Any
()
?
1
:
2
;
}
}
...
...
Mall.Module.Product/ProductModule.cs
View file @
6f79776f
...
...
@@ -2,12 +2,14 @@
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
Mall.Common
;
using
Mall.Common.API
;
using
Mall.Common.Plugin
;
using
Mall.Model.Entity.Product
;
using
Mall.Model.Extend.Product
;
using
Mall.Model.Extend.User
;
using
Mall.Model.Query
;
using
Mall.Repository
;
using
Mall.Repository.BaseSetUp
;
using
Mall.Repository.Product
;
...
...
@@ -127,6 +129,10 @@ namespace Mall.Module.Product
/// 订单商品
/// </summary>
private
readonly
RB_Goods_OrderRepository
goods_OrderRepository
=
new
RB_Goods_OrderRepository
();
/// <summary>
/// 地区处理
/// </summary>
private
readonly
Rb_destinationRepository
destinationRepository
=
new
Rb_destinationRepository
();
...
...
@@ -160,9 +166,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
}
}
...
...
@@ -190,14 +196,9 @@ namespace Mall.Module.Product
if
(
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Any
()
)
foreach
(
var
item
in
svlist
)
{
string
imgIds
=
string
.
Join
(
","
,
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
).
Distinct
());
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
imgIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
foreach
(
var
item
in
svlist
.
Where
(
x
=>
x
.
Image
>
0
))
{
item
.
ImagePath
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
.
Image
).
FirstOrDefault
()?.
Path
??
""
;
}
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
SpecificationList
)
{
...
...
@@ -221,9 +222,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
item
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
...
...
@@ -336,9 +337,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
}
}
...
...
@@ -445,14 +446,9 @@ namespace Mall.Module.Product
if
(
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Any
()
)
foreach
(
var
item
in
svlist
)
{
string
imgIds
=
string
.
Join
(
","
,
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
).
Distinct
());
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
imgIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
foreach
(
var
item
in
svlist
.
Where
(
x
=>
x
.
Image
>
0
))
{
item
.
ImagePath
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
.
Image
).
FirstOrDefault
()?.
Path
??
""
;
}
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
SpecificationList
)
{
...
...
@@ -477,9 +473,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
item
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
...
...
@@ -531,14 +527,9 @@ namespace Mall.Module.Product
if
(
model
.
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
if
(
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Any
()
)
foreach
(
var
item
in
svlist
)
{
string
imgIds
=
string
.
Join
(
","
,
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
).
Distinct
());
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
imgIds
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
svlist
.
Where
(
x
=>
x
.
Image
>
0
))
{
item
.
ImagePath
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
.
Image
).
FirstOrDefault
()?.
Path
??
""
;
}
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
model
.
SpecificationList
)
{
...
...
@@ -570,24 +561,21 @@ namespace Mall.Module.Product
model
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
model
.
CarouselImage
)
&&
model
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
model
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
model
.
CarouselImage
);
//轮播图
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
string
.
Join
(
","
,
CarouselIdList
),
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
CarouselIdList
)
{
var
cmodel
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
).
FirstOrDefault
();
{
model
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
item
,
Name
=
cmodel
?.
Name
??
""
,
Path
=
cmodel
?.
Path
??
""
Id
=
0
,
Name
=
""
,
Path
=
item
});
}
}
if
(
model
.
CustomShareImage
>
0
)
{
model
.
CustomShareImagePath
=
material_InfoRepository
.
GetEntity
(
model
.
CustomShareImage
)?.
Path
??
""
;
}
model
.
CustomShareImagePath
=
model
.
CustomShareImage
;
//服务列表
model
.
ServiceList
=
new
List
<
RB_ImageCommonModel
>();
if
(
model
.
IsDefaultService
==
2
)
...
...
@@ -823,29 +811,10 @@ namespace Mall.Module.Product
var
list
=
goodsRepository
.
GetAppletGoodsPageList
(
pageIndex
,
pageSize
,
out
count
,
demodel
);
if
(
list
.
Any
())
{
List
<
int
>
MaterialIds
=
new
List
<
int
>();
foreach
(
var
item
in
list
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
MaterialIds
.
AddRange
(
CarouselIdList
);
}
}
List
<
RB_Material_Info_Extend
>
MaterialList
=
new
List
<
RB_Material_Info_Extend
>();
string
goodsIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
Id
));
var
categoryList
=
goods_CategoryRepository
.
GetList
(
new
RB_Goods_Category_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciList
=
goods_SpecificationRepository
.
GetList
(
new
RB_Goods_Specification_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
var
speciVList
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
speciVList
.
Any
())
{
MaterialIds
.
AddRange
(
speciVList
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
??
0
));
}
if
(
MaterialIds
.
Any
())
{
MaterialList
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
MaterialIds
)
});
}
var
speciPList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
List
<
RB_Goods_Order_Extend
>
orderlist
=
goods_OrderRepository
.
GetGoodsOrderNum
(
goodsIds
:
goodsIds
);
...
...
@@ -855,14 +824,14 @@ namespace Mall.Module.Product
item
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
MaterialList
.
Where
(
x
=>
x
.
Id
==
CarouselIdList
[
0
]).
FirstOrDefault
()?.
Path
??
""
;
item
.
CarouselImageList
=
MaterialList
.
Where
(
x
=>
x
.
Id
!=
CarouselIdList
[
0
])
.
Select
(
x
=>
new
RB_ImageCommonModel
()
item
.
CoverImage
=
CarouselIdList
[
0
]
;
item
.
CarouselImageList
=
CarouselIdList
.
Select
(
x
=>
new
RB_ImageCommonModel
()
{
Id
=
x
.
Id
,
Name
=
x
.
Name
,
Path
=
x
.
Path
Id
=
0
,
Name
=
""
,
Path
=
x
}).
ToList
();
}
...
...
@@ -878,14 +847,9 @@ namespace Mall.Module.Product
if
(
item
.
SpecificationList
.
Any
())
{
var
svlist
=
speciVList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
if
(
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Any
()
)
foreach
(
var
qitem
in
svlist
)
{
var
imgIds
=
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
??
0
).
Distinct
().
ToList
();
var
mlist
=
MaterialList
.
Where
(
x
=>
imgIds
.
Contains
(
x
.
Id
)).
ToList
();
foreach
(
var
qitem
in
svlist
.
Where
(
x
=>
x
.
Image
>
0
))
{
qitem
.
ImagePath
=
mlist
.
Where
(
x
=>
x
.
Id
==
qitem
.
Image
).
FirstOrDefault
()?.
Path
??
""
;
}
qitem
.
ImagePath
=
qitem
.
Image
;
}
foreach
(
var
qitem
in
item
.
SpecificationList
)
{
...
...
@@ -894,11 +858,7 @@ namespace Mall.Module.Product
}
item
.
SpecificationPriceList
=
speciPList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
}
if
(
item
.
CustomShareImage
>
0
)
{
item
.
CustomShareImagePath
=
material_InfoRepository
.
GetEntity
(
item
.
CustomShareImage
)?.
Path
??
""
;
}
item
.
CustomShareImagePath
=
item
.
CustomShareImage
;
#
endregion
item
.
SalesNum
+=
(
orderlist
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
FirstOrDefault
()?.
OrderNum
??
0
);
...
...
@@ -2035,9 +1995,9 @@ namespace Mall.Module.Product
//轮播图
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
}
foreach
(
var
item
in
glist
)
...
...
@@ -2237,9 +2197,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
//轮播图
}
}
...
...
@@ -2267,9 +2227,9 @@ namespace Mall.Module.Product
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
//轮播图
}
}
...
...
@@ -2277,6 +2237,70 @@ namespace Mall.Module.Product
return
list
;
}
/// <summary>
/// 获取后台商品列表(导出专用)
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
List
<
RB_Goods_Extend
>
GetProductGoodsListForExcel
(
RB_Goods_Extend
demodel
)
{
var
list
=
goodsRepository
.
GetList
(
demodel
);
if
(
list
.
Any
())
{
var
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
var
SpecificationPriceList
=
new
List
<
RB_Goods_SpecificationPrice_Extend
>();
if
(
list
.
Where
(
x
=>
x
.
IsCustomSpecification
==
1
).
Any
())
{
string
goodsIds
=
string
.
Join
(
","
,
list
.
Where
(
x
=>
x
.
IsCustomSpecification
==
1
).
Select
(
x
=>
x
.
Id
));
SpecificationList
=
goods_SpecificationRepository
.
GetList
(
new
RB_Goods_Specification_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
if
(
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
foreach
(
var
item
in
svlist
)
{
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
SpecificationList
)
{
item
.
SpecificationValueList
=
svlist
.
Where
(
x
=>
x
.
SpecificationId
==
item
.
Id
).
ToList
();
}
}
SpecificationPriceList
=
goods_SpecificationPriceRepository
.
GetList
(
new
RB_Goods_SpecificationPrice_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
}
//区域
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
});
}
foreach
(
var
item
in
list
)
{
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
CarouselIdList
[
0
];
}
item
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
item
.
SpecificationPriceList
=
new
List
<
RB_Goods_SpecificationPrice_Extend
>();
if
(
item
.
IsCustomSpecification
==
1
)
{
item
.
SpecificationList
=
SpecificationList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
item
.
SpecificationPriceList
=
SpecificationPriceList
.
Where
(
x
=>
x
.
GoodsId
==
item
.
Id
).
ToList
();
}
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>
...
...
@@ -2858,14 +2882,9 @@ namespace Mall.Module.Product
if
(
model
.
SpecificationList
.
Any
())
{
var
svlist
=
goods_SpecificationValueRepository
.
GetList
(
new
RB_Goods_SpecificationValue_Extend
()
{
GoodsId
=
goodsId
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
if
(
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Any
()
)
foreach
(
var
item
in
svlist
)
{
string
imgIds
=
string
.
Join
(
","
,
svlist
.
Where
(
x
=>
x
.
Image
>
0
).
Select
(
x
=>
x
.
Image
).
Distinct
());
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
imgIds
,
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
svlist
.
Where
(
x
=>
x
.
Image
>
0
))
{
item
.
ImagePath
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
.
Image
).
FirstOrDefault
()?.
Path
??
""
;
}
item
.
ImagePath
=
item
.
Image
;
}
foreach
(
var
item
in
model
.
SpecificationList
)
{
...
...
@@ -2981,24 +3000,19 @@ namespace Mall.Module.Product
model
.
CarouselImageList
=
new
List
<
RB_ImageCommonModel
>();
if
(!
string
.
IsNullOrEmpty
(
model
.
CarouselImage
)
&&
model
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
model
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
model
.
CarouselImage
);
//轮播图
var
mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
MaterialIds
=
string
.
Join
(
","
,
CarouselIdList
),
TenantId
=
TenantId
,
MallBaseId
=
MallBaseId
});
foreach
(
var
item
in
CarouselIdList
)
{
var
cmodel
=
mlist
.
Where
(
x
=>
x
.
Id
==
item
).
FirstOrDefault
();
model
.
CarouselImageList
.
Add
(
new
RB_ImageCommonModel
()
{
Id
=
item
,
Name
=
cmodel
?.
Name
??
""
,
Path
=
cmodel
?.
Path
??
""
Id
=
0
,
Name
=
""
,
Path
=
item
});
}
}
if
(
model
.
CustomShareImage
>
0
)
{
model
.
CustomShareImagePath
=
material_InfoRepository
.
GetEntity
(
model
.
CustomShareImage
)?.
Path
??
""
;
}
model
.
CustomShareImagePath
=
model
.
CustomShareImage
;
//服务列表
model
.
ServiceList
=
new
List
<
RB_ImageCommonModel
>();
if
(
model
.
IsDefaultService
==
2
)
...
...
@@ -3278,5 +3292,498 @@ namespace Mall.Module.Product
}
#
endregion
#
region
商品导入
/// <summary>
/// 赞羊商品导入
/// </summary>
/// <param name="path_server"></param>
/// <param name="goodsStatus"></param>
/// <param name="categoryIdList"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public
string
SetGoodsBatchImport
(
string
path_server
,
int
goodsStatus
,
List
<
int
>
categoryIdList
,
int
tenantId
,
int
mallBaseId
)
{
if
(!
System
.
IO
.
File
.
Exists
(
path_server
))
{
return
"导入文件已删除,请刷新后重新导入再试"
;
}
int
FileType
=
path_server
.
Contains
(
".csv"
)
?
1
:
2
;
//1 赞羊导入 2 和平导入
//处理文件内容读取
List
<
RB_Goods_Extend
>
list
=
DataHelper
.
GoodsBetchDataHelper
.
ImportClaimData
(
path_server
);
list
=
list
.
Where
(
x
=>
!
string
.
IsNullOrWhiteSpace
(
x
.
Name
)).
ToList
();
if
(
list
.
Any
())
{
List
<
string
>
AreaName
=
new
List
<
string
>();
foreach
(
var
item
in
list
)
{
#
region
导入验证
if
(
string
.
IsNullOrEmpty
(
item
.
Name
))
{
return
"有商品名称为空,无法导入"
;
}
if
((
item
.
OriginalPrice
??
0
)
<=
0
)
{
return
"商品原价为空:"
+
item
.
Name
;
}
if
((
item
.
SellingPrice
??
0
)
<=
0
)
{
return
"商品售价为空:"
+
item
.
Name
;
}
if
(
string
.
IsNullOrEmpty
(
item
.
CoverImage
))
{
return
"封面图为空:"
+
item
.
Name
;
}
if
(
string
.
IsNullOrEmpty
(
item
.
CarouselImage
))
{
return
"轮播图为空:"
+
item
.
Name
;
}
if
(
item
.
IsCustomSpecification
==
1
)
{
if
(
string
.
IsNullOrEmpty
(
item
.
SpecificationImport
))
{
return
"规格组为空:"
+
item
.
Name
;
}
if
(
string
.
IsNullOrEmpty
(
item
.
SpecificationPriceImport
))
{
return
"规格详情为空:"
+
item
.
Name
;
}
}
if
(
item
.
IsAreaBuy
==
1
)
{
if
(
string
.
IsNullOrEmpty
(
item
.
AreaImport
))
{
return
"区域购买为空:"
+
item
.
Name
;
}
}
if
(
FileType
==
1
)
{
try
{
//转化轮播图
List
<
GoodsCarouselImport
>
CarouseList
=
JsonConvert
.
DeserializeObject
<
List
<
GoodsCarouselImport
>>(
item
.
CarouselImage
);
item
.
CarouselImage
=
JsonConvert
.
SerializeObject
(
CarouseList
.
Select
(
x
=>
x
.
pic_url
));
//转化为系统格式
}
catch
(
Exception
)
{
return
"轮播图格式有误"
;
}
item
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
item
.
SpecificationPriceList
=
new
List
<
RB_Goods_SpecificationPrice_Extend
>();
item
.
AreaList
=
new
List
<
RB_Goods_Area_Extend
>();
try
{
List
<
GoodsSpecificationImport
>
SpecificationList
=
JsonConvert
.
DeserializeObject
<
List
<
GoodsSpecificationImport
>>(
item
.
SpecificationImport
);
List
<
GoodsSpecificationPriceImport
>
SpecificationPriceList
=
JsonConvert
.
DeserializeObject
<
List
<
GoodsSpecificationPriceImport
>>(
item
.
SpecificationPriceImport
);
//转化规格组
if
(
item
.
IsCustomSpecification
==
1
)
{
//规格组转化
int
Num
=
1
;
foreach
(
var
qitem
in
SpecificationList
)
{
List
<
RB_Goods_SpecificationValue_Extend
>
SpecificationValueList
=
new
List
<
RB_Goods_SpecificationValue_Extend
>();
int
EnabledImage
=
2
;
foreach
(
var
qqitem
in
qitem
.
attr_list
)
{
if
(!
string
.
IsNullOrEmpty
(
qqitem
.
pic_url
))
{
EnabledImage
=
1
;
}
SpecificationValueList
.
Add
(
new
RB_Goods_SpecificationValue_Extend
()
{
Sort
=
qqitem
.
attr_id
,
Name
=
FromUnicodeString
(
qqitem
.
attr_name
),
Image
=
qqitem
.
pic_url
});
}
if
(
Num
>
1
)
{
EnabledImage
=
2
;
}
item
.
SpecificationList
.
Add
(
new
RB_Goods_Specification_Extend
()
{
Sort
=
qitem
.
attr_group_id
,
Name
=
FromUnicodeString
(
qitem
.
attr_group_name
),
EnabledImage
=
EnabledImage
,
SpecificationValueList
=
SpecificationValueList
});
Num
++;
}
//规格详情转化
foreach
(
var
qitem
in
SpecificationPriceList
)
{
item
.
SpecificationPriceList
.
Add
(
new
RB_Goods_SpecificationPrice_Extend
()
{
SpecificationSort
=
qitem
.
sign_id
,
GoodsNumbers
=
FromUnicodeString
(
qitem
.
no
),
GoodsWeight
=
qitem
.
weight
,
InventoryNum
=
qitem
.
stock
,
SellingPrice
=
qitem
.
price
});
}
}
else
{
item
.
DefaultSpecificationName
=
SpecificationList
.
FirstOrDefault
()?.
attr_list
?.
FirstOrDefault
()?.
attr_name
??
""
;
item
.
GoodsNumbers
=
SpecificationPriceList
.
FirstOrDefault
()?.
no
??
""
;
item
.
GoodsWeight
=
SpecificationPriceList
.
FirstOrDefault
()?.
weight
??
0
;
}
}
catch
(
Exception
)
{
return
"规格组/规格详情有误"
;
}
try
{
//转化区域
if
(
item
.
IsAreaBuy
==
1
)
{
List
<
GoodsAreaListImport
>
GoodsAreaList
=
JsonConvert
.
DeserializeObject
<
List
<
GoodsAreaListImport
>>(
item
.
AreaImport
);
foreach
(
var
qitem
in
GoodsAreaList
)
{
foreach
(
var
qqitem
in
qitem
.
list
)
{
item
.
AreaList
.
Add
(
new
RB_Goods_Area_Extend
()
{
AreaName
=
qqitem
.
name
//拿到name 查询根据系统区域表再次查询所有的区域拿到id
});
AreaName
.
Add
(
"'"
+
(
qqitem
.
name
??
""
)
+
"'"
);
}
}
}
}
catch
(
Exception
)
{
return
"区域格式有误"
;
}
}
else
{
try
{
//转化轮播图
List
<
string
>
CarouseList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
}
catch
(
Exception
)
{
return
"轮播图格式有误"
;
}
item
.
SpecificationList
=
new
List
<
RB_Goods_Specification_Extend
>();
item
.
SpecificationPriceList
=
new
List
<
RB_Goods_SpecificationPrice_Extend
>();
item
.
AreaList
=
new
List
<
RB_Goods_Area_Extend
>();
try
{
item
.
SpecificationList
=
JsonConvert
.
DeserializeObject
<
List
<
RB_Goods_Specification_Extend
>>(
item
.
SpecificationImport
);
item
.
SpecificationPriceList
=
JsonConvert
.
DeserializeObject
<
List
<
RB_Goods_SpecificationPrice_Extend
>>(
item
.
SpecificationPriceImport
);
//转化规格组
if
(
item
.
IsCustomSpecification
!=
1
)
{
item
.
DefaultSpecificationName
=
item
.
SpecificationList
.
FirstOrDefault
()?.
SpecificationValueList
?.
FirstOrDefault
()?.
Name
??
""
;
item
.
GoodsNumbers
=
item
.
SpecificationPriceList
.
FirstOrDefault
()?.
GoodsNumbers
??
""
;
item
.
GoodsWeight
=
item
.
SpecificationPriceList
.
FirstOrDefault
()?.
GoodsWeight
??
0
;
}
}
catch
(
Exception
)
{
return
"规格组/规格详情有误"
;
}
try
{
//转化区域
if
(
item
.
IsAreaBuy
==
1
)
{
item
.
AreaList
=
JsonConvert
.
DeserializeObject
<
List
<
RB_Goods_Area_Extend
>>(
item
.
AreaImport
);
}
}
catch
(
Exception
)
{
return
"区域格式有误"
;
}
}
#
endregion
#
region
规格验证
if
(
item
.
IsCustomSpecification
==
1
)
{
if
(
item
.
SpecificationList
.
Count
()
!=
item
.
SpecificationList
.
Select
(
x
=>
x
.
Sort
).
Distinct
().
Count
())
{
return
"商品规格组排序有误:"
+
item
.
Name
;
}
int
TotalNum
=
1
;
foreach
(
var
qitem
in
item
.
SpecificationList
)
{
if
(
qitem
.
SpecificationValueList
.
Count
()
!=
qitem
.
SpecificationValueList
.
Select
(
x
=>
x
.
Sort
).
Distinct
().
Count
())
{
return
"商品规格组排序有误:"
+
item
.
Name
;
}
TotalNum
*=
qitem
.
SpecificationValueList
.
Count
();
if
(
qitem
.
EnabledImage
!=
1
)
{
foreach
(
var
qqitem
in
qitem
.
SpecificationValueList
)
{
qqitem
.
Image
=
""
;
}
}
}
//验证总keys数量
if
(
item
.
SpecificationPriceList
.
Count
()
!=
TotalNum
)
{
return
"商品规格明细数量有误:"
+
item
.
Name
;
}
//初始化所有keys
List
<
string
>
KeyList
=
new
List
<
string
>();
for
(
var
i
=
1
;
i
<=
TotalNum
;
i
++)
{
KeyList
.
Add
(
""
);
}
int
MGBJNum
=
1
;
//组装所有keys
foreach
(
var
qitem
in
item
.
SpecificationList
)
{
int
LBBJNum
=
TotalNum
/
qitem
.
SpecificationValueList
.
Count
()
/
MGBJNum
;
int
KeyIndex
=
0
;
for
(
var
i
=
1
;
i
<=
LBBJNum
;
i
++)
{
foreach
(
var
qqitem
in
qitem
.
SpecificationValueList
)
{
for
(
var
j
=
1
;
j
<=
MGBJNum
;
j
++)
{
KeyList
[
KeyIndex
]
=
KeyList
[
KeyIndex
]
+
":"
+
qqitem
.
Sort
;
KeyIndex
++;
}
}
}
}
//验证所有keys
foreach
(
var
qitem
in
KeyList
)
{
string
keys
=
qitem
[
1.
.];
var
pricemodel
=
item
.
SpecificationPriceList
.
Where
(
x
=>
x
.
SpecificationSort
==
keys
).
FirstOrDefault
();
if
(
pricemodel
==
null
)
{
return
"商品规格价格Key有误:"
+
item
.
Name
;
}
pricemodel
.
InventoryNum
??=
0
;
pricemodel
.
SellingPrice
??=
0
;
pricemodel
.
GoodsNumbers
??=
""
;
pricemodel
.
GoodsWeight
??=
0
;
item
.
InventoryNum
+=
(
pricemodel
.
InventoryNum
??
0
);
}
//主表价格 如果有自定义规格,直接取最小值
item
.
SellingPrice
=
item
.
SpecificationPriceList
.
Min
(
x
=>
x
.
SellingPrice
??
0
);
}
#
endregion
#
region
商品分类
item
.
CategoryList
=
new
List
<
RB_Goods_Category_Extend
>();
foreach
(
var
qitem
in
categoryIdList
)
{
item
.
CategoryList
.
Add
(
new
RB_Goods_Category_Extend
()
{
CategoryId
=
qitem
});
}
#
endregion
#
region
赋默认值
item
.
GoodsStatus
=
goodsStatus
;
item
.
DefaultSpecificationName
??=
""
;
item
.
GoodsNumbers
??=
""
;
item
.
GoodsWeight
??=
0
;
item
.
IsDefaultService
??=
1
;
item
.
GoodsService
=
"[]"
;
item
.
FreightId
??=
0
;
item
.
FormsId
??=
0
;
item
.
SeparateDistribution
??=
2
;
item
.
SeparateDistributionType
??=
1
;
item
.
SeparateDistributionMoneyType
??=
1
;
item
.
EnjoyMember
??=
2
;
item
.
SeparateSetMember
??=
2
;
item
.
GoodsType
??=
Common
.
Enum
.
Goods
.
OrderTypeEnum
.
Mall
;
item
.
Status
=
0
;
item
.
TenantId
=
tenantId
;
item
.
MallBaseId
=
mallBaseId
;
item
.
CreateDate
=
DateTime
.
Now
;
item
.
UpdateDate
=
DateTime
.
Now
;
#
endregion
#
region
修正默认
item
.
IsSellWell
=
item
.
IsSellWell
==
1
?
1
:
2
;
item
.
IsQuickBuy
=
item
.
IsQuickBuy
==
1
?
1
:
2
;
item
.
IsGoodsNegotiable
=
item
.
IsGoodsNegotiable
==
1
?
1
:
2
;
item
.
IsAreaBuy
=
item
.
IsAreaBuy
==
1
?
1
:
2
;
item
.
IsMultipleDeduction
=
item
.
IsMultipleDeduction
==
1
?
1
:
2
;
item
.
IsCustomSpecification
=
item
.
IsCustomSpecification
==
1
?
1
:
2
;
#
endregion
}
//根据区域名称 查找所有区域id
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Destination_Extend
>
destList
=
new
List
<
Model
.
Extend
.
BaseSetUp
.
RB_Destination_Extend
>();
if
(
FileType
==
1
)
{
destList
=
destinationRepository
.
GetListExt
(
new
Model
.
Extend
.
BaseSetUp
.
RB_Destination_Extend
()
{
NameStr
=
string
.
Join
(
","
,
AreaName
.
Distinct
())
});
}
var
trans
=
goodsRepository
.
DbTransaction
;
DateTime
dt
=
DateTime
.
Now
;
try
{
foreach
(
var
item
in
list
)
{
if
(
item
.
IsAreaBuy
==
1
&&
FileType
==
1
)
{
foreach
(
var
qitem
in
item
.
AreaList
)
{
qitem
.
AreaId
=
destList
.
Where
(
x
=>
x
.
Name
==
qitem
.
AreaName
).
FirstOrDefault
()?.
ID
;
qitem
.
AreaType
=
(
int
)(
destList
.
Where
(
x
=>
x
.
Name
==
qitem
.
AreaName
).
FirstOrDefault
()?.
CodeLevel
??
Common
.
Enum
.
AreaRegionEnum
.
CountryEnum
);
}
}
bool
flag
=
SetGoodsImportInfo
(
item
,
trans
);
if
(
flag
==
false
)
{
goodsRepository
.
DBSession
.
Rollback
();
return
"请联系管理员,商品导入失败:"
+
item
.
Name
;
}
}
goodsRepository
.
DBSession
.
Commit
();
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetGoodsBatchImport"
);
goodsRepository
.
DBSession
.
Rollback
();
System
.
IO
.
File
.
Delete
(
path_server
);
return
"出错啦,请联系管理员"
;
}
}
System
.
IO
.
File
.
Delete
(
path_server
);
return
""
;
}
/// <summary>
/// 新增商品导入
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public
bool
SetGoodsImportInfo
(
RB_Goods_Extend
demodel
,
System
.
Data
.
IDbTransaction
trans
)
{
try
{
int
Id
=
goodsRepository
.
Insert
(
demodel
,
trans
);
bool
flag
=
Id
>
0
;
if
(
flag
)
{
//插入分类
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
},
trans
);
}
//插入规格
if
(
demodel
.
IsCustomSpecification
==
1
)
{
foreach
(
var
item
in
demodel
.
SpecificationList
)
{
int
sid
=
goods_SpecificationRepository
.
Insert
(
new
RB_Goods_Specification
()
{
CreateDate
=
demodel
.
CreateDate
,
EnabledImage
=
item
.
EnabledImage
,
GoodsId
=
Id
,
Id
=
0
,
MallBaseId
=
demodel
.
MallBaseId
,
Name
=
item
.
Name
,
Sort
=
item
.
Sort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
},
trans
);
if
(
sid
>
0
)
{
foreach
(
var
qitem
in
item
.
SpecificationValueList
)
{
goods_SpecificationValueRepository
.
Insert
(
new
RB_Goods_SpecificationValue
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
Image
=
qitem
.
Image
,
MallBaseId
=
demodel
.
MallBaseId
,
Name
=
qitem
.
Name
,
Sort
=
qitem
.
Sort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
SpecificationId
=
sid
},
trans
);
}
}
}
foreach
(
var
item
in
demodel
.
SpecificationPriceList
)
{
goods_SpecificationPriceRepository
.
Insert
(
new
RB_Goods_SpecificationPrice
()
{
CreateDate
=
demodel
.
CreateDate
,
GoodsId
=
Id
,
Id
=
0
,
GoodsNumbers
=
item
.
GoodsNumbers
,
GoodsWeight
=
item
.
GoodsWeight
,
InventoryNum
=
item
.
InventoryNum
,
MallBaseId
=
demodel
.
MallBaseId
,
SellingPrice
=
item
.
SellingPrice
,
SpecificationSort
=
item
.
SpecificationSort
,
Status
=
0
,
TenantId
=
demodel
.
TenantId
,
UpdateDate
=
demodel
.
UpdateDate
},
trans
);
}
}
//插入区域
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
},
trans
);
}
}
return
true
;
}
catch
(
Exception
ex
)
{
LogHelper
.
Write
(
ex
,
"SetGoodsImportInfo"
);
return
false
;
}
}
/// <summary>
/// unicode 解码
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public
string
FromUnicodeString
(
string
str
)
{
//最直接的方法Regex.Unescape(str);
StringBuilder
strResult
=
new
StringBuilder
();
if
(!
string
.
IsNullOrEmpty
(
str
))
{
string
[]
strlist
=
str
.
Replace
(
"\\"
,
""
).
Split
(
'u'
);
try
{
for
(
int
i
=
1
;
i
<
strlist
.
Length
;
i
++)
{
int
charCode
=
Convert
.
ToInt32
(
strlist
[
i
],
16
);
strResult
.
Append
((
char
)
charCode
);
}
}
catch
(
FormatException
)
{
return
Regex
.
Unescape
(
str
);
}
}
return
strResult
.
ToString
();
}
#
endregion
}
}
Mall.Module.User/UserModule.cs
View file @
6f79776f
...
...
@@ -1924,9 +1924,9 @@ namespace Mall.Module.User
item
.
CoverImage
=
""
;
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
item
.
CarouselImage
);
//封面图
item
.
CoverImage
=
material_InfoRepository
.
GetEntity
(
CarouselIdList
[
0
])?.
Path
??
""
;
item
.
CoverImage
=
CarouselIdList
[
0
]
;
}
}
}
...
...
@@ -2527,25 +2527,6 @@ namespace Mall.Module.User
//查询商品信息
string
goodsIds
=
string
.
Join
(
","
,
list
.
Select
(
x
=>
x
.
GoodsId
).
Distinct
());
var
goodsList
=
goodsRepository
.
GetList
(
new
RB_Goods_Extend
()
{
GoodsIds
=
goodsIds
,
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
});
//查询图片
List
<
RB_Material_Info_Extend
>
Mlist
=
new
List
<
RB_Material_Info_Extend
>();
if
(
goodsList
.
Any
())
{
List
<
int
>
imgIds
=
new
List
<
int
>();
foreach
(
var
item
in
goodsList
)
{
if
(!
string
.
IsNullOrEmpty
(
item
.
CarouselImage
)
&&
item
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
item
.
CarouselImage
);
//封面图
imgIds
.
Add
(
CarouselIdList
[
0
]);
}
}
if
(
imgIds
.
Any
())
{
Mlist
=
material_InfoRepository
.
GetList
(
new
RB_Material_Info_Extend
()
{
TenantId
=
demodel
.
TenantId
,
MallBaseId
=
demodel
.
MallBaseId
,
MaterialIds
=
string
.
Join
(
","
,
imgIds
.
Distinct
())
});
}
}
foreach
(
var
item
in
list
)
{
...
...
@@ -2557,9 +2538,9 @@ namespace Mall.Module.User
{
if
(!
string
.
IsNullOrEmpty
(
goodsModel
.
CarouselImage
)
&&
goodsModel
.
CarouselImage
!=
"[]"
)
{
List
<
int
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
goodsModel
.
CarouselImage
);
List
<
string
>
CarouselIdList
=
JsonConvert
.
DeserializeObject
<
List
<
string
>>(
goodsModel
.
CarouselImage
);
//封面图
item
.
GoodsImgPath
=
Mlist
.
Where
(
x
=>
x
.
Id
==
CarouselIdList
[
0
]).
FirstOrDefault
()?.
Path
??
""
;
item
.
GoodsImgPath
=
CarouselIdList
[
0
]
;
}
}
}
...
...
Mall.Repository/BaseSetUp/RB_DestinationRepository.cs
View file @
6f79776f
...
...
@@ -100,6 +100,9 @@ namespace Mall.Repository.BaseSetUp
{
sb
.
AppendFormat
(
" AND {0} LIKE '%{1}%' "
,
nameof
(
RB_Destination_Extend
.
Name
),
where
.
Name
.
Trim
());
}
if
(!
string
.
IsNullOrEmpty
(
where
.
NameStr
))
{
sb
.
AppendFormat
(
" AND {0} in({1})"
,
nameof
(
RB_Destination_Extend
.
Name
),
where
.
NameStr
);
}
}
return
Get
<
RB_Destination_Extend
>(
sb
.
ToString
()).
ToList
();
...
...
Mall.WebApi/Controllers/Product/ProductController.cs
View file @
6f79776f
...
...
@@ -1114,10 +1114,13 @@ namespace Mall.WebApi.Controllers.MallBase
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
},
...
...
@@ -1132,7 +1135,11 @@ namespace Mall.WebApi.Controllers.MallBase
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
}
}
};
...
...
@@ -1143,12 +1150,93 @@ namespace Mall.WebApi.Controllers.MallBase
{
demodel
.
TenantId
=
parms
.
TenantId
;
demodel
.
MallBaseId
=
parms
.
MallBaseId
;
var
list
=
productModule
.
GetProductGoodsList
(
demodel
);
var
list
=
productModule
.
GetProductGoodsList
ForExcel
(
demodel
);
#
region
组装数据
int
Num
=
0
;
foreach
(
var
item
in
list
)
{
Num
++;
string
GGZ
=
""
;
string
GGMX
=
""
;
if
(
item
.
IsCustomSpecification
==
1
)
{
var
obj
=
item
.
SpecificationList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
GoodsId
,
x
.
Name
,
x
.
Sort
,
x
.
EnabledImage
,
SpecificationValueList
=
x
.
SpecificationValueList
.
Select
(
z
=>
new
{
z
.
Id
,
z
.
GoodsId
,
z
.
SpecificationId
,
z
.
Name
,
z
.
Image
,
z
.
Sort
})
});
GGZ
=
JsonConvert
.
SerializeObject
(
obj
);
//序列化
GGMX
=
JsonConvert
.
SerializeObject
(
item
.
SpecificationPriceList
.
Select
(
x
=>
new
{
x
.
Id
,
x
.
GoodsId
,
x
.
SpecificationSort
,
x
.
SellingPrice
,
x
.
InventoryNum
,
x
.
GoodsWeight
,
x
.
GoodsNumbers
}));
}
else
{
List
<
object
>
objList
=
new
List
<
object
>();
List
<
object
>
SpecificationValueList
=
new
List
<
object
>();
SpecificationValueList
.
Add
(
new
{
Id
=
0
,
GoodsId
=
item
.
Id
,
SpecificationId
=
0
,
Name
=
item
.
DefaultSpecificationName
,
Image
=
""
,
Sort
=
0
});
objList
.
Add
(
new
{
Id
=
0
,
GoodsId
=
item
.
Id
,
Name
=
"规格"
,
Sort
=
0
,
EnabledImage
=
2
,
SpecificationValueList
});
GGZ
=
JsonConvert
.
SerializeObject
(
objList
);
//序列化
List
<
object
>
SpecificationPriceList
=
new
List
<
object
>();
SpecificationPriceList
.
Add
(
new
{
Id
=
0
,
GoodsId
=
item
.
Id
,
SpecificationSort
=
""
,
item
.
SellingPrice
,
item
.
InventoryNum
,
item
.
GoodsWeight
,
item
.
GoodsNumbers
});
GGMX
=
JsonConvert
.
SerializeObject
(
SpecificationPriceList
);
//序列化
}
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
)
{
...
...
@@ -1157,10 +1245,15 @@ namespace Mall.WebApi.Controllers.MallBase
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
.
Unit
){
},
new
ExcelColumn
(
value
:(
item
.
SellingPrice
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsCustomSpecification
??
2
).
ToString
()){
},
new
ExcelColumn
(
value
:
GGZ
.
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
InventoryNum
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
SalesNum
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
LimitBuyGoodsNum
??
0
).
ToString
()){
},
...
...
@@ -1171,11 +1264,17 @@ namespace Mall.WebApi.Controllers.MallBase
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
??
0
).
ToString
()
){
},
new
ExcelColumn
(
value
:
item
.
CustomShareTitles
){
},
new
ExcelColumn
(
value
:
item
.
CustomShareImage
??
""
){
},
new
ExcelColumn
(
value
:
item
.
CustomShareTitles
??
""
){
},
new
ExcelColumn
(
value
:(
item
.
Sort
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
LimitBuyOrderNum
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsAreaBuy
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:
AreaList
.
ToString
()){
},
new
ExcelColumn
(
value
:
GGMX
.
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsQuickBuy
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsSellWell
??
0
).
ToString
()){
},
new
ExcelColumn
(
value
:(
item
.
IsGoodsNegotiable
??
0
).
ToString
()){
},
}
};
...
...
@@ -1367,7 +1466,7 @@ namespace Mall.WebApi.Controllers.MallBase
if
(
demodel
.
CarouselImageList
==
null
||
!
demodel
.
CarouselImageList
.
Any
())
{
return
ApiResult
.
ParamIsNull
(
"请添加商品轮播图"
);
}
demodel
.
CarouselImage
=
JsonConvert
.
SerializeObject
(
demodel
.
CarouselImageList
.
Select
(
x
=>
x
.
Id
));
demodel
.
CarouselImage
=
JsonConvert
.
SerializeObject
(
demodel
.
CarouselImageList
.
Select
(
x
=>
x
.
Path
));
if
((
demodel
.
SellingPrice
??
0
)
<=
0
){
return
ApiResult
.
ParamIsNull
(
"请输入售价"
);
}
...
...
@@ -1405,7 +1504,7 @@ namespace Mall.WebApi.Controllers.MallBase
TotalNum
*=
item
.
SpecificationValueList
.
Count
();
if
(
item
.
EnabledImage
==
1
)
{
foreach
(
var
qitem
in
item
.
SpecificationValueList
)
{
if
((
qitem
.
Image
??
0
)
<=
0
)
{
if
((
qitem
.
Image
??
""
)
==
""
)
{
return
ApiResult
.
ParamIsNull
(
"请选择规格图片"
);
}
}
...
...
@@ -1633,7 +1732,7 @@ namespace Mall.WebApi.Controllers.MallBase
#
region
默认值
demodel
.
VideoAddress
??=
""
;
demodel
.
CustomShareTitles
??=
""
;
demodel
.
CustomShareImage
??=
0
;
demodel
.
CustomShareImage
??=
""
;
demodel
.
GoodsStatus
??=
2
;
demodel
.
DefaultSpecificationName
??=
""
;
demodel
.
Sort
??=
0
;
...
...
@@ -1839,5 +1938,54 @@ namespace Mall.WebApi.Controllers.MallBase
}
#
endregion
#
region
商品导入
/// <summary>
/// 商品导入
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
ApiResult
SetGoodsBatchImport
()
{
var
req
=
RequestParm
;
JObject
parms
=
JObject
.
Parse
(
req
.
msg
.
ToString
());
string
FilePath
=
parms
.
GetStringValue
(
"FilePath"
);
int
GoodsStatus
=
parms
.
GetInt
(
"GoodsStatus"
,
0
);
string
CategoryList
=
parms
.
GetStringValue
(
"CategoryList"
);
if
(
string
.
IsNullOrEmpty
(
FilePath
))
{
return
ApiResult
.
ParamIsNull
(
"文件路径不存在"
);
}
if
(
GoodsStatus
<=
0
)
{
return
ApiResult
.
ParamIsNull
(
"请选择商品状态"
);
}
if
(
string
.
IsNullOrEmpty
(
CategoryList
))
{
return
ApiResult
.
ParamIsNull
(
"请选择商品分类"
);
}
List
<
int
>
CategoryIdList
=
new
List
<
int
>();
try
{
CategoryIdList
=
JsonConvert
.
DeserializeObject
<
List
<
int
>>(
CategoryList
);
}
catch
(
Exception
)
{
return
ApiResult
.
ParamIsNull
(
"商品分类传递不正确"
);
}
string
msg
=
productModule
.
SetGoodsBatchImport
(
FilePath
,
GoodsStatus
,
CategoryIdList
,
req
.
TenantId
,
req
.
MallBaseId
);
if
(
msg
==
""
)
{
return
ApiResult
.
Success
();
}
else
{
return
ApiResult
.
Failed
(
msg
);
}
}
#
endregion
}
}
\ No newline at end of file
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