release- 下架与mall联动

release-2024-08-08
pikaqiudeshujia 7 months ago
parent c882c8207b
commit 04f28b30c7

@ -24,7 +24,9 @@ public enum AlbumStateEnum {
ARRIVED(4, "已上架"), ARRIVED(4, "已上架"),
DELETE(5, "已删除") DELETE(5, "已删除"),
REMOVAL(6, "下架")
; ;
private Integer code; private Integer code;

@ -342,6 +342,10 @@ public class AlbumService {
// 删除操作 // 删除操作
deleteAlbum(artistAlbum); deleteAlbum(artistAlbum);
break; break;
case 6:
//下架操作
removal(artistAlbum);
break;
default: default:
// 其他不允许操作 // 其他不允许操作
throw new BizException(ErrorConstants.STATE_ERROR); throw new BizException(ErrorConstants.STATE_ERROR);
@ -421,6 +425,7 @@ public class AlbumService {
} }
// 拼接MALL模块需要的商品对象和参数对象 // 拼接MALL模块需要的商品对象和参数对象
// 上架的同时发起MQMALL接收到后会调用商品新增的接口
List<SongInfo> songInfoList = songInfoDao.findByAlbumId(artistAlbum.getId()); List<SongInfo> songInfoList = songInfoDao.findByAlbumId(artistAlbum.getId());
for (SongInfo songInfo : songInfoList) { for (SongInfo songInfo : songInfoList) {
MallProduct mallProduct = MallProduct.builder() MallProduct mallProduct = MallProduct.builder()
@ -447,9 +452,17 @@ public class AlbumService {
rabbitTemplate.convertAndSend("luoo_mall_product_add", mallMqMap); rabbitTemplate.convertAndSend("luoo_mall_product_add", mallMqMap);
} }
}
// 下架操作
private void removal(ArtistAlbum artistAlbum) {
// 只有上架允许下架
if (ObjectUtils.notEqual(AlbumStateEnum.ARRIVED.getCode(), artistAlbum.getState())) {
throw new BizException(ErrorConstants.STATE_ERROR);
}
// 上架的同时发起MQMALL接收到后会调用商品新增的接口 // 下架或删除的同时发起MQMALL接收到后会调用商品下架的接口
rabbitTemplate.convertAndSend("luoo_mall_product_delete", artistAlbum.getId());
} }
/** /**
@ -459,12 +472,13 @@ public class AlbumService {
*/ */
private void deleteAlbum(ArtistAlbum artistAlbum) { private void deleteAlbum(ArtistAlbum artistAlbum) {
// 只有新建,待上架,已驳回状态下允许删除 // 只有新建,待上架,已驳回,下架状态下允许删除
Integer state = artistAlbum.getState(); Integer state = artistAlbum.getState();
Integer[] allowState = new Integer[]{ Integer[] allowState = new Integer[]{
AlbumStateEnum.SAVE.getCode(), AlbumStateEnum.SAVE.getCode(),
AlbumStateEnum.WAIT_ARRIVE.getCode(), AlbumStateEnum.WAIT_ARRIVE.getCode(),
AlbumStateEnum.BACK.getCode() AlbumStateEnum.BACK.getCode(),
AlbumStateEnum.REMOVAL.getCode()
}; };
if (!Arrays.asList(allowState).contains(state)) { if (!Arrays.asList(allowState).contains(state)) {
throw new BizException(ErrorConstants.STATE_ERROR); throw new BizException(ErrorConstants.STATE_ERROR);

Loading…
Cancel
Save