|
@@ -3,6 +3,7 @@ package com.jzg.quotation.summary.controller;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -14,7 +15,10 @@ import com.jzg.commons.constants.quote.enums.base.QuoteRuleCategory;
|
|
|
import com.jzg.commons.core.base.BaseController;
|
|
import com.jzg.commons.core.base.BaseController;
|
|
|
import com.jzg.commons.core.base.StateResult;
|
|
import com.jzg.commons.core.base.StateResult;
|
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
import com.jzg.commons.core.page.HttpResult;
|
|
|
|
|
+import com.jzg.commons.entity.dto.LotteryCounDTO;
|
|
|
|
|
+import com.jzg.commons.entity.dto.UnifiedUserCenterDTO;
|
|
|
import com.jzg.commons.entity.enums.MessageCodeEnum;
|
|
import com.jzg.commons.entity.enums.MessageCodeEnum;
|
|
|
|
|
+import com.jzg.commons.entity.enums.YesNoEnum;
|
|
|
import com.jzg.commons.entity.orders.po.*;
|
|
import com.jzg.commons.entity.orders.po.*;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
import com.jzg.commons.entity.po.*;
|
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
import com.jzg.commons.entity.quote.vo.QuoteVo;
|
|
@@ -25,8 +29,7 @@ import com.jzg.commons.entity.quote.vo.underwriting.SpecialAppointmentsVo;
|
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsDto;
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsDto;
|
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsInfoDto;
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsInfoDto;
|
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsPackageDto;
|
|
import com.jzg.commons.entity.rights.dto.InsOrderRightsPackageDto;
|
|
|
-import com.jzg.commons.entity.vo.CompanyClauseVo;
|
|
|
|
|
-import com.jzg.commons.entity.vo.InsCompanyClauseVo;
|
|
|
|
|
|
|
+import com.jzg.commons.entity.vo.*;
|
|
|
import com.jzg.commons.exception.SystemException;
|
|
import com.jzg.commons.exception.SystemException;
|
|
|
import com.jzg.commons.exception.TokenExpireException;
|
|
import com.jzg.commons.exception.TokenExpireException;
|
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
import com.jzg.commons.util.AssertionUtils;
|
|
@@ -39,6 +42,7 @@ import com.jzg.quotation.summary.aop.OrderOperationLog;
|
|
|
import com.jzg.quotation.summary.aop.QuoteVerification;
|
|
import com.jzg.quotation.summary.aop.QuoteVerification;
|
|
|
import com.jzg.quotation.summary.async.AsyncGetPayLink;
|
|
import com.jzg.quotation.summary.async.AsyncGetPayLink;
|
|
|
import com.jzg.quotation.summary.classifier.QuoteInfoParameterFilling;
|
|
import com.jzg.quotation.summary.classifier.QuoteInfoParameterFilling;
|
|
|
|
|
+import com.jzg.quotation.summary.client.LocalLivingClient;
|
|
|
import com.jzg.quotation.summary.constants.QuoteNumberConstant;
|
|
import com.jzg.quotation.summary.constants.QuoteNumberConstant;
|
|
|
import com.jzg.quotation.summary.converter.QuoteInfoConverter;
|
|
import com.jzg.quotation.summary.converter.QuoteInfoConverter;
|
|
|
import com.jzg.quotation.summary.entity.po.QuoteRuleMapping;
|
|
import com.jzg.quotation.summary.entity.po.QuoteRuleMapping;
|
|
@@ -54,12 +58,16 @@ import lombok.RequiredArgsConstructor;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
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.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -145,6 +153,15 @@ public class UnifyOrderManager {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private AsyncGetPayLink asyncGetPayLink;
|
|
private AsyncGetPayLink asyncGetPayLink;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private LocalLivingClient localLivingClient;
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${lottery.activity.scene:3}")
|
|
|
|
|
+ private Integer lotteryScene;
|
|
|
|
|
+
|
|
|
|
|
+ //本地生活在一账通的固定平台ID
|
|
|
|
|
+ private static final String CLIENT_ID = "bdsh-X9yZ1wV3uT5sR7qP9o";
|
|
|
|
|
+
|
|
|
private String getSystemCode() {
|
|
private String getSystemCode() {
|
|
|
//如果是APP登录的话 则传递SystemCode的头部字段
|
|
//如果是APP登录的话 则传递SystemCode的头部字段
|
|
|
if (baseController.getUserSystemCode().equals("APP")) {
|
|
if (baseController.getUserSystemCode().equals("APP")) {
|
|
@@ -255,12 +272,107 @@ 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());
|
|
|
quoteResultsVo.setOrdersNo(ordersNo);
|
|
quoteResultsVo.setOrdersNo(ordersNo);
|
|
|
// 报价后更新订单
|
|
// 报价后更新订单
|
|
|
insOrdersService.orderAfterUpdateQuote(ordersNo, quoteResultsVo);
|
|
insOrdersService.orderAfterUpdateQuote(ordersNo, quoteResultsVo);
|
|
|
|
|
+
|
|
|
|
|
+ //////////////////////////////////////////新增营销抽奖活动////////////////////////////////////////////////
|
|
|
|
|
+ //远程调用活动列表
|
|
|
|
|
+ //匹配规则 每报价()次,可得()次抽奖机会,每日最多()次抽奖
|
|
|
|
|
+ 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)) {
|
|
|
|
|
+ int count = insOrdersService.countQuoteNum(baseController.getUserSystemCode(), quoteVo.getOrder().getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
|
|
+ if (count >= Integer.parseInt(table.getQutNum()) && count <= Integer.parseInt(table.getQutLotteryMax())) {
|
|
|
|
|
+ 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) {
|
|
|
log.error("车险报价异常", e);
|
|
log.error("车险报价异常", e);
|
|
|
Throwable root = e.getCause() != null ? e.getCause() : e;
|
|
Throwable root = e.getCause() != null ? e.getCause() : e;
|
|
@@ -272,6 +384,50 @@ public class UnifyOrderManager {
|
|
|
.equals(InsOrderStatusEnum.WAIT_AUDIT) ? HttpResult.ok(quoteResultsVo) : HttpResult.error(500, quoteResultsVo, quoteResultsVo.getErrorMessage());
|
|
.equals(InsOrderStatusEnum.WAIT_AUDIT) ? HttpResult.ok(quoteResultsVo) : HttpResult.error(500, quoteResultsVo, quoteResultsVo.getErrorMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 记录规则完成
|
|
|
|
|
+ */
|
|
|
|
|
+ private void completeRule(String tenantId, String userId, String userPhone, String activityId,
|
|
|
|
|
+ String tableId, String qutNum, String qutLotteryNum, String qutLotteryMax,Integer status, Integer activityType) {
|
|
|
|
|
+ SysUserActivityCompleteInRule exist = null;
|
|
|
|
|
+ // 先查询是否已存在记录(防重入)
|
|
|
|
|
+ if (9 != activityType) {
|
|
|
|
|
+ exist = insOrdersService.selectByRule(
|
|
|
|
|
+ tenantId, userId, activityId, qutNum, activityType);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ exist = insOrdersService.selectByRuleAndUserPhone(
|
|
|
|
|
+ activityId, userPhone, qutNum, activityType);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (exist != null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ SysUserActivityCompleteInRule record = new SysUserActivityCompleteInRule();
|
|
|
|
|
+ record.setTenantId(tenantId);
|
|
|
|
|
+ record.setUserId(userId);
|
|
|
|
|
+ record.setUserPhone(userPhone);
|
|
|
|
|
+ record.setActivityType(activityType);
|
|
|
|
|
+ record.setActivityId(activityId);
|
|
|
|
|
+ record.setLocalActivityTableId(tableId);
|
|
|
|
|
+ //报价/出单次数/承保费用
|
|
|
|
|
+ record.setRuleCompleteNum(qutNum);
|
|
|
|
|
+ //抽奖次数
|
|
|
|
|
+ record.setLotteryNum(StrUtil.isNotBlank(qutLotteryNum)
|
|
|
|
|
+ ? Integer.parseInt(qutLotteryNum) : 0);
|
|
|
|
|
+ //报价用,今日抽奖最大次数
|
|
|
|
|
+ record.setLotteryMaxNum(StrUtil.isNotBlank(qutLotteryMax)
|
|
|
|
|
+ ? Integer.parseInt(qutLotteryMax) : 0);
|
|
|
|
|
+ record.setStatus(status);
|
|
|
|
|
+ record.setReceiveTime(LocalDateTime.now());
|
|
|
|
|
+ record.setCreateBy(userId);
|
|
|
|
|
+ record.setUpdateBy(userId);
|
|
|
|
|
+ insOrdersService.insertActivityCompleteInRule(record);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("匹配规则完成,activityType={}, tenantId={}, userId={}, activityId={}, qutNum={}, qutLotteryNum={}, qutLotteryMax={}, userPhone={}",
|
|
|
|
|
+ activityType, tenantId, userId, activityId, qutNum, qutLotteryNum, qutLotteryMax, userPhone);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@OrderOperationLog(
|
|
@OrderOperationLog(
|
|
|
module = "车险订单",
|
|
module = "车险订单",
|
|
@@ -556,6 +712,110 @@ public class UnifyOrderManager {
|
|
|
|
|
|
|
|
// 保存状态查询结果
|
|
// 保存状态查询结果
|
|
|
insOrdersService.orderAfterUpdateOrderStatus(orderStatusVo.getOrder().getOrdersNo(), 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 (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());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 处理 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)) {
|
|
|
|
|
+ int count = insOrdersService.countOrderNum(baseController.getUserSystemCode(), insOrders.getRealQuoteUserId(), activity.getActivityStartTime(), activity.getActivityEndTime());
|
|
|
|
|
+ for (OrderRuleVO orderRule : table.getOrderRules()) {
|
|
|
|
|
+ if (count >= Integer.parseInt(orderRule.getOrdNum())) {
|
|
|
|
|
+ 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()) {
|
|
|
|
|
+ // 记录规则完成 标记已同步
|
|
|
|
|
+ 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());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return HttpResult.ok("状态刷新成功");
|
|
return HttpResult.ok("状态刷新成功");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -681,4 +941,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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|