| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- package com.ydtech.modules.order.controller;
- 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.aop.request.RequestSingleParam;
- 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.KindInfoVo;
- 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.InsAreaCompany;
- import com.ydtech.modules.order.entity.InsDrivingIntentionInsurance;
- 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.yangguang.YgQuoteAccidentVo;
- import com.ydtech.modules.order.entity.vo.zj.ZjQuoteAccidentVo;
- import com.ydtech.modules.order.service.*;
- import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
- import com.ydtech.modules.protocol.entity.constants.PtlApiType;
- import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
- import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
- import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
- import com.ydtech.modules.protocol.service.PtlAgreementService;
- 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.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.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- 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;
- @Autowired
- InsAreaCompanyService insAreaCompanyService;
- @Autowired
- ChengTaiOrderApiService chengTaiOrderApiService;
- @Autowired
- YongAnOrderService yongAnOrderService;
- @Autowired
- YangGuangOrderApiService yangGuangOrderApiService;
- @Autowired
- PtlAgreementService ptlAgreementService;
- @Autowired
- InsDrivingIntentionInsuranceService insDrivingIntentionInsuranceService;
- @QuoteVerification("报价授权")
- @PostMapping(value = "/quote")
- public HttpResult<QuoteRespVo> quote(@RequestBody BaseQuoteVo<Object> quoteVo) throws Exception {
- //处理商业险 为空的去掉
- List<KindInfoVo> kinds = quoteVo.getKinds();
- kinds.removeIf(item->Double.compare(item.getAmount(),0) == 0 && Double.compare(item.getUnitAmount(),0) == 0 && item.getServiceTimes() == 0);
- BaseQuoteInfoVo quoteInfo = insOrdersComponents.getQuoteInfo(quoteVo.getOrderNo(), quoteVo.getAgreementId(),quoteVo.getKinds());
- quoteInfo.setKindList(kinds);
- //设置座位数 驾意险需要传
- quoteVo.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
- HttpResult<QuoteRespVo> respVo = null;
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- HttpResult<PtlAgreementQueryVo> byAgreementId = ptlAgreementService.getByAgreementId(quoteVo.getAgreementId());
- LocalDateTime currentDate = LocalDateTime.now();
- if(byAgreementId.getData().getAgreement().getIsValid().equals("0") //是否有效
- || byAgreementId.getData().getAgreement().getValidStatus().equals("0") //是否有效
- || !(currentDate.isAfter(byAgreementId.getData().getAgreement().getStartDate()) && currentDate.isBefore(byAgreementId.getData().getAgreement().getEndDate()))){
- throw new SystemException("协议失效,请检查调度");
- }
- 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);
- quoteVo1.setSeatNum(quoteInfo.getCarInfo().getSeatCount());
- 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);
- // quoteVo1.setSeatNum();
- 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("CHAC1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)){
- BaseQuoteVo<InsDrivingIntentionInsurance> quoteVo1 = new BaseQuoteVo<>();
- InsDrivingIntentionInsurance javaObject = new InsDrivingIntentionInsurance();
- if(!Objects.isNull(quoteVo.getAccidentalDrivingVo())) {
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- javaObject = jsonObject.toJavaObject(InsDrivingIntentionInsurance.class);
- BeanUtils.copyProperties(quoteVo,quoteVo1);
- if(StringUtils.isNotBlank(javaObject.getProjectCode())){
- LambdaQueryWrapper<InsDrivingIntentionInsurance> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(InsDrivingIntentionInsurance::getProjectCode,javaObject.getProjectCode());
- InsDrivingIntentionInsurance insDrivingIntentionInsurance = insDrivingIntentionInsuranceService.getOne(wrapper);
- if (StringUtils.isNotBlank(insDrivingIntentionInsurance.getRelateCode())){
- javaObject.setProjectCode(insDrivingIntentionInsurance.getRelateCode());
- quoteVo1.setAccidentalDrivingVo(javaObject);
- }else{
- throw new SystemException("驾意险失效,请检查方案配置");
- }
- }else{
- quoteVo1.setAccidentalDrivingVo(javaObject);
- }
- }
- respVo = chengTaiOrderApiService.quoteApi(quoteInfo, quoteVo1);
- }
- if ("YGBX1000000".equals(ptlAgreementAttribution.getInsCompanyId()) && Objects.isNull(respVo)) {
- BaseQuoteVo<List<YgQuoteAccidentVo>> quoteVo1 = new BaseQuoteVo<>();
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(quoteVo.getAccidentalDrivingVo()));
- BeanUtils.copyProperties(quoteVo, quoteVo1);
- if(jsonObject.size() > 0) {
- YgQuoteAccidentVo ygQuoteAccidentVo = new YgQuoteAccidentVo();
- ygQuoteAccidentVo.setProductCode(jsonObject.getString("projectCode"));
- ygQuoteAccidentVo.setQuantityCasualty(jsonObject.getString("quantity"));
- List<YgQuoteAccidentVo> javaObjectList = new ArrayList<>();
- javaObjectList.add(ygQuoteAccidentVo);
- quoteVo1.setAccidentalDrivingVo(javaObjectList);
- } else {
- quoteVo1.setAccidentalDrivingVo(new ArrayList<>());
- }
- respVo = yangGuangOrderApiService.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());
- respVo.getData().setOrderstatus("0");
- }
- return respVo;
- }
- @PostMapping(value = "submitImage")
- public HttpResult submitImage(@RequestSingleParam(value = "companyId") String companyId) throws Exception {
- InsAreaCompany insAreaCompany = insAreaCompanyService.getById(companyId);
- PtlAgreementAttribution ptlAgreementAttribution = ptlAgreementAttributionService.getById(insAreaCompany.getAgreementId());
- if(Objects.isNull(ptlAgreementAttribution) || Objects.isNull(ptlAgreementAttribution.getApiType())){
- throw new SystemException("协议数据出错,请联系管理员");
- }
- HttpResult httpResult = null;
- //判断是否是爬虫
- if(ptlAgreementAttribution.getApiType() == 2){
- httpResult = insCrawlerOrderService.submitImage(companyId);
- }else if(ptlAgreementAttribution.getApiType() == 1){
- //渤海
- if(insAreaCompany.getCompanyId().equals("BPIC1000000")){
- httpResult = boHaiOrderApiService.submitImage(companyId);
- }
- //大家
- if(insAreaCompany.getCompanyId().equals("DJPC1000000")){
- httpResult = daJiaOrderService.submitImage(companyId);
- }
- //国任
- if(insAreaCompany.getCompanyId().equals("XDCX1000000")){
- httpResult = guorenOrderApiService.uploadImageApi(companyId);
- }
- //华泰
- if(insAreaCompany.getCompanyId().equals("HTIC1000000")){
- httpResult = huaTaiOrderApiService.submitImage(companyId);
- }
- //永安
- if(insAreaCompany.getCompanyId().equals("YAIC1000000")){
- httpResult = yongAnOrderService.submitImage(companyId);
- }
- //永诚
- if(insAreaCompany.getCompanyId().equals("AICS1000000")){
- httpResult = yongchengOrderApiService.uploadImageApi(companyId);
- }
- //中煤
- if(insAreaCompany.getCompanyId().equals("ZMBX1000000")){
- httpResult = zhongMeiOrderApiService.submitImage(companyId);
- }
- //紫金
- if(insAreaCompany.getCompanyId().equals("ZKIC1000000")){
- httpResult = zijinOrderApiService.submitImage(companyId);
- }
- //诚泰
- if(insAreaCompany.getCompanyId().equals("CHAC1000000")){
- httpResult = chengTaiOrderApiService.submitImages(companyId);
- }
- //阳光
- if (insAreaCompany.getCompanyId().equals("YGBX1000000")) {
- httpResult = yangGuangOrderApiService.upload(companyId);
- }
- }
- return httpResult;
- }
- @PostMapping(value = "batchOrderStatus")
- public HttpResult batchOrderStatus(@RequestSingleParam("orderNos") List<String> orderNos) throws Exception {
- List<InsAreaCompany> list = insAreaCompanyService.list(new LambdaQueryWrapper<InsAreaCompany>()
- .in(InsAreaCompany::getId, orderNos));
- list.forEach(item -> {
- //如果是爬虫的 先调用爬虫的查询订单状态
- if (Objects.isNull(item.getApiType()) || item.getApiType() == 2) {
- try {
- insCrawlerOrderService.verifyPayment(item.getId());
- }catch (Exception e){
- }
- }
- if (item.getCompanyId().equals("AICS1000000") && item.getApiType() == 1) {
- try {
- yongchengOrderApiService.callbackAnOrder(item.getId());
- }catch (Exception e){
- }
- } else if (item.getCompanyId().equals("ZMBX1000000") && item.getApiType() == 1) {
- try {
- zhongMeiOrderApiService.paymentEnquiry(item.getId());
- }catch (Exception e){}
- } else if (item.getCompanyId().equals("ZKIC1000000")) {
- try {
- zijinOrderApiService.auditStatusQuery(item.getId());
- }catch (Exception e){}
- } else if (item.getCompanyId().equals("XDCX1000000")) {
- try {
- guorenOrderApiService.pay(item.getId());
- }catch (Exception e){}
- } else if (item.getCompanyId().equals("YGBX1000000")) {
- try {
- yangGuangOrderApiService.paymentCallback(item.getId());
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- } else if (item.getCompanyId().equals("HTIC1000000")) {
- try {
- huaTaiOrderApiService.paymentEnquiry(item.getId());
- }catch (Exception e){}
- } else if (item.getCompanyId().equals("DJPC1000000")) {
- try {
- daJiaOrderService.verifyPayment(item.getId());
- }catch (Exception e){}
- } else if (item.getCompanyId().equals("CHAC1000000")) {
- try {
- chengTaiOrderApiService.getPayUrl(item.getId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else if (item.getCompanyId().equals("BPIC1000000")) {
- try {
- boHaiOrderApiService.auditStatusQuery(item.getId());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- return HttpResult.ok("查询成功");
- }
- }
|