Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松 2025-09-17 15:43:27 +08:00
commit f32aa4c7a0
1 changed files with 17 additions and 3 deletions

View File

@ -1343,12 +1343,26 @@ public class ShopSyncServiceImpl implements ShopSyncService {
} }
private void saveCouponsForShops(List<Long> ids, ShopCoupon coupon, Long couponId) { private void saveCouponsForShops(List<Long> ids, ShopCoupon coupon, Long couponId) {
ids.forEach(id -> { List<Long> couponFoodIds = new ArrayList<>();
if (StrUtil.isNotBlank(coupon.getFoods()) && ",".equals(coupon.getFoods())) {
if (StrUtil.isNotBlank(coupon.getFoods()) && !",".equals(coupon.getFoods())) {
couponFoodIds = Arrays.stream(coupon.getFoods().split(",")).map(Long::parseLong).toList();
}
}
for (Long id : ids) {
if (CollUtil.isNotEmpty(couponFoodIds)) {
List<Long> foodIds = productService.listAs(new QueryWrapper().select(Product::getId)
.in(Product::getSyncId, couponFoodIds).eq(Product::getShopId, id), Long.class);
if (CollUtil.isEmpty(foodIds)) {
continue;
}
coupon.setFoods(foodIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
}
coupon.setShopId(id); coupon.setShopId(id);
coupon.setSyncId(couponId); coupon.setSyncId(couponId);
coupon.setId(null); // 确保是新增操作 coupon.setId(null);
couponService.save(coupon); couponService.save(coupon);
}); }
} }
private void deleteCouponsBySyncId(Long couponId) { private void deleteCouponsBySyncId(Long couponId) {