Commit 81b1729a by chongfu.liang

Merge branch 'feature/2.0.9-购物车检查券是否可用'

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/enums/ResponseResult.java
parents d42f4e66 ba17d4fe
......@@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
......@@ -31,6 +32,10 @@ public class GetCouponDetailResponseDto {
private Active active;
private List<ActiveProduct> activeProduct;
private List<ActiveRestrictionVOS> activeRestrictionVOS;
/**
* 可核销周,时间段设置
*/
private List<ActiveRedeemTimeInterval> activeRedeemTimeIntervalList;
}
@Data
public static class Active{
......@@ -122,4 +127,32 @@ public class GetCouponDetailResponseDto {
private String errorCode;
private String parameter;
}
@Data
public static class ActiveRedeemTimeInterval{
private Long id;
private Integer partnerid;
private Integer activeid;
/**
* 启用时间 时分秒
*/
private String begintime;
/**
* 结束时间 时分秒
*/
private String endtime;
private Integer status;
private Date createdate;
private String createuser;
/**
* 周几可用, 7位数字,第一位为周日
*/
private String weekday;
/**
* 限制使用日期, 年-月-, 多个竖线分割,仅在列表内的日期可用
*/
private String limitdates;
}
}
......@@ -185,6 +185,7 @@ public enum ResponseResult {
COUPON_VERIFICATION_FAIL("46012","优惠券核销失败"),
COUPON_CALLBACK_FAIL("46013","优惠券移除卡包失败"),
COUPON_INVAILD("46014", "优惠券失效"),
COUPON_DATETIME_INVAILD("46015", "优惠券在当前时间不可用"),
/**
* 加价购商品
*/
......
......@@ -67,6 +67,9 @@ import java.awt.geom.Point2D;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -498,6 +501,8 @@ public class CheckOrder {
throw new ServiceException(ResponseResult.COUPON_GETINFO_INVAILD);
}
}
List<GetCouponDetailResponseDto.ActiveRedeemTimeInterval> activeRedeemTimeIntervalList = getCouponDetailResponseDto.getDetails().get(0).getActiveRedeemTimeIntervalList();
checkCouonRedeemTime(activeRedeemTimeIntervalList);
String activeCode = getCouponDetailResponseDto.getDetails().get(0).getActive().getActiveCode();
// 校验点餐方式,查询购物车接口内部已校验
shoppingCartInfoRequestVo.setCouponCode(createOrderVo.getCouponCode());
......@@ -525,6 +530,36 @@ public class CheckOrder {
return shoppingCartGoodsDto;
}
private void checkCouonRedeemTime(List<GetCouponDetailResponseDto.ActiveRedeemTimeInterval> activeRedeemTimeIntervalList) {
if (CollectionUtils.isNotEmpty(activeRedeemTimeIntervalList)){
for (GetCouponDetailResponseDto.ActiveRedeemTimeInterval dateLimit : activeRedeemTimeIntervalList){
String weekday = dateLimit.getWeekday(); // 日期限制 0011100 周日开始,0表示不可用
if (StringUtils.isNotBlank(weekday)){ // 存在校验周几
char[] chars = weekday.toCharArray();
int dayOfWeek = LocalDate.now().getDayOfWeek().getValue(); // 从周一开始
if (dayOfWeek == 7){
dayOfWeek = 0;
}
if (Integer.parseInt(String.valueOf(chars[dayOfWeek])) == 0){ //限制
throw new ServiceException(ResponseResult.COUPON_DATETIME_INVAILD);
}
}
String begintime = dateLimit.getBegintime(); // 开始时间 00:00:00
String endtime = dateLimit.getEndtime(); // 结束时间 12:59:59
if (StringUtils.isNotBlank(begintime) && StringUtils.isNotBlank(endtime)){ // 存在校验时段
String[] beginTimeArr = begintime.split(":");
String[] endTimeArr = endtime.split(":");
LocalTime beginLocalTime = LocalTime.of(Integer.valueOf(beginTimeArr[0]), Integer.valueOf(beginTimeArr[1]), Integer.valueOf(beginTimeArr[2]));
LocalTime endLocalTime = LocalTime.of(Integer.valueOf(endTimeArr[0]), Integer.valueOf(endTimeArr[1]), Integer.valueOf(endTimeArr[2]));
LocalTime now = LocalTime.now();
if (now.isBefore(beginLocalTime) || now.isAfter(endLocalTime)){
throw new ServiceException(ResponseResult.COUPON_DATETIME_INVAILD);
}
}
}
}
}
/**
* 获取门店配送信息
*/
......
......@@ -325,7 +325,6 @@ public class OrderServiceImpl implements Orderservice {
// 查询小程序自提外卖配置信息 校验当前订单类型的下单参数 校验外卖是否满足起送条件
Integer pushOrderTime = checkOrder.checkOrderByOrderType(createOrderVo, userLoginInfoDto, storeResponseDto, shoppingCartGoodsDto, trackingNo);
OrderExtInfoDto extInfo = getExtInfo(userLoginInfoDto, storeResponseDto, pushOrderTime, createOrderVo, shoppingCartGoodsDto);
//1.9.2套餐需求同步优化创建订单代码
BaseResponse createOrderOperateDtoResponse = this.sdkCreateOrder(createOrderVo, storeResponseDto, shoppingCartGoodsDto, userLoginInfoDto);
if(createOrderOperateDtoResponse == null || !ResponseResult.SUCCESS.getCode().equals(createOrderOperateDtoResponse.getCode()) || createOrderOperateDtoResponse.getResult() == null ) {
......
......@@ -2,7 +2,7 @@
<configuration>
<property resource="application.properties"/>
<property name="PROJECT_NAME" value="${spring.application.name}" />
<property name="LOG_HOME" value="/data/logs" />
<property name="LOG_HOME" value="/media/freemud/_dde_data/data/logs" />
<!-- %m输出的信息,%p日志级别,%t线程名,%d日期,%c类的全名,,,, -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
......
......@@ -96,6 +96,7 @@ public enum ResponseResult {
SHOPPING_CART_LIMIT_ADD("44025", "加购数量超过限制"),
SHOPPING_CART_GOODS_CHECK_ERROR("44028", "当前餐盘中没有可用券的饮品"),
SHOPPING_CART_NO_MEAL("44029", "请至少选择一个可选商品"),
SHOPPING_CART_COUPON_NOT_USE("44030", "优惠券不可用"),
/**
* 订单状态码
......
......@@ -622,6 +622,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
this.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
}
// 校验入参券是否可用
if (!checkAvailableCoupon(shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getCouponCode())){
return ResponseUtil.error(ResponseResult.SHOPPING_CART_COUPON_NOT_USE);
};
return ResponseUtil.success(shoppingCartGoodsResponseVo);
}
......@@ -645,9 +650,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (goodsList == null || !ResponseResult.SUCCESS.getCode().equals(goodsList.getCode())) {
return goodsList;
}
String partnerId = shoppingCartInfoRequestVo.getPartnerId();
String storeId = shoppingCartInfoRequestVo.getShopId();
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = goodsList.getResult();
// 校验入参券是否可用
if (!checkAvailableCoupon(shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getCouponCode())){
return ResponseUtil.error(ResponseResult.SHOPPING_CART_COUPON_NOT_USE);
};
//SVC卡支付
SVCCardPay(shoppingCartInfoRequestVo.getCardCode(), shoppingCartInfoRequestVo.getReceiveId(), partnerId, storeId, shoppingCartGoodsResponseVo);
return ResponseUtil.success(shoppingCartGoodsResponseVo);
......@@ -2102,4 +2114,20 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return false;
}
}
private boolean checkAvailableCoupon(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String couponCode) {
if (StringUtils.isBlank(couponCode)){
return true;
}
if (shoppingCartGoodsResponseVo == null || shoppingCartGoodsResponseVo.getAvailableCoupon() == null || shoppingCartGoodsResponseVo.getAvailableCoupon().getDisableCoupons() == null){
return true;
}
List<ActivityCouponBean> disableCoupons = shoppingCartGoodsResponseVo.getAvailableCoupon().getDisableCoupons();
ActivityCouponBean activityCouponBean = disableCoupons.stream().filter(p -> p.getCouponCode().equals(couponCode)).findFirst().orElse(null);
if (activityCouponBean == null){
return true;
} else {
return false;
}
}
}
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