修改导入套餐
This commit is contained in:
@@ -44,7 +44,7 @@ public class PrcPriceSet extends BaseEntity
|
||||
private List<PrcCustomerPriceSet> customers;
|
||||
/** async save task id (not persisted) */
|
||||
private String saveTaskId;
|
||||
/** Y: backend joins product library into details (skip front pull) */
|
||||
/** Y: ignored on save; library pull only via /detail/pullFromLibrary */
|
||||
private String pullFromLibrary;
|
||||
/** Y: even if version already has details, delete+re-pull from library */
|
||||
private String forcePullLibrary;
|
||||
|
||||
+35
-19
@@ -892,7 +892,8 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
set.setUpdateBy(operName);
|
||||
set.setCreateBy(operName);
|
||||
set.setSaveTaskId(taskId);
|
||||
set.setPullFromLibrary("Y");
|
||||
// Dedicated pull API — does not go through savePrcPriceSet.
|
||||
set.setPullFromLibrary(null);
|
||||
set.setForcePullLibrary(force ? "Y" : "N");
|
||||
if (psvId == null)
|
||||
{
|
||||
@@ -1004,6 +1005,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
List<PrcPriceSetDetail> hits = matchImportDetails(candidates, row);
|
||||
if (!hits.isEmpty())
|
||||
{
|
||||
// Existing band: only skip when Excel left both fees blank (keep old prices).
|
||||
if (freight == null && registration == null)
|
||||
{
|
||||
skippedFee++;
|
||||
@@ -1029,11 +1031,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (freight == null && registration == null)
|
||||
{
|
||||
skippedFee++;
|
||||
continue;
|
||||
}
|
||||
// New band: always insert weight/country row (fees may be null; editable later).
|
||||
PrcPriceSetDetail created = buildDetailFromImportRow(
|
||||
priceSetId, psvId, productCode, productName, row, freight, registration);
|
||||
created.setPspId(pspId);
|
||||
@@ -1043,11 +1041,19 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
{
|
||||
touched.add(created.getPsdId());
|
||||
}
|
||||
if (freight == null && registration == null)
|
||||
{
|
||||
skippedFee++;
|
||||
}
|
||||
inserted++;
|
||||
}
|
||||
}
|
||||
setProductMapper.bindDetailPspByPsvId(psvId);
|
||||
reportImportProgress(taskId, priceSetId, 95, "finishing");
|
||||
if (inserted == 0 && updated == 0)
|
||||
{
|
||||
throw new ServiceException(MessageUtils.message("price.set.import.noDetailWritten"));
|
||||
}
|
||||
return MessageUtils.message("price.set.import.upsertSuccess",
|
||||
Integer.valueOf(inserted), Integer.valueOf(updated), Integer.valueOf(skippedFee));
|
||||
}
|
||||
@@ -1086,16 +1092,16 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
PrcPriceSetDetail d = new PrcPriceSetDetail();
|
||||
d.setPriceSetId(priceSetId);
|
||||
d.setPsvId(psvId);
|
||||
d.setProductCode(productCode);
|
||||
d.setProductName(productName);
|
||||
d.setProductCode(trimToLen(productCode, 20));
|
||||
d.setProductName(trimToLen(productName, 50));
|
||||
d.setCountryCode(row.getCountryCode());
|
||||
d.setCountryName(row.getCountryName());
|
||||
d.setCountryName(trimToLen(row.getCountryName(), 50));
|
||||
d.setZoneId(row.getZoneId());
|
||||
d.setZoneCode(row.getZoneCode());
|
||||
d.setZoneName(row.getZoneName());
|
||||
d.setZoneName(trimToLen(row.getZoneName(), 100));
|
||||
d.setWeightMin(row.getWeightMin());
|
||||
d.setWeightMax(row.getWeightMax());
|
||||
d.setWeightLabel(formatWeightLabel(row.getWeightMin(), row.getWeightMax()));
|
||||
d.setWeightLabel(trimToLen(formatWeightLabel(row.getWeightMin(), row.getWeightMax()), 50));
|
||||
d.setProductCountryId(row.getDetailId());
|
||||
d.setFvValue(freight);
|
||||
d.setFvRegistrationFee(registration);
|
||||
@@ -1105,6 +1111,20 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
return d;
|
||||
}
|
||||
|
||||
private static String trimToLen(String s, int max)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String t = s.trim();
|
||||
if (t.length() <= max)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return t.substring(0, max);
|
||||
}
|
||||
|
||||
private void reportImportProgress(String taskId, Long priceSetId, int percent, String message)
|
||||
{
|
||||
if (StringUtils.isEmpty(taskId) || saveAsyncRunner == null)
|
||||
@@ -2136,12 +2156,12 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
private void saveOrUpdateVersion(PrcPriceSet set)
|
||||
{
|
||||
PrcPriceSetVersion version = resolveSaveVersion(set);
|
||||
boolean pullLibrary = "Y".equalsIgnoreCase(set.getPullFromLibrary());
|
||||
// null details = leave existing rows alone; empty list = clear / replace with nothing
|
||||
// null details = leave existing rows alone; empty list = clear / replace with nothing.
|
||||
// Library pull must NOT run here — only via pullFromLibrary() / Excel import on Step 2.
|
||||
boolean detailsProvided = set.getDetails() != null;
|
||||
List<PrcPriceSetDetail> details = filterDetails(set.getDetails());
|
||||
// Allow creating an empty draft version when client sends version (Step1 -> Step2).
|
||||
if (version == null && !detailsProvided && !pullLibrary)
|
||||
if (version == null && !detailsProvided)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2192,11 +2212,7 @@ public class PrcPriceSetServiceImpl implements IPrcPriceSetService
|
||||
versionMapper.updatePrcPriceSetVersion(version);
|
||||
}
|
||||
set.setVersion(version);
|
||||
if (pullLibrary)
|
||||
{
|
||||
replaceVersionDetailsFromLibrary(set, version);
|
||||
}
|
||||
else if (detailsProvided)
|
||||
if (detailsProvided)
|
||||
{
|
||||
upsertVersionDetails(set, version, details);
|
||||
reportSaveProgress(set, 85, "saving surcharges");
|
||||
|
||||
Reference in New Issue
Block a user