Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pms-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
pms-ci-test
Commits
8136e6e6
提交
8136e6e6
authored
7月 04, 2023
作者:
xiaowang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
修改路径
上级
1b165851
隐藏空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
577 行增加
和
3840 行删除
+577
-3840
BackstageTaskServiceImpl.java
...va/com/mmc/pms/service/Impl/BackstageTaskServiceImpl.java
+24
-24
BrandManageServiceImpl.java
...java/com/mmc/pms/service/Impl/BrandManageServiceImpl.java
+63
-67
CategoriesServiceImpl.java
.../java/com/mmc/pms/service/Impl/CategoriesServiceImpl.java
+1
-1
GoodsInfoServiceImpl.java
...n/java/com/mmc/pms/service/Impl/GoodsInfoServiceImpl.java
+30
-30
IndustrySpecServiceImpl.java
...ava/com/mmc/pms/service/Impl/IndustrySpecServiceImpl.java
+438
-393
InspComtServiceImpl.java
...in/java/com/mmc/pms/service/Impl/InspComtServiceImpl.java
+6
-10
MiniProgramProductMallServiceImpl.java
...c/pms/service/Impl/MiniProgramProductMallServiceImpl.java
+3
-3
ProductServiceImpl.java
...ain/java/com/mmc/pms/service/Impl/ProductServiceImpl.java
+10
-10
WebDeviceServiceImpl.java
...n/java/com/mmc/pms/service/Impl/WebDeviceServiceImpl.java
+1
-1
WebProductMallServiceImpl.java
...a/com/mmc/pms/service/Impl/WebProductMallServiceImpl.java
+1
-2
BackstageTaskServiceImpl.java
...va/com/mmc/pms/service/impl/BackstageTaskServiceImpl.java
+0
-284
BrandManageServiceImpl.java
...java/com/mmc/pms/service/impl/BrandManageServiceImpl.java
+0
-94
CategoriesServiceImpl.java
.../java/com/mmc/pms/service/impl/CategoriesServiceImpl.java
+0
-329
GoodsInfoServiceImpl.java
...n/java/com/mmc/pms/service/impl/GoodsInfoServiceImpl.java
+0
-1127
IndustrySpecServiceImpl.java
...ava/com/mmc/pms/service/impl/IndustrySpecServiceImpl.java
+0
-503
InspComtServiceImpl.java
...in/java/com/mmc/pms/service/impl/InspComtServiceImpl.java
+0
-26
MiniProgramProductMallServiceImpl.java
...c/pms/service/impl/MiniProgramProductMallServiceImpl.java
+0
-206
ProductServiceImpl.java
...ain/java/com/mmc/pms/service/impl/ProductServiceImpl.java
+0
-336
WebDeviceServiceImpl.java
...n/java/com/mmc/pms/service/impl/WebDeviceServiceImpl.java
+0
-295
WebProductMallServiceImpl.java
...a/com/mmc/pms/service/impl/WebProductMallServiceImpl.java
+0
-99
没有找到文件。
src/main/java/com/mmc/pms/service/Impl/BackstageTaskServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyun.oss.HttpMethod
;
import
com.google.common.reflect.TypeToken
;
import
com.google.gson.Gson
;
import
com.mmc.pms.auth.dto.CompanyInfoDTO
;
...
...
@@ -25,21 +24,15 @@ import com.mmc.pms.model.work.vo.UpAndDownServiceVO;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.BackstageTaskService
;
import
com.mmc.pms.service.InspComtService
;
import
feign.Feign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.security.SecurityProperties
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.MultiValueMap
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.ParseException
;
...
...
@@ -65,7 +58,6 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
public
ResultBody
addWorkService
(
ServiceVO
param
,
Integer
userAccountId
)
{
ServiceDO
serviceDO
=
new
ServiceDO
(
param
,
userAccountId
);
...
...
@@ -89,13 +81,16 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
}
@Override
public
ResultBody
<
ServiceDTO
>
queryById
(
Integer
id
,
HttpServletRequest
request
)
{
public
ResultBody
<
ServiceDTO
>
queryById
(
Integer
id
,
HttpServletRequest
request
)
{
ServiceDO
serviceDO
=
backstageTaskServiceDao
.
queryById
(
id
);
String
token
=
userAppApi
.
getCompanyInfoById
(
serviceDO
.
getCompanyId
(),
request
.
getHeader
(
"token"
));
String
token
=
userAppApi
.
getCompanyInfoById
(
serviceDO
.
getCompanyId
(),
request
.
getHeader
(
"token"
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
token
);
CompanyInfoDTO
companyInfoDTO
=
JSON
.
parseObject
(
String
.
valueOf
((
JSONObject
)
jsonObject
.
get
(
"result"
)),
CompanyInfoDTO
.
class
);
CompanyInfoDTO
companyInfoDTO
=
JSON
.
parseObject
(
String
.
valueOf
((
JSONObject
)
jsonObject
.
get
(
"result"
)),
CompanyInfoDTO
.
class
);
String
companyName
=
companyInfoDTO
.
getCompanyName
();
ServiceDTO
serviceDTO
=
new
ServiceDTO
(
serviceDO
,
companyName
);
ServiceDTO
serviceDTO
=
new
ServiceDTO
(
serviceDO
,
companyName
);
Map
<
Integer
,
String
>
categoriesNameMap
=
getCategoriesNameByIds
(
Arrays
.
asList
(
serviceDTO
.
getApplicationId
(),
serviceDTO
.
getIndustryId
()));
...
...
@@ -109,8 +104,6 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return
ResultBody
.
success
(
serviceDTO
);
}
private
Map
<
Integer
,
String
>
getCategoriesNameByIds
(
List
<
Integer
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
new
HashMap
<>();
...
...
@@ -128,7 +121,8 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
}
@Override
public
PageResult
queryServiceManagerList
(
ServiceQO
param
,
Integer
userAccountId
,
CompanyInfoVO
companyInfoVO
)
{
public
PageResult
queryServiceManagerList
(
ServiceQO
param
,
Integer
userAccountId
,
CompanyInfoVO
companyInfoVO
)
{
int
count
=
backstageTaskServiceDao
.
count
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
...
...
@@ -181,9 +175,9 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
List
<
ServiceDO
>
pageList
=
backstageTaskServiceDao
.
queryPageByLimit
(
param
,
categoriesIds
,
userIds
);
backstageTaskServiceDao
.
queryPageByLimit
(
param
,
categoriesIds
,
userIds
);
List
<
WorkServiceDTO
>
workServiceDTOList
=
getWorkServiceDTOS
(
pageList
,
request
);
List
<
WorkServiceDTO
>
workServiceDTOList
=
getWorkServiceDTOS
(
pageList
,
request
);
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
workServiceDTOList
);
}
...
...
@@ -210,20 +204,26 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
@Override
public
ResultBody
queryByIdCount
(
Integer
companyId
)
{
return
ResultBody
.
success
(
backstageTaskServiceDao
.
queryByIdCount
(
companyId
));
return
ResultBody
.
success
(
backstageTaskServiceDao
.
queryByIdCount
(
companyId
));
}
private
List
<
WorkServiceDTO
>
getWorkServiceDTOS
(
List
<
ServiceDO
>
pageList
,
HttpServletRequest
request
)
{
String
companyInfoVOS
=
userAppApi
.
listCompanyPage
(
new
CompanyInfoQO
(
1
,
100000
),
request
.
getHeader
(
"token"
)
);
private
List
<
WorkServiceDTO
>
getWorkServiceDTOS
(
List
<
ServiceDO
>
pageList
,
HttpServletRequest
request
)
{
String
companyInfoVOS
=
userAppApi
.
listCompanyPage
(
new
CompanyInfoQO
(
1
,
100000
),
request
.
getHeader
(
"token"
));
JSONObject
jsonObject
=
JSON
.
parseObject
(
companyInfoVOS
);
JSONObject
jsonObject1
=
JSON
.
parseObject
(
String
.
valueOf
(
jsonObject
.
get
(
"result"
)));
List
<
CompanyInfoVO
>
companyInfoList
=
new
Gson
().
fromJson
(
new
Gson
().
toJson
(
jsonObject1
.
get
(
"list"
)),
new
TypeToken
<
List
<
CompanyInfoVO
>>(){}.
getType
());
List
<
CompanyInfoVO
>
companyInfoList
=
new
Gson
()
.
fromJson
(
new
Gson
().
toJson
(
jsonObject1
.
get
(
"list"
)),
new
TypeToken
<
List
<
CompanyInfoVO
>>()
{}.
getType
());
String
companyName
=
""
;
List
<
WorkServiceDTO
>
workServiceDTOList
=
new
ArrayList
<>();
for
(
ServiceDO
item
:
pageList
)
{
for
(
CompanyInfoVO
companyInfoVO
:
companyInfoList
)
{
if
(
item
.
getCompanyId
().
equals
(
companyInfoVO
.
getId
())){
companyName
=
companyInfoVO
.
getCompanyName
();
if
(
item
.
getCompanyId
().
equals
(
companyInfoVO
.
getId
()))
{
companyName
=
companyInfoVO
.
getCompanyName
();
}
}
List
<
InspComtDO
>
inspComtDOS
=
generateComments
(
item
);
...
...
src/main/java/com/mmc/pms/service/Impl/BrandManageServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
...
...
@@ -17,82 +17,78 @@ import java.util.stream.Collectors;
/**
* @Author LW
*
@date 2023/3/14 13:27
* 概要:
*
*
@date 2023/3/14 13:27
概要:
*/
@Service
public
class
BrandManageServiceImpl
implements
BrandManageService
{
@Autowired
private
BrandManageDao
brandManageDao
;
@Resource
private
ProductDao
productDao
;
@Autowired
private
BrandManageDao
brandManageDao
;
@Resource
private
ProductDao
productDao
;
/**
* 添加品牌信息
*
* @param brandName 品牌名称
* @return {@link ResultBody}
*/
@Override
public
ResultBody
addBrandInfo
(
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
null
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandManageDao
.
insertBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
/**
* 添加品牌信息
*
* @param brandName 品牌名称
* @return {@link ResultBody}
*/
@Override
public
ResultBody
addBrandInfo
(
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
null
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandManageDao
.
insertBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
}
/**
* 品牌列表信息
*
* @return {@link ResultBody}
*/
@Override
public
PageResult
listBrandInfo
(
Integer
pageNo
,
Integer
pageSize
)
{
int
count
=
brandManageDao
.
countBrandInfo
();
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
0
);
}
int
itemIndex
=
(
pageNo
-
1
)
*
pageSize
;
List
<
BrandInfoDO
>
brandInfo
=
brandManageDao
.
listBrandInfo
(
itemIndex
,
pageSize
);
List
<
BrandInfoDTO
>
brandInfoList
=
brandInfo
.
stream
()
.
map
(
BrandInfoDO:
:
buildBrandInfoDTO
)
.
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
brandInfoList
);
/**
* 品牌列表信息
*
* @return {@link ResultBody}
*/
@Override
public
PageResult
listBrandInfo
(
Integer
pageNo
,
Integer
pageSize
)
{
int
count
=
brandManageDao
.
countBrandInfo
();
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
0
);
}
int
itemIndex
=
(
pageNo
-
1
)
*
pageSize
;
List
<
BrandInfoDO
>
brandInfo
=
brandManageDao
.
listBrandInfo
(
itemIndex
,
pageSize
);
List
<
BrandInfoDTO
>
brandInfoList
=
brandInfo
.
stream
().
map
(
BrandInfoDO:
:
buildBrandInfoDTO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
brandInfoList
);
}
/**
* 删除品牌信息
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
deleteBrandInfo
(
Integer
id
)
{
// 判断该品牌是否绑定产品信息
int
count
=
productDao
.
countProductSpecByBrandId
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
BRAND_DELETE_FAIL
);
}
brandManageDao
.
removeBrandInfoById
(
id
);
return
ResultBody
.
success
();
/**
* 删除品牌信息
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
deleteBrandInfo
(
Integer
id
)
{
// 判断该品牌是否绑定产品信息
int
count
=
productDao
.
countProductSpecByBrandId
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
BRAND_DELETE_FAIL
);
}
brandManageDao
.
removeBrandInfoById
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
editBrandInfo
(
Integer
id
,
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
id
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandInfoDO
.
setId
(
id
);
brandManageDao
.
updateBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
@Override
public
ResultBody
editBrandInfo
(
Integer
id
,
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
id
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandInfoDO
.
setId
(
id
);
brandManageDao
.
updateBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
}
}
src/main/java/com/mmc/pms/service/Impl/CategoriesServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mmc.pms.common.ResultBody
;
...
...
src/main/java/com/mmc/pms/service/Impl/GoodsInfoServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.alibaba.fastjson2.JSONObject
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.GoodsInfoDao
;
...
...
@@ -26,7 +25,6 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author 23214
...
...
@@ -46,7 +44,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
addGoods
(
GoodsAddVO
goodsAddVO
)
{
public
ResultBody
addGoods
(
GoodsAddVO
goodsAddVO
,
Integer
userAccountId
)
{
// 判断商品名称是否存在
if
(
goodsInfoDao
.
countGoodsInfoByName
(
goodsAddVO
)
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
...
...
@@ -118,10 +116,10 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
for
(
GoodsProdSpecVO
goodsSpecVO
:
goodsSpecList
)
{
MallProdInfoDO
mallProdSkuInfoDO
=
new
MallProdInfoDO
(
goodsSpecVO
)
.
setProd
Sku
Id
(
goodsSpecVO
.
getSkuId
())
.
setProd
uct
Id
(
goodsSpecVO
.
getSkuId
())
.
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的sku信息
goodsInfo
Dao
.
insertMallProdSkuInfo
(
mallProdSkuInfoDO
);
product
Dao
.
insertMallProdSkuInfo
(
mallProdSkuInfoDO
);
for
(
MallProductSpecVO
mallProductSpecVO
:
goodsSpecVO
.
getSpecIds
())
{
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
...
...
@@ -140,7 +138,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
GoodsInfo
goodsInfo
,
GoodsProdSpecVO
goodsSpec
,
Integer
id
)
{
MallProdInfoDO
mallProdInfoDO
=
new
MallProdInfoDO
();
mallProdInfoDO
.
setGoodsInfoId
(
goodsInfo
.
getId
());
mallProdInfoDO
.
setProd
Sku
Id
(
id
);
mallProdInfoDO
.
setProd
uct
Id
(
id
);
mallProdInfoDO
.
setProdSkuSpecName
(
goodsSpec
.
getGoodsSpecName
());
mallProdInfoDO
.
setCategoriesId
(
goodsSpec
.
getCategoryId
());
mallProdInfoDO
.
setChooseType
(
goodsSpec
.
getChooseType
());
...
...
@@ -155,12 +153,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 遍历自定义规格信息
for
(
GoodsProdSpecVO
productSpec
:
customGoodsSpecList
)
{
// 构建商品对应的sku信息
ProductSkuDO
productSkuDO
=
new
ProductSkuDO
()
.
setCategoriesId
(
productSpec
.
getCategoryId
())
.
setProductName
(
productSpec
.
getProductName
())
.
setCustomize
(
1
)
.
setDirectoryId
(
goodsInfo
.
getDirectoryId
());
ProductDO
productSkuDO
=
new
ProductDO
().
setProductName
(
productSpec
.
getProductName
()).
setCustomize
(
1
);
// 插入产品sku信息
productDao
.
insertProductSku
(
productSkuDO
);
MallProdInfoDO
mallProdInfoDO
=
...
...
@@ -173,7 +167,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
param
->
{
ProductSpecDO
productSpecDO
=
new
ProductSpecDO
()
.
setProduct
Sku
Id
(
productSkuDO
.
getId
())
.
setProductId
(
productSkuDO
.
getId
())
.
setVersionDesc
(
"自定义"
)
.
setSpecImage
(
param
.
getSpecImage
())
.
setSpecName
(
param
.
getSpecName
())
...
...
@@ -416,7 +410,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
MallProdInfoDO
mallProdInfoDO
=
new
MallProdInfoDO
();
mallProdInfoDO
.
setId
(
d
.
getId
())
.
setProd
Sku
Id
(
d
.
getSkuId
())
.
setProd
uct
Id
(
d
.
getSkuId
())
.
setCategoriesId
(
d
.
getCategoryId
())
.
setProdSkuSpecName
(
d
.
getGoodsSpecName
())
.
setChooseType
(
d
.
getChooseType
())
...
...
@@ -503,13 +497,10 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
.
map
(
d
->
{
// 构建商品对应的sku信息
ProductSkuDO
productSkuDO
=
new
ProductSkuDO
()
.
setId
(
d
.
getSkuId
())
.
setCategoriesId
(
d
.
getCategoryId
())
.
setProductName
(
d
.
getProductName
());
ProductDO
productSkuDO
=
new
ProductDO
().
setId
(
d
.
getSkuId
()).
setProductName
(
d
.
getProductName
());
productDao
.
updateProductSku
(
productSkuDO
);
return
new
MallProdInfoDO
(
d
).
setId
(
d
.
getId
()).
setProd
Sku
Id
(
d
.
getSkuId
());
return
new
MallProdInfoDO
(
d
).
setId
(
d
.
getId
()).
setProd
uct
Id
(
d
.
getSkuId
());
})
.
collect
(
Collectors
.
toList
());
// 批量修改sku的信息
...
...
@@ -949,9 +940,11 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 查询商品信息
List
<
OrderGoodsProdDTO
>
orderGoodsProdDTOList
=
productDao
.
listProdGoodsSkuInfo
(
mallOrderGoodsInfoQO
);
//填充价格
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
=
productDao
.
listAllProductSpecPriceByType
(
prodSkuSpecIds
);
this
.
buildProductSpecPrice
(
orderGoodsProdDTOList
,
allProductSpecPriceDOS
,
mallOrderGoodsInfoQO
.
getCooperationTagIds
());
// 填充价格
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
=
productDao
.
listAllProductSpecPriceByType
(
prodSkuSpecIds
);
this
.
buildProductSpecPrice
(
orderGoodsProdDTOList
,
allProductSpecPriceDOS
,
mallOrderGoodsInfoQO
.
getCooperationTagIds
());
// 还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额
List
<
Integer
>
goodsIds
=
orderGoodsProdDTOList
.
stream
()
...
...
@@ -983,19 +976,26 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
/**
* 填充产品规格价格
*
* @param orderGoodsProdDTOList
* @param allProductSpecPriceDOS
* @param cooperationTagIds
*/
private
void
buildProductSpecPrice
(
List
<
OrderGoodsProdDTO
>
orderGoodsProdDTOList
,
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
,
List
<
Integer
>
cooperationTagIds
){
Map
<
Integer
,
List
<
ProductSpecPriceDO
>>
productSpecPriceMap
=
allProductSpecPriceDOS
.
stream
()
private
void
buildProductSpecPrice
(
List
<
OrderGoodsProdDTO
>
orderGoodsProdDTOList
,
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
,
List
<
Integer
>
cooperationTagIds
)
{
Map
<
Integer
,
List
<
ProductSpecPriceDO
>>
productSpecPriceMap
=
allProductSpecPriceDOS
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
ProductSpecPriceDO:
:
getProductSpecId
));
for
(
OrderGoodsProdDTO
orderGoodsProdDTO
:
orderGoodsProdDTOList
)
{
for
(
OrderGoodsProdDetailDTO
prodDetailDTO
:
orderGoodsProdDTO
.
getOrderGoodsProdDetailDTOS
())
{
List
<
ProductSpecPriceDO
>
specPriceDOS
=
productSpecPriceMap
.
get
(
prodDetailDTO
.
getProductSpecId
());
for
(
OrderGoodsProdDetailDTO
prodDetailDTO
:
orderGoodsProdDTO
.
getOrderGoodsProdDetailDTOS
())
{
List
<
ProductSpecPriceDO
>
specPriceDOS
=
productSpecPriceMap
.
get
(
prodDetailDTO
.
getProductSpecId
());
if
(
CollectionUtils
.
isNotEmpty
(
specPriceDOS
))
{
List
<
ProductSpecPriceDO
>
tempSpecPrice
=
specPriceDOS
.
stream
()
List
<
ProductSpecPriceDO
>
tempSpecPrice
=
specPriceDOS
.
stream
()
.
filter
(
d
->
cooperationTagIds
.
contains
(
d
.
getCooperationTag
()))
.
sorted
(
Comparator
.
comparing
(
ProductSpecPriceDO:
:
getPrice
))
.
collect
(
Collectors
.
toList
());
...
...
src/main/java/com/mmc/pms/service/Impl/IndustrySpecServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
...
...
@@ -6,13 +6,8 @@ import com.mmc.pms.dao.BrandManageDao;
import
com.mmc.pms.dao.IndustrySpecDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.model.sale.dto.ProductInventoryVO
;
import
com.mmc.pms.model.sale.dto.ProductSpecVO
;
import
com.mmc.pms.model.sale.dto.RemoveSkuDTO
;
import
com.mmc.pms.model.qo.IndustrySkuQO
;
import
com.mmc.pms.model.sale.dto.IndustrySpecCPQVO
;
import
com.mmc.pms.model.sale.dto.IndustrySpecDTO
;
import
com.mmc.pms.model.sale.dto.IndustrySpecPriceDTO
;
import
com.mmc.pms.model.sale.dto.*
;
import
com.mmc.pms.model.sale.vo.GoodsProductSkuVO
;
import
com.mmc.pms.model.sale.vo.IndustrySkuVO
;
import
com.mmc.pms.model.sale.vo.IndustrySpecVO
;
...
...
@@ -31,428 +26,478 @@ import java.util.stream.Collectors;
/**
* @Author LW
*
@date 2022/10/8 10:58
* 概要:
*
*
@date 2022/10/8 10:58
概要:
*/
@Service
public
class
IndustrySpecServiceImpl
implements
IndustrySpecService
{
@Autowired
IndustrySpecDao
industrySpecDao
;
@Autowired
ProductDao
productDao
;
@Autowired
IndustrySpecDao
industrySpecDao
;
@Autowired
ProductDao
productDao
;
@Autowired
private
BrandManageDao
brandManageDao
;
@Autowired
private
BrandManageDao
brandManageDao
;
@Override
public
ResultBody
addIndustrySku
(
IndustrySkuVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSkuName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
IndustrySku
industrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
insertIndustrySku
(
industrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
return
ResultBody
.
success
();
@Override
public
ResultBody
addIndustrySku
(
IndustrySkuVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSkuName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
@Override
public
ResultBody
getIndustrySkuDetail
(
Integer
id
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SKU_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
IndustrySku
IndustrySku
=
industrySpecDao
.
getIndustrySkuById
(
id
);
return
ResultBody
.
success
(
IndustrySku
.
buildIndustrySku
());
IndustrySku
industrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
insertIndustrySku
(
industrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
editIndustrySku
(
IndustrySkuVO
param
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SKU_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
skuNameCount
=
industrySpecDao
.
countSkuName
(
param
);
if
(
skuNameCount
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
IndustrySku
IndustrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
updateIndustrySku
(
IndustrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
return
ResultBody
.
success
();
@Override
public
ResultBody
getIndustrySkuDetail
(
Integer
id
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
IndustrySku
IndustrySku
=
industrySpecDao
.
getIndustrySkuById
(
id
);
return
ResultBody
.
success
(
IndustrySku
.
buildIndustrySku
());
}
@Override
public
ResultBody
listPageIndustrySku
(
IndustrySkuQO
param
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySku
(
param
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
));
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
IndustrySku
>
industrySkuList
=
industrySpecDao
.
listPageIndustrySku
(
param
);
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
industrySkuList
.
stream
()
.
map
(
IndustrySku:
:
buildIndustrySkuDTO
)
.
collect
(
Collectors
.
toList
())));
@Override
public
ResultBody
editIndustrySku
(
IndustrySkuVO
param
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
skuNameCount
=
industrySpecDao
.
countSkuName
(
param
);
if
(
skuNameCount
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
IndustrySku
IndustrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
updateIndustrySku
(
IndustrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
return
ResultBody
.
success
();
}
/**
* 新增方案规格
*
* @param param
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
addIndustrySpec
(
IndustrySpecVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSpecName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 新增规格表信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
insertIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
@Override
public
ResultBody
listPageIndustrySku
(
IndustrySkuQO
param
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySku
(
param
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
));
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
IndustrySku
>
industrySkuList
=
industrySpecDao
.
listPageIndustrySku
(
param
);
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
industrySkuList
.
stream
()
.
map
(
IndustrySku:
:
buildIndustrySkuDTO
)
.
collect
(
Collectors
.
toList
())));
}
private
void
addInventorySpec
(
IndustrySpecVO
param
,
IndustrySpecDO
industrySpecDO
)
{
for
(
ProductInventoryVO
d
:
param
.
getProductInventoryList
())
{
IndustryProductInventoryDO
industryProductInventoryDO
=
new
IndustryProductInventoryDO
(
d
);
industryProductInventoryDO
.
setIndustrySpecId
(
industrySpecDO
.
getId
());
industrySpecDao
.
insertIndustryProductInventory
(
industryProductInventoryDO
);
// 新增清单绑定的产品规格信息
// 判断该sku是否指定产品规格 0:未指定 1:指定
if
(
d
.
getSelect
().
equals
(
0
))
{
// 如果是表示不指定则要添加所有对sku下的所有产品规格
// 先查出该sku下的所有规格信息
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
listProductSpec
(
d
.
getProductSku
().
getId
());
// 批量插入
for
(
ProductSpecDO
productSpecDO
:
productSpecList
)
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecDO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecDO
.
getProductSkuId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
}
else
{
// 指定的直接拿指定的数据
for
(
ProductSpecVO
productSpecVO
:
d
.
getProductSpecList
())
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecVO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecVO
.
getProductSkuId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
}
}
/**
* 新增方案规格
*
* @param param
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
addIndustrySpec
(
IndustrySpecVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSpecName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 新增规格表信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
insertIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
}
/**
* 获取行业规格信息
*
* @param industrySpecId
* @return
*/
@Override
public
ResultBody
getIndustrySpecDetail
(
Integer
industrySpecId
)
{
// 查询当前行业规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecId
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
private
void
addInventorySpec
(
IndustrySpecVO
param
,
IndustrySpecDO
industrySpecDO
)
{
for
(
ProductInventoryVO
d
:
param
.
getProductInventoryList
())
{
IndustryProductInventoryDO
industryProductInventoryDO
=
new
IndustryProductInventoryDO
(
d
);
industryProductInventoryDO
.
setIndustrySpecId
(
industrySpecDO
.
getId
());
industrySpecDao
.
insertIndustryProductInventory
(
industryProductInventoryDO
);
// 新增清单绑定的产品规格信息
// 判断该sku是否指定产品规格 0:未指定 1:指定
if
(
d
.
getSelect
().
equals
(
0
))
{
// 如果是表示不指定则要添加所有对sku下的所有产品规格
// 先查出该sku下的所有规格信息
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
listProductSpec
(
d
.
getProductSku
().
getId
());
// 批量插入
for
(
ProductSpecDO
productSpecDO
:
productSpecList
)
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecDO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecDO
.
getProductId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
// 初始化行业规格DTO
IndustrySpecDTO
industrySpecDTO
;
// 获取行业规格的基本信息
IndustrySpecDO
industrySpec
=
industrySpecDao
.
getIndustrySpecById
(
industrySpecId
);
industrySpecDTO
=
industrySpec
.
buildIndustrySpecDTO
();
// 获取这个规格下的产品sku信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
industrySpecId
);
// 获取产品skuId
List
<
Integer
>
productSkuId
=
industryProductInventory
.
stream
().
map
(
IndustryProductInventoryDO:
:
getProductSkuId
).
collect
(
Collectors
.
toList
());
// 分别查出产品sku的详细信息
List
<
ProductSkuDO
>
productSkuList
=
productDao
.
listProductSkuDO
(
productSkuId
);
// 查出产品sku对应的品牌的信息
Set
<
Integer
>
brandInfoIds
=
productSkuList
.
stream
().
map
(
ProductSkuDO:
:
getBrandInfoId
).
collect
(
Collectors
.
toSet
());
List
<
BrandInfoDO
>
brandInfoList
=
brandManageDao
.
listBrandInfoByIds
(
brandInfoIds
);
// 拿到行业产品清单id的集合
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
().
map
(
IndustryProductInventoryDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 再分别查出产品规格id
List
<
InventorySpecDO
>
inventorySpecList
=
productDao
.
listInventorySpecInfo
(
industryProductInventoryIds
);
if
(
inventorySpecList
.
size
()
!=
0
)
{
// 获取所有产品规格id
List
<
Integer
>
productSpecIds
=
inventorySpecList
.
stream
().
map
(
InventorySpecDO:
:
getProductSpecId
).
collect
(
Collectors
.
toList
());
// 根据这些规格id查询规格信息
List
<
ProductSpecDO
>
productSpecInfoList
=
productDao
.
listProductSpecInfo
(
productSpecIds
);
// 构建产品规格信息
List
<
ProductSpecVO
>
productSpecList
=
productSpecInfoList
.
stream
().
map
(
d
->
{
ProductSpecVO
productSpecVO
=
new
ProductSpecVO
();
productSpecVO
.
setSpecImage
(
d
.
getSpecImage
());
productSpecVO
.
setProductSkuId
(
d
.
getProductSkuId
());
productSpecVO
.
setSpecName
(
d
.
getSpecName
());
productSpecVO
.
setId
(
d
.
getId
());
productSpecVO
.
setPartNo
(
d
.
getPartNo
());
productSpecVO
.
setVersionDesc
(
d
.
getVersionDesc
());
return
productSpecVO
;
}).
collect
(
Collectors
.
toList
());
// 根据产品skuId分组
Map
<
Integer
,
List
<
ProductSpecVO
>>
maps
=
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecVO:
:
getProductSkuId
));
// 构建其余产品清单的信息
List
<
ProductInventoryVO
>
list
=
new
ArrayList
<>();
for
(
IndustryProductInventoryDO
d
:
industryProductInventory
)
{
for
(
ProductSkuDO
e
:
productSkuList
)
{
GoodsProductSkuVO
goodsProductSkuVO
=
new
GoodsProductSkuVO
();
goodsProductSkuVO
.
setId
(
d
.
getId
());
goodsProductSkuVO
.
setCategoryName
(
e
.
getCategoryName
());
goodsProductSkuVO
.
setProductName
(
e
.
getProductName
());
for
(
BrandInfoDO
b
:
brandInfoList
)
{
if
(
e
.
getBrandInfoId
().
equals
(
b
.
getId
()))
{
goodsProductSkuVO
.
setProductBrand
(
b
.
getBrandName
());
break
;
}
}
goodsProductSkuVO
.
setGoodsTypeId
(
e
.
getCategoriesId
());
goodsProductSkuVO
.
setModel
(
e
.
getModel
());
ProductInventoryVO
productInventoryVO
=
new
ProductInventoryVO
();
productInventoryVO
.
setProductSku
(
goodsProductSkuVO
);
if
(
d
.
getProductSkuId
().
equals
(
e
.
getId
()))
{
// 匹配分组之后id相等的数据构建到ProductInventoryVO对象中
List
<
ProductSpecVO
>
productSpecVOS
=
maps
.
get
(
e
.
getId
());
productInventoryVO
.
setProductSpecList
(
productSpecVOS
);
productInventoryVO
.
setSelect
(
d
.
getSelected
());
productInventoryVO
.
setProductSkuId
(
d
.
getProductSkuId
());
list
.
add
(
productInventoryVO
);
}
}
}
// 组装产品清单
industrySpecDTO
.
setProductInventoryList
(
list
);
}
else
{
// 指定的直接拿指定的数据
for
(
ProductSpecVO
productSpecVO
:
d
.
getProductSpecList
())
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecVO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecVO
.
getProductSkuId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
return
ResultBody
.
success
(
industrySpecDTO
);
}
}
}
/**
* 编辑行业规格信息
*
* @param param
* @return
*/
@Override
public
ResultBody
editIndustrySpec
(
IndustrySpecVO
param
)
{
int
count
=
industrySpecDao
.
countIndustrySpec
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
countName
=
industrySpecDao
.
countSpecName
(
param
);
if
(
countName
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 修改行业规格基本信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
updateIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
// 先获取绑定的的产品skuId
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
param
.
getId
());
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
().
map
(
IndustryProductInventoryDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 批量删除原来绑定的产品规格信息
if
(
industryProductInventoryIds
.
size
()
!=
0
)
{
industrySpecDao
.
batchDeleteInventorySpec
(
industryProductInventoryIds
);
/**
* 获取行业规格信息
*
* @param industrySpecId
* @return
*/
@Override
public
ResultBody
getIndustrySpecDetail
(
Integer
industrySpecId
)
{
// 查询当前行业规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecId
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 初始化行业规格DTO
IndustrySpecDTO
industrySpecDTO
;
// 获取行业规格的基本信息
IndustrySpecDO
industrySpec
=
industrySpecDao
.
getIndustrySpecById
(
industrySpecId
);
industrySpecDTO
=
industrySpec
.
buildIndustrySpecDTO
();
// 获取这个规格下的产品sku信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
industrySpecId
);
// 获取产品skuId
List
<
Integer
>
productSkuId
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getProductSkuId
)
.
collect
(
Collectors
.
toList
());
// 分别查出产品sku的详细信息
List
<
ProductDO
>
productSkuList
=
productDao
.
listProductSkuDO
(
productSkuId
);
// 查出产品sku对应的品牌的信息
Set
<
Integer
>
brandInfoIds
=
productSkuList
.
stream
().
map
(
ProductDO:
:
getBrandInfoId
).
collect
(
Collectors
.
toSet
());
List
<
BrandInfoDO
>
brandInfoList
=
brandManageDao
.
listBrandInfoByIds
(
brandInfoIds
);
// 拿到行业产品清单id的集合
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
// 再分别查出产品规格id
List
<
InventorySpecDO
>
inventorySpecList
=
productDao
.
listInventorySpecInfo
(
industryProductInventoryIds
);
if
(
inventorySpecList
.
size
()
!=
0
)
{
// 获取所有产品规格id
List
<
Integer
>
productSpecIds
=
inventorySpecList
.
stream
()
.
map
(
InventorySpecDO:
:
getProductSpecId
)
.
collect
(
Collectors
.
toList
());
// 根据这些规格id查询规格信息
List
<
ProductSpecDO
>
productSpecInfoList
=
productDao
.
listProductSpecInfo
(
productSpecIds
);
// 构建产品规格信息
List
<
ProductSpecVO
>
productSpecList
=
productSpecInfoList
.
stream
()
.
map
(
d
->
{
ProductSpecVO
productSpecVO
=
new
ProductSpecVO
();
productSpecVO
.
setSpecImage
(
d
.
getSpecImage
());
productSpecVO
.
setProductSkuId
(
d
.
getProductId
());
productSpecVO
.
setSpecName
(
d
.
getSpecName
());
productSpecVO
.
setId
(
d
.
getId
());
productSpecVO
.
setPartNo
(
d
.
getPartNo
());
productSpecVO
.
setVersionDesc
(
d
.
getVersionDesc
());
return
productSpecVO
;
})
.
collect
(
Collectors
.
toList
());
// 根据产品skuId分组
Map
<
Integer
,
List
<
ProductSpecVO
>>
maps
=
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecVO:
:
getProductSkuId
));
// 构建其余产品清单的信息
List
<
ProductInventoryVO
>
list
=
new
ArrayList
<>();
for
(
IndustryProductInventoryDO
d
:
industryProductInventory
)
{
for
(
ProductDO
e
:
productSkuList
)
{
GoodsProductSkuVO
goodsProductSkuVO
=
new
GoodsProductSkuVO
();
goodsProductSkuVO
.
setId
(
d
.
getId
());
goodsProductSkuVO
.
setProductName
(
e
.
getProductName
());
for
(
BrandInfoDO
b
:
brandInfoList
)
{
if
(
e
.
getBrandInfoId
().
equals
(
b
.
getId
()))
{
goodsProductSkuVO
.
setProductBrand
(
b
.
getBrandName
());
break
;
}
}
goodsProductSkuVO
.
setModel
(
e
.
getModel
());
ProductInventoryVO
productInventoryVO
=
new
ProductInventoryVO
();
productInventoryVO
.
setProductSku
(
goodsProductSkuVO
);
if
(
d
.
getProductSkuId
().
equals
(
e
.
getId
()))
{
// 匹配分组之后id相等的数据构建到ProductInventoryVO对象中
List
<
ProductSpecVO
>
productSpecVOS
=
maps
.
get
(
e
.
getId
());
productInventoryVO
.
setProductSpecList
(
productSpecVOS
);
productInventoryVO
.
setSelect
(
d
.
getSelected
());
productInventoryVO
.
setProductSkuId
(
d
.
getProductSkuId
());
list
.
add
(
productInventoryVO
);
}
}
// 批量删除绑定的产品sku信息
industrySpecDao
.
deleteIndustryProductInventory
(
param
.
getId
());
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
}
// 组装产品清单
industrySpecDTO
.
setProductInventoryList
(
list
);
}
return
ResultBody
.
success
(
industrySpecDTO
);
}
/**
* 编辑行业规格信息
*
* @param param
* @return
*/
@Override
public
ResultBody
editIndustrySpec
(
IndustrySpecVO
param
)
{
int
count
=
industrySpecDao
.
countIndustrySpec
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
countName
=
industrySpecDao
.
countSpecName
(
param
);
if
(
countName
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 修改行业规格基本信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
updateIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
// 先获取绑定的的产品skuId
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
param
.
getId
());
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
// 批量删除原来绑定的产品规格信息
if
(
industryProductInventoryIds
.
size
()
!=
0
)
{
industrySpecDao
.
batchDeleteInventorySpec
(
industryProductInventoryIds
);
}
// 批量删除绑定的产品sku信息
industrySpecDao
.
deleteIndustryProductInventory
(
param
.
getId
());
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
}
/**
* 列表页面行业规范
*
* @param pageNo 页面没有
* @param pageSize 页面大小
* @param industrySkuId 行业sku id
* @param keyword 关键字
* @return {@link ResultBody}
*/
@Override
public
ResultBody
listPageIndustrySpec
(
Integer
pageNo
,
Integer
pageSize
,
Integer
industrySkuId
,
String
keyword
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySpec
(
industrySkuId
,
keyword
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
));
}
List
<
IndustrySpecDO
>
industrySpecList
=
industrySpecDao
.
listPageIndustrySpec
((
pageNo
-
1
)
*
pageSize
,
pageSize
,
industrySkuId
,
keyword
);
List
<
Integer
>
specIds
=
industrySpecList
.
stream
().
map
(
IndustrySpecDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 根据规格id批量查询价格信息
List
<
IndustrySpecPriceDO
>
industrySpecPrice
=
industrySpecDao
.
getIndustrySpecPriceList
(
specIds
);
Map
<
Integer
,
List
<
IndustrySpecPriceDO
>>
priceMap
=
industrySpecPrice
.
stream
().
collect
(
Collectors
.
groupingBy
(
IndustrySpecPriceDO:
:
getIndustrySpecId
));
List
<
IndustrySpecDTO
>
list
=
industrySpecList
.
stream
().
map
(
d
->
{
IndustrySpecDTO
industrySpecDTO
=
d
.
buildIndustrySpecDTO
();
if
(!
CollectionUtils
.
isEmpty
(
priceMap
.
get
(
d
.
getId
())))
{
industrySpecDTO
.
setPriceList
(
priceMap
.
get
(
d
.
getId
()).
stream
().
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
).
collect
(
Collectors
.
toList
()));
}
return
industrySpecDTO
;
}).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
));
/**
* 列表页面行业规范
*
* @param pageNo 页面没有
* @param pageSize 页面大小
* @param industrySkuId 行业sku id
* @param keyword 关键字
* @return {@link ResultBody}
*/
@Override
public
ResultBody
listPageIndustrySpec
(
Integer
pageNo
,
Integer
pageSize
,
Integer
industrySkuId
,
String
keyword
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySpec
(
industrySkuId
,
keyword
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
));
}
List
<
IndustrySpecDO
>
industrySpecList
=
industrySpecDao
.
listPageIndustrySpec
(
(
pageNo
-
1
)
*
pageSize
,
pageSize
,
industrySkuId
,
keyword
);
List
<
Integer
>
specIds
=
industrySpecList
.
stream
().
map
(
IndustrySpecDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 根据规格id批量查询价格信息
List
<
IndustrySpecPriceDO
>
industrySpecPrice
=
industrySpecDao
.
getIndustrySpecPriceList
(
specIds
);
Map
<
Integer
,
List
<
IndustrySpecPriceDO
>>
priceMap
=
industrySpecPrice
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
IndustrySpecPriceDO:
:
getIndustrySpecId
));
List
<
IndustrySpecDTO
>
list
=
industrySpecList
.
stream
()
.
map
(
d
->
{
IndustrySpecDTO
industrySpecDTO
=
d
.
buildIndustrySpecDTO
();
if
(!
CollectionUtils
.
isEmpty
(
priceMap
.
get
(
d
.
getId
())))
{
industrySpecDTO
.
setPriceList
(
priceMap
.
get
(
d
.
getId
()).
stream
()
.
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
)
.
collect
(
Collectors
.
toList
()));
}
return
industrySpecDTO
;
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
));
}
/**
* 行业规格价格配置
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
industrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecCPQQ
.
getIndustrySpecId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
/**
* 行业规格价格配置
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
industrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecCPQQ
.
getIndustrySpecId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
}
private
List
<
IndustrySpecPriceDO
>
getIndustrySpecPriceDOS
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 批量插入规格价格
return
industrySpecCPQQ
.
getSpecPrice
().
stream
().
map
(
d
->
{
IndustrySpecPriceDO
industrySpecPriceDO
=
new
IndustrySpecPriceDO
();
industrySpecPriceDO
.
setCooperationTag
(
d
.
getCooperationTag
());
industrySpecPriceDO
.
setType
(
industrySpecCPQQ
.
getType
());
industrySpecPriceDO
.
setPrice
(
d
.
getPrice
());
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
))
{
private
List
<
IndustrySpecPriceDO
>
getIndustrySpecPriceDOS
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 批量插入规格价格
return
industrySpecCPQQ
.
getSpecPrice
().
stream
()
.
map
(
d
->
{
IndustrySpecPriceDO
industrySpecPriceDO
=
new
IndustrySpecPriceDO
();
industrySpecPriceDO
.
setCooperationTag
(
d
.
getCooperationTag
());
industrySpecPriceDO
.
setType
(
industrySpecCPQQ
.
getType
());
industrySpecPriceDO
.
setPrice
(
d
.
getPrice
());
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
))
{
industrySpecPriceDO
.
setLeaseTerm
(
industrySpecCPQQ
.
getLeaseTerm
());
}
industrySpecPriceDO
.
setIndustrySpecId
(
industrySpecCPQQ
.
getIndustrySpecId
());
return
industrySpecPriceDO
;
}).
collect
(
Collectors
.
toList
());
}
}
industrySpecPriceDO
.
setIndustrySpecId
(
industrySpecCPQQ
.
getIndustrySpecId
());
return
industrySpecPriceDO
;
})
.
collect
(
Collectors
.
toList
());
}
/**
* 行业规格价格配置修改
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
updateIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 先删除原来该规格下的所有价格配置信息
industrySpecDao
.
removeIndustrySpecCPQ
(
industrySpecCPQQ
);
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
}
/**
* 行业规格价格配置修改
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
updateIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 先删除原来该规格下的所有价格配置信息
industrySpecDao
.
removeIndustrySpecCPQ
(
industrySpecCPQQ
);
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
}
public
ResultBody
insertSpecPrice
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
List
<
IndustrySpecPriceDO
>
list
=
getIndustrySpecPriceDOS
(
industrySpecCPQQ
);
// 批量插入规格价格
if
(
industrySpecCPQQ
.
getType
().
equals
(
0
))
{
int
status
=
industrySpecDao
.
batchInsertSpecPrice
(
list
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
}
else
{
// 批量插入租赁价格
industrySpecDao
.
batchInsertLeaseSpecPrice
(
list
);
}
return
ResultBody
.
success
();
public
ResultBody
insertSpecPrice
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
List
<
IndustrySpecPriceDO
>
list
=
getIndustrySpecPriceDOS
(
industrySpecCPQQ
);
// 批量插入规格价格
if
(
industrySpecCPQQ
.
getType
().
equals
(
0
))
{
int
status
=
industrySpecDao
.
batchInsertSpecPrice
(
list
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
}
else
{
// 批量插入租赁价格
industrySpecDao
.
batchInsertLeaseSpecPrice
(
list
);
}
return
ResultBody
.
success
();
}
/**
* 获取配置价格信息
*
* @param industrySpecCPQQ 行业规范
* @return {@link ResultBody}
*/
@Override
public
ResultBody
getIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
)
&&
industrySpecCPQQ
.
getLeaseTerm
()
==
null
)
{
return
ResultBody
.
error
(
"租赁期限不能为空!"
);
}
List
<
IndustrySpecPriceDO
>
industrySpecPriceList
=
industrySpecDao
.
getIndustrySpecCPQ
(
industrySpecCPQQ
);
List
<
IndustrySpecPriceDTO
>
list
=
industrySpecPriceList
.
stream
()
.
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
/**
* 获取配置价格信息
*
* @param industrySpecCPQQ 行业规范
* @return {@link ResultBody}
*/
@Override
public
ResultBody
getIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
)
&&
industrySpecCPQQ
.
getLeaseTerm
()
==
null
)
{
return
ResultBody
.
error
(
"租赁期限不能为空!"
);
}
List
<
IndustrySpecPriceDO
>
industrySpecPriceList
=
industrySpecDao
.
getIndustrySpecCPQ
(
industrySpecCPQQ
);
List
<
IndustrySpecPriceDTO
>
list
=
industrySpecPriceList
.
stream
()
.
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
)
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
}
@Override
public
ResultBody
removeIndustrySku
(
Integer
id
)
{
// 查询该sku下是否有行业规格存在
int
specCount
=
industrySpecDao
.
countIndustrySpecBySkuId
(
id
);
if
(
specCount
<=
0
)
{
// 删除
industrySpecDao
.
removeIndustrySku
(
id
);
return
ResultBody
.
success
();
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_EXIST_UNDER_THE_SKU
);
}
@Override
public
ResultBody
removeIndustrySku
(
Integer
id
)
{
// 查询该sku下是否有行业规格存在
int
specCount
=
industrySpecDao
.
countIndustrySpecBySkuId
(
id
);
if
(
specCount
<=
0
)
{
// 删除
industrySpecDao
.
removeIndustrySku
(
id
);
return
ResultBody
.
success
();
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_EXIST_UNDER_THE_SKU
);
}
}
/**
* 删除行业规格
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
removeIndustrySpec
(
Integer
id
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取该规格下绑定的商品的信息
RemoveSkuDTO
removeSkuDTO
=
new
RemoveSkuDTO
();
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpecList
=
industrySpecDao
.
listMallIndustrySpec
(
id
);
if
(
mallIndustrySkuInfoSpecList
.
size
()
!=
0
)
{
List
<
String
>
goodsName
=
new
ArrayList
<>();
mallIndustrySkuInfoSpecList
.
forEach
(
d
->
goodsName
.
add
(
d
.
getGoodsName
()));
removeSkuDTO
.
setGoodsName
(
goodsName
);
return
ResultBody
.
success
(
removeSkuDTO
);
}
else
{
// 根据规格id获取规格清单绑定的信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
id
);
if
(
industryProductInventory
.
size
()
!=
0
)
{
// 删除行业绑定的清单
industrySpecDao
.
removeIndustryProductInventory
(
industryProductInventory
.
stream
().
map
(
IndustryProductInventoryDO:
:
getId
).
collect
(
Collectors
.
toList
()));
List
<
Integer
>
ids
=
industryProductInventory
.
stream
().
map
(
IndustryProductInventoryDO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
InventorySpecDO
>
inventorySpecList
=
industrySpecDao
.
listInventorySpec
(
ids
);
// 删除
industrySpecDao
.
removeInventorySpec
(
inventorySpecList
.
stream
().
map
(
InventorySpecDO:
:
getId
).
collect
(
Collectors
.
toList
()));
}
industrySpecDao
.
removeIndustrySpec
(
id
);
return
ResultBody
.
success
();
}
/**
* 删除行业规格
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
removeIndustrySpec
(
Integer
id
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取该规格下绑定的商品的信息
RemoveSkuDTO
removeSkuDTO
=
new
RemoveSkuDTO
();
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpecList
=
industrySpecDao
.
listMallIndustrySpec
(
id
);
if
(
mallIndustrySkuInfoSpecList
.
size
()
!=
0
)
{
List
<
String
>
goodsName
=
new
ArrayList
<>();
mallIndustrySkuInfoSpecList
.
forEach
(
d
->
goodsName
.
add
(
d
.
getGoodsName
()));
removeSkuDTO
.
setGoodsName
(
goodsName
);
return
ResultBody
.
success
(
removeSkuDTO
);
}
else
{
// 根据规格id获取规格清单绑定的信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
id
);
if
(
industryProductInventory
.
size
()
!=
0
)
{
// 删除行业绑定的清单
industrySpecDao
.
removeIndustryProductInventory
(
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
()));
List
<
Integer
>
ids
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
List
<
InventorySpecDO
>
inventorySpecList
=
industrySpecDao
.
listInventorySpec
(
ids
);
// 删除
industrySpecDao
.
removeInventorySpec
(
inventorySpecList
.
stream
().
map
(
InventorySpecDO:
:
getId
).
collect
(
Collectors
.
toList
()));
}
industrySpecDao
.
removeIndustrySpec
(
id
);
return
ResultBody
.
success
();
}
//
// @Override
// public List<IndustrySpecPriceDTO> listAppGoodsPriceByTagId(Integer goodsInfoId, Integer tagInfoId) {
// List<IndustrySpecPriceDO> industrySpecPriceDOS = industrySpecDao.listAppGoodsPriceByTagId(goodsInfoId, tagInfoId);
// if (CollectionUtils.isEmpty(industrySpecPriceDOS)) {
// return null;
// }
// List<IndustrySpecPriceDTO> collect = industrySpecPriceDOS.stream().map(IndustrySpecPriceDO::buildIndustrySpecPriceDTO).collect(Collectors.toList());
// return collect;
// }
}
//
// @Override
// public List<IndustrySpecPriceDTO> listAppGoodsPriceByTagId(Integer goodsInfoId, Integer
// tagInfoId) {
// List<IndustrySpecPriceDO> industrySpecPriceDOS =
// industrySpecDao.listAppGoodsPriceByTagId(goodsInfoId, tagInfoId);
// if (CollectionUtils.isEmpty(industrySpecPriceDOS)) {
// return null;
// }
// List<IndustrySpecPriceDTO> collect =
// industrySpecPriceDOS.stream().map(IndustrySpecPriceDO::buildIndustrySpecPriceDTO).collect(Collectors.toList());
// return collect;
// }
}
src/main/java/com/mmc/pms/service/Impl/InspComtServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
Impl
;
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.dao.InspComtDao
;
import
com.mmc.pms.entity.InspComtDO
;
...
...
@@ -10,9 +9,7 @@ import org.springframework.stereotype.Service;
import
java.util.List
;
/**
* <p>
* 评论表 服务实现类
* </p>
*
* @author Pika
* @since 2023-06-09
...
...
@@ -20,11 +17,10 @@ import java.util.List;
@Service
public
class
InspComtServiceImpl
implements
InspComtService
{
@Autowired
private
InspComtDao
inspComtDao
;
@Autowired
private
InspComtDao
inspComtDao
;
@Override
public
List
<
InspComtDO
>
randomGetInspComtList
(
Integer
size
)
{
return
inspComtDao
.
randomGetInspComtList
(
size
);
}
@Override
public
List
<
InspComtDO
>
randomGetInspComtList
(
Integer
size
)
{
return
inspComtDao
.
randomGetInspComtList
(
size
);
}
}
src/main/java/com/mmc/pms/service/Impl/MiniProgramProductMallServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
...
...
@@ -100,7 +100,7 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall
GoodsSpecDTO
goodsSpecDTO
=
new
GoodsSpecDTO
();
goodsSpecDTO
.
setId
(
d
.
getId
())
.
setSkuId
(
d
.
getProd
Sku
Id
())
.
setSkuId
(
d
.
getProd
uct
Id
())
.
setGoodsSpecName
(
d
.
getProdSkuSpecName
())
.
setSkuName
(
d
.
getProductSkuName
())
.
setBrandInfoId
(
d
.
getBrandInfoId
())
...
...
@@ -190,7 +190,7 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall
return
productSpecVO
;
})
.
collect
(
Collectors
.
toList
());
Product
Sku
DO
productSkuDetail
=
ProductDO
productSkuDetail
=
goodsInfoDao
.
getProductSkuDetail
(
industryProductInventoryDO
.
getProductSkuId
());
GoodsProductSkuVO
goodsProductSkuVO
=
new
GoodsProductSkuVO
();
BeanUtils
.
copyProperties
(
productSkuDetail
,
goodsProductSkuVO
);
...
...
src/main/java/com/mmc/pms/service/Impl/ProductServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
...
...
@@ -37,7 +37,7 @@ public class ProductServiceImpl implements ProductSkuService {
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
Product
SkuDO
productSkuDO
=
new
ProductSku
DO
(
param
);
Product
DO
productSkuDO
=
new
Product
DO
(
param
);
productSkuDO
.
setCustomize
(
0
);
// 新增产品sku
int
status
=
productDao
.
insertProductSku
(
productSkuDO
);
...
...
@@ -50,11 +50,11 @@ public class ProductServiceImpl implements ProductSkuService {
@Override
public
ResultBody
getProductSkuDetail
(
Integer
id
)
{
// 校验此sku是否还存在或已删除
int
count
=
productDao
.
count
Sku
IsExist
(
id
);
int
count
=
productDao
.
count
Product
IsExist
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SKU
_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT
_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
Product
SkuDO
productSkuDO
=
productDao
.
getProductSku
Detail
(
id
);
Product
DO
productSkuDO
=
productDao
.
getProduct
Detail
(
id
);
return
ResultBody
.
success
(
productSkuDO
.
buildProductSkuDTO
());
}
...
...
@@ -65,7 +65,7 @@ public class ProductServiceImpl implements ProductSkuService {
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
Product
SkuDO
productSkuDO
=
new
ProductSku
DO
(
param
);
Product
DO
productSkuDO
=
new
Product
DO
(
param
);
int
status
=
productDao
.
updateProductSku
(
productSkuDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
...
...
@@ -82,14 +82,14 @@ public class ProductServiceImpl implements ProductSkuService {
}
Integer
pageNo
=
productSkuQO
.
getPageNo
();
productSkuQO
.
buildCurrentPage
();
List
<
Product
Sku
DO
>
productSkuList
=
productDao
.
listPageProductSku
(
productSkuQO
);
List
<
ProductDO
>
productSkuList
=
productDao
.
listPageProductSku
(
productSkuQO
);
List
<
Integer
>
productSkuIds
=
productSkuList
.
stream
().
map
(
Product
Sku
DO:
:
getId
).
collect
(
Collectors
.
toList
());
productSkuList
.
stream
().
map
(
ProductDO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
getProductSpecList
(
productSkuIds
);
Map
<
Integer
,
List
<
ProductSpecDO
>>
productSpecMap
=
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecDO:
:
getProduct
Sku
Id
));
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecDO:
:
getProductId
));
List
<
ProductSkuDTO
>
list
=
productSkuList
.
stream
().
map
(
Product
Sku
DO:
:
buildProductSkuDTO
).
collect
(
Collectors
.
toList
());
productSkuList
.
stream
().
map
(
ProductDO:
:
buildProductSkuDTO
).
collect
(
Collectors
.
toList
());
list
.
stream
()
.
peek
(
d
->
{
...
...
src/main/java/com/mmc/pms/service/Impl/WebDeviceServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.auth.dto.UserAccountSimpleDTO
;
import
com.mmc.pms.common.ResultBody
;
...
...
src/main/java/com/mmc/pms/service/Impl/WebProductMallServiceImpl.java
浏览文件 @
8136e6e6
package
com
.
mmc
.
pms
.
service
.
I
mpl
;
package
com
.
mmc
.
pms
.
service
.
i
mpl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.dao.WebProductMallDao
;
...
...
@@ -8,7 +8,6 @@ import com.mmc.pms.entity.ProductCategory;
import
com.mmc.pms.model.other.dto.AdDTO
;
import
com.mmc.pms.model.qo.GoodsInfoQO
;
import
com.mmc.pms.model.sale.dto.GoodsInfoListDTO
;
import
com.mmc.pms.model.qo.GoodsInfoQO
;
import
com.mmc.pms.model.sale.dto.ProductCategoryDTO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.WebProductMallService
;
...
...
src/main/java/com/mmc/pms/service/impl/BackstageTaskServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.reflect.TypeToken
;
import
com.google.gson.Gson
;
import
com.mmc.pms.auth.dto.CompanyInfoDTO
;
import
com.mmc.pms.auth.dto.CompanyInfoVO
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.constant.DateConstant
;
import
com.mmc.pms.dao.BackstageTaskServiceDao
;
import
com.mmc.pms.dao.CategoriesDao
;
import
com.mmc.pms.entity.Categories
;
import
com.mmc.pms.entity.InspComtDO
;
import
com.mmc.pms.entity.ServiceDO
;
import
com.mmc.pms.feign.UserAppApi
;
import
com.mmc.pms.model.qo.CompanyInfoQO
;
import
com.mmc.pms.model.qo.ServiceQO
;
import
com.mmc.pms.model.work.dto.ServiceDTO
;
import
com.mmc.pms.model.work.dto.WorkServiceDTO
;
import
com.mmc.pms.model.work.vo.ServiceVO
;
import
com.mmc.pms.model.work.vo.UpAndDownServiceVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.BackstageTaskService
;
import
com.mmc.pms.service.InspComtService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RandomUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @Author LW
*
* @date 2023/6/8 9:59 概要:
*/
@Service
@Slf4j
public
class
BackstageTaskServiceImpl
implements
BackstageTaskService
{
@Autowired
private
BackstageTaskServiceDao
backstageTaskServiceDao
;
@Autowired
private
CategoriesDao
categoriesDao
;
@Autowired
private
UserAppApi
userAppApi
;
@Autowired
private
InspComtService
inspComtService
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Override
public
ResultBody
addWorkService
(
ServiceVO
param
,
Integer
userAccountId
)
{
ServiceDO
serviceDO
=
new
ServiceDO
(
param
,
userAccountId
);
backstageTaskServiceDao
.
insert
(
serviceDO
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
updateById
(
ServiceVO
param
)
{
ServiceDO
serviceDO
=
new
ServiceDO
(
param
);
backstageTaskServiceDao
.
update
(
serviceDO
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
deleteByIds
(
List
<
Integer
>
ids
)
{
if
(!
CollectionUtils
.
isEmpty
(
ids
))
{
backstageTaskServiceDao
.
deleteByIds
(
ids
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
<
ServiceDTO
>
queryById
(
Integer
id
,
HttpServletRequest
request
)
{
ServiceDO
serviceDO
=
backstageTaskServiceDao
.
queryById
(
id
);
String
token
=
userAppApi
.
getCompanyInfoById
(
serviceDO
.
getCompanyId
(),
request
.
getHeader
(
"token"
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
token
);
CompanyInfoDTO
companyInfoDTO
=
JSON
.
parseObject
(
String
.
valueOf
((
JSONObject
)
jsonObject
.
get
(
"result"
)),
CompanyInfoDTO
.
class
);
String
companyName
=
companyInfoDTO
.
getCompanyName
();
ServiceDTO
serviceDTO
=
new
ServiceDTO
(
serviceDO
,
companyName
);
Map
<
Integer
,
String
>
categoriesNameMap
=
getCategoriesNameByIds
(
Arrays
.
asList
(
serviceDTO
.
getApplicationId
(),
serviceDTO
.
getIndustryId
()));
if
(!
CollectionUtils
.
isEmpty
(
categoriesNameMap
))
{
serviceDTO
.
setApplicationName
(
categoriesNameMap
.
get
(
serviceDTO
.
getApplicationId
()));
serviceDTO
.
setIndustryName
(
categoriesNameMap
.
get
(
serviceDTO
.
getIndustryId
()));
}
List
<
InspComtDO
>
inspComtList
=
RandomGetInspComt
(
id
,
20
,
200
);
serviceDTO
.
setInspComtList
(
inspComtList
);
serviceDTO
.
setInspComtAmount
(
inspComtList
.
size
());
return
ResultBody
.
success
(
serviceDTO
);
}
private
Map
<
Integer
,
String
>
getCategoriesNameByIds
(
List
<
Integer
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
new
HashMap
<>();
}
Set
<
Integer
>
idSet
=
new
HashSet
<>();
for
(
Integer
id
:
ids
)
{
idSet
.
add
(
id
);
}
List
<
Categories
>
categories
=
categoriesDao
.
getCategoriesListByIds
(
idSet
);
if
(
CollectionUtils
.
isEmpty
(
categories
))
{
return
new
HashMap
<>();
}
return
categories
.
stream
()
.
collect
(
Collectors
.
toMap
(
Categories:
:
getId
,
d
->
d
.
getName
(),
(
k1
,
k2
)
->
k1
));
}
@Override
public
PageResult
queryServiceManagerList
(
ServiceQO
param
,
Integer
userAccountId
,
CompanyInfoVO
companyInfoVO
)
{
int
count
=
backstageTaskServiceDao
.
count
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
param
.
setCompanyId
(
companyInfoVO
.
getId
());
param
.
setCompanyType
(
companyInfoVO
.
getCompanyType
());
List
<
ServiceDO
>
services
=
backstageTaskServiceDao
.
queryAllByLimit
(
param
);
List
<
ServiceDTO
>
pageList
=
setApplicationNameAndIndustryName
(
services
);
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
);
}
private
List
<
ServiceDTO
>
setApplicationNameAndIndustryName
(
List
<
ServiceDO
>
services
)
{
List
<
Integer
>
list
=
new
ArrayList
<>();
for
(
ServiceDO
service
:
services
)
{
list
.
add
(
service
.
getApplicationId
());
list
.
add
(
service
.
getIndustryId
());
}
Map
<
Integer
,
String
>
categoriesNameMap
=
getCategoriesNameByIds
(
list
);
List
<
ServiceDTO
>
pageList
=
services
.
stream
()
.
map
(
d
->
{
ServiceDTO
serviceDTO
=
new
ServiceDTO
(
d
);
serviceDTO
.
setApplicationName
(
categoriesNameMap
.
get
(
d
.
getApplicationId
()));
serviceDTO
.
setIndustryName
(
categoriesNameMap
.
get
(
d
.
getIndustryId
()));
return
serviceDTO
;
})
.
collect
(
Collectors
.
toList
());
return
pageList
;
}
@Override
@Transactional
public
PageResult
queryWorkServiceList
(
ServiceQO
param
,
HttpServletRequest
request
)
{
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
Integer
>
userIds
=
null
;
Integer
provinceCode
=
param
.
getProvinceId
();
if
(
provinceCode
!=
null
)
{
userIds
=
userAppApi
.
feignListUserAccountIds
(
provinceCode
,
null
,
null
,
null
);
if
(
userIds
==
null
||
userIds
.
size
()
==
0
)
{
userIds
=
Arrays
.
asList
(-
1
);
}
}
List
<
Integer
>
categoriesIds
=
param
.
getCategoryId
();
int
count
=
backstageTaskServiceDao
.
conditionCount
(
param
,
categoriesIds
,
userIds
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
List
<
ServiceDO
>
pageList
=
backstageTaskServiceDao
.
queryPageByLimit
(
param
,
categoriesIds
,
userIds
);
List
<
WorkServiceDTO
>
workServiceDTOList
=
getWorkServiceDTOS
(
pageList
,
request
);
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
workServiceDTOList
);
}
@Override
public
List
<
ServiceDTO
>
feignQueryWorkServiceListById
(
List
<
Integer
>
ids
)
{
return
backstageTaskServiceDao
.
QueryWorkServiceListById
(
ids
);
}
@Override
public
ResultBody
batchUpAndDownWorkService
(
UpAndDownServiceVO
param
)
{
if
(!
CollectionUtils
.
isEmpty
(
param
.
getIds
()))
{
backstageTaskServiceDao
.
batchUpAndDownWorkService
(
param
);
}
return
ResultBody
.
success
();
}
@Override
public
Integer
getWorkServiceCountByCategoriesId
(
List
<
Integer
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
0
;
}
return
backstageTaskServiceDao
.
getWorkServiceCountByCategoriesId
(
ids
);
}
@Override
public
ResultBody
queryByIdCount
(
Integer
companyId
)
{
return
ResultBody
.
success
(
backstageTaskServiceDao
.
queryByIdCount
(
companyId
));
}
private
List
<
WorkServiceDTO
>
getWorkServiceDTOS
(
List
<
ServiceDO
>
pageList
,
HttpServletRequest
request
)
{
String
companyInfoVOS
=
userAppApi
.
listCompanyPage
(
new
CompanyInfoQO
(
1
,
100000
),
request
.
getHeader
(
"token"
));
JSONObject
jsonObject
=
JSON
.
parseObject
(
companyInfoVOS
);
JSONObject
jsonObject1
=
JSON
.
parseObject
(
String
.
valueOf
(
jsonObject
.
get
(
"result"
)));
List
<
CompanyInfoVO
>
companyInfoList
=
new
Gson
()
.
fromJson
(
new
Gson
().
toJson
(
jsonObject1
.
get
(
"list"
)),
new
TypeToken
<
List
<
CompanyInfoVO
>>()
{}.
getType
());
String
companyName
=
""
;
List
<
WorkServiceDTO
>
workServiceDTOList
=
new
ArrayList
<>();
for
(
ServiceDO
item
:
pageList
)
{
for
(
CompanyInfoVO
companyInfoVO
:
companyInfoList
)
{
if
(
item
.
getCompanyId
().
equals
(
companyInfoVO
.
getId
()))
{
companyName
=
companyInfoVO
.
getCompanyName
();
}
}
List
<
InspComtDO
>
inspComtDOS
=
generateComments
(
item
);
WorkServiceDTO
workServiceDTO
=
WorkServiceDTO
.
builder
()
.
id
(
item
.
getId
())
.
serviceName
(
item
.
getServiceName
())
.
companyId
(
item
.
getCompanyId
())
.
companyName
(
companyName
)
.
coverPlan
(
item
.
getCoverPlan
())
.
serviceIntroduction
(
item
.
getServiceIntroduction
())
.
video
(
item
.
getVideo
())
.
shareCard
(
item
.
getShareCard
())
.
inspComtList
(
inspComtDOS
)
.
inspComtAmount
(
inspComtDOS
.
size
())
.
build
();
workServiceDTOList
.
add
(
workServiceDTO
);
}
return
workServiceDTOList
;
}
/**
* 生成评论
*
* @param item
* @return
*/
private
List
<
InspComtDO
>
generateComments
(
ServiceDO
item
)
{
Date
newServiceHours
=
null
;
try
{
newServiceHours
=
DateUtils
.
parseDate
(
"2023-06-26 23:59:59"
,
DateConstant
.
YYYYMMDDHHMMSS
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
List
<
InspComtDO
>
inspComtDOS
;
// 在这个时间创建的服务信息属于新服务,生成评论的数量在3-5个之间;旧服务则生成20-200个之间
if
(
item
.
getCreateTime
().
after
(
newServiceHours
))
{
inspComtDOS
=
RandomGetInspComt
(
item
.
getId
(),
3
,
5
);
}
else
{
inspComtDOS
=
RandomGetInspComt
(
item
.
getId
(),
20
,
200
);
}
return
inspComtDOS
;
}
/** 根据id随机获取N条的评论 */
private
List
<
InspComtDO
>
RandomGetInspComt
(
Integer
id
,
Integer
min
,
Integer
max
)
{
String
listStr
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
id
);
List
<
InspComtDO
>
inspComtRandomList
=
null
;
if
(
StringUtils
.
isNotBlank
(
listStr
))
{
inspComtRandomList
=
JSONArray
.
parseArray
(
listStr
,
InspComtDO
.
class
);
}
else
{
inspComtRandomList
=
inspComtService
.
randomGetInspComtList
(
RandomUtils
.
nextInt
(
min
,
max
));
String
toJSONString
=
JSONObject
.
toJSONString
(
inspComtRandomList
);
redisTemplate
.
opsForValue
().
set
(
id
,
toJSONString
);
}
return
inspComtRandomList
;
}
}
src/main/java/com/mmc/pms/service/impl/BrandManageServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.BrandManageDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.entity.BrandInfoDO
;
import
com.mmc.pms.model.sale.dto.BrandInfoDTO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.BrandManageService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @Author LW
*
* @date 2023/3/14 13:27 概要:
*/
@Service
public
class
BrandManageServiceImpl
implements
BrandManageService
{
@Autowired
private
BrandManageDao
brandManageDao
;
@Resource
private
ProductDao
productDao
;
/**
* 添加品牌信息
*
* @param brandName 品牌名称
* @return {@link ResultBody}
*/
@Override
public
ResultBody
addBrandInfo
(
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
null
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandManageDao
.
insertBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
}
/**
* 品牌列表信息
*
* @return {@link ResultBody}
*/
@Override
public
PageResult
listBrandInfo
(
Integer
pageNo
,
Integer
pageSize
)
{
int
count
=
brandManageDao
.
countBrandInfo
();
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
0
);
}
int
itemIndex
=
(
pageNo
-
1
)
*
pageSize
;
List
<
BrandInfoDO
>
brandInfo
=
brandManageDao
.
listBrandInfo
(
itemIndex
,
pageSize
);
List
<
BrandInfoDTO
>
brandInfoList
=
brandInfo
.
stream
().
map
(
BrandInfoDO:
:
buildBrandInfoDTO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
brandInfoList
);
}
/**
* 删除品牌信息
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
deleteBrandInfo
(
Integer
id
)
{
// 判断该品牌是否绑定产品信息
int
count
=
productDao
.
countProductSpecByBrandId
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
BRAND_DELETE_FAIL
);
}
brandManageDao
.
removeBrandInfoById
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
editBrandInfo
(
Integer
id
,
String
brandName
)
{
// 根据品牌名称判断是否存在
int
count
=
brandManageDao
.
countBrandInfoByName
(
id
,
brandName
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
BrandInfoDO
brandInfoDO
=
new
BrandInfoDO
(
brandName
);
brandInfoDO
.
setId
(
id
);
brandManageDao
.
updateBrandInfo
(
brandInfoDO
);
return
ResultBody
.
success
();
}
}
src/main/java/com/mmc/pms/service/impl/CategoriesServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.CategoriesDao
;
import
com.mmc.pms.dao.DirectoryDao
;
import
com.mmc.pms.dao.GoodsInfoDao
;
import
com.mmc.pms.entity.Categories
;
import
com.mmc.pms.entity.DirectoryDO
;
import
com.mmc.pms.entity.GoodsInfo
;
import
com.mmc.pms.feign.ImsAppApi
;
import
com.mmc.pms.model.categories.dto.AllCategoryDTO
;
import
com.mmc.pms.model.categories.dto.CategoriesDTO
;
import
com.mmc.pms.model.categories.dto.CategoriesInfoListDTO
;
import
com.mmc.pms.model.categories.dto.ClassifyInfoDTO
;
import
com.mmc.pms.model.categories.vo.ClassifyInfoVO
;
import
com.mmc.pms.model.categories.vo.CurriculumInfoVO
;
import
com.mmc.pms.model.categories.vo.DirectoryInfoVO
;
import
com.mmc.pms.model.categories.vo.RelevantBusinessVO
;
import
com.mmc.pms.model.sale.vo.QueryClassifyVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.BackstageTaskService
;
import
com.mmc.pms.service.CategoriesService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author lw
* @description 针对表【categories(通用分类表)】的数据库操作Service实现
* @createDate 2023-05-24 10:29:28
*/
@Service
@Slf4j
public
class
CategoriesServiceImpl
implements
CategoriesService
{
@Autowired
private
CategoriesDao
categoriesDao
;
@Resource
private
GoodsInfoDao
goodsInfoDao
;
@Autowired
private
DirectoryDao
directoryDao
;
@Autowired
private
BackstageTaskService
backstageTaskService
;
@Autowired
private
ImsAppApi
appApi
;
@Override
public
ResultBody
addOrEditDirectory
(
DirectoryInfoVO
param
)
{
int
type
=
categoriesDao
.
countUpdateDirectoryName
(
param
);
if
(
type
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
DIRECTORY_NAME_HAS_BEEN_EXIST
);
}
DirectoryDO
directory
=
new
DirectoryDO
(
param
);
if
(
param
.
getId
()
==
null
)
{
categoriesDao
.
insertDirectory
(
directory
);
}
else
{
// 获取默认目录信息
DirectoryDO
directoryDO
=
categoriesDao
.
selectDirectoryById
(
param
.
getId
());
if
(
directoryDO
!=
null
&&
!
directoryDO
.
getDirectoryName
().
equals
(
param
.
getDirectoryName
()))
{
return
ResultBody
.
error
(
ResultEnum
.
DEFAULT_DIRECTORY
);
}
categoriesDao
.
updateDirectory
(
directory
);
}
return
ResultBody
.
success
();
}
@Override
public
PageResult
directoryList
(
Integer
pageNo
,
Integer
pageSize
,
Integer
type
)
{
int
count
=
categoriesDao
.
countDirectoryList
();
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
);
}
List
<
DirectoryDO
>
directoryList
=
categoriesDao
.
directoryList
((
pageNo
-
1
)
*
pageSize
,
pageSize
,
type
);
List
<
DirectoryInfoVO
>
list
=
directoryList
.
stream
().
map
(
DirectoryDO:
:
buildDirectoryInfoVO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
);
}
@Override
public
ResultBody
removeDirectory
(
Integer
id
)
{
// 查询该目录下是否有分类有的话就不给删除
int
count
=
categoriesDao
.
countDirectory
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
THERE_ARE_CATEGORIES_IN_THE_DIRECTORY
);
}
DirectoryDO
defaultCount
=
categoriesDao
.
selectDirectoryById
(
id
);
if
(
defaultCount
!=
null
)
{
return
ResultBody
.
error
(
ResultEnum
.
DEFAULT_DIRECTORY
);
}
categoriesDao
.
removeDirectory
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
addClassification
(
ClassifyInfoVO
classifyInfoVO
)
{
int
count
=
categoriesDao
.
countClassificationByName
(
classifyInfoVO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_NAME_HAS_BEEN_EXIST
);
}
Categories
categories
=
new
Categories
(
classifyInfoVO
);
if
(
classifyInfoVO
.
getPid
()
==
0
)
{
if
(
classifyInfoVO
.
getIcon
()
!=
null
)
{
int
typeCount
=
categoriesDao
.
getCountCategoriesByPid
(
0
,
classifyInfoVO
.
getType
());
categories
.
setSort
(
typeCount
+
1
);
categoriesDao
.
insertClassification
(
categories
);
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_ICON_NOT_NULL
);
}
}
else
{
categoriesDao
.
insertClassification
(
categories
);
}
return
ResultBody
.
success
();
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
updateClassification
(
ClassifyInfoVO
classifyInfoVO
)
{
int
count
=
categoriesDao
.
countClassificationByName
(
classifyInfoVO
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_NAME_HAS_BEEN_EXIST
);
}
if
(
classifyInfoVO
.
getPid
()
==
0
)
{
if
(
classifyInfoVO
.
getIcon
()
!=
null
)
{
categoriesDao
.
updateClassification
(
classifyInfoVO
);
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
WARE_TYPE_ICON_NOT_NULL
);
}
}
else
{
categoriesDao
.
updateClassification
(
classifyInfoVO
);
}
return
ResultBody
.
success
();
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
exchangeSortType
(
Integer
firstId
,
Integer
secondId
)
{
Categories
firstCategories
=
categoriesDao
.
getGoodsGroupById
(
firstId
);
Categories
secondCategories
=
categoriesDao
.
getGoodsGroupById
(
secondId
);
int
updateCount1
=
categoriesDao
.
updateTypeSort
(
firstId
,
secondCategories
.
getSort
());
int
updateCount2
=
categoriesDao
.
updateTypeSort
(
secondId
,
firstCategories
.
getSort
());
if
(
updateCount1
==
updateCount2
)
{
return
ResultBody
.
success
();
}
else
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultBody
.
error
(
"排序失败"
);
}
}
@Override
public
PageResult
getClassificationList
(
QueryClassifyVO
queryClassifyVO
)
{
int
count
=
categoriesDao
.
countListClassification
(
queryClassifyVO
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
queryClassifyVO
.
getPageNo
(),
queryClassifyVO
.
getPageSize
(),
count
);
}
int
pageNo
=
queryClassifyVO
.
getPageNo
();
queryClassifyVO
.
buildCurrentPage
();
List
<
Categories
>
categories
=
categoriesDao
.
selectAllClassification
(
queryClassifyVO
);
List
<
ClassifyInfoDTO
>
categoriesList
=
categories
.
stream
().
map
(
Categories:
:
buildClassifyInfoDTO
).
collect
(
Collectors
.
toList
());
List
<
ClassifyInfoDTO
>
topLevelCategories
=
new
ArrayList
<>();
Map
<
Integer
,
ClassifyInfoDTO
>
categoriesMap
=
new
HashMap
<>();
// 将每个数据模型对象添加到Map中,以便在递归过程中查找它们的父母
for
(
ClassifyInfoDTO
category
:
categoriesList
)
{
category
.
setChildren
(
new
ArrayList
<>());
categoriesMap
.
put
(
category
.
getId
(),
category
);
}
// 构建树结构
for
(
ClassifyInfoDTO
category
:
categoriesList
)
{
if
(
category
.
getPid
()
==
0
)
{
topLevelCategories
.
add
(
category
);
}
else
{
ClassifyInfoDTO
parent
=
categoriesMap
.
get
(
category
.
getPid
());
parent
.
getChildren
().
add
(
category
);
}
}
return
PageResult
.
buildPage
(
pageNo
,
queryClassifyVO
.
getPageSize
(),
count
,
topLevelCategories
);
}
@Override
public
ResultBody
getClassifyDetails
(
Integer
id
)
{
Categories
goodsGroup
=
categoriesDao
.
getGoodsGroupById
(
id
);
return
ResultBody
.
success
(
goodsGroup
==
null
?
null
:
goodsGroup
.
buildClassifyDetailsDTO
());
}
@Override
public
ResultBody
queryRelevantBusiness
(
Integer
id
,
Integer
type
)
{
RelevantBusinessVO
relevantBusinessVO
=
new
RelevantBusinessVO
();
switch
(
type
)
{
case
0
:
List
<
GoodsInfo
>
goodsInfo
=
goodsInfoDao
.
ListGoodsInfoByCategoryId
(
id
);
if
(
CollectionUtils
.
isNotEmpty
(
goodsInfo
))
{
relevantBusinessVO
.
setRelevanceGoodsInfoVOs
(
goodsInfo
.
stream
()
.
map
(
GoodsInfo:
:
buildRelevanceGoodsInfoVO
)
.
collect
(
Collectors
.
toList
()));
return
ResultBody
.
success
(
relevantBusinessVO
);
}
break
;
default
:
return
ResultBody
.
error
(
"输入类型有误!"
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
getDirectoryList
(
Integer
type
)
{
List
<
DirectoryDO
>
directoryList
=
categoriesDao
.
getDirectoryList
(
type
);
List
<
DirectoryInfoVO
>
list
=
directoryList
.
stream
().
map
(
DirectoryDO:
:
buildDirectoryInfoVO
).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
}
@Override
public
List
<
Categories
>
getCategoriesListByDirectoryName
(
String
directoryName
)
{
DirectoryDO
directoryDO
=
directoryDao
.
getDirectoryByName
(
directoryName
);
List
<
Categories
>
categories
=
categoriesDao
.
getCategoriesByDirectoryId
(
directoryDO
.
getId
());
return
categories
;
}
@Override
public
ResultBody
getApplicationList
(
String
directoryName
)
{
List
<
Categories
>
categories
=
getCategoriesListByDirectoryName
(
directoryName
);
if
(
org
.
springframework
.
util
.
CollectionUtils
.
isEmpty
(
categories
))
{
return
ResultBody
.
success
();
}
List
<
CategoriesDTO
>
collect
=
categories
.
stream
().
map
(
CategoriesDTO:
:
new
).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
List
<
Categories
>
getCategoriesListByIds
(
Set
<
Integer
>
ids
)
{
if
(
CollectionUtils
.
isEmpty
(
ids
))
{
return
null
;
}
return
categoriesDao
.
getCategoriesListByIds
(
ids
);
}
@Override
public
List
<
AllCategoryDTO
>
feigQqueryCategoryInfoByType
(
Integer
type
)
{
List
<
DirectoryDO
>
categoryDirectoryList
=
getCategoryDirectoryList
(
type
);
if
(
CollectionUtils
.
isNotEmpty
(
categoryDirectoryList
))
{
List
<
AllCategoryDTO
>
allCategoryDTOList
=
categoryDirectoryList
.
stream
()
.
map
(
DirectoryDO:
:
buildAllCategoryDTO
)
.
collect
(
Collectors
.
toList
());
Map
<
Integer
,
List
<
CategoriesInfoListDTO
>>
categoryMap
=
getCategoryMap
(
allCategoryDTOList
);
addSubCategories
(
allCategoryDTOList
,
categoryMap
);
log
.
info
(
"Res: "
+
JSONObject
.
toJSON
(
allCategoryDTOList
));
return
allCategoryDTOList
;
}
return
null
;
}
@Override
public
ResultBody
deleteRelevantBusiness
(
Integer
id
)
{
int
count
=
goodsInfoDao
.
countGoodsInfoByCategoryId
(
id
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GROUP_DONT_DELETE
);
}
Integer
taskCount
=
backstageTaskService
.
getWorkServiceCountByCategoriesId
(
Collections
.
singletonList
(
id
));
if
(
taskCount
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GROUP_DONT_DELETE
);
}
List
<
CurriculumInfoVO
>
curriculumInfo
=
appApi
.
feignCurriculumInfoList
(
id
);
if
(
CollectionUtils
.
isNotEmpty
(
curriculumInfo
))
{
return
ResultBody
.
error
(
ResultEnum
.
GROUP_DONT_DELETE
);
}
// 获取分类信息
Categories
categories
=
categoriesDao
.
getGoodsGroupById
(
id
);
if
(
categories
!=
null
&&
categories
.
getParentId
().
equals
(
0
))
{
int
childCount
=
categoriesDao
.
countChildById
(
id
);
if
(
childCount
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GROUP_DONT_DELETE_BY_CHILD
);
}
}
categoriesDao
.
deleteById
(
id
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
queryCategoryInfoByType
(
Integer
type
)
{
List
<
DirectoryDO
>
categoryDirectoryList
=
getCategoryDirectoryList
(
type
);
if
(
CollectionUtils
.
isNotEmpty
(
categoryDirectoryList
))
{
List
<
AllCategoryDTO
>
allCategoryDTOList
=
categoryDirectoryList
.
stream
()
.
map
(
DirectoryDO:
:
buildAllCategoryDTO
)
.
collect
(
Collectors
.
toList
());
Map
<
Integer
,
List
<
CategoriesInfoListDTO
>>
categoryMap
=
getCategoryMap
(
allCategoryDTOList
);
addSubCategories
(
allCategoryDTOList
,
categoryMap
);
return
ResultBody
.
success
(
allCategoryDTOList
);
}
return
ResultBody
.
success
();
}
private
List
<
DirectoryDO
>
getCategoryDirectoryList
(
Integer
type
)
{
return
categoriesDao
.
getDirectoryList
(
type
);
}
private
Map
<
Integer
,
List
<
CategoriesInfoListDTO
>>
getCategoryMap
(
List
<
AllCategoryDTO
>
allCategoryDTOList
)
{
List
<
Integer
>
directoryIdIds
=
allCategoryDTOList
.
stream
()
.
map
(
AllCategoryDTO:
:
getDirectoryId
)
.
collect
(
Collectors
.
toList
());
List
<
Categories
>
categoriesList
=
categoriesDao
.
selectCategoryByDirectoryId
(
directoryIdIds
);
return
categoriesList
.
stream
()
.
map
(
Categories:
:
buildCategoriesInfoListDTO
)
.
collect
(
Collectors
.
groupingBy
(
CategoriesInfoListDTO:
:
getDirectoryId
));
}
private
void
addSubCategories
(
List
<
AllCategoryDTO
>
allCategoryDTOList
,
Map
<
Integer
,
List
<
CategoriesInfoListDTO
>>
categoryMap
)
{
for
(
AllCategoryDTO
allCategoryDTO
:
allCategoryDTOList
)
{
Optional
.
ofNullable
(
categoryMap
.
get
(
allCategoryDTO
.
getDirectoryId
()))
.
ifPresent
(
allCategoryDTO:
:
setCategoriesInfoListDTO
);
}
}
}
src/main/java/com/mmc/pms/service/impl/GoodsInfoServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.GoodsInfoDao
;
import
com.mmc.pms.dao.IndustrySpecDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.model.order.dto.OrderGoodsIndstDTO
;
import
com.mmc.pms.model.order.dto.OrderGoodsProdDTO
;
import
com.mmc.pms.model.order.dto.OrderGoodsProdDetailDTO
;
import
com.mmc.pms.model.qo.MallOrderGoodsInfoQO
;
import
com.mmc.pms.model.qo.ProductSpecPriceQO
;
import
com.mmc.pms.model.sale.dto.*
;
import
com.mmc.pms.model.sale.qo.MallGoodsQO
;
import
com.mmc.pms.model.sale.vo.*
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.GoodsInfoService
;
import
com.mmc.pms.util.CodeUtil
;
import
com.mmc.pms.util.TDateUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author 23214
* @description 针对表【goods_info(商品基本信息)】的数据库操作Service实现
* @createDate 2023-05-27 14:08:45
*/
@Service
public
class
GoodsInfoServiceImpl
implements
GoodsInfoService
{
@Resource
private
GoodsInfoDao
goodsInfoDao
;
@Resource
private
ProductDao
productDao
;
@Resource
private
com
.
mmc
.
pms
.
service
.
impl
.
ProductServiceImpl
productSkuService
;
@Resource
private
IndustrySpecDao
industrySpecDao
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
addGoods
(
GoodsAddVO
goodsAddVO
,
Integer
userAccountId
)
{
// 判断商品名称是否存在
if
(
goodsInfoDao
.
countGoodsInfoByName
(
goodsAddVO
)
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 判断商品详情中描述是否为空
if
(
goodsAddVO
.
getGoodsDetailVO
().
getGoodsDesc
()
==
null
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_DESC_IS_NOT_NULL
);
}
String
YYYY_MM_DD_HH_MM_SS
=
"yyyyMMddHHmmss"
;
// 初始化商品对象,并构建对象
GoodsInfo
goodsInfo
=
new
GoodsInfo
(
goodsAddVO
);
goodsInfo
.
setGoodsNo
(
"IUAV"
+
TDateUtil
.
getDateStr
(
new
Date
(),
YYYY_MM_DD_HH_MM_SS
)
+
CodeUtil
.
getRandomNum
(
4
));
// 暂未接入用户默认传1
goodsInfo
.
setAddGoodsUserId
(
1
);
goodsInfo
.
setSort
(
goodsInfoDao
.
countGoodsInfo
()
+
1
);
// 插入商品基本信息
goodsInfoDao
.
insertGoodsInfo
(
goodsInfo
);
// 调用图片视频插入信息方法
addGoodsImageInfo
(
goodsInfo
.
getId
(),
goodsAddVO
);
// 调用商品详情信息方法
addGoodsDetail
(
goodsInfo
.
getId
(),
goodsAddVO
.
getGoodsDetailVO
());
// 判断其他服务是否为空,不为空则插入
if
(!
CollectionUtils
.
isEmpty
(
goodsAddVO
.
getOtherService
()))
{
addOtherService
(
goodsAddVO
.
getOtherService
(),
goodsInfo
.
getId
());
}
// 调用产品规格的新增方法
if
(!
goodsAddVO
.
getDirectoryId
().
equals
(
2
))
{
// 添加产品规格信息
productSkuSpecOperation
(
goodsInfo
,
goodsAddVO
.
getProductSpec
());
}
else
{
industrySkuSpecOperation
(
goodsInfo
,
goodsAddVO
.
getProductSpec
());
}
return
ResultBody
.
success
();
}
/** 插入行业sku及规格信息 */
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
industrySkuSpecOperation
(
GoodsInfo
goodsInfo
,
List
<
GoodsProdSpecVO
>
productSpec
)
{
for
(
GoodsProdSpecVO
goodsSpecVO
:
productSpec
)
{
MallIndustrySkuInfoDO
mallIndustrySkuInfoDO
=
new
MallIndustrySkuInfoDO
(
goodsSpecVO
).
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的sku信息
goodsInfoDao
.
insertMallIndustrySkuInfo
(
mallIndustrySkuInfoDO
);
for
(
MallProductSpecVO
mallProductSpecVO
:
goodsSpecVO
.
getSpecIds
())
{
// 构建商品对应的规格信息
MallIndustrySkuInfoSpecDO
mallIndustrySkuInfoSpecDO
=
new
MallIndustrySkuInfoSpecDO
()
.
setIndustrySpecId
(
mallProductSpecVO
.
getMallSpecId
())
.
setMallIndustrySkuInfoId
(
mallIndustrySkuInfoDO
.
getId
())
.
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallIndustrySkuInfoSpec
(
mallIndustrySkuInfoSpecDO
);
}
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
productSkuSpecOperation
(
GoodsInfo
goodsInfo
,
List
<
GoodsProdSpecVO
>
productSpec
)
{
// 遍历规格信息,获取其中自定义的规格信息
List
<
GoodsProdSpecVO
>
customGoodsSpecList
=
productSpec
.
stream
().
filter
(
spec
->
spec
.
getFlag
().
equals
(
1
)).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
customGoodsSpecList
))
{
addCustomization
(
goodsInfo
,
customGoodsSpecList
);
}
// 遍历规格信息,获取其中非自定义的规格信息
List
<
GoodsProdSpecVO
>
goodsSpecList
=
productSpec
.
stream
().
filter
(
spec
->
spec
.
getFlag
().
equals
(
0
)).
collect
(
Collectors
.
toList
());
for
(
GoodsProdSpecVO
goodsSpecVO
:
goodsSpecList
)
{
MallProdInfoDO
mallProdSkuInfoDO
=
new
MallProdInfoDO
(
goodsSpecVO
)
.
setProductId
(
goodsSpecVO
.
getSkuId
())
.
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的sku信息
productDao
.
insertMallProdSkuInfo
(
mallProdSkuInfoDO
);
for
(
MallProductSpecVO
mallProductSpecVO
:
goodsSpecVO
.
getSpecIds
())
{
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
new
MallProdSkuInfoSpecDO
()
.
setProductSpecId
(
mallProductSpecVO
.
getMallSpecId
())
.
setMallProdSkuInfoId
(
mallProdSkuInfoDO
.
getId
())
.
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallProdSkuInfoSpec
(
mallProdSkuInfoSpecDO
);
}
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
MallProdInfoDO
buildMallProdSkuInfo
(
GoodsInfo
goodsInfo
,
GoodsProdSpecVO
goodsSpec
,
Integer
id
)
{
MallProdInfoDO
mallProdInfoDO
=
new
MallProdInfoDO
();
mallProdInfoDO
.
setGoodsInfoId
(
goodsInfo
.
getId
());
mallProdInfoDO
.
setProductId
(
id
);
mallProdInfoDO
.
setProdSkuSpecName
(
goodsSpec
.
getGoodsSpecName
());
mallProdInfoDO
.
setCategoriesId
(
goodsSpec
.
getCategoryId
());
mallProdInfoDO
.
setChooseType
(
goodsSpec
.
getChooseType
());
mallProdInfoDO
.
setMust
(
goodsSpec
.
getMust
());
mallProdInfoDO
.
setFlag
(
goodsSpec
.
getFlag
());
mallProdInfoDO
.
setSkuUnitId
(
goodsSpec
.
getSkuUnitId
());
return
mallProdInfoDO
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addCustomization
(
GoodsInfo
goodsInfo
,
List
<
GoodsProdSpecVO
>
customGoodsSpecList
)
{
// 遍历自定义规格信息
for
(
GoodsProdSpecVO
productSpec
:
customGoodsSpecList
)
{
// 构建商品对应的sku信息
ProductDO
productSkuDO
=
new
ProductDO
().
setProductName
(
productSpec
.
getProductName
()).
setCustomize
(
1
);
// 插入产品sku信息
productDao
.
insertProductSku
(
productSkuDO
);
MallProdInfoDO
mallProdInfoDO
=
buildMallProdSkuInfo
(
goodsInfo
,
productSpec
,
productSkuDO
.
getId
());
// 插入数据库商品对应的sku信息
productDao
.
insertMallProdSkuInfo
(
mallProdInfoDO
);
// 先将自定的信息存储到数据库中
productSpec
.
getCustomizeInfo
().
stream
()
.
peek
(
param
->
{
ProductSpecDO
productSpecDO
=
new
ProductSpecDO
()
.
setProductId
(
productSkuDO
.
getId
())
.
setVersionDesc
(
"自定义"
)
.
setSpecImage
(
param
.
getSpecImage
())
.
setSpecName
(
param
.
getSpecName
())
.
setPartNo
(
param
.
getPartNo
());
// 新增产品sku
productDao
.
insertProductSpec
(
productSpecDO
);
// 批量配置价格信息
ProductSpecCPQVO
productSpecCPQVO
=
param
.
getProductSpecCPQVO
();
if
(
productSpecCPQVO
!=
null
)
{
productSpecCPQVO
.
setProductSpecId
(
productSpecDO
.
getId
());
productSkuService
.
insertSpecPrice
(
productSpecCPQVO
);
}
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
new
MallProdSkuInfoSpecDO
()
.
setProductSpecId
(
productSpecDO
.
getId
())
.
setMallProdSkuInfoId
(
mallProdInfoDO
.
getId
())
.
setGoodsInfoId
(
goodsInfo
.
getId
());
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallProdSkuInfoSpec
(
mallProdSkuInfoSpecDO
);
})
.
collect
(
Collectors
.
toList
());
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addOtherService
(
List
<
Integer
>
otherService
,
Integer
goodsId
)
{
// 插入其他服务
List
<
GoodsServiceDO
>
otherList
=
otherService
.
stream
()
.
map
(
d
->
{
GoodsServiceDO
goodsServiceDO
=
new
GoodsServiceDO
();
goodsServiceDO
.
setGoodsInfoId
(
goodsId
);
goodsServiceDO
.
setSaleServiceId
(
d
);
return
goodsServiceDO
;
})
.
collect
(
Collectors
.
toList
());
goodsInfoDao
.
insertGoodsService
(
otherList
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addGoodsDetail
(
Integer
goodsId
,
GoodsDetailVO
goodsDetailVO
)
{
GoodsDetailDO
goodsDetailDO
=
new
GoodsDetailDO
(
goodsDetailVO
);
goodsDetailDO
.
setGoodsInfoId
(
goodsId
);
goodsInfoDao
.
insertGoodsDetail
(
goodsDetailDO
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addGoodsImageInfo
(
Integer
goodsId
,
GoodsAddVO
goodsAddVO
)
{
List
<
GoodsImgDO
>
list
=
goodsAddVO
.
getImages
().
stream
()
.
map
(
d
->
{
GoodsImgDO
goodsImgDO
=
new
GoodsImgDO
(
d
);
goodsImgDO
.
setGoodsInfoId
(
goodsId
);
return
goodsImgDO
;
})
.
collect
(
Collectors
.
toList
());
// 插入图片信息
goodsInfoDao
.
insertGoodsImgInfo
(
list
);
// 插入商品视频信息
if
(
goodsAddVO
.
getGoodsVideo
()
!=
null
)
{
GoodsVideoDO
goodsVideoDO
=
new
GoodsVideoDO
().
setGoodsInfoId
(
goodsId
).
setVideoUrl
(
goodsAddVO
.
getGoodsVideo
());
goodsInfoDao
.
insertVideoInfo
(
goodsVideoDO
);
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
editGoodsInfo
(
GoodsAddVO
goodsAddVO
)
{
// 判断商品是否还存在
int
count
=
goodsInfoDao
.
countGoodsInfoById
(
goodsAddVO
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF
);
}
// 判断商品名称是否存在
if
(
goodsInfoDao
.
countGoodsInfoByName
(
goodsAddVO
)
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 判断商品详情中描述是否为空
if
(
goodsAddVO
.
getGoodsDetailVO
().
getGoodsDesc
()
==
null
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_DESC_IS_NOT_NULL
);
}
// 初始化商品对象,并构建对象
GoodsInfo
goodsInfo
=
new
GoodsInfo
(
goodsAddVO
);
// 插入商品基本信息
goodsInfoDao
.
updateGoodsInfo
(
goodsInfo
);
// 修改商品详情信息
updateGoodsDetail
(
goodsAddVO
);
// 修改商品图片及视频信息
updateImageInfo
(
goodsAddVO
);
// 修改其他服务信息
updateOtherService
(
goodsAddVO
);
// 修改规格信息
if
(!
goodsAddVO
.
getDirectoryId
().
equals
(
2
))
{
updateMallProductSkuSpec
(
goodsAddVO
);
}
else
{
updateMallIndustrySkuSpec
(
goodsAddVO
);
}
return
ResultBody
.
success
();
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateMallIndustrySkuSpec
(
GoodsAddVO
goodsAddVO
)
{
// 先获取用户输入的商品绑定sku的id集合
Set
<
Integer
>
inputMallSkuIds
=
goodsAddVO
.
getProductSpec
().
stream
()
.
map
(
GoodsProdSpecVO:
:
getId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
// 从数据库获取该商品对应绑定的skuId的集合
List
<
MallIndustrySkuInfoDO
>
mallIndusSkuInfoList
=
goodsInfoDao
.
getMallIndustrySkuInfo
(
goodsAddVO
.
getId
());
List
<
Integer
>
dbMallSkuIds
=
mallIndusSkuInfoList
.
stream
()
.
map
(
MallIndustrySkuInfoDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
// 对比数据库id如果不在就删除
List
<
Integer
>
delIds
=
dbMallSkuIds
.
stream
()
.
filter
(
id
->
!
inputMallSkuIds
.
contains
(
id
))
.
collect
(
Collectors
.
toList
());
if
(
delIds
.
size
()
!=
0
)
{
// 先删除商品绑定sku下的spec信息
industrySpecDao
.
batchUpdateMallIndustrySpec
(
delIds
,
goodsAddVO
.
getId
());
industrySpecDao
.
batchUpdateMallIndustrySku
(
delIds
);
}
// 修改商品绑定的sku信息
List
<
GoodsProdSpecVO
>
updateGoodsSpec
=
goodsAddVO
.
getProductSpec
().
stream
().
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
List
<
MallIndustrySkuInfoDO
>
mallIndustrySkuInfoList
=
updateGoodsSpec
.
stream
()
.
map
(
d
->
{
MallIndustrySkuInfoDO
mallIndustrySkuInfoDO
=
new
MallIndustrySkuInfoDO
();
mallIndustrySkuInfoDO
.
setId
(
d
.
getId
())
.
setIndustrySkuId
(
d
.
getSkuId
())
.
setCategoriesId
(
d
.
getCategoryId
())
.
setIndustrySkuSpecName
(
d
.
getGoodsSpecName
())
.
setChooseType
(
d
.
getChooseType
())
.
setSkuUnitId
(
d
.
getSkuUnitId
())
.
setMust
(
d
.
getMust
());
return
mallIndustrySkuInfoDO
;
})
.
collect
(
Collectors
.
toList
());
// 批量修改sku的信息
industrySpecDao
.
batchUpdateMallIndustrySkuInfo
(
mallIndustrySkuInfoList
);
// 获取新的sku信息
List
<
GoodsProdSpecVO
>
list
=
goodsAddVO
.
getProductSpec
().
stream
()
.
filter
(
d
->
d
.
getId
()
==
null
)
.
collect
(
Collectors
.
toList
());
industrySkuSpecOperation
(
new
GoodsInfo
(
goodsAddVO
.
getId
()),
list
);
// 获取商品对应的skuId
List
<
Integer
>
mallSkuIds
=
goodsAddVO
.
getProductSpec
().
stream
()
.
map
(
GoodsProdSpecVO:
:
getId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toList
());
// 根据这些id查出下面对应的规格信息
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpecList
=
industrySpecDao
.
listMallIndustrySpecInfo
(
mallSkuIds
);
// 分组
Map
<
Integer
,
List
<
MallIndustrySkuInfoSpecDO
>>
dbSpecMap
=
mallIndustrySkuInfoSpecList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
MallIndustrySkuInfoSpecDO:
:
getMallIndustrySkuInfoId
));
List
<
GoodsProdSpecVO
>
goodsSpecList
=
goodsAddVO
.
getProductSpec
().
stream
()
.
filter
(
d
->
d
.
getId
()
!=
null
)
.
collect
(
Collectors
.
toList
());
for
(
GoodsProdSpecVO
goodsSpecVO
:
goodsSpecList
)
{
// 分组后的每一条商品绑定的规格信息
List
<
MallIndustrySkuInfoSpecDO
>
dbMallIndustrySkuSpecList
=
dbSpecMap
.
get
(
goodsSpecVO
.
getId
());
Set
<
Integer
>
inputMallSpecIds
=
goodsSpecVO
.
getSpecIds
().
stream
()
.
map
(
MallProductSpecVO:
:
getId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
List
<
Integer
>
delSpecId
=
dbMallIndustrySkuSpecList
.
stream
()
.
map
(
MallIndustrySkuInfoSpecDO:
:
getId
)
.
filter
(
id
->
!
inputMallSpecIds
.
contains
(
id
))
.
collect
(
Collectors
.
toList
());
if
(
delSpecId
.
size
()
!=
0
)
{
// 删除多余的spec信息
industrySpecDao
.
batchUpdateMallIndustSpec
(
delSpecId
,
goodsAddVO
.
getId
());
}
// 新增spec的信息
for
(
MallProductSpecVO
mallProductSpecVO
:
goodsSpecVO
.
getSpecIds
())
{
if
(
mallProductSpecVO
.
getId
()
==
null
)
{
MallIndustrySkuInfoSpecDO
mallIndustrySkuInfoSpecDO
=
new
MallIndustrySkuInfoSpecDO
()
.
setIndustrySpecId
(
mallProductSpecVO
.
getMallSpecId
())
.
setMallIndustrySkuInfoId
(
goodsSpecVO
.
getId
())
.
setGoodsInfoId
(
goodsAddVO
.
getId
());
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallIndustrySkuInfoSpec
(
mallIndustrySkuInfoSpecDO
);
}
}
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateMallProductSkuSpec
(
GoodsAddVO
goodsAddVO
)
{
GoodsInfo
goodsInfo
=
new
GoodsInfo
(
goodsAddVO
);
// 1、普通的sku修改逻辑
List
<
GoodsProdSpecVO
>
specInfo
=
goodsAddVO
.
getProductSpec
().
stream
()
.
filter
(
spec
->
!
spec
.
getFlag
().
equals
(
1
))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
specInfo
))
{
// 1.1先获取用户输入的商品绑定sku的id集合
List
<
GoodsProdSpecVO
>
updateGoodsSpec
=
specInfo
.
stream
().
filter
(
d
->
d
.
getId
()
!=
null
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
inputMallSkuIds
=
updateGoodsSpec
.
stream
().
map
(
GoodsProdSpecVO:
:
getId
).
collect
(
Collectors
.
toList
());
// 1.2从数据库获取该商品对应绑定的skuId的集合
List
<
MallProdInfoDO
>
mallProSkuInfoList
=
goodsInfoDao
.
getMallProSkuInfo
(
goodsAddVO
.
getId
());
List
<
Integer
>
dbMallSkuIds
=
mallProSkuInfoList
.
stream
().
map
(
MallProdInfoDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 对比数据库id如果不在就删除
List
<
Integer
>
delIds
=
dbMallSkuIds
.
stream
()
.
filter
(
id
->
!
inputMallSkuIds
.
contains
(
id
))
.
collect
(
Collectors
.
toList
());
if
(
delIds
.
size
()
!=
0
)
{
// 先删除商品绑定sku下的spec信息
goodsInfoDao
.
batchUpdateMallProSpec
(
delIds
,
goodsAddVO
.
getId
());
goodsInfoDao
.
batchUpdateMallProductSku
(
delIds
);
}
// 修改商品绑定的sku信息
List
<
MallProdInfoDO
>
mallProdSkuInfoList
=
updateGoodsSpec
.
stream
()
.
map
(
d
->
{
MallProdInfoDO
mallProdInfoDO
=
new
MallProdInfoDO
();
mallProdInfoDO
.
setId
(
d
.
getId
())
.
setProductId
(
d
.
getSkuId
())
.
setCategoriesId
(
d
.
getCategoryId
())
.
setProdSkuSpecName
(
d
.
getGoodsSpecName
())
.
setChooseType
(
d
.
getChooseType
())
.
setSkuUnitId
(
d
.
getSkuUnitId
())
.
setMust
(
d
.
getMust
());
return
mallProdInfoDO
;
})
.
collect
(
Collectors
.
toList
());
// 1.3批量修改sku的信息
for
(
MallProdInfoDO
mallProdInfoDO
:
mallProdSkuInfoList
)
{
goodsInfoDao
.
updateMallProdSkuInfo
(
mallProdInfoDO
);
}
// goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList);
// 1.4对新的sku进行操作
List
<
GoodsProdSpecVO
>
list
=
specInfo
.
stream
().
filter
(
d
->
d
.
getId
()
==
null
).
collect
(
Collectors
.
toList
());
productSkuSpecOperation
(
goodsInfo
,
list
);
// 获取商品对应的skuId
List
<
Integer
>
mallSkuIds
=
goodsAddVO
.
getProductSpec
().
stream
()
.
filter
(
d
->
d
.
getId
()
!=
null
)
.
map
(
GoodsProdSpecVO:
:
getId
)
.
collect
(
Collectors
.
toList
());
if
(
mallSkuIds
.
size
()
>
0
)
{
// 根据这些id查出下面对应的规格信息
List
<
MallProdSkuInfoSpecDO
>
mallProdSkuInfoSpecList
=
goodsInfoDao
.
listMallProdSpecInfo
(
mallSkuIds
);
// 分组
Map
<
Integer
,
List
<
MallProdSkuInfoSpecDO
>>
dbSpecMap
=
mallProdSkuInfoSpecList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
MallProdSkuInfoSpecDO:
:
getMallProdSkuInfoId
));
for
(
GoodsProdSpecVO
goodsSpecVO
:
updateGoodsSpec
)
{
// 分组后的每一条商品绑定的规格信息
List
<
MallProdSkuInfoSpecDO
>
dbMallProdSkuSpecList
=
dbSpecMap
.
get
(
goodsSpecVO
.
getId
());
Set
<
Integer
>
inputMallSpecIds
=
goodsSpecVO
.
getSpecIds
().
stream
()
.
map
(
MallProductSpecVO:
:
getId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
List
<
Integer
>
delSpecId
=
dbMallProdSkuSpecList
.
stream
()
.
map
(
MallProdSkuInfoSpecDO:
:
getId
)
.
filter
(
id
->
!
inputMallSpecIds
.
contains
(
id
))
.
collect
(
Collectors
.
toList
());
if
(
delSpecId
.
size
()
!=
0
)
{
// 删除多余的spec信息
goodsInfoDao
.
batchUpdateMallProdSpec
(
delSpecId
);
}
// 新增spec的信息
for
(
MallProductSpecVO
mallProductSpecVO
:
goodsSpecVO
.
getSpecIds
())
{
if
(
mallProductSpecVO
.
getId
()
==
null
)
{
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
new
MallProdSkuInfoSpecDO
()
.
setProductSpecId
(
mallProductSpecVO
.
getMallSpecId
())
.
setMallProdSkuInfoId
(
goodsSpecVO
.
getId
())
.
setGoodsInfoId
(
goodsAddVO
.
getId
());
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallProdSkuInfoSpec
(
mallProdSkuInfoSpecDO
);
}
}
}
}
}
// 2、对自定义的sku进行操作
List
<
GoodsProdSpecVO
>
zdySpecInfo
=
goodsAddVO
.
getProductSpec
().
stream
()
.
filter
(
spec
->
spec
.
getFlag
().
equals
(
1
))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
zdySpecInfo
))
{
updateCustomize
(
goodsInfo
,
zdySpecInfo
,
goodsAddVO
.
getId
());
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateCustomize
(
GoodsInfo
goodsInfo
,
List
<
GoodsProdSpecVO
>
zdySpecInfo
,
Integer
id
)
{
// 先获取自定义的sku及规格(原来有的)
List
<
GoodsProdSpecVO
>
zdySpec
=
zdySpecInfo
.
stream
().
filter
(
d
->
d
.
getId
()
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
zdySpec
))
{
// 根据获取到的自定义sku及规格进行操作
List
<
MallProdInfoDO
>
zdySpecList
=
zdySpec
.
stream
()
.
map
(
d
->
{
// 构建商品对应的sku信息
ProductDO
productSkuDO
=
new
ProductDO
().
setId
(
d
.
getSkuId
()).
setProductName
(
d
.
getProductName
());
productDao
.
updateProductSku
(
productSkuDO
);
return
new
MallProdInfoDO
(
d
).
setId
(
d
.
getId
()).
setProductId
(
d
.
getSkuId
());
})
.
collect
(
Collectors
.
toList
());
// 批量修改sku的信息
for
(
MallProdInfoDO
mallProdInfoDO
:
zdySpecList
)
{
goodsInfoDao
.
updateMallProdSkuInfo
(
mallProdInfoDO
);
}
// goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList);
}
for
(
GoodsProdSpecVO
goodsSpecVO
:
zdySpec
)
{
// 【1】获取输入的自定义规格信息// id不为空则修改
List
<
ProductSpecVO
>
customizeInfoList
=
goodsSpecVO
.
getCustomizeInfo
().
stream
()
.
filter
(
d
->
d
.
getId
()
!=
null
)
.
collect
(
Collectors
.
toList
());
for
(
ProductSpecVO
d
:
customizeInfoList
)
{
// ①修改价格配置
ProductSpecCPQVO
productSpecCPQVO
=
d
.
getProductSpecCPQVO
();
// 删除所有的随后在新增
productDao
.
removeProductSpecCPQ
(
productSpecCPQVO
);
productSkuService
.
insertSpecPrice
(
productSpecCPQVO
);
// ②在修改自定义的数据
productDao
.
updateProductSpec
(
new
ProductSpecDO
(
d
));
}
// 【2】删除多余的自定义规格
if
(!
CollectionUtils
.
isEmpty
(
goodsSpecVO
.
getDelProductSpecId
()))
{
// 批量查出spec的数据
List
<
MallProdSkuInfoSpecDO
>
prodSkuInfoSpecList
=
productDao
.
getProductSpecByIds
(
goodsSpecVO
.
getDelProductSpecId
());
for
(
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
:
prodSkuInfoSpecList
)
{
productDao
.
removeProductSpec
(
mallProdSkuInfoSpecDO
.
getProductSpecId
());
}
goodsInfoDao
.
batchUpdateMallProdSpec
(
goodsSpecVO
.
getDelProductSpecId
());
}
// 【3】新增最新的自定义规格
List
<
ProductSpecVO
>
collect
=
goodsSpecVO
.
getCustomizeInfo
().
stream
()
.
filter
(
d
->
d
.
getId
()
==
null
)
.
collect
(
Collectors
.
toList
());
for
(
ProductSpecVO
param
:
collect
)
{
ProductSpecDO
productSpecDO
=
new
ProductSpecDO
(
param
);
// 新增产品sku
productDao
.
insertProductSpec
(
productSpecDO
);
// 批量配置价格信息
ProductSpecCPQVO
productSpecCPQVO
=
param
.
getProductSpecCPQVO
();
productSpecCPQVO
.
setProductSpecId
(
productSpecDO
.
getId
());
productSkuService
.
insertSpecPrice
(
productSpecCPQVO
);
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
new
MallProdSkuInfoSpecDO
()
.
setProductSpecId
(
productSpecDO
.
getId
())
.
setMallProdSkuInfoId
(
goodsSpecVO
.
getId
())
.
setGoodsInfoId
(
id
);
// 插入数据库商品对应的规格信息
goodsInfoDao
.
insertMallProdSkuInfoSpec
(
mallProdSkuInfoSpecDO
);
}
}
// 2.2 新增新的自定义规格信息
List
<
GoodsProdSpecVO
>
newZdySpec
=
zdySpecInfo
.
stream
().
filter
(
d
->
d
.
getId
()
==
null
).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
newZdySpec
))
{
productSkuSpecOperation
(
goodsInfo
,
newZdySpec
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateOtherService
(
GoodsAddVO
goodsAddVO
)
{
// 删除其他服务
goodsInfoDao
.
deleteGoodsServiceByGoodsId
(
goodsAddVO
.
getId
());
// 插入其他服务
if
(!
CollectionUtils
.
isEmpty
(
goodsAddVO
.
getOtherService
()))
{
List
<
Integer
>
other
=
goodsAddVO
.
getOtherService
();
List
<
GoodsServiceDO
>
otherList
=
other
.
stream
()
.
map
(
d
->
{
GoodsServiceDO
goodsServiceDO
=
new
GoodsServiceDO
();
goodsServiceDO
.
setGoodsInfoId
(
goodsAddVO
.
getId
());
goodsServiceDO
.
setSaleServiceId
(
d
);
return
goodsServiceDO
;
})
.
collect
(
Collectors
.
toList
());
goodsInfoDao
.
insertGoodsService
(
otherList
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateImageInfo
(
GoodsAddVO
goodsAddVO
)
{
Set
<
Integer
>
imgIds
=
goodsAddVO
.
getImages
().
stream
()
.
map
(
GoodsImgVO:
:
getId
)
.
filter
(
Objects:
:
nonNull
)
.
collect
(
Collectors
.
toSet
());
List
<
GoodsImgDO
>
dbImgList
=
goodsInfoDao
.
listGoodsInfoByGoodsId
(
goodsAddVO
.
getId
());
List
<
Integer
>
deleteIds
=
dbImgList
.
stream
()
.
map
(
GoodsImgDO:
:
getId
)
.
filter
(
id
->
!
imgIds
.
contains
(
id
))
.
collect
(
Collectors
.
toList
());
if
(
deleteIds
.
size
()
!=
0
)
{
// 删除多余的图片
goodsInfoDao
.
deleteImgByIds
(
deleteIds
);
}
// 新增图片
List
<
GoodsImgDO
>
imgDOList
=
goodsAddVO
.
getImages
().
stream
()
.
filter
(
d
->
d
.
getId
()
==
null
)
.
map
(
d
->
{
GoodsImgDO
goodsImgDO
=
new
GoodsImgDO
(
d
);
goodsImgDO
.
setGoodsInfoId
(
goodsAddVO
.
getId
());
return
goodsImgDO
;
})
.
collect
(
Collectors
.
toList
());
if
(
imgDOList
.
size
()
!=
0
)
{
goodsInfoDao
.
insertGoodsImgInfo
(
imgDOList
);
}
// 删除视频
goodsInfoDao
.
deleteGoodsVideoById
(
goodsAddVO
.
getId
());
// 插入视频
if
(
goodsAddVO
.
getGoodsVideo
()
!=
null
)
{
GoodsVideoDO
goodsVideoDO
=
new
GoodsVideoDO
();
goodsVideoDO
.
setGoodsInfoId
(
goodsAddVO
.
getId
());
goodsVideoDO
.
setVideoUrl
(
goodsAddVO
.
getGoodsVideo
());
goodsInfoDao
.
insertVideoInfo
(
goodsVideoDO
);
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateGoodsDetail
(
GoodsAddVO
goodsAddVO
)
{
GoodsDetailDO
goodsDetailDO
=
new
GoodsDetailDO
(
goodsAddVO
.
getGoodsDetailVO
()).
setGoodsInfoId
(
goodsAddVO
.
getId
());
// 商品详情修改
goodsInfoDao
.
updateGoodsDetail
(
goodsDetailDO
);
}
@Override
public
ResultBody
getGoodsInfoDetail
(
Integer
goodsInfoId
,
Integer
type
,
Integer
leaseTerm
)
{
// 判断此商品是否还存在
int
count
=
goodsInfoDao
.
countGoodsInfoById
(
goodsInfoId
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF
);
}
// 初始化商品返回信息的对象
MallGoodsDetailDTO
mallGoodsDetail
=
new
MallGoodsDetailDTO
();
// 获取商品基本信息
GoodsInfo
goodsInfo
=
goodsInfoDao
.
getGoodsSimpleInfo
(
goodsInfoId
);
mallGoodsDetail
.
setId
(
goodsInfo
.
getId
())
.
setGoodsNo
(
goodsInfo
.
getGoodsNo
())
.
setGoodsName
(
goodsInfo
.
getGoodsName
())
.
setCategoryByOne
(
goodsInfo
.
getCategoryByOne
())
.
setGoodsVideo
(
goodsInfo
.
getVideoUrl
())
.
setDirectoryId
(
goodsInfo
.
getDirectoryId
())
.
setCategoryByTwo
(
goodsInfo
.
getCategoryByTwo
())
.
setTag
(
goodsInfo
.
getEcoLabel
())
.
setShelfStatus
(
goodsInfo
.
getShelfStatus
())
.
setGoodsVideoId
(
goodsInfo
.
getGoodsVideoId
());
// 获取商品图片信息
mallGoodsDetail
.
setImages
(
getGoodsImageInfo
(
goodsInfoId
));
// 获取商品详细信息
mallGoodsDetail
.
setGoodsDetail
(
getGoodsDetail
(
goodsInfoId
));
// 获取其他服务信息
mallGoodsDetail
.
setOtherService
(
getOtherServiceInfo
(
goodsInfoId
));
// 获取规格信息
if
(!
goodsInfo
.
getDirectoryId
().
equals
(
2
))
{
// 获取产品规格信息
mallGoodsDetail
.
setGoodsSpec
(
getProductSpecInfo
(
goodsInfoId
,
type
,
leaseTerm
));
}
else
{
// 获取行业规格信息
mallGoodsDetail
.
setGoodsSpec
(
getIndustrySpecInfo
(
goodsInfoId
));
}
return
ResultBody
.
success
(
mallGoodsDetail
);
}
private
List
<
GoodsSpecDTO
>
getIndustrySpecInfo
(
Integer
goodsInfoId
)
{
// 获取商品对应绑定的行业sku信息
List
<
MallIndustrySkuInfoDO
>
mallIndustrySkuInfoList
=
goodsInfoDao
.
getMallIndustrySkuInfo
(
goodsInfoId
);
List
<
GoodsSpecDTO
>
list
=
mallIndustrySkuInfoList
.
stream
()
.
map
(
MallIndustrySkuInfoDO:
:
buildGoodsSpecDTO
)
.
collect
(
Collectors
.
toList
());
// 根据商品id查出该商品下绑定的规格信息
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpec
=
industrySpecDao
.
getIndustrySkuInfoSpec
(
goodsInfoId
);
list
=
list
.
stream
()
.
peek
(
d
->
{
List
<
MallIndustrySpecDTO
>
industrySpec
=
new
ArrayList
<>();
for
(
MallIndustrySkuInfoSpecDO
e
:
mallIndustrySkuInfoSpec
)
{
if
(
d
.
getId
().
equals
(
e
.
getMallIndustrySkuInfoId
()))
{
IndustrySpecDO
industrySpecDO
=
e
.
getIndustrySpecDO
();
MallIndustrySpecDTO
industrySpecDTO
=
industrySpecDO
.
buildMallIndustrySpecDTO
();
industrySpecDTO
.
setId
(
e
.
getId
());
industrySpecDTO
.
setIndustrySpecId
(
e
.
getIndustrySpecId
());
industrySpecDTO
.
setIndustrySkuId
(
d
.
getSkuId
());
industrySpec
.
add
(
industrySpecDTO
);
}
}
d
.
setIndustrySpecList
(
industrySpec
);
})
.
collect
(
Collectors
.
toList
());
return
list
;
}
private
List
<
GoodsSpecDTO
>
getProductSpecInfo
(
Integer
goodsInfoId
,
Integer
type
,
Integer
leaseTerm
)
{
// 获取商品对应绑定sku的信息
List
<
MallProdInfoDO
>
mallProdSkuInfoList
=
goodsInfoDao
.
getAllMallProSkuInfo
(
goodsInfoId
);
List
<
GoodsSpecDTO
>
list
=
mallProdSkuInfoList
.
stream
()
.
map
(
MallProdInfoDO:
:
buildGoodsSpecDTO
)
.
collect
(
Collectors
.
toList
());
// 获取规格来源详细信息
List
<
MallProdSkuInfoSpecDO
>
mallProdSkuInfoSpec
=
goodsInfoDao
.
getMallProSkuInfoSpec
(
goodsInfoId
);
// 根据id查询出规格的具体信息
list
=
list
.
stream
()
.
peek
(
d
->
{
List
<
MallProductSpecDTO
>
specList
=
new
ArrayList
<>();
for
(
MallProdSkuInfoSpecDO
e
:
mallProdSkuInfoSpec
)
{
if
(
d
.
getId
().
equals
(
e
.
getMallProdSkuInfoId
()))
{
// 构建规格对象
ProductSpecDO
productSpecDO
=
e
.
getProductSpecDO
();
MallProductSpecDTO
productSpecDTO
=
productSpecDO
.
buildMallProductSpecDTO
();
productSpecDTO
.
setProductSkuId
(
d
.
getSkuId
());
productSpecDTO
.
setId
(
e
.
getId
());
productSpecDTO
.
setProductSpec
(
e
.
getProductSpecId
());
// 获取自定义sku下规格的价格配置信息
ProductSpecCPQVO
productSpecCPQVO
=
new
ProductSpecCPQVO
();
productSpecCPQVO
.
setProductSpecId
(
e
.
getProductSpecId
());
productSpecCPQVO
.
setType
(
type
);
if
(
type
.
equals
(
1
))
{
productSpecCPQVO
.
setLeaseTerm
(
leaseTerm
);
}
List
<
ProductSpecPriceDO
>
productSpecPrice
=
productDao
.
getProductSpecPrice
(
productSpecCPQVO
);
List
<
SpecPriceVO
>
collect
=
productSpecPrice
.
stream
()
.
map
(
m
->
{
SpecPriceVO
specPriceVO
=
new
SpecPriceVO
();
specPriceVO
.
setId
(
m
.
getId
());
specPriceVO
.
setPrice
(
m
.
getPrice
());
specPriceVO
.
setCooperationTag
(
m
.
getCooperationTag
());
return
specPriceVO
;
})
.
collect
(
Collectors
.
toList
());
productSpecCPQVO
.
setSpecPrice
(
collect
);
productSpecDTO
.
setProductSpecCPQVO
(
productSpecCPQVO
);
specList
.
add
(
productSpecDTO
);
}
}
d
.
setProductSpecList
(
specList
);
})
.
collect
(
Collectors
.
toList
());
return
list
;
}
public
List
<
GoodsOtherServiceDTO
>
getOtherServiceInfo
(
Integer
goodsInfoId
)
{
List
<
GoodsServiceDO
>
goodsServiceDO
=
goodsInfoDao
.
listGoodsServiceByGoodsId
(
goodsInfoId
);
return
goodsServiceDO
.
stream
()
.
map
(
GoodsServiceDO:
:
buildGoodsOtherServiceDTO
)
.
collect
(
Collectors
.
toList
());
}
public
GoodsDetailInfoDTO
getGoodsDetail
(
Integer
goodsInfoId
)
{
GoodsDetailDO
goodsDetail
=
goodsInfoDao
.
getGoodsDetailByGoodsId
(
goodsInfoId
);
return
goodsDetail
.
buildGoodsDetailInfoDTO
();
}
public
List
<
GoodsImgDTO
>
getGoodsImageInfo
(
Integer
goodsInfoId
)
{
List
<
GoodsImgDO
>
goodsImgList
=
goodsInfoDao
.
listGoodsInfoByGoodsId
(
goodsInfoId
);
return
goodsImgList
.
stream
().
map
(
GoodsImgDO:
:
buildGoodsImgDTO
).
collect
(
Collectors
.
toList
());
}
@Override
public
ResultBody
getSaleServiceInfoToList
()
{
List
<
SaleServiceDO
>
list
=
goodsInfoDao
.
listSaleServiceInfo
();
List
<
SaleServiceDTO
>
serviceDTOList
=
list
.
stream
().
map
(
d
->
d
.
buildSaleServiceDTO
()).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
serviceDTOList
);
}
@Override
public
ResultBody
getSkuUnit
()
{
List
<
SkuUnitDO
>
skuUnitList
=
goodsInfoDao
.
getSkuUnit
();
List
<
SkuUnitDTO
>
list
=
skuUnitList
.
stream
().
map
(
SkuUnitDO:
:
buildSkuUnitDTO
).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
}
/**
* 根据商品id,商品规格id查询并填充相关信息
*
* @param param
* @return
*/
@Override
public
List
<
MallGoodsShopCarDTO
>
fillGoodsInfo
(
List
<
MallGoodsShopCarDTO
>
param
)
{
Set
<
Integer
>
goodsIds
=
new
HashSet
<>();
// 获取商品id
for
(
MallGoodsShopCarDTO
mallGoodsShopCarDTO
:
param
)
{
goodsIds
.
add
(
mallGoodsShopCarDTO
.
getGoodsInfoId
());
}
// 查询出商品信息后进行填充
List
<
GoodsInfo
>
goodsInfoDOList
=
goodsInfoDao
.
listSimpleGoodsInfoByIds
(
goodsIds
);
for
(
MallGoodsShopCarDTO
mallGoodsShopCarDTO
:
param
)
{
for
(
GoodsInfo
goodsInfo
:
goodsInfoDOList
)
{
if
(
mallGoodsShopCarDTO
.
getGoodsInfoId
().
toString
().
equals
(
goodsInfo
.
getId
().
toString
()))
{
mallGoodsShopCarDTO
.
setDirectoryId
(
goodsInfo
.
getDirectoryId
());
mallGoodsShopCarDTO
.
setShelfStatus
(
goodsInfo
.
getShelfStatus
());
mallGoodsShopCarDTO
.
setGoodsName
(
goodsInfo
.
getGoodsName
());
mallGoodsShopCarDTO
.
setMainImg
(
goodsInfo
.
getMainImg
());
break
;
}
}
}
// 对产品和行业的规格id进行分类
Set
<
Integer
>
prodIds
=
new
HashSet
<>();
Set
<
Integer
>
indstIds
=
new
HashSet
<>();
for
(
MallGoodsShopCarDTO
mallGoodsShopCarDTO
:
param
)
{
if
(
mallGoodsShopCarDTO
.
getDirectoryId
().
equals
(
1
))
{
for
(
MallSkuInfoSpecDTO
mallSkuInfoSpecDTO
:
mallGoodsShopCarDTO
.
getSkuList
())
{
prodIds
.
add
(
mallSkuInfoSpecDTO
.
getMallSkuInfoSpecId
());
}
}
else
if
(
mallGoodsShopCarDTO
.
getDirectoryId
().
equals
(
2
))
{
for
(
MallSkuInfoSpecDTO
mallSkuInfoSpecDTO
:
mallGoodsShopCarDTO
.
getSkuList
())
{
indstIds
.
add
(
mallSkuInfoSpecDTO
.
getMallSkuInfoSpecId
());
}
}
}
// 根据规格id查找规格信息
List
<
MallGoodsSpecInfoDO
>
goodsSpecInfoDOList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
prodIds
))
{
List
<
MallGoodsSpecInfoDO
>
goodsProdSpecInfoDOList
=
goodsInfoDao
.
listProdSpecInfo
(
prodIds
);
goodsSpecInfoDOList
.
addAll
(
goodsProdSpecInfoDOList
);
}
if
(!
CollectionUtils
.
isEmpty
(
indstIds
))
{
List
<
MallGoodsSpecInfoDO
>
goodsIndstSpecInfoDOList
=
goodsInfoDao
.
listIndstSpecInfo
(
indstIds
);
goodsSpecInfoDOList
.
addAll
(
goodsIndstSpecInfoDOList
);
}
// 根据查出来的sku,填充到MallGoodsShopCarDTO里面
for
(
MallGoodsShopCarDTO
mallGoodsShopCarDTO
:
param
)
{
for
(
MallGoodsSpecInfoDO
mallGoodsSpecInfoDO
:
goodsSpecInfoDOList
)
{
// 找到对应商品
if
(
mallGoodsShopCarDTO
.
getGoodsInfoId
()
.
toString
()
.
equals
(
mallGoodsSpecInfoDO
.
getId
().
toString
())
&&
mallGoodsShopCarDTO
.
getDirectoryId
()
.
toString
()
.
equals
(
mallGoodsSpecInfoDO
.
getDirectoryId
().
toString
()))
{
for
(
SkuSpecDO
skuSpecDO
:
mallGoodsSpecInfoDO
.
getSkuSpecDOList
())
{
for
(
MallSkuInfoSpecDTO
mallSkuInfoSpecDTO
:
mallGoodsShopCarDTO
.
getSkuList
())
{
// 根据对应规格进行填充
if
(
skuSpecDO
.
getId
()
.
toString
()
.
equals
(
mallSkuInfoSpecDTO
.
getMallSkuInfoSpecId
().
toString
()))
{
mallSkuInfoSpecDTO
.
setSpecName
(
skuSpecDO
.
getSpecName
());
mallSkuInfoSpecDTO
.
setDeleted
(
skuSpecDO
.
getSkuSpecDeleted
());
mallSkuInfoSpecDTO
.
setValid
(
skuSpecDO
.
getSkuSpecDeleted
()
==
0
&&
skuSpecDO
.
getSpecDeleted
()
==
0
);
break
;
}
}
}
break
;
}
}
}
return
param
;
}
@Override
public
List
<
MallProductSpecPriceDTO
>
feignListProductSpecPrice
(
ProductSpecPriceQO
productSpecPriceQO
)
{
Set
<
Integer
>
ids
=
new
HashSet
<>(
productSpecPriceQO
.
getProductSpecIds
());
List
<
MallProductSpecPriceDTO
>
mallProductSpecPriceDTOS
=
productSpecPriceQO
.
getProductSpecIds
().
stream
()
.
map
(
d
->
{
MallProductSpecPriceDTO
mallProductSpecPriceDTO
=
new
MallProductSpecPriceDTO
();
mallProductSpecPriceDTO
.
setProductSpecId
(
d
);
return
mallProductSpecPriceDTO
;
})
.
collect
(
Collectors
.
toList
());
// 分别找出渠道价格和市场价格
List
<
ProductSpecPriceDO
>
productSpecPriceDOS
=
productDao
.
listProductSpecPrice
(
productSpecPriceQO
.
getChannelClass
(),
ids
);
List
<
ProductSpecPriceDO
>
productSpecPriceDOS1
=
productDao
.
listProductSpecPrice
(
0
,
ids
);
// 设置合作价格
for
(
ProductSpecPriceDO
productSpecPriceDO
:
productSpecPriceDOS
)
{
for
(
MallProductSpecPriceDTO
mallProductSpecPriceDTO
:
mallProductSpecPriceDTOS
)
{
if
(
mallProductSpecPriceDTO
.
getProductSpecId
()
.
equals
(
productSpecPriceDO
.
getProductSpecId
()))
{
mallProductSpecPriceDTO
.
setOpPrice
(
productSpecPriceDO
.
getPrice
());
break
;
}
}
}
// 设置市场价格
for
(
ProductSpecPriceDO
productSpecPriceDO
:
productSpecPriceDOS1
)
{
for
(
MallProductSpecPriceDTO
mallProductSpecPriceDTO
:
mallProductSpecPriceDTOS
)
{
if
(
mallProductSpecPriceDTO
.
getProductSpecId
()
.
equals
(
productSpecPriceDO
.
getProductSpecId
()))
{
mallProductSpecPriceDTO
.
setMkPrice
(
productSpecPriceDO
.
getPrice
());
break
;
}
}
}
return
mallProductSpecPriceDTOS
;
}
@Override
public
ProductSpecPriceDTO
feignGetUnitPriceByTag
(
Integer
id
,
Integer
tagId
)
{
ProductSpecPriceDTO
price
=
productDao
.
feignGetUnitPrice
(
id
,
tagId
);
return
price
;
}
@Override
public
List
<
OrderGoodsProdDTO
>
feignListProdGoodsSkuInfo
(
MallOrderGoodsInfoQO
mallOrderGoodsInfoQO
)
{
// 查询渠道等级对应的商品价格
Set
<
Integer
>
prodSkuSpecIds
=
productDao
.
listProductSpecIds
(
mallOrderGoodsInfoQO
.
getMallProdSkuSpecIds
());
// 查询商品信息
List
<
OrderGoodsProdDTO
>
orderGoodsProdDTOList
=
productDao
.
listProdGoodsSkuInfo
(
mallOrderGoodsInfoQO
);
// 填充价格
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
=
productDao
.
listAllProductSpecPriceByType
(
prodSkuSpecIds
);
this
.
buildProductSpecPrice
(
orderGoodsProdDTOList
,
allProductSpecPriceDOS
,
mallOrderGoodsInfoQO
.
getCooperationTagIds
());
// 还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额
List
<
Integer
>
goodsIds
=
orderGoodsProdDTOList
.
stream
()
.
map
(
OrderGoodsProdDTO:
:
getGoodsInfoId
)
.
collect
(
Collectors
.
toList
());
// 拼装商品服务
List
<
GoodsServiceDTO
>
services
=
goodsInfoDao
.
listGoodsService
(
goodsIds
).
stream
()
.
map
(
d
->
d
.
buildGoodsServiceDTO
())
.
collect
(
Collectors
.
toList
());
Map
<
Integer
,
List
<
GoodsServiceDTO
>>
mapGoodsService
=
org
.
springframework
.
util
.
CollectionUtils
.
isEmpty
(
services
)
?
null
:
services
.
stream
().
collect
(
Collectors
.
groupingBy
(
GoodsServiceDTO:
:
getGoodsInfoId
));
List
<
OrderGoodsProdDTO
>
collect
=
orderGoodsProdDTOList
.
stream
()
.
map
(
d
->
{
OrderGoodsProdDTO
orderGoodsProdDTO
=
d
;
if
(
mapGoodsService
!=
null
&&
mapGoodsService
.
containsKey
(
d
.
getGoodsInfoId
()))
{
orderGoodsProdDTO
.
setServices
(
mapGoodsService
.
get
(
d
.
getGoodsInfoId
()));
}
return
orderGoodsProdDTO
;
})
.
collect
(
Collectors
.
toList
());
return
collect
;
}
/**
* 填充产品规格价格
*
* @param orderGoodsProdDTOList
* @param allProductSpecPriceDOS
* @param cooperationTagIds
*/
private
void
buildProductSpecPrice
(
List
<
OrderGoodsProdDTO
>
orderGoodsProdDTOList
,
List
<
ProductSpecPriceDO
>
allProductSpecPriceDOS
,
List
<
Integer
>
cooperationTagIds
)
{
Map
<
Integer
,
List
<
ProductSpecPriceDO
>>
productSpecPriceMap
=
allProductSpecPriceDOS
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
ProductSpecPriceDO:
:
getProductSpecId
));
for
(
OrderGoodsProdDTO
orderGoodsProdDTO
:
orderGoodsProdDTOList
)
{
for
(
OrderGoodsProdDetailDTO
prodDetailDTO
:
orderGoodsProdDTO
.
getOrderGoodsProdDetailDTOS
())
{
List
<
ProductSpecPriceDO
>
specPriceDOS
=
productSpecPriceMap
.
get
(
prodDetailDTO
.
getProductSpecId
());
if
(
CollectionUtils
.
isNotEmpty
(
specPriceDOS
))
{
List
<
ProductSpecPriceDO
>
tempSpecPrice
=
specPriceDOS
.
stream
()
.
filter
(
d
->
cooperationTagIds
.
contains
(
d
.
getCooperationTag
()))
.
sorted
(
Comparator
.
comparing
(
ProductSpecPriceDO:
:
getPrice
))
.
collect
(
Collectors
.
toList
());
prodDetailDTO
.
setUnitPrice
(
tempSpecPrice
.
get
(
0
).
getPrice
());
}
}
}
}
@Override
public
List
<
OrderGoodsIndstDTO
>
feignListIndstGoodsSkuInfo
(
MallOrderGoodsInfoQO
mallOrderGoodsInfoQO
)
{
// 查询商品信息
List
<
MallGoodsInfoSimpleDO
>
mallGoodsInfoSimpleDOS
=
goodsInfoDao
.
listMallGoodsIndstSimpleInfo
(
mallOrderGoodsInfoQO
.
getMallIndstSkuSpecIds
());
List
<
Integer
>
industrySpecIds
=
goodsInfoDao
.
listIndustrySpecIds
(
mallOrderGoodsInfoQO
.
getMallIndstSkuSpecIds
());
// 查询商品价格
List
<
IndustrySpecPriceDO
>
industrySpecPriceDOS
=
industrySpecDao
.
listIndustrySpecPrice
(
mallOrderGoodsInfoQO
.
getCooperationTagId
(),
industrySpecIds
);
// 查询商品行业规格对应的产品清单
List
<
MallGoodsProductDO
>
mallGoodsProductDOS
=
goodsInfoDao
.
listIndustryProductList
(
industrySpecIds
);
// 配置商品行业规格价格
this
.
fillOrderGoodsIndstPrice
(
mallGoodsInfoSimpleDOS
,
industrySpecPriceDOS
,
industrySpecIds
);
if
(!
CollectionUtils
.
isEmpty
(
industrySpecIds
))
{
// 查询商品价格,找出市场价
List
<
IndustrySpecPriceDO
>
industryMarketPrice
=
industrySpecDao
.
listIndustrySpecPrice
(
0
,
industrySpecIds
);
this
.
fillOrderGoodsIndstPrice
(
mallGoodsInfoSimpleDOS
,
industryMarketPrice
,
industrySpecIds
);
}
// 配置产品清单
for
(
MallGoodsInfoSimpleDO
mallGoodsInfoSimpleDO
:
mallGoodsInfoSimpleDOS
)
{
for
(
MallGoodsSpecSimpleDO
mallGoodsSpecSimpleDO
:
mallGoodsInfoSimpleDO
.
getMallGoodsSpecSimpleDOS
())
{
mallGoodsSpecSimpleDO
.
setMallGoodsProductDOS
(
new
ArrayList
<
MallGoodsProductDO
>());
// 从产品清单中拿出对应的方案规格里面
for
(
MallGoodsProductDO
mallGoodsProductDO
:
mallGoodsProductDOS
)
{
if
(
mallGoodsProductDO
.
getIndustrySpecId
()
.
toString
()
.
equals
(
mallGoodsSpecSimpleDO
.
getIndustrySpecId
().
toString
()))
{
mallGoodsSpecSimpleDO
.
getMallGoodsProductDOS
().
add
(
mallGoodsProductDO
);
}
}
}
}
// 转换对象
List
<
OrderGoodsIndstDTO
>
collect
=
mallGoodsInfoSimpleDOS
.
stream
()
.
map
(
d
->
d
.
buildOrderGoodsIndstDTO
())
.
collect
(
Collectors
.
toList
());
// 拼装商品服务
List
<
Integer
>
goodsIds
=
collect
.
stream
().
map
(
OrderGoodsIndstDTO:
:
getGoodsInfoId
).
collect
(
Collectors
.
toList
());
List
<
GoodsServiceDTO
>
services
=
goodsInfoDao
.
listGoodsService
(
goodsIds
).
stream
()
.
map
(
d
->
d
.
buildGoodsServiceDTO
())
.
collect
(
Collectors
.
toList
());
Map
<
Integer
,
List
<
GoodsServiceDTO
>>
mapGoodsService
=
org
.
springframework
.
util
.
CollectionUtils
.
isEmpty
(
services
)
?
null
:
services
.
stream
().
collect
(
Collectors
.
groupingBy
(
GoodsServiceDTO:
:
getGoodsInfoId
));
List
<
OrderGoodsIndstDTO
>
resultList
=
collect
.
stream
()
.
map
(
d
->
{
OrderGoodsIndstDTO
orderGoodsIndstDTO
=
d
;
if
(
mapGoodsService
!=
null
&&
mapGoodsService
.
containsKey
(
d
.
getGoodsInfoId
()))
{
orderGoodsIndstDTO
.
setServices
(
mapGoodsService
.
get
(
d
.
getGoodsInfoId
()));
}
return
orderGoodsIndstDTO
;
})
.
collect
(
Collectors
.
toList
());
return
resultList
;
}
private
List
<
MallGoodsInfoSimpleDO
>
fillOrderGoodsIndstPrice
(
List
<
MallGoodsInfoSimpleDO
>
mallGoodsInfoSimpleDOS
,
List
<
IndustrySpecPriceDO
>
industrySpecPriceDOS
,
List
<
Integer
>
industrySpecIds
)
{
// 配置商品行业规格价格
for
(
MallGoodsInfoSimpleDO
mallGoodsInfoSimpleDO
:
mallGoodsInfoSimpleDOS
)
{
for
(
MallGoodsSpecSimpleDO
mallGoodsSpecSimpleDO
:
mallGoodsInfoSimpleDO
.
getMallGoodsSpecSimpleDOS
())
{
// 查询规格进行配置
for
(
IndustrySpecPriceDO
industrySpecPriceDO
:
industrySpecPriceDOS
)
{
if
(
mallGoodsSpecSimpleDO
.
getIndustrySpecId
()
.
toString
()
.
equals
(
industrySpecPriceDO
.
getIndustrySpecId
().
toString
()))
{
mallGoodsSpecSimpleDO
.
setUnitPrice
(
industrySpecPriceDO
.
getPrice
());
industrySpecIds
.
removeIf
(
d
->
d
.
toString
().
equals
(
industrySpecPriceDO
.
getIndustrySpecId
().
toString
()));
break
;
}
}
}
}
return
mallGoodsInfoSimpleDOS
;
}
@Override
public
PageResult
listPageGoodsInfo
(
MallGoodsQO
param
)
{
int
count
=
goodsInfoDao
.
countListGoodsInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
GoodsInfo
>
goodsInfo
=
goodsInfoDao
.
listGoodsInfo
(
param
);
List
<
GoodsInfoListDTO
>
pageList
=
goodsInfo
.
stream
().
map
(
GoodsInfo:
:
buildGoodsInfoListDTO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
);
}
@Override
public
ResultBody
batchOnShelfOrTakeDown
(
List
<
Integer
>
ids
,
Integer
status
)
{
goodsInfoDao
.
batchUpOrDownWare
(
ids
,
status
);
return
ResultBody
.
success
();
}
@Override
public
ResultBody
batchRemoveWareInfo
(
List
<
Integer
>
ids
)
{
goodsInfoDao
.
removeWareInfo
(
ids
);
return
ResultBody
.
success
();
}
}
src/main/java/com/mmc/pms/service/impl/IndustrySpecServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.BrandManageDao
;
import
com.mmc.pms.dao.IndustrySpecDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.model.qo.IndustrySkuQO
;
import
com.mmc.pms.model.sale.dto.*
;
import
com.mmc.pms.model.sale.vo.GoodsProductSkuVO
;
import
com.mmc.pms.model.sale.vo.IndustrySkuVO
;
import
com.mmc.pms.model.sale.vo.IndustrySpecVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.IndustrySpecService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
/**
* @Author LW
*
* @date 2022/10/8 10:58 概要:
*/
@Service
public
class
IndustrySpecServiceImpl
implements
IndustrySpecService
{
@Autowired
IndustrySpecDao
industrySpecDao
;
@Autowired
ProductDao
productDao
;
@Autowired
private
BrandManageDao
brandManageDao
;
@Override
public
ResultBody
addIndustrySku
(
IndustrySkuVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSkuName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
IndustrySku
industrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
insertIndustrySku
(
industrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
getIndustrySkuDetail
(
Integer
id
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
IndustrySku
IndustrySku
=
industrySpecDao
.
getIndustrySkuById
(
id
);
return
ResultBody
.
success
(
IndustrySku
.
buildIndustrySku
());
}
@Override
public
ResultBody
editIndustrySku
(
IndustrySkuVO
param
)
{
// 判断此sku是否还存在
int
count
=
industrySpecDao
.
countIndustrySkuById
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
skuNameCount
=
industrySpecDao
.
countSkuName
(
param
);
if
(
skuNameCount
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
IndustrySku
IndustrySku
=
new
IndustrySku
(
param
);
// 新增产品sku
int
status
=
industrySpecDao
.
updateIndustrySku
(
IndustrySku
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
listPageIndustrySku
(
IndustrySkuQO
param
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySku
(
param
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
));
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
IndustrySku
>
industrySkuList
=
industrySpecDao
.
listPageIndustrySku
(
param
);
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
industrySkuList
.
stream
()
.
map
(
IndustrySku:
:
buildIndustrySkuDTO
)
.
collect
(
Collectors
.
toList
())));
}
/**
* 新增方案规格
*
* @param param
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ResultBody
addIndustrySpec
(
IndustrySpecVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
industrySpecDao
.
countSpecName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 新增规格表信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
insertIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
}
private
void
addInventorySpec
(
IndustrySpecVO
param
,
IndustrySpecDO
industrySpecDO
)
{
for
(
ProductInventoryVO
d
:
param
.
getProductInventoryList
())
{
IndustryProductInventoryDO
industryProductInventoryDO
=
new
IndustryProductInventoryDO
(
d
);
industryProductInventoryDO
.
setIndustrySpecId
(
industrySpecDO
.
getId
());
industrySpecDao
.
insertIndustryProductInventory
(
industryProductInventoryDO
);
// 新增清单绑定的产品规格信息
// 判断该sku是否指定产品规格 0:未指定 1:指定
if
(
d
.
getSelect
().
equals
(
0
))
{
// 如果是表示不指定则要添加所有对sku下的所有产品规格
// 先查出该sku下的所有规格信息
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
listProductSpec
(
d
.
getProductSku
().
getId
());
// 批量插入
for
(
ProductSpecDO
productSpecDO
:
productSpecList
)
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecDO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecDO
.
getProductId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
}
else
{
// 指定的直接拿指定的数据
for
(
ProductSpecVO
productSpecVO
:
d
.
getProductSpecList
())
{
InventorySpecDO
inventorySpecDO
=
new
InventorySpecDO
();
inventorySpecDO
.
setIndustryProductInventoryId
(
industryProductInventoryDO
.
getId
());
inventorySpecDO
.
setProductSpecId
(
productSpecVO
.
getId
());
inventorySpecDO
.
setProductSkuId
(
productSpecVO
.
getProductSkuId
());
industrySpecDao
.
insertInventorySpec
(
inventorySpecDO
);
}
}
}
}
/**
* 获取行业规格信息
*
* @param industrySpecId
* @return
*/
@Override
public
ResultBody
getIndustrySpecDetail
(
Integer
industrySpecId
)
{
// 查询当前行业规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecId
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 初始化行业规格DTO
IndustrySpecDTO
industrySpecDTO
;
// 获取行业规格的基本信息
IndustrySpecDO
industrySpec
=
industrySpecDao
.
getIndustrySpecById
(
industrySpecId
);
industrySpecDTO
=
industrySpec
.
buildIndustrySpecDTO
();
// 获取这个规格下的产品sku信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
industrySpecId
);
// 获取产品skuId
List
<
Integer
>
productSkuId
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getProductSkuId
)
.
collect
(
Collectors
.
toList
());
// 分别查出产品sku的详细信息
List
<
ProductDO
>
productSkuList
=
productDao
.
listProductSkuDO
(
productSkuId
);
// 查出产品sku对应的品牌的信息
Set
<
Integer
>
brandInfoIds
=
productSkuList
.
stream
().
map
(
ProductDO:
:
getBrandInfoId
).
collect
(
Collectors
.
toSet
());
List
<
BrandInfoDO
>
brandInfoList
=
brandManageDao
.
listBrandInfoByIds
(
brandInfoIds
);
// 拿到行业产品清单id的集合
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
// 再分别查出产品规格id
List
<
InventorySpecDO
>
inventorySpecList
=
productDao
.
listInventorySpecInfo
(
industryProductInventoryIds
);
if
(
inventorySpecList
.
size
()
!=
0
)
{
// 获取所有产品规格id
List
<
Integer
>
productSpecIds
=
inventorySpecList
.
stream
()
.
map
(
InventorySpecDO:
:
getProductSpecId
)
.
collect
(
Collectors
.
toList
());
// 根据这些规格id查询规格信息
List
<
ProductSpecDO
>
productSpecInfoList
=
productDao
.
listProductSpecInfo
(
productSpecIds
);
// 构建产品规格信息
List
<
ProductSpecVO
>
productSpecList
=
productSpecInfoList
.
stream
()
.
map
(
d
->
{
ProductSpecVO
productSpecVO
=
new
ProductSpecVO
();
productSpecVO
.
setSpecImage
(
d
.
getSpecImage
());
productSpecVO
.
setProductSkuId
(
d
.
getProductId
());
productSpecVO
.
setSpecName
(
d
.
getSpecName
());
productSpecVO
.
setId
(
d
.
getId
());
productSpecVO
.
setPartNo
(
d
.
getPartNo
());
productSpecVO
.
setVersionDesc
(
d
.
getVersionDesc
());
return
productSpecVO
;
})
.
collect
(
Collectors
.
toList
());
// 根据产品skuId分组
Map
<
Integer
,
List
<
ProductSpecVO
>>
maps
=
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecVO:
:
getProductSkuId
));
// 构建其余产品清单的信息
List
<
ProductInventoryVO
>
list
=
new
ArrayList
<>();
for
(
IndustryProductInventoryDO
d
:
industryProductInventory
)
{
for
(
ProductDO
e
:
productSkuList
)
{
GoodsProductSkuVO
goodsProductSkuVO
=
new
GoodsProductSkuVO
();
goodsProductSkuVO
.
setId
(
d
.
getId
());
goodsProductSkuVO
.
setProductName
(
e
.
getProductName
());
for
(
BrandInfoDO
b
:
brandInfoList
)
{
if
(
e
.
getBrandInfoId
().
equals
(
b
.
getId
()))
{
goodsProductSkuVO
.
setProductBrand
(
b
.
getBrandName
());
break
;
}
}
goodsProductSkuVO
.
setModel
(
e
.
getModel
());
ProductInventoryVO
productInventoryVO
=
new
ProductInventoryVO
();
productInventoryVO
.
setProductSku
(
goodsProductSkuVO
);
if
(
d
.
getProductSkuId
().
equals
(
e
.
getId
()))
{
// 匹配分组之后id相等的数据构建到ProductInventoryVO对象中
List
<
ProductSpecVO
>
productSpecVOS
=
maps
.
get
(
e
.
getId
());
productInventoryVO
.
setProductSpecList
(
productSpecVOS
);
productInventoryVO
.
setSelect
(
d
.
getSelected
());
productInventoryVO
.
setProductSkuId
(
d
.
getProductSkuId
());
list
.
add
(
productInventoryVO
);
}
}
}
// 组装产品清单
industrySpecDTO
.
setProductInventoryList
(
list
);
}
return
ResultBody
.
success
(
industrySpecDTO
);
}
/**
* 编辑行业规格信息
*
* @param param
* @return
*/
@Override
public
ResultBody
editIndustrySpec
(
IndustrySpecVO
param
)
{
int
count
=
industrySpecDao
.
countIndustrySpec
(
param
.
getId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取名称判断此前是否已经存在
int
countName
=
industrySpecDao
.
countSpecName
(
param
);
if
(
countName
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
// 修改行业规格基本信息
IndustrySpecDO
industrySpecDO
=
new
IndustrySpecDO
(
param
);
int
status
=
industrySpecDao
.
updateIndustrySpec
(
industrySpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
// 先获取绑定的的产品skuId
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
param
.
getId
());
List
<
Integer
>
industryProductInventoryIds
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
// 批量删除原来绑定的产品规格信息
if
(
industryProductInventoryIds
.
size
()
!=
0
)
{
industrySpecDao
.
batchDeleteInventorySpec
(
industryProductInventoryIds
);
}
// 批量删除绑定的产品sku信息
industrySpecDao
.
deleteIndustryProductInventory
(
param
.
getId
());
// 新增规格绑定产品sku表信息
addInventorySpec
(
param
,
industrySpecDO
);
return
ResultBody
.
success
();
}
/**
* 列表页面行业规范
*
* @param pageNo 页面没有
* @param pageSize 页面大小
* @param industrySkuId 行业sku id
* @param keyword 关键字
* @return {@link ResultBody}
*/
@Override
public
ResultBody
listPageIndustrySpec
(
Integer
pageNo
,
Integer
pageSize
,
Integer
industrySkuId
,
String
keyword
)
{
int
count
=
industrySpecDao
.
countListPageIndustrySpec
(
industrySkuId
,
keyword
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
));
}
List
<
IndustrySpecDO
>
industrySpecList
=
industrySpecDao
.
listPageIndustrySpec
(
(
pageNo
-
1
)
*
pageSize
,
pageSize
,
industrySkuId
,
keyword
);
List
<
Integer
>
specIds
=
industrySpecList
.
stream
().
map
(
IndustrySpecDO:
:
getId
).
collect
(
Collectors
.
toList
());
// 根据规格id批量查询价格信息
List
<
IndustrySpecPriceDO
>
industrySpecPrice
=
industrySpecDao
.
getIndustrySpecPriceList
(
specIds
);
Map
<
Integer
,
List
<
IndustrySpecPriceDO
>>
priceMap
=
industrySpecPrice
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
IndustrySpecPriceDO:
:
getIndustrySpecId
));
List
<
IndustrySpecDTO
>
list
=
industrySpecList
.
stream
()
.
map
(
d
->
{
IndustrySpecDTO
industrySpecDTO
=
d
.
buildIndustrySpecDTO
();
if
(!
CollectionUtils
.
isEmpty
(
priceMap
.
get
(
d
.
getId
())))
{
industrySpecDTO
.
setPriceList
(
priceMap
.
get
(
d
.
getId
()).
stream
()
.
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
)
.
collect
(
Collectors
.
toList
()));
}
return
industrySpecDTO
;
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
));
}
/**
* 行业规格价格配置
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
industrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
industrySpecCPQQ
.
getIndustrySpecId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
}
private
List
<
IndustrySpecPriceDO
>
getIndustrySpecPriceDOS
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 批量插入规格价格
return
industrySpecCPQQ
.
getSpecPrice
().
stream
()
.
map
(
d
->
{
IndustrySpecPriceDO
industrySpecPriceDO
=
new
IndustrySpecPriceDO
();
industrySpecPriceDO
.
setCooperationTag
(
d
.
getCooperationTag
());
industrySpecPriceDO
.
setType
(
industrySpecCPQQ
.
getType
());
industrySpecPriceDO
.
setPrice
(
d
.
getPrice
());
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
))
{
industrySpecPriceDO
.
setLeaseTerm
(
industrySpecCPQQ
.
getLeaseTerm
());
}
industrySpecPriceDO
.
setIndustrySpecId
(
industrySpecCPQQ
.
getIndustrySpecId
());
return
industrySpecPriceDO
;
})
.
collect
(
Collectors
.
toList
());
}
/**
* 行业规格价格配置修改
*
* @param industrySpecCPQQ
* @return
*/
@Override
public
ResultBody
updateIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
// 先删除原来该规格下的所有价格配置信息
industrySpecDao
.
removeIndustrySpecCPQ
(
industrySpecCPQQ
);
// 批量插入规格价格
insertSpecPrice
(
industrySpecCPQQ
);
return
ResultBody
.
success
();
}
public
ResultBody
insertSpecPrice
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
List
<
IndustrySpecPriceDO
>
list
=
getIndustrySpecPriceDOS
(
industrySpecCPQQ
);
// 批量插入规格价格
if
(
industrySpecCPQQ
.
getType
().
equals
(
0
))
{
int
status
=
industrySpecDao
.
batchInsertSpecPrice
(
list
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
}
else
{
// 批量插入租赁价格
industrySpecDao
.
batchInsertLeaseSpecPrice
(
list
);
}
return
ResultBody
.
success
();
}
/**
* 获取配置价格信息
*
* @param industrySpecCPQQ 行业规范
* @return {@link ResultBody}
*/
@Override
public
ResultBody
getIndustrySpecCPQ
(
IndustrySpecCPQVO
industrySpecCPQQ
)
{
if
(
industrySpecCPQQ
.
getType
().
equals
(
1
)
&&
industrySpecCPQQ
.
getLeaseTerm
()
==
null
)
{
return
ResultBody
.
error
(
"租赁期限不能为空!"
);
}
List
<
IndustrySpecPriceDO
>
industrySpecPriceList
=
industrySpecDao
.
getIndustrySpecCPQ
(
industrySpecCPQQ
);
List
<
IndustrySpecPriceDTO
>
list
=
industrySpecPriceList
.
stream
()
.
map
(
IndustrySpecPriceDO:
:
buildIndustrySpecPriceDTO
)
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
}
@Override
public
ResultBody
removeIndustrySku
(
Integer
id
)
{
// 查询该sku下是否有行业规格存在
int
specCount
=
industrySpecDao
.
countIndustrySpecBySkuId
(
id
);
if
(
specCount
<=
0
)
{
// 删除
industrySpecDao
.
removeIndustrySku
(
id
);
return
ResultBody
.
success
();
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_EXIST_UNDER_THE_SKU
);
}
}
/**
* 删除行业规格
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public
ResultBody
removeIndustrySpec
(
Integer
id
)
{
// 判断该规格是否存在
int
count
=
industrySpecDao
.
countIndustrySpec
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 获取该规格下绑定的商品的信息
RemoveSkuDTO
removeSkuDTO
=
new
RemoveSkuDTO
();
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpecList
=
industrySpecDao
.
listMallIndustrySpec
(
id
);
if
(
mallIndustrySkuInfoSpecList
.
size
()
!=
0
)
{
List
<
String
>
goodsName
=
new
ArrayList
<>();
mallIndustrySkuInfoSpecList
.
forEach
(
d
->
goodsName
.
add
(
d
.
getGoodsName
()));
removeSkuDTO
.
setGoodsName
(
goodsName
);
return
ResultBody
.
success
(
removeSkuDTO
);
}
else
{
// 根据规格id获取规格清单绑定的信息
List
<
IndustryProductInventoryDO
>
industryProductInventory
=
industrySpecDao
.
getIndustryProductInventory
(
id
);
if
(
industryProductInventory
.
size
()
!=
0
)
{
// 删除行业绑定的清单
industrySpecDao
.
removeIndustryProductInventory
(
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
()));
List
<
Integer
>
ids
=
industryProductInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
());
List
<
InventorySpecDO
>
inventorySpecList
=
industrySpecDao
.
listInventorySpec
(
ids
);
// 删除
industrySpecDao
.
removeInventorySpec
(
inventorySpecList
.
stream
().
map
(
InventorySpecDO:
:
getId
).
collect
(
Collectors
.
toList
()));
}
industrySpecDao
.
removeIndustrySpec
(
id
);
return
ResultBody
.
success
();
}
}
//
// @Override
// public List<IndustrySpecPriceDTO> listAppGoodsPriceByTagId(Integer goodsInfoId, Integer
// tagInfoId) {
// List<IndustrySpecPriceDO> industrySpecPriceDOS =
// industrySpecDao.listAppGoodsPriceByTagId(goodsInfoId, tagInfoId);
// if (CollectionUtils.isEmpty(industrySpecPriceDOS)) {
// return null;
// }
// List<IndustrySpecPriceDTO> collect =
// industrySpecPriceDOS.stream().map(IndustrySpecPriceDO::buildIndustrySpecPriceDTO).collect(Collectors.toList());
// return collect;
// }
}
src/main/java/com/mmc/pms/service/impl/InspComtServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.dao.InspComtDao
;
import
com.mmc.pms.entity.InspComtDO
;
import
com.mmc.pms.service.InspComtService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 评论表 服务实现类
*
* @author Pika
* @since 2023-06-09
*/
@Service
public
class
InspComtServiceImpl
implements
InspComtService
{
@Autowired
private
InspComtDao
inspComtDao
;
@Override
public
List
<
InspComtDO
>
randomGetInspComtList
(
Integer
size
)
{
return
inspComtDao
.
randomGetInspComtList
(
size
);
}
}
src/main/java/com/mmc/pms/service/impl/MiniProgramProductMallServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.MiniProgramProductMallDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.model.sale.dto.*
;
import
com.mmc.pms.model.sale.vo.GoodsProductSkuVO
;
import
com.mmc.pms.service.MiniProgramProductMallService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @Author small @Date 2023/5/16 15:08 @Version 1.0
*/
@Service
public
class
MiniProgramProductMallServiceImpl
implements
MiniProgramProductMallService
{
@Autowired
private
MiniProgramProductMallDao
goodsInfoDao
;
@Override
public
ResultBody
getAppGoodsInfoDetail
(
Integer
goodsId
)
{
// 查询此商品是否下架或删除
GoodsInfoDO
goodsInfoDO
=
goodsInfoDao
.
getGoodsInfoByGoodsId
(
goodsId
);
if
(
goodsInfoDO
==
null
||
goodsInfoDO
.
getShelfStatus
().
equals
(
0
))
{
return
ResultBody
.
error
(
ResultEnum
.
SHOP_GOODS_NOT_ERROR
);
}
AppGoodsInfoDetailDTO
appGoodsInfoDetailDTO
=
new
AppGoodsInfoDetailDTO
();
appGoodsInfoDetailDTO
.
setId
(
goodsInfoDO
.
getId
())
.
setGoodsName
(
goodsInfoDO
.
getGoodsName
())
.
setGoodsVideoId
(
goodsInfoDO
.
getGoodsVideoId
())
.
setMasterTypeId
(
goodsInfoDO
.
getMasterTypeId
())
.
setRepoId
(
goodsInfoDO
.
getRepoId
())
.
setSortTypeId
(
goodsInfoDO
.
getSortTypeId
())
.
setShelfStatus
(
goodsInfoDO
.
getShelfStatus
())
.
setSlaveTypeId
(
goodsInfoDO
.
getSlaveTypeId
())
.
setShareFlyServiceId
(
goodsInfoDO
.
getShareFlyServiceId
())
.
setGoodsVideo
(
goodsInfoDO
.
getVideoUrl
())
.
setTag
(
goodsInfoDO
.
getTag
())
.
setPid
(
goodsInfoDO
.
getPid
());
// 获取商品图片信息
List
<
GoodsImgDO
>
goodsImgDO
=
goodsInfoDao
.
listGoodsInfoByGoodsId
(
goodsId
);
appGoodsInfoDetailDTO
.
setImages
(
goodsImgDO
.
stream
().
map
(
GoodsImgDO:
:
buildGoodsImgDTO
).
collect
(
Collectors
.
toList
()));
// 获取商品详情信息
GoodsDetailDO
goodsDetailDO
=
goodsInfoDao
.
getGoodsDetailByGoodsId
(
goodsId
);
appGoodsInfoDetailDTO
.
setGoodsDetail
(
goodsDetailDO
.
buildGoodsDetailInfoDTO
());
// 获取其他服务信息
List
<
GoodsServiceDO
>
goodsServiceDO
=
goodsInfoDao
.
listGoodsServiceByGoodsId
(
goodsId
);
appGoodsInfoDetailDTO
.
setOtherService
(
goodsServiceDO
.
stream
()
.
map
(
GoodsServiceDO:
:
buildGoodsOtherServiceDTO
)
.
collect
(
Collectors
.
toList
()));
// 判断商品是什么类型
if
(!
goodsInfoDO
.
getSortTypeId
().
equals
(
2
))
{
// 获取该商品绑定的sku信息
List
<
MallProdInfoDO
>
mallProdSkuInfo
=
goodsInfoDao
.
getMallProdInfoByGoodsId
(
goodsId
);
// 获取该商品绑定的规格信息
List
<
MallProdSkuInfoSpecDO
>
mallProdSkuInfoSpecList
=
goodsInfoDao
.
listMallProdSkuInfoSpec
(
goodsId
);
Map
<
Integer
,
List
<
MallProdSkuInfoSpecDO
>>
specMap
=
mallProdSkuInfoSpecList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
MallProdSkuInfoSpecDO:
:
getMallProdSkuInfoId
));
List
<
GoodsSpecDTO
>
list
=
mallProdSkuInfo
.
stream
()
.
map
(
d
->
{
// 获取sku下规格信息
List
<
MallProdSkuInfoSpecDO
>
mallProdSkuInfoSpecDOList
=
specMap
.
get
(
d
.
getId
());
List
<
ProductSpecDO
>
productSpecList
=
goodsInfoDao
.
listProductSpecInfo
(
mallProdSkuInfoSpecDOList
.
stream
()
.
map
(
MallProdSkuInfoSpecDO:
:
getProductSpecId
)
.
collect
(
Collectors
.
toList
()));
List
<
MallProductSpecDTO
>
collect
=
productSpecList
.
stream
()
.
map
(
ProductSpecDO:
:
buildMallProductSpecDTO
)
.
collect
(
Collectors
.
toList
());
collect
.
stream
()
.
peek
(
m
->
{
for
(
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
:
mallProdSkuInfoSpecDOList
)
{
if
(
m
.
getProductSpec
()
.
equals
(
mallProdSkuInfoSpecDO
.
getProductSpecId
()))
{
m
.
setId
(
mallProdSkuInfoSpecDO
.
getId
());
break
;
}
}
})
.
collect
(
Collectors
.
toList
());
GoodsSpecDTO
goodsSpecDTO
=
new
GoodsSpecDTO
();
goodsSpecDTO
.
setId
(
d
.
getId
())
.
setSkuId
(
d
.
getProductId
())
.
setGoodsSpecName
(
d
.
getProdSkuSpecName
())
.
setSkuName
(
d
.
getProductSkuName
())
.
setBrandInfoId
(
d
.
getBrandInfoId
())
.
setCategoryId
(
d
.
getCategoriesId
())
.
setTypeName
(
d
.
getTypeName
())
.
setChooseType
(
d
.
getChooseType
())
.
setSkuUnitId
(
d
.
getSkuUnitId
())
.
setUnitName
(
d
.
getUnitName
())
.
setMust
(
d
.
getMust
())
.
setProductSpecList
(
collect
);
return
goodsSpecDTO
;
})
.
collect
(
Collectors
.
toList
());
appGoodsInfoDetailDTO
.
setGoodsSpec
(
list
);
}
else
{
appGoodsInfoDetailDTO
.
setGoodsSpec
(
getIndustrySpecInfo
(
goodsId
));
}
return
ResultBody
.
success
(
appGoodsInfoDetailDTO
);
}
private
List
<
GoodsSpecDTO
>
getIndustrySpecInfo
(
Integer
goodsInfoId
)
{
// 获取商品对应绑定的行业sku信息
List
<
MallIndustrySkuInfoDO
>
mallIndustrySkuInfoList
=
goodsInfoDao
.
getMallIndustrySkuInfo
(
goodsInfoId
);
List
<
GoodsSpecDTO
>
list
=
mallIndustrySkuInfoList
.
stream
()
.
map
(
MallIndustrySkuInfoDO:
:
buildGoodsSpecDTO
)
.
collect
(
Collectors
.
toList
());
// 根据商品id查出该商品下绑定的规格信息
List
<
MallIndustrySkuInfoSpecDO
>
mallIndustrySkuInfoSpec
=
goodsInfoDao
.
getIndustrySkuInfoSpec
(
goodsInfoId
);
list
=
list
.
stream
()
.
peek
(
d
->
{
List
<
MallIndustrySpecDTO
>
industrySpec
=
new
ArrayList
<>();
for
(
MallIndustrySkuInfoSpecDO
e
:
mallIndustrySkuInfoSpec
)
{
if
(
d
.
getId
().
equals
(
e
.
getMallIndustrySkuInfoId
()))
{
IndustrySpecDO
industrySpecDO
=
e
.
getIndustrySpecDO
();
// 获取商品清单信息
List
<
IndustryProductInventoryDO
>
industryProdInventory
=
goodsInfoDao
.
getIndustryProductInventory
(
e
.
getIndustrySpecId
());
List
<
ProductInventoryVO
>
productInventoryList
=
new
ArrayList
<>();
// 获取行业规格绑定的产品规格信息
List
<
InventorySpecDO
>
inventorySpecDOList
=
goodsInfoDao
.
listInventorySpec
(
industryProdInventory
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getId
)
.
collect
(
Collectors
.
toList
()));
Map
<
Integer
,
List
<
InventorySpecDO
>>
inventoryMap
=
inventorySpecDOList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
InventorySpecDO:
:
getIndustryProductInventoryId
));
getIndustrySpecOnProdSpecInfo
(
industryProdInventory
,
productInventoryList
,
inventoryMap
);
MallIndustrySpecDTO
industrySpecDTO
=
industrySpecDO
.
buildMallIndustrySpecDTO
();
industrySpecDTO
.
setId
(
e
.
getId
());
industrySpecDTO
.
setIndustrySpecId
(
e
.
getIndustrySpecId
());
industrySpecDTO
.
setIndustrySkuId
(
d
.
getSkuId
());
industrySpecDTO
.
setProductInventoryList
(
productInventoryList
);
industrySpec
.
add
(
industrySpecDTO
);
}
}
d
.
setIndustrySpecList
(
industrySpec
);
})
.
collect
(
Collectors
.
toList
());
return
list
;
}
private
void
getIndustrySpecOnProdSpecInfo
(
List
<
IndustryProductInventoryDO
>
industryProdInventory
,
List
<
ProductInventoryVO
>
productInventoryList
,
Map
<
Integer
,
List
<
InventorySpecDO
>>
inventoryMap
)
{
for
(
IndustryProductInventoryDO
industryProductInventoryDO
:
industryProdInventory
)
{
List
<
InventorySpecDO
>
inventorySpec
=
inventoryMap
.
get
(
industryProductInventoryDO
.
getId
());
if
(!
CollectionUtils
.
isEmpty
(
inventorySpec
))
{
List
<
ProductSpecVO
>
productSpecList
=
inventorySpec
.
stream
()
.
map
(
in
->
{
ProductSpecDO
productSpecDetail
=
goodsInfoDao
.
getProductSpecDetail
(
in
.
getProductSpecId
());
ProductSpecVO
productSpecVO
=
new
ProductSpecVO
();
BeanUtils
.
copyProperties
(
productSpecDetail
,
productSpecVO
);
return
productSpecVO
;
})
.
collect
(
Collectors
.
toList
());
ProductDO
productSkuDetail
=
goodsInfoDao
.
getProductSkuDetail
(
industryProductInventoryDO
.
getProductSkuId
());
GoodsProductSkuVO
goodsProductSkuVO
=
new
GoodsProductSkuVO
();
BeanUtils
.
copyProperties
(
productSkuDetail
,
goodsProductSkuVO
);
// 添加数据
ProductInventoryVO
productInventoryVO
=
new
ProductInventoryVO
();
productInventoryVO
.
setSelect
(
industryProductInventoryDO
.
getSelected
());
productInventoryVO
.
setProductSku
(
goodsProductSkuVO
);
productInventoryVO
.
setProductSpecList
(
productSpecList
);
productInventoryList
.
add
(
productInventoryVO
);
}
}
}
}
src/main/java/com/mmc/pms/service/impl/ProductServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.dao.IndustrySpecDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.model.lease.vo.PriceAcquisition
;
import
com.mmc.pms.model.qo.ProductSkuQO
;
import
com.mmc.pms.model.sale.dto.*
;
import
com.mmc.pms.model.sale.vo.ProductSpecCPQVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.ProductSkuService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* @author 23214
* @description 针对表【product_sku(产品sku表)】的数据库操作Service实现
* @createDate 2023-05-25 14:55:56
*/
@Service
public
class
ProductServiceImpl
implements
ProductSkuService
{
@Autowired
private
ProductDao
productDao
;
@Autowired
private
IndustrySpecDao
industrySpecDao
;
@Override
public
ResultBody
addProductSku
(
ProductSkuVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
productDao
.
countSkuName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
ProductDO
productSkuDO
=
new
ProductDO
(
param
);
productSkuDO
.
setCustomize
(
0
);
// 新增产品sku
int
status
=
productDao
.
insertProductSku
(
productSkuDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
getProductSkuDetail
(
Integer
id
)
{
// 校验此sku是否还存在或已删除
int
count
=
productDao
.
countProductIsExist
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
PRODUCT_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
ProductDO
productSkuDO
=
productDao
.
getProductDetail
(
id
);
return
ResultBody
.
success
(
productSkuDO
.
buildProductSkuDTO
());
}
@Override
public
ResultBody
editProductSku
(
ProductSkuVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
productDao
.
countSkuName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
ProductDO
productSkuDO
=
new
ProductDO
(
param
);
int
status
=
productDao
.
updateProductSku
(
productSkuDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
listPageProductSku
(
ProductSkuQO
productSkuQO
)
{
int
count
=
productDao
.
countListPageProductSku
(
productSkuQO
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
productSkuQO
.
getPageNo
(),
productSkuQO
.
getPageSize
(),
count
));
}
Integer
pageNo
=
productSkuQO
.
getPageNo
();
productSkuQO
.
buildCurrentPage
();
List
<
ProductDO
>
productSkuList
=
productDao
.
listPageProductSku
(
productSkuQO
);
List
<
Integer
>
productSkuIds
=
productSkuList
.
stream
().
map
(
ProductDO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
getProductSpecList
(
productSkuIds
);
Map
<
Integer
,
List
<
ProductSpecDO
>>
productSpecMap
=
productSpecList
.
stream
().
collect
(
Collectors
.
groupingBy
(
ProductSpecDO:
:
getProductId
));
List
<
ProductSkuDTO
>
list
=
productSkuList
.
stream
().
map
(
ProductDO:
:
buildProductSkuDTO
).
collect
(
Collectors
.
toList
());
list
.
stream
()
.
peek
(
d
->
{
List
<
ProductSpecDO
>
productSpecDOS
=
productSpecMap
.
get
(
d
.
getId
());
if
(
CollectionUtils
.
isEmpty
(
productSpecDOS
))
{
d
.
setProductSpecList
(
null
);
}
else
{
d
.
setProductSpecList
(
productSpecDOS
.
stream
()
.
map
(
ProductSpecDO:
:
buildProductSpecDTO
)
.
collect
(
Collectors
.
toList
()));
}
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
productSkuQO
.
getPageSize
(),
count
,
list
));
}
@Override
public
ResultBody
addOrEditProductSpec
(
ProductSpecVO
param
)
{
// 获取名称判断此前是否已经存在
int
count
=
productDao
.
countSpecName
(
param
);
if
(
count
>
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_CATEGORY_NAME_EXIST_ERROR
);
}
if
(
param
.
getId
()
==
null
)
{
ProductSpecDO
productSpecDO
=
new
ProductSpecDO
(
param
);
// 新增产品sku
int
status
=
productDao
.
insertProductSpec
(
productSpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_ADD_DATA
);
}
}
else
{
ProductSpecDO
productSpecDO
=
new
ProductSpecDO
(
param
);
int
status
=
productDao
.
updateProductSpec
(
productSpecDO
);
if
(
status
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
FAILED_TO_EDIT_DATA
);
}
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
getProductSpecDetail
(
Integer
id
)
{
// 校验此sku是否还存在或已删除
int
count
=
productDao
.
countSpecIsExist
(
id
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
ProductSpecDO
productSpecDO
=
productDao
.
getProductSpecDetail
(
id
);
return
ResultBody
.
success
(
productSpecDO
.
buildProductSpecDTO
());
}
@Override
public
ResultBody
listPageProductSpec
(
Integer
pageNo
,
Integer
pageSize
,
Integer
productSkuId
,
String
keyword
)
{
int
count
=
productDao
.
countListPageProductSpec
(
productSkuId
,
keyword
);
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
));
}
List
<
ProductSpecDO
>
productSpecList
=
productDao
.
listPageProductSpec
((
pageNo
-
1
)
*
pageSize
,
pageSize
,
productSkuId
,
keyword
);
List
<
Integer
>
specIds
=
productSpecList
.
stream
().
map
(
ProductSpecDO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
ProductSpecPriceDO
>
productSpecPrice
=
productDao
.
getProductSpecPriceList
(
specIds
);
Map
<
Integer
,
List
<
ProductSpecPriceDO
>>
priceMap
=
productSpecPrice
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
ProductSpecPriceDO:
:
getProductSpecId
));
List
<
ProductSpecDTO
>
list
=
productSpecList
.
stream
()
.
map
(
d
->
{
ProductSpecDTO
productSpecDTO
=
d
.
buildProductSpecDTO
();
if
(!
org
.
springframework
.
util
.
CollectionUtils
.
isEmpty
(
priceMap
.
get
(
d
.
getId
())))
{
productSpecDTO
.
setPriceList
(
priceMap
.
get
(
d
.
getId
()).
stream
()
.
map
(
ProductSpecPriceDO:
:
buildProductSpecPriceDTO
)
.
collect
(
Collectors
.
toList
()));
}
return
productSpecDTO
;
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
pageSize
,
count
,
list
));
}
@Override
public
ResultBody
productSpecCPQ
(
ProductSpecCPQVO
productSpecCPQVO
)
{
// 判断该规格是否存在
int
count
=
productDao
.
countSpecIsExist
(
productSpecCPQVO
.
getProductSpecId
());
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED
);
}
// 批量插入规格销售或租赁价格
return
insertSpecPrice
(
productSpecCPQVO
);
}
@Override
public
List
<
ProductSpecPriceDO
>
getProductSpecPriceDOS
(
ProductSpecCPQVO
productSpecCPQVO
)
{
// 批量插入规格价格
return
productSpecCPQVO
.
getSpecPrice
().
stream
()
.
map
(
d
->
{
ProductSpecPriceDO
productSpecPriceDO
=
new
ProductSpecPriceDO
();
productSpecPriceDO
.
setCooperationTag
(
d
.
getCooperationTag
());
productSpecPriceDO
.
setPrice
(
d
.
getPrice
());
productSpecPriceDO
.
setType
(
productSpecCPQVO
.
getType
());
productSpecPriceDO
.
setProductSpecId
(
productSpecCPQVO
.
getProductSpecId
());
if
(
productSpecCPQVO
.
getType
().
equals
(
1
))
{
productSpecPriceDO
.
setLeaseTerm
(
productSpecCPQVO
.
getLeaseTerm
());
}
return
productSpecPriceDO
;
})
.
collect
(
Collectors
.
toList
());
}
@Override
public
ResultBody
updateProductSpecCPQ
(
ProductSpecCPQVO
productSpecCPQVO
)
{
// 先删除原来该规格下的所有价格配置信息
productDao
.
removeProductSpecCPQ
(
productSpecCPQVO
);
// 批量插入规格销售或租赁价格
return
insertSpecPrice
(
productSpecCPQVO
);
}
@NotNull
public
ResultBody
insertSpecPrice
(
ProductSpecCPQVO
productSpecCPQVO
)
{
List
<
ProductSpecPriceDO
>
list
=
getProductSpecPriceDOS
(
productSpecCPQVO
);
if
(
productSpecCPQVO
.
getType
().
equals
(
1
)
&&
productSpecCPQVO
.
getLeaseTerm
()
==
null
)
{
return
ResultBody
.
error
(
"租赁期限不能为空!"
);
}
// 批量插入规格销售价格
if
(
productSpecCPQVO
.
getType
().
equals
(
0
))
{
productDao
.
batchInsertSpecPrice
(
list
);
}
else
{
// 批量插入租赁价格
productDao
.
batchInsertLeaseSpecPrice
(
list
);
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
getProductSpecCPQ
(
ProductSpecCPQVO
productSpecCPQVO
)
{
if
(
productSpecCPQVO
.
getType
().
equals
(
1
)
&&
productSpecCPQVO
.
getLeaseTerm
()
==
null
)
{
return
ResultBody
.
error
(
"租赁期限不能为空!"
);
}
List
<
ProductSpecPriceDO
>
productSpecPriceList
=
productDao
.
getProductSpecPrice
(
productSpecCPQVO
);
List
<
ProductSpecPriceDTO
>
list
=
productSpecPriceList
.
stream
()
.
map
(
ProductSpecPriceDO:
:
buildProductSpecPriceDTO
)
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
list
);
}
@Override
public
ResultBody
removeProductSku
(
Integer
id
)
{
// 判断该sku下是否有规格,没有则删除,有则不能删除
int
specCount
=
productDao
.
countSpecByProdSkuId
(
id
);
if
(
specCount
<=
0
)
{
// 删除
productDao
.
removeProductSku
(
id
);
return
ResultBody
.
success
();
}
else
{
return
ResultBody
.
error
(
ResultEnum
.
SPEC_EXIST_UNDER_THE_SKU
);
}
}
@Override
public
ResultBody
removeProductSpec
(
Integer
id
)
{
// 根据规格id查询绑定的商品或者行业的sku
RemoveSkuDTO
removeSkuDTO
=
new
RemoveSkuDTO
();
List
<
MallProdSkuInfoSpecDO
>
mallProdSkuInfoSpecList
=
productDao
.
listMallProductSpec
(
id
);
// 拿到清单的id
List
<
InventorySpecDO
>
inventorySpecList
=
productDao
.
listInventorySpec
(
id
);
if
(
mallProdSkuInfoSpecList
.
size
()
!=
0
||
inventorySpecList
.
size
()
!=
0
)
{
if
(
inventorySpecList
.
size
()
!=
0
)
{
// 根据清单id 获取行业规格id
Set
<
Integer
>
inventoryIds
=
inventorySpecList
.
stream
()
.
map
(
InventorySpecDO:
:
getIndustryProductInventoryId
)
.
collect
(
Collectors
.
toSet
());
List
<
IndustryProductInventoryDO
>
industryProductInventoryList
=
industrySpecDao
.
listIndustryProdInventory
(
inventoryIds
);
// 获取行业规格id
Set
<
Integer
>
industrySpecIds
=
industryProductInventoryList
.
stream
()
.
map
(
IndustryProductInventoryDO:
:
getIndustrySpecId
)
.
collect
(
Collectors
.
toSet
());
// 分别获取规格对应的sku信息
List
<
IndustrySpecDO
>
industrySpecList
=
industrySpecDao
.
listIndustrySpec
(
industrySpecIds
);
List
<
SkuAndSpecDTO
>
industrySkuNameList
=
new
ArrayList
<>();
industrySpecList
.
stream
()
.
peek
(
d
->
{
SkuAndSpecDTO
skuAndSpecDTO
=
new
SkuAndSpecDTO
();
skuAndSpecDTO
.
setIndustrySkuName
(
d
.
getSolutionName
());
skuAndSpecDTO
.
setIndustrySpecNames
(
d
.
getSpecName
());
industrySkuNameList
.
add
(
skuAndSpecDTO
);
})
.
collect
(
Collectors
.
toList
());
removeSkuDTO
.
setIndustrySkuName
(
industrySkuNameList
);
}
if
(
mallProdSkuInfoSpecList
.
size
()
!=
0
)
{
// 获取商品名称
List
<
String
>
goodsNameList
=
new
ArrayList
<>();
mallProdSkuInfoSpecList
.
forEach
(
d
->
goodsNameList
.
add
(
d
.
getGoodsName
()));
removeSkuDTO
.
setGoodsName
(
goodsNameList
);
}
return
ResultBody
.
success
(
removeSkuDTO
);
}
else
{
productDao
.
removeProductSpec
(
id
);
return
ResultBody
.
success
();
}
}
@Override
public
BigDecimal
feignGetUnitPriceByTag
(
PriceAcquisition
priceAcquisition
)
{
Map
<
Integer
,
Integer
>
dayMap
=
new
HashMap
<>();
dayMap
.
put
(
0
,
7
);
dayMap
.
put
(
8
,
15
);
dayMap
.
put
(
16
,
30
);
dayMap
.
put
(
31
,
Integer
.
MAX_VALUE
);
Integer
dayRange
=
dayMap
.
entrySet
().
stream
()
.
filter
(
entry
->
priceAcquisition
.
getDay
()
<=
entry
.
getKey
())
.
findFirst
()
.
map
(
Map
.
Entry
::
getValue
)
.
orElseThrow
(()
->
new
RuntimeException
(
"租赁期限错误错误!"
));
priceAcquisition
.
setDay
(
dayRange
);
return
productDao
.
feignGetUnitPriceByTag
(
priceAcquisition
);
}
@Override
public
ResultBody
productDirectoryList
()
{
List
<
DirectoryDO
>
directoryList
=
productDao
.
productDirectoryList
();
if
(
CollectionUtils
.
isNotEmpty
(
directoryList
))
{
return
ResultBody
.
success
(
directoryList
.
stream
()
.
map
(
DirectoryDO:
:
buildDirectoryInfoVO
)
.
collect
(
Collectors
.
toList
()));
}
return
ResultBody
.
success
();
}
}
src/main/java/com/mmc/pms/service/impl/WebDeviceServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.auth.dto.UserAccountSimpleDTO
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.common.ResultEnum
;
import
com.mmc.pms.constant.TokenConstant
;
import
com.mmc.pms.dao.CategoriesDao
;
import
com.mmc.pms.dao.GoodsInfoDao
;
import
com.mmc.pms.dao.ProductDao
;
import
com.mmc.pms.dao.WebDeviceDao
;
import
com.mmc.pms.entity.*
;
import
com.mmc.pms.feign.UserAppApi
;
import
com.mmc.pms.model.lease.dto.*
;
import
com.mmc.pms.model.lease.vo.LeaseVo
;
import
com.mmc.pms.model.other.dto.AdDTO
;
import
com.mmc.pms.model.other.dto.DistrictInfoDTO
;
import
com.mmc.pms.model.other.dto.ModelDTO
;
import
com.mmc.pms.model.qo.WareInfoQO
;
import
com.mmc.pms.model.sale.dto.MallGoodsDetailDTO
;
import
com.mmc.pms.model.sale.dto.SkuInfoDTO
;
import
com.mmc.pms.model.sale.vo.ProductSpecCPQVO
;
import
com.mmc.pms.model.sale.vo.SpecPriceVO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.WebDeviceService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @Author small @Date 2023/5/15 14:32 @Version 1.0
*/
@Service
public
class
WebDeviceServiceImpl
implements
WebDeviceService
{
@Autowired
WebDeviceDao
webDeviceDao
;
@Autowired
UserAppApi
userAppApi
;
@Autowired
ProductDao
productDao
;
@Autowired
GoodsInfoDao
goodsInfoDao
;
@Autowired
GoodsInfoServiceImpl
goodsInfoService
;
@Autowired
private
CategoriesDao
categoriesDao
;
@Override
public
ResultBody
listSecondDistrict
()
{
List
<
DistrictDO
>
list
=
webDeviceDao
.
listSecondDistrict
();
List
<
DistrictInfoDTO
>
dtoList
=
list
.
stream
().
map
(
DistrictDO:
:
builderDistrictInfoDTO
).
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
dtoList
);
}
@Override
public
ResultBody
category
()
{
List
<
DeviceCategory
>
category
=
webDeviceDao
.
category
();
List
<
DeviceCategoryDTO
>
collect
=
category
.
stream
()
.
map
(
t
->
{
return
t
.
deviceCategory
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
brand
()
{
List
<
Brand
>
brand
=
webDeviceDao
.
brand
();
List
<
BrandDTO
>
collect
=
brand
.
stream
()
.
map
(
t
->
{
return
t
.
brandDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
deviceBrand
()
{
List
<
Brand
>
brand
=
webDeviceDao
.
deviceBrand
();
List
<
BrandDTO
>
collect
=
brand
.
stream
()
.
map
(
t
->
{
return
t
.
brandDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
model
()
{
List
<
Model
>
model
=
webDeviceDao
.
model
();
List
<
ModelDTO
>
collect
=
model
.
stream
()
.
map
(
t
->
{
return
t
.
modelDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
deviceModel
()
{
List
<
Model
>
model
=
webDeviceDao
.
deviceModel
();
List
<
ModelDTO
>
collect
=
model
.
stream
()
.
map
(
t
->
{
return
t
.
modelDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
deviceList
(
Integer
districtId
,
Integer
categoryId
,
Integer
brandId
,
Integer
modelId
)
{
List
<
DeviceListDO
>
deviceList
=
webDeviceDao
.
deviceList
(
districtId
,
categoryId
,
brandId
,
modelId
);
List
<
DeviceListDTO
>
collect
=
deviceList
.
stream
()
.
map
(
t
->
{
return
t
.
deviceListDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
update
(
LeaseVo
param
)
{
InventoryDO
inventory
=
webDeviceDao
.
findInventory
(
param
.
getInventoryId
());
Integer
residueCount
=
inventory
.
getResidueCount
();
Integer
count
=
residueCount
-
param
.
getInventoryUsage
();
param
.
setInventoryUsage
(
count
);
int
update
=
webDeviceDao
.
update
(
param
);
return
ResultBody
.
success
(
update
);
}
@Override
public
ResultBody
detail
(
Integer
id
)
{
List
<
WareInfoDO
>
list
=
webDeviceDao
.
detail
(
id
);
List
<
WareInfoItemDTO
>
pageList
=
list
.
stream
()
.
map
(
d
->
{
return
d
.
buildWareInfoItemDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
pageList
);
}
@Override
public
ResultBody
listWareInfoPage
(
WareInfoQO
param
,
HttpServletRequest
request
,
Integer
userAccountId
)
{
List
<
Integer
>
userIds
=
null
;
if
(
param
.
getProvinceId
()
!=
null
)
{
userIds
=
userAppApi
.
feignListUserAccountIds
(
param
.
getProvinceId
(),
null
,
null
,
StringUtils
.
isBlank
(
request
.
getHeader
(
TokenConstant
.
TOKEN
))
?
null
:
request
.
getHeader
(
TokenConstant
.
TOKEN
));
if
(
userIds
==
null
||
userIds
.
size
()
==
0
)
{
userIds
=
Collections
.
singletonList
(-
1
);
}
}
int
count
=
webDeviceDao
.
countListWareInfoPage
(
param
.
getCategoryId
(),
userIds
,
param
.
getType
());
if
(
count
==
0
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
));
}
int
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
GoodsInfo
>
list
=
webDeviceDao
.
listWareInfoPage
(
param
,
userIds
,
param
.
getType
());
List
<
LeaseGoodsInfoDTO
>
pageList
=
list
.
stream
().
map
(
GoodsInfo:
:
buildLeaseGoodsInfoDTO
).
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isBlank
(
request
.
getHeader
(
TokenConstant
.
TOKEN
)))
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
));
}
UserAccountSimpleDTO
userAccountSimpleDTO
=
userAppApi
.
feignGetUserSimpleInfo
(
userAccountId
,
request
.
getHeader
(
TokenConstant
.
TOKEN
));
if
(
userAccountSimpleDTO
==
null
)
{
return
ResultBody
.
error
(
ResultEnum
.
INTERNAL_SERVER_ERROR
);
}
if
(
userAccountSimpleDTO
.
getCooperationTagId
()
==
null
)
{
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
));
}
List
<
Integer
>
goodsId
=
pageList
.
stream
().
map
(
LeaseGoodsInfoDTO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
MallProdSkuInfoSpecDO
>
mallProSkuInfoSpec
=
goodsInfoDao
.
listMallprodSpecById
(
goodsId
);
Map
<
Integer
,
MallProdSkuInfoSpecDO
>
specMap
=
mallProSkuInfoSpec
.
stream
()
.
collect
(
Collectors
.
toMap
(
MallProdSkuInfoSpecDO:
:
getGoodsInfoId
,
d
->
d
,
(
k1
,
k2
)
->
k1
));
pageList
.
stream
()
.
peek
(
d
->
{
MallProdSkuInfoSpecDO
mallProdSkuInfoSpecDO
=
specMap
.
get
(
d
.
getId
());
d
.
setPrice
(
mallProdSkuInfoSpecDO
.
getPrice
());
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
));
}
@Override
public
ResultBody
getLeaseGoodsDetail
(
Integer
goodsInfoId
,
Integer
userAccountId
,
HttpServletRequest
request
,
Integer
type
)
{
int
count
=
goodsInfoDao
.
countGoodsInfoById
(
goodsInfoId
);
if
(
count
<=
0
)
{
return
ResultBody
.
error
(
ResultEnum
.
GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF
);
}
// 初始化商品返回信息的对象
ResultBody
goodsInfoDetail
=
goodsInfoService
.
getGoodsInfoDetail
(
goodsInfoId
,
type
,
0
);
MallGoodsDetailDTO
result
=
(
MallGoodsDetailDTO
)
goodsInfoDetail
.
getResult
();
return
ResultBody
.
success
(
result
);
}
@Override
public
WareInfoDTO
getWareInfoById
(
Integer
id
)
{
WareInfoDO
wareInfoDO
=
webDeviceDao
.
getWareInfoById
(
id
);
WareDetailDO
wareDetailDO
=
webDeviceDao
.
getWareDetailById
(
id
);
if
(
wareInfoDO
!=
null
)
{
wareInfoDO
.
setWareDetailContent
(
wareDetailDO
.
getContent
());
}
return
wareInfoDO
==
null
?
null
:
wareInfoDO
.
buildWareInfoDTO
();
}
@Override
public
ResultBody
getPageHomeCategories
(
Integer
type
)
{
List
<
DirectoryDO
>
directoryList
=
categoriesDao
.
getDirectoryList
(
type
);
if
(
CollectionUtils
.
isNotEmpty
(
directoryList
))
{
List
<
Integer
>
directoryIds
=
directoryList
.
stream
().
map
(
DirectoryDO:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Categories
>
categoriesList
=
categoriesDao
.
getCategoriesListByDirectoryIds
(
directoryIds
);
return
ResultBody
.
success
(
categoriesList
.
stream
()
.
map
(
Categories:
:
buildCategoryTypeDTO
)
.
collect
(
Collectors
.
toList
()));
}
return
ResultBody
.
success
();
}
@Override
public
ResultBody
<
AdDTO
>
ad
()
{
List
<
AdDO
>
ad
=
webDeviceDao
.
ad
();
List
<
AdDTO
>
collect
=
ad
.
stream
()
.
map
(
t
->
{
return
t
.
adDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
List
<
SkuInfoDTO
>
listWareSkuById
(
Integer
id
)
{
List
<
SkuInfoDO
>
skuInfoDOS
=
webDeviceDao
.
listSkuInfo
(
id
);
return
skuInfoDOS
.
isEmpty
()
?
null
:
skuInfoDOS
.
stream
()
.
map
(
d
->
{
return
d
.
buildSkuInfoDTO
();
})
.
collect
(
Collectors
.
toList
());
}
@Override
public
ResultBody
<
ProductSpecCPQVO
>
getLeaseGoodsPriceDetail
(
Integer
productSpecId
,
Integer
leaseTerm
)
{
ProductSpecCPQVO
productSpecCPQVO
=
new
ProductSpecCPQVO
();
List
<
SpecPriceVO
>
specPriceList
=
goodsInfoDao
.
getPriceBySpecId
(
productSpecId
,
leaseTerm
);
productSpecCPQVO
.
setProductSpecId
(
productSpecId
);
productSpecCPQVO
.
setLeaseTerm
(
leaseTerm
);
productSpecCPQVO
.
setSpecPrice
(
specPriceList
);
return
ResultBody
.
success
(
productSpecCPQVO
);
}
}
src/main/java/com/mmc/pms/service/impl/WebProductMallServiceImpl.java
deleted
100644 → 0
浏览文件 @
1b165851
package
com
.
mmc
.
pms
.
service
.
impl
;
import
com.mmc.pms.common.ResultBody
;
import
com.mmc.pms.dao.WebProductMallDao
;
import
com.mmc.pms.entity.AdDO
;
import
com.mmc.pms.entity.GoodsInfoDO
;
import
com.mmc.pms.entity.ProductCategory
;
import
com.mmc.pms.model.other.dto.AdDTO
;
import
com.mmc.pms.model.qo.GoodsInfoQO
;
import
com.mmc.pms.model.sale.dto.GoodsInfoListDTO
;
import
com.mmc.pms.model.sale.dto.ProductCategoryDTO
;
import
com.mmc.pms.page.PageResult
;
import
com.mmc.pms.service.WebProductMallService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @Author small @Date 2023/5/15 20:08 @Version 1.0
*/
@Service
public
class
WebProductMallServiceImpl
implements
WebProductMallService
{
@Autowired
private
WebProductMallDao
webProductMallDao
;
@Override
public
ResultBody
productCategory
()
{
List
<
ProductCategory
>
category
=
webProductMallDao
.
productCategory
();
List
<
ProductCategoryDTO
>
collect
=
category
.
stream
()
.
map
(
t
->
{
return
t
.
productCategoryDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
productParts
()
{
List
<
ProductCategory
>
category
=
webProductMallDao
.
productParts
();
List
<
ProductCategoryDTO
>
collect
=
category
.
stream
()
.
map
(
t
->
{
return
t
.
productCategoryDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
productQuality
()
{
List
<
ProductCategory
>
category
=
webProductMallDao
.
productQuality
();
List
<
ProductCategoryDTO
>
collect
=
category
.
stream
()
.
map
(
t
->
{
return
t
.
productCategoryDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
ResultBody
<
AdDTO
>
ad
()
{
List
<
AdDO
>
ad
=
webProductMallDao
.
ad
();
List
<
AdDTO
>
collect
=
ad
.
stream
()
.
map
(
t
->
{
return
t
.
adDTO
();
})
.
collect
(
Collectors
.
toList
());
return
ResultBody
.
success
(
collect
);
}
@Override
public
PageResult
listPageGoodsInfo
(
GoodsInfoQO
param
)
{
int
count
=
webProductMallDao
.
countListGoodsInfo
(
param
);
if
(
count
==
0
)
{
return
PageResult
.
buildPage
(
param
.
getPageNo
(),
param
.
getPageSize
(),
count
);
}
Integer
pageNo
=
param
.
getPageNo
();
param
.
buildCurrentPage
();
List
<
GoodsInfoDO
>
goodsInfo
=
webProductMallDao
.
listGoodsInfo
(
param
);
goodsInfo
.
stream
()
.
forEach
(
t
->
{
Integer
product
=
webProductMallDao
.
findProduct
(
t
.
getId
());
t
.
setIsCoupons
(
product
);
});
List
<
GoodsInfoListDTO
>
pageList
=
goodsInfo
.
stream
().
map
(
GoodsInfoDO:
:
buildGoodsInfoListDTO
).
collect
(
Collectors
.
toList
());
return
PageResult
.
buildPage
(
pageNo
,
param
.
getPageSize
(),
count
,
pageList
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论