md
This commit is contained in:
parent
15c7d8c4c9
commit
fae80076bc
@ -98,6 +98,8 @@ public interface IEmisWaybillService
|
|||||||
public int draftSubmitOrder(EmisWaybill emisWaybill,boolean isOms) throws EmisBizError;
|
public int draftSubmitOrder(EmisWaybill emisWaybill,boolean isOms) throws EmisBizError;
|
||||||
|
|
||||||
|
|
||||||
|
public int realMatchOrderApi(EmisWaybill emisWaybillSave) throws EmisBizError;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下单
|
* 下单
|
||||||
* @param emisWaybill
|
* @param emisWaybill
|
||||||
|
|||||||
@ -319,6 +319,255 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API下单方式
|
||||||
|
* @param emisWaybillSave
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int realMatchOrderApi(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
// 如果没有单号就生成单号,如果有单号需要判断是否重复
|
||||||
|
if( !StringUtils.isEmpty(emisWaybillSave.getBillCode()) ) {
|
||||||
|
boolean isExists = this.checkWaybillIsExists(emisWaybillSave.getBillCode());
|
||||||
|
if (isExists) {
|
||||||
|
throw new EmisBizError(EmisBizErrorType.EXISTS, "运单号重复");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 转换api数据到真实数据
|
||||||
|
cvtRealMatchOrderApiToReal(emisWaybillSave);
|
||||||
|
|
||||||
|
String sendSiteCode=null;
|
||||||
|
sendSiteCode=emisWaybillSave.getSendSiteCode();
|
||||||
|
emisWaybillSave.setSendSiteCode(sendSiteCode);
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(sendSiteCode)){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "寄件地址不在网点服务区");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getBillCode()) ) {
|
||||||
|
// 生成新的运单号
|
||||||
|
String waybillNo = emisElectronicSitePagService.realMatchWaybill(sendSiteCode, "T7080");
|
||||||
|
emisWaybillSave.setBillCode(waybillNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
addNewWaybillByApi(emisWaybillSave);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换API下单数据到真实数据
|
||||||
|
* @param emisWaybillSave
|
||||||
|
* @throws EmisBizError
|
||||||
|
*/
|
||||||
|
private void cvtRealMatchOrderApiToReal(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
// 货物名称必填
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getGoodsInfo())){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货物描述不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 运费必填
|
||||||
|
if(emisWaybillSave.getFreight() == null || (
|
||||||
|
emisWaybillSave.getFreight()!=null && emisWaybillSave.getFreight().compareTo(BigDecimal.ZERO)==0 ) ){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 货值必填
|
||||||
|
if(StringUtils.isEmpty(emisWaybillSave.getRealValue()) ){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1, "货值必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 线路转换
|
||||||
|
EmisTransLine transLine=getTransLineByName(emisWaybillSave.getTransLineType());
|
||||||
|
if(transLine==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "线路不正确");
|
||||||
|
}
|
||||||
|
emisWaybillSave.setTransLineType(transLine.getLineCode());
|
||||||
|
|
||||||
|
// 产品转换
|
||||||
|
EmisTransProduct transProduct=getTransProductByName(transLine.getLineCode(),emisWaybillSave.getProductType());
|
||||||
|
if(transProduct==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "产品不正确");
|
||||||
|
}
|
||||||
|
emisWaybillSave.setProductType(transProduct.getProdCode());
|
||||||
|
|
||||||
|
// 收件国家省市区转换
|
||||||
|
String receiveCountryCode=getCountryCodeByName(emisWaybillSave.getReceiveCountry());
|
||||||
|
if(receiveCountryCode==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "收件国家不正确");
|
||||||
|
}
|
||||||
|
String rcvProviceCode=getChildRegionCodeByName(receiveCountryCode,null,emisWaybillSave.getReceiveProvince());
|
||||||
|
if(rcvProviceCode==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "收件省不正确");
|
||||||
|
}
|
||||||
|
String rcvCityCode=getChildRegionCodeByName(receiveCountryCode,rcvProviceCode,emisWaybillSave.getReceiveCity());
|
||||||
|
String rcvDistrictCode=getChildRegionCodeByName(receiveCountryCode,rcvCityCode,emisWaybillSave.getReceiveCounty());
|
||||||
|
|
||||||
|
emisWaybillSave.setReceiveCountry(receiveCountryCode);
|
||||||
|
emisWaybillSave.setReceiveProvince(rcvProviceCode);
|
||||||
|
emisWaybillSave.setReceiveCity(rcvCityCode);
|
||||||
|
emisWaybillSave.setReceiveCounty(rcvDistrictCode);
|
||||||
|
|
||||||
|
// 寄件国家省市区
|
||||||
|
String sendCountryCode=getCountryCodeByName(emisWaybillSave.getSendCountry());
|
||||||
|
if(sendCountryCode==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件国家不正确");
|
||||||
|
}
|
||||||
|
String sendProviceCode=getChildRegionCodeByName(sendCountryCode,null,emisWaybillSave.getSendProvince());
|
||||||
|
if(sendProviceCode==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件省不正确");
|
||||||
|
}
|
||||||
|
String sendCityCode=getChildRegionCodeByName(sendCountryCode,sendProviceCode,emisWaybillSave.getSendCity());
|
||||||
|
String sendDistrictCode=getChildRegionCodeByName(sendCountryCode,sendCityCode,emisWaybillSave.getSendCounty());
|
||||||
|
|
||||||
|
emisWaybillSave.setSendCountry(sendCountryCode);
|
||||||
|
emisWaybillSave.setSendProvince(sendProviceCode);
|
||||||
|
emisWaybillSave.setSendCity(sendCityCode);
|
||||||
|
emisWaybillSave.setSendCounty(sendDistrictCode);
|
||||||
|
|
||||||
|
// 计算目的地,寄件网点自动填充
|
||||||
|
// EmisDestination sendDestination=calcSendSiteByBase(sendCountryCode,transLine.getLineCode(),sendProviceCode,sendCityCode,sendDistrictCode,emisWaybillSave.getSendAddress());
|
||||||
|
// if(sendDestination==null){
|
||||||
|
// throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "寄件地址不在服务区");
|
||||||
|
// }
|
||||||
|
// emisWaybillSave.setSendSiteCode(sendDestination.getSiteCode());
|
||||||
|
// emisWaybillSave.setSendSiteName(sendDestination.getSiteName());
|
||||||
|
|
||||||
|
// 取件方式
|
||||||
|
String pickupMethod=DictUtils.getDictValue("emis_qujian_fangshi",emisWaybillSave.getPickupMethod());
|
||||||
|
if(pickupMethod==null){
|
||||||
|
pickupMethod="2";// 上门取件
|
||||||
|
}
|
||||||
|
emisWaybillSave.setPickupMethod(pickupMethod);
|
||||||
|
|
||||||
|
// 取件员或操作员
|
||||||
|
if(!StringUtils.isEmpty(emisWaybillSave.getOperateEmployeeCode())) {
|
||||||
|
if ("1".equals(pickupMethod)) {
|
||||||
|
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(emisWaybillSave.getSendSiteCode(), emisWaybillSave.getOperateEmployeeCode());
|
||||||
|
if (empUser != null) {
|
||||||
|
emisWaybillSave.setOperateEmployeeCode(empUser.getEmpCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ("2".equals(pickupMethod)) {
|
||||||
|
SysUser empUser = getEmisStaffBySiteCodeAndEmpName(emisWaybillSave.getSendSiteCode(), emisWaybillSave.getOperateEmployeeCode());
|
||||||
|
if (empUser != null) {
|
||||||
|
emisWaybillSave.setTakePieceEmployeeCode(empUser.getEmpCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 包装类型
|
||||||
|
String packTypeStr = emisWaybillSave.getPackType();
|
||||||
|
if(StringUtils.isEmpty(packTypeStr)){
|
||||||
|
packTypeStr="纸箱";
|
||||||
|
}
|
||||||
|
|
||||||
|
packTypeStr=WaybillHelper.formatQueryValue(packTypeStr);
|
||||||
|
|
||||||
|
String packTypeCvtStr="";
|
||||||
|
String [] packTypeArr = packTypeStr.split(",");
|
||||||
|
if(packTypeArr.length>0){
|
||||||
|
for(String itemLabel:packTypeArr){
|
||||||
|
if(StringUtils.isEmpty(itemLabel)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String dictValue=DictUtils.getDictValue("emis_tab_packing_type",itemLabel.trim());
|
||||||
|
if(!StringUtils.isEmpty(dictValue)){
|
||||||
|
packTypeCvtStr = packTypeCvtStr + dictValue + ",";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emisWaybillSave.setPackType(packTypeCvtStr);
|
||||||
|
|
||||||
|
// 派送方式
|
||||||
|
String dispatchMethod=DictUtils.getDictValue("emis_tab_dispatch_mode",emisWaybillSave.getDispatchMethod());
|
||||||
|
if(dispatchMethod==null){
|
||||||
|
emisWaybillSave.setDispatchMethod("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 付款方式
|
||||||
|
String paymentType=DictUtils.getDictValue("emis_payment_type",emisWaybillSave.getPaymentType());
|
||||||
|
if(paymentType==null){
|
||||||
|
emisWaybillSave.setPaymentType("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 月结方式获取月结客户的编码和名称
|
||||||
|
if("2".equals(paymentType)
|
||||||
|
|| "4".equals(paymentType)
|
||||||
|
|| "5".equals(paymentType)
|
||||||
|
){
|
||||||
|
EmisCustomerUser emisCustomerUser=getMonthCustomerByName(emisWaybillSave.getCustNo());
|
||||||
|
if(emisCustomerUser==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "月结客户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
emisWaybillSave.setCustomerCode(emisCustomerUser.getCustomerCode());
|
||||||
|
emisWaybillSave.setCustomerName(emisCustomerUser.getCustomerName());
|
||||||
|
|
||||||
|
emisWaybillSave.setCustNo(emisCustomerUser.getMonthlyPayCode());
|
||||||
|
emisWaybillSave.setPayee(emisCustomerUser.getPayee());
|
||||||
|
emisWaybillSave.setSalesmen(emisCustomerUser.getSalesmen());
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
emisWaybillSave.setCustNo(null);
|
||||||
|
// 判断现金的回款联系人和销售联系人
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 报关方式
|
||||||
|
String customsEclaration=DictUtils.getDictValue("emis_declare_mode",emisWaybillSave.getCustomsEclaration());
|
||||||
|
if(customsEclaration==null){
|
||||||
|
customsEclaration="1";
|
||||||
|
}
|
||||||
|
emisWaybillSave.setCustomsEclaration(customsEclaration);
|
||||||
|
|
||||||
|
// 清关方式
|
||||||
|
String customsClear=DictUtils.getDictValue("emis_customs_clear",emisWaybillSave.getCustomsClear());
|
||||||
|
if(customsClear==null){
|
||||||
|
customsClear="1";
|
||||||
|
}
|
||||||
|
emisWaybillSave.setCustomsClear(customsClear);
|
||||||
|
|
||||||
|
// "发送寄件/签收短信不正确"
|
||||||
|
emisWaybillSave.setBlMessage("1");
|
||||||
|
|
||||||
|
|
||||||
|
// 计算目的地
|
||||||
|
EmisDestination destination=calcDestSiteByBase(receiveCountryCode,transLine.getLineCode(),rcvProviceCode,rcvCityCode,rcvDistrictCode,emisWaybillSave.getReceiveAddress());
|
||||||
|
if(destination==null){
|
||||||
|
throw new EmisBizError(EmisBizErrorType.NOT_EXISTS, "找不到目的地");
|
||||||
|
}
|
||||||
|
|
||||||
|
emisWaybillSave.setDestinationCode(destination.getDestCode());
|
||||||
|
emisWaybillSave.setDispatchUnderlingSiteCode(destination.getSiteCode());
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 计算体积重量
|
||||||
|
calcVolumeWeight(emisWaybillSave);
|
||||||
|
// 计算结算重量
|
||||||
|
calcSettledWeight(emisWaybillSave);
|
||||||
|
// 计算应收费
|
||||||
|
calcWaybillFee(emisWaybillSave);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
log.error("===api下单模式,计费错误:",ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果填写了运费则使用一口价模式
|
||||||
|
emisWaybillSave.setCalcFeeType("1");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 转换草稿数据到真实数据
|
* 转换草稿数据到真实数据
|
||||||
@ -329,7 +578,7 @@ 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, "货物描述不能为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 运费必填
|
// 运费必填
|
||||||
@ -1831,6 +2080,29 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api 新开单
|
||||||
|
* @param emisWaybillSave
|
||||||
|
*/
|
||||||
|
private void addNewWaybillByApi(EmisWaybill emisWaybillSave) throws EmisBizError {
|
||||||
|
|
||||||
|
// 公共计算部分
|
||||||
|
calcWayBillCommonInfoByOms(emisWaybillSave,true);
|
||||||
|
|
||||||
|
// 插入运单数据
|
||||||
|
emisWaybillMapper.insertEmisWaybill(emisWaybillSave);
|
||||||
|
|
||||||
|
// 产生主键插入其他数据
|
||||||
|
// 插入费用
|
||||||
|
List<EmisWaybillFeeitem> feeitemList=emisWaybillSave.getFeeitemList();
|
||||||
|
if(!CollectionUtils.isEmpty(feeitemList)){
|
||||||
|
for (EmisWaybillFeeitem feeItem:feeitemList) {
|
||||||
|
feeItem.setWaybillId(emisWaybillSave.getId());
|
||||||
|
emisWaybillFeeitemMapper.insertEmisWaybillFeeitem(feeItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 运单修改更新
|
* 运单修改更新
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user