| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- package com.ydtech.modules.order.controller;
- import com.alibaba.fastjson.JSON;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.ydtech.constants.enums.InsuranceRisk;
- import com.ydtech.constants.enums.dict.agreement.ProductsType;
- import com.ydtech.core.page.HttpResult;
- import com.ydtech.exception.SystemException;
- import com.ydtech.modules.base.controller.BaseController;
- import com.ydtech.modules.ins.model.vo.QuoteRespVo;
- import com.ydtech.modules.order.aop.QuoteVerification;
- import com.ydtech.modules.order.components.InsOrdersComponents;
- import com.ydtech.modules.order.entity.vo.AccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
- import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
- import com.ydtech.modules.order.entity.vo.QuoteAccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.bohai.BoHaiQuoteAccidentVo;
- import com.ydtech.modules.order.entity.vo.guoren.GuoRenQuoteVo;
- import com.ydtech.modules.order.entity.vo.guoren.GuorenAccidentalDrivingVo;
- import com.ydtech.modules.order.entity.vo.zj.ZjQuoteAccidentVo;
- import com.ydtech.modules.order.service.*;
- import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
- import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
- import com.ydtech.modules.protocol.entity.constants.PtlApiType;
- import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
- import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
- import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
- import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
- import com.ydtech.modules.protocol.service.impl.TaxSourceExcludeServiceImpl;
- import com.ydtech.utils.StringUtils;
- import io.swagger.annotations.Api;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.util.ObjectUtils;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Objects;
- @Api(tags = "报价")
- @RestController
- @RequestMapping(value = "/quote")
- public class QuoteController extends BaseController {
- @Autowired
- TaxSourceExcludeServiceImpl taxSourceExcludeService;
- @Autowired
- PtlTaxSourceNewService ptlTaxSourceNewService;
- @Autowired
- PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
- @Autowired
- InsOrdersComponents insOrdersComponents;
- @Autowired
- PtlAgreementAttributionService ptlAgreementAttributionService;
- @Autowired
- InsCrawlerOrderService insCrawlerOrderService;
- @Autowired
- ZhongMeiOrderApiService zhongMeiOrderApiService;
- @Autowired
- ZijinOrderApiService zijinOrderApiService;
- @Autowired
- YongchengOrderApiService yongchengOrderApiService;
- @Autowired
- HuaTaiOrderApiService huaTaiOrderApiService;
- @Autowired
- GuorenOrderApiService guorenOrderApiService;
- @Autowired
- DaJiaOrderService daJiaOrderService;
- @Autowired
- BoHaiOrderApiService boHaiOrderApiService;
- @Autowired
- PingAnOrderApiService pingAnOrderApiService;
- @Autowired
- InsOrdersService insOrdersService;
- @QuoteVerification("报价授权")
- @PostMapping(value = "/quote")
- public HttpResult<QuoteRespVo> quote(@RequestBody BaseQuoteVo<Object> quoteVo) throws Exception {
- String isTaxSource = quoteVo.getIsTaxSource();
- boolean isExclude = true;
- //排除的部门信息
- List<TaxSourceExcludeDto> excludeDepts =
- taxSourceExcludeService.list(new LambdaQueryWrapper<TaxSourceExcludeDto>()
- .eq(TaxSourceExcludeDto::getExcludeInfo, getDeptId())
- .eq(TaxSourceExcludeDto::getInsCompanyId, quoteVo.getCompanyId())
- .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
- BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
- //部门排除
- String finalDeptId = getDeptId();
- if (excludeDepts.stream().anyMatch(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(finalDeptId))) {
- isExclude = false;
- }
- if(Objects.isNull(quoteVo.getKinds())){
- quoteVo.setKinds(new ArrayList<>());
- }
- ProductsType insuranceRisk = InsuranceRisk.determineInsuranceInformation(quoteVo.getKinds(), quoteVo.getRisks());
- //默认协议走逻辑判断 且不在排除部门中走默认判断逻辑
- if(StringUtils.isNotBlank(isTaxSource) && "1".equals(isTaxSource) && isExclude){
- String taxAgreementId = ptlTaxSourceNewService.getAgreementId(getDeptId(), getUserId(), quoteVo.getCompanyId(), quoteInfo,insuranceRisk.getCode(),quoteVo.getOrderNo());
- quoteVo.setAgreementId(taxAgreementId);
- // log.info("======================订单号"+orderno+"走默认协议判断逻辑!匹配协议为:"+taxAgreementId+"=======================");
- //throw new SystemException("订单号"+orderno+"走默认协议判断逻辑!匹配协议为:"+taxAgreementId);
- }else{
- //不在排除部门内进行默认判断
- if(isExclude){
- //走正常协议判断是错误的 判断是否有默认配置,如果有不可能进来,前台报错
- List<PtlTaxSourceNew> taxSourceDtoList = ptlTaxSourceNewMapper.selectList(new LambdaQueryWrapper<PtlTaxSourceNew>()
- .eq(PtlTaxSourceNew::getInsCompanyId, quoteVo.getCompanyId())
- .eq(PtlTaxSourceNew::getDefaultFlag,"1"));
- if(taxSourceDtoList!=null && !taxSourceDtoList.isEmpty()){
- //throw new SystemException("配置默认协议且部门未排除应走默认逻辑,操作错误,请联系管理员!!");
- //强制走默认状态
- String taxAgreementId = ptlTaxSourceNewService.getAgreementId(getDeptId(), getUserId(), quoteVo.getCompanyId(), quoteInfo,insuranceRisk.getCode(),quoteVo.getOrderNo());
- quoteVo.setAgreementId(taxAgreementId);
- }
- }
- }
- HttpResult<QuoteRespVo> respVo = null;
- PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
- if (PtlApiType.PTL_API_2.getCode() == ptlAgreementAttribution.getApiType()) {
- BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- BaseQuoteVo baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- respVo = insCrawlerOrderService.quote(quoteInfo, baseQuoteVo);
- }
- if("ZMBX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- if(jsonObject.size() > 0) {
- AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- }else{
- quoteVo1.setAccidentalDrivingVo(null);
- }
- respVo = zhongMeiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("AICS1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- //转换类型
- BaseQuoteVo<AccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- respVo = yongchengOrderApiService.quoteApi(baseQuoteVo);
- }
- if("YAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- }
- if("ZKIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<List<ZjQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
- JSONArray jsonObject = JSONArray.parseArray(JSONArray.toJSONString(quoteVo.getAccidentalDrivingVo()));
- List<ZjQuoteAccidentVo> javaObject = jsonObject.toJavaList(ZjQuoteAccidentVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- respVo = zijinOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("XDCX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- GuoRenQuoteVo<QuoteAccidentalDrivingVo> quoteVo1 = new GuoRenQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- QuoteAccidentalDrivingVo javaObject = jsonObject.toJavaObject(QuoteAccidentalDrivingVo.class);
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- BaseQuoteVo<GuorenAccidentalDrivingVo> baseQuoteVo = insOrdersService.convertDriving(quoteVo1);
- GuoRenQuoteVo guoRenQuoteVo = new GuoRenQuoteVo();
- BeanUtils.copyProperties(baseQuoteVo, guoRenQuoteVo);
- guoRenQuoteVo.setGuoRenSpecialAgreementVo(baseQuoteVo.getGuoRenSpecialAgreementVo());
- respVo = guorenOrderApiService.quoteApi(guoRenQuoteVo);
- }
- if("HTIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- AccidentalDrivingVo javaObject = new AccidentalDrivingVo();
- if(!Objects.isNull(quoteVo.getAccidentalDrivingVo())) {
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- javaObject= jsonObject.toJavaObject(AccidentalDrivingVo.class);
- }
- BeanUtils.copyProperties(quoteVo,quoteVo1);
- quoteVo1.setAccidentalDrivingVo(javaObject);
- respVo = huaTaiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("DJPC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- respVo = daJiaOrderService.quote(quoteInfo, quoteVo);
- }
- if("BPIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<List<BoHaiQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- if(jsonObject.size() > 0) {
- BoHaiQuoteAccidentVo javaObject = new BoHaiQuoteAccidentVo();
- javaObject.setPackageCode(jsonObject.getString("projectCode"));
- javaObject.setProductCode(jsonObject.getString("riskCode"));
- javaObject.setCopies(jsonObject.getString("quantity"));
- List<BoHaiQuoteAccidentVo> javaObjectList = new ArrayList<>();
- javaObjectList.add(javaObject);
- quoteVo1.setAccidentalDrivingVo(javaObjectList);
- }else{
- quoteVo1.setAccidentalDrivingVo(new ArrayList<>());
- }
- respVo = boHaiOrderApiService.quote(quoteInfo, quoteVo1);
- }
- if("PAIC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- // BaseQuoteVo<AccidentalDrivingVo> quoteVo1 = new BaseQuoteVo<>();
- // JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- // AccidentalDrivingVo javaObject = jsonObject.toJavaObject(AccidentalDrivingVo.class);
- // BeanUtils.copyProperties(quoteVo,quoteVo1);
- // quoteVo1.setAccidentalDrivingVo(javaObject);
- // return pingAnOrderApiService.quote(quoteInfo, quoteVo1);
- }
- PtlAgreementAttribution byId = ptlAgreementAttributionService.getById(quoteVo.getAgreementId());
- if( respVo != null && !ObjectUtils.isEmpty( respVo.getData() )){
- respVo.getData().setApiType(byId.getApiType());
- }
- return respVo;
- }
- }
|