|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -13,11 +14,9 @@ import org.springframework.beans.BeansException;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import shop.alien.entity.store.*;
|
|
import shop.alien.entity.store.*;
|
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
|
|
import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
|
|
|
-import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleDetailVo;
|
|
|
|
|
-import shop.alien.entity.store.vo.LifeDiscountCouponFriendRuleVo;
|
|
|
|
|
-import shop.alien.entity.store.vo.LifeDiscountCouponStoreFriendVo;
|
|
|
|
|
-import shop.alien.entity.store.vo.LifeDiscountCouponVo;
|
|
|
|
|
|
|
+import shop.alien.entity.store.vo.*;
|
|
|
import shop.alien.mapper.*;
|
|
import shop.alien.mapper.*;
|
|
|
|
|
+import shop.alien.store.config.WebSocketProcess;
|
|
|
import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
|
|
import shop.alien.store.service.LifeDiscountCouponStoreFriendService;
|
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
import shop.alien.util.common.constant.DiscountCouponEnum;
|
|
|
|
|
|
|
@@ -67,6 +66,8 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
|
|
|
|
|
private final LifeDiscountCouponFriendRuleDetailMapper lifeDiscountCouponFriendRuleDetailMapper;
|
|
private final LifeDiscountCouponFriendRuleDetailMapper lifeDiscountCouponFriendRuleDetailMapper;
|
|
|
|
|
|
|
|
|
|
+ private final WebSocketProcess webSocketProcess;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<LifeDiscountCouponStoreFriendVo> getFriendCouponList(UserLoginInfo userLoginInfo, String friendUserId) {
|
|
public List<LifeDiscountCouponStoreFriendVo> getFriendCouponList(UserLoginInfo userLoginInfo, String friendUserId) {
|
|
|
List<LifeDiscountCouponStoreFriendVo> result = new ArrayList<>();
|
|
List<LifeDiscountCouponStoreFriendVo> result = new ArrayList<>();
|
|
@@ -192,19 +193,31 @@ public class LifeDiscountCouponStoreFriendServiceImpl extends ServiceImpl<LifeDi
|
|
|
lifeDiscountCoupon.setSingleQty(lifeDiscountCoupon.getSingleQty() - couponDto.getSingleQty());
|
|
lifeDiscountCoupon.setSingleQty(lifeDiscountCoupon.getSingleQty() - couponDto.getSingleQty());
|
|
|
// 更新数据库中的优惠券库存信息
|
|
// 更新数据库中的优惠券库存信息
|
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
lifeDiscountCouponMapper.updateById(lifeDiscountCoupon);
|
|
|
- // 发送好友优惠券通知
|
|
|
|
|
- LifeNotice lifeMessage = new LifeNotice();
|
|
|
|
|
- String text = "您的好友"+userLoginInfo.getUserName()+"送了您"+couponDto.getSingleQty()+"张店铺优惠券,快去使用吧!";
|
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
|
- jsonObject.put("message", text);
|
|
|
|
|
- lifeMessage.setReceiverId("store_"+storeUser.getPhone());
|
|
|
|
|
- lifeMessage.setTitle("赠券通知");
|
|
|
|
|
- lifeMessage.setContext(jsonObject.toJSONString());
|
|
|
|
|
- lifeMessage.setNoticeType(1);
|
|
|
|
|
- lifeMessage.setIsRead(0);
|
|
|
|
|
- lifeMessage.setDeleteFlag(0);
|
|
|
|
|
- lifeMessage.setSenderId("system");
|
|
|
|
|
- lifeNoticeMapper.insert(lifeMessage);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ int friendStoreId = lifeDiscountCouponStoreFriendDto.getFriendStoreUserId();
|
|
|
|
|
+ LambdaQueryWrapper<StoreUser> storeUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ storeUserLambdaQueryWrapper.eq(StoreUser::getStoreId, friendStoreId);
|
|
|
|
|
+ List<StoreUser> storeUserList = storeUserMapper.selectList(storeUserLambdaQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ if(CollectionUtils.isNotEmpty(storeUserList)){
|
|
|
|
|
+ StoreUser friendStoreUser = storeUserList.get(0);
|
|
|
|
|
+ String friendPhone = friendStoreUser.getPhone();
|
|
|
|
|
+ if(StringUtils.isNotEmpty(friendPhone)){
|
|
|
|
|
+ // 发送好友优惠券通知
|
|
|
|
|
+ LifeNotice lifeMessage = new LifeNotice();
|
|
|
|
|
+ String text = "您的好友"+userLoginInfo.getUserName()+"送了您"+couponDto.getSingleQty()+"张店铺优惠券,快去使用吧!";
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("message", text);
|
|
|
|
|
+ lifeMessage.setReceiverId("store_"+friendPhone);
|
|
|
|
|
+ lifeMessage.setTitle("赠券通知");
|
|
|
|
|
+ lifeMessage.setContext(jsonObject.toJSONString());
|
|
|
|
|
+ lifeMessage.setNoticeType(1);
|
|
|
|
|
+ lifeMessage.setIsRead(0);
|
|
|
|
|
+ lifeMessage.setDeleteFlag(0);
|
|
|
|
|
+ lifeMessage.setSenderId("system");
|
|
|
|
|
+ lifeNoticeMapper.insert(lifeMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 如果所有优惠券都成功处理,返回 true
|
|
// 如果所有优惠券都成功处理,返回 true
|
|
|
return true;
|
|
return true;
|