|
@@ -1,17 +1,23 @@
|
|
|
package shop.alien.store.service.impl;
|
|
package shop.alien.store.service.impl;
|
|
|
|
|
|
|
|
import com.aliyun.tea.utils.StringUtils;
|
|
import com.aliyun.tea.utils.StringUtils;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.BeansException;
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.result.R;
|
|
import shop.alien.entity.result.R;
|
|
|
|
|
+import shop.alien.entity.store.LifeCollect;
|
|
|
import shop.alien.entity.store.LifeDiscountCoupon;
|
|
import shop.alien.entity.store.LifeDiscountCoupon;
|
|
|
import shop.alien.entity.store.LifeDiscountCouponUser;
|
|
import shop.alien.entity.store.LifeDiscountCouponUser;
|
|
|
|
|
+import shop.alien.entity.store.StoreInfo;
|
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponUserDto;
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponUserDto;
|
|
|
|
|
+import shop.alien.mapper.LifeCollectMapper;
|
|
|
import shop.alien.mapper.LifeDiscountCouponMapper;
|
|
import shop.alien.mapper.LifeDiscountCouponMapper;
|
|
|
import shop.alien.mapper.LifeDiscountCouponUserMapper;
|
|
import shop.alien.mapper.LifeDiscountCouponUserMapper;
|
|
|
|
|
+import shop.alien.mapper.StoreInfoMapper;
|
|
|
import shop.alien.store.service.LifeDiscountCouponUserService;
|
|
import shop.alien.store.service.LifeDiscountCouponUserService;
|
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
|
|
|
|
|
@@ -32,6 +38,10 @@ import java.util.Date;
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountCouponUserMapper, LifeDiscountCouponUser> implements LifeDiscountCouponUserService {
|
|
public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountCouponUserMapper, LifeDiscountCouponUser> implements LifeDiscountCouponUserService {
|
|
|
|
|
|
|
|
|
|
+ private final LifeCollectMapper lifeCollectMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final StoreInfoMapper storeInfoMapper;
|
|
|
|
|
+
|
|
|
private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
|
|
private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
|
|
|
|
|
|
|
|
private final LifeDiscountCouponUserMapper lifeDiscountCouponUserMapper;
|
|
private final LifeDiscountCouponUserMapper lifeDiscountCouponUserMapper;
|
|
@@ -81,6 +91,22 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
|
|
|
//削减该优惠券库存
|
|
//削减该优惠券库存
|
|
|
lifeDiscountCoupon.setSingleQty(lifeDiscountCoupon.getSingleQty() - receiveQuantity);
|
|
lifeDiscountCoupon.setSingleQty(lifeDiscountCoupon.getSingleQty() - receiveQuantity);
|
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
|
|
|
+
|
|
|
|
|
+ //是否领取优惠券收藏店铺
|
|
|
|
|
+ Integer attentionCanReceived = lifeDiscountCoupon.getAttentionCanReceived();
|
|
|
|
|
+ if(attentionCanReceived != null && attentionCanReceived == 1){
|
|
|
|
|
+ LifeCollect lifeCollect = new LifeCollect();
|
|
|
|
|
+ lifeCollect.setStoreId(lifeDiscountCoupon.getStoreId());
|
|
|
|
|
+ lifeCollect.setUserId(lifeDiscountCouponUserDto.getUserId().toString());
|
|
|
|
|
+ lifeCollectMapper.insert(lifeCollect);
|
|
|
|
|
+
|
|
|
|
|
+ //同步店铺收藏数量
|
|
|
|
|
+ if (!StringUtils.isEmpty(lifeCollect.getStoreId())) {
|
|
|
|
|
+ LambdaQueryWrapper<LifeCollect> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq(LifeCollect::getStoreId, lifeCollect.getStoreId());
|
|
|
|
|
+ storeInfoMapper.update(null, new LambdaUpdateWrapper<StoreInfo>().eq(StoreInfo::getId, lifeCollect.getStoreId()).set(StoreInfo::getCollectNum, lifeCollectMapper.selectCount(queryWrapper)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} catch (BeansException e) {
|
|
} catch (BeansException e) {
|
|
|
log.error("LifeDiscountCouponController.receiveCoupon ERROR Msg=" + e.getMessage());
|
|
log.error("LifeDiscountCouponController.receiveCoupon ERROR Msg=" + e.getMessage());
|
|
|
return R.fail("领取失败");
|
|
return R.fail("领取失败");
|