|
|
package com.yohoufo.order.service.support;
|
|
|
|
|
|
import com.google.common.base.Throwables;
|
|
|
import com.yohoufo.common.ApiResponse;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.dal.order.model.AppraiseAddress;
|
|
|
import com.yohoufo.order.service.impl.AppraiseAddressService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 运费
|
|
|
*
|
...
|
...
|
@@ -20,6 +26,9 @@ public class DeliveryWayCostSupport { |
|
|
@Autowired
|
|
|
private UfoServiceCaller ufoServiceCaller;
|
|
|
|
|
|
@Autowired
|
|
|
private AppraiseAddressService appraiseAddressService;
|
|
|
|
|
|
public double getCostOfSf() {
|
|
|
String key = "buyer.delivery.way.cost.sf";
|
|
|
double defaultValue = 25;
|
...
|
...
|
@@ -41,4 +50,26 @@ public class DeliveryWayCostSupport { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public double getCostOfSfByAreaCode(String areaCode) {
|
|
|
double fee = 25D;
|
|
|
try {
|
|
|
AppraiseAddress appraiseAddress = appraiseAddressService.queryAppraiseAddressByAreaCode(areaCode);
|
|
|
BigDecimal shipFeeFromDB;
|
|
|
if (appraiseAddress != null && Objects.nonNull(shipFeeFromDB = appraiseAddress.getShipFee())){
|
|
|
fee = shipFeeFromDB.doubleValue();
|
|
|
}else{
|
|
|
log.warn("in getCostOfSfByAreaCode fail, appraiseAddress {} areaCode {}", appraiseAddress, areaCode);
|
|
|
fee = getCostOfSf();
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
fee = getCostOfSf();
|
|
|
log.warn("request cost of sf fail exception {}", Throwables.getStackTraceAsString(e));
|
|
|
}finally {
|
|
|
return fee;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|