|
|
@@ -14,12 +14,14 @@ import com.sqx.modules.common.service.CommonInfoService;
|
|
|
import com.sqx.modules.coupon.service.TbCouponUserService;
|
|
|
import com.sqx.modules.goods.entity.GoodsShop;
|
|
|
import com.sqx.modules.goods.service.GoodsShopService;
|
|
|
+import com.sqx.modules.member.dto.CanReduceQueryDTO;
|
|
|
import com.sqx.modules.member.dto.VipPromoRecordDTO;
|
|
|
import com.sqx.modules.member.entity.VipPromoCode;
|
|
|
import com.sqx.modules.member.service.VipPromoCodeService;
|
|
|
import com.sqx.modules.member.service.VipPromoRecordService;
|
|
|
import com.sqx.modules.member.service.VipService;
|
|
|
import com.sqx.modules.member.vo.VipReduceVO;
|
|
|
+import com.sqx.modules.order.entity.TbOrder;
|
|
|
import com.sqx.modules.order.service.AppOrderService;
|
|
|
import com.sqx.modules.pay.dto.GetPayParamDTO;
|
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
|
@@ -32,6 +34,7 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
|
@@ -146,15 +149,23 @@ public class VipServiceImpl implements VipService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public VipReduceVO getVipReduceInfo(Long userId, Long shopId) {
|
|
|
- GoodsShop goodsShop = goodsShopService.getById(shopId);
|
|
|
+ public VipReduceVO getVipReduceInfo(Long userId, @Valid CanReduceQueryDTO canReduceQueryDTO) {
|
|
|
+ // 查询订单原始金额是否达到会员立减金额
|
|
|
+ CommonInfo vipPromotionMinAmount = commonInfoService.findOne(446);
|
|
|
+ if (canReduceQueryDTO.getOriginalPrice().compareTo(new BigDecimal(vipPromotionMinAmount.getValue())) <= 0) {
|
|
|
+ return VipReduceVO.builder().reduceAmount(BigDecimal.ZERO)
|
|
|
+ .canReduceFlag(Constant.NO)
|
|
|
+ .vipReduceDesc("订单金额未达到会员立减金额")
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询店铺是否参与会员立减
|
|
|
+ GoodsShop goodsShop = goodsShopService.getById(canReduceQueryDTO.getShopId());
|
|
|
if (ObjectUtil.isNull(goodsShop)) {
|
|
|
throw new SqxException("无效的店铺id!");
|
|
|
}
|
|
|
-
|
|
|
String goodsShopVipPromotion = goodsShop.getVipPromotion();
|
|
|
if (!StrUtil.equals(goodsShopVipPromotion, Constant.YES)) {
|
|
|
-
|
|
|
return VipReduceVO.builder()
|
|
|
.reduceAmount(BigDecimal.ZERO)
|
|
|
.canReduceFlag(Constant.NO)
|
|
|
@@ -162,6 +173,7 @@ public class VipServiceImpl implements VipService {
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
+ // 查询用户是否为会员
|
|
|
UserEntity user = userService.getById(userId);
|
|
|
String vipFlag = ObjectUtil.isNotNull(user.getIsVip()) && user.getIsVip() == 1 && VipExpirationUtil.isVipValid(user.getVipExpirationTime())
|
|
|
? Constant.YES : Constant.NO;
|
|
|
@@ -172,8 +184,8 @@ public class VipServiceImpl implements VipService {
|
|
|
.build();
|
|
|
}
|
|
|
|
|
|
- int count = appOrderService.getCurDayVipPromotionByUserCount(userId);
|
|
|
// 会员每天限制优惠单数(单)
|
|
|
+ int count = appOrderService.getCurDayVipPromotionByUserCount(userId);
|
|
|
CommonInfo vipPromotionCount = commonInfoService.findOne(445);
|
|
|
if (count >= Integer.parseInt(vipPromotionCount.getValue())) {
|
|
|
return VipReduceVO.builder().reduceAmount(BigDecimal.ZERO)
|