Commit d99cc04a by ping.wu

套餐优惠计算

parent 834b8079
......@@ -46,6 +46,11 @@ public class CartGoods {
*/
private String unit;
/**
* 商品券code
*/
private String couponCode;
private String spuId;
private String skuId;
/**
......
......@@ -35,7 +35,7 @@
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
<artifactId>productcenter-sdk</artifactId>
<version>3.2.RELEASE</version>
<version>3.2.RELEASE</version> <!-- //3.6.4-SNAPSHOTE -->
</dependency>
<dependency>
<groupId>com.freemud.application.service.sdk</groupId>
......
......@@ -84,6 +84,7 @@ public class ShoppingCartConvertAdapter {
public ShoppingCartGoodsDto.CartGoodsDetailDto convertCartGoods2DetailGoods(CartGoods cartGoods, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.ApportionGoods> apportionGoodsList, Map<String, String> duplicateGoodsMap) {
// 设置基础信息
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
cartGoodsDetailDto.setTas(0.02d);
cartGoodsDetailDto.setSpuId(cartGoods.getSpuId());
cartGoodsDetailDto.setSpuName(cartGoods.getSpuName());
cartGoodsDetailDto.setSkuId(StringUtils.isEmpty(cartGoods.getSkuId()) ? cartGoods.getSpuId() : cartGoods.getSkuId());
......@@ -345,6 +346,7 @@ public class ShoppingCartConvertAdapter {
cartGoods.setSpuId(spuId);
cartGoods.setSkuId(skuId);
cartGoods.setQty(qty);
cartGoods.setCouponCode(addShoppingCartGoodsRequestVo.getCouponCode());
Integer goodsType = StringUtils.isEmpty(skuId)||ObjectUtils.equals(spuId,skuId) ? GoodsTypeEnum.SPU_GOODS.getGoodsType() : GoodsTypeEnum.SKU_GOODS.getGoodsType();
if (spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
goodsType = GoodsTypeEnum.COUPON_GOODS.getGoodsType();
......
......@@ -2,9 +2,8 @@ package cn.freemud.controller;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.*;
import cn.freemud.enums.ResponseResult;
import cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl;
import cn.freemud.utils.ResponseUtil;
import cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo;
import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams;
import io.swagger.annotations.Api;
......@@ -43,7 +42,7 @@ public class MCoffeeShoppingCartController {
*/
@ApiAnnotation(logMessage = "addGoods")
@PostMapping(value = "/addGoods")
public BaseResponse addGoods(@Validated @LogParams @RequestBody AddShoppingCartGoodsRequestVo request) {
public BaseResponse addGoods(@Validated @LogParams @RequestBody MCoffeeAddGoodsRequestVo request) {
return shoppingCartMCoffeeService.addGoods(request);
}
......
......@@ -222,6 +222,11 @@ public class ShoppingCartGoodsDto {
* 统计分类名称
*/
private String classificationName;
/**
* 税率
*/
private Double tas;
/**
* 配料或属性
*/
......
......@@ -19,7 +19,8 @@ public enum GoodsTypeEnum {
COUPON_GOODS(2, "商品券"),
SET_MEAL_GOODS(3,"套餐商品"),
SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品");
SPU_GOODS(5, "spu商品"),
REDUCE_PRICE_GOODS(6,"加价购商品");
private Integer goodsType;
private String desc;
......
......@@ -171,10 +171,15 @@ public class CouponDiscountCalculation {
List<String> couponCodes = Lists.newArrayList();
memberCoupons.forEach(memberCoupon -> {
// 只筛选小于结束时间得券
if (System.currentTimeMillis() < DateUtil.convert2Date(memberCoupon.getEndTime(), DateUtil.FORMAT_YYYY_MM_DD_HHMMSS).getTime()) {
couponCodes.add(memberCoupon.getCouponCode());
}
// if (Objects.equals(memberCoupon.getCouponType(), CouponTypeEnum.TYPE_1.getCode())
// || Objects.equals(memberCoupon.getCouponType(), CouponTypeEnum.TYPE_3.getCode())) {
// 只筛选小于结束时间得券
if (System.currentTimeMillis() < DateUtil.convert2Date(memberCoupon.getEndTime(), DateUtil.FORMAT_YYYY_MM_DD_HHMMSS).getTime()) {
couponCodes.add(memberCoupon.getCouponCode());
}
// }
});
List<CouponState> couponStateList = buildAvailableCoupons(cartGoods, partnerId, storeId, couponCodes);
if (CollectionUtils.isEmpty(couponStateList)) {
return null;
......@@ -312,6 +317,10 @@ public class CouponDiscountCalculation {
int usableCouponNum = 0;
for (CouponState couponStateVo : couponStateList) {
// 过滤0得代金券
if (Objects.equals(couponStateVo.getType(), CouponTypeEnum.TYPE_0.getCode())) {
continue;
}
// 过滤0得代金券
if (Objects.equals(couponStateVo.getType(), CouponTypeEnum.TYPE_1.getCode())
&& (couponStateVo.getOriginalPrice() == null
|| couponStateVo.getOriginalPrice() == 0)) {
......
package cn.freemud.service.impl.mcoffee.entity;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ComboxGoodsRequestVo;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: MCoffeeAddGoodsRequestVo
* @Package cn.freemud.service.impl.mcoffee.entity
* @Description:
* @author: ping1.wu
* @date: 2020/8/8 21:04
* @Copyright: 2020 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class MCoffeeAddGoodsRequestVo {
@NotEmpty(message = "sessionId不能为空")
private String sessionId;
/**
* 商户Id
*/
@NotEmpty(message = "partnerId不能为空")
private String partnerId;
/**
* 微信appId
*/
@NotEmpty(message = "appId不能为空")
private String appId;
/**
* 门店Id
* 商城没有门店id,如果需要门店id必传在业务中进行校验
*/
//@NotEmpty(message = "shopId不能为空")
private String shopId;
/**
* 下单类型 CreateOrderType 外卖、到店、商城
*/
private Integer orderType;
/**
* 渠道类型 OrderChannelType
*/
private String channelType;
private String spuId;
private String skuId;
/**
* 商品额外的属性
*/
private List<CartGoods.CartGoodsExtra> extra;
private String version;
/**
* 1.6.0 版本增加 节点ID
*/
private String nodeId;
/**
* 1.6.0 版本增加 分类名
*/
private String categoryName;
/**
* 套餐固定商品
*/
private List<ComboxGoodsRequestVo> productComboList;
/**
* 套餐可选商品
*/
private List<ComboxGoodsRequestVo> productGroupList;
private String appType;
private String tableNumber;
/**
* 数量
*/
private Integer qty;
/**
* 业务类型: 0 : 自提 1:外卖 2:微商城
*/
private String menuType ;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
/**
* 操作类型 1= 添加商品券 2=加价购
*/
private Integer operationType;
/**
* 优惠券号
*/
private String couponCode;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment