Skip to content

Commit

Permalink
Merge pull request lilishop#67
Browse files Browse the repository at this point in the history
feature/pg
  • Loading branch information
LeiGaoRobot authored Sep 8, 2022
2 parents 2066445 + e2bf90e commit c57366c
Show file tree
Hide file tree
Showing 32 changed files with 520 additions and 60 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,其他问题先看文档后提问)

#### 不用削尖脑袋往老群里加,老群活跃度较低,很多潜水党,新群相对而言活跃一些 :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606:


##### 交流 qq 1群 961316482(已满)
<a target="_blank" href="https://qm.qq.com/cgi-bin/qm/qr?k=BAhURE3DG2YWhQk6kRxVapbLykqMoPS8&jump_from=webapi"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="Lilishop交流群" title="Lilishop交流群">点击快捷加群</a>
Expand Down
46 changes: 46 additions & 0 deletions consumer/src/main/java/cn/lili/event/impl/MemberCouponExecute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package cn.lili.event.impl;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.event.OrderStatusChangeEvent;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dto.OrderMessage;
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.promotion.service.MemberCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* 会员优惠券执行类
*
* @author paulG
* @since 2022/8/12
**/
@Service
public class MemberCouponExecute implements OrderStatusChangeEvent {

/**
* 订单
*/
@Autowired
private OrderService orderService;

@Autowired
private MemberCouponService memberCouponService;

@Override
public void orderChange(OrderMessage orderMessage) {
// 订单取消返还优惠券
if (orderMessage.getNewStatus() == OrderStatusEnum.CANCELLED) {
Order order = orderService.getBySn(orderMessage.getOrderSn());
if (CharSequenceUtil.isNotEmpty(order.getUseStoreMemberCouponIds())) {
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUseStoreMemberCouponIds().split(",")));
} else if (CharSequenceUtil.isNotEmpty(order.getUsePlatformMemberCouponId())) {
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUsePlatformMemberCouponId().split(",")));
}
}
}


}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cn.lili.event.impl;


