修改为单店时 移除子店铺的券
This commit is contained in:
parent
af6f23c6ca
commit
84acedfff6
|
|
@ -1305,7 +1305,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ("only".equals(couponSource.getUseShopType())) {
|
if ("only".equals(couponSource.getUseShopType())) {
|
||||||
deleteCouponsBySyncId(couponId);
|
upIsDel(couponId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Long> ids = new ArrayList<>();
|
List<Long> ids = new ArrayList<>();
|
||||||
|
|
@ -1328,14 +1328,16 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
||||||
couponSource.setId(null);
|
couponSource.setId(null);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1://新增
|
case 1://新增
|
||||||
saveCouponsForShops(ids, couponSource, couponId);
|
saveCouponsForShops(null, ids, couponSource, couponId);
|
||||||
break;
|
break;
|
||||||
case 2://先删除再新增
|
case 2://先删除再新增
|
||||||
|
List<ShopCoupon> couponList = couponService.list(new QueryWrapper().eq(ShopCoupon::getSyncId, couponId));
|
||||||
|
Map<Long, Long> map = couponList.stream().collect(Collectors.toMap(ShopCoupon::getShopId, ShopCoupon::getId));
|
||||||
deleteCouponsBySyncId(couponId);
|
deleteCouponsBySyncId(couponId);
|
||||||
saveCouponsForShops(ids, couponSource, couponId);
|
saveCouponsForShops(map, ids, couponSource, couponId);
|
||||||
break;
|
break;
|
||||||
case 3:// 删除
|
case 3:// 删除
|
||||||
deleteCouponsBySyncId(couponId);
|
upIsDel(couponId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// 处理未知类型,可根据业务需求抛出异常或忽略
|
// 处理未知类型,可根据业务需求抛出异常或忽略
|
||||||
|
|
@ -1343,7 +1345,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveCouponsForShops(List<Long> ids, ShopCoupon coupon, Long couponId) {
|
private void saveCouponsForShops(Map<Long, Long> map, List<Long> ids, ShopCoupon coupon, Long couponId) {
|
||||||
List<Long> couponFoodIds = new ArrayList<>();
|
List<Long> couponFoodIds = new ArrayList<>();
|
||||||
if (StrUtil.isNotBlank(coupon.getFoods()) && ",".equals(coupon.getFoods())) {
|
if (StrUtil.isNotBlank(coupon.getFoods()) && ",".equals(coupon.getFoods())) {
|
||||||
if (StrUtil.isNotBlank(coupon.getFoods()) && !",".equals(coupon.getFoods())) {
|
if (StrUtil.isNotBlank(coupon.getFoods()) && !",".equals(coupon.getFoods())) {
|
||||||
|
|
@ -1362,12 +1364,19 @@ public class ShopSyncServiceImpl implements ShopSyncService {
|
||||||
coupon.setShopId(id);
|
coupon.setShopId(id);
|
||||||
coupon.setSyncId(couponId);
|
coupon.setSyncId(couponId);
|
||||||
coupon.setId(null);
|
coupon.setId(null);
|
||||||
|
if (CollUtil.isNotEmpty(map) && map.containsKey(id)) {
|
||||||
|
coupon.setId(map.get(id));
|
||||||
|
}
|
||||||
couponService.save(coupon);
|
couponService.save(coupon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteCouponsBySyncId(Long couponId) {
|
private void upIsDel(Long couponId) {
|
||||||
couponService.update(new ShopCoupon().setIsDel(1), new QueryWrapper()
|
couponService.update(new ShopCoupon().setIsDel(1), new QueryWrapper()
|
||||||
.eq(ShopCoupon::getSyncId, couponId));
|
.eq(ShopCoupon::getSyncId, couponId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteCouponsBySyncId(Long couponId) {
|
||||||
|
couponService.remove(new QueryWrapper().eq(ShopCoupon::getSyncId, couponId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue