|
@@ -1,8 +1,10 @@
|
|
|
package com.sqx.modules.member.service.impl;
|
|
package com.sqx.modules.member.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.sqx.common.exception.SqxException;
|
|
import com.sqx.common.exception.SqxException;
|
|
|
|
|
+import com.sqx.common.utils.Constant;
|
|
|
import com.sqx.modules.app.bo.UpdateMoneyBO;
|
|
import com.sqx.modules.app.bo.UpdateMoneyBO;
|
|
|
import com.sqx.modules.app.entity.UserEntity;
|
|
import com.sqx.modules.app.entity.UserEntity;
|
|
|
import com.sqx.modules.app.service.UserMoneyService;
|
|
import com.sqx.modules.app.service.UserMoneyService;
|
|
@@ -10,9 +12,13 @@ import com.sqx.modules.app.service.UserService;
|
|
|
import com.sqx.modules.common.entity.CommonInfo;
|
|
import com.sqx.modules.common.entity.CommonInfo;
|
|
|
import com.sqx.modules.common.service.CommonInfoService;
|
|
import com.sqx.modules.common.service.CommonInfoService;
|
|
|
import com.sqx.modules.coupon.service.TbCouponUserService;
|
|
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.VipPromoRecordDTO;
|
|
import com.sqx.modules.member.dto.VipPromoRecordDTO;
|
|
|
import com.sqx.modules.member.service.VipPromoRecordService;
|
|
import com.sqx.modules.member.service.VipPromoRecordService;
|
|
|
import com.sqx.modules.member.service.VipService;
|
|
import com.sqx.modules.member.service.VipService;
|
|
|
|
|
+import com.sqx.modules.member.vo.VipReduceVO;
|
|
|
|
|
+import com.sqx.modules.order.service.AppOrderService;
|
|
|
import com.sqx.modules.pay.dto.GetPayParamDTO;
|
|
import com.sqx.modules.pay.dto.GetPayParamDTO;
|
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
import com.sqx.modules.pay.entity.PayDetails;
|
|
|
import com.sqx.modules.pay.enums.PayChannelEnum;
|
|
import com.sqx.modules.pay.enums.PayChannelEnum;
|
|
@@ -42,6 +48,8 @@ public class VipServiceImpl implements VipService {
|
|
|
private final TbCouponUserService tbCouponUserService;
|
|
private final TbCouponUserService tbCouponUserService;
|
|
|
private final VipPromoRecordService vipPromoRecordService;
|
|
private final VipPromoRecordService vipPromoRecordService;
|
|
|
private final UserMoneyService userMoneyService;
|
|
private final UserMoneyService userMoneyService;
|
|
|
|
|
+ private final GoodsShopService goodsShopService;
|
|
|
|
|
+ private final AppOrderService appOrderService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public PayTransactionsVO getPayParam(Long userId, String promoCode) {
|
|
public PayTransactionsVO getPayParam(Long userId, String promoCode) {
|
|
@@ -128,6 +136,52 @@ public class VipServiceImpl implements VipService {
|
|
|
afterPaySuccess(userId);
|
|
afterPaySuccess(userId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public VipReduceVO getVipReduceInfo(Long userId, Long shopId) {
|
|
|
|
|
+ GoodsShop goodsShop = goodsShopService.getById(shopId);
|
|
|
|
|
+ if (ObjectUtil.isNull(goodsShop)) {
|
|
|
|
|
+ new SqxException("无效的店铺id!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String goodsShopVipPromotion = goodsShop.getVipPromotion();
|
|
|
|
|
+ if (!StrUtil.equals(goodsShopVipPromotion, Constant.YES)) {
|
|
|
|
|
+
|
|
|
|
|
+ return VipReduceVO.builder()
|
|
|
|
|
+ .reduceAmount(BigDecimal.ZERO)
|
|
|
|
|
+ .canReduceFlag(Constant.NO)
|
|
|
|
|
+ .vipReduceDesc("店铺未参与会员立减")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ UserEntity user = userService.getById(userId);
|
|
|
|
|
+ String vipFlag = ObjectUtil.isNotNull(user.getIsVip()) && user.getIsVip() == 1 && VipExpirationUtil.isVipValid(user.getVipExpirationTime())
|
|
|
|
|
+ ? Constant.YES : Constant.NO;
|
|
|
|
|
+ if (!StrUtil.equals(vipFlag, Constant.YES)) {
|
|
|
|
|
+ return VipReduceVO.builder().reduceAmount(BigDecimal.ZERO)
|
|
|
|
|
+ .canReduceFlag(Constant.NO)
|
|
|
|
|
+ .vipReduceDesc("用户非会员,不能立减")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int count = appOrderService.getCurDayVipPromotionByUserCount(userId);
|
|
|
|
|
+ // 会员每天限制优惠单数(单)
|
|
|
|
|
+ CommonInfo vipPromotionCount = commonInfoService.findOne(445);
|
|
|
|
|
+ if (count >= Integer.parseInt(vipPromotionCount.getValue())) {
|
|
|
|
|
+ return VipReduceVO.builder().reduceAmount(BigDecimal.ZERO)
|
|
|
|
|
+ .canReduceFlag(Constant.NO)
|
|
|
|
|
+ .vipReduceDesc("会员当日优惠单数已达上限")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 会员每单立减金额(元)
|
|
|
|
|
+ CommonInfo vipPromotionAmount = commonInfoService.findOne(444);
|
|
|
|
|
+ BigDecimal vipPromotionAmountDecimal = new BigDecimal(vipPromotionAmount.getValue());
|
|
|
|
|
+ return VipReduceVO.builder().reduceAmount(vipPromotionAmountDecimal)
|
|
|
|
|
+ .canReduceFlag(Constant.YES)
|
|
|
|
|
+ .vipReduceDesc("会员每单立减金额" + vipPromotionAmountDecimal + "元")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void afterPaySuccess(Long userId) {
|
|
private void afterPaySuccess(Long userId) {
|
|
|
// 会员期限(天)
|
|
// 会员期限(天)
|
|
|
CommonInfo vipExpirationDays = commonInfoService.findOne(314);
|
|
CommonInfo vipExpirationDays = commonInfoService.findOne(314);
|