Commit ac05693d by xiaoer.li@freemud.com

Merge remote-tracking branch 'remotes/origin/feature/2.0-换购券'

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/enums/GoodsTypeEnum.java
#	shopping-cart-application-service/src/main/java/cn/freemud/enums/ResponseResult.java
parents 8a98edc7 d786ff25
...@@ -17,7 +17,8 @@ public enum GoodsTypeEnum { ...@@ -17,7 +17,8 @@ public enum GoodsTypeEnum {
COMMON_GOODS(1, "正常商品"), COMMON_GOODS(1, "正常商品"),
COUPON_GOODS(2, "商品券"), COUPON_GOODS(2, "商品券"),
SET_MEAL_GOODS(3,"套餐商品"), HG_COUPON_GOODS(7, "换购券"),
SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"), SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品"), SPU_GOODS(5, "spu商品"),
EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配"); EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配");
......
...@@ -192,7 +192,7 @@ public interface ShoppingCartBaseService { ...@@ -192,7 +192,7 @@ public interface ShoppingCartBaseService {
CartGoodsStates cartGoodsStates = new CartGoodsStates(); CartGoodsStates cartGoodsStates = new CartGoodsStates();
for (CartGoods cartGoods : checkCartRequest.getCartGoodsList()) { for (CartGoods cartGoods : checkCartRequest.getCartGoodsList()) {
// 当goodsId为空或商品是商品券时直接跳过 // 当goodsId为空或商品是商品券时直接跳过
if (StringUtils.isEmpty(cartGoods.getGoodsId()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.COUPON_GOODS.getGoodsType())) { if (StringUtils.isEmpty(cartGoods.getGoodsId()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.COUPON_GOODS.getGoodsType()) || Objects.equals(cartGoods.getGoodsType(), GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType())) {
continue; continue;
} }
shoppingCartAdapter.updateCartGoodsInfoNew(cartGoods, productList); shoppingCartAdapter.updateCartGoodsInfoNew(cartGoods, productList);
......
...@@ -3305,14 +3305,20 @@ public class OrderAdapter { ...@@ -3305,14 +3305,20 @@ public class OrderAdapter {
Object value = redisCache.hashGet(hashKey, type); Object value = redisCache.hashGet(hashKey, type);
JSONArray jsonArray = value != null ? JSONArray.parseArray(value.toString()) : new JSONArray(); JSONArray jsonArray = value != null ? JSONArray.parseArray(value.toString()) : new JSONArray();
if(null != jsonArray && jsonArray.size() >0){ if(null != jsonArray && jsonArray.size() >0){
for(int i=0;i<jsonArray.size();i++){ for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = (JSONObject) jsonArray.get(i); JSONObject jsonObject = (JSONObject) jsonArray.get(i);
jsonObject.remove("@type"); jsonObject.remove("@type");
} }
} }
return (value != null ? JSONObject.parseArray(jsonArray.toString(), AssortmentOpenPlatformPartnerWxappConfig.class) : new ArrayList()); return (value != null ? JSONObject.parseArray(jsonArray.toString(), AssortmentOpenPlatformPartnerWxappConfig.class) : new ArrayList());
} else { } else {
return new ArrayList(); return new ArrayList();
} }
} }
public DeleteOrderDto convent2DeleteOrderDto(String oId) {
DeleteOrderDto deleteOrderDto = new DeleteOrderDto();
deleteOrderDto.setOrderId(oId);
return deleteOrderDto;
}
} }
...@@ -217,6 +217,15 @@ public class OrderController { ...@@ -217,6 +217,15 @@ public class OrderController {
} }
/** /**
* 取消支付删除订单
*/
@ApiAnnotation(logMessage = "deleteOrderById")
@PostMapping("/deleteOrderById")
public BaseResponse deleteOrderById(@Validated @LogParams @RequestBody DeleteOrderVo deleteOrderVo) {
return orderservice.deleteOrderById(deleteOrderVo);
}
/**
* 用户申请退款 * 用户申请退款
*/ */
@ApiAnnotation(logMessage = "refund") @ApiAnnotation(logMessage = "refund")
......
...@@ -55,7 +55,7 @@ public interface Orderservice { ...@@ -55,7 +55,7 @@ public interface Orderservice {
* @param oid 订单ID * @param oid 订单ID
* @return * @return
*/ */
BaseResponse queryOrderById(Integer operation,String sessionId, String oid, String partnerId,String channel); BaseResponse queryOrderById(Integer operation, String sessionId, String oid, String partnerId, String channel);
/** /**
* 支付取消删除订单 * 支付取消删除订单
...@@ -63,6 +63,11 @@ public interface Orderservice { ...@@ -63,6 +63,11 @@ public interface Orderservice {
BaseResponse deleteOrder(DeleteOrderVo deleteOrderVo); BaseResponse deleteOrder(DeleteOrderVo deleteOrderVo);
/** /**
* 支付取消删除订单
*/
BaseResponse deleteOrderById(DeleteOrderVo deleteOrderVo);
/**
* 订单申请退款 * 订单申请退款
*/ */
BaseResponse orderRefund(OrderRefundVo orderRefundVo); BaseResponse orderRefund(OrderRefundVo orderRefundVo);
......
...@@ -1477,6 +1477,44 @@ public class OrderServiceImpl implements Orderservice { ...@@ -1477,6 +1477,44 @@ public class OrderServiceImpl implements Orderservice {
} }
@Override @Override
public BaseResponse deleteOrderById(DeleteOrderVo deleteOrderVo) {
if (StringUtils.isBlank(deleteOrderVo.getOid())) {
return ResponseUtil.error(ResponseResult.PARAMETER_MISSING.getCode(), "oid不能为空");
}
BaseQueryOrderRequest baseQueryOrderRequest = new BaseQueryOrderRequest();
baseQueryOrderRequest.setOrderId(deleteOrderVo.getOid());
baseQueryOrderRequest.setTrackingNo(LogTreadLocal.getTrackingNo());
QueryOrderByIdResponse queryOrderByIdResponse = orderCenterSdkService.queryOrderById(baseQueryOrderRequest);
String string = JSONObject.toJSONString(queryOrderByIdResponse);
JSONObject jsonObject = JSONObject.parseObject(string);
QueryOrderByIdResponseDto responseDto = jsonObject.toJavaObject(QueryOrderByIdResponseDto.class);
if (!RESPONSE_SUCCESS_CODE.equals(responseDto.getErrcode()) || responseDto.getData() == null) {
return ResponseUtil.error(ResponseResult.ORDER_QUERYORDER_ERROR);
}
OrderBean orderBean = responseDto.getData();
if (!PayStatus.NOT_PAY.getCode().equals(orderBean.getPayStatus())) {
return ResponseUtil.error(ResponseResult.ORDER_DELETE_ERROR.getCode(), "订单状态不允许删除");
}
if (!OrderStatus.WAIT_PAY.getCode().equals(orderBean.getStatus())) {
return ResponseUtil.error(ResponseResult.ORDER_DELETE_ERROR.getCode(), "订单状态不允许删除");
}
DeleteOrderDto deleteOrderDto = orderAdapter.convent2DeleteOrderDto(deleteOrderVo.getOid());
//
DeleteOrderRequest var1 = new DeleteOrderRequest();
var1.setOrderId(deleteOrderDto.getOrderId());
var1.setTrackingNo(LogTreadLocal.getTrackingNo());
var1.setOperator("未支付删除");
BaseOrderResponse baseOrderResponse = orderCenterSdkService.deleteOrder(var1);
if (!RESPONSE_SUCCESS_CODE.equals(baseOrderResponse.getErrcode())) {
return ResponseUtil.error(ResponseResult.ORDER_DELETE_ERROR);
}
// TODO: 2019/9/10 删除订单通知
backOrdersStatusChange(orderBean.getOid(), orderBean.getStatus());
return ResponseUtil.success();
}
@Override
public BaseResponse orderRefund(OrderRefundVo orderRefundVo) { public BaseResponse orderRefund(OrderRefundVo orderRefundVo) {
if (StringUtils.isEmpty(orderRefundVo.getReason())) { if (StringUtils.isEmpty(orderRefundVo.getReason())) {
orderRefundVo.setReason("退款"); orderRefundVo.setReason("退款");
......
...@@ -112,6 +112,7 @@ public class ActivityCalculationDiscountRequestDto { ...@@ -112,6 +112,7 @@ public class ActivityCalculationDiscountRequestDto {
* 例如8折为80 * 例如8折为80
*/ */
private Integer memberDiscount; private Integer memberDiscount;
private String couponCode;
/** /**
* 加料 * 加料
*/ */
......
package cn.freemud.entities.dto; package cn.freemud.entities.dto;
import cn.freemud.entities.vo.CartGoods;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class CheckSpqInfoResponseDto { public class CheckSpqInfoResponseDto {
private String spuId; private String spuId;
...@@ -26,4 +29,7 @@ public class CheckSpqInfoResponseDto { ...@@ -26,4 +29,7 @@ public class CheckSpqInfoResponseDto {
private String couponCode; private String couponCode;
private Long price; private Long price;
private String picture; private String picture;
private String defaultSpecId;
private String defaultSpecName;
private List<CartGoods.CartGoodsExtra> extras;
} }
...@@ -33,7 +33,7 @@ public class CartGoods { ...@@ -33,7 +33,7 @@ public class CartGoods {
*/ */
private String goodsId; private String goodsId;
/** /**
* 1.正常商品,2.商品券,3.套餐商品 * 1.正常商品,2.商品券,3.套餐商品,4、换购券
*/ */
private Integer goodsType; private Integer goodsType;
/** /**
......
...@@ -45,4 +45,7 @@ public class GetProductsVo { ...@@ -45,4 +45,7 @@ public class GetProductsVo {
* 分类名称 * 分类名称
*/ */
private String categoryName; private String categoryName;
private String defaultSpecId;
private String defaultSpecName;
private List<CartGoods.CartGoodsExtra> extra;
} }
\ No newline at end of file
...@@ -17,6 +17,7 @@ public enum GoodsTypeEnum { ...@@ -17,6 +17,7 @@ public enum GoodsTypeEnum {
COMMON_GOODS(1, "正常商品"), COMMON_GOODS(1, "正常商品"),
COUPON_GOODS(2, "商品券"), COUPON_GOODS(2, "商品券"),
HG_COUPON_GOODS(7, "换购券"),
SET_MEAL_GOODS(3, "套餐商品"), SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"), SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品"), SPU_GOODS(5, "spu商品"),
......
...@@ -89,6 +89,7 @@ public enum ResponseResult { ...@@ -89,6 +89,7 @@ public enum ResponseResult {
SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE("44022", "已加入同样优惠券,第二张暂不可用"), SHOPPING_CART_GOODS_COUPON_CAN_NOT_USE("44022", "已加入同样优惠券,第二张暂不可用"),
SHOPPING_CART_PRODUCT_CAN_NOT_USE("44023", "商品不可用"), SHOPPING_CART_PRODUCT_CAN_NOT_USE("44023", "商品不可用"),
SHOPPING_CART_COUPON_CAN_NOT_USE("44024", "商品券不可用"), SHOPPING_CART_COUPON_CAN_NOT_USE("44024", "商品券不可用"),
SHOPPING_CART_HG_COUPON_NOT_EXIST("44027", "换购券不存在"),
SHOPPING_CART_LIMIT_ADD("44025", "加购数量超过限制"), SHOPPING_CART_LIMIT_ADD("44025", "加购数量超过限制"),
/** /**
......
...@@ -100,6 +100,8 @@ public interface CouponService { ...@@ -100,6 +100,8 @@ public interface CouponService {
*/ */
CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto); CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto);
CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto, String goodsId);
/** /**
* 领券 * 领券
* *
......
...@@ -102,7 +102,7 @@ public interface ShoppingCartNewService { ...@@ -102,7 +102,7 @@ public interface ShoppingCartNewService {
List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList); List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList);
/** /**
* 校验券是否有效 * 商品券校验券是否有效
* *
* @param partnerId * @param partnerId
* @param storeId * @param storeId
...@@ -110,9 +110,13 @@ public interface ShoppingCartNewService { ...@@ -110,9 +110,13 @@ public interface ShoppingCartNewService {
* @param productIds * @param productIds
* @return * @return
*/ */
default String validCoupon(String partnerId, String storeId, String spuId, List<Long> productIds,String menuType) { default String validCoupon(String partnerId
, String storeId
, String spuId
, List<Long> productIds
, String menuType) {
String spuId2; String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()),menuType); CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class); CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto); CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
if (checkSpqInfoResponseDto == null) { if (checkSpqInfoResponseDto == null) {
...@@ -124,6 +128,35 @@ public interface ShoppingCartNewService { ...@@ -124,6 +128,35 @@ public interface ShoppingCartNewService {
} }
/** /**
* 换购券
*
* @param partnerId
* @param storeId
* @param spuId
* @param productIds
* @param menuType
* @param goodsId
* @return
*/
default String validCoupon(String partnerId
, String storeId
, String spuId
, List<Long> productIds
, String menuType
, String goodsId) {
String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto, goodsId);
if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_HG_COUPON_NOT_EXIST);
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2;
}
/**
* 添加商品券商品 * 添加商品券商品
* *
* @param addShoppingCartGoodsRequestVo * @param addShoppingCartGoodsRequestVo
......
...@@ -10,14 +10,9 @@ import cn.freemud.entities.dto.activity.ShareDiscountActivityDto; ...@@ -10,14 +10,9 @@ import cn.freemud.entities.dto.activity.ShareDiscountActivityDto;
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.*; import cn.freemud.enums.*;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.CouponService; import cn.freemud.service.CouponService;
import cn.freemud.service.IPromotionService; import cn.freemud.service.IPromotionService;
import cn.freemud.service.UserService;
import com.alibaba.fastjson.JSONArray;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant; import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService;
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.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
...@@ -96,11 +91,26 @@ public class CouponPromotionService implements IPromotionService { ...@@ -96,11 +91,26 @@ public class CouponPromotionService implements IPromotionService {
cartGoods.setQty(1); cartGoods.setQty(1);
cartGoods.setCouponCode(checkSpqInfoResponseDto.getCouponCode()); cartGoods.setCouponCode(checkSpqInfoResponseDto.getCouponCode());
cartGoods.setSpuName(checkSpqInfoResponseDto.getSpuName()); cartGoods.setSpuName(checkSpqInfoResponseDto.getSpuName());
cartGoods.setSpecProductId(checkSpqInfoResponseDto.getDefaultSpecId());
cartGoods.setSubName(checkSpqInfoResponseDto.getDefaultSpecName());
cartGoods.setExtra(checkSpqInfoResponseDto.getExtras());
if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods discountGoods = calculationDiscountResult.getGoods()
.stream()
.filter(d -> cartGoods.getCartGoodsUid().equals(d.getCartGoodsUid()))
.findFirst()
.orElse(null);
if (discountGoods != null) {
cartGoods.setAmount(discountGoods.getRealAmount());
} else {
cartGoods.setAmount(checkSpqInfoResponseDto.getPrice());
}
}
cartGoods.setOriginalAmount(checkSpqInfoResponseDto.getPrice());
} }
} }
} }
} }
} }
...@@ -144,7 +154,7 @@ public class CouponPromotionService implements IPromotionService { ...@@ -144,7 +154,7 @@ public class CouponPromotionService implements IPromotionService {
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto(); ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
activityDiscountsDto.setActivityCode(apportionDetails.getActivityCode()); activityDiscountsDto.setActivityCode(apportionDetails.getActivityCode());
activityDiscountsDto.setActivityName(apportionDetails.getActivityName()); activityDiscountsDto.setActivityName(apportionDetails.getActivityName());
activityDiscountsDto.setActivityType(apportionDetails.getActivityType()); activityDiscountsDto.setActivityType(this.convent2ActivityType(apportionDetails.getActivityType()));
activityDiscountsDto.setDiscountAmount(0 - couponDiscount.getDiscountAmount()); activityDiscountsDto.setDiscountAmount(0 - couponDiscount.getDiscountAmount());
return activityDiscountsDto; return activityDiscountsDto;
} }
...@@ -162,4 +172,12 @@ public class CouponPromotionService implements IPromotionService { ...@@ -162,4 +172,12 @@ public class CouponPromotionService implements IPromotionService {
activityClassifyCouponBean.setUsableCoupons(Lists.newArrayList()); activityClassifyCouponBean.setUsableCoupons(Lists.newArrayList());
return activityClassifyCouponBean; return activityClassifyCouponBean;
} }
private Integer convent2ActivityType(Integer type) {
Integer Hg = 33;
if (type != null && Hg.equals(type)) {
type = 32;
}
return type;
}
} }
...@@ -68,6 +68,7 @@ import org.springframework.stereotype.Service; ...@@ -68,6 +68,7 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service @Service
@Slf4j @Slf4j
...@@ -679,6 +680,90 @@ public class CouponServiceImpl implements CouponService { ...@@ -679,6 +680,90 @@ public class CouponServiceImpl implements CouponService {
return dto; return dto;
} }
/**
* 换购券
*
* @param requestDto
* @param goodsId
* @return
*/
@Override
public CheckSpqInfoResponseDto checkSpqInfo(CheckSpqInfoRequestDto requestDto, String goodsId) {
log.info("checkSpqInfo****" + gson.toJson(requestDto));
String partnerId = requestDto.getPartnerId();
String couponCode = requestDto.getCouponCode();
String storeId = requestDto.getStoreId();
//TODO 查询券详情券是否存在
GetMemberCouponRequestVo requestVo = new GetMemberCouponRequestVo();
requestVo.setPartnerId(partnerId);
requestVo.setCouponCode(couponCode);
requestVo.setStoreId(requestDto.getStoreId());
GetCouponDetailResponseDto couponDetailResponseDto = couponService.getMemberCoupon(requestVo);
LogUtil.info("couponService.getMemberCoupon", gson.toJson(requestVo), gson.toJson(couponDetailResponseDto));
if (couponDetailResponseDto == null || !couponDetailResponseDto.getResult().equals(ResponseCodeConstant.RESPONSE_SUCCESS_1) || CollectionUtils.isEmpty(couponDetailResponseDto.getDetails())) {
return null;
}
if (CollectionUtils.isEmpty(couponDetailResponseDto.getDetails())) {
return null;
}
boolean productValid = false;
GetCouponDetailResponseDto.Details couponActivityDetail = null;
for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) {
if (productValid) break;
if (!CouponStatus.STATUS_0.getCode().equals(detail.getStatus())) continue;
for (GetCouponDetailResponseDto.ActiveProduct activeProduct : detail.getActiveProduct()) {
if (goodsId.equals(activeProduct.getProductIdPartner())) {
productValid = true;
couponActivityDetail = detail;
break;
}
}
}
//检查商品是否有效
if (!productValid) {
return null;
}
//TODO 判断该券是否在这个门店下(一个券可以在多个门店下使用)
List<String> couPonstoreIds = Lists.newArrayList();
for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) {
if (!CouponStatus.STATUS_0.getCode().equals(detail.getStatus())) continue;
for (GetCouponDetailResponseDto.ActiveRestrictionVOS activeRestrictionVO : detail.getActiveRestrictionVOS()) {
couPonstoreIds.add(activeRestrictionVO.getStoreIdPartner());
}
}
if (CollectionUtils.isNotEmpty(couPonstoreIds) && !couPonstoreIds.contains(storeId)) {
return null;
}
//券返回的商品id
List<String> skuIds = Lists.newArrayList();
String skuId = goodsId;
skuIds.add(skuId);
//TODO 通过skuid查询spuid
Map<String, GetProductsVo> productsVoMap = itemService.getProducts(skuIds, partnerId, storeId, requestDto.getMenuType());
GetProductsVo productsVo = productsVoMap.get(skuId);
if (null == productsVo || !Objects.equals(productsVo.getStatus(), StoreItemStatus.PUT_ON_SALE.getCode())) {
return null;
}
CheckSpqInfoResponseDto dto = new CheckSpqInfoResponseDto();
dto.setCouponCode(couponCode);
dto.setActiveCode(couponActivityDetail.getActive().getActiveCode());
dto.setCouponName(couponActivityDetail.getTitle());
dto.setActivityName(couponActivityDetail.getActive().getActiveName());
dto.setPrice(productsVo.getFinalPrice());
dto.setSpuId(productsVo.getSpuId());
dto.setSpuName(productsVo.getSkuName());
dto.setSkuId(productsVo.getSkuId());
dto.setSkuName(StringUtils.isNotBlank(productsVo.getSkuName()) ? productsVo.getSkuName() : productsVo.getSpuName());
dto.setPicture(productsVo.getSpuPicture());
dto.setDefaultSpecName(productsVo.getDefaultSpecName());
dto.setDefaultSpecId(productsVo.getDefaultSpecId());
dto.setExtras(productsVo.getExtra());
log.info("dto***" + dto);
return dto;
}
@Autowired @Autowired
private ActivityClient activityClient; private ActivityClient activityClient;
......
...@@ -18,6 +18,7 @@ import cn.freemud.base.entity.BaseResponse; ...@@ -18,6 +18,7 @@ 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.GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean;
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;
import cn.freemud.enums.ResponseResult; import cn.freemud.enums.ResponseResult;
...@@ -32,6 +33,7 @@ import com.google.common.collect.Lists; ...@@ -32,6 +33,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -201,7 +203,26 @@ public class ItemServiceImpl implements ItemService { ...@@ -201,7 +203,26 @@ public class ItemServiceImpl implements ItemService {
String picture = CollectionUtils.isNotEmpty(product.getProductPictureList()) String picture = CollectionUtils.isNotEmpty(product.getProductPictureList())
? product.getProductPictureList().get(0).getUrl() : product.getPicture(); ? product.getProductPictureList().get(0).getUrl() : product.getPicture();
getProductsVo.setSpuPicture(picture); getProductsVo.setSpuPicture(picture);
getProductsVo.setStatus(product.getStatus()); //getProductsVo.setStatus(product.getStatus());
if (CollectionUtils.isNotEmpty(product.getProductAttributeGroupList())
&& CollectionUtils.isNotEmpty(product.getProductAttributeGroupList().get(0).getAttributeValues())) {
List<CartGoods.CartGoodsExtra> extras = new ArrayList<>();
List<String> specId = new ArrayList<>();
List<String> specName = new ArrayList<>();
for (ProductListDto.DataBean.ProductAttributeGroupListBean bean : product.getProductAttributeGroupList()) {
for (ProductListDto.DataBean.ProductAttributeGroupListBean.AttributeValueBean attr : bean.getAttributeValues()) {
CartGoods.CartGoodsExtra extra = new CartGoods.CartGoodsExtra();
extra.setAttributeId(attr.getAttributeId());
extra.setAttributeName(attr.getAttributeValue());
specName.add(attr.getAttributeValue());
specId.add(attr.getAttributeId());
break;
}
}
getProductsVo.setExtra(extras);
getProductsVo.setDefaultSpecName(StringUtils.join(specName, "/"));
getProductsVo.setDefaultSpecId(StringUtils.join(specId, "/"));
}
resultMap.put(skuProductBean.getSkuId(), getProductsVo); resultMap.put(skuProductBean.getSkuId(), getProductsVo);
} }
}); });
......
...@@ -246,7 +246,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -246,7 +246,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
productIds.add(Long.parseLong(goodsId)); productIds.add(Long.parseLong(goodsId));
} else { } else {
//校验券是否有效 //校验券是否有效
spuId2 = validCoupon(partnerId, storeId, spuId, productIds,BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode()); if (StringUtils.isNotBlank(skuId)) {
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId);
cartGoods.setGoodsId(spuId);
} else {
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
}
} }
// 获取商品详细信息 // 获取商品详细信息
List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(partnerId, storeId
...@@ -276,7 +281,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -276,7 +281,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else { } else {
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null // 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo, this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
spuId, allCartGoodsList, productBeanListSpuClass); spuId, allCartGoodsList, productBeanListSpuClass, StringUtils.isNotBlank(skuId) ? true : false);
} }
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo); Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
...@@ -763,13 +768,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -763,13 +768,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
else { else {
// 商品券ID换取商品 // 商品券ID换取商品
String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length()); String spqId = cartGoods.getCartGoodsUid().substring(CommonsConstant.COUPON_PREFIX.length());
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId,menuType); CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spqId, menuType);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto); CheckSpqInfoResponseDto checkSpqInfoResponseDto = null;
if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto, cartGoods.getSkuId());
} else {
checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto);
}
// 商品券不存在时,将商品券从购物车移除 // 商品券不存在时,将商品券从购物车移除
if (checkSpqInfoResponseDto == null) { if (checkSpqInfoResponseDto == null) {
cartGoodsList.remove(i); cartGoodsList.remove(i);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST); if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_HG_COUPON_NOT_EXIST);
} else {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
}
} }
validCouponMap.put(spqId, checkSpqInfoResponseDto); validCouponMap.put(spqId, checkSpqInfoResponseDto);
cartGoods.setName(checkSpqInfoResponseDto.getCouponName()); cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
...@@ -781,7 +796,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -781,7 +796,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
coupons.add(coupon); coupons.add(coupon);
// 添加商品券代表的商品 // 添加商品券代表的商品
String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId(); String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(), 100, cartGoodsUid); if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(), 100, cartGoodsUid, cartGoods.getSpuId());
} else {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(), 100, cartGoodsUid);
}
} }
} }
// 当加价购商品不为空时 // 当加价购商品不为空时
...@@ -801,8 +820,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -801,8 +820,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
activityCalculationDiscountRequestDto.setIsMember(isMember); activityCalculationDiscountRequestDto.setIsMember(isMember);
ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto; ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto;
try { try {
System.out.println("start discount");
System.out.println(JSON.toJSONString(activityCalculationDiscountRequestDto));
activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto); activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
} catch (Exception ex) { } catch (Exception ex) {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex); ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount", activityCalculationDiscountRequestDto, ex);
...@@ -849,6 +866,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -849,6 +866,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods); this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
} }
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList
, String goodsId
, Integer goodsQuantity
, Long originalPrice
, Integer memberDiscount
, String cartGoodsUid
, String couponCode) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsId(goodsId);
calculationDiscountGoods.setCartGoodsUid(cartGoodsUid);
calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
calculationDiscountGoods.setOriginalPrice(originalPrice);
calculationDiscountGoods.setMemberDiscount(memberDiscount);
calculationDiscountGoods.setCouponCode(couponCode);
this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
}
/** /**
* 促销增加 * 促销增加
* *
...@@ -1233,7 +1267,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1233,7 +1267,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo
, CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId , CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId
, List<CartGoods> allCartGoodsList, List<ProductBeanDTO> productBeanListSpuClass) { , List<CartGoods> allCartGoodsList, List<ProductBeanDTO> productBeanListSpuClass, boolean isHg) {
// 商品券商品list // 商品券商品list
List<CartGoods> tmpCartGoods = allCartGoodsList.parallelStream().filter(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)).collect(Collectors.toList()); List<CartGoods> tmpCartGoods = allCartGoodsList.parallelStream().filter(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)).collect(Collectors.toList());
// 当已有商品券时,不得添加(暂时的限制) // 当已有商品券时,不得添加(暂时的限制)
...@@ -1243,7 +1277,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1243,7 +1277,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else { } else {
cartGoods.setCartGoodsUid(spuId); cartGoods.setCartGoodsUid(spuId);
// 设置商品类型为商品券 // 设置商品类型为商品券
cartGoods.setGoodsType(GoodsTypeEnum.COUPON_GOODS.getGoodsType()); if (isHg) {
cartGoods.setGoodsType(GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType());
} else {
cartGoods.setGoodsType(GoodsTypeEnum.COUPON_GOODS.getGoodsType());
}
// 商品券Id // 商品券Id
String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length()); String spqId = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
cartGoods.setSpuId(spqId); cartGoods.setSpuId(spqId);
......
...@@ -160,11 +160,22 @@ public class CouponTest { ...@@ -160,11 +160,22 @@ public class CouponTest {
//1617,1617,88600017957134272219 //1617,1617,88600017957134272219
String partnerId = "1864"; String partnerId = "1864";
String memberId = "1617"; String memberId = "1617";
/*
String code = "88600039947518452055"; String code = "88600039947518452055";
CheckSpqInfoRequestDto requestDto=new CheckSpqInfoRequestDto(); partnerId = "1864";
memberId = "1617";
code = "88600039947518452055";
*/
String code = "88607422333514819844";
partnerId = "2399";
memberId = "2399";
code = "88607422333514819844";
CheckSpqInfoRequestDto requestDto = new CheckSpqInfoRequestDto();
requestDto.setCouponCode(code); requestDto.setCouponCode(code);
requestDto.setPartnerId(partnerId); requestDto.setPartnerId(partnerId);
requestDto.setStoreId("111"); requestDto.setStoreId("");
CheckSpqInfoResponseDto memberCoupon = couponService.checkSpqInfo(requestDto); CheckSpqInfoResponseDto memberCoupon = couponService.checkSpqInfo(requestDto);
logger.info(JSONObject.toJSONString(memberCoupon)); logger.info(JSONObject.toJSONString(memberCoupon));
} }
......
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