Commit c67d633f by 周晓航

Merge branch 'feature_夜间配送ID1040499_zxh20211208' into qa

parents 8112b0f1 f70fb10b
......@@ -81,7 +81,7 @@ public class DeliveryInfoDTO {
* 额外拓展属性 json
* @see cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO
*/
private String expandFields;
private DeliveryInfoExpandFieldDTO expandFields;
}
......@@ -19,9 +19,7 @@ import cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO;
import cn.freemud.entities.dto.console.NightDeliveryuInfo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.utils.DateTimeUtil;
import com.alibaba.fastjson.JSON;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -51,34 +49,31 @@ public interface DeliveryService {
* @param amount 原始配送费价格
* @param expandFields 门店反馈的额外配送费配置
*/
default List<ExtraDeliveryDto> nightDeliveryAmountHandle(long amount, String expandFields) {
default List<ExtraDeliveryDto> nightDeliveryAmountHandle(long amount, DeliveryInfoExpandFieldDTO expandFields) {
List<ExtraDeliveryDto> list = new ArrayList<>();
if (amount > 0) {
ExtraDeliveryDto defaultAmount = new ExtraDeliveryDto(ExtraDeliveryDto.TYPE_DEFAULT, amount);
list.add(defaultAmount);
}
if (StringUtils.isNotBlank(expandFields)) {
DeliveryInfoExpandFieldDTO expandField = JSON.parseObject(expandFields, DeliveryInfoExpandFieldDTO.class);
if (Objects.nonNull(expandField) && CollectionUtils.isNotEmpty(expandField.getNightDeliveryInfo())) {
for (NightDeliveryuInfo info : expandField.getNightDeliveryInfo()) {
if (info.getStatus() == NightDeliveryuInfo.COMMON_STATUS_OPEN) {
// 当前时间在区间内
try {
Date nowTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(DateTimeUtil.getCurrentTimeStr());
Date startTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getStartTime());
Date endTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getEndTime());
if (DateTimeUtil.isEffectiveDate(nowTime, startTime, endTime)) {
ExtraDeliveryDto extraDeliveryDto = new ExtraDeliveryDto(info.getType(), amount);
list.add(extraDeliveryDto);
// 金额 增加
amount += info.getPrice();
}
} catch (ParseException e) {
// 报错表示 时间格式设置错误, 默认当做不计算
e.printStackTrace();
if (Objects.nonNull(expandFields) && CollectionUtils.isNotEmpty(expandFields.getNightDeliveryInfo())) {
for (NightDeliveryuInfo info : expandFields.getNightDeliveryInfo()) {
if (info.getStatus() == NightDeliveryuInfo.COMMON_STATUS_OPEN) {
// 当前时间在区间内
try {
Date nowTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(DateTimeUtil.getCurrentTimeStr());
Date startTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getStartTime());
Date endTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getEndTime());
if (DateTimeUtil.isEffectiveDate(nowTime, startTime, endTime)) {
ExtraDeliveryDto extraDeliveryDto = new ExtraDeliveryDto(info.getType(), amount);
list.add(extraDeliveryDto);
// 金额 增加
amount += info.getPrice();
}
} catch (ParseException e) {
// 报错表示 时间格式设置错误, 默认当做不计算
e.printStackTrace();
}
}
}
}
......
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