|
|
@@ -1,8 +1,18 @@
|
|
|
package com.ydtech.modules.order.controller;
|
|
|
|
|
|
-import com.ydtech.core.page.HttpResult;
|
|
|
+import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.constants.UserConstants;
|
|
|
+import com.ydtech.modules.admin.model.po.SysBarcodeConfig;
|
|
|
+import com.ydtech.modules.admin.service.SysBarcodeConfigService;
|
|
|
import com.ydtech.modules.admin.service.SysQRCodeRelationService;
|
|
|
+import com.ydtech.modules.admin.service.impl.SysBarcodeConfigServiceImpl;
|
|
|
+import com.ydtech.modules.esm.model.EsmInsCompany;
|
|
|
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
|
|
|
+import com.ydtech.modules.esm.service.impl.EsmInsCompanyServiceImpl;
|
|
|
import com.ydtech.modules.order.entity.InsAreaCompany;
|
|
|
import com.ydtech.modules.order.entity.InsOrderQrCode;
|
|
|
import com.ydtech.modules.order.entity.InsOrders;
|
|
|
@@ -13,6 +23,7 @@ import com.ydtech.modules.order.service.InsOrdersService;
|
|
|
import com.ydtech.modules.protocol.entity.constants.PtlApiType;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -26,6 +37,7 @@ import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@Api(tags = "订单二维码管理")
|
|
|
@@ -39,15 +51,24 @@ public class QrCodeController {
|
|
|
@Resource
|
|
|
private InsAreaCompanyService insAreaCompanyService;
|
|
|
|
|
|
- @Resource
|
|
|
- private InsOrdersService insOrdersService;
|
|
|
@Resource
|
|
|
SysQRCodeRelationService sysQRCodeRelationService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ SysBarcodeConfigService sysBarcodeConfigService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ InsOrdersService insOrdersService;
|
|
|
+
|
|
|
//二维码生成地址
|
|
|
@Value("${qrcode.genAddress}")
|
|
|
private String qrCodeGenAddress;
|
|
|
|
|
|
+ //二维码生成地址
|
|
|
+ @Value("${qrcode.imageSrc}")
|
|
|
+ private String imageSrc;
|
|
|
+ @Autowired
|
|
|
+ private EsmInsCompanyService esmInsCompanyService;
|
|
|
|
|
|
@GetMapping(value = "/getQrCode")
|
|
|
@ApiOperation(value = "获取二维码")
|
|
|
@@ -61,16 +82,7 @@ public class QrCodeController {
|
|
|
InsOrders insOrders = insOrdersService.getById(insOrderQrCode.getOrderno());
|
|
|
|
|
|
QrCodeVo qrCodeVo = new QrCodeVo();
|
|
|
- String qrCodeUrl = "";
|
|
|
- //是否是太平洋保险 大家财险
|
|
|
- if ("TPIC1000000".equals(insAreaCompany.getCompanyId()) || "DJPC1000000".equals(insAreaCompany.getCompanyId())
|
|
|
- || ("CHAC1000000").equals(insAreaCompany.getCompanyId())
|
|
|
- || ("HTIC1000000".equals(insAreaCompany.getCompanyId()) && PtlApiType.PTL_API_2.getCode() == insAreaCompany.getApiType())) {
|
|
|
- qrCodeUrl = insAreaCompany.getPaymentLink();
|
|
|
- } else {
|
|
|
- qrCodeUrl = qrCodeGenAddress + "?areaCompanyId=" + areaCompanyId;
|
|
|
- }
|
|
|
-
|
|
|
+ String qrCodeUrl = qrCodeGenAddress + "?areaCompanyId=" + areaCompanyId;
|
|
|
qrCodeVo.setQrCodeUrl(qrCodeUrl);
|
|
|
qrCodeVo.setInscompany(insAreaCompany.getInscompany());//保险公司
|
|
|
qrCodeVo.setSumpremium(insAreaCompany.getSumpremium());//总保费
|
|
|
@@ -99,7 +111,6 @@ public class QrCodeController {
|
|
|
return modelAndView;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@PostMapping(value = "/destructionQrCode")
|
|
|
@ApiOperation(value = "销毁二维码")
|
|
|
public ModelAndView destructionQrCode(String areaCompanyId) {
|
|
|
@@ -116,29 +127,78 @@ public class QrCodeController {
|
|
|
|
|
|
@GetMapping(value = "/index")
|
|
|
@ApiOperation(value = "扫描二维码地址")
|
|
|
- public String index(String areaCompanyId) throws IOException {
|
|
|
+ @SaIgnore
|
|
|
+ public ModelAndView index(String areaCompanyId) throws IOException {
|
|
|
InsOrderQrCode insOrderQrCode = insOrderQrCodeService.getOne(areaCompanyId);
|
|
|
+ InsAreaCompany insAreaCompany = insAreaCompanyService.getById(areaCompanyId);
|
|
|
+ // 根据保险公司获取二维码配置方式
|
|
|
+ LambdaQueryWrapper<SysBarcodeConfig> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SysBarcodeConfig::getCompanyId, insAreaCompany.getCompanyId());
|
|
|
+ List<SysBarcodeConfig> configs = sysBarcodeConfigService.list(wrapper);
|
|
|
+ if (CollUtil.isEmpty(configs) || configs.size() > 1) {
|
|
|
+ //重定向到错误页面中
|
|
|
+ ModelAndView modelAndView = new ModelAndView("qrcode_error");
|
|
|
+ return modelAndView;
|
|
|
+ }
|
|
|
+ Integer configType = configs.get(0).getType();
|
|
|
if (insOrderQrCode == null) {
|
|
|
//重定向到错误页面中
|
|
|
- return "redirect:/order/qrCode/error";
|
|
|
+ ModelAndView modelAndView = new ModelAndView("qrcode_error");
|
|
|
+ return modelAndView;
|
|
|
}
|
|
|
-
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String qrcodeCreateTimeStr = dateFormat.format(insOrderQrCode.getCreatetime());
|
|
|
- LocalDate qrcodeCreateTime = LocalDate.parse(qrcodeCreateTimeStr);
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
-
|
|
|
- if (Math.abs(currentDate.toEpochDay() - qrcodeCreateTime.toEpochDay()) >= 1) {
|
|
|
+ if(UserConstants.CONFIG_TYPE_2.equals(configType) || UserConstants.CONFIG_TYPE_1.equals(configType)){
|
|
|
+ InsOrders insOrders = insOrdersService.getById(insOrderQrCode.getOrderno());
|
|
|
+ // 获取图标
|
|
|
+ EsmInsCompany company = esmInsCompanyService.getById(insAreaCompany.getCompanyId());
|
|
|
+ ModelAndView modelAndView = new ModelAndView("qrcode");
|
|
|
+ QrCodeVo qrCodeVo = new QrCodeVo();
|
|
|
+ qrCodeVo.setLogo(company.getLogo());
|
|
|
+ if(UserConstants.CONFIG_TYPE_1.equals(configType)){
|
|
|
+ qrCodeVo.setQrCodeUrl("data:image/png;base64,"+insAreaCompany.getPaymentLink());
|
|
|
+ } else {
|
|
|
+ qrCodeVo.setQrCodeUrl("https://api.qrserver.com/v1/create-qr-code/?size=300x300&data="+insAreaCompany.getPaymentLink());
|
|
|
+ }
|
|
|
+ qrCodeVo.setImageSrc(imageSrc);
|
|
|
+ qrCodeVo.setInscompany(insAreaCompany.getInscompany());//保险公司
|
|
|
+ qrCodeVo.setInscompanyCode(insAreaCompany.getCompanyId());//保险公司编号
|
|
|
+ qrCodeVo.setSumpremium(insAreaCompany.getSumpremium());//总保费
|
|
|
+ qrCodeVo.setSypremium(insAreaCompany.getSypremium());//商业险
|
|
|
+ qrCodeVo.setJqpremium(insAreaCompany.getJqpremium());//交强险
|
|
|
+ qrCodeVo.setTaxamount(insAreaCompany.getTaxamount());//车船税
|
|
|
+ qrCodeVo.setJypremium(insAreaCompany.getJypremium());//驾驭险
|
|
|
+ qrCodeVo.setCApplyNme(insOrders.getApplyinfo().getString("name"));//投保人
|
|
|
+ qrCodeVo.setCInsuredNme(insOrders.getInsureinfo().getString("name"));//被保人
|
|
|
+ qrCodeVo.setCOwnerNme(insOrders.getOwnerinfo().getString("name"));//车主
|
|
|
+ qrCodeVo.setCPlateNo(insOrders.getLicenseno());//车牌号
|
|
|
+ qrCodeVo.setJqStartDate(insAreaCompany.getJqStartDate());//交强开始时间
|
|
|
+ qrCodeVo.setJqEndDate(insAreaCompany.getJqEndDate());//交强结束时间
|
|
|
+ qrCodeVo.setSyStartDate(insAreaCompany.getSyStartDate());
|
|
|
+ qrCodeVo.setSysEndDate(insAreaCompany.getSyEndDate());
|
|
|
+ qrCodeVo.setSyStartDate(insAreaCompany.getSyStartDate());
|
|
|
+ qrCodeVo.setSysEndDate(insAreaCompany.getSyEndDate());
|
|
|
+ modelAndView.addObject("data",qrCodeVo);
|
|
|
+ return modelAndView;
|
|
|
+ } else if(UserConstants.CONFIG_TYPE_0.equals(configType)){
|
|
|
+ //更新二维码扫描时间
|
|
|
+ insOrderQrCode.setScanCodeTime(new Date());
|
|
|
+ insOrderQrCodeService.updateById(insOrderQrCode);
|
|
|
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String qrcodeCreateTimeStr = dateFormat.format(insOrderQrCode.getCreatetime());
|
|
|
+ LocalDate qrcodeCreateTime = LocalDate.parse(qrcodeCreateTimeStr);
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+
|
|
|
+ if (Math.abs(currentDate.toEpochDay() - qrcodeCreateTime.toEpochDay()) >= 1) {
|
|
|
+ //重定向到错误页面中
|
|
|
+ ModelAndView modelAndView = new ModelAndView("qrcode_error");
|
|
|
+ return modelAndView;
|
|
|
+ }
|
|
|
+ ModelAndView modelAndView = new ModelAndView("https://api.qrserver.com/v1/create-qr-code/?size=300x300&data="+insOrderQrCode.getJumpUrl());
|
|
|
+ return modelAndView;
|
|
|
+ }else{
|
|
|
//重定向到错误页面中
|
|
|
- return "redirect:/order/qrCode/error";
|
|
|
+ ModelAndView modelAndView = new ModelAndView("qrcode_error");
|
|
|
+ return modelAndView;
|
|
|
}
|
|
|
-
|
|
|
- //更新二维码扫描时间
|
|
|
- insOrderQrCode.setScanCodeTime(new Date());
|
|
|
- insOrderQrCodeService.updateById(insOrderQrCode);
|
|
|
- //直接重定向到jumlurl
|
|
|
- return "redirect:" + insOrderQrCode.getJumpUrl();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|