This commit is contained in:
linfso 2024-07-16 13:07:23 +08:00
parent b9cd424585
commit 0ba0c4038d
2 changed files with 145 additions and 111 deletions

View File

@ -2202,32 +2202,32 @@ public class EmisBaseService {
}else{
// 重复则只修改,不增加
EmisCustomerAddress queryObj=new EmisCustomerAddress();
queryObj.setCounty(emisCustomerAddressNew.getCounty());
queryObj.setName(emisCustomerAddressNew.getName());
queryObj.setPhone(emisCustomerAddressNew.getPhone());
queryObj.setProvince(emisCustomerAddressNew.getProvince());
queryObj.setCity(emisCustomerAddressNew.getCity());
queryObj.setCounty(emisCustomerAddressNew.getCounty());
queryObj.setAddressType(emisCustomerAddressNew.getAddressType());
queryObj.setAddress(emisCustomerAddressNew.getAddress());
queryObj.setCompany(emisCustomerAddressNew.getCompany());
List<EmisCustomerAddress> existList=emisCustomerAddressMapper.selectExistAddressList(queryObj);
// 重复数据需要修正地址的客户归属
if(existList!=null){
for (EmisCustomerAddress cusddress:existList) {
if(StringUtils.isEmpty(cusddress.getCustomerCode())){
// 增加使用站点
String useSiteCode = emisCustomerAddressNew.getUseSiteCode();
if(useSiteCode.indexOf(emisCustomerAddressNew.getUseSiteCode())==-1){
cusddress.setUseSiteCode(useSiteCode+","+emisCustomerAddressNew.getUseSiteCode());
}
cusddress.setCustomerCode(emisCustomerAddressNew.getCustomerCode());
emisCustomerAddressMapper.updateAddessCustomerCodeAndUseSite(cusddress);
}
}
}
// EmisCustomerAddress queryObj=new EmisCustomerAddress();
// queryObj.setCounty(emisCustomerAddressNew.getCounty());
// queryObj.setName(emisCustomerAddressNew.getName());
// queryObj.setPhone(emisCustomerAddressNew.getPhone());
// queryObj.setProvince(emisCustomerAddressNew.getProvince());
// queryObj.setCity(emisCustomerAddressNew.getCity());
// queryObj.setCounty(emisCustomerAddressNew.getCounty());
// queryObj.setAddressType(emisCustomerAddressNew.getAddressType());
// queryObj.setAddress(emisCustomerAddressNew.getAddress());
// queryObj.setCompany(emisCustomerAddressNew.getCompany());
//
// List<EmisCustomerAddress> existList=emisCustomerAddressMapper.selectExistAddressList(queryObj);
// // 重复数据需要修正地址的客户归属
// if(existList!=null){
// for (EmisCustomerAddress cusddress:existList) {
// if(StringUtils.isEmpty(cusddress.getCustomerCode())){
// // 增加使用站点
// String useSiteCode = emisCustomerAddressNew.getUseSiteCode();
// if(useSiteCode.indexOf(emisCustomerAddressNew.getUseSiteCode())==-1){
// cusddress.setUseSiteCode(useSiteCode+","+emisCustomerAddressNew.getUseSiteCode());
// }
// cusddress.setCustomerCode(emisCustomerAddressNew.getCustomerCode());
// emisCustomerAddressMapper.updateAddessCustomerCodeAndUseSite(cusddress);
// }
// }
// }
}

View File

