批量插入

This commit is contained in:
2025-11-28 18:08:12 +08:00
parent e80bf9a39e
commit 403c872ee3
12 changed files with 22 additions and 27 deletions

View File

@@ -49,7 +49,7 @@ public class MkCouponGiftServiceImpl extends ServiceImpl<MkCouponGiftMapper, MkC
public void addCouponGift(Long sourceId, String sourceName, Integer type, List<MkCouponGiftDTO> couponGiftList) {
remove(new QueryWrapper().eq(MkCouponGift::getSourceId, sourceId).eq(MkCouponGift::getType, type));
if (CollUtil.isNotEmpty(couponGiftList)) {
List newCoupons = new ArrayList<>();
List<MkCouponGift> newCoupons = new ArrayList<>();
for (MkCouponGiftDTO giftDTO : couponGiftList) {
ShopCoupon coupon = couponMapper.selectOneByQuery(new QueryWrapper().eq(ShopCoupon::getId, giftDTO.getCouponId()));
if (coupon == null) {
@@ -64,7 +64,7 @@ public class MkCouponGiftServiceImpl extends ServiceImpl<MkCouponGiftMapper, MkC
couponGift.setNum(giftDTO.getNum());
newCoupons.add(couponGift);
}
saveBatch(newCoupons);
mapper.insertBatchSelective(newCoupons, 50);
}
}

View File

@@ -476,7 +476,7 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
recordList.add(record);
}
}
saveBatch(recordList);
mapper.insertBatchSelective(recordList, 50);
QueryWrapper queryWrapper = new QueryWrapper();
ShopCoupon newCoupon = new ShopCoupon();
newCoupon.setGiftNum(coupon.getGiftNum());