|
|
@@ -244,7 +244,7 @@ public class UnifyOrderManager {
|
|
|
String systemCode = getSystemCode();
|
|
|
String companyName = CompanyConstants.getCompanyNameByCode(esmInsCompanyHttpResult.getData().getCompanyCode());
|
|
|
|
|
|
-
|
|
|
+ log.info("查询保司配置的协议:systemCode=[{}],companyId=[{}]",systemCode, esmInsCompanyHttpResult.getData().getId());
|
|
|
HttpResult<List<PtlAgreement>> byCompanyId = orgClient.getByCompanyId(esmInsCompanyHttpResult.getData().getId(), systemCode);
|
|
|
if (CollUtil.isEmpty(byCompanyId.getData())) {
|
|
|
AssertionUtils.isFail(true, "保司未配置协议");
|
|
|
@@ -698,7 +698,7 @@ public class UnifyOrderManager {
|
|
|
@Operation(summary = "获取订单状态")
|
|
|
@PostMapping("/getOrderStatus")
|
|
|
public HttpResult getOrderStatus(@RequestBody OrderStatusVo orderStatusVo) throws Exception {
|
|
|
-
|
|
|
+ log.info("更新订单状态:orderStatusVo=[{}]",JSONUtil.toJsonStr(orderStatusVo));
|
|
|
InsOrders insOrders = insOrdersService.getById(orderStatusVo.getOrder().getOrdersNo());
|
|
|
AssertionUtils.isFail(Objects.isNull(insOrders), "订单不存在");
|
|
|
HttpResult<EsmInsCompany> esmInsCompanyHttpResult = platformClient.findById(insOrders.getCompanyId());
|
|
|
@@ -720,104 +720,152 @@ public class UnifyOrderManager {
|
|
|
InsOrdersAccidentalDriving insOrdersAccidentalDriving = insOrdersAccidentalDrivingService.getByOrderId(insOrders.getId());
|
|
|
orderStatusVo.setInsOrdersAccidentalDriving(insOrdersAccidentalDriving);
|
|
|
OrderStatusResultVo orderStatusResultVo = orderStatusService.queryOrderState(orderStatusVo);
|
|
|
-
|
|
|
+ log.info("订单状态orderStatusResultVo=[{}]",JSONUtil.toJsonStr(orderStatusResultVo));
|
|
|
// 保存状态查询结果
|
|
|
insOrdersService.orderAfterUpdateOrderStatus(orderStatusVo.getOrder().getOrdersNo(), orderStatusResultVo);
|
|
|
//////////////////////////////////////////新增营销抽奖活动////////////////////////////////////////////////
|
|
|
// 承保(客户)、出单(业务员)
|
|
|
- if(orderStatusResultVo.getOrderStatus() == InsOrderStatusEnum.UNDERWRITED) {
|
|
|
- // 远程调用活动列表
|
|
|
- // 匹配规则
|
|
|
- // 规则一:累计出单()次,可得()次抽奖机会
|
|
|
- // 规则二:累计出单()次,可得()次抽奖机会
|
|
|
- // 下一个规则的出单次数不能不上一个规则出单次数小
|
|
|
- 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(orderStatusResultVo.getOrderStatus() == InsOrderStatusEnum.UNDERWRITED){
|
|
|
+ doSomethingAfterUnderwited(insOrders);
|
|
|
+ }
|
|
|
+ return HttpResult.ok("状态刷新成功");
|
|
|
+ }
|
|
|
|
|
|
- if (activity.getLocalActivityTables() == null) {
|
|
|
- continue;
|
|
|
+ /**
|
|
|
+ * 模拟承保(跳过实际付款操作)
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/5/19 12:00
|
|
|
+ */
|
|
|
+ @Operation(summary = "模拟承保(跳过实际付款操作)")
|
|
|
+ @PostMapping("/mockUnderwited")
|
|
|
+ public HttpResult<String> mockUnderwited(@RequestBody OrderStatusVo orderStatusVo){
|
|
|
+ log.info("模拟承保(跳过实际付款操作). orderStatusVo=[{}]", JSONUtil.toJsonStr(orderStatusVo));
|
|
|
+ InsOrders insOrders = insOrdersService.getById(orderStatusVo.getOrder().getOrdersNo());
|
|
|
+ AssertionUtils.isFail(Objects.isNull(insOrders), "订单不存在");
|
|
|
+ HttpResult<EsmInsCompany> esmInsCompanyHttpResult = platformClient.findById(insOrders.getCompanyId());
|
|
|
+ orderStatusVo.getOrder().setAgreementId(insOrders.getAgreementId());
|
|
|
+ orderStatusVo.getOrder().setInsuranceCompanyCode(esmInsCompanyHttpResult.getData().getCompanyCode());
|
|
|
+ orderStatusVo.getOrder().setInsuranceCompanyId(esmInsCompanyHttpResult.getData().getId());
|
|
|
+ orderStatusVo.getOrder().setCompanyOrderNo(insOrders.getCompanyOrderNo());
|
|
|
+ orderStatusVo.getOrder().setApiType(Integer.parseInt(insOrders.getApiType()));
|
|
|
+ orderStatusVo.setInsOrders(insOrders);
|
|
|
+ //获取保司实体
|
|
|
+ QuotationBaseService orderStatusService = companyFactory.getOrderStatusService(orderStatusVo);
|
|
|
+ orderStatusVo.setCarInfo(insOrdersCarInfoService.getByOrderId(insOrders.getId()));
|
|
|
+ InsOrdersPolicy insOrdersPolicy = insOrdersPolicyService.getById(insOrders.getId());
|
|
|
+ orderStatusVo.setInsOrdersPolicy(insOrdersPolicy);
|
|
|
+ List<InsOrdersCarUserInfo> insOrdersCarUserInfos = insOrdersCarUserInfoService.getByOrderId(insOrders.getId());
|
|
|
+ orderStatusVo.setInsOrdersCarUserInfoList(insOrdersCarUserInfos);
|
|
|
+ InsOrdersCosts insOrdersCosts = insOrdersCostsService.getById(insOrders.getId());
|
|
|
+ orderStatusVo.setInsOrdersCosts(insOrdersCosts);
|
|
|
+ InsOrdersAccidentalDriving insOrdersAccidentalDriving = insOrdersAccidentalDrivingService.getByOrderId(insOrders.getId());
|
|
|
+ orderStatusVo.setInsOrdersAccidentalDriving(insOrdersAccidentalDriving);
|
|
|
+// OrderStatusResultVo orderStatusResultVo = orderStatusService.queryOrderState(orderStatusVo);
|
|
|
+// log.info("订单状态orderStatusResultVo=[{}]",JSONUtil.toJsonStr(orderStatusResultVo));
|
|
|
+
|
|
|
+ this.doSomethingAfterUnderwited(insOrders);
|
|
|
+ return HttpResult.ok("模拟承保(跳过实际付款操作)");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单承保后执行一些操作
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/5/19 11:59
|
|
|
+ */
|
|
|
+ private void doSomethingAfterUnderwited(InsOrders insOrders) {
|
|
|
+ // 远程调用活动列表
|
|
|
+ // 匹配规则
|
|
|
+ // 规则一:累计出单()次,可得()次抽奖机会
|
|
|
+ // 规则二:累计出单()次,可得()次抽奖机会
|
|
|
+ // 下一个规则的出单次数不能不上一个规则出单次数小
|
|
|
+ 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=9 的承保规则
|
|
|
+ if ("9".equals(table.getType())) {
|
|
|
+ Double totalFee = insOrdersService.queryTotalFee(insOrders.getInsOrderNo());
|
|
|
+ String userPhone = insOrdersService.queryCustomerPhone(insOrders.getInsOrderNo());
|
|
|
+ for (UnderwritingRuleVO underwritingRuleVO : table.getUnderwritingRules()) {
|
|
|
+ if (new BigDecimal(totalFee).compareTo(underwritingRuleVO.getUwMinPremium()) >= 0 && new BigDecimal(totalFee).compareTo(underwritingRuleVO.getUwMaxPremium()) <= 0) {
|
|
|
+ // 存本地记录 等绑定后更新本地记录的同步状态字段即可
|
|
|
+ completeRule(null, null, userPhone, activity.getId(),
|
|
|
+ table.getId(), underwritingRuleVO.getUwMinPremium()+"-"+underwritingRuleVO.getUwMaxPremium() , underwritingRuleVO.getUwLotteryNum(),null ,YesNoEnum.NO.getCode(), 9);
|
|
|
+ log.info("客户承保,满足条件插入记录,userId:{},clientId:{},tenantId:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- // 遍历所有本地活动表
|
|
|
- for (LocalActivityTableVO table : activity.getLocalActivityTables()) {
|
|
|
- // 处理 type=9 的承保规则
|
|
|
- if ("9".equals(table.getType())) {
|
|
|
- Double totalFee = insOrdersService.queryTotalFee(insOrders.getInsOrderNo());
|
|
|
- String userPhone = insOrdersService.queryCustomerPhone(insOrders.getInsOrderNo());
|
|
|
- for (UnderwritingRuleVO underwritingRuleVO : table.getUnderwritingRules()) {
|
|
|
- if (new BigDecimal(totalFee).compareTo(underwritingRuleVO.getUwMinPremium()) >= 0 && new BigDecimal(totalFee).compareTo(underwritingRuleVO.getUwMaxPremium()) <= 0) {
|
|
|
+ // 处理 type=8 的出单规则
|
|
|
+ if ("8".equals(table.getType())) {
|
|
|
+ // 只处理本租户的出单规则
|
|
|
+ if (!baseController.getUserSystemCode().equals(table.getTenantId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 查询是否在一账通绑定
|
|
|
+ UnifiedUserCenterDTO unifiedUserCenterDTO = new UnifiedUserCenterDTO();
|
|
|
+ unifiedUserCenterDTO.setUserId(insOrders.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:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
+ log.error("业务员出单,查询用户绑定一账通接口异常", e);
|
|
|
+ }
|
|
|
+ if (unifiedUserClientVOHttpResult == null || unifiedUserClientVOHttpResult.getCode() != 200 || unifiedUserClientVOHttpResult.getData() == null) {
|
|
|
+ // 判断是否满足条件
|
|
|
+ // 业务员累计出单次数是否大于等于本活动规定时间范围内的出单次数
|
|
|
+ // 统计业务员的出单次数
|
|
|
+ int count = insOrdersService.countOrderNum(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
+ for (OrderRuleVO orderRule : table.getOrderRules()) {
|
|
|
+ if (count >= Integer.parseInt(orderRule.getOrdNum())) {
|
|
|
// 存本地记录 等绑定后更新本地记录的同步状态字段即可
|
|
|
- completeRule(null, null, userPhone, activity.getId(),
|
|
|
- table.getId(), underwritingRuleVO.getUwMinPremium()+"-"+underwritingRuleVO.getUwMaxPremium() , underwritingRuleVO.getUwLotteryNum(),null ,YesNoEnum.NO.getCode(), 9);
|
|
|
- log.info("客户承保,满足条件插入记录,userId:{},clientId:{},tenantId:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
+ completeRule(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), null, activity.getId(),
|
|
|
+ table.getId(), orderRule.getOrdNum() , String.valueOf(orderRule.getOrdLotteryNum()),null ,YesNoEnum.NO.getCode(), 8);
|
|
|
+
|
|
|
+ log.info("业务员出单,满足条件插入记录,userId:{},clientId:{},tenantId:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- // 处理 type=8 的出单规则
|
|
|
- if ("8".equals(table.getType())) {
|
|
|
- // 只处理本租户的出单规则
|
|
|
- if (!baseController.getUserSystemCode().equals(table.getTenantId())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 查询是否在一账通绑定
|
|
|
- UnifiedUserCenterDTO unifiedUserCenterDTO = new UnifiedUserCenterDTO();
|
|
|
- unifiedUserCenterDTO.setUserId(insOrders.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:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
- log.error("业务员出单,查询用户绑定一账通接口异常", e);
|
|
|
- }
|
|
|
- if (unifiedUserClientVOHttpResult == null || unifiedUserClientVOHttpResult.getCode() != 200 || unifiedUserClientVOHttpResult.getData() == null) {
|
|
|
- // 判断是否满足条件
|
|
|
- // 业务员累计出单次数是否大于等于本活动规定时间范围内的出单次数
|
|
|
- // 统计业务员的出单次数
|
|
|
- int count = insOrdersService.countOrderNum(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
- for (OrderRuleVO orderRule : table.getOrderRules()) {
|
|
|
- if (count >= Integer.parseInt(orderRule.getOrdNum())) {
|
|
|
- // 存本地记录 等绑定后更新本地记录的同步状态字段即可
|
|
|
- completeRule(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), null, activity.getId(),
|
|
|
- table.getId(), orderRule.getOrdNum() , String.valueOf(orderRule.getOrdLotteryNum()),null ,YesNoEnum.NO.getCode(), 8);
|
|
|
-
|
|
|
- log.info("业务员出单,满足条件插入记录,userId:{},clientId:{},tenantId:{}", insOrders.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(insOrders.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:{}", insOrders.getRealQuoteUserId(), table.getQutLotteryNum(), baseController.getUserSystemCode());
|
|
|
+ log.error("业务员出单,远程调用本地生活抽奖次数增加异常", e);
|
|
|
}
|
|
|
- }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(insOrders.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:{}", insOrders.getRealQuoteUserId(), table.getQutLotteryNum(), baseController.getUserSystemCode());
|
|
|
- log.error("业务员出单,远程调用本地生活抽奖次数增加异常", e);
|
|
|
- }
|
|
|
- if (lotteryCountVOHttpResult != null && lotteryCountVOHttpResult.getData().getSuccess()) {
|
|
|
- int count = insOrdersService.countOrderNum(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
- for (OrderRuleVO orderRule : table.getOrderRules()) {
|
|
|
- if (count >= Integer.parseInt(orderRule.getOrdNum())) {
|
|
|
- // 记录规则完成 标记已同步
|
|
|
- completeRule(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), null, activity.getId(),
|
|
|
- table.getId(), table.getQutNum(), table.getQutLotteryNum(), table.getQutLotteryMax(), YesNoEnum.YES.getCode(), 8);
|
|
|
- log.info("业务员出单,满足条件插入记录并远程同步,userId:{},clientId:{},tenantId:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
- }
|
|
|
+ if (lotteryCountVOHttpResult != null && lotteryCountVOHttpResult.getData().getSuccess()) {
|
|
|
+ int count = insOrdersService.countOrderNum(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
+ for (OrderRuleVO orderRule : table.getOrderRules()) {
|
|
|
+ if (count >= Integer.parseInt(orderRule.getOrdNum())) {
|
|
|
+ // 记录规则完成 标记已同步
|
|
|
+ completeRule(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), null, activity.getId(),
|
|
|
+ table.getId(), table.getQutNum(), table.getQutLotteryNum(), table.getQutLotteryMax(), YesNoEnum.YES.getCode(), 8);
|
|
|
+ log.info("业务员出单,满足条件插入记录并远程同步,userId:{},clientId:{},tenantId:{}", insOrders.getRealQuoteUserId(), CLIENT_ID, baseController.getUserSystemCode());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -827,7 +875,6 @@ public class UnifyOrderManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return HttpResult.ok("状态刷新成功");
|
|
|
}
|
|
|
|
|
|
@OrderOperationLog(
|