This commit is contained in:
wujinliang
2026-09-18 09:16:02 +08:00
parent 522afd0185
commit 6be4e764a9
11 changed files with 211 additions and 27 deletions
@@ -33,6 +33,7 @@ public class CustomerAddressService {
@Transactional
public Long create(long tenantId, long userId, CustomerAddressDtos.SaveRequest request) {
ensureNoDuplicate(tenantId, request, null);
CustomerAddressEntity value = new CustomerAddressEntity();
value.setId(IdWorker.getId());
value.setTenantId(tenantId);
@@ -51,6 +52,7 @@ public class CustomerAddressService {
if (!value.getAddressType().equals(request.addressType())) {
throw new BizException(ResultCode.VALIDATION_FAILED, "地址类型创建后不可修改");
}
ensureNoDuplicate(tenantId, request, id);
if (request.defaultAddress()) clearDefault(tenantId, request.addressType(), id);
apply(value, request);
value.setUpdatedBy(userId);
@@ -99,6 +101,25 @@ public class CustomerAddressService {
.set(CustomerAddressEntity::getDefaultAddress, false));
}
private void ensureNoDuplicate(long tenantId, CustomerAddressDtos.SaveRequest request, Long excludedId) {
boolean duplicate = mapper.selectList(new LambdaQueryWrapper<CustomerAddressEntity>()
.eq(CustomerAddressEntity::getTenantId, tenantId)
.eq(CustomerAddressEntity::getActive, true)
.eq(CustomerAddressEntity::getAddressType, request.addressType())
.eq(CustomerAddressEntity::getCompanyName, request.companyName().trim())
.eq(CustomerAddressEntity::getContactName, request.contactName().trim())
.eq(CustomerAddressEntity::getPhone, request.phone().trim())
.eq(CustomerAddressEntity::getCountryCode, request.countryCode().trim().toUpperCase())
.eq(CustomerAddressEntity::getCity, request.city().trim())
.eq(CustomerAddressEntity::getAddressLine, request.addressLine().trim())
.ne(excludedId != null, CustomerAddressEntity::getId, excludedId))
.stream().findAny().isPresent();
if (duplicate) {
throw new BizException(ResultCode.CONFLICT, "PICKUP".equals(request.addressType())
? "相同的企业提货地址已存在" : "相同的企业私人仓地址已存在");
}
}
private static void apply(CustomerAddressEntity value, CustomerAddressDtos.SaveRequest source) {
value.setAddressType(source.addressType()); value.setAddressName(source.addressName().trim());
value.setCompanyName(source.companyName().trim()); value.setContactName(source.contactName().trim());
@@ -324,11 +324,11 @@ public class UnifiedOrderQueryService {
order.getDestinationWarehouseId(), order.getDestinationWarehouseName(), null, null,
order.getInboundCode(),
order.getExpectedShipDate(), null, null, totalPackageCount(cargo), null, null,
order.getEstimatedVolumeCbm(), volumeCbm(cargo), null, null,
order.getEstimatedVolumeCbm(), volumeCbm(cargo), grossWeightKg(cargo), volumeCbm(cargo),
order.getExpectedArrivalAt(), null, null, null, order.getFulfillmentType(), order.getLxCode(),
order.getPickupMethod(), order.getTaxMode(), order.getContainerMode(),
order.getCustomsInspection(), order.getDestinationType(), order.getAmazonWarehouseCode(),
null, null, null, null, null, null, null, order.getExpressCompany(), order.getExpressTrackingNo(),
null, null, null, null, netWeightKg(cargo), null, null, order.getExpressCompany(), order.getExpressTrackingNo(),
StringUtils.hasText(creatorName) ? creatorName : string(order.getCreatedBy()), skuNos(cargo), totalQuantity(cargo), shipmentId(order, cargo), referenceId(order, cargo),
null, null, null, null, null, coLoadGroup,
order.getCustomerRemark(), latestInternalNote, order.getWarehouseRemark(), order.getCustomerServiceRemark(),
@@ -348,13 +348,14 @@ public class UnifiedOrderQueryService {
displayedPackageCount(order, cargo, inbound), null,
distinctLocationCodes(inbound.locationCodes()),
order.getEstimatedVolumeCbm(), volumeCbm(cargo),
inbound.actualGrossWeightKg(), inbound.actualVolumeCbm(),
measuredOrDeclared(inbound.actualGrossWeightKg(), grossWeightKg(cargo)),
measuredOrDeclared(inbound.actualVolumeCbm(), volumeCbm(cargo)),
order.getExpectedArrivalAt() != null ? order.getExpectedArrivalAt() : inbound.expectedArrivalAt(), inbound.feeReviewStatus(),
inbound.companyName(), inbound.businessType(), inbound.fulfillmentType(), inbound.lxCode(),
order.getPickupMethod(), inbound.taxMode(), inbound.containerMode(),
inbound.customsInspection(), inbound.destinationType(), inbound.destinationCode(), inbound.palletCount(),
inbound.chargeableWeightKg(), inbound.chargeableVolumeCbm(), inbound.volumeWeightKg(),
inbound.actualNetWeightKg(),
measuredOrDeclared(inbound.actualNetWeightKg(), netWeightKg(cargo)),
inbound.measureCompletedAt(), inbound.inboundedAt(), inbound.expressCompanyName(), inbound.expressTrackingNo(),
StringUtils.hasText(creatorName) ? creatorName : inbound.createdByName(), skuNos(cargo), totalQuantity(cargo), shipmentId(order, cargo), referenceId(order, cargo), measurement(inbound),
preload(summary.preload()), loading(summary.loading()),
@@ -378,13 +379,14 @@ public class UnifiedOrderQueryService {
inbound.id(), inbound.version(), inbound.inboundCode(), null, inbound.holdFlag(), inbound.currentHoldReason(),
displayedPackageCount(order, cargo, inbound), null, distinctLocationCodes(inbound.locationCodes()),
order == null ? null : order.getEstimatedVolumeCbm(), volumeCbm(cargo),
inbound.actualGrossWeightKg(), inbound.actualVolumeCbm(),
measuredOrDeclared(inbound.actualGrossWeightKg(), grossWeightKg(cargo)),
measuredOrDeclared(inbound.actualVolumeCbm(), volumeCbm(cargo)),
order != null && order.getExpectedArrivalAt() != null ? order.getExpectedArrivalAt() : inbound.expectedArrivalAt(), inbound.feeReviewStatus(), inbound.companyName(),
inbound.businessType(), inbound.fulfillmentType(), inbound.lxCode(),
order == null ? null : order.getPickupMethod(), inbound.taxMode(), inbound.containerMode(),
inbound.customsInspection(), inbound.destinationType(), inbound.destinationCode(), inbound.palletCount(),
inbound.chargeableWeightKg(), inbound.chargeableVolumeCbm(), inbound.volumeWeightKg(),
inbound.actualNetWeightKg(),
measuredOrDeclared(inbound.actualNetWeightKg(), netWeightKg(cargo)),
inbound.measureCompletedAt(), inbound.inboundedAt(), inbound.expressCompanyName(), inbound.expressTrackingNo(),
inbound.createdByName(), skuNos(cargo), totalQuantity(cargo), shipmentId(order, cargo), referenceId(order, cargo),
measurement(inbound), preload(summary.preload()), loading(summary.loading()),
@@ -490,6 +492,10 @@ public class UnifiedOrderQueryService {
return cargo == null ? null : cargo.volumeCbm();
}
private BigDecimal measuredOrDeclared(BigDecimal measured, BigDecimal declared) {
return measured == null ? declared : measured;
}
private record CargoSummary(List<String> skuNos, List<String> shipmentIds, List<String> referenceIds,
Integer totalQuantity, Integer totalPackageCount, BigDecimal grossWeightKg,
BigDecimal netWeightKg, BigDecimal volumeCbm) {