分享奖励接口修改

This commit is contained in:
张松 2025-03-11 10:00:02 +08:00
parent 6bb75935c9
commit 7f06b4d1c4
1 changed files with 8 additions and 7 deletions

View File

@ -58,11 +58,18 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
@Override
public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
if (shopShare == null) {
shopShare = new ShopShareVO();
shopShare.setShopId(shopId);
}
if (shopShareDTO.getNewCouponList() != null && !shopShareDTO.getNewCouponList().isEmpty()) {
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
if (count != shopShareDTO.getNewCouponList().size()) {
throw new ApiNotPrintException("优惠券不存在");
}
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList()));
}
if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
@ -70,14 +77,8 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
if (count != shopShareDTO.getRewardCouponList().size()) {
throw new ApiNotPrintException("优惠券不存在");
}
shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponList()));
}
ShopShare shopShare = getOne(new QueryWrapper().eq(ShopShare::getShopId, shopId));
if (shopShare == null) {
shopShare = new ShopShareVO();
shopShare.setShopId(shopId);
}
shopShare.setRewardCoupon(JSONArray.toJSONString(shopShareDTO.getRewardCouponList()));
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList()));
BeanUtil.copyProperties(shopShareDTO, shopShare);
return saveOrUpdate(shopShare);
}