@ -1054,39 +1054,61 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
emisWaybillSave.setOrderSn(orderSn);
}
// 登记网点
if(isNew) {
emisWaybillSave.setRegisterSiteCode(getCurrentUser().getOwnerSiteCode());
emisWaybillSave.setRegisterManCode(getCurrentUser().getEmpCode());
emisWaybillSave.setRegisterDate(new Date());
if( StringUtils.isAnyEmpty(
emisWaybillSave.getTransLineType(),
emisWaybillSave.getProductType()
)
) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路、产品必填");
}
if(isNew) {
emisWaybillSave.setDataFrom(WaybillHelper.getDataFrom());
}
if(emisWaybillSave.getFreight().floatValue()<=0.0f){
// 检查数据
if(emisWaybillSave.getFreight()==null || emisWaybillSave.getFreight().floatValue()<=0.0f){
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"运费必须大于0");
}
if (emisWaybillSave.getSettlementWeight().floatValue() <= 0.0f
|| emisWaybillSave.getTotalVolume().floatValue() <= 0.0f
|| emisWaybillSave.getBillWeight().floatValue() <= 0.0f
|| emisWaybillSave.getVolumeWeight().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(StringUtils.isAnyEmpty(
emisWaybillSave.getPickupMethod(),
emisWaybillSave.getDispatchMethod(),
emisWaybillSave.getCustomsEclaration(),
emisWaybillSave.getCustomsClear()
)
){
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"取件方式,派送方式,报关方式,清关方式必填");
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,"计费方式必填");
}
@ -1096,22 +1118,81 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件网点必填");
}
// 寄件网点财务中心
EmisSite sendSite = getSiteByCode(emisWaybillSave.getSendSiteCode());
if(sendSite!=null) {
emisWaybillSave.setSendCenterCode(sendSite.getParentSiteCode());
// 寄件地址
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 ){
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(getCurrentUser().getOwnerSiteCode());
emisWaybillSave.setRegisterManCode(getCurrentUser().getEmpCode());
emisWaybillSave.setRegisterDate(new Date());
}
if(isNew) {
emisWaybillSave.setDataFrom(WaybillHelper.getDataFrom());
}
// 寄件网点财务中心
EmisSite sendSite = getSiteByCode(emisWaybillSave.getSendSiteCode());
if(sendSite!=null) {
emisWaybillSave.setSendCenterCode(sendSite.getParentSiteCode());
}
// 订单运单初始状态 订单为已接单,运单未初始,待揽收
emisWaybillSave.setOrderStatus("1");
emisWaybillSave.setWaybillStatus("0");
@ -1144,18 +1225,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
// 订单类型为正式单
emisWaybillSave.setOrderType("1");
// 寄件地址
if(StringUtils.isAnyEmpty(
emisWaybillSave.getSendCountry(),
emisWaybillSave.getSendName(),
emisWaybillSave.getSendMobile(),
emisWaybillSave.getSendProvince(),
emisWaybillSave.getSendAddress()
)
){
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"寄件人信息不完整,名称, 电话,国家,省份,地址必填");
}
// 发件地址
EmisCustomerAddress sendAddress = new EmisCustomerAddress();
sendAddress.setCountry(emisWaybillSave.getSendCountry());
sendAddress.setName(emisWaybillSave.getSendName());
@ -1171,19 +1241,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
sendAddress.setUseSiteCode(emisWaybillSave.getSendSiteCode());
sendAddress.setAddressType("1");
// 收件地址
if(StringUtils.isAnyEmpty(
emisWaybillSave.getReceiveCountry(),
emisWaybillSave.getReceiveName(),
emisWaybillSave.getReceiveMobile(),
emisWaybillSave.getReceiveProvince(),
emisWaybillSave.getReceiveAddress()
)
){
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"收件人信息不完整,名称, 电话,国家,省份,地址必填");
}
EmisCustomerAddress recieveAddress = new EmisCustomerAddress();
recieveAddress.setCountry(emisWaybillSave.getReceiveCountry());
recieveAddress.setName(emisWaybillSave.getReceiveName());
@ -1203,10 +1262,6 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
String customerCode=null;
String customerName=null;
if( emisWaybillSave.getPaymentType()==null) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"支付方式必填");
}
// 月结客户直接根据月结编号获取客户编码和名称
if(
"2".equals(emisWaybillSave.getPaymentType())
@ -1249,6 +1304,9 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
newEmisCustomerUser.setSettledType("1");
newEmisCustomerUser.setUserType("1");
newEmisCustomerUser.setBlOpenOms("0");
newEmisCustomerUser.setRemark("开单自动生成的现金用户");
// 预置主归属网点
newEmisCustomerUser.setOwnerSite(emisWaybillSave.getSendSiteCode());
EmisCustomerUser newUser=createCustomerUser(newEmisCustomerUser);
@ -1300,24 +1358,15 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
}
// 保存客户收件、寄件地址
sendAddress.setCustomerCode(customerCode);
recieveAddress.setCustomerCode(customerCode);
// 保存客户收件、寄件地址,开单不要关联客户地址数据
// sendAddress.setCustomerCode(customerCode);
// recieveAddress.setCustomerCode(customerCode);
createCustomerAddress(sendAddress);
createCustomerAddress(recieveAddress);
emisWaybillSave.setCustomerCode(customerCode);
emisWaybillSave.setCustomerName(customerName);
if( StringUtils.isAnyEmpty(
emisWaybillSave.getTransLineType(),
emisWaybillSave.getProductType()
)
) {
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"线路、产品必填");
}
// 获取泡重比
EmisTransLine emisTransLine = getTransLineByCode(emisWaybillSave.getTransLineType());
@ -1331,11 +1380,8 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
emisWaybillSave.setSendDate(new Date());
}
if(isNew) {
if( emisWaybillSave.getSendDate()==null ){
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR1,"发件日期必填");
}
}
// 开单当天不算时效
Date estDate = getEstimateDate(
emisWaybillSave.getSendDate(),emisWaybillSave.getProductType(),
@ -1372,19 +1418,7 @@ public class EmisWaybillServiceImpl extends EmisBaseService implements IEmisWayb
}
}
// 判断网点余额-运单金额 是否足够,如果不够则不允许下单
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, "网点余额不足,请充值");
}
// 公共计算部分
calcWayBillCommonInfo(emisWaybillSave,true);