Commit ab2c3035 by 徐康

Merge branch 'master' into feature/20200727_麦咖啡p1v2支付券码路由

parents 5d9a54e0 9f5d2724
...@@ -187,12 +187,20 @@ public class CheckOrder { ...@@ -187,12 +187,20 @@ public class CheckOrder {
} }
// TODO: 2020/6/16 门店校验处理 // TODO: 2020/6/16 门店校验处理
String takeMealFlag = createOrderVo.getTakeMealFlag(); String takeMealFlag = createOrderVo.getTakeMealFlag();
//未营业无预约时间无法下单 String takeMealTimes = createOrderVo.getTakeMealTime();
if (!StoreConstant.BUSINESS.equals(storeResponseDto.getState()) && StringUtils.isBlank(takeMealFlag) && "0".equals(takeMealFlag)) {
throw new ServiceException(ResponseResult.STORE_ITEM_CHECK_CLOSE); //立即送达
if("0".equals(takeMealFlag) || (StringUtils.isEmpty(createOrderVo.getExpectTime()) && StringUtils.isEmpty(takeMealTimes))) {
//未营业无预约时间无法下单
if (!StoreConstant.BUSINESS.equals(storeResponseDto.getState())) {
throw new ServiceException(ResponseResult.STORE_ITEM_CHECK_CLOSE);
}
// 外卖单选择立即送达的话,下单时间必须在店铺外卖时间内
if(createOrderVo.getOrderType().compareTo(CreateOrderType.TAKE_OUT.getCode()) == 0) {
checkTakeOutTime(storeResponseDto, new Date(), new Date(), true);
}
} }
String takeMealTimes = createOrderVo.getTakeMealTime();
//有预约时间 //有预约时间
if(StringUtils.isNotBlank(takeMealTimes) || StringUtils.isNotBlank(createOrderVo.getExpectTime())){ if(StringUtils.isNotBlank(takeMealTimes) || StringUtils.isNotBlank(createOrderVo.getExpectTime())){
// 设置预约时间 // 设置预约时间
...@@ -314,37 +322,48 @@ public class CheckOrder { ...@@ -314,37 +322,48 @@ public class CheckOrder {
} }
if (CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType())) { if (CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType())) {
String deliveryStr = storeResponseDto.getDeliveryHoursDay().replace("-", ",") checkTakeOutTime(storeResponseDto, date, takeMealDateTime, expectTimeInTodayBusinessTime);
.replace("_", ","); }
String[] deliverys = deliveryStr.split(","); }
Date deliveryStartDate = null;
Date deliveryEndDate = null; /**
if (deliverys.length == 2) { * 检验订单是否在外卖时间内
SimpleDateFormat hhmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); * @param storeResponseDto 店铺信息
SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); * @param now 当前时间
String startDateTimeStr = yyyyMMdd.format(date) + " " + deliverys[0] + ":00"; * @param takeMealDateTime 预约单送达时间/即时单下单时间
String endDateTimeStr = yyyyMMdd.format(date) + " " + deliverys[1] + ":00"; * @param expectTimeInTodayBusinessTime 是否在当日营业时间内
try { */
deliveryEndDate = hhmmss.parse(endDateTimeStr); private void checkTakeOutTime(StoreResponse.BizVO storeResponseDto, Date now, Date takeMealDateTime, boolean expectTimeInTodayBusinessTime) {
deliveryStartDate = hhmmss.parse(startDateTimeStr); String deliveryStr = storeResponseDto.getDeliveryHoursDay().replace("-", ",")
} catch (ParseException e) { .replace("_", ",");
LogUtil.error("getStoreDeliveryInfo_error", endDateTimeStr, e.getMessage()); String[] deliverys = deliveryStr.split(",");
} Date deliveryStartDate = null;
} Date deliveryEndDate = null;
if (deliveryStartDate == null || deliveryEndDate == null) { if (deliverys.length == 2) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY); SimpleDateFormat hhmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
} SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
// 校验预约配送时间 String startDateTimeStr = yyyyMMdd.format(now) + " " + deliverys[0] + ":00";
if (expectTimeInTodayBusinessTime && (takeMealDateTime.before(deliveryStartDate) || takeMealDateTime.after(deliveryEndDate))) { String endDateTimeStr = yyyyMMdd.format(now) + " " + deliverys[1] + ":00";
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY); try {
} deliveryStartDate = hhmmss.parse(startDateTimeStr);
Date nextDeliveryStartDate = DateUtil.addDays(deliveryStartDate, 1); deliveryEndDate = hhmmss.parse(endDateTimeStr);
Date nextDeliveryEndDate = DateUtil.addDays(deliveryEndDate, 1); } catch (ParseException e) {
// 隔日预约外卖校验预约配送时间 LogUtil.error("getStoreDeliveryInfo_error", endDateTimeStr, e.getMessage());
if (!expectTimeInTodayBusinessTime && (takeMealDateTime.before(nextDeliveryStartDate) || takeMealDateTime.after(nextDeliveryEndDate))) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
} }
} }
if (deliveryStartDate == null || deliveryEndDate == null) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
}
// 校验预约配送时间
if (expectTimeInTodayBusinessTime && (takeMealDateTime.before(deliveryStartDate) || takeMealDateTime.after(deliveryEndDate))) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
}
Date nextDeliveryStartDate = DateUtil.addDays(deliveryStartDate, 1);
Date nextDeliveryEndDate = DateUtil.addDays(deliveryEndDate, 1);
// 隔日预约外卖校验预约配送时间
if (!expectTimeInTodayBusinessTime && (takeMealDateTime.before(nextDeliveryStartDate) || takeMealDateTime.after(nextDeliveryEndDate))) {
throw new ServiceException(ResponseResult.ORDER_CREATE_TIME_NOT_DELIVERY);
}
} }
public Date getOrderExpectTime(String takeMealFlag,String takeMealTimes,String expectTime, public Date getOrderExpectTime(String takeMealFlag,String takeMealTimes,String expectTime,
......
...@@ -157,6 +157,11 @@ public class ActivityCalculationDiscountResponseDto { ...@@ -157,6 +157,11 @@ public class ActivityCalculationDiscountResponseDto {
@Data @Data
public static class Goods { public static class Goods {
/**
* 购物车行记录
*/
private String cartGoodsUid;
/** /**
* 商品id * 商品id
*/ */
......
...@@ -25,5 +25,6 @@ public class ShoppingCartGoodsBaseResponseVo { ...@@ -25,5 +25,6 @@ public class ShoppingCartGoodsBaseResponseVo {
* 购物车中商品价格或有效性是否发生变化 * 购物车中商品价格或有效性是否发生变化
*/ */
private Boolean changed; private Boolean changed;
private String uid;
} }
...@@ -14,6 +14,7 @@ import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; ...@@ -14,6 +14,7 @@ import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
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;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -92,6 +93,7 @@ public class BuyAndGiftsPromotionService implements IPromotionService { ...@@ -92,6 +93,7 @@ public class BuyAndGiftsPromotionService implements IPromotionService {
cartGoods.setClassificationName(product.getCategoryName()); cartGoods.setClassificationName(product.getCategoryName());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额 // nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGoods.setNodeId(sendActivity.getActivityCode()); cartGoods.setNodeId(sendActivity.getActivityCode());
this.setGiftExtra(cartGoods,product,cartGoodsList);
cartGoodsList.add(cartGoods); cartGoodsList.add(cartGoods);
totalGiftAmount += product.getFinalPrice() * sendGoods.getSendNumber(); totalGiftAmount += product.getFinalPrice() * sendGoods.getSendNumber();
} }
...@@ -162,4 +164,37 @@ public class BuyAndGiftsPromotionService implements IPromotionService { ...@@ -162,4 +164,37 @@ public class BuyAndGiftsPromotionService implements IPromotionService {
} }
return productBeanList; return productBeanList;
} }
private void setGiftExtra(CartGoods cartGoods,ProductBeanDTO product,List<CartGoods> cartGoodsList) {
long count = cartGoodsList.stream().filter(c -> c.getSpuId().equals(cartGoods.getSpuId())).count();
//购物车内存在同类
if (count>0) {
CartGoods find = cartGoodsList.stream().filter(c -> c.getSpuId().equals(cartGoods.getSpuId())).findFirst().get();
cartGoods.setExtra(find.getExtra());
cartGoods.setSpuName(find.getSpuName());
cartGoods.setSkuName(find.getSkuName());
cartGoods.setSubName(find.getSubName());
}
//不存在
else {
if (product.getProductAttributeGroupList().size()==0) {
return;
}
List<CartGoods.CartGoodsExtra> extra = new ArrayList<>();
ArrayList<String> name = new ArrayList<>();
List<ProductBeanDTO.ProductAttributeGroupListBean> productAttributeGroupList = product.getProductAttributeGroupList();
for (ProductBeanDTO.ProductAttributeGroupListBean productAttributeGroupListBean : productAttributeGroupList) {
ProductBeanDTO.ProductAttributeGroupListBean.AttributeValueBean bean = productAttributeGroupListBean.getAttributeValues().stream().findFirst().get();
CartGoods.CartGoodsExtra goodsExtra = new CartGoods.CartGoodsExtra();
goodsExtra.setAttributeId(bean.getAttributeId());
goodsExtra.setAttributeName(bean.getAttributeValue());
name.add(bean.getAttributeValue());
extra.add(goodsExtra);
}
cartGoods.setExtra(extra);
cartGoods.setSubName(StringUtils.join(name, "/"));
}
}
} }
...@@ -64,6 +64,7 @@ public class SetMealServiceImpl implements IPromotionService { ...@@ -64,6 +64,7 @@ public class SetMealServiceImpl implements IPromotionService {
String toastMsg = getTotalAmount(cartGoods, productGroupAmount, numberMap, goodsMap); String toastMsg = getTotalAmount(cartGoods, productGroupAmount, numberMap, goodsMap);
if (StringUtils.isNotEmpty(toastMsg)) { if (StringUtils.isNotEmpty(toastMsg)) {
shoppingCartGoodsResponseVo.setToastMsg(toastMsg); shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
shoppingCartGoodsResponseVo.setUid(cartGoods.getCartGoodsUid());
} }
} }
......
...@@ -284,8 +284,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -284,8 +284,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// 促销活动的优惠金额计算 // 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount); updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount);
clearMsg(shoppingCartGoodsResponseVo, cartGoods.getCartGoodsUid());
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
...@@ -377,8 +377,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -377,8 +377,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// 促销活动的优惠金额计算 // 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType(),deliveryAmount); updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount);
clearMsg(shoppingCartGoodsResponseVo, cartGoodsUid);
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
...@@ -1567,4 +1568,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1567,4 +1568,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
return qty; return qty;
} }
/**
* 去除非活动商品的提示
*
* @param shoppingCartGoodsResponseVo
* @param cartUid
*/
public void clearMsg(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String cartUid) {
if (StringUtils.isNotBlank(shoppingCartGoodsResponseVo.getToastMsg()) && StringUtils.isNotBlank(shoppingCartGoodsResponseVo.getUid()) && !cartUid.equals(shoppingCartGoodsResponseVo.getUid())) {
shoppingCartGoodsResponseVo.setUid("");
shoppingCartGoodsResponseVo.setToastMsg("");
}
}
} }
...@@ -48,6 +48,7 @@ public class TimeSalePromotionService implements IPromotionService { ...@@ -48,6 +48,7 @@ public class TimeSalePromotionService implements IPromotionService {
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量 // 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
Map<String, Integer> numberMap = new HashMap<>(); Map<String, Integer> numberMap = new HashMap<>();
List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode()); List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode());
String uid = "";
for (CartGoods cartGoods : cartGoodsList) { for (CartGoods cartGoods : cartGoodsList) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods goods; ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods goods;
if ((goods = goodsMap.get(cartGoods.getGoodsId())) == null) { if ((goods = goodsMap.get(cartGoods.getGoodsId())) == null) {
...@@ -74,12 +75,14 @@ public class TimeSalePromotionService implements IPromotionService { ...@@ -74,12 +75,14 @@ public class TimeSalePromotionService implements IPromotionService {
: goods.getOriginalPrice() * cartGoods.getQty()); : goods.getOriginalPrice() * cartGoods.getQty());
if (StringUtils.isEmpty(toastMsg)) { if (StringUtils.isEmpty(toastMsg)) {
toastMsg = "该商品限" + goodsDiscount.getActualGoodsNumber() + "份优惠 超出按照原价计算哦"; toastMsg = "该商品限" + goodsDiscount.getActualGoodsNumber() + "份优惠 超出按照原价计算哦";
uid = goods.getCartGoodsUid();
} }
} }
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty()); numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty());
} }
if (StringUtils.isNotBlank(toastMsg)) { if (StringUtils.isNotBlank(toastMsg)) {
shoppingCartGoodsResponseVo.setToastMsg(toastMsg); shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
shoppingCartGoodsResponseVo.setUid(uid);
} }
} }
......
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