Commit ef10dad2 by 查志伟

Merge branch '20211028-订单赠品支持选择属性-zhiwei.zha'

parents 4c1ea35c f6e2bd05
...@@ -38,6 +38,19 @@ public class RedisKeyConstant { ...@@ -38,6 +38,19 @@ public class RedisKeyConstant {
* 用户购物车总价在redis的key前缀 * 用户购物车总价在redis的key前缀
*/ */
public final static String SAAS_SHOPPINGCART_AMOUNT_PREFIX = "saas:user:info:cart:amount:goods:"; public final static String SAAS_SHOPPINGCART_AMOUNT_PREFIX = "saas:user:info:cart:amount:goods:";
/**
* 用户购物车赠品在redis中的缓存key
* {0}:商户号
* {1}:门店号
* {2}:用户的userId
*
* 缓存结构为hash
* hashKey为购物车行uid
* value为 CartGoods类型的json字符串
*/
public final static String SAAS_SHOPPING_CART_GIFT_KEY = "saas:user:info:cart:gift:{0}:{1}:{2}";
/** /**
* 商品的信息前缀 * 商品的信息前缀
*/ */
......
...@@ -12,17 +12,13 @@ ...@@ -12,17 +12,13 @@
*/ */
package cn.freemud.adapter; package cn.freemud.adapter;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.calculate.ApportionDetails; import cn.freemud.entities.dto.calculate.ApportionDetails;
import cn.freemud.entities.dto.calculate.ApportionGoods; import cn.freemud.entities.dto.calculate.ApportionGoods;
import cn.freemud.entities.dto.calculate.SendGoods; import cn.freemud.entities.dto.calculate.SendGoods;
import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto; import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto;
import cn.freemud.entities.dto.product.*; import cn.freemud.entities.dto.product.*;
import cn.freemud.entities.dto.product.info.GroupDetailType; import cn.freemud.entities.dto.product.info.*;
import cn.freemud.entities.dto.product.info.ProductComboType;
import cn.freemud.entities.dto.product.info.ProductGroupType;
import cn.freemud.entities.dto.product.info.SkuProductBean;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
...@@ -405,10 +401,10 @@ public class ShoppingCartConvertAdapter { ...@@ -405,10 +401,10 @@ public class ShoppingCartConvertAdapter {
cartGoodsRequestVo.setAppId(request.getAppId()); cartGoodsRequestVo.setAppId(request.getAppId());
cartGoodsRequestVo.setSpuId(request.getEncryptCode()); cartGoodsRequestVo.setSpuId(request.getEncryptCode());
// cartGoodsRequestVo.setSkuId(getProductsVo.getSkuId()); // cartGoodsRequestVo.setSkuId(getProductsVo.getSkuId());
List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.ProductAttributeGroupListBean> productAttributeGroupList = getProductsVo.getProductAttributeGroupList(); List<ProductAttributeGroupListBean> productAttributeGroupList = getProductsVo.getProductAttributeGroupList();
if (productAttributeGroupList != null && productAttributeGroupList.size() > 0) { if (productAttributeGroupList != null && productAttributeGroupList.size() > 0) {
List<CartGoods.CartGoodsExtra> cartGoodsExtraList = new ArrayList<>(); List<CartGoods.CartGoodsExtra> cartGoodsExtraList = new ArrayList<>();
for (GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.ProductAttributeGroupListBean productAttributeList : productAttributeGroupList) { for (ProductAttributeGroupListBean productAttributeList : productAttributeGroupList) {
CartGoods.CartGoodsExtra goodsExtra = new CartGoods.CartGoodsExtra(); CartGoods.CartGoodsExtra goodsExtra = new CartGoods.CartGoodsExtra();
goodsExtra.setAttributeId(productAttributeList.getAttributeValues().get(0).getAttributeId()); goodsExtra.setAttributeId(productAttributeList.getAttributeValues().get(0).getAttributeId());
goodsExtra.setAttributeName(productAttributeList.getAttributeValues().get(0).getAttributeValue()); goodsExtra.setAttributeName(productAttributeList.getAttributeValues().get(0).getAttributeValue());
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
package cn.freemud.adapter; package cn.freemud.adapter;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.CProductType; import cn.freemud.enums.CProductType;
import cn.freemud.enums.ProductType; import cn.freemud.enums.ProductType;
...@@ -223,63 +222,6 @@ public class StoreItemAdapter { ...@@ -223,63 +222,6 @@ public class StoreItemAdapter {
} }
public ProductVo convert2ProductVo(GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBean) {
ProductVo productVo = BeanUtil.convertBean(productBean, ProductVo::new);
productVo.setStatusDesc(Optional.ofNullable(StoreItemStatus.getByCode(productVo.getStatus()))
.map(StoreItemStatus::getDesc).orElse(""));
List<ProductGroupDto> productGroups = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(productBean.getProductAttributeGroupList())) {
productBean.getProductAttributeGroupList().sort(Comparator.comparing(ProductBean.ProductAttributeGroupListBean::getAttributeType));
for (ProductBean.ProductAttributeGroupListBean attribute : productBean.getProductAttributeGroupList()) {
ProductGroupDto productGroupDto = new ProductGroupDto();
productGroupDto.setName(attribute.getAttributeName());
List<ProductGroupDto.GroupDetailBean> groupDetailBeans = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(attribute.getAttributeValues())) {
for (ProductBean.ProductAttributeGroupListBean.AttributeValueBean attributeValue : attribute.getAttributeValues()) {
/**
* 过滤下架的规格和售罄的规格
*/
if (StoreItemStatus.PUT_ON_SALE.getCode().equals(attributeValue.getStatus())) {
ProductGroupDto.GroupDetailBean groupDetailBean = new ProductGroupDto.GroupDetailBean();
groupDetailBean.setGroupId(attribute.getAttributeType().toString());
groupDetailBean.setProductId(attributeValue.getAttributeId());
groupDetailBean.setProductName(attributeValue.getAttributeValue());
groupDetailBean.setSequence(attributeValue.getSequence());
groupDetailBean.setProductFinalPrice(attributeValue.getPrice());
groupDetailBean.setProductPrice(attributeValue.getPrice());
groupDetailBean.setStatus(attributeValue.getStatus());
groupDetailBean.setStatusDesc(Optional.ofNullable(StoreItemStatus.getByCode(attributeValue.getStatus()))
.map(StoreItemStatus::getDesc).orElse(""));
groupDetailBeans.add(groupDetailBean);
}
}
}
productGroupDto.setGroupDetail(groupDetailBeans);
//如果规格为空则不返回该规格
if (CollectionUtils.isNotEmpty(groupDetailBeans)) {
productGroups.add(productGroupDto);
}
}
//设置规格类型
productVo.setType(8);
}
if (CollectionUtils.isNotEmpty(productBean.getProductPictureList())) {
productVo.setPicture(productBean.getProductPictureList().get(0).getUrl());
}
//商品标签信息
List<ProductVo.ProductLabel> productLabels = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(productBean.getLabelNames())) {
productBean.getLabelNames().forEach(label -> {
ProductVo.ProductLabel productLabel = new ProductVo.ProductLabel();
productLabel.setLabelName(label.getName());
productLabels.add(productLabel);
});
}
productVo.setProductLabels(productLabels);
productVo.setProductGroups(productGroups);
return productVo;
}
/** /**
* 处理多余规格 * 处理多余规格
* 多规格商品的下架或者不是限时特购商品去除不需要的规格值 * 多规格商品的下架或者不是限时特购商品去除不需要的规格值
......
...@@ -22,6 +22,7 @@ import cn.freemud.entities.vo.coupon.CouponAvailableRequestVo; ...@@ -22,6 +22,7 @@ import cn.freemud.entities.vo.coupon.CouponAvailableRequestVo;
import cn.freemud.enums.CouponTypeEnum; import cn.freemud.enums.CouponTypeEnum;
import cn.freemud.enums.OrderChannelType; import cn.freemud.enums.OrderChannelType;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.service.CartGiftService;
import cn.freemud.service.OpenStoreIappWxappConfigService; import cn.freemud.service.OpenStoreIappWxappConfigService;
import cn.freemud.service.ShoppingCartNewService; import cn.freemud.service.ShoppingCartNewService;
import cn.freemud.service.impl.ShoppingCartMallServiceImpl; import cn.freemud.service.impl.ShoppingCartMallServiceImpl;
...@@ -29,7 +30,6 @@ import cn.freemud.service.impl.ShoppingCartMealServiceImpl; ...@@ -29,7 +30,6 @@ import cn.freemud.service.impl.ShoppingCartMealServiceImpl;
import cn.freemud.service.impl.ShoppingCartNewServiceImpl; import cn.freemud.service.impl.ShoppingCartNewServiceImpl;
import cn.freemud.service.impl.ShoppingCartToolsServiceImpl; import cn.freemud.service.impl.ShoppingCartToolsServiceImpl;
import cn.freemud.utils.ResponseUtil; import cn.freemud.utils.ResponseUtil;
import com.alibaba.fastjson.JSON;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo; import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.enums.IappIdType; import com.freemud.api.assortment.datamanager.enums.IappIdType;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager; import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
...@@ -38,8 +38,8 @@ import com.freemud.application.sdk.api.log.ApiAnnotation; ...@@ -38,8 +38,8 @@ import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams; import com.freemud.application.sdk.api.log.LogParams;
import com.freemud.application.sdk.api.log.LogThreadLocal; import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl; import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import com.freemud.sdk.api.assortment.shoppingcart.util.ShoppingSdkLogUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -70,6 +70,8 @@ public class ShoppingCartController { ...@@ -70,6 +70,8 @@ public class ShoppingCartController {
@Autowired @Autowired
private ShoppingCartDemoController shoppingCartDemoController; private ShoppingCartDemoController shoppingCartDemoController;
@Autowired
private CartGiftService cartGiftService;
@Resource @Resource
private MapperFacade mapperFacade; private MapperFacade mapperFacade;
...@@ -115,6 +117,14 @@ public class ShoppingCartController { ...@@ -115,6 +117,14 @@ public class ShoppingCartController {
} }
} }
@IsConvertEN
@PostMapping(value = "/updateGiftAttr")
@ApiAnnotation(logMessage = "updateGiftAttr")
@ApiOperation("修改购物车中赠品的属性")
public BaseResponse<CartGoods> updateGiftAttr(@Validated @LogParams @RequestBody UpdateGiftAttrRequestVo request) {
return ResponseUtil.success(cartGiftService.updateGiftAttr(request));
}
/** /**
* 查询购物车信息 * 查询购物车信息
*/ */
......
...@@ -3,9 +3,9 @@ package cn.freemud.demo.adapter.manager; ...@@ -3,9 +3,9 @@ package cn.freemud.demo.adapter.manager;
import cn.freemud.demo.entities.bo.goods.ProductBO; import cn.freemud.demo.entities.bo.goods.ProductBO;
import cn.freemud.demo.entities.bo.goods.ValiadShopProductBO; import cn.freemud.demo.entities.bo.goods.ValiadShopProductBO;
import cn.freemud.demo.entities.bo.product.ProductStockBO; import cn.freemud.demo.entities.bo.product.ProductStockBO;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.dto.GetProductStockResponseDto; import cn.freemud.entities.dto.GetProductStockResponseDto;
import cn.freemud.entities.dto.product.ValiadShopProductResponse; import cn.freemud.entities.dto.product.ValiadShopProductResponse;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.utils.BeanUtil; import cn.freemud.utils.BeanUtil;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -19,7 +19,7 @@ public class ProductDTO2BOAdapter { ...@@ -19,7 +19,7 @@ public class ProductDTO2BOAdapter {
@Resource @Resource
private MapperFacade mapperFacade; private MapperFacade mapperFacade;
public ProductBO convert2ProductBO(GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBeanDTO) { public ProductBO convert2ProductBO(ProductBean productBeanDTO) {
ProductBO productBO = BeanUtil.convertBean(productBeanDTO, ProductBO::new); ProductBO productBO = BeanUtil.convertBean(productBeanDTO, ProductBO::new);
productBO.setGoodsId(productBeanDTO.getPid()); productBO.setGoodsId(productBeanDTO.getPid());
......
package cn.freemud.demo.entities.bo.goods; package cn.freemud.demo.entities.bo.goods;
import cn.freemud.entities.dto.GetMenuResponseDto; import cn.freemud.entities.dto.product.info.ProductAttributeGroupListBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import lombok.Data; import lombok.Data;
...@@ -38,7 +38,7 @@ public class GetProductBySkuIdResponseBO { ...@@ -38,7 +38,7 @@ public class GetProductBySkuIdResponseBO {
/** /**
* 属性 * 属性
*/ */
private List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.ProductAttributeGroupListBean> productAttributeGroupList; private List<ProductAttributeGroupListBean> productAttributeGroupList;
/** /**
* 分类id * 分类id
*/ */
......
...@@ -11,6 +11,7 @@ import cn.freemud.demo.entities.bo.product.ProductStockBO; ...@@ -11,6 +11,7 @@ import cn.freemud.demo.entities.bo.product.ProductStockBO;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.product.ValiadShopProductResponse; import cn.freemud.entities.dto.product.ValiadShopProductResponse;
import cn.freemud.entities.dto.product.ValidateShopProductRequest; import cn.freemud.entities.dto.product.ValidateShopProductRequest;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.ItemService; import cn.freemud.service.ItemService;
...@@ -61,11 +62,11 @@ public class KgdProductServiceImpl implements ProductService { ...@@ -61,11 +62,11 @@ public class KgdProductServiceImpl implements ProductService {
public List<ProductBO> getProductInfo(GetProductBO getProductBO) { public List<ProductBO> getProductInfo(GetProductBO getProductBO) {
// 获取添加商品的详细信息 // 获取添加商品的详细信息
List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(getProductBO.getPartnerId(), List<ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(getProductBO.getPartnerId(),
getProductBO.getStoreId(), getProductBO.getGoodsId(), getProductBO.getMenuType(), shoppingCartBaseService); getProductBO.getStoreId(), getProductBO.getGoodsId(), getProductBO.getMenuType(), shoppingCartBaseService);
List<ProductBO> productList = new ArrayList<>(); List<ProductBO> productList = new ArrayList<>();
for (GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean dto : productBeanListSpuClass){ for (ProductBean dto : productBeanListSpuClass){
ProductBO platformProductBO = productDTO2BOAdapter.convert2ProductBO(dto); ProductBO platformProductBO = productDTO2BOAdapter.convert2ProductBO(dto);
productList.add(platformProductBO); productList.add(platformProductBO);
} }
......
//package cn.freemud.entities.dto;
//
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
//import java.util.List;
//import java.util.Objects;
//
//@Data
//public class ActivityCalculationDiscountRequestDto {
// /**
// * 区域
// */
// private String area;
// /**
// * 可用渠道
// */
// private String channel;
// /**
// * 渠道
// */
// private String productChannel;
// /**
// * 绑定的小程序id
// */
// private String appId;
// /**
// * i应用传isaas,快中台传fast
// */
// private String application = "isaas";
// /**
// * 是否展示活动列表 0:默认,不展示 1:展示
// */
// private Integer isShowActivities;
// /**
// * 是否显示商品的活动信息 0:默认,不展示 1:展示
// */
// private Integer isShowGoodsActivity;
// /**
// * 商户
// */
// private String partnerCode;
// /**
// * 门店
// */
// private String storeId;
//
// /**
// * 门店的组织机构树
// */
// private List<String> orgIds;
//
// /**
// * 用户id(有优惠券时,该字段必传)
// */
// private String userId;
// /**
// * 版本号
// */
// private Integer ver;
// /**
// * 优惠券集合
// */
// private List<CalculationDiscountCoupon> coupons;
// /**
// * 商品集合
// */
// private List<CalculationDiscountGoods> goods;
//
// private Long distributionFee;
// /**
// * 购买月卡费用(分)
// */
// private Long payCardFee;
// /**
// * 是否是会员
// */
// private Boolean isMember;
//
// @Data
// public static class CalculationDiscountCoupon {
// /**
// * 优惠券码
// */
// private String code;
// /**
// * 活动号
// */
// private String activityCode;
// /**
// * 购物车商品行uid(种子券商品才传)
// */
// private String cartGoodsUid;
// /**
// * 优惠券类型
// */
// private Integer couponType;
// }
//
// @Data
// public static class CalculationDiscountGoods {
// /**
// * 键位编号(麦咖啡)
// */
// private String goodsCode;
// /**
// * 商品核销券号
// */
// private String couponCode;
// /**
// * 商品ID
// */
// private String goodsId;
// /**
// * 购物车行uid
// */
// private String cartGoodsUid;
// /**
// * 加车时间
// */
// private Long addCartTime;
// /**
// * 商品品类
// */
// private String category;
// /**
// * 商品数量
// */
// private Integer goodsQuantity;
// /**
// * 原价(分)
// */
// private Long originalPrice;
// /**
// * 折扣比例
// * 例如8折为80
// */
// private Integer memberDiscount;
// /**
// * 加料
// */
// private List<Material> smallMaterial;
// private String spuId;
//
// @Override
// public boolean equals(Object o) {
// if (this == o)
// return true;
// if (o == null || getClass() != o.getClass())
// return false;
// CalculationDiscountGoods that = (CalculationDiscountGoods) o;
// return Objects.equals(goodsId, that.goodsId) &&
// Objects.equals(category, that.category) &&
// Objects.equals(cartGoodsUid, that.cartGoodsUid) &&
// Objects.equals(originalPrice, that.originalPrice);
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(super.hashCode(), goodsId, category, originalPrice);
// }
//
// @Data
// @NoArgsConstructor
// static public class Material {
// /**
// * 加料商品ID
// */
// private String goodsId;
// /**
// * 加料数量
// */
// private Integer goodsQuantity;
// /**
// * 加料原价
// */
// private Long originalPrice;
// /**
// * 加料现价
// */
// private Integer nowPrice;
// /**
// * 1 :小料、2:可选搭配
// */
// private int type;
// }
// }
//
//}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
*/ */
package cn.freemud.entities.dto; package cn.freemud.entities.dto;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean; import cn.freemud.entities.dto.product.info.ProductBean;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
...@@ -38,6 +38,11 @@ public class GetProductInfoDto { ...@@ -38,6 +38,11 @@ public class GetProductInfoDto {
private Integer productInfoType; private Integer productInfoType;
/** /**
* 查询商品的属性(不管spu还是sku,都返回其spu对于的属性信息)
*/
private Boolean autoFillSkuAttr = false;
/**
* 门店商品渠道,不传则默认为default,仅对开放了门店商品渠道信息商户使用,请慎用该参数 * 门店商品渠道,不传则默认为default,仅对开放了门店商品渠道信息商户使用,请慎用该参数
*/ */
private String channel; private String channel;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
*/ */
package cn.freemud.entities.dto; package cn.freemud.entities.dto;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean; import cn.freemud.entities.dto.product.info.ProductBean;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -24,7 +24,6 @@ public class ProductInfosDto { ...@@ -24,7 +24,6 @@ public class ProductInfosDto {
private DataBean data; private DataBean data;
private Integer errcode; private Integer errcode;
private Integer code;
private String errmsg; private String errmsg;
@NoArgsConstructor @NoArgsConstructor
......
...@@ -7,8 +7,32 @@ import java.util.List; ...@@ -7,8 +7,32 @@ import java.util.List;
@Data @Data
public class ProductAttributeGroupListBean { public class ProductAttributeGroupListBean {
/**
* 名称
*/
private String attributeName; private String attributeName;
/**
* 别名
*/
private String foreignAttributeName;
/**
* 属性类型
*/
private Integer attributeType; private Integer attributeType;
/**
* 三方编号
*/
private String customerCode;
private Integer maxNumber;
private Integer minNumber;
private Integer must;
private String options;
/**
* 排序,越小越靠前
*/
private Integer sequence;
private List<AttributeValueBean> attributeValues; private List<AttributeValueBean> attributeValues;
} }
package cn.freemud.entities.dto.product.info;
import cn.freemud.entities.dto.BindingCouponTypeDto;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
public class ProductBean {
private String barcode;
private String brandId;
private String brandName;
private String category;
private String categoryName;
private String companyId;
/**
* 加料最大限购
*/
private Integer maxNum;
/**
* 加料最小限购
*/
private Integer minNum;
private String customerCode;
/**
* 最终价格 单位分
*/
private Long finalPrice;
/**
* 是否是SKU商品 1是0否
*/
private Integer isSkuProduct;
private String name;
private String foreignName;
/**
* 原始价格 单位分
*/
private Long originalPrice;
/**
* 包装费 单位分
*/
private Long packPrice;
private String picture;
/**
* 商品id, 单规格为spuId,多规格为skuId
*/
private String pid;
/**
* 商品父id, 多规格商品,该字段为多规格的spuId
*/
private String specProductId;
private Integer pknumber;
private String productionLocation;
private String remark;
private Integer saleCount;
private String sellTimeName;
private Integer sequence;
private String sourceChannel;
private String specification;
private Integer status;
private Integer stock;
private Integer stockLimit;
/**
* type=10 多规格 type=1 单规格
*/
private int type;
/**
* 是否是称重商品 1、表示为称重
*/
private Integer weightType;
/**
* 重量,最多四位小数,单位kg
*/
private Double weight;
/**
* 税率代码
*/
private String taxId;
/**
* 税率
*/
private Double tax;
private String unit;
private int updateStatus;
private boolean valid;
private int version;
private List<ProductLabelNameListBean> labelNames;
private List<ProductAttributeGroupListBean> productAttributeGroupList;
private List<?> productGroupList;
private List<ProductPictureListBean> productPictureList;
private List<?> productSpecification;
private List<?> sellTimeList;
private List<?> specificationList;
//SKU
private List<SkuProductBean> skuList;
//规格信息
private List<SpecificationGroupBean> specificationGroupList;
//Sku 规格 如果 当前是sku 则有值
private List<SkuSpecValue> skuSpecValues;
/**
* 虚拟商品 绑定的券信息
*/
private List<BindingCouponTypeDto> productBindingCouponTypes;
@NoArgsConstructor
@Data
public static class SpecificationGroupBean {
private String partnerId;
private Integer sequence;
private String specId;
private String specName;
private String foreignSpecName;
private List<SpecValueVo> specValueVos;
@NoArgsConstructor
@Data
public static class SpecValueVo {
private Integer sequence;
private String specId;
private String specValue;
private String foreignSpecValue;
private String specValueId;
}
}
@NoArgsConstructor
@Data
public static class ProductLabelNameListBean {
private String id;
private String name;
private String foreignName;
private String partnerId;
List<?> productList;
private String storeId;
private String type;
}
}
\ No newline at end of file
package cn.freemud.entities.vo; package cn.freemud.entities.vo;
import cn.freemud.entities.dto.BindingCouponTypeDto; import cn.freemud.entities.dto.BindingCouponTypeDto;
import cn.freemud.entities.dto.GetMenuResponseDto; import cn.freemud.entities.dto.product.info.ProductAttributeGroupListBean;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
...@@ -37,7 +37,7 @@ public class GetProductsVo { ...@@ -37,7 +37,7 @@ public class GetProductsVo {
/** /**
* 属性 * 属性
*/ */
private List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.ProductAttributeGroupListBean> productAttributeGroupList; private List<ProductAttributeGroupListBean> productAttributeGroupList;
/** /**
* 分类id * 分类id
*/ */
......
package cn.freemud.entities.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* @author Clover.z
* @Date 2021/11/1
* @Desc
*/
@Data
public class UpdateGiftAttrRequestVo {
/**
* 商户Id
*/
@ApiModelProperty("商户Id")
@NotBlank(message = "partnerId不能为空")
private String partnerId;
/**
* 门店号
*/
@ApiModelProperty("门店号")
@NotBlank(message = "shopId不能为空")
private String shopId;
/**
* 用户登陆session
*/
@ApiModelProperty("用户登陆session")
@NotBlank(message = "请先登陆")
private String sessionId;
/**
* 要更新的购物车赠品行id
*/
@ApiModelProperty("要更新的购物车赠品行id")
@NotBlank(message = "购物车行id不能为空")
private String uid;
/**
* 赠品选择的属性信息
*/
@ApiModelProperty("赠品选择的属性信息")
@NotEmpty(message = "请选择属性")
@Valid
private List<ExtraAttr> extra;
@Data
public static class ExtraAttr {
@ApiModelProperty("属性id")
@NotBlank
private String attributeId;
@ApiModelProperty("属性名称")
@NotBlank
private String attributeName;
}
}
package cn.freemud.service;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.UpdateGiftAttrRequestVo;
/**
* @author Clover.z
* @Date 2021/11/1
* @Desc 购物车赠品信息Service
*/
public interface CartGiftService {
/**
* 更新赠品的购物车行中属性信息
* @param requestVo
* @return
*/
CartGoods updateGiftAttr(UpdateGiftAttrRequestVo requestVo);
}
package cn.freemud.service; package cn.freemud.service;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.demo.entities.bo.goods.GetProductBySkuIdResponseBO; import cn.freemud.demo.entities.bo.goods.GetProductBySkuIdResponseBO;
import cn.freemud.entities.dto.GetMenuResponseDto; import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.GetProductsVo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -20,7 +19,7 @@ public interface ItemService { ...@@ -20,7 +19,7 @@ public interface ItemService {
boolean hasAttributeAll(List<String> attributeIds, GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBean); boolean hasAttributeAll(List<String> attributeIds, ProductBean productBean);
/** /**
* 通过sku或单品组装MAP商品详情信息 * 通过sku或单品组装MAP商品详情信息
......
...@@ -15,9 +15,9 @@ package cn.freemud.service.active; ...@@ -15,9 +15,9 @@ package cn.freemud.service.active;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto; import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult; import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import java.util.List; import java.util.List;
...@@ -35,9 +35,11 @@ public interface ActiveService { ...@@ -35,9 +35,11 @@ public interface ActiveService {
*/ */
void gifAddCart(List<CartGoods> oldcartGoodsLists, void gifAddCart(List<CartGoods> oldcartGoodsLists,
List<CartGoods> addcartGoodsList, List<CartGoods> addcartGoodsList,
List<ProductBeanDTO> products , List<ProductBean> products ,
ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,
CalculationDiscountResult discountResult, CalculationDiscountResult discountResult,
String partnerId, String partnerId,
String storeId,
String userId,
Integer flag); Integer flag);
} }
...@@ -13,13 +13,16 @@ ...@@ -13,13 +13,16 @@
package cn.freemud.service.active.impl; package cn.freemud.service.active.impl;
import cn.freemud.entities.dto.calculate.*; import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.calculate.Goods;
import cn.freemud.entities.dto.calculate.GoodsDiscount;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.CalculationGoodsType; import cn.freemud.enums.CalculationGoodsType;
import cn.freemud.service.active.ActiveService; import cn.freemud.service.active.ActiveService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
...@@ -71,10 +74,12 @@ public class CocoActiveServiceImpl implements ActiveService { ...@@ -71,10 +74,12 @@ public class CocoActiveServiceImpl implements ActiveService {
@Override @Override
public void gifAddCart(List<CartGoods> oldcartGoodsLists, public void gifAddCart(List<CartGoods> oldcartGoodsLists,
List<CartGoods> addcartGoodsList, List<CartGoods> addcartGoodsList,
List<ProductBeanDTO> products , List<ProductBean> products ,
ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,
CalculationDiscountResult discountResult, CalculationDiscountResult discountResult,
String partnerId, String partnerId,
String storeId,
String userId,
Integer flag) { Integer flag) {
// 点餐页赠品分行显示,赠品显示小料 // 点餐页赠品分行显示,赠品显示小料
......
...@@ -13,25 +13,37 @@ ...@@ -13,25 +13,37 @@
package cn.freemud.service.active.impl; package cn.freemud.service.active.impl;
import cn.freemud.entities.dto.calculate.*; import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.calculate.Goods;
import cn.freemud.entities.dto.calculate.GoodsDiscount;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
import cn.freemud.enums.CalculationGoodsType; import cn.freemud.enums.CalculationGoodsType;
import cn.freemud.service.active.ActiveService; import cn.freemud.service.active.ActiveService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import cn.freemud.service.cache.GiftCacheManager;
import cn.freemud.service.impl.BuyAndGiftsPromotionService;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service("platformActiveService") @Service("platformActiveService")
public class PlatformActiveServiceImpl implements ActiveService { public class PlatformActiveServiceImpl implements ActiveService {
@Autowired
private BuyAndGiftsPromotionService buyAndGiftsPromotionService;
@Autowired
private GiftCacheManager giftCacheManager;
/** /**
* 用户选择的商品和数量都要传给促销 * 用户选择的商品和数量都要传给促销
* @param calculationSharingDiscountRequestDto * @param calculationSharingDiscountRequestDto
...@@ -66,27 +78,29 @@ public class PlatformActiveServiceImpl implements ActiveService { ...@@ -66,27 +78,29 @@ public class PlatformActiveServiceImpl implements ActiveService {
@Override @Override
public void gifAddCart(List<CartGoods> oldcartGoodsLists, public void gifAddCart(List<CartGoods> oldcartGoodsLists,
List<CartGoods> addcartGoodsList, List<ProductBeanDTO> products , List<CartGoods> addcartGoodsList,
List<ProductBean> products ,
ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,
CalculationDiscountResult discountResult, CalculationDiscountResult discountResult,
String partnerId, String partnerId,
String storeId,
String userId,
Integer flag) { Integer flag) {
Map<String, Goods> discountForGift = this.getDiscountForGift(discountResult); Map<String, Goods> discountForGift = this.getDiscountForGift(discountResult);
List<CartGoods> list = new ArrayList<>();
for (ProductBean product : products) {
for (ProductBeanDTO product : products) { Goods goods = discountForGift.get(product.getPid());
String k = product.getPid();
Goods goods = discountForGift.get(k);
GoodsDiscount discount = goods.getDiscounts() GoodsDiscount discount = goods.getDiscounts()
.stream() .stream()
.filter(g -> ActivityTypeEnum.TYPE_63.getCode().equals(g.getType()) ||ActivityTypeEnum.TYPE_62.getCode().equals(g.getType()) || ActivityTypeEnum.TYPE_61.getCode().equals(g.getType()) || ActivityTypeEnum.TYPE_230.getCode().equals(g.getType())) .filter(g -> ActivityTypeEnum.TYPE_63.getCode().equals(g.getType()) ||ActivityTypeEnum.TYPE_62.getCode().equals(g.getType()) || ActivityTypeEnum.TYPE_61.getCode().equals(g.getType()) || ActivityTypeEnum.TYPE_230.getCode().equals(g.getType()))
.findFirst() .findFirst()
.get(); .get();
CartGoods cartGood = new CartGoods(); CartGoods cartGood = new CartGoods();
cartGood.setGoodsId(goods.getGoodsId()); cartGood.setGoodsId(goods.getGoodsId());
cartGood.setGoodsType(1); cartGood.setGoodsType(1);
cartGood.setSpuId(goods.getGoodsId()); cartGood.setSpuId(Objects.equals(product.getIsSkuProduct(), 1) ? product.getSpecProductId() : goods.getGoodsId());
cartGood.setSkuId(goods.getGoodsId()); cartGood.setSkuId(goods.getGoodsId());
cartGood.setOriginalPrice(product.getFinalPrice()); cartGood.setOriginalPrice(product.getFinalPrice());
cartGood.setPackPrice(product.getPackPrice()); cartGood.setPackPrice(product.getPackPrice());
...@@ -98,6 +112,7 @@ public class PlatformActiveServiceImpl implements ActiveService { ...@@ -98,6 +112,7 @@ public class PlatformActiveServiceImpl implements ActiveService {
cartGood.setPic(product.getPicture()); cartGood.setPic(product.getPicture());
cartGood.setSkuName(product.getName()); cartGood.setSkuName(product.getName());
cartGood.setActivityType(discount.getType()); cartGood.setActivityType(discount.getType());
cartGood.setActivityCode(discount.getActivityCode());
cartGood.setStockLimit(ObjectUtils.equals(1, product.getStockLimit())); cartGood.setStockLimit(ObjectUtils.equals(1, product.getStockLimit()));
cartGood.setCustomerCode(product.getCustomerCode()); cartGood.setCustomerCode(product.getCustomerCode());
cartGood.setUnit(product.getUnit()); cartGood.setUnit(product.getUnit());
...@@ -107,8 +122,10 @@ public class PlatformActiveServiceImpl implements ActiveService { ...@@ -107,8 +122,10 @@ public class PlatformActiveServiceImpl implements ActiveService {
cartGood.setClassificationName(product.getCategoryName()); cartGood.setClassificationName(product.getCategoryName());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额 // nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood.setNodeId(discount.getActivityCode()); cartGood.setNodeId(discount.getActivityCode());
addcartGoodsList.add(cartGood); list.addAll(buyAndGiftsPromotionService.setGiftExtra(cartGood, product, addcartGoodsList));
} }
// 因为有涉及到用户选择的属性,存入redis
addcartGoodsList.addAll(giftCacheManager.resetGiftCache(list, null, partnerId, storeId, userId));
} }
public Map<String, Goods> getDiscountForGift(CalculationDiscountResult discountResult) { public Map<String, Goods> getDiscountForGift(CalculationDiscountResult discountResult) {
......
package cn.freemud.service.cache;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import com.alibaba.fastjson.JSON;
import com.freemud.sdk.api.assortment.shoppingcart.constant.RedisKeyConstant;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author Clover.z
* @Date 2021/10/28
* @Desc 购物车对应的赠品缓存
*/
@Component
@RequiredArgsConstructor
public class GiftCacheManager {
private final RedisTemplate<String, String> redisTemplate;
/**
* 购物车中赠品缓存有效期,默认3天
*/
@Value("${saas.shoppingCart.giftCache.expireDay:3}")
private Integer expireDay;
/**
* 重置购物车赠品缓存
* @param giftList 赠品行信息
* @param activityCode 赠品对应的活动号(不传则覆盖缓存所有数据,传则只会重置指定活动的赠品数据)
* @param partnerId 商户号
* @param storeCode 门店号
* @param userId 用户userId
* @return 返回更新后的赠品信息
*/
public List<CartGoods> resetGiftCache(@NotNull List<CartGoods> giftList,
String activityCode,
@NotBlank String partnerId,
@NotBlank String storeCode,
@NotBlank String userId) {
String redisKey = MessageFormat.format(RedisKeyConstant.SAAS_SHOPPING_CART_GIFT_KEY, partnerId, storeCode, userId);
BoundHashOperations<String, String, String> operations = redisTemplate.boundHashOps(redisKey);
List<String> values = operations.values();
// 将缓存转为对象
List<CartGoods> oldGiftList = CollectionUtils.isEmpty(values)
? new ArrayList<>()
: values.stream().map(v -> JSON.parseObject(v, CartGoods.class)).collect(Collectors.toList());
// 存放最新的赠品缓存信息
Map<String, String> newValues = new HashMap<>();
for (CartGoods gift : giftList) {
// 匹配赠品的商品属性,将原有赠品的属性更新到新计算出的赠品中
Iterator<CartGoods> it = oldGiftList.iterator();
while (it.hasNext()) {
CartGoods old = it.next();
boolean isSameType = StringUtils.isBlank(activityCode) || activityCode.equals(old.getActivityCode());
if (! old.getGoodsId().equals(gift.getGoodsId()) || ! isSameType) continue;
// 赠品匹配上了,copy赠品属性
gift.setExtra(old.getExtra());
gift.setSubName(old.getSubName());
gift.setCartGoodsUid(old.getCartGoodsUid());
// 如果赠品为多个同一商品,并且每个商品都有不同的属性,所以这里要移除掉已经匹配上的商品
it.remove();
break;
}
newValues.put(gift.getCartGoodsUid(), JSON.toJSONString(gift));
}
// oldGiftList中剩下的, 属于其他活动的数据,不变,需要原样放入缓存中
if (StringUtils.isNotBlank(activityCode)) {
oldGiftList = oldGiftList.stream().filter(old -> !activityCode.equals(old.getActivityCode())).collect(Collectors.toList());
for (CartGoods old : oldGiftList) {
newValues.put(old.getCartGoodsUid(), JSON.toJSONString(old));
}
}
if (CollectionUtils.isNotEmpty(values)) {
//旧值不为空,清掉
redisTemplate.delete(redisKey);
}
if (!newValues.isEmpty()) {
operations.putAll(newValues);
operations.expire(expireDay, TimeUnit.DAYS);
}
return giftList;
}
/**
* 查询赠品的购物车信息
* @param partnerId 商户号
* @param storeCode 门店号
* @param userId 用户id
* @param uid 购物车行id
* @return
*/
public CartGoods queryGiftGoods(@NotBlank String partnerId,
@NotBlank String storeCode,
@NotBlank String userId,
@NotBlank String uid) {
String redisKey = MessageFormat.format(RedisKeyConstant.SAAS_SHOPPING_CART_GIFT_KEY, partnerId, storeCode, userId);
BoundHashOperations<String, String, String> operations = redisTemplate.boundHashOps(redisKey);
String value = operations.get(uid);
if (StringUtils.isBlank(value)) throw new ServiceException(ResponseResult.SHOPPING_CART_GETINFO_INVAILD);
return JSON.parseObject(value, CartGoods.class);
}
/**
* 查询赠品的购物车信息
* @param partnerId 商户号
* @param storeCode 门店号
* @param userId 用户id
* @param goods 赠品信息
* @return
*/
public void updateGiftGoods(@NotBlank String partnerId,
@NotBlank String storeCode,
@NotBlank String userId,
@NotNull CartGoods goods) {
String redisKey = MessageFormat.format(RedisKeyConstant.SAAS_SHOPPING_CART_GIFT_KEY, partnerId, storeCode, userId);
BoundHashOperations<String, String, String> operations = redisTemplate.boundHashOps(redisKey);
operations.put(goods.getCartGoodsUid(), JSON.toJSONString(goods));
}
/**
* 清空赠品的购物车信息
* @param partnerId 商户号
* @param storeCode 门店号
* @param userId 用户id
* @return
*/
public void clearGiftCache(@NotBlank String partnerId,
@NotBlank String storeCode,
@NotBlank String userId) {
String redisKey = MessageFormat.format(RedisKeyConstant.SAAS_SHOPPING_CART_GIFT_KEY, partnerId, storeCode, userId);
redisTemplate.delete(redisKey);
}
}
package cn.freemud.service.customer;
import cn.freemud.entities.vo.CustomerInfoVo;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import com.freemud.api.assortment.datamanager.entity.vo.AssortmentCustomerInfoVo;
import com.freemud.api.assortment.datamanager.manager.customer.AssortmentCustomerInfoManager;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
/**
* @author Clover.z
* @Date 2021/11/1
* @Desc 会员信息通用能力下沉
*/
@Component
@RequiredArgsConstructor
public class CustomerInfoManager {
private final AssortmentCustomerInfoManager assortmentCustomerInfoManager;
/**
* 获取登陆用户信息
* @param sessionId
* @return
*/
public CustomerInfoVo getCustomerInfoVo(String sessionId) {
AssortmentCustomerInfoVo info = assortmentCustomerInfoManager.getCustomerInfoByObject(sessionId);
if (info == null) throw new ServiceException(ResponseResult.NOT_LOGIN);
CustomerInfoVo customer = new CustomerInfoVo();
BeanUtils.copyProperties(info, customer);
return customer;
}
}
...@@ -2,13 +2,14 @@ package cn.freemud.service.impl; ...@@ -2,13 +2,14 @@ package cn.freemud.service.impl;
import cn.freemud.adapter.ShoppingCartConvertAdapter; import cn.freemud.adapter.ShoppingCartConvertAdapter;
import cn.freemud.constant.ShoppingCartConstant; import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.dto.UserLoginInfoDto; import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult; import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.calculate.SendActivity; import cn.freemud.entities.dto.calculate.SendActivity;
import cn.freemud.entities.dto.calculate.SendGoods; import cn.freemud.entities.dto.calculate.SendGoods;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.dto.product.info.SkuProductBean;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityTypeEnum; import cn.freemud.enums.ActivityTypeEnum;
...@@ -19,7 +20,6 @@ import cn.freemud.service.IPromotionService; ...@@ -19,7 +20,6 @@ import cn.freemud.service.IPromotionService;
import cn.freemud.service.ItemService; import cn.freemud.service.ItemService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum; import com.freemud.application.sdk.api.ordercenter.enums.ProductTypeEnum;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum; import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl; import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -107,17 +107,17 @@ public class AdditionalPromotionService implements IPromotionService { ...@@ -107,17 +107,17 @@ public class AdditionalPromotionService implements IPromotionService {
// List<ProductBeanDTO> productBeanList = assortmentSdkService.getProductsInfoSdk(shoppingCartInfoRequestVo.getPartnerId() // List<ProductBeanDTO> productBeanList = assortmentSdkService.getProductsInfoSdk(shoppingCartInfoRequestVo.getPartnerId()
// , shoppingCartInfoRequestVo.getShopId(), goodsIds,shoppingCartInfoRequestVo.getMenuType(), shoppingCartBaseService); // , shoppingCartInfoRequestVo.getShopId(), goodsIds,shoppingCartInfoRequestVo.getMenuType(), shoppingCartBaseService);
// fisherman 剔除上面sdk的调用 // fisherman 剔除上面sdk的调用
List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean> productsInfo = assortmentSdkService.getProductsInfo(shoppingCartInfoRequestVo.getPartnerId() List<ProductBean> productsInfo = assortmentSdkService.getProductsInfo(shoppingCartInfoRequestVo.getPartnerId()
, shoppingCartInfoRequestVo.getShopId(), goodsIds, shoppingCartInfoRequestVo.getMenuType(), shoppingCartBaseService); , shoppingCartInfoRequestVo.getShopId(), goodsIds, shoppingCartInfoRequestVo.getMenuType(), shoppingCartBaseService);
if (CollectionUtils.isEmpty(productsInfo)) { if (CollectionUtils.isEmpty(productsInfo)) {
throw new ServiceException(ResponseResult.PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST); throw new ServiceException(ResponseResult.PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST);
} }
return productsInfo.stream().map(productBean -> { return productsInfo.stream().map(productBean -> {
CreateOrderVo.PremiumExchangeActivity.Product product = new CreateOrderVo.PremiumExchangeActivity.Product(); CreateOrderVo.PremiumExchangeActivity.Product product = new CreateOrderVo.PremiumExchangeActivity.Product();
List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.SkuProductBean> skuList = productBean.getSkuList(); List<SkuProductBean> skuList = productBean.getSkuList();
List<String> skuIds = null; List<String> skuIds = null;
if (null != skuList) { if (null != skuList) {
skuIds = skuList.stream().map(GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean.SkuProductBean::getSkuId).collect(Collectors.toList()); skuIds = skuList.stream().map(SkuProductBean::getSkuId).collect(Collectors.toList());
} }
if (!CollectionUtils.isEmpty(skuIds)) { if (!CollectionUtils.isEmpty(skuIds)) {
for (String skuId : skuIds) { for (String skuId : skuIds) {
......
...@@ -4,8 +4,8 @@ import cn.freemud.adapter.ShoppingCartConvertAdapter; ...@@ -4,8 +4,8 @@ import cn.freemud.adapter.ShoppingCartConvertAdapter;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean;
import cn.freemud.entities.dto.product.CheckCartRequest; import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartGoodsBaseResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsBaseResponseVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
......
package cn.freemud.service.impl;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.CustomerInfoVo;
import cn.freemud.entities.vo.UpdateGiftAttrRequestVo;
import cn.freemud.service.CartGiftService;
import cn.freemud.service.cache.GiftCacheManager;
import cn.freemud.service.customer.CustomerInfoManager;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* @author Clover.z
* @Date 2021/11/1
* @Desc
*/
@RequiredArgsConstructor
@Service
public class CartGiftServiceImpl implements CartGiftService {
private final CustomerInfoManager customerInfoManager;
private final GiftCacheManager giftCacheManager;
/**
* 更新赠品的购物车行中属性信息
*
* @param requestVo
* @return
*/
@Override
public CartGoods updateGiftAttr(UpdateGiftAttrRequestVo requestVo) {
// 查询登陆用户信息
CustomerInfoVo user = customerInfoManager.getCustomerInfoVo(requestVo.getSessionId());
String partnerId = requestVo.getPartnerId();
String storeCode = requestVo.getShopId();
// 查询赠品缓存
CartGoods goods = giftCacheManager.queryGiftGoods(partnerId, storeCode, user.getMemberId(), requestVo.getUid());
List<CartGoods.CartGoodsExtra> attrList = new ArrayList<>();
List<String> nameList = new ArrayList<>();
requestVo.getExtra().forEach(a -> {
CartGoods.CartGoodsExtra e = new CartGoods.CartGoodsExtra();
e.setAttributeId(a.getAttributeId());
e.setAttributeName(a.getAttributeName());
attrList.add(e);
nameList.add(a.getAttributeName());
});
goods.setExtra(attrList);
goods.setSubName(StringUtils.join(nameList, "/"));
// 更新赠品缓存
giftCacheManager.updateGiftGoods(partnerId, storeCode, user.getMemberId(), goods);
return goods;
}
}
...@@ -17,8 +17,9 @@ import cn.freemud.adapter.StoreItemAdapter; ...@@ -17,8 +17,9 @@ import cn.freemud.adapter.StoreItemAdapter;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.demo.entities.bo.goods.GetProductBySkuIdResponseBO; import cn.freemud.demo.entities.bo.goods.GetProductBySkuIdResponseBO;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.product.info.AttributeValueBean;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.GetProductsVo; import cn.freemud.entities.vo.GetProductsVo;
import cn.freemud.enums.ProductInfoType; import cn.freemud.enums.ProductInfoType;
...@@ -62,7 +63,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -62,7 +63,7 @@ public class ItemServiceImpl implements ItemService {
public BaseResponse<Map<String, ProductBean>> getProducts(String partnerId, String shopId, List<String> productIds, boolean reflash ,String menuType) { public BaseResponse<Map<String, ProductBean>> getProducts(String partnerId, String shopId, List<String> productIds, boolean reflash , String menuType) {
Map<String, ProductBean> newProductBeanMap = Maps.newTreeMap(); Map<String, ProductBean> newProductBeanMap = Maps.newTreeMap();
if (CollectionUtils.isEmpty(productIds)) { if (CollectionUtils.isEmpty(productIds)) {
return ResponseUtil.success(newProductBeanMap); return ResponseUtil.success(newProductBeanMap);
...@@ -101,8 +102,8 @@ public class ItemServiceImpl implements ItemService { ...@@ -101,8 +102,8 @@ public class ItemServiceImpl implements ItemService {
* @param productBean * @param productBean
* @return * @return
*/ */
public Map<String, ProductBean.ProductAttributeGroupListBean.AttributeValueBean> getAttributeValuesByProduct(ProductBean productBean) { public Map<String, AttributeValueBean> getAttributeValuesByProduct(ProductBean productBean) {
Map<String, ProductBean.ProductAttributeGroupListBean.AttributeValueBean> attributeValueBeanMap = Maps.newTreeMap(); Map<String, AttributeValueBean> attributeValueBeanMap = Maps.newTreeMap();
if (productBean == null) { if (productBean == null) {
return attributeValueBeanMap; return attributeValueBeanMap;
} }
...@@ -128,7 +129,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -128,7 +129,7 @@ public class ItemServiceImpl implements ItemService {
if (CollectionUtils.isEmpty(attributeIds)) { if (CollectionUtils.isEmpty(attributeIds)) {
return true; return true;
} }
Map<String, ProductBean.ProductAttributeGroupListBean.AttributeValueBean> attributeValueBeanMap = getAttributeValuesByProduct(productBean); Map<String, AttributeValueBean> attributeValueBeanMap = getAttributeValuesByProduct(productBean);
for (String attributeId : attributeIds) { for (String attributeId : attributeIds) {
if (!attributeValueBeanMap.containsKey(attributeId)) { if (!attributeValueBeanMap.containsKey(attributeId)) {
return false; return false;
......
...@@ -23,9 +23,6 @@ import cn.freemud.constant.ShoppingCartConstant; ...@@ -23,9 +23,6 @@ import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.demo.controller.ShoppingCartDemoController; import cn.freemud.demo.controller.ShoppingCartDemoController;
import cn.freemud.demo.entities.dto.goods.add.list.BaseListCartGoodsVO; import cn.freemud.demo.entities.dto.goods.add.list.BaseListCartGoodsVO;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountResponseDto;
import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto; import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.activity.DiscountSharingDto; import cn.freemud.entities.dto.activity.DiscountSharingDto;
...@@ -35,6 +32,8 @@ import cn.freemud.entities.dto.openplatform.WeixinProductResponseDto; ...@@ -35,6 +32,8 @@ import cn.freemud.entities.dto.openplatform.WeixinProductResponseDto;
import cn.freemud.entities.dto.order.PackAmountConfig; import cn.freemud.entities.dto.order.PackAmountConfig;
import cn.freemud.entities.dto.pay.*; import cn.freemud.entities.dto.pay.*;
import cn.freemud.entities.dto.product.CheckCartRequest; import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.dto.product.info.SkuProductBean;
import cn.freemud.entities.dto.shoppingCart.SendPoint; import cn.freemud.entities.dto.shoppingCart.SendPoint;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.GetUserScoreUseDetailRequest; import cn.freemud.entities.dto.user.GetUserScoreUseDetailRequest;
...@@ -49,6 +48,7 @@ import cn.freemud.interceptor.BizServiceException; ...@@ -49,6 +48,7 @@ import cn.freemud.interceptor.BizServiceException;
import cn.freemud.interceptor.ServiceException; import cn.freemud.interceptor.ServiceException;
import cn.freemud.redis.RedisCache; import cn.freemud.redis.RedisCache;
import cn.freemud.service.*; import cn.freemud.service.*;
import cn.freemud.service.cache.GiftCacheManager;
import cn.freemud.service.delivery.DeliveryFactory; import cn.freemud.service.delivery.DeliveryFactory;
import cn.freemud.service.delivery.DeliveryService; import cn.freemud.service.delivery.DeliveryService;
import cn.freemud.service.impl.calculate.*; import cn.freemud.service.impl.calculate.*;
...@@ -214,6 +214,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -214,6 +214,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
@Autowired @Autowired
private GetActivityMsgHandle getActivityMsgHandle; private GetActivityMsgHandle getActivityMsgHandle;
@Autowired
private GiftCacheManager giftCacheManager;
/** /**
* 从微信卡券向购物车中添加商品 * 从微信卡券向购物车中添加商品
...@@ -381,7 +383,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -381,7 +383,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//更新购物车券状态 //更新购物车券状态
newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult); newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult);
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null
, null, null, activityQueryDto, menuType, deliveryAmount , userLoginInfoDto, null, activityQueryDto, menuType, deliveryAmount
, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId); , ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId);
...@@ -1035,6 +1037,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1035,6 +1037,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ShoppingCartRelationService shoppingCartRelationService = shoppingCartRelationFactory.cleanAfter(shoppingCartClearRequestVo.getPartnerId()); ShoppingCartRelationService shoppingCartRelationService = shoppingCartRelationFactory.cleanAfter(shoppingCartClearRequestVo.getPartnerId());
shoppingCartRelationService.cleanAfter(shoppingCartGoodsResponseVo, shoppingCartClearRequestVo); shoppingCartRelationService.cleanAfter(shoppingCartGoodsResponseVo, shoppingCartClearRequestVo);
// 清空购物车赠品的缓存信息
giftCacheManager.clearGiftCache(partnerId, storeId, userId);
return ResponseUtil.success(shoppingCartGoodsResponseVo); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
...@@ -2185,7 +2189,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2185,7 +2189,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
&& productBeanListSpuClass.get(0).getStockLimit() == 1) { && productBeanListSpuClass.get(0).getStockLimit() == 1) {
stockLimit = true; stockLimit = true;
} else { } else {
for (ProductBean.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { for (SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (spuId2.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { if (spuId2.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
stockLimit = true; stockLimit = true;
break; break;
...@@ -2220,7 +2224,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2220,7 +2224,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
&& productBeanListSpuClass.get(0).getStockLimit() == 1) { && productBeanListSpuClass.get(0).getStockLimit() == 1) {
isLimit = true; isLimit = true;
} else { } else {
for (ProductBean.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { for (SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
isLimit = true; isLimit = true;
break; break;
...@@ -3343,7 +3347,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3343,7 +3347,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
&& productBeanListSpuClass.get(0).getStockLimit() == 1) { && productBeanListSpuClass.get(0).getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); availableStocks = stockClient.getAvailableStocks(requestDto);
} else { } else {
for (ProductBean.SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { for (SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); availableStocks = stockClient.getAvailableStocks(requestDto);
break; break;
......
...@@ -95,7 +95,7 @@ public class CalculationSharingCartService { ...@@ -95,7 +95,7 @@ public class CalculationSharingCartService {
/** /**
* 买赠 * 买赠
*/ */
giftSharingService.giftResponse(discountResult, cartGoodsList, shoppingCartInfoRequestVo, activityQueryDto, partnerId,flag); giftSharingService.giftResponse(discountResult, cartGoodsList, shoppingCartInfoRequestVo, activityQueryDto, partnerId, storeId, userId, flag);
/** /**
* 加价购 * 加价购
......
...@@ -128,7 +128,7 @@ public class CalculationSharingEquallyService { ...@@ -128,7 +128,7 @@ public class CalculationSharingEquallyService {
/** /**
* 赠品 * 赠品
*/ */
giftSharingService.equally(discountResult, cartGoodsDetailDtoList, activityQueryDto, menuType); giftSharingService.equally(discountResult, cartGoodsDetailDtoList, activityQueryDto, menuType, userLoginInfoDto);
/** /**
* 加价购商品 * 加价购商品
......
...@@ -3,11 +3,11 @@ package cn.freemud.service.impl.mcoffee.calculation; ...@@ -3,11 +3,11 @@ package cn.freemud.service.impl.mcoffee.calculation;
import cn.freemud.adapter.ShoppingCartMccafeAdapter; import cn.freemud.adapter.ShoppingCartMccafeAdapter;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ShareDiscountActivityDto; import cn.freemud.entities.dto.activity.ShareDiscountActivityDto;
import cn.freemud.entities.dto.calculate.*; import cn.freemud.entities.dto.calculate.*;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
import cn.freemud.enums.ActivityChannelEnum; import cn.freemud.enums.ActivityChannelEnum;
...@@ -284,11 +284,11 @@ public class CalculationServiceImpl { ...@@ -284,11 +284,11 @@ public class CalculationServiceImpl {
List<String> productIds = products.stream().map(t -> t.getSkuId()).collect(Collectors.toList()); List<String> productIds = products.stream().map(t -> t.getSkuId()).collect(Collectors.toList());
//调用商品的接口获取商品键位 //调用商品的接口获取商品键位
BaseResponse<Map<String, GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean>> baseResponse = itemService.getProducts(shoppingCartInfoRequestVo.getPartnerId(), BaseResponse<Map<String, ProductBean>> baseResponse = itemService.getProducts(shoppingCartInfoRequestVo.getPartnerId(),
shoppingCartInfoRequestVo.getShopId(), productIds, false, shoppingCartInfoRequestVo.getMenuType()); shoppingCartInfoRequestVo.getShopId(), productIds, false, shoppingCartInfoRequestVo.getMenuType());
if (ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) && baseResponse.getResult() != null){ if (ResponseResult.SUCCESS.getCode().equals(baseResponse.getCode()) && baseResponse.getResult() != null){
for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods: products) { for (ShoppingCartGoodsDto.CartGoodsDetailDto cartGoods: products) {
GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBean = baseResponse.getResult().get(cartGoods.getSkuId()); ProductBean productBean = baseResponse.getResult().get(cartGoods.getSkuId());
cartGoods.setProductCode(productBean.getCustomerCode()); cartGoods.setProductCode(productBean.getCustomerCode());
} }
} }
......
package cn.freemud.service.product;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.GetProductInfoDto;
import cn.freemud.entities.dto.ProductInfosDto;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.thirdparty.ProductClient;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author Clover.z
* @Date 2021/10/29
* @Desc 商品服务通用能力下沉
*/
@Component
@RequiredArgsConstructor
public class ProductInfoManager {
private final ProductClient productClient;
/**
* 查询商品信息
* @param partnerId 商户号
* @param storeCode 门店号
* @param menuType 菜单类型
* @param goodsIdList 商品id集合
* @return
*/
public List<ProductBean> getProductsInfo(String partnerId,
String storeCode,
String menuType,
List<String> goodsIdList) {
return this.getProductsInfo(partnerId, storeCode, menuType, false, goodsIdList);
}
/**
* 查询商品信息(可指定查询sku对于spu的信息,不需要spu信息的情况下不要使用)
* @param partnerId 商户号
* @param storeCode 门店号
* @param menuType 菜单类型
* @param querySkuAttr 是否查询自规格对应spu的属性信息 不需要属性信息就不要传true
* @param goodsIdList 商品id集合
* @return
*/
public List<ProductBean> getProductsInfo(String partnerId,
String storeCode,
String menuType,
Boolean querySkuAttr,
List<String> goodsIdList) {
if (CollectionUtils.isEmpty(goodsIdList)) {
return new ArrayList<>();
}
//移除空的goodsId及spq的商品券
goodsIdList = goodsIdList.parallelStream().filter(StringUtils::isNotEmpty).filter(goodsId -> !goodsId.startsWith(CommonsConstant.COUPON_PREFIX)).collect(Collectors.toList());
if (CollectionUtils.isEmpty(goodsIdList)) {
return new ArrayList<>();
}
GetProductInfoDto query = new GetProductInfoDto();
query.setPartnerId(partnerId);
query.setShopId(storeCode);
query.setProductInfoType(2);
query.setProductIds(goodsIdList);
query.setChannel(StringUtils.isBlank(menuType) ? "saas" : menuType);
query.setAutoFillSkuAttr(querySkuAttr);
ProductInfosDto response = productClient.listProductInfos(query);
if (null == response || !Objects.equals(ResponseCodeConstant.RESPONSE_SUCCESS, response.getErrcode()) || null == response.getData()) {
throw new ServiceException(ResponseResult.STORE_ITEM_QUERY_ERROR);
}
return CollectionUtils.isEmpty(response.getData().getProducts()) ? new ArrayList<>() : response.getData().getProducts();
}
}
package cn.freemud.service;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.vo.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Arrays;
import java.util.Map;
import static org.junit.Assert.*;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title:
* @Package: cn.freemud.service.thirdpart
* @Description:
* @author: biao.zhang
* @date: 2018/12/17 16:34
* @Copyright: 2018 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@EnableDiscoveryClient
@EnableFeignClients
@EnableAutoConfiguration
public class ItemServiceTest {
@Autowired
private ItemService itemService;
@Test
public void hasAttributeAll() {
GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBean = new GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean();
boolean result = itemService.hasAttributeAll(Arrays.asList("1", "2"), productBean);
assertTrue(result);
}
@Test
public void getProducts() {
Map<String, GetProductsVo> maps = itemService.getProducts(Arrays.asList("1", "2"), "1864", "1011","saas");
assertFalse(maps == null || maps.isEmpty());
}
}
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