Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/qiuqiu'
Browse files Browse the repository at this point in the history
合并砍价/积分相关

# Conflicts:
#	consumer/src/main/java/cn/lili/event/impl/MemberPointExecute.java
#	update-sql/version4.2to4.3.sql
  • Loading branch information
chopper711 committed Jul 30, 2021
2 parents 8deaef0 + 0cad52c commit 829472c
Show file tree
Hide file tree
Showing 57 changed files with 2,359 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ResultMessage<IPage<MemberPointsHistory>> getByPage(PageVO page) {

LambdaQueryWrapper<MemberPointsHistory> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(MemberPointsHistory::getMemberId, UserContext.getCurrentUser().getId());

queryWrapper.orderByDesc(MemberPointsHistory::getCreateTime);
return ResultUtil.data(memberPointsHistoryService.page(PageUtil.initPage(page), queryWrapper));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package cn.lili.controller.promotion;

import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.KanjiaActivity;
import cn.lili.modules.promotion.entity.dos.KanjiaActivityLog;
import cn.lili.modules.promotion.entity.dto.KanJiaActivityLogQuery;
import cn.lili.modules.promotion.entity.dto.KanjiaActivityQuery;
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
import cn.lili.modules.promotion.entity.vos.kanjia.*;
import cn.lili.modules.promotion.service.KanjiaActivityGoodsService;
import cn.lili.modules.promotion.service.KanjiaActivityLogService;
import cn.lili.modules.promotion.service.KanjiaActivityService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* 买家端,砍价活动商品
*
* @author qiuqiu
* @date 2021/7/12
**/
@RestController
@Api(tags = "买家端,砍价商品接口")
@RequestMapping("/buyer/promotion/kanjiaGoods")
public class KanjiaGoodsActivityBuyerController {

/**
* 砍价活动商品
*/
@Autowired
private KanjiaActivityGoodsService kanJiaActivityGoodsService;
/**
* 帮砍记录
*/
@Autowired
private KanjiaActivityLogService kanJiaActivityLogService;
/**
* 砍价活动
*/
@Autowired
private KanjiaActivityService kanJiaActivityService;

@GetMapping
@ApiOperation(value = "分页获取砍价商品")
public ResultMessage<IPage<KanjiaActivityGoodsListVO>> kanjiaActivityGoodsPage(KanjiaActivityGoodsParams kanjiaActivityGoodsParams, PageVO page) {
// 会员端查询到的肯定是已经开始的活动商品
kanjiaActivityGoodsParams.setPromotionStatus(PromotionStatusEnum.START.name());
return ResultUtil.data(kanJiaActivityGoodsService.kanjiaGoodsVOPage(kanjiaActivityGoodsParams, page));
}

@GetMapping("/{id}")
@ApiOperation(value = "获取砍价活动商品")
@ApiImplicitParam(name = "id", value = "砍价活动商品ID", required = true, paramType = "path")
public ResultMessage<KanjiaActivityGoodsVO> getKanjiaActivityGoods(@PathVariable String id) {
return ResultUtil.data(kanJiaActivityGoodsService.getKanJiaGoodsVO(id));
}

@GetMapping("/getKanjiaActivity/logs")
@ApiOperation(value = "分页获取砍价活动-帮砍记录")
public ResultMessage<IPage<KanjiaActivityLog>> getKanjiaActivityLog(KanJiaActivityLogQuery kanJiaActivityLogQuery, PageVO page) {
return ResultUtil.data(kanJiaActivityLogService.getForPage(kanJiaActivityLogQuery, page));
}

@PostMapping("/getKanjiaActivity")
@ApiOperation(value = "获取砍价活动")
public ResultMessage<KanjiaActivityVO> getKanJiaActivity(KanjiaActivitySearchParams kanjiaActivitySearchParams) {
//如果是非被邀请关系则填写会员ID
if (StrUtil.isEmpty(kanjiaActivitySearchParams.getKanjiaActivityId())) {
kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId());
}
return ResultUtil.data(kanJiaActivityService.getKanjiaActivityVO(kanjiaActivitySearchParams));
}

@PostMapping
@ApiImplicitParam(name = "id", value = "砍价活动商品ID", required = true, paramType = "path")
@ApiOperation(value = "发起砍价活动")
public ResultMessage<KanjiaActivityLog> launchKanJiaActivity(String id) {
KanjiaActivityLog kanjiaActivityLog = kanJiaActivityService.add(id);
return ResultUtil.data(kanjiaActivityLog);
}

@PostMapping("/help/{kanjiaActivityId}")
@ApiImplicitParam(name = "kanJiaActivityId", value = "砍价活动ID", required = true, paramType = "path")
@ApiOperation(value = "帮砍一刀")
public ResultMessage<KanjiaActivityLog> helpKanJia(@PathVariable String kanjiaActivityId) {
KanjiaActivityLog kanjiaActivityLog = kanJiaActivityService.helpKanJia(kanjiaActivityId);
return ResultUtil.data(kanjiaActivityLog);
}

@GetMapping("/kanjiaActivity/mine/")
@ApiOperation(value = "分页获取已参与的砍价活动")
public ResultMessage<IPage<KanjiaActivity>> getPointsGoodsPage(KanjiaActivityQuery kanjiaActivityQuery, PageVO page) {
// 会员端查询到的肯定是已经开始的活动商品
kanjiaActivityQuery.setMemberId(UserContext.getCurrentUser().getId());
IPage<KanjiaActivity> kanjiaActivity = kanJiaActivityService.getForPage(kanjiaActivityQuery, page);
return ResultUtil.data(kanjiaActivity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import cn.lili.modules.promotion.service.PointsGoodsService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand Down Expand Up @@ -44,4 +46,11 @@ public ResultMessage<IPage<PointsGoodsCategory>> page(String name, PageVO page)
return ResultUtil.data(pointsGoodsCategoryService.getCategoryByPage(name, page));
}

@GetMapping("/{id}")
@ApiOperation(value = "获取积分活动商品")
@ApiImplicitParam(name = "id", value = "积分商品ID", required = true, paramType = "path")
public ResultMessage<PointsGoodsVO> getPointsGoodsPage(@PathVariable String id) {
return ResultUtil.data(pointsGoodsService.getPointsGoodsDetail(id));
}

}
3 changes: 0 additions & 3 deletions config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ spring:
# replica-set-name: mongoreplset
cache:
type: redis
#amqp
# rabbitmq:
# host: 192.168.0.116
jpa:
# 自动生成表结构
generate-ddl: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.lili.event.impl;


import cn.hutool.core.convert.Convert;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.event.AfterSaleStatusChangeEvent;
Expand Down Expand Up @@ -87,7 +88,7 @@ public void orderChange(OrderMessage orderMessage) {
if (orderMessage.getNewStatus().equals(OrderStatusEnum.COMPLETED)) {
Order order = orderService.getBySn(orderMessage.getOrderSn());
//根据订单编号获取订单数据,如果订单促销类型不为空,并且订单促销类型为积分订单 则直接返回
if (StringUtils.isNotEmpty(order.getOrderPromotionType()) && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINT.name())) {
if (StringUtils.isNotEmpty(order.getOrderPromotionType()) && order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name())) {
return;
}
//获取积分设置
Expand All @@ -96,7 +97,13 @@ public void orderChange(OrderMessage orderMessage) {
Double point = CurrencyUtil.mul(pointSetting.getMoney(), order.getFlowPrice(), 0);
//赠送会员积分
memberService.updateMemberPoint(point.longValue(), true, order.getMemberId(), "会员下单,赠送积分" + point + "分");

//取消订单恢复积分
} else if (orderMessage.getNewStatus().equals(OrderStatusEnum.CANCELLED)) {
//根据订单编号获取订单数据,如果为积分订单则跳回
Order order = orderService.getBySn(orderMessage.getOrderSn());
if (order.getOrderPromotionType().equals(OrderPromotionTypeEnum.POINTS.name()) && order.getPriceDetailDTO().getPayPoint() != null) {
memberService.updateMemberPoint(Convert.toLong(order.getPriceDetailDTO().getPayPoint()), true, order.getMemberId(), "订单取消,恢复积分:" + order.getPriceDetailDTO().getPayPoint() + "分");
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ public enum PromotionTypeEnum {
COUPON("优惠券"),
FULL_DISCOUNT("满减"),
POINTS_GOODS("积分商品"),
KANJIA("砍价"),
COUPON_ACTIVITY("优惠券活动")
;

/**
* 拼团秒杀拥有独立库存,如果其他促销也有独立库存涉及库存扣减的,请添加在下方
*/
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL};
static PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA};

private final String description;

Expand Down
36 changes: 28 additions & 8 deletions framework/src/main/java/cn/lili/common/enums/ResultCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public enum ResultCode {
USER_OVERDUE_CONNECT_ERROR(20022, "授权信息已过期,请重新授权/登录"),
USER_CONNECT_BANDING_ERROR(20023, "当前联合登陆方式,已绑定其他账号,需进行解绑操作"),
USER_CONNECT_NOT_EXIST_ERROR(20024, "暂无联合登陆信息,无法实现一键注册功能,请点击第三方登录进行授权"),
USER_POINTS_ERROR(20024, "用户积分不足"),

/**
* 权限
Expand Down Expand Up @@ -234,13 +235,16 @@ public enum ResultCode {
* 活动
*/
PROMOTION_GOODS_NOT_EXIT(40001, "当前促销商品不存在!"),
PROMOTION_SAME_ACTIVE_EXIST(40002, "当前时间内已存在同类活动"),
PROMOTION_START_TIME_ERROR(40003, "活动起始时间不能大于活动结束时间"),
PROMOTION_TIME_ERROR(40004, "活动起始时间必须大于当前时间"),
PROMOTION_SAME_ERROR(40005, "当前时间段已存在相同活动!"),
PROMOTION_GOODS_ERROR(40006, "请选择要参与活动的商品"),
PROMOTION_STATUS_END(40007, "当前活动已停止"),
PROMOTION_UPDATE_ERROR(40008, "当前活动已开始/结束,无法编辑!"),
PROMOTION_SAME_ACTIVE_EXIST(40002,"当前时间内已存在同类活动"),
PROMOTION_START_TIME_ERROR(40003,"活动起始时间不能大于活动结束时间"),
PROMOTION_TIME_ERROR(40004,"活动起始时间必须大于当前时间"),
PROMOTION_SAME_ERROR(40005,"当前时间段已存在相同活动!"),
PROMOTION_GOODS_ERROR(40006,"请选择要参与活动的商品"),
PROMOTION_STATUS_END(40007,"当前活动已停止"),
PROMOTION_UPDATE_ERROR(40008,"当前活动已开始/结束,无法编辑!"),
PROMOTION_ACTIVITY_GOODS_ERROR(40009,"当前活动已经开始无法添加商品"),
PROMOTION_ACTIVITY_ERROR(40009,"当前促销活动不存在"),
PROMOTION_LOG_EXIST(40010,"活动已参加,已发重复参加"),

/**
* 优惠券
Expand Down Expand Up @@ -325,7 +329,23 @@ public enum ResultCode {
* 其他促销
*/
MEMBER_SIGN_REPEAT(47001, "请勿重复签到"),
POINT_GOODS_ACTIVE_STOCK_ERROR(47002, "活动库存数量不能高于商品库存"),
POINT_GOODS_ACTIVE_STOCK_ERROR(47002, "最低金额不能高于商品金额"),

/**
* 砍价活动
*/
KANJIA_GOODS_ACTIVE_STOCK_ERROR(48001, "活动库存数量不能高于商品库存"),
KANJIA_GOODS_ACTIVE_PRICE_ERROR(48002, "最低购买金额不能高于商品金额"),
KANJIA_GOODS_ACTIVE_HIGHEST_PRICE_ERROR(48003, "最高砍价金额不能为0且不能超过商品金额"),
KANJIA_GOODS_ACTIVE_LOWEST_PRICE_ERROR(48004, "最低砍价金额不能为0且不能超过商品金额"),
KANJIA_GOODS_ACTIVE_HIGHEST_LOWEST_PRICE_ERROR(48005, "最低砍价金额不能高于最高砍价金额"),
KANJIA_GOODS_ACTIVE_SETTLEMENT_PRICE_ERROR(48006, "结算金额不能高于商品金额"),
KANJIA_GOODS_DELETE_ERROR(48007, "删除砍价商品异常"),
KANJIA_ACTIVITY_NOT_FOUND_ERROR(48008, "砍价记录不存在"),
KANJIA_ACTIVITY_LOG_MEMBER_ERROR(48009, "当前会员已经帮砍"),
KANJIA_ACTIVITY_MEMBER_ERROR(48010, "当前会员已经发起此砍价商品活动"),
KANJIA_ACTIVITY_NOT_PASS_ERROR(48011, "当前砍价未满足条件,不能进行购买"),
KANJIA_NUM_BUY_ERROR(48012, "砍价商品购买数量不正确"),
/**
* 店铺
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public enum CartTypeEnum {
* 立即购买
*/
BUY_NOW,
/**
* 虚拟商品
*/
VIRTUAL,
/**
* 拼团
*/
Expand All @@ -25,8 +29,8 @@ public enum CartTypeEnum {
*/
POINTS,
/**
* 虚拟商品
* 砍价商品
*/
VIRTUAL;
KANJIA;

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ public class CartSkuVO extends CartBase implements Serializable {
@ApiModelProperty(value = "是否可配送")
private Boolean isShip;

@ApiModelProperty(value =
"拼团id 如果是拼团购买 此值为拼团活动id," +
@ApiModelProperty(value = "拼团id 如果是拼团购买 此值为拼团活动id," +
"当pintuanId为空,则表示普通购买(或者拼团商品,单独购买)")
private String pintuanId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ public class TradeBuilder {
*/
int[] defaultRender = {0, 1, 2, 4, 5, 6, 7};

/**
* 单个商品优惠,不需要渲染满减优惠
*/
int[] singleRender = {0, 2, 4, 5, 6, 7};

/**
* 购物车购物车渲染
* 0-> 校验商品, 1-》 满优惠渲染, 2->渲染优惠, 5->计算价格
*/
int[] cartRender = {0, 1, 2, 5};


/**
* 构造购物车
* 购物车与结算信息不一致的地方主要是优惠券计算和运费计算,其他规则都是一致都
Expand Down Expand Up @@ -98,12 +104,23 @@ public TradeDTO buildTrade(CartTypeEnum checkedWay) {
//将购物车到sku未选择信息过滤
List<CartSkuVO> collect = tradeDTO.getSkuList().parallelStream().filter(i -> Boolean.TRUE.equals(i.getChecked())).collect(Collectors.toList());
tradeDTO.setSkuList(collect);
//按照计划进行渲染
for (int index : defaultRender) {
try {
cartRenderSteps.get(index).render(tradeDTO);
} catch (Exception e) {
log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e);
if (checkedWay.equals(CartTypeEnum.CART) || checkedWay.equals(CartTypeEnum.BUY_NOW) || checkedWay.equals(CartTypeEnum.VIRTUAL)) {
//按照计划进行渲染
for (int index : defaultRender) {
try {
cartRenderSteps.get(index).render(tradeDTO);
} catch (Exception e) {
log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e);
}
}
} else {
//按照计划进行渲染
for (int index : singleRender) {
try {
cartRenderSteps.get(index).render(tradeDTO);
} catch (Exception e) {
log.error("购物车{}渲染异常:", cartRenderSteps.get(index).getClass(), e);
}
}
}

Expand Down
Loading

0 comments on commit 829472c

Please sign in to comment.