分享奖励接口修改
This commit is contained in:
parent
6bb75935c9
commit
7f06b4d1c4
|
|
@ -58,11 +58,18 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
|
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()) {
|
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));
|
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()) {
|
if (count != shopShareDTO.getNewCouponList().size()) {
|
||||||
throw new ApiNotPrintException("优惠券不存在");
|
throw new ApiNotPrintException("优惠券不存在");
|
||||||
}
|
}
|
||||||
|
shopShare.setNewCoupon(JSONArray.toJSONString(shopShareDTO.getNewCouponList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
|
if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
|
||||||
|
|
@ -70,14 +77,8 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
||||||
if (count != shopShareDTO.getRewardCouponList().size()) {
|
if (count != shopShareDTO.getRewardCouponList().size()) {
|
||||||
throw new ApiNotPrintException("优惠券不存在");
|
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);
|
BeanUtil.copyProperties(shopShareDTO, shopShare);
|
||||||
return saveOrUpdate(shopShare);
|
return saveOrUpdate(shopShare);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue