|
@@ -2,17 +2,33 @@ package zs.payment.service.Imseweishopgoods.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import zs.payment.entity.mysql.ImsEweiShopGoods;
|
|
import zs.payment.entity.mysql.ImsEweiShopGoods;
|
|
|
|
|
+import zs.payment.entity.mysql.ImsEweiShopGoodsOption;
|
|
|
|
|
+import zs.payment.entity.mysql.ImsEweiShopGoodsParam;
|
|
|
|
|
+import zs.payment.entity.mysql.ImsEweiShopGoodsSpec;
|
|
|
import zs.payment.mapper.primary.ImsEweiShopGoodsMapper;
|
|
import zs.payment.mapper.primary.ImsEweiShopGoodsMapper;
|
|
|
import zs.payment.service.Imseweishopgoods.ImsEweiShopGoodsService;
|
|
import zs.payment.service.Imseweishopgoods.ImsEweiShopGoodsService;
|
|
|
|
|
+import zs.payment.service.imseweishopgoodsoption.ImsEweiShopGoodsOptionService;
|
|
|
|
|
+import zs.payment.service.imseweishopgoodsparam.ImsEweiShopGoodsParamService;
|
|
|
|
|
+import zs.payment.service.imseweishopgoodsspec.ImsEweiShopGoodsSpecService;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class ImsEweiShopGoodsServiceImpl extends ServiceImpl<ImsEweiShopGoodsMapper, ImsEweiShopGoods> implements ImsEweiShopGoodsService {
|
|
public class ImsEweiShopGoodsServiceImpl extends ServiceImpl<ImsEweiShopGoodsMapper, ImsEweiShopGoods> implements ImsEweiShopGoodsService {
|
|
|
-
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ImsEweiShopGoodsSpecService specService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ImsEweiShopGoodsOptionService optionService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ImsEweiShopGoodsParamService paramService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public ImsEweiShopGoods getBySupplyId(String supplyId,String supplySource) {
|
|
public ImsEweiShopGoods getBySupplyId(String supplyId,String supplySource) {
|
|
@@ -32,9 +48,42 @@ public class ImsEweiShopGoodsServiceImpl extends ServiceImpl<ImsEweiShopGoodsMa
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean deleteBySupplyId(String supplyId, String supplySource) {
|
|
public Boolean deleteBySupplyId(String supplyId, String supplySource) {
|
|
|
- return lambdaUpdate().set(ImsEweiShopGoods::getDeleted, 1)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ ImsEweiShopGoods one = lambdaQuery().eq(ImsEweiShopGoods::getUniacid, 463)
|
|
|
|
|
+ .eq(ImsEweiShopGoods::getDeleted, 0)
|
|
|
.eq(ImsEweiShopGoods::getSupplySource, supplySource)
|
|
.eq(ImsEweiShopGoods::getSupplySource, supplySource)
|
|
|
- .eq(ImsEweiShopGoods::getSupplyId, supplyId).update();
|
|
|
|
|
|
|
+ .eq(ImsEweiShopGoods::getSupplyId, supplyId).one();
|
|
|
|
|
+ if (Optional.ofNullable(one).isPresent()){
|
|
|
|
|
+ Long goodsId = one.getId();
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 检查是否存在订单记录(查询 ims_ewei_shop_order_goods 表)
|
|
|
|
|
+ boolean hasOrder = baseMapper.existsOrderByGoodsId(goodsId);
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasOrder) {
|
|
|
|
|
+ // 4a. 无订单记录:物理删除商品及关联数据
|
|
|
|
|
+ removeById(goodsId);
|
|
|
|
|
+ specService.remove(new LambdaQueryWrapper<ImsEweiShopGoodsSpec>()
|
|
|
|
|
+ .eq(ImsEweiShopGoodsSpec::getGoodsid, goodsId));
|
|
|
|
|
+ optionService.remove(new LambdaQueryWrapper<ImsEweiShopGoodsOption>()
|
|
|
|
|
+ .eq(ImsEweiShopGoodsOption::getGoodsid, goodsId));
|
|
|
|
|
+ paramService.remove(new LambdaQueryWrapper<ImsEweiShopGoodsParam>()
|
|
|
|
|
+ .eq(ImsEweiShopGoodsParam::getGoodsid, goodsId));
|
|
|
|
|
+ log.info("物理删除其他进货商品及关联数据 goodsId={}", goodsId);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 4b. 有订单记录:软删除
|
|
|
|
|
+ LambdaUpdateWrapper<ImsEweiShopGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ updateWrapper.eq(ImsEweiShopGoods::getId, goodsId)
|
|
|
|
|
+ .set(ImsEweiShopGoods::getIssupplyRecommend,0)
|
|
|
|
|
+ .set(ImsEweiShopGoods::getDeleted, 1)
|
|
|
|
|
+ .set(ImsEweiShopGoods::getStatus, 0);
|
|
|
|
|
+ update(updateWrapper);
|
|
|
|
|
+ log.info("软删除其他进货商品 goodsId={}", goodsId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|