Commit f70fb10b by 周晓航

修改对接api 属性

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