|
|
@@ -12,17 +12,21 @@ import shop.alien.entity.result.R;
|
|
|
import shop.alien.entity.store.LifeCollect;
|
|
|
import shop.alien.entity.store.LifeDiscountCoupon;
|
|
|
import shop.alien.entity.store.LifeDiscountCouponUser;
|
|
|
+import shop.alien.entity.store.LifeUser;
|
|
|
import shop.alien.entity.store.StoreInfo;
|
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponUserDto;
|
|
|
import shop.alien.mapper.LifeCollectMapper;
|
|
|
import shop.alien.mapper.LifeDiscountCouponMapper;
|
|
|
import shop.alien.mapper.LifeDiscountCouponUserMapper;
|
|
|
+import shop.alien.mapper.LifeUserMapper;
|
|
|
import shop.alien.mapper.StoreInfoMapper;
|
|
|
import shop.alien.store.config.BaseRedisService;
|
|
|
import shop.alien.store.service.LifeDiscountCouponUserService;
|
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
|
import shop.alien.util.coupon.DiscountCouponExpirationUtil;
|
|
|
import shop.alien.util.coupon.LifeDiscountCouponStock;
|
|
|
+import shop.alien.util.type.PhoneTypeIdResult;
|
|
|
+import shop.alien.util.type.TypeUtil;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -42,6 +46,8 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
|
|
|
|
|
|
private final LifeCollectMapper lifeCollectMapper;
|
|
|
|
|
|
+ private final LifeUserMapper lifeUserMapper;
|
|
|
+
|
|
|
private final StoreInfoMapper storeInfoMapper;
|
|
|
|
|
|
private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
|
|
|
@@ -50,6 +56,8 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
|
|
|
|
|
|
private final BaseRedisService baseRedisService;
|
|
|
|
|
|
+ private final TypeUtil typeUtil;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -127,15 +135,25 @@ public class LifeDiscountCouponUserServiceImpl extends ServiceImpl<LifeDiscountC
|
|
|
Integer attentionCanReceived = lifeDiscountCoupon.getAttentionCanReceived();
|
|
|
if(attentionCanReceived != null && attentionCanReceived == 1){
|
|
|
|
|
|
+ LifeUser lifeUser = lifeUserMapper.selectById(lifeDiscountCouponUserDto.getUserId());
|
|
|
+ String collectUserId = lifeUser != null && !StringUtils.isEmpty(lifeUser.getUserPhone())
|
|
|
+ ? "user_" + lifeUser.getUserPhone()
|
|
|
+ : lifeDiscountCouponUserDto.getUserId().toString();
|
|
|
+
|
|
|
LambdaQueryWrapper<LifeCollect> lifeCollectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
lifeCollectLambdaQueryWrapper.eq(LifeCollect::getStoreId, lifeDiscountCoupon.getStoreId());
|
|
|
- lifeCollectLambdaQueryWrapper.eq(LifeCollect::getUserId, lifeDiscountCouponUserDto.getUserId());
|
|
|
+ lifeCollectLambdaQueryWrapper.eq(LifeCollect::getUserId, collectUserId);
|
|
|
lifeCollectLambdaQueryWrapper.eq(LifeCollect::getDeleteFlag, 0);
|
|
|
int lifeCollectCount = lifeCollectMapper.selectCount(lifeCollectLambdaQueryWrapper);
|
|
|
if(lifeCollectCount == 0){
|
|
|
LifeCollect lifeCollect = new LifeCollect();
|
|
|
lifeCollect.setStoreId(lifeDiscountCoupon.getStoreId());
|
|
|
- lifeCollect.setUserId(lifeDiscountCouponUserDto.getUserId().toString());
|
|
|
+ lifeCollect.setUserId(collectUserId);
|
|
|
+ PhoneTypeIdResult typeId = typeUtil.resolveTypeAndId(collectUserId);
|
|
|
+ if (typeId != null) {
|
|
|
+ lifeCollect.setUserIdUserType(typeId.getType());
|
|
|
+ lifeCollect.setUserIdRefId(typeId.getId());
|
|
|
+ }
|
|
|
lifeCollectMapper.insert(lifeCollect);
|
|
|
//同步店铺收藏数量
|
|
|
if (!StringUtils.isEmpty(lifeCollect.getStoreId())) {
|