|
@@ -14,11 +14,11 @@ import com.fire.dto.ChannelSupplier;
|
|
import com.fire.dto.enums.Status;
|
|
import com.fire.dto.enums.Status;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.messaging.support.MessageBuilder;
|
|
import org.springframework.messaging.support.MessageBuilder;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import redis.clients.jedis.JedisCluster;
|
|
import redis.clients.jedis.JedisCluster;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -38,13 +38,13 @@ import static com.fire.dto.enums.RedisKey.GLOBAL_ID_INCR;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, ChannelSupplier> implements SupplierService {
|
|
public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, ChannelSupplier> implements SupplierService {
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private BankCardService bankCardService;
|
|
private BankCardService bankCardService;
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private RocketMQTemplate rocketMQTemplate;
|
|
private RocketMQTemplate rocketMQTemplate;
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
+ @Resource
|
|
private JedisCluster jedisCluster;
|
|
private JedisCluster jedisCluster;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -74,8 +74,10 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void updateSupplierById(ChannelSupplier channelSupplier) {
|
|
public void updateSupplierById(ChannelSupplier channelSupplier) {
|
|
- channelSupplier.setUpdator("admin");
|
|
|
|
- channelSupplier.setUpdateTime(new Date());
|
|
|
|
|
|
+ if (channelSupplier != null) {
|
|
|
|
+ channelSupplier.setUpdator("admin");
|
|
|
|
+ channelSupplier.setUpdateTime(new Date());
|
|
|
|
+ }
|
|
LambdaUpdateWrapper<ChannelSupplier> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<ChannelSupplier> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
lambdaUpdateWrapper.eq(channelSupplier.getSupplierId() != null, ChannelSupplier::getSupplierId, channelSupplier.getSupplierId());
|
|
lambdaUpdateWrapper.eq(channelSupplier.getSupplierId() != null, ChannelSupplier::getSupplierId, channelSupplier.getSupplierId());
|
|
int result = baseMapper.update(channelSupplier, lambdaUpdateWrapper);
|
|
int result = baseMapper.update(channelSupplier, lambdaUpdateWrapper);
|
|
@@ -91,20 +93,26 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
|
|
bankCard.setRelationId(channelSupplier.getSupplierId());
|
|
bankCard.setRelationId(channelSupplier.getSupplierId());
|
|
});
|
|
});
|
|
|
|
|
|
- bankCardService.saveBankCards(channelSupplier.getBankCards());
|
|
|
|
|
|
+ bankCardService.saveOrUpdateBankCards(channelSupplier.getBankCards());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void saveSupplier(ChannelSupplier channelSupplier) {
|
|
public void saveSupplier(ChannelSupplier channelSupplier) {
|
|
- channelSupplier.setCreator("admin");
|
|
|
|
- channelSupplier.setCreateTime(new Date());
|
|
|
|
- channelSupplier.setSupplierId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
|
- int result = baseMapper.insert(channelSupplier);
|
|
|
|
- if (result > 0) {
|
|
|
|
- rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
|
- log.info("添加的供应商是:【{}】", channelSupplier);
|
|
|
|
|
|
+ if (channelSupplier != null) {
|
|
|
|
+ if (channelSupplier.getSupplierId() == null) {
|
|
|
|
+ channelSupplier.setSupplierId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
|
|
|
|
+ }
|
|
|
|
+ channelSupplier.setCreator("admin");
|
|
|
|
+ channelSupplier.setCreateTime(new Date());
|
|
|
|
+ int result = baseMapper.insert(channelSupplier);
|
|
|
|
+ if (result > 0) {
|
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
|
+ log.info("添加的供应商是:【{}】", channelSupplier);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,11 +134,24 @@ public class SupplierServiceImpl extends ServiceImpl<ChannelSupplierMapper, Chan
|
|
if (bankId != null) {
|
|
if (bankId != null) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
map.put("id", bankId);
|
|
map.put("id", bankId);
|
|
-
|
|
|
|
baseMapper.deleteByMap(map);
|
|
baseMapper.deleteByMap(map);
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
throw new BaseException(Status.PARAM_ERROR.status(), Status.PARAM_ERROR.message());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setInvalid(Long supplierId, Integer isValid) {
|
|
|
|
+ ChannelSupplier channelSupplier = ChannelSupplier.builder().supplierId(supplierId)
|
|
|
|
+ .isValid(isValid).build();
|
|
|
|
+ int result = baseMapper.updateById(channelSupplier);
|
|
|
|
+ if (result > 0) {
|
|
|
|
+ rocketMQTemplate.send(UPDATE_TOPIC + ":" + SUPPLIER_TAG, MessageBuilder.withPayload(SUPPLIER_TAG).build());
|
|
|
|
+ if (channelSupplier.getIsValid() == 0) {
|
|
|
|
+ log.info("编号为【{}】的供应商已置无效", supplierId);
|
|
|
|
+ } else {
|
|
|
|
+ log.info("编号为【{}】的供应商已置有效", supplierId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|