package com.cyksj.service.mange.goods;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyksj.mapper.GoodsDonSkuMapper;
import com.cyksj.mapper.GoodsDonSkuSubsidyMapper;
import com.cyksj.model.entity.GoodsDonSku;
import com.cyksj.model.entity.GoodsDonSkuSubsidy;
import com.cyksj.service.mange.GoodsDonSkuSubsidyService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 项目名: yhlxj2
 * 文件名: GoodsDonSkuSubsidyServiceImpl
 * 创建者: JavaZou
 * 创建时间:2024/4/11 12:14
 */
@Service
@RequiredArgsConstructor
public class GoodsDonSkuSubsidyServiceImpl extends ServiceImpl<GoodsDonSkuSubsidyMapper, GoodsDonSkuSubsidy> implements GoodsDonSkuSubsidyService {
	private final GoodsDonSkuMapper goodsDonSkuMapper;

	@Override
	public void saveOrUpdateSubsidy(GoodsDonSkuSubsidy goodsDonSkuSubsidy) {
		Long skuId = goodsDonSkuSubsidy.getSkuId();
		GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
		Assert.notNull(sku, "选择的规格不存在");
		goodsDonSkuSubsidy.setGoodsId(goodsDonSkuSubsidy.getGoodsId());
		this.saveOrUpdate(goodsDonSkuSubsidy);
	}
}
