记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
207dd82d
Commit
207dd82d
authored
Dec 31, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
库存相关 redis
parent
26ab013e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
GoblinStorePurchasingServiceImpl.java
...service/impl/manage/GoblinStorePurchasingServiceImpl.java
+25
-4
No files found.
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinStorePurchasingServiceImpl.java
View file @
207dd82d
...
@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
...
@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.CollectionUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.base.constant.MQConst
;
import
com.liquidnet.service.base.constant.MQConst
;
...
@@ -220,13 +221,13 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
...
@@ -220,13 +221,13 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
String
marketSpuId
=
params
.
getSpuId
().
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
params
.
getStoreMarketId
()));
String
marketSpuId
=
params
.
getSpuId
().
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
params
.
getStoreMarketId
()));
GoblinMarketRelationVo
relationVo
=
GoblinMarketRelationVo
.
getNew
();
GoblinMarketRelationVo
relationVo
=
GoblinMarketRelationVo
.
getNew
();
relationVo
.
setSpuId
(
params
.
getSpuId
());
relationVo
.
setSpuId
(
params
.
getSpuId
());
List
<
String
>
skuList
=
CollectionUtil
.
arrayListString
();
List
<
String
>
skuList
=
CollectionUtil
.
arrayListString
();
//skuId数组
List
<
String
>
marketSkuList
=
CollectionUtil
.
arrayListString
();
List
<
String
>
marketSkuList
=
CollectionUtil
.
arrayListString
();
//活动skuId数组
List
<
String
>
errorNameList
=
CollectionUtil
.
arrayListString
();
//修改失败的款式名称数组
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
LinkedList
<
String
>
sqls
=
CollectionUtil
.
linkedListString
();
sqls
.
add
(
SqlMapping
.
get
(
"goblin.store.market.insertRelation"
));
sqls
.
add
(
SqlMapping
.
get
(
"goblin.store.market.insertRelation"
));
LinkedList
<
Object
[]>
sqlsData
=
CollectionUtil
.
linkedListObjectArr
();
LinkedList
<
Object
[]>
sqlsData
=
CollectionUtil
.
linkedListObjectArr
();
for
(
GoblinStorePurchaseItemParam
item
:
params
.
getGoblinStorePurchaseItemParam
())
{
for
(
GoblinStorePurchaseItemParam
item
:
params
.
getGoblinStorePurchaseItemParam
())
{
//todo 修改 相关vo 修改库存 判断库存
String
purchaseId
=
IDGenerator
.
nextMilliId2
();
String
purchaseId
=
IDGenerator
.
nextMilliId2
();
GoblinStoreMarketPurchasing
bean
=
GoblinStoreMarketPurchasing
.
getNew
();
GoblinStoreMarketPurchasing
bean
=
GoblinStoreMarketPurchasing
.
getNew
();
bean
.
setStoreId
(
params
.
getStoreId
());
bean
.
setStoreId
(
params
.
getStoreId
());
...
@@ -243,6 +244,14 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
...
@@ -243,6 +244,14 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
bean
.
setCreatedAt
(
now
);
bean
.
setCreatedAt
(
now
);
//mongo
//mongo
GoblinGoodsSkuInfoVo
skuVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
item
.
getSkuId
());
GoblinGoodsSkuInfoVo
skuVo
=
goblinRedisUtils
.
getGoodsSkuInfoVo
(
item
.
getSkuId
());
//判断库存相关
int
restStock
=
goblinRedisUtils
.
decrSkuStock
(
null
,
item
.
getSkuId
(),
item
.
getStockMarketing
());
if
(
restStock
<
0
)
{
errorNameList
.
add
(
skuVo
.
getName
());
goblinRedisUtils
.
incrSkuStock
(
null
,
item
.
getSkuId
(),
item
.
getStockMarketing
());
continue
;
}
goblinRedisUtils
.
setSkuStock
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
item
.
getSkuId
(),
item
.
getStockMarketing
());
skuVo
.
setSpuId
(
marketSpuId
);
skuVo
.
setSpuId
(
marketSpuId
);
skuVo
.
setSkuId
(
item
.
getSkuId
().
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
params
.
getStoreMarketId
())));
skuVo
.
setSkuId
(
item
.
getSkuId
().
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
params
.
getStoreMarketId
())));
skuVo
.
setPrice
(
bean
.
getPriceMarketing
());
skuVo
.
setPrice
(
bean
.
getPriceMarketing
());
...
@@ -276,6 +285,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
...
@@ -276,6 +285,9 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
String
sqlData
=
SqlMapping
.
gets
(
sqls
,
sqlsData
);
String
sqlData
=
SqlMapping
.
gets
(
sqls
,
sqlsData
);
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_STORE_MARKET
.
getKey
(),
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_STORE_MARKET
.
getKey
(),
sqlData
);
sqlData
);
if
(
errorNameList
.
size
()
>
0
)
{
return
ResponseDto
.
failure
(
JsonUtils
.
toJson
(
errorNameList
));
}
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
}
...
@@ -331,7 +343,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
...
@@ -331,7 +343,7 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
@Override
@Override
public
ResponseDto
<
Boolean
>
purchasingSpuDel
(
String
marketId
,
String
storeId
,
String
spuId
)
{
public
ResponseDto
<
Boolean
>
purchasingSpuDel
(
String
marketId
,
String
storeId
,
String
spuId
)
{
//
todo 修改 相关vo 修改库存 判断库存
//
判断 如果有订单待支付 则不能关闭
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
String
marketSpuId
=
spuId
.
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
marketId
));
String
marketSpuId
=
spuId
.
concat
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
()).
concat
(
IDGenerator
.
marketGoodId
(
marketId
));
GoblinStoreMarketPurchasing
bean
=
GoblinStoreMarketPurchasing
.
getNew
();
GoblinStoreMarketPurchasing
bean
=
GoblinStoreMarketPurchasing
.
getNew
();
...
@@ -343,6 +355,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
...
@@ -343,6 +355,15 @@ public class GoblinStorePurchasingServiceImpl implements IGoblinStorePurchasingS
goblinRedisUtils
.
delGoodsInfoVo
(
marketSpuId
);
goblinRedisUtils
.
delGoodsInfoVo
(
marketSpuId
);
goblinRedisUtils
.
removeMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
marketId
,
spuId
);
goblinRedisUtils
.
removeMarketRelation
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
marketId
,
spuId
);
goblinRedisUtils
.
delStoreMarketIsConfig
(
marketId
,
storeId
,
spuId
,
marketSpuId
);
goblinRedisUtils
.
delStoreMarketIsConfig
(
marketId
,
storeId
,
spuId
,
marketSpuId
);
//库存处理
GoblinGoodsInfoVo
marketVo
=
goblinRedisUtils
.
getGoodsInfoVo
(
marketSpuId
);
for
(
String
marketSkuId
:
marketVo
.
getSkuIdList
())
{
String
skuId
=
marketSkuId
.
split
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
())[
0
];
//库存回滚
int
restStock
=
goblinRedisUtils
.
getSkuStock
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
marketSkuId
);
int
restStockDe
=
goblinRedisUtils
.
decrSkuStock
(
GoblinStatusConst
.
MarketPreStatus
.
MARKET_PRE_PURCHASE
.
getValue
(),
marketSkuId
,
restStock
);
goblinRedisUtils
.
incrSkuStock
(
null
,
skuId
,
restStock
+
restStockDe
);
}
//mysql
//mysql
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_STORE_MARKET
.
getKey
(),
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
GOBLIN_STORE_MARKET
.
getKey
(),
SqlMapping
.
get
(
"goblin.store.market.delSpuRelation"
,
bean
.
getDelFlag
(),
bean
.
getUpdatedAt
(),
marketId
,
storeId
,
spuId
));
SqlMapping
.
get
(
"goblin.store.market.delSpuRelation"
,
bean
.
getDelFlag
(),
bean
.
getUpdatedAt
(),
marketId
,
storeId
,
spuId
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment