Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
sibu-v-mall
/
sibu-v-mall-third-api
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
a55a1469
由
刘嘉
编写于
2018-04-11 13:22:57 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
菠萝派接口- 更改库存接口修改
1 个父辈
e9a791bb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
63 行增加
和
59 行删除
com.sibu.orderHelper.service/src/main/java/com/sibu/orderHelper/integral/service/pineapple/impl/SyncStockBizServiceImpl.java
com.sibu.orderHelper.service/src/main/java/com/sibu/orderHelper/integral/service/pineapple/impl/SyncStockBizServiceImpl.java
查看文件 @
a55a146
...
...
@@ -38,70 +38,45 @@ public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncSto
params
.
put
(
"productId"
,
callRequest
.
getBizModel
().
getPlatProductID
());
//先判断SKU在判断产品
IMProductBean
iMProductBean
=
pineappleDao
.
getIMProductBeanByMap
(
params
);
if
(!
StringUtil
.
isNull
(
iMProductBean
)){
if
(
callRequest
.
getBizModel
().
getQuantity
()
<
0
){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
}
if
(!
StringUtil
.
isNull
(
callRequest
.
getBizModel
().
getSkuID
())
)
{
params
.
put
(
"skuId"
,
callRequest
.
getBizModel
().
getSkuID
());
//查询该条SKUi
SkuBean
skuBean
=
pineappleDao
.
getSkuBeanByMap
(
params
);
if
(
StringUtil
.
isNull
(
skuBean
)){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
}
//更新该条SKU
skuBean
.
setStockNum
(
callRequest
.
getBizModel
().
getQuantity
());
if
(
pineappleDao
.
updateSku
(
skuBean
)
>
0
){
//根据产品ID获取所有SKU总数
List
<
SkuApiResponse
>
skuBeanList
=
pineappleDao
.
getSkuBeanListByMap
(
callRequest
.
getBizModel
().
getPlatProductID
());
if
(!
StringUtil
.
isNull
(
skuBeanList
)){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU集合,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU集合,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
}
//更新SKU缓存
RedisProductSkuService
.
setProductSkuFromRedis
(
skuBeanList
,
callRequest
.
getBizModel
().
getSkuID
());
Integer
sumStock
=
skuBeanList
.
stream
().
map
(
s
->
s
.
getStockNum
()).
reduce
(
0
,(
a
,
b
)
->{
return
a
+
b
;
});
//更新产品
params
.
put
(
"stockNum"
,
sumStock
);
if
(
pineappleDao
.
updateProduct
(
params
)
>
0
){
//更新产品缓存
RedisProductStockService
.
setProductStock
(
iMProductBean
.
getImProductId
(),
sumStock
);
//1、更新商品库存
IMProductInventory
productInventory
=
new
IMProductInventory
();
productInventory
.
setImProductId
(
iMProductBean
.
getImProductId
());
productInventory
.
setStockNum
(
sumStock
);
if
(
pineappleDao
.
updateProductInventory
(
productInventory
)
>
0
){
//更新缓存
pineappleSyncStockResponse
.
setQuantity
(
String
.
valueOf
(
callRequest
.
getBizModel
().
getQuantity
()));
pineappleSyncStockResponse
.
setMessage
(
PineappleEnum
.
SUCCESS
.
getMsg
());
pineappleSyncStockResponse
.
setCode
(
PineappleEnum
.
SUCCESS
.
getCode
());
return
pineappleSyncStockResponse
;
}
}
else
{
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,更新产品库存失败,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,更新产品库存失败,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
()));
}
}
if
(
StringUtil
.
isNull
(
iMProductBean
)){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,没有该商品"
,
callRequest
.
getRequest
().
getAppkey
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,没有该商品"
,
callRequest
.
getRequest
().
getAppkey
()));
}
if
(
callRequest
.
getBizModel
().
getQuantity
()
<
0
){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0"
,
callRequest
.
getRequest
().
getAppkey
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0"
,
callRequest
.
getRequest
().
getAppkey
()));
}
if
(!
StringUtil
.
isNull
(
callRequest
.
getBizModel
().
getSkuID
())
)
{
params
.
put
(
"skuId"
,
callRequest
.
getBizModel
().
getSkuID
());
//查询该条SKUi
SkuBean
skuBean
=
pineappleDao
.
getSkuBeanByMap
(
params
);
if
(
StringUtil
.
isNull
(
skuBean
)){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU"
,
callRequest
.
getRequest
().
getAppkey
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU"
,
callRequest
.
getRequest
().
getAppkey
()));
}
if
(!
StringUtil
.
isNull
(
callRequest
.
getBizModel
().
getPlatProductID
())){
//更新该条SKU
skuBean
.
setStockNum
(
callRequest
.
getBizModel
().
getQuantity
());
if
(
pineappleDao
.
updateSku
(
skuBean
)
>
0
){
//根据产品ID获取所有SKU总数
List
<
SkuApiResponse
>
skuBeanList
=
pineappleDao
.
getSkuBeanListByMap
(
callRequest
.
getBizModel
().
getPlatProductID
());
if
(!
StringUtil
.
isNull
(
skuBeanList
)
&&
!
skuBeanList
.
isEmpty
()
){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,
该产品有SKU,请指定SKUID,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantit
y
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,该产品有SKU,请指定SKUID,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
(
)));
if
(!
StringUtil
.
isNull
(
skuBeanList
)){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,
查询不到该SKU集合"
,
callRequest
.
getRequest
().
getAppke
y
()));
throw
new
BizException
(
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,查询不到该SKU集合"
,
callRequest
.
getRequest
().
getAppkey
()
)));
}
params
.
put
(
"stockNum"
,
callRequest
.
getBizModel
().
getQuantity
());
//更新SKU缓存
RedisProductSkuService
.
setProductSkuFromRedis
(
skuBeanList
,
callRequest
.
getBizModel
().
getSkuID
());
Integer
sumStock
=
skuBeanList
.
stream
().
map
(
s
->
s
.
getStockNum
()).
reduce
(
0
,(
a
,
b
)
->{
return
a
+
b
;
});
//更新产品
params
.
put
(
"stockNum"
,
sumStock
);
if
(
pineappleDao
.
updateProduct
(
params
)
>
0
){
//更新产品
RedisProductStockService
.
setProductStock
(
iMProductBean
.
getImProductId
(),
callRequest
.
getBizModel
().
getQuantity
()
);
//更新产品
缓存
RedisProductStockService
.
setProductStock
(
iMProductBean
.
getImProductId
(),
sumStock
);
//1、更新商品库存
IMProductInventory
productInventory
=
new
IMProductInventory
();
productInventory
.
setImProductId
(
iMProductBean
.
getImProductId
());
productInventory
.
setStockNum
(
callRequest
.
getBizModel
().
getQuantity
()
);
productInventory
.
setStockNum
(
sumStock
);
if
(
pineappleDao
.
updateProductInventory
(
productInventory
)
>
0
){
//更新缓存
pineappleSyncStockResponse
.
setQuantity
(
String
.
valueOf
(
callRequest
.
getBizModel
().
getQuantity
()));
...
...
@@ -109,11 +84,40 @@ public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncSto
pineappleSyncStockResponse
.
setCode
(
PineappleEnum
.
SUCCESS
.
getCode
());
return
pineappleSyncStockResponse
;
}
}
else
{
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败"
,
callRequest
.
getRequest
().
getAppkey
()));
throw
new
BizException
((
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败"
,
callRequest
.
getRequest
().
getAppkey
())));
}
}
else
{
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新sku库存失败"
,
callRequest
.
getRequest
().
getAppkey
()));
throw
new
BizException
((
String
.
format
(
"菠萝派商城appkey[%s]更新sku库存失败"
,
callRequest
.
getRequest
().
getAppkey
())));
}
}
if
(!
StringUtil
.
isNull
(
callRequest
.
getBizModel
().
getPlatProductID
())){
List
<
SkuApiResponse
>
skuBeanList
=
pineappleDao
.
getSkuBeanListByMap
(
callRequest
.
getBizModel
().
getPlatProductID
());
if
(!
StringUtil
.
isNull
(
skuBeanList
)
&&
!
skuBeanList
.
isEmpty
()){
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,该产品有SKU,请指定SKUID,method:%s,PlatProductID:%s,SkuID:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,该产品有SKU,请指定SKUID,method:%s,PlatProductID:%s,SkuID:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
()));
}
params
.
put
(
"stockNum"
,
callRequest
.
getBizModel
().
getQuantity
());
if
(
pineappleDao
.
updateProduct
(
params
)
>
0
){
//更新产品
RedisProductStockService
.
setProductStock
(
iMProductBean
.
getImProductId
(),
callRequest
.
getBizModel
().
getQuantity
());
//1、更新商品库存
IMProductInventory
productInventory
=
new
IMProductInventory
();
productInventory
.
setImProductId
(
iMProductBean
.
getImProductId
());
productInventory
.
setStockNum
(
callRequest
.
getBizModel
().
getQuantity
());
if
(
pineappleDao
.
updateProductInventory
(
productInventory
)
>
0
){
//更新缓存
pineappleSyncStockResponse
.
setQuantity
(
String
.
valueOf
(
callRequest
.
getBizModel
().
getQuantity
()));
pineappleSyncStockResponse
.
setMessage
(
PineappleEnum
.
SUCCESS
.
getMsg
());
pineappleSyncStockResponse
.
setCode
(
PineappleEnum
.
SUCCESS
.
getCode
());
return
pineappleSyncStockResponse
;
}
}
}
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]
更新库存失败,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantit
y
()));
throw
new
BizException
(
String
.
format
(
"菠萝派商城appkey[%s]更新库存失败,method:%s,PlatProductID:%s,SkuID:s%,Quantity:%s"
,
callRequest
.
getRequest
().
getAppkey
(),
callRequest
.
getRequest
().
getMethod
(),
callRequest
.
getBizModel
().
getPlatProductID
(),
callRequest
.
getBizModel
().
getSkuID
(),
callRequest
.
getBizModel
().
getQuantity
(
)));
log
.
error
(
String
.
format
(
"菠萝派商城appkey[%s]
没有更改到库存"
,
callRequest
.
getRequest
().
getAppke
y
()));
throw
new
BizException
(
(
String
.
format
(
"菠萝派商城appkey[%s]没有更改到库存"
,
callRequest
.
getRequest
().
getAppkey
()
)));
}
@Override
...
...
请
注册
或
登录
后发表评论