|
@@ -1,6 +1,7 @@
|
|
|
package com.fire.admin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -71,6 +72,19 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<ChannelInfo> getChannelInfoByOperator(Integer operator) {
|
|
|
+ if (operator != null) {
|
|
|
+ LambdaQueryWrapper<ChannelInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(ChannelInfo::getOperator, operator);
|
|
|
+ List<ChannelInfo> channelInfos = baseMapper.selectList(lambdaQueryWrapper);
|
|
|
+ if (ObjectUtil.isNotEmpty(channelInfos)) {
|
|
|
+ return channelInfos;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<ChannelSupplier> getSupplierInfo(String supplierName) {
|
|
|
return supplierService.getSupplierInfo(supplierName);
|
|
@@ -86,6 +100,7 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void updateChannelInfoById(ChannelInfo channelInfo) {
|
|
|
if (channelInfo != null) {
|
|
|
channelInfo.setUpdator(SecurityUtil.getUser().getUsername());
|
|
@@ -100,12 +115,13 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
log.info("添加的通道产品是:【{}】", channelInfo.getChannelProductInfos().toString());
|
|
|
}
|
|
|
} else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void insertChannelInfo(ChannelInfo channelInfo) {
|
|
|
if (channelInfo != null) {
|
|
|
if (channelInfo.getChannelId() == null) {
|
|
@@ -124,49 +140,29 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
log.info("添加的通道是:【{}】", channelInfo);
|
|
|
}
|
|
|
} else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void saveOrUpdateChannelInfos(List<ChannelInfo> channelInfos) {
|
|
|
- if (ObjectUtil.isNotEmpty(channelInfos)) {
|
|
|
- for (ChannelInfo info : channelInfos) {
|
|
|
- if (info.getChannelId() == null) {
|
|
|
- info.setChannelId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
- info.setCreator(SecurityUtil.getUser().getUsername());
|
|
|
- info.setCreateTime(new Date());
|
|
|
- log.info("添加的通道是:", channelInfos);
|
|
|
- } else {
|
|
|
- info.setUpdator(SecurityUtil.getUser().getUsername());
|
|
|
- info.setUpdateTime(new Date());
|
|
|
- log.info("修改的通道是:", channelInfos);
|
|
|
- }
|
|
|
- }
|
|
|
- this.saveOrUpdateBatch(channelInfos);
|
|
|
- } else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void deleteChannelAndChanProdByChannelId(Long channelId) {
|
|
|
if (channelId != null) {
|
|
|
int channelResult = baseMapper.deleteById(channelId);
|
|
|
int channelProductResult = channelProductService.deleteChannelProductByChanId(channelId);
|
|
|
- if (channelResult > 0 && channelProductResult > 0) {
|
|
|
+ if (channelResult > 0 || channelProductResult > 0) {
|
|
|
rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
log.info("编号为:【{}】的通道删除成功!", channelId);
|
|
|
log.info("通道编号为:【{}】的通道产品删除成功!", channelId);
|
|
|
}
|
|
|
} else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public int deleteChannelBySupplierId(Long supplierId) {
|
|
|
if (supplierId != null) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -179,7 +175,7 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
return 0;
|
|
|
}
|
|
|
} else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -192,23 +188,28 @@ public class ChannelInfoServiceImpl extends ServiceImpl<ChannelInfoMapper, Chann
|
|
|
return result;
|
|
|
}
|
|
|
} else {
|
|
|
- throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void setInvalid(Long channelId, Integer isValid) {
|
|
|
- ChannelInfo channelInfo = ChannelInfo.builder().channelId(channelId)
|
|
|
- .isValid(isValid).build();
|
|
|
- int result = baseMapper.updateById(channelInfo);
|
|
|
- if (result > 0) {
|
|
|
- rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
- if (channelInfo.getIsValid() == 0) {
|
|
|
- log.info("编号为【{}】的通道已置无效", channelId);
|
|
|
- } else {
|
|
|
- log.info("编号为【{}】的通道已置有效", channelId);
|
|
|
+ if (channelId != null && isValid != null) {
|
|
|
+ ChannelInfo channelInfo = ChannelInfo.builder().channelId(channelId)
|
|
|
+ .isValid(isValid).build();
|
|
|
+ int result = baseMapper.updateById(channelInfo);
|
|
|
+ if (result > 0) {
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
+ if (channelInfo.getIsValid() == 0) {
|
|
|
+ log.info("编号为【{}】的通道已置无效", channelId);
|
|
|
+ } else {
|
|
|
+ log.info("编号为【{}】的通道已置有效", channelId);
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ throw new BaseException(Status.PARAM_LOSS.status(), Status.PARAM_LOSS.message());
|
|
|
}
|
|
|
}
|
|
|
}
|