Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-shopmall-parent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f59604b6
authored
Apr 24, 2023
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
商品信息通知接口
1 parent
b44abd3c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
21 deletions
platform-shopmall-api/src/main/java/cn/com/glsx/admin/modules/model/cloudcrane/request/GoodsPriceNoticeRequest.java
platform-shopmall-api/src/main/java/cn/com/glsx/admin/modules/model/cloudcrane/request/GoodsStatusNoticeRequest.java
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/mapper/GoodsMapper.java
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/service/GoodsService.java
platform-shopmall/src/main/resources/mapper/GoodsMapper.xml
platform-shopmall-api/src/main/java/cn/com/glsx/admin/modules/model/cloudcrane/request/GoodsPriceNoticeRequest.java
View file @
f59604b
...
@@ -3,11 +3,13 @@ package cn.com.glsx.admin.modules.model.cloudcrane.request;
...
@@ -3,11 +3,13 @@ package cn.com.glsx.admin.modules.model.cloudcrane.request;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
@Data
@Data
public
class
GoodsPriceNoticeRequest
extends
AbstractCloudCraneRequest
{
public
class
GoodsPriceNoticeRequest
extends
AbstractCloudCraneRequest
{
@Schema
(
description
=
"商品Sku编码"
)
@Schema
(
description
=
"商品Sku编码"
)
private
String
goodsSkuCode
;
private
List
<
String
>
goodsSkuCodes
;
@Schema
(
description
=
"商品销售价"
)
@Schema
(
description
=
"商品销售价"
)
private
Double
sellPrice
;
private
Double
sellPrice
;
...
...
platform-shopmall-api/src/main/java/cn/com/glsx/admin/modules/model/cloudcrane/request/GoodsStatusNoticeRequest.java
View file @
f59604b
...
@@ -3,11 +3,13 @@ package cn.com.glsx.admin.modules.model.cloudcrane.request;
...
@@ -3,11 +3,13 @@ package cn.com.glsx.admin.modules.model.cloudcrane.request;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.Data
;
import
java.util.List
;
@Data
@Data
public
class
GoodsStatusNoticeRequest
extends
AbstractCloudCraneRequest
{
public
class
GoodsStatusNoticeRequest
extends
AbstractCloudCraneRequest
{
@Schema
(
description
=
"商品Sku编码"
)
@Schema
(
description
=
"商品Sku编码"
)
private
String
goodsSkuCode
;
private
List
<
String
>
goodsSkuCodes
;
@Schema
(
description
=
"商品上下架状态"
)
@Schema
(
description
=
"商品上下架状态"
)
private
Integer
shelvesStatus
;
private
Integer
shelvesStatus
;
...
...
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/mapper/GoodsMapper.java
View file @
f59604b
package
cn
.
com
.
glsx
.
admin
.
modules
.
mapper
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
mapper
;
import
cn.com.glsx.admin.modules.entity.Goods
;
import
cn.com.glsx.admin.modules.entity.Goods
;
import
cn.com.glsx.admin.modules.model.cloudcrane.request.QueryGoodsListByConditionRequest
;
import
cn.com.glsx.admin.modules.model.cloudcrane.request.QueryGoodsListByConditionRequestDTO
;
import
cn.com.glsx.admin.modules.model.cloudcrane.request.QueryGoodsListByConditionRequestDTO
;
import
cn.com.glsx.admin.modules.model.cloudcrane.response.*
;
import
cn.com.glsx.admin.modules.model.cloudcrane.response.GoodsSkuListItem
;
import
cn.com.glsx.admin.modules.model.cloudcrane.response.GoodsSkuListSearchItem
;
import
cn.com.glsx.admin.modules.model.cloudcrane.response.QueryGoodsPriceListResponse
;
import
cn.com.glsx.admin.modules.model.cloudcrane.response.QueryGoodsShelvesListResponse
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -28,4 +30,9 @@ public interface GoodsMapper extends CommonBaseMapper<Goods> {
...
@@ -28,4 +30,9 @@ public interface GoodsMapper extends CommonBaseMapper<Goods> {
int
insertOrUpdate
(
Goods
goods
);
int
insertOrUpdate
(
Goods
goods
);
Goods
selectByGoodsSkuCode
(
String
goodsSkuCode
);
Goods
selectByGoodsSkuCode
(
String
goodsSkuCode
);
int
batchUpdateShelvesStatus
(
@Param
(
"goodsList"
)
List
<
Goods
>
goodsList
);
int
batchUpdatePrices
(
@Param
(
"goodsList"
)
List
<
Goods
>
goodsList
);
}
}
\ No newline at end of file
\ No newline at end of file
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/service/GoodsService.java
View file @
f59604b
...
@@ -18,6 +18,7 @@ import com.github.pagehelper.PageInfo;
...
@@ -18,6 +18,7 @@ import com.github.pagehelper.PageInfo;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.common.utils.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.compress.utils.Lists
;
import
org.apache.kafka.clients.producer.KafkaProducer
;
import
org.apache.kafka.clients.producer.KafkaProducer
;
import
org.apache.kafka.clients.producer.ProducerRecord
;
import
org.apache.kafka.clients.producer.ProducerRecord
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.InitializingBean
;
...
@@ -26,7 +27,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
...
@@ -26,7 +27,6 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -319,30 +319,62 @@ public class GoodsService implements InitializingBean {
...
@@ -319,30 +319,62 @@ public class GoodsService implements InitializingBean {
}
}
public
void
goodsStatusNotice
(
GoodsStatusNoticeRequest
request
)
{
public
void
goodsStatusNotice
(
GoodsStatusNoticeRequest
request
)
{
Goods
goods
=
goodsMapper
.
selectByGoodsSkuCode
(
request
.
getGoodsSkuCode
());
List
<
Goods
>
goodsList
=
goodsMapper
.
selectByGoodsSkuCodes
(
request
.
getGoodsSkuCodes
());
if
(
goods
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
goodsList
)
)
{
return
;
return
;
}
}
goods
.
setShelvesStatus
(
request
.
getShelvesStatus
());
goods
.
setUpdatedDate
(
new
Date
());
goodsMapper
.
updateByPrimaryKey
(
goods
);
BizOrderNotifyMessage
message
=
buildGoodsStatusNotice
(
goods
);
Map
<
String
,
Goods
>
localGoodsMap
=
goodsList
.
stream
().
collect
(
Collectors
.
toMap
(
Goods:
:
getGoodsSkuCode
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
this
.
sendKafka
(
message
);
//去云中鹤查实时状态
List
<
QueryGoodsShelvesListResponse
>
goodsShelvesListResponse
=
cloudCraneService
.
queryGoodsShelvesList
(
request
.
getGoodsSkuCodes
());
List
<
Goods
>
updateGoodsList
=
Lists
.
newArrayList
();
goodsShelvesListResponse
.
forEach
(
shelvesResponse
->
{
Goods
localGoods
=
localGoodsMap
.
get
(
shelvesResponse
.
getGoodsSkuCode
());
if
(
localGoods
!=
null
)
{
if
(!
Objects
.
equals
(
shelvesResponse
.
getShelvesStatus
(),
localGoods
.
getShelvesStatus
()))
{
localGoods
.
setShelvesStatus
(
shelvesResponse
.
getShelvesStatus
());
updateGoodsList
.
add
(
localGoods
);
BizOrderNotifyMessage
message
=
buildGoodsStatusNotice
(
localGoods
);
this
.
sendKafka
(
message
);
}
}
});
if
(
CollectionUtils
.
isNotEmpty
(
updateGoodsList
))
{
goodsMapper
.
batchUpdateShelvesStatus
(
updateGoodsList
);
}
}
}
public
void
goodsPriceNotice
(
GoodsPriceNoticeRequest
request
)
{
public
void
goodsPriceNotice
(
GoodsPriceNoticeRequest
request
)
{
Goods
goods
=
goodsMapper
.
selectByGoodsSkuCode
(
request
.
getGoodsSkuCode
());
List
<
Goods
>
goodsList
=
goodsMapper
.
selectByGoodsSkuCodes
(
request
.
getGoodsSkuCodes
());
if
(
goods
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
goodsList
)
)
{
return
;
return
;
}
}
goods
.
setMarketPrice
(
request
.
getMarketPrice
());
goods
.
setSellPrice
(
request
.
getSellPrice
());
goods
.
setUpdatedDate
(
new
Date
());
goodsMapper
.
updateByPrimaryKey
(
goods
);
BizOrderNotifyMessage
message
=
buildGoodsPriceNotice
(
goods
);
Map
<
String
,
Goods
>
localGoodsMap
=
goodsList
.
stream
().
collect
(
Collectors
.
toMap
(
Goods:
:
getGoodsSkuCode
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
this
.
sendKafka
(
message
);
//去云中鹤查实时价格
List
<
QueryGoodsPriceListResponse
>
goodsPriceListResponse
=
cloudCraneService
.
queryGoodsPriceList
(
request
.
getGoodsSkuCodes
());
List
<
Goods
>
updateGoodsList
=
Lists
.
newArrayList
();
goodsPriceListResponse
.
forEach
(
priceResponse
->
{
Goods
localGoods
=
localGoodsMap
.
get
(
priceResponse
.
getGoodsSkuCode
());
if
(
localGoods
!=
null
)
{
if
(!
Objects
.
equals
(
priceResponse
.
getMarketPrice
(),
localGoods
.
getMarketPrice
())
||
!
Objects
.
equals
(
priceResponse
.
getSellPrice
(),
localGoods
.
getSellPrice
()))
{
localGoods
.
setMarketPrice
(
priceResponse
.
getMarketPrice
());
localGoods
.
setSellPrice
(
priceResponse
.
getSellPrice
());
updateGoodsList
.
add
(
localGoods
);
BizOrderNotifyMessage
message
=
buildGoodsPriceNotice
(
localGoods
);
this
.
sendKafka
(
message
);
}
}
});
if
(
CollectionUtils
.
isNotEmpty
(
updateGoodsList
))
{
goodsMapper
.
batchUpdatePrices
(
updateGoodsList
);
}
}
}
private
BizOrderNotifyMessage
buildGoodsStatusNotice
(
Goods
goods
)
{
private
BizOrderNotifyMessage
buildGoodsStatusNotice
(
Goods
goods
)
{
...
@@ -361,7 +393,8 @@ public class GoodsService implements InitializingBean {
...
@@ -361,7 +393,8 @@ public class GoodsService implements InitializingBean {
.
messageType
(
BizMessageTypeEnum
.
MessageTypeEnum
.
GOODS
.
getValue
())
.
messageType
(
BizMessageTypeEnum
.
MessageTypeEnum
.
GOODS
.
getValue
())
.
messageSmallType
(
BizMessageTypeEnum
.
MessageSmallTypeEnum
.
GOODS_CHANGE_PRICE
.
getValue
())
.
messageSmallType
(
BizMessageTypeEnum
.
MessageSmallTypeEnum
.
GOODS_CHANGE_PRICE
.
getValue
())
.
goodsSkuCode
(
goods
.
getGoodsSkuCode
())
.
goodsSkuCode
(
goods
.
getGoodsSkuCode
())
.
goodsSkuStatus
(
goods
.
getShelvesStatus
())
.
marketPrice
(
goods
.
getMarketPrice
())
.
sellPrice
(
goods
.
getSellPrice
())
.
time
(
DateUtils
.
currentDateTime
())
.
time
(
DateUtils
.
currentDateTime
())
.
build
();
.
build
();
return
message
;
return
message
;
...
...
platform-shopmall/src/main/resources/mapper/GoodsMapper.xml
View file @
f59604b
...
@@ -274,4 +274,27 @@
...
@@ -274,4 +274,27 @@
where sg.del_flag = 0
where sg.del_flag = 0
and sg.goods_sku_code = #{goodsSkuCode}
and sg.goods_sku_code = #{goodsSkuCode}
</select>
</select>
<update
id=
"batchUpdateShelvesStatus"
parameterType=
"java.util.List"
>
<foreach
collection=
"goodsList"
item=
"item"
index=
"index"
open=
""
close=
""
separator=
";"
>
update shopmall_goods
<set>
shelves_status=${item.shelvesStatus},
updated_date=sysdate()
</set>
where id = ${item.id}
</foreach>
</update>
<update
id=
"batchUpdatePrices"
parameterType=
"java.util.List"
>
<foreach
collection=
"goodsList"
item=
"item"
index=
"index"
open=
""
close=
""
separator=
";"
>
update shopmall_goods
<set>
sell_price=${item.sellPrice},
market_price=${item.marketPrice},
updated_date=sysdate()
</set>
where id = ${item.id}
</foreach>
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment