Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:beijing_hongye_huicheng/lilishop
Browse files Browse the repository at this point in the history
  • Loading branch information
chopper711 committed Jun 18, 2024
2 parents 8c5ce39 + 0063820 commit 94da713
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public Token refreshStoreToken(String refreshToken) {
public Token mobilePhoneLogin(String mobilePhone) {
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mobile", mobilePhone);
Member member = this.baseMapper.selectOne(queryWrapper);
Member member = this.baseMapper.selectOne(queryWrapper, false);
//如果手机号不存在则自动注册用户
if (member == null) {
member = new Member(mobilePhone, UuidUtils.getUUID(), mobilePhone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
Expand Down Expand Up @@ -52,7 +51,7 @@ static String getPromotionGoodsStockCacheKey(PromotionTypeEnum typeEnum, String
* @param skus 商品skuId
* @return 促销商品集合
*/
List<PromotionGoods> findSkuValidPromotions(List<GoodsSkuDTO> skus);
List<PromotionGoods> findSkuValidPromotions(List<String> skus);

/**
* 分页获取促销商品信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import cn.lili.trigger.model.TimeTriggerMsg;
import cn.lili.trigger.util.DelayQueueTools;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import groovy.util.logging.Slf4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -46,8 +46,8 @@
* @author Bulbasaur
* @since 2021/5/20 6:10 下午
*/
@Slf4j
@Service
@Slf4j
public class CouponActivityServiceImpl extends AbstractPromotionsServiceImpl<CouponActivityMapper, CouponActivity> implements CouponActivityService {

@Autowired
Expand Down Expand Up @@ -227,20 +227,14 @@ public List<MemberCoupon> trigger(CouponActivityTrigger couponActivityTrigger) {
/**
* 自动发送优惠券则需要补足日志
*/
if (couponActivityTrigger.getCouponActivityTypeEnum().equals(CouponActivityTypeEnum.AUTO_COUPON)) {
if (couponActivityTrigger.getCouponActivityTypeEnum().equals(CouponActivityTypeEnum.AUTO_COUPON) || couponActivityTrigger.getCouponActivityTypeEnum().equals(CouponActivityTypeEnum.SPECIFY)) {
couponActivities = memberCouponSignService.receiveCoupon(couponActivities);
}

/**
* 自动领取优惠券判定同时,将精准发券功能同时判定
*/
if (couponActivityTrigger.getCouponActivityTypeEnum().equals(CouponActivityTypeEnum.SPECIFY)) {

couponActivities.addAll(memberCouponSignService.receiveCoupon(currentCouponActivity(CouponActivityTypeEnum.SPECIFY.name())));
}


//优惠券发放列表
log.info("当前用户的优惠券活动信息:{}", couponActivityTrigger);
log.info("当前进行的优惠券活动:{}", couponActivities);
List<CouponActivityItemVO> couponActivityItemVOS = new ArrayList<>();

//准备发放优惠券活动的列表
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package cn.lili.modules.promotion.serviceimpl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.lili.cache.Cache;
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.goods.service.GoodsService;
import cn.lili.modules.goods.service.GoodsSkuService;
Expand All @@ -34,7 +31,6 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -52,11 +48,6 @@ public class PromotionGoodsServiceImpl extends ServiceImpl<PromotionGoodsMapper,

private static final String SKU_ID_COLUMN = "sku_id";

/**
* Redis
*/
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 秒杀活动申请
*/
Expand Down Expand Up @@ -96,22 +87,12 @@ public List<PromotionGoods> findSkuValidPromotion(String skuId, String storeIds)
}

@Override
public List<PromotionGoods> findSkuValidPromotions(List<GoodsSkuDTO> skus) {
List<String> categories = skus.stream().map(GoodsSku::getCategoryPath).collect(Collectors.toList());
List<String> skuIds = skus.stream().map(GoodsSku::getId).collect(Collectors.toList());
List<String> categoriesPath = new ArrayList<>();
categories.forEach(i -> {
if (CharSequenceUtil.isNotEmpty(i)) {
categoriesPath.addAll(Arrays.asList(i.split(",")));
}
}
);
public List<PromotionGoods> findSkuValidPromotions(List<String> skuIds) {
QueryWrapper<PromotionGoods> queryWrapper = new QueryWrapper<>();

queryWrapper.and(i -> i.or(j -> j.in(SKU_ID_COLUMN, skuIds))
.or(n -> n.eq("scope_type", PromotionsScopeTypeEnum.ALL.name()))
.or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name())
.and(l -> l.in(CollUtil.isNotEmpty(categoriesPath), "scope_id", categoriesPath)))));
.or(n -> n.and(k -> k.eq("scope_type", PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()))));
queryWrapper.and(i -> i.or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.START)).or(PromotionTools.queryPromotionStatus(PromotionsStatusEnum.NEW)));
return this.list(queryWrapper);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ public void init() {
if (skuIPage == null || CollUtil.isEmpty(skuIPage.getRecords())) {
break;
}
List<PromotionGoods> skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIPage.getRecords());
List<String> skuIds = skuIPage.getRecords().stream().map(GoodsSku::getId).collect(Collectors.toList());
List<PromotionGoods> skuValidPromotions = promotionGoodsService.findSkuValidPromotions(skuIds);

List<String> brandIds = new ArrayList<>();

Expand Down Expand Up @@ -248,7 +249,9 @@ public void init() {
(CharSequenceUtil.isNotEmpty(j.getSkuId()) && j.getSkuId().equals(goodsSku.getId())) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals("0")) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.ALL.name()) && j.getStoreId().equals(esGoodsIndex.getStoreId())) ||
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getScopeId().contains(goodsSku.getCategoryPath())))
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals("0") && j.getScopeId().contains(goodsSku.getCategoryPath()))||
(j.getScopeType().equals(PromotionsScopeTypeEnum.PORTION_GOODS_CATEGORY.name()) && j.getStoreId().equals(goodsSku.getStoreId()) && j.getScopeId().contains(goodsSku.getCategoryPath()))
)
.collect(Collectors.toList());
if (CollUtil.isNotEmpty(promotionGoods)) {
esGoodsIndex.setPromotionMapJson(JSONUtil.toJsonStr(promotionService.wrapperPromotionMapList(promotionGoods)));
Expand Down

0 comments on commit 94da713

Please sign in to comment.