纪新园 2 лет назад
Родитель
Сommit
2a0b33da67

+ 55 - 55
blade-service/blade-box-tube/src/main/java/org/springblade/box/tube/service/impl/TradingBoxServiceImpl.java

@@ -177,11 +177,10 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						tradingBoxFees.setItemName(r.getData().getCname());
 						tradingBoxFees.setItemName(r.getData().getCname());
 					}
 					}
 				}
 				}
-
-				/*CorpsDesc corpsDesc = corpsDescClient.getCorpId(tradingBoxFees.getCorpId());
+				CorpsDesc corpsDesc = corpsDescClient.getCorpId(tradingBoxFees.getCorpId());
 				if (ObjectUtils.isNotNull(corpsDesc)) {
 				if (ObjectUtils.isNotNull(corpsDesc)) {
 					tradingBoxFees.setCorpName(corpsDesc.getCname());
 					tradingBoxFees.setCorpName(corpsDesc.getCname());
-				}*/
+				}
 			}
 			}
 			details.setTradingBoxFeesList(tradingBoxFeesList);
 			details.setTradingBoxFeesList(tradingBoxFeesList);
 
 
@@ -516,13 +515,13 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				if (tradingBoxItem.getId() == null) {
 				if (tradingBoxItem.getId() == null) {
 
 
 					LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
 					LambdaQueryWrapper<TradingBoxItem> tradingBoxItemLambdaQueryWrapper = new LambdaQueryWrapper<>();
-					tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getIsDeleted,0)
-						.eq(TradingBoxItem::getTenantId,AuthUtil.getTenantId())
-						.eq(TradingBoxItem::getPid,tradingBox.getId())
-						.eq(TradingBoxItem::getCode,tradingBoxItem.getCode());
+					tradingBoxItemLambdaQueryWrapper.eq(TradingBoxItem::getIsDeleted, 0)
+						.eq(TradingBoxItem::getTenantId, AuthUtil.getTenantId())
+						.eq(TradingBoxItem::getPid, tradingBox.getId())
+						.eq(TradingBoxItem::getCode, tradingBoxItem.getCode());
 					List<TradingBoxItem> tradingBoxItemList1 = tradingBoxItemMapper.selectList(tradingBoxItemLambdaQueryWrapper);
 					List<TradingBoxItem> tradingBoxItemList1 = tradingBoxItemMapper.selectList(tradingBoxItemLambdaQueryWrapper);
-					if (ObjectUtils.isNotNull(tradingBoxItemList1) && tradingBoxItemList1.size()>0){
-						throw new RuntimeException("箱号:"+tradingBoxItem.getCode()+"已存在,保存失败");
+					if (ObjectUtils.isNotNull(tradingBoxItemList1) && tradingBoxItemList1.size() > 0) {
+						throw new RuntimeException("箱号:" + tradingBoxItem.getCode() + "已存在,保存失败");
 					}
 					}
 					if (tradingBox.getType().equals("ZR")) {
 					if (tradingBox.getType().equals("ZR")) {
 						if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate())) {
 						if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate())) {
@@ -546,47 +545,6 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 					tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
 					tradingBoxItem.setCreateUserName(AuthUtil.getUserName());
 					tradingBoxItem.setTenantId(AuthUtil.getTenantId());
 					tradingBoxItem.setTenantId(AuthUtil.getTenantId());
 					tradingBoxItem.setPid(tradingBox.getId());
 					tradingBoxItem.setPid(tradingBox.getId());
-
-					//计算租金费用
-					TradingBoxFees tradingBoxFees = new TradingBoxFees();
-					tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
-					tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
-					tradingBoxFees.setAmount(tradingBoxItem.getAmount());
-					tradingBoxFees.setPrice(tradingBoxItem.getAmount());
-					tradingBoxFees.setQuantity(BigDecimal.valueOf(tradingBoxItem.getOverdueDays()));
-					tradingBoxFees.setCurrency(tradingBoxItem.getCurrency());
-					tradingBoxFees.setCode(tradingBoxItem.getCode());
-					tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
-					//获取费用id
-					R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
-					if (fees.isSuccess() && fees.getData() != null) {
-						tradingBoxFees.setItemId(fees.getData().getId());
-					}
-					if ("ZR".equals(tradingBox.getType())) {
-						tradingBoxFees.setFeesType(2);
-						tradingBoxFees.setBillType("租入");
-					} else {
-						tradingBoxFees.setFeesType(1);
-						tradingBoxFees.setBillType("租出");
-					}
-					tradingBoxFees.setPid(tradingBox.getId());
-					tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
-					tradingBoxFees.setUnit(tradingBoxItem.getBoxType());
-					tradingBoxFees.setExchangeRate(new BigDecimal(1));
-					if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate()) && ObjectUtils.isNotNull(tradingBoxItem.getOverdueDays())) {
-						Calendar calendar = new GregorianCalendar();
-						calendar.setTime(tradingBoxItem.getLeaseCommencementDate());
-						calendar.add(Calendar.DATE, tradingBoxItem.getOverdueDays());
-						tradingBoxFees.setRentStartDate(calendar.getTime());
-						tradingBoxItem.setRentEndDate(calendar.getTime());
-					}
-					tradingBoxFees.setRentEndDate(tradingBox.getRentCalculationDate());
-					tradingBoxFees.setCreateUser(AuthUtil.getUserId());
-					tradingBoxFees.setCreateTime(new Date());
-					tradingBoxFees.setTenantId(AuthUtil.getTenantId());
-					tradingBoxFees.setSubmitPay(0);
-					tradingBoxFeesMapper.insert(tradingBoxFees);
-
 					tradingBoxItemMapper.insert(tradingBoxItem);
 					tradingBoxItemMapper.insert(tradingBoxItem);
 				} else {
 				} else {
 					if (tradingBox.getType().equals("ZR") && "录入".equals(tradingBoxItem.getStatus())) {
 					if (tradingBox.getType().equals("ZR") && "录入".equals(tradingBoxItem.getStatus())) {
@@ -1072,6 +1030,48 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
 			tradingBoxItem.setUpdateUserName(AuthUtil.getUserName());
 			if ("1".equals(tradingBox.getRentType())) {
 			if ("1".equals(tradingBox.getRentType())) {
 				tradingBoxItem.setLeaseCommencementDate(tradingBox.getRentDate());
 				tradingBoxItem.setLeaseCommencementDate(tradingBox.getRentDate());
+				if (ObjectUtils.isNotNull(tradingBoxItem.getLeaseCommencementDate()) && ObjectUtils.isNotNull(tradingBoxItem.getOverdueDays())) {
+					//计算租金费用
+					TradingBoxFees tradingBoxFees = new TradingBoxFees();
+					tradingBoxFees.setCorpId(tradingBox.getPurchaseCompanyId());
+					tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
+					tradingBoxFees.setAmount(tradingBoxItem.getAmount());
+					tradingBoxFees.setPrice(tradingBoxItem.getAmount());
+					tradingBoxFees.setQuantity(BigDecimal.valueOf(tradingBoxItem.getOverdueDays()));
+					tradingBoxFees.setCurrency(tradingBoxItem.getCurrency());
+					tradingBoxFees.setCode(tradingBoxItem.getCode());
+					tradingBoxFees.setCorpName(tradingBox.getPurchaseCompanyName());
+					//获取费用id
+					R<FeesDesc> fees = feesDescClient.getFeesByName("租金");
+					if (fees.isSuccess() && fees.getData() != null) {
+						tradingBoxFees.setItemId(fees.getData().getId());
+					}
+					if ("ZR".equals(tradingBox.getType())) {
+						tradingBoxFees.setFeesType(2);
+						tradingBoxFees.setBillType("租入");
+					} else {
+						tradingBoxFees.setFeesType(1);
+						tradingBoxFees.setBillType("租出");
+					}
+					tradingBoxFees.setPid(tradingBox.getId());
+					tradingBoxFees.setSrcOrderNo(tradingBox.getContractNo());
+					tradingBoxFees.setUnit(tradingBoxItem.getBoxType());
+					tradingBoxFees.setExchangeRate(new BigDecimal(1));
+
+					Calendar calendar = new GregorianCalendar();
+					calendar.setTime(tradingBoxItem.getLeaseCommencementDate());
+					calendar.add(Calendar.DATE, tradingBoxItem.getOverdueDays());
+
+					tradingBoxFees.setRentStartDate(tradingBoxItem.getLeaseCommencementDate());
+					tradingBoxFees.setRentEndDate(calendar.getTime());
+					tradingBoxFees.setCreateUser(AuthUtil.getUserId());
+					tradingBoxFees.setCreateTime(new Date());
+					tradingBoxFees.setTenantId(AuthUtil.getTenantId());
+					tradingBoxFees.setSubmitPay(0);
+					tradingBoxFeesMapper.insert(tradingBoxFees);
+
+					tradingBoxItem.setRentEndDate(calendar.getTime());
+				}
 				if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
 				if (ObjectUtils.isNotNull(tradingBoxItem.getCode())) {
 					//更新箱档案信息
 					//更新箱档案信息
 					Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
 					Archives archivesR = archivesMapper.selectOne(new LambdaQueryWrapper<Archives>().eq(Archives::getIsDeleted, 0).eq(Archives::getTenantId, AuthUtil.getTenantId()).eq(Archives::getCode, tradingBoxItem.getCode()));
@@ -1130,7 +1130,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 						}
 						}
 						archivesTrajectory.setStatus("租入");
 						archivesTrajectory.setStatus("租入");
 						tradingBoxItem.setStatus("待使用");
 						tradingBoxItem.setStatus("待使用");
-						tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
+//						tradingBoxItem.setRentEndDate(tradingBoxItem.getLeaseCommencementDate());
 					} else {
 					} else {
 						archives.setBoxAccessStatus("空箱离场");
 						archives.setBoxAccessStatus("空箱离场");
 						archives.setStatus("使用");
 						archives.setStatus("使用");
@@ -1804,7 +1804,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 		if (tradingBoxs.getId() == null) {
 		if (tradingBoxs.getId() == null) {
 			throw new RuntimeException("缺少必要参数");
 			throw new RuntimeException("缺少必要参数");
 		}
 		}
-		if ("JK".equals(tradingBoxs.getType()) || "CK".equals(tradingBoxs.getType())){
+		if ("JK".equals(tradingBoxs.getType()) || "CK".equals(tradingBoxs.getType())) {
 			Transport transport = transportMapper.selectById(tradingBoxs.getId());
 			Transport transport = transportMapper.selectById(tradingBoxs.getId());
 			Long pid = tradingBoxs.getId();
 			Long pid = tradingBoxs.getId();
 
 
@@ -1908,7 +1908,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				}
 				}
 			}
 			}
 			return R.data(transport);
 			return R.data(transport);
-		}else{
+		} else {
 			TradingBox tradingBox = baseMapper.selectById(tradingBoxs.getId());
 			TradingBox tradingBox = baseMapper.selectById(tradingBoxs.getId());
 			Long pid = tradingBoxs.getId();
 			Long pid = tradingBoxs.getId();
 
 
@@ -2019,7 +2019,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 
 
 	@Override
 	@Override
 	public R revokeBill(TradingBox tradingBox) {
 	public R revokeBill(TradingBox tradingBox) {
-		if ("JKFC".equals(tradingBox.getType()) || "CKZY".equals(tradingBox.getType())){
+		if ("JKFC".equals(tradingBox.getType()) || "CKZY".equals(tradingBox.getType())) {
 			Transport selectTransport = transportMapper.selectById(tradingBox.getId());
 			Transport selectTransport = transportMapper.selectById(tradingBox.getId());
 			if (selectTransport == null) {
 			if (selectTransport == null) {
 				throw new SecurityException("撤销失败,未找到主表信息");
 				throw new SecurityException("撤销失败,未找到主表信息");
@@ -2050,7 +2050,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				throw new SecurityException("撤销失败,请选择费用明细");
 				throw new SecurityException("撤销失败,请选择费用明细");
 			}
 			}
 			return R.data(selectTransport);
 			return R.data(selectTransport);
-		}else{
+		} else {
 			TradingBox selectTradingBox = baseMapper.selectById(tradingBox.getId());
 			TradingBox selectTradingBox = baseMapper.selectById(tradingBox.getId());
 			if (selectTradingBox == null) {
 			if (selectTradingBox == null) {
 				throw new SecurityException("撤销失败,未找到主表信息");
 				throw new SecurityException("撤销失败,未找到主表信息");