Commit 915a9442 by 章家宝

feat(changlog):门店变更日志changeField改用中文

1 parent 0ac90176
...@@ -361,14 +361,19 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -361,14 +361,19 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
private void writeChangeLogForApproval(StoreListing listing, StoreListing oldEffective, private void writeChangeLogForApproval(StoreListing listing, StoreListing oldEffective,
LocalDateTime effectiveTime) { LocalDateTime effectiveTime) {
int versionNo = (listing.getChangeCount() == null ? 0 : listing.getChangeCount()); int versionNo = storeListingMapper.selectCount(
new LambdaQueryWrapper<StoreListing>()
.eq(StoreListing::getMerchantNo, listing.getMerchantNo())
.eq(StoreListing::getBusinessScene, listing.getBusinessScene())
.eq(StoreListing::getStatus, StoreStatusEnum.APPROVED.getCode()))
.intValue();
if (oldEffective == null) { if (oldEffective == null) {
StoreChangeLog entity = new StoreChangeLog(); StoreChangeLog entity = new StoreChangeLog();
entity.setListingId(listing.getListingId()); entity.setListingId(listing.getListingId());
entity.setVersionNo(versionNo); entity.setVersionNo(versionNo);
entity.setChangeField("status"); entity.setChangeField("status");
entity.setBeforeValue(null); entity.setBeforeValue(null);
entity.setAfterValue(StoreStatusEnum.APPROVED.getCode()); entity.setAfterValue(StoreStatusEnum.APPROVED.getDesc());
entity.setChangeUserId(CurrentUserHolder.getUserId()); entity.setChangeUserId(CurrentUserHolder.getUserId());
entity.setChangeUserName(CurrentUserHolder.getName()); entity.setChangeUserName(CurrentUserHolder.getName());
entity.setEffectiveTime(effectiveTime); entity.setEffectiveTime(effectiveTime);
...@@ -398,7 +403,7 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -398,7 +403,7 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
StoreChangeLog entity = new StoreChangeLog(); StoreChangeLog entity = new StoreChangeLog();
entity.setListingId(listing.getListingId()); entity.setListingId(listing.getListingId());
entity.setVersionNo(versionNo); entity.setVersionNo(versionNo);
entity.setChangeField(field); entity.setChangeField(LISTING_FIELD_LABELS.getOrDefault(field, field));
entity.setBeforeValue(before == null ? null : String.valueOf(before)); entity.setBeforeValue(before == null ? null : String.valueOf(before));
entity.setAfterValue(after == null ? null : String.valueOf(after)); entity.setAfterValue(after == null ? null : String.valueOf(after));
entity.setChangeUserId(CurrentUserHolder.getUserId()); entity.setChangeUserId(CurrentUserHolder.getUserId());
...@@ -450,9 +455,10 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -450,9 +455,10 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
for (Map.Entry<Integer, StoreListingItem> e : newMap.entrySet()) { for (Map.Entry<Integer, StoreListingItem> e : newMap.entrySet()) {
StoreListingItem oldItem = oldMap.get(e.getKey()); StoreListingItem oldItem = oldMap.get(e.getKey());
StoreListingItem newItem = e.getValue(); StoreListingItem newItem = e.getValue();
String label = "item[" + newItem.getProductCategory() + "]"; String category = newItem.getProductCategory();
if (oldItem == null) { if (oldItem == null) {
writeItemLog(newListingId, versionNo, label, null, "新增", effectiveTime); writeItemLog(newListingId, versionNo,
"【" + category + "】产品分类", null, "新增", effectiveTime);
continue; continue;
} }
for (String field : ITEM_DIFF_FIELDS) { for (String field : ITEM_DIFF_FIELDS) {
...@@ -460,7 +466,7 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -460,7 +466,7 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
Object after = getItemFieldValue(newItem, field); Object after = getItemFieldValue(newItem, field);
if (isChanged(before, after)) { if (isChanged(before, after)) {
writeItemLog(newListingId, versionNo, writeItemLog(newListingId, versionNo,
label + "." + field, itemFieldLabel(category, field),
before == null ? null : String.valueOf(before), before == null ? null : String.valueOf(before),
after == null ? null : String.valueOf(after), after == null ? null : String.valueOf(after),
effectiveTime); effectiveTime);
...@@ -469,8 +475,9 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -469,8 +475,9 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
} }
for (Map.Entry<Integer, StoreListingItem> e : oldMap.entrySet()) { for (Map.Entry<Integer, StoreListingItem> e : oldMap.entrySet()) {
if (!newMap.containsKey(e.getKey())) { if (!newMap.containsKey(e.getKey())) {
String label = "item[" + e.getValue().getProductCategory() + "]"; String category = e.getValue().getProductCategory();
writeItemLog(newListingId, versionNo, label, "已删除", null, effectiveTime); writeItemLog(newListingId, versionNo,
"【" + category + "】产品分类", "已删除", null, effectiveTime);
} }
} }
} }
...@@ -513,6 +520,40 @@ public class StoreApprovalServiceImpl implements StoreApprovalService { ...@@ -513,6 +520,40 @@ public class StoreApprovalServiceImpl implements StoreApprovalService {
}; };
} }
private static final Map<String, String> LISTING_FIELD_LABELS = Map.of(
"costDecoration", "装修、设备总投入",
"costMonthly", "当月产生费用",
"costLabor", "人工成本",
"costTotal", "运营成本合计",
"categoryCount", "产品分类数"
);
private static final Map<String, String> ITEM_FEE_TYPE_LABELS = Map.of(
"marketFee1", "管理层市场费1",
"marketFee2", "管理层市场费2",
"sunshine1", "一线阳光激励1",
"sunshine2", "一线阳光激励2"
);
private static final Map<String, String> ITEM_SUFFIX_LABELS = Map.of(
"CalcMode", "计算模式",
"CalcWay", "计算方式",
"Value", "数值",
"Unit", "单位",
"OnlinePoint", "线上积分"
);
private static String itemFieldLabel(String category, String field) {
for (Map.Entry<String, String> fee : ITEM_FEE_TYPE_LABELS.entrySet()) {
if (field.startsWith(fee.getKey())) {
String suffix = field.substring(fee.getKey().length());
String suffixLabel = ITEM_SUFFIX_LABELS.getOrDefault(suffix, suffix);
return "【" + category + "】" + fee.getValue() + suffixLabel;
}
}
return "【" + category + "】" + field;
}
private void writeApprovalLog(Long listingId, ApprovalActionEnum action, private void writeApprovalLog(Long listingId, ApprovalActionEnum action,
String preStatus, String postStatus, String reason) { String preStatus, String postStatus, String reason) {
StoreApprovalLog entity = new StoreApprovalLog(); StoreApprovalLog entity = new StoreApprovalLog();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!