记得上下班打卡 | git大法好,push需谨慎

Commit 52b2aab8 authored by 姜秀龙's avatar 姜秀龙

sqb 删除商品处理关联关系

parent ee44a556
...@@ -10,7 +10,9 @@ import com.liquidnet.service.base.ErrorMapping; ...@@ -10,7 +10,9 @@ import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsSqbAddParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsSqbAddParam;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt; import com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt;
import com.liquidnet.service.goblin.mapper.GoblinGoodsMapper;
import com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper; import com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtSqbGoodsService; import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtSqbGoodsService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
...@@ -48,6 +50,8 @@ public class GoblinStoreMgtSqbGoodsController { ...@@ -48,6 +50,8 @@ public class GoblinStoreMgtSqbGoodsController {
@Autowired @Autowired
private GoblinSqbGoodsExtMapper goblinSqbGoodsExtMapper; private GoblinSqbGoodsExtMapper goblinSqbGoodsExtMapper;
@Autowired @Autowired
private GoblinGoodsMapper goblinGoodsMapper;
@Autowired
private SqbBiz goblinShouQianBaService; private SqbBiz goblinShouQianBaService;
/** /**
...@@ -188,10 +192,52 @@ public class GoblinStoreMgtSqbGoodsController { ...@@ -188,10 +192,52 @@ public class GoblinStoreMgtSqbGoodsController {
} }
private boolean existsSqbSpu(String mallSn, String sqbSpuId) { private boolean existsSqbSpu(String mallSn, String sqbSpuId) {
return goblinSqbGoodsExtMapper.selectCount(new LambdaQueryWrapper<GoblinSqbGoodsExt>() List<GoblinSqbGoodsExt> extList = goblinSqbGoodsExtMapper.selectList(new LambdaQueryWrapper<GoblinSqbGoodsExt>()
.eq(GoblinSqbGoodsExt::getMallSn, mallSn) .eq(GoblinSqbGoodsExt::getMallSn, mallSn)
.eq(GoblinSqbGoodsExt::getSqbSpuId, sqbSpuId) .eq(GoblinSqbGoodsExt::getSqbSpuId, sqbSpuId)
.eq(GoblinSqbGoodsExt::getDelFlg, "0")) > 0; .eq(GoblinSqbGoodsExt::getDelFlg, "0")
.last("LIMIT 20"));
if (CollectionUtils.isEmpty(extList)) {
return false;
}
// 本地商品已删除但 ext 关系未清理时:允许重新同步(自动软删 ext 记录,避免“已存在”卡死)
boolean hasLiveLocalSpu = false;
for (GoblinSqbGoodsExt ext : extList) {
if (ext == null || StringUtils.isBlank(ext.getSpuId())) {
continue;
}
GoblinGoods localGoods = goblinGoodsMapper.selectOne(new LambdaQueryWrapper<GoblinGoods>()
.eq(GoblinGoods::getSpuId, ext.getSpuId())
.eq(GoblinGoods::getDelFlg, "0")
.select(GoblinGoods::getSpuId)
.last("LIMIT 1"));
if (localGoods != null) {
hasLiveLocalSpu = true;
break;
}
}
if (hasLiveLocalSpu) {
return true;
}
try {
LocalDateTime now = LocalDateTime.now();
for (GoblinSqbGoodsExt ext : extList) {
if (ext == null || ext.getMid() == null) {
continue;
}
GoblinSqbGoodsExt upd = new GoblinSqbGoodsExt();
upd.setMid(ext.getMid());
upd.setDelFlg("1");
upd.setUpdatedAt(now);
upd.setDeletedAt(now);
goblinSqbGoodsExtMapper.updateById(upd);
}
} catch (Exception e) {
log.warn("收钱吧商品管理:清理已删除SPU的ext关系失败, mallSn={}, sqbSpuId={}", mallSn, sqbSpuId, e);
}
return false;
} }
private void saveSqbExtRelations(GoblinGoodsInfoVo goodsInfoVo, GoblinSqbPerfGoodsVo sqbGoods) { private void saveSqbExtRelations(GoblinGoodsInfoVo goodsInfoVo, GoblinSqbPerfGoodsVo sqbGoods) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment