diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs index a970f94..3ad5943 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs @@ -2494,7 +2494,19 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services var stopInfo = JsonConvert.DeserializeObject>(HttpHelper.HttpGet(url, null, dic, "application/json")); if (stopInfo?.data == null) throw Oops.Oh("店铺不存在!"); - var goodInfoList = exportDto.GoodId != null ? await _db.Queryable().Where(t => t.Id == exportDto.GoodId).ToListAsync() : await _db.Queryable().Where(t => exportDto.GoodsId.Contains(t.Id)).ToListAsync(); + var goodInfoList = new List(); + if (exportDto.GoodsId.Any()) + goodInfoList = await _db.Queryable().Where(t => exportDto.GoodsId.Contains(t.Id)).ToListAsync(); + else + { + if (exportDto.GoodId != null) + goodInfoList = await _db.Queryable().Where(t => t.Id == exportDto.GoodId).ToListAsync(); + else + { + var goodIds = await _db.Queryable().Where(t => t.DeviceId == exportDto.DeviceId).Select(q => q.GoodsId).Distinct().ToListAsync(); + goodInfoList = await _db.Queryable().Where(t => goodIds.Contains(t.Id)).ToListAsync(); + } + } if (goodInfoList.Count == 0) { var templateUrl = "https://bpa.oss-cn-chengdu.aliyuncs.com/hkerp/test/goods//商品模版.xlsx";