无关风月
2026-01-09 f9e857610cd8ec3c5807651ad11fd3034f1e0be7
商城 富文本
4个文件已添加
7个文件已修改
403 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsShopController.java 208 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/ShoppingCartItem.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysBanner.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysConfig.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsShopQuery.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/ShopCarVO.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsShopController.java
New file
@@ -0,0 +1,208 @@
package com.ruoyi.web.controller.api;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.ShoppingCartItem;
import com.ruoyi.system.model.TCrmSupplier;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.model.TErpGoodsType;
import com.ruoyi.system.model.TErpGoodsUnit;
import com.ruoyi.system.query.TErpGoodsShopQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.ShopCarVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
 * erp商品 前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2025-08-20
 */
@RestController
@RequestMapping("/t-erp-goods")
@Api(tags = "2.0新增海诊商城")
public class TErpGoodsShopController {
    private final TErpGoodsService erpGoodsService;
    private final TokenService tokenService;
    private final TErpGoodsTypeService erpGoodsTypeService;
    private final TErpGoodsUnitService erpGoodsUnitService;
    private final TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService;
    private final TErpSupplierWarehousingService erpSupplierWarehousingService;
    private final TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService;
    private final TErpMaintenanceReminderService erpMaintenanceReminderService;
    private final TCrmClinicService crmClinicService;
    private final TCrmSupplierService crmSupplierService;
    private final ISysUserService sysUserService;
    @Autowired
    private RedisCache redisCache;
    @Autowired
    public TErpGoodsShopController(TErpGoodsService erpGoodsService, TokenService tokenService, TErpGoodsTypeService erpGoodsTypeService, TErpGoodsUnitService erpGoodsUnitService,
                                   TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService, TErpSupplierWarehousingService erpSupplierWarehousingService,
                                   TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService, TCrmClinicService crmClinicService, TCrmSupplierService crmSupplierService, ISysUserService sysUserService) {
        this.erpGoodsService = erpGoodsService;
        this.tokenService = tokenService;
        this.erpGoodsTypeService = erpGoodsTypeService;
        this.erpGoodsUnitService = erpGoodsUnitService;
        this.erpSupplierWarehousingBatchService = erpSupplierWarehousingBatchService;
        this.erpSupplierWarehousingService = erpSupplierWarehousingService;
        this.erpSupplierOutboundGoodsService = erpSupplierOutboundGoodsService;
        this.erpMaintenanceReminderService = erpMaintenanceReminderService;
        this.crmClinicService = crmClinicService;
        this.crmSupplierService = crmSupplierService;
        this.sysUserService = sysUserService;
    }
    /**
     * 海诊商城分页列表
     */
    @ApiOperation(value = "海诊商城分页列表")
    @PostMapping(value = "/pageShopList")
    public R<PageInfo<TErpGoodsVO>> pageShopList(@RequestBody TErpGoodsShopQuery query) {
        return R.ok(erpGoodsService.pageShopList(query));
    }
    /**
     * 海诊商城-商品详情
     */
    @ApiOperation(value = "海诊商城-商品详情")
    @GetMapping(value = "/shopDetail")
    public R<TErpGoodsVO> pageShopList(String id) {
        TErpGoods goods = erpGoodsService.getById(id);
        TErpGoodsVO res = new TErpGoodsVO();
        BeanUtils.copyProperties(goods, res);
        TCrmSupplier supplier = crmSupplierService.getById(goods.getSupplierClinicId());
        if (supplier != null) res.setSupplierName(supplier.getSupplierName());
        TErpGoodsType erpGoodsType = erpGoodsTypeService.getById(goods.getTypeId());
        if (erpGoodsType != null) res.setTypeName(erpGoodsType.getTypeName());
        if (goods.getPackingUnitId() != null) {
            TErpGoodsUnit goodsUnit = erpGoodsUnitService.getById(goods.getPackingUnitId());
            if (goodsUnit != null) res.setPackingUnitName(goodsUnit.getUnitName());
        }
        return R.ok(res);
    }
    @ApiOperation(value = "海诊商城-清空购物车")
    @GetMapping(value = "/clear")
    public void clearAll() {
        Long userId = tokenService.getLoginUser().getUserId();
        redisCache.deleteObject("shopCart:"+userId);
    }
    @ApiOperation(value = "海诊商城-单删购物车")
    @GetMapping(value = "/clearById")
    public void clear(String id) {
        Long userId = tokenService.getLoginUser().getUserId();
        List<ShoppingCartItem> cacheList = redisCache.getCacheList("shopCart:"+userId);
        List<ShoppingCartItem> res = new ArrayList<>();
        redisCache.deleteObject("shopCart:"+userId);
        for (ShoppingCartItem shoppingCartItem : cacheList) {
            if (!shoppingCartItem.getId().equals(id)){
                res.add(shoppingCartItem);
            }
        }
        if (!res.isEmpty()){
            redisCache.setCacheList("shopCart:"+userId, res);
        }
    }
    /**
     * 海诊商城-加入购物车
     */
    @ApiOperation(value = "海诊商城-加入购物车")
    @GetMapping(value = "/addShopCar")
    public R addShopCar(String id, Integer num) {
        ShoppingCartItem shoppingCartItem = new ShoppingCartItem();
        shoppingCartItem.setId(id);
        shoppingCartItem.setNum(num);
        Long userId = tokenService.getLoginUser().getUserId();
        List<ShoppingCartItem> cacheList = redisCache.getCacheList("shopCart:"+userId);
        redisCache.deleteObject("shopCart:"+userId);
        if (cacheList != null) {
            if (!cacheList.isEmpty()) {
                for (ShoppingCartItem cartItem : cacheList) {
                    if (cartItem.getId().equals(id)) {
                        cartItem.setNum( num);
                        redisCache.setCacheList("shopCart:"+userId, cacheList);
                        return R.ok();
                    }else{
                        cacheList.add(cartItem);
                    }
                }
            } else {
                cacheList = new ArrayList<>();
                cacheList.add(shoppingCartItem);
            }
        } else {
            cacheList = new ArrayList<>();
            cacheList.add(shoppingCartItem);
        }
        redisCache.setCacheList("shopCart:"+userId, cacheList);
        return R.ok();
    }
    /**
     * 海诊商城-查询购物车
     */
    @ApiOperation(value = "海诊商城-查询购物车")
    @GetMapping(value = "/queryShopCar")
    public R<ShopCarVO> queryShopCar() {
        ShopCarVO res = new ShopCarVO();
        Long userId = tokenService.getLoginUser().getUserId();
        List<ShoppingCartItem> cacheList = redisCache.getCacheList("shopCart:"+userId);
        List<String> goodsIds = cacheList.stream().map(ShoppingCartItem::getId).collect(Collectors.toList());
        if (goodsIds.isEmpty()){
            ShopCarVO shopCarVO = new ShopCarVO();
            shopCarVO.setTotalPrice(BigDecimal.ZERO);
            shopCarVO.setList(new PageInfo<>());
            return R.ok(shopCarVO);
        }
        TErpGoodsShopQuery tErpGoodsShopQuery = new TErpGoodsShopQuery();
        tErpGoodsShopQuery.setGoodsIds(goodsIds);
        PageInfo<TErpGoodsVO> tErpGoodsVOPageInfo = erpGoodsService.pageShopList(tErpGoodsShopQuery);
        List<TErpGoodsVO> records = tErpGoodsVOPageInfo.getRecords();
        for (TErpGoodsVO record : records) {
            for (ShoppingCartItem cartItem : cacheList) {
                if (cartItem.getId().equals(record.getId())) {
                    record.setNumber(cartItem.getNum());
                    record.setPrice(record.getSalesAmount().multiply(new BigDecimal(record.getNumber())).setScale(2, RoundingMode.HALF_UP));
                }
            }
        }
        List<TErpGoodsVO> listAll = erpGoodsService.pageShopListAll(tErpGoodsShopQuery);
        for (TErpGoodsVO record : listAll) {
            for (ShoppingCartItem cartItem : cacheList) {
                if (cartItem.getId().equals(record.getId())) {
                    record.setNumber(cartItem.getNum());
                    record.setPrice(record.getSalesAmount().multiply(new BigDecimal(record.getNumber())).setScale(2, RoundingMode.HALF_UP));
                }
            }
        }
        BigDecimal totalPrice = records.stream().map(TErpGoodsVO::getPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
        res.setList(tErpGoodsVOPageInfo);
        res.setTotalPrice(totalPrice);
        return R.ok(res);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/ShoppingCartItem.java
New file
@@ -0,0 +1,12 @@
package com.ruoyi.system.dto;
import lombok.Data;
// 定义购物车项实体类,
@Data
public class ShoppingCartItem {
    // erp商品id
    private String id;
    // 数量
    private Integer num;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TErpGoodsMapper.java
@@ -5,10 +5,7 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.query.PageAddListQuery;
import com.ruoyi.system.query.TErpGoodsAdminQuery;
import com.ruoyi.system.query.TErpGoodsInventoryQuery;
import com.ruoyi.system.query.TErpGoodsQuery;
import com.ruoyi.system.query.*;
import com.ruoyi.system.vo.TErpGoodsInventoryVO;
import com.ruoyi.system.vo.TErpGoodsVO;
import org.apache.ibatis.annotations.Param;
@@ -46,5 +43,8 @@
    List<TErpGoodsVO> pageAdminList(@Param("query") TErpGoodsAdminQuery query, @Param("pageInfo") PageInfo<TErpGoodsVO> pageInfo);
    List<TErpGoods> pageAddList(@Param("tErpGoodsPage") Page<TErpGoods> tErpGoodsPage, @Param("clinicSupplierId") String clinicSupplierId, @Param("query") PageAddListQuery query);
    List<TErpGoodsVO> pageShopList(@Param("query") TErpGoodsShopQuery query, @Param("pageInfo")PageInfo<TErpGoodsVO> pageInfo);
    List<TErpGoodsVO> pageShopListAll(@Param("query")TErpGoodsShopQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysBanner.java
@@ -1,14 +1,14 @@
package com.ruoyi.system.model;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
@@ -56,5 +56,7 @@
    @ApiModelProperty(value = "内容id  资讯 直播 产品 活动")
    @TableField("content_id")
    private String contentId;
    @ApiModelProperty(value = "2.0新增字段 端口 1诊所 2患者")
    @TableField("port")
    private Integer port;
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TSysConfig.java
@@ -1,14 +1,14 @@
package com.ruoyi.system.model;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
 * <p>
@@ -29,7 +29,7 @@
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    @ApiModelProperty(value = "配置类型 1=用户协议 2=隐私协议")
    @ApiModelProperty(value = "配置类型 1=用户协议 2=隐私协议 3=其他设置 4AI诊聊介绍 5大师专区 6大师介绍 7直播系统介绍 8在线培训 9异地诊疗 10互联网医院")
    @TableField("config_type")
    private Integer configType;
ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsShopQuery.java
New file
@@ -0,0 +1,25 @@
package com.ruoyi.system.query;
import com.ruoyi.common.core.domain.BasePage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(value = "海诊商城查询参数query")
public class TErpGoodsShopQuery extends BasePage {
    @ApiModelProperty(value = "供应商id")
    private String supplierId;
    @ApiModelProperty(value = "输入框查询条件")
    private String queryCondition;
    @ApiModelProperty(value = "商品类型ids")
    private List<String> typeIds;
    @ApiModelProperty(value = "商品ids 前端忽略")
    private List<String> goodsIds;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TErpGoodsService.java
@@ -78,5 +78,7 @@
    List<TErpGoods> pageAddList(Page<TErpGoods> tErpGoodsPage, String clinicSupplierId, PageAddListQuery query);
    PageInfo<TErpGoodsVO> pageShopList(TErpGoodsShopQuery query);
    List<TErpGoodsVO> pageShopListAll(TErpGoodsShopQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TErpGoodsServiceImpl.java
@@ -43,7 +43,8 @@
    @Resource
    private TErpGoodsTypeMapper erpGoodsTypeMapper;
    @Resource
    private TErpProcurementGoodsMapper erpProcurementGoodsMapper;
    @Resource
    private TErpGoodsMapper erpGoodsMapper;
@@ -175,8 +176,50 @@
    public List<TErpGoods> pageAddList(Page<TErpGoods> tErpGoodsPage, String clinicSupplierId, PageAddListQuery query) {
        return this.baseMapper.pageAddList(tErpGoodsPage, clinicSupplierId, query);
    }
    @Override
    public PageInfo<TErpGoodsVO> pageShopList(TErpGoodsShopQuery query) {
        PageInfo<TErpGoodsVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TErpGoodsVO> list = this.baseMapper.pageShopList(query, pageInfo);
        if (list.isEmpty()){
            return new PageInfo<>();
        }
        List<String> goodsIds = list.stream().map(TErpGoods::getId).collect(Collectors.toList());
        Map<String, List<TErpProcurementGoods>> goodsSalesMap = erpProcurementGoodsMapper.selectList(new LambdaQueryWrapper<TErpProcurementGoods>()
                        .in(TErpProcurementGoods::getGoodsId, goodsIds)).stream()
                .collect(Collectors.groupingBy(TErpProcurementGoods::getGoodsId));
        List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
        List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
        for (TErpGoodsVO tErpGoodsVO : list) {
            List<TErpProcurementGoods> tErpProcurementGoods = goodsSalesMap.get(tErpGoodsVO.getId());
            // 计算采购数量
            tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
            typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
        }
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public List<TErpGoodsVO> pageShopListAll(TErpGoodsShopQuery query) {
        List<TErpGoodsVO> list = this.baseMapper.pageShopListAll(query);
        if (list.isEmpty()){
            return new ArrayList<>();
        }
        List<String> goodsIds = list.stream().map(TErpGoods::getId).collect(Collectors.toList());
        Map<String, List<TErpProcurementGoods>> goodsSalesMap = erpProcurementGoodsMapper.selectList(new LambdaQueryWrapper<TErpProcurementGoods>()
                        .in(TErpProcurementGoods::getGoodsId, goodsIds)).stream()
                .collect(Collectors.groupingBy(TErpProcurementGoods::getGoodsId));
        List<String> typeIds = list.stream().map(TErpGoods::getTypeId).collect(Collectors.toList());
        List<TErpGoodsType> typeList = erpGoodsTypeMapper.selectBatchIds(typeIds);
        for (TErpGoodsVO tErpGoodsVO : list) {
            List<TErpProcurementGoods> tErpProcurementGoods = goodsSalesMap.get(tErpGoodsVO.getId());
            // 计算采购数量
            tErpGoodsVO.setSalesCount(tErpProcurementGoods.stream().filter(e->e.getPurchaseCount()!=null).mapToInt(TErpProcurementGoods::getPurchaseCount).sum());
            typeList.stream().filter(t -> t.getId().equals(tErpGoodsVO.getTypeId())).findFirst().ifPresent(t -> tErpGoodsVO.setTypeName(t.getTypeName()));
        }
        return list;
    }
    @Override
    public List<TErpGoodsVO> listExport(TErpGoodsQuery query, SysUser user) {
        List<TErpGoodsVO> list = this.baseMapper.listExport(query, user);
        if (list.isEmpty()) {
ruoyi-system/src/main/java/com/ruoyi/system/vo/ShopCarVO.java
New file
@@ -0,0 +1,18 @@
package com.ruoyi.system.vo;
import com.ruoyi.common.basic.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ApiModel("购物车返回VO")
public class ShopCarVO {
    @ApiModelProperty("总计金额")
    private BigDecimal totalPrice;
    @ApiModelProperty("购物车")
    private PageInfo<TErpGoodsVO> list;
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TErpGoodsVO.java
@@ -1,7 +1,6 @@
package com.ruoyi.system.vo;
import com.ruoyi.system.model.TErpGoods;
import com.ruoyi.system.model.TErpIssueReporting;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -11,11 +10,20 @@
@Data
@ApiModel(value = "供应商erp商品VO")
public class TErpGoodsVO extends TErpGoods {
    @ApiModelProperty(value = "总库存数量")
    private Integer allNum;
    @ApiModelProperty(value = "总价")
    private BigDecimal allTotalPrice;
    @ApiModelProperty(value = "供应商名称")
    private String supplier;
    @ApiModelProperty(value = "销量")
    private Integer salesCount;
    @ApiModelProperty(value = "供应商资质")
    private String qualificationPicture;
    @ApiModelProperty(value = "数量")
    private Integer number;
    @ApiModelProperty(value = "合计金额")
    private BigDecimal price;
}
ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml
@@ -443,5 +443,54 @@
    </select>
    <select id="pageShopList" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select t1.id,t1.cover,t1.low_purchase_quantity,t1.packing_unit_id,t1.sales_amount,t1.supplier_clinic_id,t2.supplier_name as supplier
        ,t3.unit_name as packingUnitName
        from t_erp_goods t1
        left join t_crm_supplier t2 on t1.supplier_clinic_id = t2.id
        left join t_erp_goods_unit t3 on t1.packing_unit_id = t3.id
        where t1.goods_source = 1
        and t1.disabled = 0
        and t1.state = 1
        and t1.sales_amount is not null
        <if test="query.supplierId != null and query.supplierId != ''">
            and t1.supplier_clinic_id = #{query.supplierId}
        </if>
        <if test="query.queryCondition != null and query.queryCondition != ''">
            and (
            t2.supplier_name like concat('%',#{query.queryCondition},'%') or
            t1.goods_name like concat('%',#{query.queryCondition},'%') or
            t1.instructions_use like concat('%',#{query.queryCondition},'%') or
            t1.ingredient like concat('%',#{query.queryCondition},'%') or
            t1.trait like concat('%',#{query.queryCondition},'%') or
            t1.indication like concat('%',#{query.queryCondition},'%') or
            )
        </if>
        <if test="query.goodsIds != null and query.goodsIds.size()>0">
            AND t1.id IN
            <foreach collection="query.goodsIds" close=")" open="(" item="id" separator=",">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="pageShopListAll" resultType="com.ruoyi.system.vo.TErpGoodsVO">
        select t1.id,t1.cover,t1.low_purchase_quantity,t1.packing_unit_id,t1.sales_amount,t1.supplier_clinic_id,t2.supplier_name as supplier
        ,t3.unit_name as packingUnitName
        from t_erp_goods t1
        left join t_crm_supplier t2 on t1.supplier_clinic_id = t2.id
        left join t_erp_goods_unit t3 on t1.packing_unit_id = t3.id
        where t1.goods_source = 1
        and t1.disabled = 0
        and t1.state = 1
        and t1.sales_amount is not null
        <if test="query.goodsIds != null and query.goodsIds.size()>0">
            AND t1.id IN
            <foreach collection="query.goodsIds" close=")" open="(" item="id" separator=",">
                #{id}
            </foreach>
        </if>
    </select>
</mapper>