Commit 1583f5ee by 王璐琦

refactor(report): 优化其他品牌延保和权益统计逻辑

- 移除冗余配置项和变量,简化代码结构
- 新增isOtherBrandExtendedWarrantyOrder方法判断除原厂权益外的延保订单
- 新增isOtherBrandEquityOrder方法判断排除原厂延保及广联延保的权益订单
- 用新方法替代原有复杂条件判断,统一延保和权益业务列逻辑
- 修正订单商品品类匹配逻辑,避免重复和错误统计
- 代码逻辑更加清晰,提升维护性和准确性
1 parent 36140381
...@@ -1903,7 +1903,6 @@ public class DailyReportDataService { ...@@ -1903,7 +1903,6 @@ public class DailyReportDataService {
//岚图品牌id //岚图品牌id
Integer ltqBrandId = OrePropertyConfigurer.getProperty("lt.car.child.brand.ids",Integer.class, 2188); Integer ltqBrandId = OrePropertyConfigurer.getProperty("lt.car.child.brand.ids",Integer.class, 2188);
Integer goodsTypeOriginalFactoryEquity = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.originalFactoryEquity", Integer.class, 189); Integer goodsTypeOriginalFactoryEquity = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.originalFactoryEquity", Integer.class, 189);
Integer goodsTypeGlEquity = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.equity.type", Integer.class, 126);
Integer goodsTypeOriginalFactoryExtWarranty = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.originalFactoryExtendedWarranty", Integer.class, 253); Integer goodsTypeOriginalFactoryExtWarranty = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.originalFactoryExtendedWarranty", Integer.class, 253);
Integer goodsTypeGlExtWarranty = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.glExtendedWarranty", Integer.class, 254); Integer goodsTypeGlExtWarranty = OrePropertyConfigurer.getProperty("smartcarlife.goodsType.extendedInsurance.glExtendedWarranty", Integer.class, 254);
...@@ -2017,11 +2016,9 @@ public class DailyReportDataService { ...@@ -2017,11 +2016,9 @@ public class DailyReportDataService {
if (isOrderFullyRefunded(order)) continue; if (isOrderFullyRefunded(order)) continue;
GoodsOrderCustomer customer = order.getCustomer(); GoodsOrderCustomer customer = order.getCustomer();
if (customer == null || customer.getSalesType() == null || customer.getSalesType() != SalesTypeEnum.BEFORE_SALE.getValue()) continue; if (customer == null || customer.getSalesType() == null || customer.getSalesType() != SalesTypeEnum.BEFORE_SALE.getValue()) continue;
boolean isExtWarranty = containsOrderGoodsCategory(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
boolean isEquity = containsOrderGoodsCategory(order, goodsTypeOriginalFactoryEquity, goodsTypeGlEquity);
// 业务列:延保仅统计延保基础场景;权益 and 延保不追加基础场景限制。 // 业务列:延保仅统计延保基础场景;权益 and 延保不追加基础场景限制。
boolean ewBusiness = matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY) && isExtWarranty && !isEquity; boolean ewBusiness = isOtherBrandExtendedWarrantyOrder(order, goodsTypeOriginalFactoryEquity);
boolean eqBusiness = isEquity && !isExtWarranty; boolean eqBusiness = isOtherBrandEquityOrder(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
String phone = customer.getCustomerPhone(); String phone = customer.getCustomerPhone();
Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags()); Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags());
boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), endDate, endDate) boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), endDate, endDate)
...@@ -2053,11 +2050,9 @@ public class DailyReportDataService { ...@@ -2053,11 +2050,9 @@ public class DailyReportDataService {
if (isOrderFullyRefunded(order)) continue; if (isOrderFullyRefunded(order)) continue;
GoodsOrderCustomer customer = order.getCustomer(); GoodsOrderCustomer customer = order.getCustomer();
if (customer == null || customer.getSalesType() == null || customer.getSalesType() != SalesTypeEnum.BEFORE_SALE.getValue()) continue; if (customer == null || customer.getSalesType() == null || customer.getSalesType() != SalesTypeEnum.BEFORE_SALE.getValue()) continue;
boolean isExtWarranty = containsOrderGoodsCategory(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
boolean isEquity = containsOrderGoodsCategory(order, goodsTypeOriginalFactoryEquity, goodsTypeGlEquity);
// 业务列:延保仅统计延保基础场景;权益 and 延保不追加基础场景限制。 // 业务列:延保仅统计延保基础场景;权益 and 延保不追加基础场景限制。
boolean ewBusiness = matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY) && isExtWarranty && !isEquity; boolean ewBusiness = isOtherBrandExtendedWarrantyOrder(order, goodsTypeOriginalFactoryEquity);
boolean eqBusiness = isEquity && !isExtWarranty; boolean eqBusiness = isOtherBrandEquityOrder(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
String phone = customer.getCustomerPhone(); String phone = customer.getCustomerPhone();
Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags()); Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags());
boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), startDate, endDate) boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), startDate, endDate)
...@@ -2159,6 +2154,22 @@ public class DailyReportDataService { ...@@ -2159,6 +2154,22 @@ public class DailyReportDataService {
} }
/** /**
* 其他品牌报表业务列“延保”:延保基础场景且订单商品不包含原厂权益。
*/
private boolean isOtherBrandExtendedWarrantyOrder(GoodsOrderDTO order, Integer originalFactoryEquityGoodsType) {
return matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY)
&& !containsOrderGoodsCategory(order, originalFactoryEquityGoodsType);
}
/**
* 其他品牌报表业务列“权益 and 延保”:订单商品不包含原厂延保、广联延保。
*/
private boolean isOtherBrandEquityOrder(GoodsOrderDTO order, Integer originalFactoryExtWarrantyGoodsType,
Integer glExtWarrantyGoodsType) {
return !containsOrderGoodsCategory(order, originalFactoryExtWarrantyGoodsType, glExtWarrantyGoodsType);
}
/**
* 延保权益-问界交付部数据统计:按交付专员维度 * 延保权益-问界交付部数据统计:按交付专员维度
* <p>hmzxBrandFlag=3(单问界), BEFORE_SALE, department=5(交付部)</p> * <p>hmzxBrandFlag=3(单问界), BEFORE_SALE, department=5(交付部)</p>
*/ */
...@@ -3077,13 +3088,13 @@ public class DailyReportDataService { ...@@ -3077,13 +3088,13 @@ public class DailyReportDataService {
for (GoodsSubOrderDTO sub : order.getSubOrderList()) { for (GoodsSubOrderDTO sub : order.getSubOrderList()) {
BigDecimal net = calcSubOrderNet(sub); BigDecimal net = calcSubOrderNet(sub);
addProductName(productNames, sub); addProductName(productNames, sub);
boolean isEw = matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginFactoryExtWarranty) boolean isOriginalFactoryEquity = matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginFactoryEquity);
boolean isExtendedWarranty = matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginFactoryExtWarranty)
|| matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeGlExtWarranty); || matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeGlExtWarranty);
boolean isEq = matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginFactoryEquity); if (!isOriginalFactoryEquity && matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY)) {
if (isEw && matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY)) {
ewAmt = ewAmt.add(net); ewAmt = ewAmt.add(net);
} }
if (isEq) { eqAmt = eqAmt.add(net); } if (!isExtendedWarranty) { eqAmt = eqAmt.add(net); }
} }
} }
vo.setPurchasedProduct(CollectionUtils.isNotEmpty(productNames) ? String.join(",", productNames) : "无"); vo.setPurchasedProduct(CollectionUtils.isNotEmpty(productNames) ? String.join(",", productNames) : "无");
...@@ -3577,19 +3588,9 @@ public class DailyReportDataService { ...@@ -3577,19 +3588,9 @@ public class DailyReportDataService {
Byte salesType = customer.getSalesType(); Byte salesType = customer.getSalesType();
Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags()); Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags());
boolean deliveryDateMatch = isSameDay(customer.getActualDeliveryDate(), order.getInstallUpgradeTime()); boolean deliveryDateMatch = isSameDay(customer.getActualDeliveryDate(), order.getInstallUpgradeTime());
// 判断订单的商品品类归属 // 业务列:延保仅排除原厂权益;权益 and 延保仅排除原厂延保、广联延保。
boolean isExtWarranty = false, isEquity = false; boolean categoryEw = isOtherBrandExtendedWarrantyOrder(order, goodsTypeOriginalFactoryEquity);
if (CollectionUtils.isNotEmpty(order.getSubOrderList())) { boolean categoryEq = isOtherBrandEquityOrder(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
for (GoodsSubOrderDTO sub : order.getSubOrderList()) {
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginalFactoryExtWarranty)) isExtWarranty = true;
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeGlExtWarranty)) isExtWarranty = true;
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginalFactoryEquity)) isEquity = true;
}
}
// 延保 = 匹配延保品类且不匹配原厂权益;权益 = 匹配原厂权益且不匹配延保品类
boolean categoryEw = matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY)
&& isExtWarranty && !isEquity;
boolean categoryEq = isEquity && !isExtWarranty;
if (salesType != null && salesType == SalesTypeEnum.BEFORE_SALE.getValue()) { if (salesType != null && salesType == SalesTypeEnum.BEFORE_SALE.getValue()) {
if (deliveryDateMatch && deliveryPhoneSet.add(phone)) orderDelivery++; if (deliveryDateMatch && deliveryPhoneSet.add(phone)) orderDelivery++;
...@@ -3755,17 +3756,9 @@ public class DailyReportDataService { ...@@ -3755,17 +3756,9 @@ public class DailyReportDataService {
Byte salesType = customer.getSalesType(); Byte salesType = customer.getSalesType();
Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags()); Set<Integer> tags = parseCustomerTagSet(customer.getCustomerTags());
boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), startDate, endDate); boolean deliveryDateMatch = isDateInRange(customer.getActualDeliveryDate(), startDate, endDate);
boolean isExtWarranty = false, isEquity = false; // 业务列:延保仅排除原厂权益;权益 and 延保仅排除原厂延保、广联延保。
if (CollectionUtils.isNotEmpty(order.getSubOrderList())) { boolean categoryEw = isOtherBrandExtendedWarrantyOrder(order, goodsTypeOriginalFactoryEquity);
for (GoodsSubOrderDTO sub : order.getSubOrderList()) { boolean categoryEq = isOtherBrandEquityOrder(order, goodsTypeOriginalFactoryExtWarranty, goodsTypeGlExtWarranty);
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginalFactoryExtWarranty)) isExtWarranty = true;
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeGlExtWarranty)) isExtWarranty = true;
if (matchesCategory(sub.getUpgradeGoodsType(), sub.getUpgradeSecondaryGoodsType(), sub.getUpgradeThirdLevelGoodsType(), goodsTypeOriginalFactoryEquity)) isEquity = true;
}
}
boolean categoryEw = matchesHmReportBusiness(order, HmReportBusinessType.EXTENDED_WARRANTY)
&& isExtWarranty && !isEquity;
boolean categoryEq = isEquity && !isExtWarranty;
if (salesType != null && salesType == SalesTypeEnum.BEFORE_SALE.getValue()) { if (salesType != null && salesType == SalesTypeEnum.BEFORE_SALE.getValue()) {
if (deliveryDateMatch && deliveryPhoneSet.add(phone)) orderDelivery++; if (deliveryDateMatch && deliveryPhoneSet.add(phone)) orderDelivery++;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!