md
This commit is contained in:
parent
37379b4a3a
commit
68bf50aab6
@ -367,13 +367,12 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
|
|
||||||
// 货物名称必填
|
// 货物名称必填
|
||||||
if(StringUtils.isEmpty(emisWaybillSave.getGoodsInfo())){
|
if(StringUtils.isEmpty(emisWaybillSave.getGoodsInfo())){
|
||||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货物描述不能为空");
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货物描述不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 运费必填
|
// 运费必填
|
||||||
if(emisWaybillSave.getFreight() == null || (
|
if(emisWaybillSave.getFreight() == null || (
|
||||||
emisWaybillSave.getFreight()!=null && emisWaybillSave.getFreight().compareTo(BigDecimal.ZERO)==0 ) ){
|
emisWaybillSave.getFreight()!=null && emisWaybillSave.getFreight().compareTo(BigDecimal.ZERO)==0 ) ){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 货值必填
|
// 货值必填
|
||||||
@ -488,14 +487,16 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
// 派送方式
|
// 派送方式
|
||||||
String dispatchMethod=DictUtils.getDictValue("emis_tab_dispatch_mode",emisWaybillSave.getDispatchMethod());
|
String dispatchMethod=DictUtils.getDictValue("emis_tab_dispatch_mode",emisWaybillSave.getDispatchMethod());
|
||||||
if(dispatchMethod==null){
|
if(dispatchMethod==null){
|
||||||
emisWaybillSave.setDispatchMethod("1");
|
dispatchMethod="1";
|
||||||
}
|
}
|
||||||
|
emisWaybillSave.setDispatchMethod(dispatchMethod);
|
||||||
|
|
||||||
// 付款方式
|
// 付款方式
|
||||||
String paymentType=DictUtils.getDictValue("emis_payment_type",emisWaybillSave.getPaymentType());
|
String paymentType=DictUtils.getDictValue("emis_payment_type",emisWaybillSave.getPaymentType());
|
||||||
if(paymentType==null){
|
if(paymentType==null){
|
||||||
emisWaybillSave.setPaymentType("1");
|
paymentType="1";
|
||||||
}
|
}
|
||||||
|
emisWaybillSave.setPaymentType(paymentType);
|
||||||
|
|
||||||
|
|
||||||
// 月结方式获取月结客户的编码和名称
|
// 月结方式获取月结客户的编码和名称
|
||||||
@ -515,7 +516,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
emisWaybillSave.setPayee(emisCustomerUser.getPayee());
|
emisWaybillSave.setPayee(emisCustomerUser.getPayee());
|
||||||
emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen());
|
emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen());
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
emisWaybillSave.setCustNo(null);
|
emisWaybillSave.setCustNo(null);
|
||||||
// 判断现金的回款联系人和销售联系人
|
// 判断现金的回款联系人和销售联系人
|
||||||
@ -549,6 +549,11 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
emisWaybillSave.setDestinationCode(destination.getDestCode());
|
emisWaybillSave.setDestinationCode(destination.getDestCode());
|
||||||
emisWaybillSave.setDispatchUnderlingSiteCode(destination.getSiteCode());
|
emisWaybillSave.setDispatchUnderlingSiteCode(destination.getSiteCode());
|
||||||
|
|
||||||
|
// 正式开单
|
||||||
|
emisWaybillSave.setOrderType("1");
|
||||||
|
|
||||||
|
// 如果填写了运费则使用按重量计费模式
|
||||||
|
emisWaybillSave.setCalcFeeType("1");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 计算体积重量
|
// 计算体积重量
|
||||||
@ -562,8 +567,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
log.error("===api下单模式,计费错误:",ex.getMessage());
|
log.error("===api下单模式,计费错误:",ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果填写了运费则使用一口价模式
|
|
||||||
emisWaybillSave.setCalcFeeType("1");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +648,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
|
|
||||||
// oms 计算发件网点
|
// oms 计算发件网点
|
||||||
if(isOms){
|
if(isOms){
|
||||||
// 计算目的地
|
// 模拟计算发件地
|
||||||
EmisDestination sendDestination=calcSendSiteByBase(sendCountryCode,transLine.getLineCode(),sendProviceCode,sendCityCode,sendDistrictCode,emisWaybillSave.getSendAddress());
|
EmisDestination sendDestination=calcSendSiteByBase(sendCountryCode,transLine.getLineCode(),sendProviceCode,sendCityCode,sendDistrictCode,emisWaybillSave.getSendAddress());
|
||||||
if(sendDestination==null){
|
if(sendDestination==null){
|
||||||
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件地址不在服务区");
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件地址不在服务区");
|
||||||
@ -1501,6 +1505,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算运单公共信息
|
* 计算运单公共信息
|
||||||
* @param emisWaybillSave
|
* @param emisWaybillSave
|
||||||
@ -1881,6 +1886,383 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api下单填充
|
||||||
|
* @param emisWaybillSave
|
||||||
|
* @param isNew
|
||||||
|
* @throws EmisBizError
|
||||||
|
*/
|
||||||
|
private void calcWayBillCommonInfoByApi(EmisWaybill emisWaybillSave,boolean isNew) throws EmisBizError {
|
||||||
|
|
||||||
|
String orderSn = WaybillHelper.genOrderSn();
|
||||||
|
|
||||||
|
// 订单号
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setOrderSn(orderSn);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getTransLineType(),
|
||||||
|
emisWaybillSave.getProductType()
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路、产品必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 检查数据
|
||||||
|
if(emisWaybillSave.getFreight()==null || emisWaybillSave.getFreight().floatValue()<=0.0f){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"运费必须大于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(emisWaybillSave.getBillWeight()==null || emisWaybillSave.getBillWeight().floatValue()<=0.0f){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"实重必须大于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(emisWaybillSave.getTotalVolume()==null || emisWaybillSave.getTotalVolume().floatValue()<=0.0f){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"体积必须大于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(emisWaybillSave.getSettlementWeight()==null || emisWaybillSave.getSettlementWeight().floatValue()<=0.0f){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"结算重量必须大于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(emisWaybillSave.getVolumeWeight()==null || emisWaybillSave.getVolumeWeight().floatValue()<=0.0f){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"体积重量必须大于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getPickupMethod())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"取件方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getDispatchMethod())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"派送方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getCustomsEclaration())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"报关方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getCustomsClear())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"清关方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getPaymentType())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"支付方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getCalcFeeType())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"计费方式必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发件网点
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getSendSiteCode())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件网点必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 寄件地址
|
||||||
|
if(StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getSendCountry(),
|
||||||
|
emisWaybillSave.getSendName(),
|
||||||
|
emisWaybillSave.getSendMobile(),
|
||||||
|
emisWaybillSave.getSendProvince(),
|
||||||
|
emisWaybillSave.getSendAddress()
|
||||||
|
)
|
||||||
|
){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件人信息不完整检查名称, 电话,国家,省份,地址必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收件地址
|
||||||
|
if(StringUtils.isAnyEmpty(
|
||||||
|
emisWaybillSave.getReceiveCountry(),
|
||||||
|
emisWaybillSave.getReceiveName(),
|
||||||
|
emisWaybillSave.getReceiveMobile(),
|
||||||
|
emisWaybillSave.getReceiveProvince(),
|
||||||
|
emisWaybillSave.getReceiveAddress()
|
||||||
|
)
|
||||||
|
|
||||||
|
){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"收件人信息不完整,名称, 电话,国家,省份,地址必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getPackType())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"包装类型必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 目的网点
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getDispatchUnderlingSiteCode())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"目的网点必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isNew) {
|
||||||
|
if( emisWaybillSave.getSendDate()==null ){
|
||||||
|
emisWaybillSave.setSendDate(new Date());
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"发件日期必填");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断网点余额-运单金额 是否足够,如果不够则不允许下单
|
||||||
|
EmisSiteAccount emisSiteAccount = getSiteAccountBySiteCode(emisWaybillSave.getSendSiteCode());
|
||||||
|
if (emisSiteAccount == null) {
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.FAIL, "网点结算账户不存在,请先开结算账户");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal curMoney = emisSiteAccount.getCurMoney();
|
||||||
|
BigDecimal closeMoney = emisSiteAccount.getCloseMoney();
|
||||||
|
|
||||||
|
BigDecimal newCurMoney = curMoney.subtract(emisWaybillSave.getFreight());
|
||||||
|
if (newCurMoney.compareTo(closeMoney) == -1) {
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.FAIL, "网点余额不足,请充值");
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------
|
||||||
|
// 登记网点
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setRegisterSiteCode("88888");
|
||||||
|
emisWaybillSave.setRegisterManCode("1");
|
||||||
|
emisWaybillSave.setRegisterDate(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setDataFrom("api");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 寄件网点财务中心
|
||||||
|
if(isNew) {
|
||||||
|
EmisSite sendSite = getSiteByCode(emisWaybillSave.getSendSiteCode());
|
||||||
|
if (sendSite != null) {
|
||||||
|
emisWaybillSave.setSendCenterCode(sendSite.getParentSiteCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单运单初始状态 订单为已接单,运单未初始,待揽收
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setOrderStatus("1");
|
||||||
|
emisWaybillSave.setWaybillStatus("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算三段码 目的网点2字码+目的地名称
|
||||||
|
String destSite3Code = "";
|
||||||
|
EmisSite destSite=getSiteByCode(emisWaybillSave.getDispatchUnderlingSiteCode());
|
||||||
|
if(destSite!=null){
|
||||||
|
destSite3Code=destSite.getSizeCode2();
|
||||||
|
// 目的网点财务中心
|
||||||
|
emisWaybillSave.setDestinationCenterCode(destSite.getParentSiteCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始 派件网点=目的网点
|
||||||
|
emisWaybillSave.setDispatchSiteCode(emisWaybillSave.getDispatchUnderlingSiteName());
|
||||||
|
|
||||||
|
// 目的地名称
|
||||||
|
EmisDestination destination=getDestinationByCode(emisWaybillSave.getDestinationCode());
|
||||||
|
String destName="";
|
||||||
|
if(destination!=null){
|
||||||
|
destName=destination.getDestName();
|
||||||
|
}
|
||||||
|
String thirdCode="["+emisWaybillSave.getSendSiteName()+'-'+destName+"]["+destSite3Code+"]";
|
||||||
|
emisWaybillSave.setThirdCode(thirdCode);
|
||||||
|
|
||||||
|
// 下单时间
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setOrderDate(emisWaybillSave.getSendDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 订单类型为正式单,系统开单
|
||||||
|
if(isNew) {
|
||||||
|
emisWaybillSave.setOrderType("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发件地址
|
||||||
|
EmisCustomerAddress sendAddress = new EmisCustomerAddress();
|
||||||
|
sendAddress.setCountry(emisWaybillSave.getSendCountry());
|
||||||
|
sendAddress.setName(emisWaybillSave.getSendName());
|
||||||
|
sendAddress.setPhone(emisWaybillSave.getSendMobile());
|
||||||
|
sendAddress.setProvince(emisWaybillSave.getSendProvince());
|
||||||
|
sendAddress.setCity(emisWaybillSave.getSendCity());
|
||||||
|
sendAddress.setCounty(emisWaybillSave.getSendCounty());
|
||||||
|
sendAddress.setTown(emisWaybillSave.getSendTown());
|
||||||
|
// recieveAddress.setEmail(emisWaybillSave);
|
||||||
|
sendAddress.setAddress(emisWaybillSave.getSendAddress());
|
||||||
|
sendAddress.setCompany(emisWaybillSave.getSendCompany());
|
||||||
|
|
||||||
|
sendAddress.setUseSiteCode(emisWaybillSave.getSendSiteCode());
|
||||||
|
sendAddress.setAddressType("1");
|
||||||
|
|
||||||
|
|
||||||
|
// 收件地址
|
||||||
|
EmisCustomerAddress recieveAddress = new EmisCustomerAddress();
|
||||||
|
recieveAddress.setCountry(emisWaybillSave.getReceiveCountry());
|
||||||
|
recieveAddress.setName(emisWaybillSave.getReceiveName());
|
||||||
|
recieveAddress.setPhone(emisWaybillSave.getReceiveMobile());
|
||||||
|
recieveAddress.setProvince(emisWaybillSave.getReceiveProvince());
|
||||||
|
recieveAddress.setCity(emisWaybillSave.getReceiveCity());
|
||||||
|
recieveAddress.setCounty(emisWaybillSave.getReceiveCounty());
|
||||||
|
recieveAddress.setTown(emisWaybillSave.getReceiveTown());
|
||||||
|
// recieveAddress.setEmail(emisWaybillSave);
|
||||||
|
recieveAddress.setAddress(emisWaybillSave.getReceiveAddress());
|
||||||
|
recieveAddress.setCompany(emisWaybillSave.getReceiveCompany());
|
||||||
|
|
||||||
|
recieveAddress.setUseSiteCode(emisWaybillSave.getSendSiteCode());
|
||||||
|
recieveAddress.setAddressType("2");
|
||||||
|
|
||||||
|
// 计算单据归属
|
||||||
|
String customerCode=null;
|
||||||
|
String customerName=null;
|
||||||
|
|
||||||
|
// 通过电话判断客户是否存在
|
||||||
|
String sendPhone=getCompletePhone(sendAddress.getPhone());
|
||||||
|
EmisCustomerUser emisCustomerUser=getCustomerUserByPhone(sendPhone);
|
||||||
|
if(emisCustomerUser!=null){
|
||||||
|
customerCode=emisCustomerUser.getCustomerCode();
|
||||||
|
customerName=emisCustomerUser.getCustomerName();
|
||||||
|
}else{
|
||||||
|
// 先创建客户
|
||||||
|
EmisCustomerUser newEmisCustomerUser = new EmisCustomerUser();
|
||||||
|
newEmisCustomerUser.setCustomerName(sendAddress.getName());
|
||||||
|
newEmisCustomerUser.setCountry(sendAddress.getCountry());
|
||||||
|
newEmisCustomerUser.setPhone(sendPhone);
|
||||||
|
newEmisCustomerUser.setProvince(sendAddress.getProvince());
|
||||||
|
newEmisCustomerUser.setCity(sendAddress.getCity());
|
||||||
|
newEmisCustomerUser.setCounty(sendAddress.getCounty());
|
||||||
|
newEmisCustomerUser.setTown(sendAddress.getTown());
|
||||||
|
newEmisCustomerUser.setEmail(sendAddress.getEmail());
|
||||||
|
newEmisCustomerUser.setAddress(sendAddress.getAddress());
|
||||||
|
newEmisCustomerUser.setCompany(sendAddress.getCompany());
|
||||||
|
newEmisCustomerUser.setCustomerType("1");
|
||||||
|
newEmisCustomerUser.setSettledType("1");
|
||||||
|
newEmisCustomerUser.setUserType("1");
|
||||||
|
|
||||||
|
newEmisCustomerUser.setBlOpenOms("0");
|
||||||
|
newEmisCustomerUser.setRemark("开单自动生成的现金用户");
|
||||||
|
|
||||||
|
newEmisCustomerUser.setSalesmen(emisWaybillSave.getSalesmen());
|
||||||
|
newEmisCustomerUser.setPayee(emisWaybillSave.getPayee());
|
||||||
|
|
||||||
|
// 预置主归属网点
|
||||||
|
newEmisCustomerUser.setOwnerSite(emisWaybillSave.getSendSiteCode());
|
||||||
|
EmisCustomerUser newUser=createCustomerUser(newEmisCustomerUser);
|
||||||
|
|
||||||
|
customerCode = newUser.getCustomerCode();
|
||||||
|
customerName = newUser.getCustomerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 月结客户直接根据月结编号获取客户编码和名称
|
||||||
|
if("2".equals(emisWaybillSave.getPaymentType())
|
||||||
|
|| "4".equals(emisWaybillSave.getPaymentType())
|
||||||
|
|| "5".equals(emisWaybillSave.getPaymentType())
|
||||||
|
|
||||||
|
){
|
||||||
|
EmisCustomerUser emisMonthCustomerUser=getCustomerUserByMonthlyPayCode(emisWaybillSave.getCustNo());
|
||||||
|
if(emisMonthCustomerUser==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.FAIL,"月结客户不存在");
|
||||||
|
}
|
||||||
|
emisWaybillSave.setCustName(emisMonthCustomerUser.getCustName());
|
||||||
|
emisWaybillSave.setPayee(emisMonthCustomerUser.getPayee());
|
||||||
|
emisWaybillSave.setSalesmen(emisMonthCustomerUser.getSalesmen());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存客户收件、寄件地址,开单不要关联客户地址数据
|
||||||
|
sendAddress.setCustomerCode(customerCode);
|
||||||
|
recieveAddress.setCustomerCode(customerCode);
|
||||||
|
createCustomerAddress(sendAddress);
|
||||||
|
createCustomerAddress(recieveAddress);
|
||||||
|
|
||||||
|
emisWaybillSave.setCustomerCode(customerCode);
|
||||||
|
emisWaybillSave.setCustomerName(customerName);
|
||||||
|
|
||||||
|
// 获取泡重比
|
||||||
|
EmisTransLine emisTransLine = getTransLineByCode(emisWaybillSave.getTransLineType());
|
||||||
|
emisWaybillSave.setMeterType(emisTransLine.getMeterRate());
|
||||||
|
|
||||||
|
// 计算标准运费
|
||||||
|
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
||||||
|
BigDecimal totalRealFee = BigDecimal.ZERO;
|
||||||
|
if(!CollectionUtils.isEmpty(feeitemList)){
|
||||||
|
for (EmisWaybillFeeitem feeItem:feeitemList) {
|
||||||
|
|
||||||
|
BigDecimal realFee = feeItem.getFee();
|
||||||
|
// 汇率计算
|
||||||
|
if( !StringUtils.isEmpty(feeItem.getCurrency()) ){
|
||||||
|
EmisExchangeRate emisExchangeRate=emisExchangeRateMapper.getValidExchangeRate(feeItem.getCurrency(),"CNY");
|
||||||
|
|
||||||
|
if(emisExchangeRate!=null){
|
||||||
|
BigDecimal rate=BigDecimal.valueOf(Double.valueOf(emisExchangeRate.getRate()));
|
||||||
|
realFee=realFee.multiply(rate);
|
||||||
|
realFee=realFee.setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
// 汇率查不到的情况就不计算
|
||||||
|
else{
|
||||||
|
// realFee=BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalRealFee=totalRealFee.add(realFee);
|
||||||
|
}
|
||||||
|
|
||||||
|
totalRealFee=totalRealFee.setScale(2,BigDecimal.ROUND_HALF_UP);
|
||||||
|
emisWaybillSave.setRealFee(totalRealFee);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 时效
|
||||||
|
EmisTransProduct emisTransProduct = getTransProductByCode(emisWaybillSave.getProductType());
|
||||||
|
emisWaybillSave.setTimeType(emisTransProduct.getAgingDesc());
|
||||||
|
|
||||||
|
if(isNew && emisWaybillSave.getSendDate()==null){
|
||||||
|
emisWaybillSave.setSendDate(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开单当天不算时效
|
||||||
|
Date estDate = getEstimateDate(
|
||||||
|
emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),
|
||||||
|
emisWaybillSave.getSendCountry(),
|
||||||
|
emisWaybillSave.getReceiveCountry(),0);
|
||||||
|
|
||||||
|
// 预计到达时间
|
||||||
|
log.info("预估到达时间==>"+ DateUtils.dateTime(estDate));
|
||||||
|
emisWaybillSave.setEstimateDate(estDate);
|
||||||
|
|
||||||
|
// 子单号
|
||||||
|
if("1".equals(emisWaybillSave.getBlGenSubbill()) ){
|
||||||
|
// 子单号拼接
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for(int i=1;i<=emisWaybillSave.getParcelQty().intValue();i++){
|
||||||
|
sb.append(emisWaybillSave.getBillCode()+ StringUtils.leftPad(String.valueOf(i),4,"0")+",");
|
||||||
|
}
|
||||||
|
emisWaybillSave.setBillCodeSub(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 允许清除的信息
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getFeeRemark())){
|
||||||
|
emisWaybillSave.setFeeRemark(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getRemark())){
|
||||||
|
emisWaybillSave.setRemark(" ");
|
||||||
|
}
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getReceiveCity())){
|
||||||
|
emisWaybillSave.setReceiveCity(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getReceiveCounty())){
|
||||||
|
emisWaybillSave.setReceiveCounty(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getSendCity())){
|
||||||
|
emisWaybillSave.setSendCity(" ");
|
||||||
|
}
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getSendCounty())){
|
||||||
|
emisWaybillSave.setSendCounty(" ");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2087,11 +2469,27 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
private void addNewWaybillByApi(EmisWaybill emisWaybillSave) throws EmisBizError {
|
private void addNewWaybillByApi(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
// 公共计算部分
|
// 公共计算部分
|
||||||
calcWayBillCommonInfoByOms(emisWaybillSave,true);
|
calcWayBillCommonInfoByApi(emisWaybillSave,true);
|
||||||
|
|
||||||
// 插入运单数据
|
// 插入运单数据
|
||||||
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
||||||
|
|
||||||
|
|
||||||
|
// 绑定专属业务员
|
||||||
|
String bindEmpCode=emisWaybillSave.getTakePieceEmployeeCode();
|
||||||
|
if(StringUtils.isEmpty(bindEmpCode)){
|
||||||
|
bindEmpCode=emisWaybillSave.getOperateEmployeeCode();
|
||||||
|
}
|
||||||
|
String customerCode=emisWaybillSave.getCustomerCode();
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(bindEmpCode)&&!StringUtils.isEmpty(customerCode)) {
|
||||||
|
bindSalesmen(bindEmpCode,customerCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 扣减子单
|
||||||
|
emisElectronicSitePagService.realMatchSubBill(emisWaybillSave.getSendSiteCode(),"T7080",emisWaybillSave.getParcelQty());
|
||||||
|
|
||||||
// 产生主键插入其他数据
|
// 产生主键插入其他数据
|
||||||
// 插入费用
|
// 插入费用
|
||||||
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
||||||
@ -2101,6 +2499,34 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
emisWaybillFeeitemMapper.insertEmisWaybillFeeitem(feeItem);
|
emisWaybillFeeitemMapper.insertEmisWaybillFeeitem(feeItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插入揽收记录
|
||||||
|
ScanInfo scanInfo = new ScanInfo();
|
||||||
|
List<Map<String,Object>> scanDataList = new ArrayList<>();
|
||||||
|
scanInfo.setOpType(2);
|
||||||
|
scanInfo.setScanType(ScanType.GOT.opCode);
|
||||||
|
|
||||||
|
String dispatchOrSendManCode="";
|
||||||
|
if("1".equals(emisWaybillSave.getPickupMethod())){
|
||||||
|
dispatchOrSendManCode=emisWaybillSave.getOperateEmployeeCode();
|
||||||
|
}
|
||||||
|
else if("2".equals(emisWaybillSave.getPickupMethod())){
|
||||||
|
dispatchOrSendManCode=emisWaybillSave.getTakePieceEmployeeCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String,Object> scanDateItem = new HashMap<>();
|
||||||
|
scanDateItem.put("billCode",emisWaybillSave.getBillCode());
|
||||||
|
scanDateItem.put("dispatchOrSendManCode",dispatchOrSendManCode);
|
||||||
|
scanDateItem.put("scanDate", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,emisWaybillSave.getSendDate()));
|
||||||
|
scanDateItem.put("scanWeight", "0.0");
|
||||||
|
scanDataList.add(scanDateItem);
|
||||||
|
scanInfo.setScanData(scanDataList);
|
||||||
|
|
||||||
|
try {
|
||||||
|
emisTmsScanRecordService.scan(scanInfo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user