Compare commits

..

No commits in common. "84acedfff6b0dcc4b74cf9c08e9921f06b41e47b" and "f32aa4c7a0173d0d62b7616ed5d72e770e4b3ab5" have entirely different histories.

1 changed files with 5 additions and 15 deletions

View File

@ -1305,7 +1305,6 @@ public class ShopSyncServiceImpl implements ShopSyncService {
return;
}
if ("only".equals(couponSource.getUseShopType())) {
upIsDel(couponId);
return;
}
List<Long> ids = new ArrayList<>();
@ -1328,16 +1327,14 @@ public class ShopSyncServiceImpl implements ShopSyncService {
couponSource.setId(null);
switch (type) {
case 1://新增
saveCouponsForShops(null, ids, couponSource, couponId);
saveCouponsForShops(ids, couponSource, couponId);
break;
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);
saveCouponsForShops(map, ids, couponSource, couponId);
saveCouponsForShops(ids, couponSource, couponId);
break;
case 3:// 删除
upIsDel(couponId);
deleteCouponsBySyncId(couponId);
break;
default:
// 处理未知类型可根据业务需求抛出异常或忽略
@ -1345,7 +1342,7 @@ public class ShopSyncServiceImpl implements ShopSyncService {
}
}
private void saveCouponsForShops(Map<Long, Long> map, List<Long> ids, ShopCoupon coupon, Long couponId) {
private void saveCouponsForShops(List<Long> ids, ShopCoupon coupon, Long couponId) {
List<Long> couponFoodIds = new ArrayList<>();
if (StrUtil.isNotBlank(coupon.getFoods()) && ",".equals(coupon.getFoods())) {
if (StrUtil.isNotBlank(coupon.getFoods()) && !",".equals(coupon.getFoods())) {
@ -1364,19 +1361,12 @@ public class ShopSyncServiceImpl implements ShopSyncService {
coupon.setShopId(id);
coupon.setSyncId(couponId);
coupon.setId(null);
if (CollUtil.isNotEmpty(map) && map.containsKey(id)) {
coupon.setId(map.get(id));
}
couponService.save(coupon);
}
}
private void upIsDel(Long couponId) {
private void deleteCouponsBySyncId(Long couponId) {
couponService.update(new ShopCoupon().setIsDel(1), new QueryWrapper()
.eq(ShopCoupon::getSyncId, couponId));
}
private void deleteCouponsBySyncId(Long couponId) {
couponService.remove(new QueryWrapper().eq(ShopCoupon::getSyncId, couponId));
}
}