import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.event.AfterSaleStatusChangeEvent;
import cn.lili.event.GoodsCommentCompleteEvent;
import cn.lili.event.MemberRegisterEvent;
Expand Down Expand Up @@ -104,7 +104,7 @@ public void orderChange(OrderMessage orderMessage) {
case COMPLETED: {
Order order = orderService.getBySn(orderMessage.getOrderSn());
//如果是积分订单 则直接返回
if (StringUtils.isNotEmpty(order.getOrderPromotionType())
if (CharSequenceUtil.isNotEmpty(order.getOrderPromotionType())
&& order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public void onMessage(MessageExt messageExt) {
for (String goodsId : JSONUtil.toList(goodsIdsJsonStr, String.class)) {
goodsIndexService.deleteIndex(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build());
}

promotionService.removeByGoodsIds(goodsIdsJsonStr);
} catch (Exception e) {
log.error("删除商品索引事件执行异常,商品信息: " + new String(messageExt.getBody()), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ReturnT<String> everyHourExecuteJobHandler(String param) {
try {
everyHourExecutes.get(i).execute();
} catch (Exception e) {
log.error("每分钟任务异常", e);
log.error("每小时任务异常", e);
}
}
return ReturnT.SUCCESS;
Expand All @@ -94,7 +94,7 @@ public ReturnT<String> everyDayExecuteJobHandler(String param) {
try {
everyDayExecutes.get(i).execute();
} catch (Exception e) {
log.error("每分钟任务异常", e);
log.error("每日任务异常", e);
}
}
return ReturnT.SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cn.lili.timetask.handler.impl.promotion;

import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.modules.promotion.entity.dos.Seckill;
import cn.lili.modules.promotion.service.SeckillService;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.SeckillSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import cn.lili.timetask.handler.EveryDayExecute;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -72,10 +73,9 @@ private void addSeckill() {
for (int i = 1; i <= SeckillService.PRE_CREATION; i++) {
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());

LambdaQueryWrapper<Seckill> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Seckill::getStartTime, seckill.getStartTime());
//如果已经存在促销,则不再次保存
if (seckillService.list(lambdaQueryWrapper).isEmpty()) {
if (seckillService.list(
PromotionTools.checkActiveTime(seckill.getStartTime(), seckill.getEndTime(), PromotionTypeEnum.SECKILL, null, seckill.getId())).isEmpty()) {
boolean result = seckillService.savePromotions(seckill);
log.info("生成秒杀活动参数:{},结果:{}", seckill, result);
}
Expand Down
15 changes: 9 additions & 6 deletions framework/src/main/java/cn/lili/common/enums/ResultCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public enum ResultCode {
MUST_HAVE_SALES_MODEL(11022, "销售模式为批发时必须要有批发规则!"),

HAVE_INVALID_SALES_MODEL(11023, "批发规则存在小于等于0的无效数据!"),
MUST_HAVE_GOODS_SKU_VALUE(11024, "规格值不能为空!"),

GOODS_PARAMS_ERROR(11013, "商品参数错误,刷新后重试"),
PHYSICAL_GOODS_NEED_TEMP(11014, "实物商品需选择配送模板"),
Expand Down Expand Up @@ -278,11 +279,6 @@ public enum ResultCode {
COUPON_RECEIVE_ERROR(41005, "当前优惠券已经被领取完了,下次要早点来哦"),
COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"),
COUPON_NOT_EXIST(41007, "当前优惠券不存在"),
COUPON_DO_NOT_RECEIVER(41030, "当前优惠券不允许主动领取"),
COUPON_ACTIVITY_NOT_EXIST(410022, "当前优惠券活动不存在"),
COUPON_SAVE_ERROR(41020, "保存优惠券失败"),
COUPON_ACTIVITY_SAVE_ERROR(41023, "保存优惠券活动失败"),
COUPON_DELETE_ERROR(41021, "删除优惠券失败"),
COUPON_LIMIT_NUM_LESS_THAN_0(41008, "领取限制数量不能为负数"),
COUPON_LIMIT_GREATER_THAN_PUBLISH(41009, "领取限制数量超出发行数量"),
COUPON_DISCOUNT_ERROR(41010, "优惠券折扣必须小于10且大于0"),
Expand All @@ -293,8 +289,15 @@ public enum ResultCode {
COUPON_MEMBER_NOT_EXIST(41015, "没有当前会员优惠券"),
COUPON_MEMBER_STATUS_ERROR(41016, "当前会员优惠券已过期/作废无法变更状态!"),

SPECIAL_CANT_USE(41020, "特殊商品不能使用优惠券,不能使用"),
SPECIAL_CANT_USE(41019, "特殊商品不能使用优惠券,不能使用"),

COUPON_SAVE_ERROR(41020, "保存优惠券失败"),
COUPON_DELETE_ERROR(41021, "删除优惠券失败"),
COUPON_ACTIVITY_NOT_EXIST(41022, "当前优惠券活动不存在"),
COUPON_ACTIVITY_SAVE_ERROR(41023, "保存优惠券活动失败"),
COUPON_ACTIVITY_MAX_NUM(41024, "优惠券活动赠券数量最多为3"),

COUPON_DO_NOT_RECEIVER(41030, "当前优惠券不允许主动领取"),

/**
* 拼团
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ public Goods(GoodsOperationDTO goodsOperationDTO) {
if (!sku.containsKey("quantity") || StringUtil.isEmpty(sku.get("quantity").toString()) || Convert.toInt(sku.get("quantity").toString()) < 0) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_ERROR);
}
sku.values().forEach(i -> {
if (CharSequenceUtil.isBlank(i.toString())) {
throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU_VALUE);
}
});


}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ private void checkGoods(Goods goods) {
break;
case "VIRTUAL_GOODS":
if (!"0".equals(goods.getTemplateId())) {
throw new ServiceException(ResultCode.VIRTUAL_GOODS_NOT_NEED_TEMP);
goods.setTemplateId("0");
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private static void builderSingle(GoodsSku goodsSku, Map<String, Object> skuInfo
//商品名称
StringBuilder goodsName = new StringBuilder(goodsOperationDTO.getGoodsName());
//规格值
Map<String, Object> specMap = new HashMap<>(16);
Map<String, Object> specMap = new LinkedHashMap<>();

// 原始规格项
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cn.lili.modules.member.entity.dos;

import cn.lili.mybatis.BaseEntity;
import cn.lili.common.enums.SwitchEnum;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.member.entity.dto.MemberEvaluationDTO;
import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.mybatis.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand Down Expand Up @@ -108,28 +108,28 @@ public class MemberEvaluation extends BaseEntity {
private Integer descriptionScore;


public MemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, GoodsSku goodsSku, Member member,Order order){
public MemberEvaluation(MemberEvaluationDTO memberEvaluationDTO, GoodsSku goodsSku, Member member, Order order) {
//复制评价信息
BeanUtils.copyProperties(memberEvaluationDTO, this);
//设置会员
this.memberId=member.getId();
this.memberId = member.getId();
//会员名称
this.memberName=member.getNickName();
this.memberName = member.getNickName();
//设置会员头像
this.memberProfile=member.getFace();
this.memberProfile = member.getFace();
//商品名称
this.goodsName=goodsSku.getGoodsName();
this.goodsName = goodsSku.getGoodsName();
//商品图片
this.goodsImage=goodsSku.getThumbnail();
this.goodsImage = goodsSku.getThumbnail();
//设置店铺ID
this.storeId=order.getStoreId();
this.storeId = order.getStoreId();
//设置店铺名称
this.storeName=order.getStoreName();
this.storeName = order.getStoreName();
//设置订单编号
this.orderNo=order.getSn();
this.orderNo = order.getSn();
//是否包含图片
this.haveImage=StringUtils.isNotEmpty(memberEvaluationDTO.getImages());
this.haveImage = StringUtils.isNotEmpty(memberEvaluationDTO.getImages());
//默认开启评价
this.status=SwitchEnum.OPEN.name();
this.status = SwitchEnum.OPEN.name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public void checkMemberEvaluation(OrderItem orderItem, Order order) {
}

//判断是否是当前会员的订单
if (!order.getMemberId().equals(UserContext.getCurrentUser().getId())) {
if (UserContext.getCurrentUser() != null && !order.getMemberId().equals(UserContext.getCurrentUser().getId())) {
throw new ServiceException(ResultCode.ORDER_NOT_USER);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.common.aop.annotation.DemoSite;
import cn.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.SwitchEnum;
Expand Down Expand Up @@ -264,6 +265,7 @@ public Member editOwn(MemberEditDTO memberEditDTO) {
}

@Override
@DemoSite
public Member modifyPass(String oldPassword, String newPassword) {
AuthUser tokenUser = UserContext.getCurrentUser();
if (tokenUser == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import cn.lili.common.enums.PromotionTypeEnum;
import cn.lili.common.utils.BeanUtil;
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
import cn.lili.modules.order.cart.entity.dto.MemberCouponDTO;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.enums.CartTypeEnum;
import cn.lili.modules.order.cart.entity.enums.DeliveryMethodEnum;
Expand Down Expand Up @@ -238,8 +239,8 @@ public Order(CartVO cartVO, TradeDTO tradeDTO) {
//店铺优惠券判定
if (tradeDTO.getStoreCoupons() != null && !tradeDTO.getStoreCoupons().isEmpty()) {
StringBuilder storeCouponIds = new StringBuilder();
for (String s : tradeDTO.getStoreCoupons().keySet()) {
storeCouponIds.append(s).append(",");
for (MemberCouponDTO value : tradeDTO.getStoreCoupons().values()) {
storeCouponIds.append(value.getMemberCoupon().getId()).append(",");
}
this.setUseStoreMemberCouponIds(storeCouponIds.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import cn.lili.modules.promotion.entity.vos.kanjia.KanjiaActivityGoodsVO;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.List;


/**
* 砍价业务层
Expand Down Expand Up @@ -69,4 +71,9 @@ public interface KanjiaActivityGoodsService extends AbstractPromotionsService<Ka
*/
boolean updateKanjiaActivityGoods(KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO);

/**
* 根据商品id删除促销活动
* @param goodsIds
*/
void deleteByGoodsIds(List<String> goodsIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,12 @@ public interface MemberCouponService extends IService<MemberCoupon> {
*/
void closeMemberCoupon(List<String> couponIds);

/**
* 恢复会员优惠券
*
* @param memberCouponIds 会员优惠券id列表
* @return 是否恢复成功
*/
boolean recoveryMemberCoupon(List<String> memberCouponIds);

}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ static String getPromotionGoodsStockCacheKey(PromotionTypeEnum typeEnum, String
*/
void deletePromotionGoods(List<String> promotionIds);

/**
* 删除商品的促销
*
* @param goodsIds 商品id
*/
void deletePromotionGoodsByGoods(List<String> goodsIds);

/**
* 根据参数删除促销商品
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ public interface PromotionService {
/**
* 根据商品索引获取当前商品索引的所有促销活动信息
*
* @param storeId 店铺id
* @param storeId 店铺id
* @param goodsSkuId 商品skuId
* @return 当前促销活动集合
*/
Map<String, Object> getGoodsSkuPromotionMap(String storeId, String goodsSkuId);

/**
* 删除商品,则删除相关促销信息
*
* @param goodsIdsJsonStr
*/
void removeByGoodsIds(String goodsIdsJsonStr);
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void sendCoupon(List<Map<String, Object>> memberList, List<CouponActivityItem> c
//批量添加优惠券
memberCouponService.saveBatch(memberCouponList);
//添加优惠券已领取数量
couponService.receiveCoupon(couponActivityItem.getCouponId(), memberCouponList.size() * couponActivityItem.getNum());
couponService.receiveCoupon(couponActivityItem.getCouponId(), memberCouponList.size());
} else {
log.error("赠送优惠券失败,当前优惠券不存在:" + couponActivityItem.getCouponId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void checkPromotions(Coupon promotions) {
}
//打折优惠券大于10折
boolean discountCoupon = (promotions.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())
&& (promotions.getCouponDiscount() < 0 && promotions.getCouponDiscount() > 10));
&& (promotions.getCouponDiscount() < 0 || promotions.getCouponDiscount() > 10));
if (discountCoupon) {
throw new ServiceException(ResultCode.COUPON_DISCOUNT_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ public boolean updateKanjiaActivityGoods(KanjiaActivityGoodsDTO kanJiaActivityGo
return this.updateById(kanJiaActivityGoodsDTO);
}

@Override
public void deleteByGoodsIds(List<String> goodsIds) {
this.remove(new QueryWrapper<KanjiaActivityGoods>().in("goods_id", goodsIds));
}

/**
* 当前促销类型
*
Expand Down
Loading

0 comments on commit c57366c

Please sign in to comment.