分享奖励接口修改
This commit is contained in:
parent
8cc60c43b3
commit
fcb458fa73
|
|
@ -0,0 +1,24 @@
|
|||
package com.czg.account.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class ShopShareCouponDTO {
|
||||
/**
|
||||
* 券id
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ public class ShopShareDTO implements Serializable {
|
|||
/**
|
||||
* 新用户获得券
|
||||
*/
|
||||
private List<Long> newCouponList;
|
||||
private List<ShopShareCouponDTO> newCouponList;
|
||||
|
||||
/**
|
||||
* 邀请人数
|
||||
|
|
@ -77,7 +77,7 @@ public class ShopShareDTO implements Serializable {
|
|||
/**
|
||||
* 奖励券
|
||||
*/
|
||||
private List<Long> rewardCouponList;
|
||||
private List<ShopShareCouponDTO> rewardCouponList;
|
||||
|
||||
/**
|
||||
* 获取方法 get-新用户领取获得 use-新用户使用获得
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.czg.account.vo;
|
||||
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.dto.ShopShareCouponDTO;
|
||||
import com.czg.account.entity.ShopShare;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
|
@ -17,9 +17,9 @@ public class ShopShareVO extends ShopShare {
|
|||
/**
|
||||
* 新人奖励优惠券信息
|
||||
*/
|
||||
private List<ShopCoupon> newCouponList = new ArrayList<>();
|
||||
private List<ShopShareCouponDTO> newCouponList = new ArrayList<>();
|
||||
/**
|
||||
* 邀请人奖励优惠券信息
|
||||
*/
|
||||
private List<ShopCoupon> rewardCouponList = new ArrayList<>();
|
||||
private List<ShopShareCouponDTO> rewardCouponList = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.czg.service.account.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.ShopShareCouponDTO;
|
||||
import com.czg.account.dto.ShopShareDTO;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.service.ShopCouponService;
|
||||
|
|
@ -42,11 +44,13 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
|||
if (shopShare != null) {
|
||||
BeanUtil.copyProperties(shopShare, shopShareVO);
|
||||
if (StrUtil.isNotBlank(shopShare.getRewardCoupon())) {
|
||||
shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
|
||||
// shopShareVO.setRewardCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getRewardCoupon()))));
|
||||
shopShareVO.setRewardCouponList(JSONArray.parseArray(shopShare.getRewardCoupon(), ShopShareCouponDTO.class));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(shopShare.getNewCoupon())) {
|
||||
shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
|
||||
// shopShareVO.setNewCouponList(shopCouponService.list(new QueryWrapper().eq(ShopCoupon::getShopId, shopId).in(ShopCoupon::getId, JSONArray.parseArray(shopShare.getNewCoupon()))));
|
||||
shopShareVO.setNewCouponList(JSONArray.parseArray(shopShare.getNewCoupon(), ShopShareCouponDTO.class));
|
||||
}
|
||||
}
|
||||
return shopShareVO;
|
||||
|
|
@ -55,14 +59,14 @@ public class ShopShareServiceImpl extends ServiceImpl<ShopShareMapper, ShopShare
|
|||
@Override
|
||||
public Boolean add(Long shopId, ShopShareDTO shopShareDTO) {
|
||||
if (shopShareDTO.getNewCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getNewCouponList()).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()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (shopShareDTO.getRewardCouponList() != null && !shopShareDTO.getRewardCouponList().isEmpty()) {
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponList()).eq(ShopCoupon::getShopId, shopId));
|
||||
long count = shopCouponService.count(new QueryWrapper().in(ShopCoupon::getId, shopShareDTO.getRewardCouponList().stream().map(ShopShareCouponDTO::getId).toList()).eq(ShopCoupon::getShopId, shopId));
|
||||
if (count != shopShareDTO.getRewardCouponList().size()) {
|
||||
throw new ApiNotPrintException("优惠券不存在");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue