huliguo
2025-06-16 a966dafb8877552267a94fe8c544c5ea72cf5650
ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/goods/GoodsServiceImpl.java
@@ -10,7 +10,6 @@
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.CodeFactoryUtil;
import com.ruoyi.goods.domain.dto.*;
import com.ruoyi.system.api.domain.poji.activity.Activity;
import com.ruoyi.goods.domain.pojo.goods.GoodsTotal;
import com.ruoyi.goods.domain.vo.*;
import com.ruoyi.goods.mapper.goods.GoodsMapper;
@@ -26,6 +25,7 @@
import com.ruoyi.system.api.domain.dto.MerGoodsPriceListDto;
import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
import com.ruoyi.system.api.domain.dto.MgtClassNumDto;
import com.ruoyi.system.api.domain.poji.activity.Activity;
import com.ruoyi.system.api.domain.poji.activity.ActivityGoods;
import com.ruoyi.system.api.domain.poji.config.SysClassification;
import com.ruoyi.system.api.domain.poji.goods.Goods;
@@ -83,16 +83,17 @@
    @Resource
    private RemoteShopService remoteShopService;
    /**
    * @description 获取推荐商品列表
    * @param page shopId
    * @return List<AppSimpleGoodsVo>
    * @author jqs34
    * @date 2023/6/4 16:27
    */
     * @param page shopId
     * @return List<AppSimpleGoodsVo>
     * @description 获取推荐商品列表
     * @author jqs34
     * @date 2023/6/4 16:27
     */
    @Override
    public List<AppSimpleGoodsVo> pageRecommendGoods(Page page, Long shopId){
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsMapper.pageRecommendGoods(page,shopId);
    public List<AppSimpleGoodsVo> pageRecommendGoods(Page page, Long shopId) {
        List<AppSimpleGoodsVo> appSimpleGoodsVoList = goodsMapper.pageRecommendGoods(page, shopId);
        return appSimpleGoodsVoList;
    }
@@ -185,10 +186,21 @@
        BeanUtils.copyProperties(goods, appGoodsInfoVo);
        //商户定制价格
        ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appGoodsInfoGetDto.getShopId(),goods.getGoodsId());
        if(shopGoods!=null){
        if (shopGoods != null) {
            appGoodsInfoVo.setSalesPrice(shopGoods.getSalesPrice());
            appGoodsInfoVo.setServiceNum(shopGoods.getServiceNum());
        } else {
            //经销商定制价格
            Shop shop = remoteShopService.getShop(appGoodsInfoGetDto.getShopId()).getData();
            Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData();
            shopGoods = shopGoodsService.getByShopIdAndGoodsId(belongShop.getShopId(), goods.getGoodsId());
            if (1 == belongShop.getModifyPricePermission() && null != shopGoods) {
                appGoodsInfoVo.setSalesPrice(shopGoods.getSalesPrice());
                appGoodsInfoVo.setServiceNum(shopGoods.getServiceNum());
            }
        }
        GoodsTotal goodsTotal = goodsTotalService.getById(goods.getGoodsId());
        appGoodsInfoVo.setSalesNum(goodsTotal.getBuyNumCount());
        //活动商品判断
@@ -275,22 +287,32 @@
    /**
     * 修改商户商品
     *
     * @param merShopGoodsEditDto
     */
    @Override
    public void editMerShopGoods(MerShopGoodsEditDto merShopGoodsEditDto){
    public void editMerShopGoods(MerShopGoodsEditDto merShopGoodsEditDto) {
        Shop shop = remoteShopService.getShop(merShopGoodsEditDto.getShopId()).getData();
        if (2 == shop.getShopType()) {
            Shop belongShop = remoteShopService.getShop(shop.getBelongShopId()).getData();
            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(shop.getBelongShopId(), merShopGoodsEditDto.getGoodsId());
            if (1 == belongShop.getModifyPricePermission() && null != shopGoods) {
                throw new ServiceException("经销商开启了统一价格管理");
            }
        }
        Goods goods = this.getById(merShopGoodsEditDto.getGoodsId());
        if(merShopGoodsEditDto.getSalePrice().compareTo(goods.getMininumPrice())<0){
            throw new ServiceException(AppErrorConstant.SALESPRICE_MIN+goods.getMininumPrice().toString()+"元");
        if (merShopGoodsEditDto.getSalePrice().compareTo(goods.getMininumPrice()) < 0) {
            throw new ServiceException(AppErrorConstant.SALESPRICE_MIN + goods.getMininumPrice().toString() + "元");
        }
        //商户定制价格
        ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(merShopGoodsEditDto.getShopId(),goods.getGoodsId());
        if(shopGoods!=null){
        ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(merShopGoodsEditDto.getShopId(), goods.getGoodsId());
        if (shopGoods != null) {
            shopGoods.setSalesPrice(merShopGoodsEditDto.getSalePrice());
            shopGoods.setServiceNum(merShopGoodsEditDto.getServiceNum());
            shopGoods.setUpdateTime(new Date());
            shopGoods.setUpdateUserId(merShopGoodsEditDto.getUserId());
        }else{
        } else {
            shopGoods = new ShopGoods();
            shopGoods.setDelFlag(0);
            shopGoods.setShopId(merShopGoodsEditDto.getShopId());