|
@@ -65,6 +65,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -271,6 +272,15 @@ public class UnifyOrderManager {
|
|
|
QuoteInfoConverter.converterKindInfoVo(quoteVo.getKindInfoVo(), quoteKindMappingMap.get(QuoteRuleCategory.KIND.getCode()), quoteVo.getCarInfoVo());
|
|
QuoteInfoConverter.converterKindInfoVo(quoteVo.getKindInfoVo(), quoteKindMappingMap.get(QuoteRuleCategory.KIND.getCode()), quoteVo.getCarInfoVo());
|
|
|
}
|
|
}
|
|
|
quoteResultsVo = quoteService.quote(quoteVo);
|
|
quoteResultsVo = quoteService.quote(quoteVo);
|
|
|
|
|
+ // 格式化保费为两位小数
|
|
|
|
|
+ QuoteResultsVo.CostsVo costs = quoteResultsVo.getCosts();
|
|
|
|
|
+ if (costs != null) {
|
|
|
|
|
+ costs.setCiPremium(formatPremium(costs.getCiPremium())); // 交强险
|
|
|
|
|
+ costs.setBiPremium(formatPremium(costs.getBiPremium())); // 商业险
|
|
|
|
|
+ costs.setNiPremium(formatPremium(costs.getNiPremium())); // 非车险
|
|
|
|
|
+ costs.setVvTax(formatPremium(costs.getVvTax())); // 车船税
|
|
|
|
|
+ costs.setSumPremium(formatPremium(costs.getSumPremium())); // 总保费
|
|
|
|
|
+ }
|
|
|
quoteResultsVo.setCiRiskInfoVo(quoteVo.getCiRiskInfoVo());
|
|
quoteResultsVo.setCiRiskInfoVo(quoteVo.getCiRiskInfoVo());
|
|
|
quoteResultsVo.setBiRiskInfoVo(quoteVo.getBiRiskInfoVo());
|
|
quoteResultsVo.setBiRiskInfoVo(quoteVo.getBiRiskInfoVo());
|
|
|
quoteResultsVo.setQuoteStatus(quoteResultsVo.getQuoteStatusEnum().getCode());
|
|
quoteResultsVo.setQuoteStatus(quoteResultsVo.getQuoteStatusEnum().getCode());
|
|
@@ -281,83 +291,83 @@ public class UnifyOrderManager {
|
|
|
//////////////////////////////////////////新增营销抽奖活动////////////////////////////////////////////////
|
|
//////////////////////////////////////////新增营销抽奖活动////////////////////////////////////////////////
|
|
|
//远程调用活动列表
|
|
//远程调用活动列表
|
|
|
//匹配规则 每报价()次,可得()次抽奖机会,每日最多()次抽奖
|
|
//匹配规则 每报价()次,可得()次抽奖机会,每日最多()次抽奖
|
|
|
- HttpResult<List<LotteryActivityVO>> result = localLivingClient.queryActivityRules(lotteryScene);
|
|
|
|
|
- if (result == null || result.getCode() != 200 || result.getData() == null) {
|
|
|
|
|
- log.error("统一报价,查询本地生活的活动列表异常");
|
|
|
|
|
- } else {
|
|
|
|
|
- for (LotteryActivityVO activity : result.getData()) {
|
|
|
|
|
- // 检查活动是否有效
|
|
|
|
|
- if (!LocalDate.now().isBefore(activity.getActivityStartTime())
|
|
|
|
|
- && !LocalDate.now().isAfter(activity.getActivityEndTime())) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (activity.getLocalActivityTables() == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- // 遍历所有本地活动表
|
|
|
|
|
- for (LocalActivityTableVO table : activity.getLocalActivityTables()) {
|
|
|
|
|
- // 只处理 type=6 的报价规则
|
|
|
|
|
- if (!"6".equals(table.getType())) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 只处理本租户的报价规则
|
|
|
|
|
- if (!baseController.getUserSystemCode().equals(table.getTenantId())) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- // 查询是否在一账通绑定
|
|
|
|
|
- UnifiedUserCenterDTO unifiedUserCenterDTO = new UnifiedUserCenterDTO();
|
|
|
|
|
- unifiedUserCenterDTO.setUserId(quoteVo.getOrder().getRealQuoteUserId());
|
|
|
|
|
- unifiedUserCenterDTO.setClientId(CLIENT_ID);
|
|
|
|
|
- unifiedUserCenterDTO.setTenantId(baseController.getUserSystemCode());
|
|
|
|
|
- HttpResult<UnifiedUserClientVO> unifiedUserClientVOHttpResult = null;
|
|
|
|
|
- try {
|
|
|
|
|
- unifiedUserClientVOHttpResult = localLivingClient.queryBind(unifiedUserCenterDTO);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.info("业务员报价,查询用户绑定一账通接口异常,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
- log.error("业务员报价,查询用户绑定一账通接口异常", e);
|
|
|
|
|
- }
|
|
|
|
|
- if (unifiedUserClientVOHttpResult == null || unifiedUserClientVOHttpResult.getCode() != 200 || unifiedUserClientVOHttpResult.getData() == null) {
|
|
|
|
|
- // 判断是否满足条件
|
|
|
|
|
- // 业务员报价次数是否大于等于本活动规定时间范围内的报价次数
|
|
|
|
|
- // 统计业务员的报价次数
|
|
|
|
|
- int count = insOrdersService.countQuoteNum(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
|
|
- if (count >= Integer.parseInt(table.getQutNum()) && count <= Integer.parseInt(table.getQutLotteryMax())) {
|
|
|
|
|
- // 存本地记录 等绑定后更新本地记录的同步状态字段即可
|
|
|
|
|
- completeRule(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), null, activity.getId(),
|
|
|
|
|
- table.getId(), table.getQutNum() ,table.getQutLotteryNum() ,table.getQutLotteryMax() ,YesNoEnum.NO.getCode(), 6);
|
|
|
|
|
- log.info("业务员报价,满足条件插入记录,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
- }
|
|
|
|
|
- }else {
|
|
|
|
|
- Map<String, List<UnifiedUserClientVO>> userClientGroupMap = unifiedUserClientVOHttpResult.getData().getUserClients()
|
|
|
|
|
- .stream()
|
|
|
|
|
- .collect(Collectors.groupingBy(UnifiedUserClientVO::getClientId));
|
|
|
|
|
- // 首先查业务员是否在一账通绑定过本地生活 【已绑定过 远程调抽奖次数增加接口 标记已同步
|
|
|
|
|
- if (userClientGroupMap.containsKey(CLIENT_ID)) {
|
|
|
|
|
- LotteryCounDTO lotteryCounDTO = new LotteryCounDTO();
|
|
|
|
|
- lotteryCounDTO.setAppUserId(quoteVo.getOrder().getRealQuoteUserId());
|
|
|
|
|
- lotteryCounDTO.setActivityId(activity.getId());
|
|
|
|
|
- lotteryCounDTO.setCount(Integer.parseInt(table.getQutLotteryNum()));
|
|
|
|
|
- HttpResult<LotteryCountVO> lotteryCountVOHttpResult = null;
|
|
|
|
|
- try {
|
|
|
|
|
- lotteryCountVOHttpResult = localLivingClient.addLotteryCount(lotteryCounDTO);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.info("业务员报价,远程调用本地生活抽奖次数增加接口异常,userId:{},count:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), table.getQutLotteryNum(), baseController.getUserSystemCode());
|
|
|
|
|
- log.error("业务员报价,远程调用本地生活抽奖次数增加异常", e);
|
|
|
|
|
- }
|
|
|
|
|
- if (lotteryCountVOHttpResult != null && lotteryCountVOHttpResult.getData().getSuccess()) {
|
|
|
|
|
- // 记录规则完成 标记已同步
|
|
|
|
|
- completeRule(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), null, activity.getId(),
|
|
|
|
|
- table.getId(), table.getQutNum(), table.getQutLotteryNum(), table.getQutLotteryMax(), YesNoEnum.YES.getCode(), 6);
|
|
|
|
|
-
|
|
|
|
|
- log.info("业务员报价,满足条件插入记录并远程同步,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// HttpResult<List<LotteryActivityVO>> result = localLivingClient.queryActivityRules(lotteryScene);
|
|
|
|
|
+// if (result == null || result.getCode() != 200 || result.getData() == null) {
|
|
|
|
|
+// log.error("统一报价,查询本地生活的活动列表异常");
|
|
|
|
|
+// } else {
|
|
|
|
|
+// for (LotteryActivityVO activity : result.getData()) {
|
|
|
|
|
+// // 检查活动是否有效
|
|
|
|
|
+// if (!LocalDate.now().isBefore(activity.getActivityStartTime())
|
|
|
|
|
+// && !LocalDate.now().isAfter(activity.getActivityEndTime())) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if (activity.getLocalActivityTables() == null) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+// // 遍历所有本地活动表
|
|
|
|
|
+// for (LocalActivityTableVO table : activity.getLocalActivityTables()) {
|
|
|
|
|
+// // 只处理 type=6 的报价规则
|
|
|
|
|
+// if (!"6".equals(table.getType())) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// // 只处理本租户的报价规则
|
|
|
|
|
+// if (!baseController.getUserSystemCode().equals(table.getTenantId())) {
|
|
|
|
|
+// continue;
|
|
|
|
|
+// }
|
|
|
|
|
+// // 查询是否在一账通绑定
|
|
|
|
|
+// UnifiedUserCenterDTO unifiedUserCenterDTO = new UnifiedUserCenterDTO();
|
|
|
|
|
+// unifiedUserCenterDTO.setUserId(quoteVo.getOrder().getRealQuoteUserId());
|
|
|
|
|
+// unifiedUserCenterDTO.setClientId(CLIENT_ID);
|
|
|
|
|
+// unifiedUserCenterDTO.setTenantId(baseController.getUserSystemCode());
|
|
|
|
|
+// HttpResult<UnifiedUserClientVO> unifiedUserClientVOHttpResult = null;
|
|
|
|
|
+// try {
|
|
|
|
|
+// unifiedUserClientVOHttpResult = localLivingClient.queryBind(unifiedUserCenterDTO);
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// log.info("业务员报价,查询用户绑定一账通接口异常,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
+// log.error("业务员报价,查询用户绑定一账通接口异常", e);
|
|
|
|
|
+// }
|
|
|
|
|
+// if (unifiedUserClientVOHttpResult == null || unifiedUserClientVOHttpResult.getCode() != 200 || unifiedUserClientVOHttpResult.getData() == null) {
|
|
|
|
|
+// // 判断是否满足条件
|
|
|
|
|
+// // 业务员报价次数是否大于等于本活动规定时间范围内的报价次数
|
|
|
|
|
+// // 统计业务员的报价次数
|
|
|
|
|
+// int count = insOrdersService.countQuoteNum(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
|
|
+// if (count >= Integer.parseInt(table.getQutNum()) && count <= Integer.parseInt(table.getQutLotteryMax())) {
|
|
|
|
|
+// // 存本地记录 等绑定后更新本地记录的同步状态字段即可
|
|
|
|
|
+// completeRule(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), null, activity.getId(),
|
|
|
|
|
+// table.getId(), table.getQutNum() ,table.getQutLotteryNum() ,table.getQutLotteryMax() ,YesNoEnum.NO.getCode(), 6);
|
|
|
|
|
+// log.info("业务员报价,满足条件插入记录,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
+// }
|
|
|
|
|
+// }else {
|
|
|
|
|
+// Map<String, List<UnifiedUserClientVO>> userClientGroupMap = unifiedUserClientVOHttpResult.getData().getUserClients()
|
|
|
|
|
+// .stream()
|
|
|
|
|
+// .collect(Collectors.groupingBy(UnifiedUserClientVO::getClientId));
|
|
|
|
|
+// // 首先查业务员是否在一账通绑定过本地生活 【已绑定过 远程调抽奖次数增加接口 标记已同步
|
|
|
|
|
+// if (userClientGroupMap.containsKey(CLIENT_ID)) {
|
|
|
|
|
+// LotteryCounDTO lotteryCounDTO = new LotteryCounDTO();
|
|
|
|
|
+// lotteryCounDTO.setAppUserId(quoteVo.getOrder().getRealQuoteUserId());
|
|
|
|
|
+// lotteryCounDTO.setActivityId(activity.getId());
|
|
|
|
|
+// lotteryCounDTO.setCount(Integer.parseInt(table.getQutLotteryNum()));
|
|
|
|
|
+// HttpResult<LotteryCountVO> lotteryCountVOHttpResult = null;
|
|
|
|
|
+// try {
|
|
|
|
|
+// lotteryCountVOHttpResult = localLivingClient.addLotteryCount(lotteryCounDTO);
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// log.info("业务员报价,远程调用本地生活抽奖次数增加接口异常,userId:{},count:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), table.getQutLotteryNum(), baseController.getUserSystemCode());
|
|
|
|
|
+// log.error("业务员报价,远程调用本地生活抽奖次数增加异常", e);
|
|
|
|
|
+// }
|
|
|
|
|
+// if (lotteryCountVOHttpResult != null && lotteryCountVOHttpResult.getData().getSuccess()) {
|
|
|
|
|
+// // 记录规则完成 标记已同步
|
|
|
|
|
+// completeRule(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), null, activity.getId(),
|
|
|
|
|
+// table.getId(), table.getQutNum(), table.getQutLotteryNum(), table.getQutLotteryMax(), YesNoEnum.YES.getCode(), 6);
|
|
|
|
|
+//
|
|
|
|
|
+// log.info("业务员报价,满足条件插入记录并远程同步,userId:{},clientId:{},tenantId:{}", quoteVo.getOrder().getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -928,4 +938,25 @@ public class UnifyOrderManager {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 格式化保费字符串:非空判断 + 保留两位小数
|
|
|
|
|
+ * @param premium 原始保费字符串
|
|
|
|
|
+ * @return 格式化后两位小数的字符串
|
|
|
|
|
+ */
|
|
|
|
|
+ public static String formatPremium(String premium) {
|
|
|
|
|
+ // 1. 空值直接返回空
|
|
|
|
|
+ if (premium == null || premium.isBlank()) {
|
|
|
|
|
+ return premium;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 2. 转BigDecimal,保留两位小数(HALF_UP 四舍五入)
|
|
|
|
|
+ return new BigDecimal(premium.trim())
|
|
|
|
|
+ .setScale(2, RoundingMode.HALF_UP)
|
|
|
|
|
+ .toPlainString();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 格式错误直接返回原值,防止报错
|
|
|
|
|
+ return premium;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|