|
@@ -17,6 +17,7 @@ import com.xynet.marketing.service.factory.coupon.merc.MercCouponFactory;
|
|
|
import com.xynet.marketing.utils.Emptys;
|
|
|
import com.xynet.marketing.utils.collections.map.JHashMap;
|
|
|
import com.xynet.marketing.utils.collections.map.JMap;
|
|
|
+import com.xynet.marketing.utils.error.BusinessException;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -81,17 +82,17 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
public void mercSend(JMap<String, Object> param) {
|
|
|
List<Object> thirdMemberIdList = param.getList("thirdMemberIdList");
|
|
|
if (!Emptys.check(thirdMemberIdList)) {
|
|
|
- throw new RuntimeException("会员列表不能为空!");
|
|
|
+ throw new BusinessException("会员列表不能为空!");
|
|
|
}
|
|
|
LambdaQueryWrapper<MercCoupon> lqw = new LambdaQueryWrapper<MercCoupon>()
|
|
|
.eq(MercCoupon::getMercId, param.getInt("mercId"))
|
|
|
.in(MercCoupon::getId, param.getList("couponIdList"));
|
|
|
List<MercCoupon> couponList = list(lqw);
|
|
|
if (!Emptys.check(couponList)) {
|
|
|
- throw new RuntimeException("没有可以赠送的优惠券!");
|
|
|
+ throw new BusinessException("没有可以赠送的优惠券!");
|
|
|
}
|
|
|
if (thirdMemberIdList.size() > 20) {
|
|
|
- throw new RuntimeException("一次最多赠送20个用户!");
|
|
|
+ throw new BusinessException("一次最多赠送20个用户!");
|
|
|
}
|
|
|
couponList.forEach(coupon -> {
|
|
|
thirdMemberIdList.forEach(memberId -> {
|
|
@@ -117,7 +118,7 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.ge(MercCoupon::getSendEndDate, today));
|
|
|
List<MercCoupon> list = list(lqw);
|
|
|
if (!Emptys.check(list)) {
|
|
|
- throw new RuntimeException("没有可赠送的优惠券!");
|
|
|
+ throw new BusinessException("没有可赠送的优惠券!");
|
|
|
}
|
|
|
list.forEach(mercCoupon -> {
|
|
|
//查询券是否已领取过了
|
|
@@ -149,7 +150,7 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
.ge(MercCoupon::getSendEndDate, orderCreateTime));
|
|
|
List<MercCoupon> list = list(lqw);
|
|
|
if (!Emptys.check(list)) {
|
|
|
- throw new RuntimeException("没有可赠送的优惠券!");
|
|
|
+ throw new BusinessException("没有可赠送的优惠券!");
|
|
|
}
|
|
|
//TODO 判断设备条件
|
|
|
list.forEach(mercCoupon -> {
|
|
@@ -259,30 +260,30 @@ public class MercCouponFactoryBase extends ServiceImpl<MercCouponMapper, MercCou
|
|
|
//查询会员优惠券信息
|
|
|
Map<String, Object> memberCoupon = memberCouponService.obj(new JHashMap<String, Object>().set("id", memberCouponId));
|
|
|
if (!Emptys.check(memberCoupon)) {
|
|
|
- throw new RuntimeException("会员优惠券不存在!");
|
|
|
+ throw new BusinessException("会员优惠券不存在!");
|
|
|
}
|
|
|
//判断券是否属于该用户
|
|
|
JMap<String, Object> memberCouponJMap = new JHashMap<String, Object>(memberCoupon);
|
|
|
if (!Objects.equals(thirdMemberId, memberCouponJMap.getString("thirdMemberId"))) {
|
|
|
- throw new RuntimeException("会员优惠券不属于该用户!");
|
|
|
+ throw new BusinessException("会员优惠券不属于该用户!");
|
|
|
}
|
|
|
//判断券是否已使用
|
|
|
if (!Objects.equals(memberCouponJMap.getString("status"), MemberCouponStatusEnum.UNUSED.getCode())) {
|
|
|
- throw new RuntimeException("该券已失效!");
|
|
|
+ throw new BusinessException("该券已失效!");
|
|
|
}
|
|
|
//查询商户券
|
|
|
MercCoupon mercCoupon = getById(memberCouponJMap.getInt("couponId"));
|
|
|
if (mercCoupon.getValidStartDate().isAfter(orderCreateTime.toLocalDate())) {
|
|
|
- throw new RuntimeException("该券于!" + mercCoupon.getValidStartDate().toString() + "开始使用!");
|
|
|
+ throw new BusinessException("该券于!" + mercCoupon.getValidStartDate().toString() + "开始使用!");
|
|
|
}
|
|
|
if (mercCoupon.getValidEndDate().isBefore(orderCreateTime.toLocalDate())) {
|
|
|
- throw new RuntimeException("该券于!" + mercCoupon.getValidEndDate().toString() + "结束!");
|
|
|
+ throw new BusinessException("该券于!" + mercCoupon.getValidEndDate().toString() + "结束!");
|
|
|
}
|
|
|
//判断优惠券是可用于该设备
|
|
|
if (!mercCoupon.getIsAllDevice()) {
|
|
|
Boolean deviceCheck = deviceService.checkDeviceId(mercCoupon.getId(), deviceId, "coupon");
|
|
|
if (!deviceCheck) {
|
|
|
- throw new RuntimeException("该券不可用于该设备!");
|
|
|
+ throw new BusinessException("该券不可用于该设备!");
|
|
|
}
|
|
|
}
|
|
|
Map<String, Map<String, Object>> couponGoodsMap = new HashMap<>();
|