优惠券对应商品的部分 子店铺使用子店铺的
This commit is contained in:
parent
db3027a2ed
commit
949eb9b158
|
|
@ -1343,12 +1343,26 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
|||
}
|
||||
|
||||
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.setSyncId(couponId);
|
||||
coupon.setId(null); // 确保是新增操作
|
||||
coupon.setId(null);
|
||||
couponService.save(coupon);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteCouponsBySyncId(Long couponId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue