18 files modified
1 files added
1 files deleted
| | |
| | | if ("/user/buchahbds.do".equals(url)) { |
| | | return true; |
| | | } |
| | | if ("/user/viewAgreementPdf.do".equals(url)) { |
| | | // PDF查看需要验证用户,允许通过cookie或header的token访问 |
| | | User currentUser = getCurrentUser(httpServletRequest); |
| | | if (currentUser == null) { |
| | | // 没有有效token,返回错误 |
| | | httpServletResponse.setCharacterEncoding("UTF-8"); |
| | | httpServletResponse.setContentType("application/json;charset=UTF-8"); |
| | | PrintWriter writer = httpServletResponse.getWriter(); |
| | | Map map = Maps.newHashMap(); |
| | | map.put("success", Boolean.valueOf(false)); |
| | | map.put("msg", "請先登錄,無權限訪問user"); |
| | | writer.print(JsonUtil.obj2String(map)); |
| | | writer.flush(); |
| | | writer.close(); |
| | | return false; |
| | | } |
| | | return true; // 已登录,允许访问 |
| | | } |
| | | User currentUser = getCurrentUser(httpServletRequest); |
| | | if (null == currentUser) { |
| | | // httpServletResponse.reset(); |
| | |
| | | String property = PropertiesUtil.getProperty("user.cookie.name"); |
| | | System.out.println(property); |
| | | String loginToken = request.getHeader(property); |
| | | |
| | | // 如果header中没有token,尝试从cookie获取 |
| | | if (loginToken == null) { |
| | | loginToken = getTokenFromCookie(request); |
| | | } |
| | | |
| | | // 如果cookie中也没有token,尝试从URL参数获取(用于iframe等场景) |
| | | if (loginToken == null) { |
| | | loginToken = request.getParameter("token"); |
| | | } |
| | | |
| | | if (loginToken == null) { |
| | | System.out.println("loginToken is null"); |
| | | return null; |
| | |
| | | // System.out.println(userJson); |
| | | return (User) JsonUtil.string2Obj(userJson, User.class); |
| | | } |
| | | |
| | | /** |
| | | * 从Cookie中获取token |
| | | * |
| | | * @param request 请求 |
| | | * @return token |
| | | */ |
| | | private String getTokenFromCookie(HttpServletRequest request) { |
| | | javax.servlet.http.Cookie[] cookies = request.getCookies(); |
| | | if (cookies != null) { |
| | | String cookieName = PropertiesUtil.getProperty("user.cookie.name"); |
| | | for (javax.servlet.http.Cookie cookie : cookies) { |
| | | if (cookieName != null && cookieName.equals(cookie.getName())) { |
| | | return cookie.getValue(); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | * 实名认证 |
| | | * @param realName |
| | | * @param idCard |
| | | * @param address |
| | | * @param img1key |
| | | * @param img2key |
| | | * @param img3key |
| | |
| | | */ |
| | | @RequestMapping({"auth.do"}) |
| | | @ResponseBody |
| | | public ServerResponse auth(String realName, String idCard, String img1key, String img2key, String img3key, HttpServletRequest request) { |
| | | return this.iUserService.auth(realName, idCard, img1key, img2key, "", request); |
| | | public ServerResponse auth(String realName, String idCard, String address, String img1key, String img2key, String img3key, HttpServletRequest request) { |
| | | return this.iUserService.auth(realName, idCard, address, img1key, img2key, "", request); |
| | | } |
| | | |
| | | //图片上传 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成用户协议PDF |
| | | * 生成用户合同PDF |
| | | */ |
| | | @RequestMapping({"generateAgreementPdf.do"}) |
| | | @ResponseBody |
| | |
| | | this.iUserAgreementService.viewAgreementPdf(request, response); |
| | | } |
| | | |
| | | /** |
| | | * 保存用户协议签名 |
| | | */ |
| | | @RequestMapping({"saveAgreementSignature.do"}) |
| | | @ResponseBody |
| | | public ServerResponse saveAgreementSignature(@RequestParam("signature") MultipartFile signatureFile, HttpServletRequest request) { |
| | | return this.iUserAgreementService.saveAgreementSignature(signatureFile, request); |
| | | } |
| | | |
| | | /** |
| | | * 生成用户合同PDF |
| | | */ |
| | | @RequestMapping({"generateAgreementContractPdf.do"}) |
| | | @ResponseBody |
| | | public ServerResponse generateAgreementContractPdf(HttpServletRequest request) { |
| | | return this.iUserAgreementService.generateAgreementContractPdf(request); |
| | | } |
| | | |
| | | /** |
| | | * 查看用户合同PDF |
| | | */ |
| | | @RequestMapping({"viewAgreementContractPdf.do"}) |
| | | public void viewAgreementContractPdf(HttpServletRequest request, HttpServletResponse response) { |
| | | this.iUserAgreementService.viewAgreementContractPdf(request, response); |
| | | } |
| | | |
| | | /** |
| | | * 保存用户合同签名 |
| | | */ |
| | | @RequestMapping({"saveAgreementContractSignature.do"}) |
| | | @ResponseBody |
| | | public ServerResponse saveAgreementContractSignature(@RequestParam("signature") MultipartFile signatureFile, HttpServletRequest request) { |
| | | return this.iUserAgreementService.saveAgreementContractSignature(signatureFile, request); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | int updateByPrimaryKeySelective(User paramUser); |
| | | |
| | | int updateSignedContract(@Param("userId") Integer userId, @Param("signedContract") String signedContract); |
| | | |
| | | int updateSignedAgreement(@Param("userId") Integer userId, @Param("signedAgreement") String signedContract); |
| | | |
| | | |
| | | |
| | | int updateByPrimaryKey(User paramUser); |
| | | |
| | | User findByPhone(String paramString); |
| | |
| | | } |
| | | |
| | | public void setDescription(String description) { |
| | | this.description = ZhConverterUtil.convertToTraditional(description); |
| | | // this.description = ZhConverterUtil.convertToTraditional(description); |
| | | this.description = description; |
| | | } |
| | | |
| | | public void setContent(String content) { |
| | | this.content = ZhConverterUtil.convertToTraditional(content); |
| | | // this.content = ZhConverterUtil.convertToTraditional(content); |
| | | this.content = content; |
| | | } |
| | | |
| | | public void setTitle(String title) { |
| | | this.title = ZhConverterUtil.convertToTraditional(title); |
| | | // this.title = ZhConverterUtil.convertToTraditional(title); |
| | | this.title = title; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | private BigDecimal djzj; |
| | | |
| | | public User(Integer id, Integer agentId, String agentName, String phone, String userPwd, String withPwd, String nickName, String realName, String idCard, Integer accountType, BigDecimal userAmt, BigDecimal enableAmt, BigDecimal enaleWithdrawAmt, BigDecimal hkAmt, BigDecimal sumChargeAmt, BigDecimal sumBuyAmt, String recomPhone, Integer isLock, Integer isLogin, Date regTime, String regIp, String regAddress, String img1Key, String img2Key, String img3Key, Integer isActive, String authMsg, BigDecimal userIndexAmt, BigDecimal enableIndexAmt, BigDecimal userFutAmt, BigDecimal enableFutAmt, String withdrawalPwd, BigDecimal tradingAmount, Integer isAuthorize, BigDecimal sgzj, BigDecimal djzj) { |
| | | private String isSignedContract; |
| | | |
| | | private String isSignedAgreement; |
| | | |
| | | public User(Integer id, Integer agentId, String agentName, String phone, String userPwd, String withPwd, String nickName, String realName, String idCard, Integer accountType, BigDecimal userAmt, |
| | | BigDecimal enableAmt, BigDecimal enaleWithdrawAmt, BigDecimal hkAmt, BigDecimal sumChargeAmt, BigDecimal sumBuyAmt, String recomPhone, Integer isLock, Integer isLogin, Date regTime, |
| | | String regIp, String regAddress, String img1Key, String img2Key, String img3Key, Integer isActive, String authMsg, BigDecimal userIndexAmt, BigDecimal enableIndexAmt, BigDecimal userFutAmt, |
| | | BigDecimal enableFutAmt, String withdrawalPwd, BigDecimal tradingAmount, Integer isAuthorize, BigDecimal sgzj, BigDecimal djzj, |
| | | String isSignedContract, String isSignedAgreement) { |
| | | this.id = id; |
| | | this.agentId = agentId; |
| | | this.agentName = agentName; |
| | |
| | | this.isAuthorize = isAuthorize; |
| | | this.sgzj = sgzj; |
| | | this.djzj = djzj; |
| | | this.isSignedContract = isSignedContract; |
| | | this.isSignedAgreement = isSignedAgreement; |
| | | } |
| | | |
| | | public User() { |
| | |
| | | public void setDjzj(BigDecimal djzj) { |
| | | this.djzj = djzj; |
| | | } |
| | | |
| | | public String getIsSignedContract() { |
| | | return isSignedContract; |
| | | } |
| | | |
| | | public void setIsSignedContract(String isSignedContract) { |
| | | this.isSignedContract = isSignedContract; |
| | | } |
| | | |
| | | public String getIsSignedAgreement() { |
| | | return isSignedAgreement; |
| | | } |
| | | |
| | | public void setIsSignedAgreement(String isSignedAgreement) { |
| | | this.isSignedAgreement = isSignedAgreement; |
| | | } |
| | | } |
| | |
| | | package com.nq.service; |
| | | |
| | | import com.nq.common.ServerResponse; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | * @return |
| | | */ |
| | | void viewAgreementPdf(HttpServletRequest request, HttpServletResponse response); |
| | | |
| | | /** |
| | | * 保存用户协议签名 |
| | | * @param signatureFile 签名图片文件 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | ServerResponse saveAgreementSignature(MultipartFile signatureFile, HttpServletRequest request); |
| | | |
| | | /** |
| | | * 生成用户合同PDF |
| | | * @param request |
| | | * @return PDF文件路径 |
| | | */ |
| | | ServerResponse generateAgreementContractPdf(HttpServletRequest request); |
| | | |
| | | /** |
| | | * 查看用户合同PDF |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | void viewAgreementContractPdf(HttpServletRequest request, HttpServletResponse response); |
| | | |
| | | /** |
| | | * 保存用户合同签名 |
| | | * @param signatureFile 签名图片文件 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | ServerResponse saveAgreementContractSignature(MultipartFile signatureFile, HttpServletRequest request); |
| | | } |
| | |
| | | |
| | | ServerResponse update(User paramUser); |
| | | |
| | | void updateSignedContract(Integer userId, String signedContract); |
| | | |
| | | void updateSignedAgreement(Integer userId, String signedAgreement); |
| | | |
| | | |
| | | /** |
| | | * 人民币和港币之间兑换操作 |
| | |
| | | */ |
| | | ServerResponse exchangeOp(BigDecimal amt,Integer type,HttpServletRequest request) throws Exception ; |
| | | |
| | | ServerResponse auth(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, HttpServletRequest paramHttpServletRequest); |
| | | ServerResponse auth(String paramString1, String paramString2,String address, String paramString3, String paramString4, String paramString5, HttpServletRequest paramHttpServletRequest); |
| | | |
| | | ServerResponse transAmt(Integer paramInteger1, Integer paramInteger2, HttpServletRequest paramHttpServletRequest); |
| | | |
| | |
| | | List<SiteNews> listData = this.siteNewsMapper.pageList(pageNum, pageSize, type, sort, keyword); |
| | | GoogleTranslateUtil googleTranslateUtil = new GoogleTranslateUtil(); |
| | | //取出每一条数据的内容,进行翻译 |
| | | |
| | | if (request.getHeader("lang") != null && !request.getHeader("lang").equals("zh-CN")&& !request.getHeader("lang").equals("tww")&& !request.getHeader("lang").equals("")) { |
| | | for (SiteNews siteNews : listData) { |
| | | //将title description content放一个数组里面 |
| | | |
| | | |
| | | // String zh = siteNews.getContent(); |
| | | |
| | | try { |
| | | // siteNews.setContent(googleTranslateUtil.translate(siteNews.getContent(), request.getHeader("lang"))); |
| | | siteNews.setTitle(googleTranslateUtil.translate(siteNews.getTitle(), request.getHeader("lang"))); |
| | | // siteNews.setDescription(googleTranslateUtil.translate(siteNews.getDescription(), request.getHeader("lang"))); |
| | | siteNews.setSourceName(googleTranslateUtil.translate(siteNews.getSourceName(), request.getHeader("lang"))); |
| | | } catch (Exception e) { |
| | | log.error("翻译失败"); |
| | | } |
| | | for (SiteNews siteNews : listData) { |
| | | try { |
| | | siteNews.setTitle(googleTranslateUtil.translate(siteNews.getTitle(), "zh-CN")); |
| | | siteNews.setSourceName(googleTranslateUtil.translate(siteNews.getSourceName(), "zh-CN")); |
| | | } catch (Exception e) { |
| | | log.error("翻译失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | PageInfo pageInfo = new PageInfo(listData); |
| | |
| | | if (dbproduct == null) { |
| | | return ServerResponse.createByErrorMsg("不存在产品设置记录"); |
| | | } |
| | | |
| | | int updateCount = this.siteProductMapper.updateByPrimaryKeySelective(siteProduct); |
| | | if (updateCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("修改成功"); |
| | |
| | | import java.io.*; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.itextpdf.text.*; |
| | | import com.itextpdf.text.pdf.*; |
| | |
| | | private com.nq.service.IUserService iUserService; |
| | | |
| | | @Override |
| | | |
| | | // 在generateAgreementPdf方法中修改返回逻辑 |
| | | public ServerResponse generateAgreementPdf(HttpServletRequest request) { |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | user = (User) iUserService.findByUserId(user.getId()).getData(); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户未登录"); |
| | | } |
| | |
| | | } |
| | | |
| | | // 检查是否已生成PDF |
| | | String pdfDir = PropertiesUtil.getProperty("agreement.pdf.dir", System.getProperty("user.dir") + "/agreement_pdf"); |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | |
| | | File dir = new File(pdfDir); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | |
| | | |
| | | String pdfFileName = "agreement_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(dir, pdfFileName); |
| | | |
| | | // 构建完整的PDF访问URL |
| | | String pdfUrl = PropertiesUtil.getProperty("pdf.server.http.prefix") + "/agreement_" + user.getId() + ".pdf"; |
| | | |
| | | // 如果PDF已存在,删除后重新生成,确保数据是最新的 |
| | | if (pdfFile.exists()) { |
| | | return ServerResponse.createBySuccess(pdfFileName); |
| | | log.info("PDF文件已存在,删除后重新生成: {}", pdfFile.getAbsolutePath()); |
| | | boolean deleted = pdfFile.delete(); |
| | | if (!deleted) { |
| | | log.warn("删除旧PDF文件失败: {}", pdfFile.getAbsolutePath()); |
| | | } |
| | | } |
| | | |
| | | // 获取模板文件路径 |
| | | String templatePath = this.getClass().getResource("/templates").getPath(); |
| | | if (templatePath.startsWith("/") && System.getProperty("os.name").toLowerCase().contains("windows")) { |
| | | templatePath = templatePath.substring(1); |
| | | } |
| | | templatePath = templatePath.replaceAll("%20", " "); |
| | | if (templatePath.contains("file:")) { |
| | | templatePath = templatePath.substring(templatePath.indexOf("file:") + 5); |
| | | } |
| | | if (templatePath.contains("!")) { |
| | | templatePath = templatePath.substring(0, templatePath.indexOf("!")); |
| | | } |
| | | |
| | | // 使用PDF模板文件 |
| | | File pdfTemplate = new File(templatePath, "中原证券股票分成协议(电子正式版).pdf"); |
| | | if (!pdfTemplate.exists()) { |
| | | // 从资源中读取PDF模板文件 |
| | | File pdfTemplate = getTemplateFile("中原证券股票分成协议(电子正式版).pdf"); |
| | | if (pdfTemplate == null || !pdfTemplate.exists()) { |
| | | return ServerResponse.createByErrorMsg("PDF模板文件不存在"); |
| | | } |
| | | |
| | | // 从PDF模板生成新的PDF,替换占位符 |
| | | generatePdfFromTemplate(pdfTemplate, pdfFile, user); |
| | | |
| | | return ServerResponse.createBySuccess(pdfFileName); |
| | | return ServerResponse.createBySuccess(pdfUrl); |
| | | } catch (Exception e) { |
| | | log.error("生成用户协议PDF失败", e); |
| | | return ServerResponse.createByErrorMsg("生成PDF失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | generateAgreementPdf11(); |
| | | } |
| | | |
| | | public static void generateAgreementPdf11() { |
| | | try { |
| | | |
| | | // 检查是否已生成PDF |
| | | String pdfDir = PropertiesUtil.getProperty("agreement.pdf.dir", System.getProperty("user.dir") + "/agreement_pdf"); |
| | | File dir = new File(pdfDir); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | String pdfFileName = "agreement_111.pdf"; |
| | | File pdfFile = new File(dir, pdfFileName); |
| | | |
| | | // 获取模板文件路径 |
| | | String templatePath = "D:/work/A-stock/src/main/resources/templates"; |
| | | if (templatePath.startsWith("/") && System.getProperty("os.name").toLowerCase().contains("windows")) { |
| | | templatePath = templatePath.substring(1); |
| | | } |
| | | templatePath = templatePath.replaceAll("%20", " "); |
| | | if (templatePath.contains("file:")) { |
| | | templatePath = templatePath.substring(templatePath.indexOf("file:") + 5); |
| | | } |
| | | if (templatePath.contains("!")) { |
| | | templatePath = templatePath.substring(0, templatePath.indexOf("!")); |
| | | } |
| | | |
| | | // 使用PDF模板文件 |
| | | File pdfTemplate = new File(templatePath, "中原证券股票分成协议(电子正式版).pdf"); |
| | | if (!pdfTemplate.exists()) { |
| | | System.out.println("PDF模板文件不存在"); |
| | | } |
| | | |
| | | // 从PDF模板生成新的PDF,替换占位符 |
| | | generatePdfFromTemplate1(pdfTemplate, pdfFile); |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("生成用户协议PDF失败", e); |
| | | |
| | | } |
| | | } |
| | | public static void generatePdfFromTemplate1(File templatePdf, File outputPdf) throws Exception { |
| | | PdfReader reader = new PdfReader(new FileInputStream(templatePdf)); |
| | | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPdf)); |
| | | |
| | | // 设置中文字体 |
| | | BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | Font font = new Font(baseFont, 12, Font.NORMAL); |
| | | // Font boldFont = new Font(baseFont, 12, Font.BOLD); |
| | | // BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | // Font font = new Font(baseFont, 5, Font.BOLD); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | String currentDate = sdf.format(new Date()); |
| | | |
| | | // 准备替换的数据 |
| | | String realName = "陈大雷"; |
| | | String idCard = "433123198802456635"; |
| | | String address = "广东省清远市三八街道明星之城18栋2单元1506"; |
| | | |
| | | // 获取PDF页数 |
| | | int pageCount = reader.getNumberOfPages(); |
| | | |
| | | // 在每一页上查找并替换占位符 |
| | | for (int pageNum = 1; pageNum <= pageCount; pageNum++) { |
| | | PdfContentByte canvas = stamper.getOverContent(pageNum); |
| | | Rectangle pageSize = reader.getPageSize(pageNum); |
| | | |
| | | // 提取PDF文本查找占位符位置 |
| | | String pageText = PdfTextExtractor.getTextFromPage(reader, pageNum, new SimpleTextExtractionStrategy()); |
| | | |
| | | // 在PDF上查找并替换占位符 |
| | | replacePlaceholdersInPdf1(canvas, pageSize, pageText, realName, idCard, address, currentDate, font,pageNum); |
| | | // 添加签名 |
| | | if(pageNum == 3){ |
| | | // 添加签名 |
| | | addHeaderImageToPdf(canvas, templatePdf.getParent(), pageSize); |
| | | } |
| | | } |
| | | |
| | | stamper.close(); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | | * 在PDF上替换占位符(使用文本覆盖方式) |
| | | */ |
| | | public static void replacePlaceholdersInPdf1(PdfContentByte canvas, Rectangle pageSize, String pageText, |
| | | String realName, String idCard, String address, |
| | | String currentDate, Font font,int pageNum) throws Exception { |
| | | // 查找占位符在文本中的位置,然后估算在PDF中的坐标 |
| | | // 由于PDF坐标系统复杂,这里使用固定位置替换 |
| | | // 实际使用时需要根据PDF模板的具体布局调整坐标 |
| | | |
| | | float margin = 50; |
| | | float lineHeight = 14; |
| | | float startY = pageSize.getHeight() - 194; |
| | | |
| | | if(pageNum == 1){ |
| | | replacePlaceholder1(canvas, "", realName, margin + 75, startY, 0, font); |
| | | startY -= lineHeight; |
| | | |
| | | replacePlaceholder1(canvas, "", address, margin + 75, startY-2, 0, font); |
| | | startY -= lineHeight; |
| | | |
| | | replacePlaceholder1(canvas, "", idCard, margin + 95, startY-2, 0, font); |
| | | } |
| | | if(pageNum == 3){ |
| | | replacePlaceholder1(canvas, "", currentDate, margin + 60, startY+32, 0, font); |
| | | replacePlaceholder1(canvas, "", currentDate, margin + 60, startY, 0, font); |
| | | } |
| | | |
| | | // if (pageText.contains("${jcurrentDate}")) { |
| | | // replacePlaceholder1(canvas, "${jcurrentDate}", currentDate, margin + 100, startY, 150, font); |
| | | // startY -= lineHeight; |
| | | // } |
| | | // |
| | | // if (pageText.contains("${ucurrentDate}")) { |
| | | // replacePlaceholder1(canvas, "${ucurrentDate}", currentDate, margin + 100, startY, 300, font); |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 在PDF左上角添加图片 |
| | | */ |
| | | public static void addHeaderImageToPdf(PdfContentByte canvas, String templatePath, Rectangle pageSize) throws Exception { |
| | | // 获取图片路径 |
| | | String imagePath = templatePath + File.separator + "zczq.png"; |
| | | File imageFile = new File(imagePath); |
| | | // 如果使用相对路径找不到,尝试从resources获取 |
| | | if (!imageFile.exists()) { |
| | | String resourcePath = "D:/work/A-stock/src/main/resources/templates"; |
| | | if (resourcePath.startsWith("/") && System.getProperty("os.name").toLowerCase().contains("windows")) { |
| | | resourcePath = resourcePath.substring(1); |
| | | } |
| | | resourcePath = resourcePath.replaceAll("%20", " "); |
| | | if (resourcePath.contains("file:")) { |
| | | resourcePath = resourcePath.substring(resourcePath.indexOf("file:") + 5); |
| | | } |
| | | if (resourcePath.contains("!")) { |
| | | resourcePath = resourcePath.substring(0, resourcePath.indexOf("!")); |
| | | } |
| | | imageFile = new File(resourcePath); |
| | | } |
| | | |
| | | if (imageFile.exists()) { |
| | | Image image = Image.getInstance(imageFile.getAbsolutePath()); |
| | | // 设置图片大小 |
| | | image.scaleToFit(100, 100); |
| | | // 设置图片位置(左上角) |
| | | image.setAbsolutePosition(370, pageSize.getHeight() - 194); |
| | | canvas.addImage(image); |
| | | } else { |
| | | log.warn("未找到图片文件: {}", imagePath); |
| | | } |
| | | } |
| | | /** |
| | | * 替换单个占位符 |
| | | */ |
| | | public static void replacePlaceholder1(PdfContentByte canvas, String placeholder, String value, |
| | | float x, float y, float width, Font font) { |
| | | // 添加白色背景覆盖占位符区域 |
| | | canvas.saveState(); |
| | | canvas.setColorFill(BaseColor.WHITE); |
| | | canvas.rectangle(x - 5, y - 15, width, 20); |
| | | canvas.fill(); |
| | | canvas.restoreState(); |
| | | |
| | | // 添加新文本 |
| | | ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, |
| | | new Phrase(value, font), x, y, 0); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 从PDF模板生成新的PDF,替换占位符 |
| | | */ |
| | | private void generatePdfFromTemplate(File templatePdf, File outputPdf, User user) throws Exception { |
| | | PdfReader reader = new PdfReader(new FileInputStream(templatePdf)); |
| | | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPdf)); |
| | | log.info("开始生成PDF,模板路径: {}, 输出路径: {}, 用户: {}", |
| | | templatePdf.getAbsolutePath(), outputPdf.getAbsolutePath(), user.getId()); |
| | | |
| | | PdfReader reader = null; |
| | | PdfStamper stamper = null; |
| | | FileOutputStream fos = null; |
| | | |
| | | try { |
| | | reader = new PdfReader(new FileInputStream(templatePdf)); |
| | | fos = new FileOutputStream(outputPdf); |
| | | stamper = new PdfStamper(reader, fos); |
| | | |
| | | // 设置中文字体 |
| | | BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | Font font = new Font(baseFont, 12, Font.NORMAL); |
| | | Font boldFont = new Font(baseFont, 12, Font.BOLD); |
| | | // 设置中文字体 |
| | | BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | Font font = new Font(baseFont, 12, Font.NORMAL); |
| | | Font boldFont = new Font(baseFont, 12, Font.BOLD); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | String currentDate = sdf.format(new Date()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | String currentDate = sdf.format(new Date()); |
| | | |
| | | // 准备替换的数据 |
| | | String realName = user.getRealName() != null ? user.getRealName() : ""; |
| | | String idCard = user.getIdCard() != null ? user.getIdCard() : ""; |
| | | String address = user.getRegAddress() != null ? user.getRegAddress() : ""; |
| | | // 准备替换的数据 |
| | | String realName = user.getRealName() != null ? user.getRealName() : ""; |
| | | String idCard = user.getIdCard() != null ? user.getIdCard() : ""; |
| | | String address = user.getRegAddress() != null ? user.getRegAddress() : ""; |
| | | |
| | | log.info("PDF生成数据 - 姓名: {}, 身份证: {}, 地址: {}", realName, idCard, address); |
| | | |
| | | // 获取PDF页数 |
| | | int pageCount = reader.getNumberOfPages(); |
| | | // 获取PDF页数 |
| | | int pageCount = reader.getNumberOfPages(); |
| | | log.info("PDF模板页数: {}", pageCount); |
| | | |
| | | // 在每一页上查找并替换占位符 |
| | | for (int pageNum = 1; pageNum <= pageCount; pageNum++) { |
| | | PdfContentByte canvas = stamper.getOverContent(pageNum); |
| | | Rectangle pageSize = reader.getPageSize(pageNum); |
| | | // 在每一页上查找并替换占位符 |
| | | for (int pageNum = 1; pageNum <= pageCount; pageNum++) { |
| | | PdfContentByte canvas = stamper.getOverContent(pageNum); |
| | | Rectangle pageSize = reader.getPageSize(pageNum); |
| | | |
| | | // 提取PDF文本查找占位符位置 |
| | | String pageText = PdfTextExtractor.getTextFromPage(reader, pageNum, new SimpleTextExtractionStrategy()); |
| | | // 提取PDF文本查找占位符位置 |
| | | String pageText = PdfTextExtractor.getTextFromPage(reader, pageNum, new SimpleTextExtractionStrategy()); |
| | | |
| | | // 在PDF上查找并替换占位符 |
| | | replacePlaceholdersInPdf(canvas, pageSize, pageText, realName, idCard, address, currentDate, font,pageNum); |
| | | // 在PDF上查找并替换占位符 |
| | | replacePlaceholdersInPdf(canvas, pageSize, pageText, realName, idCard, address, currentDate, font, pageNum); |
| | | log.info("已处理PDF第{}页", pageNum); |
| | | } |
| | | |
| | | stamper.close(); |
| | | stamper = null; |
| | | reader.close(); |
| | | reader = null; |
| | | fos.close(); |
| | | fos = null; |
| | | |
| | | // 验证生成的文件 |
| | | if (outputPdf.exists()) { |
| | | long fileSize = outputPdf.length(); |
| | | log.info("PDF生成完成,文件路径: {}, 文件大小: {} 字节", outputPdf.getAbsolutePath(), fileSize); |
| | | if (fileSize == 0) { |
| | | throw new Exception("生成的PDF文件大小为0"); |
| | | } |
| | | } else { |
| | | throw new Exception("PDF文件生成失败,文件不存在"); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("生成PDF失败", e); |
| | | throw e; |
| | | } finally { |
| | | if (stamper != null) { |
| | | try { |
| | | stamper.close(); |
| | | } catch (Exception e) { |
| | | log.error("关闭stamper失败", e); |
| | | } |
| | | } |
| | | if (reader != null) { |
| | | try { |
| | | reader.close(); |
| | | } catch (Exception e) { |
| | | log.error("关闭reader失败", e); |
| | | } |
| | | } |
| | | if (fos != null) { |
| | | try { |
| | | fos.close(); |
| | | } catch (Exception e) { |
| | | log.error("关闭输出流失败", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | stamper.close(); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public void viewAgreementPdf(HttpServletRequest request, HttpServletResponse response) { |
| | | FileInputStream fis = null; |
| | | OutputStream os = null; |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | if (user == null) { |
| | |
| | | return; |
| | | } |
| | | |
| | | String pdfDir = PropertiesUtil.getProperty("agreement.pdf.dir", System.getProperty("user.dir") + "/agreement_pdf"); |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | String pdfFileName = "agreement_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(pdfDir, pdfFileName); |
| | | |
| | | log.info("查看PDF文件,路径: {}, 是否存在: {}, 文件大小: {}", |
| | | pdfFile.getAbsolutePath(), pdfFile.exists(), |
| | | pdfFile.exists() ? pdfFile.length() : 0); |
| | | |
| | | if (!pdfFile.exists()) { |
| | | response.sendError(HttpServletResponse.SC_NOT_FOUND, "协议文件不存在,请先生成协议"); |
| | | return; |
| | | } |
| | | |
| | | long fileLength = pdfFile.length(); |
| | | if (fileLength == 0) { |
| | | log.error("PDF文件大小为0: {}", pdfFile.getAbsolutePath()); |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "PDF文件为空"); |
| | | return; |
| | | } |
| | | |
| | | // 验证PDF文件头 |
| | | FileInputStream checkFis = new FileInputStream(pdfFile); |
| | | byte[] header = new byte[4]; |
| | | checkFis.read(header); |
| | | checkFis.close(); |
| | | String headerStr = new String(header); |
| | | if (!headerStr.startsWith("%PDF")) { |
| | | log.error("文件不是有效的PDF格式,文件头: {}", headerStr); |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "PDF文件格式错误"); |
| | | return; |
| | | } |
| | | log.info("PDF文件头验证通过: {}", headerStr); |
| | | |
| | | response.setContentType("application/pdf"); |
| | | response.setHeader("Content-Disposition", "inline; filename=" + pdfFileName); |
| | | response.setHeader("Content-Disposition", "inline; filename=\"" + |
| | | new String(pdfFileName.getBytes("UTF-8"), "ISO-8859-1") + "\""); |
| | | response.setContentLengthLong(fileLength); |
| | | response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
| | | response.setHeader("Pragma", "no-cache"); |
| | | response.setDateHeader("Expires", 0); |
| | | |
| | | FileInputStream fis = new FileInputStream(pdfFile); |
| | | OutputStream os = response.getOutputStream(); |
| | | fis = new FileInputStream(pdfFile); |
| | | os = response.getOutputStream(); |
| | | |
| | | byte[] buffer = new byte[8192]; |
| | | int bytesRead; |
| | | long totalBytes = 0; |
| | | while ((bytesRead = fis.read(buffer)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | totalBytes += bytesRead; |
| | | } |
| | | |
| | | log.info("PDF文件传输完成,总字节数: {}", totalBytes); |
| | | os.flush(); |
| | | } catch (Exception e) { |
| | | log.error("查看用户协议PDF失败", e); |
| | | try { |
| | | if (!response.isCommitted()) { |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "查看PDF失败: " + e.getMessage()); |
| | | } |
| | | } catch (IOException ex) { |
| | | log.error("发送错误响应失败", ex); |
| | | } |
| | | } finally { |
| | | if (fis != null) { |
| | | try { |
| | | fis.close(); |
| | | } catch (IOException e) { |
| | | log.error("关闭文件流失败", e); |
| | | } |
| | | } |
| | | if (os != null) { |
| | | try { |
| | | os.close(); |
| | | } catch (IOException e) { |
| | | log.error("关闭输出流失败", e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse saveAgreementSignature(MultipartFile signatureFile, HttpServletRequest request) { |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户未登录"); |
| | | } |
| | | |
| | | if (signatureFile == null || signatureFile.isEmpty()) { |
| | | return ServerResponse.createByErrorMsg("签名图片不能为空"); |
| | | } |
| | | |
| | | // 保存签名图片到本地 |
| | | String signatureDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | File dir = new File(signatureDir); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | String signatureFileName = "signature_" + user.getId() + ".png"; |
| | | File signatureFileLocal = new File(dir, signatureFileName); |
| | | |
| | | signatureFile.transferTo(signatureFileLocal); |
| | | |
| | | log.info("用户{}的签名图片已保存: {}", user.getId(), signatureFileLocal.getAbsolutePath()); |
| | | |
| | | // 重新生成PDF并插入签名图片 |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | String pdfFileName = "agreement_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(pdfDir, pdfFileName); |
| | | |
| | | if (pdfFile.exists()) { |
| | | // 在PDF第三页插入签名图片 |
| | | addSignatureToPdf(pdfFile, signatureFileLocal, user); |
| | | |
| | | // 构建PDF访问地址 |
| | | String pdfUrl = PropertiesUtil.getProperty("pdf.server.http.prefix") + "/agreement_" + user.getId() + ".pdf"; |
| | | |
| | | // 更新用户表的签合同标记(保存PDF地址) |
| | | iUserService.updateSignedContract(user.getId(),pdfUrl); |
| | | } |
| | | return ServerResponse.createBySuccessMsg("签名保存成功"); |
| | | } catch (Exception e) { |
| | | log.error("保存用户协议签名失败", e); |
| | | return ServerResponse.createByErrorMsg("保存签名失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 在PDF第三页插入签名图片 |
| | | */ |
| | | private void addSignatureToPdf(File pdfFile, File signatureImage, User user) throws Exception { |
| | | PdfReader reader = new PdfReader(new FileInputStream(pdfFile)); |
| | | File tempPdf = new File(pdfFile.getParent(), "temp_" + pdfFile.getName()); |
| | | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(tempPdf)); |
| | | |
| | | int pageCount = reader.getNumberOfPages(); |
| | | |
| | | // 在第三页插入签名图片 |
| | | if (pageCount >= 3) { |
| | | PdfContentByte canvas = stamper.getOverContent(3); |
| | | Rectangle pageSize = reader.getPageSize(3); |
| | | |
| | | // 添加签名图片 |
| | | if (signatureImage.exists()) { |
| | | Image image = Image.getInstance(signatureImage.getAbsolutePath()); |
| | | // 设置图片大小(根据实际需要调整) |
| | | image.scaleToFit(100, 100); |
| | | // 设置图片位置(使用与addHeaderImageToPdf相同的坐标) |
| | | image.setAbsolutePosition(370, pageSize.getHeight() - 194); |
| | | canvas.addImage(image); |
| | | log.info("签名图片已插入到PDF第三页,位置: (370, {})", pageSize.getHeight() - 194); |
| | | } |
| | | } |
| | | |
| | | stamper.close(); |
| | | reader.close(); |
| | | |
| | | // 替换原PDF文件 |
| | | if (tempPdf.exists()) { |
| | | pdfFile.delete(); |
| | | tempPdf.renameTo(pdfFile); |
| | | log.info("PDF文件已更新,签名图片已插入"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse generateAgreementContractPdf(HttpServletRequest request) { |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | user = (User) iUserService.findByUserId(user.getId()).getData(); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户未登录"); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(user.getRealName()) || StringUtils.isBlank(user.getIdCard()) || StringUtils.isBlank(user.getRegAddress())) { |
| | | return ServerResponse.createByErrorMsg("用户信息不完整,请先完成实名认证"); |
| | | } |
| | | |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | File dir = new File(pdfDir); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | String pdfFileName = "contract_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(dir, pdfFileName); |
| | | |
| | | String pdfUrl = PropertiesUtil.getProperty("pdf.server.http.prefix") + "/contract_" + user.getId() + ".pdf"; |
| | | |
| | | if (pdfFile.exists()) { |
| | | boolean deleted = pdfFile.delete(); |
| | | if (!deleted) { |
| | | log.warn("删除旧PDF文件失败: {}", pdfFile.getAbsolutePath()); |
| | | } |
| | | } |
| | | |
| | | // 从资源中读取PDF模板文件 |
| | | File pdfTemplate = getTemplateFile("中原证券商业核心信息保密协议.pdf"); |
| | | if (pdfTemplate == null || !pdfTemplate.exists()) { |
| | | return ServerResponse.createByErrorMsg("PDF模板文件不存在"); |
| | | } |
| | | |
| | | generateContractPdfFromTemplate(pdfTemplate, pdfFile, user); |
| | | |
| | | return ServerResponse.createBySuccess(pdfUrl); |
| | | } catch (Exception e) { |
| | | log.error("生成用户合同PDF失败", e); |
| | | return ServerResponse.createByErrorMsg("生成PDF失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void viewAgreementContractPdf(HttpServletRequest request, HttpServletResponse response) { |
| | | FileInputStream fis = null; |
| | | OutputStream os = null; |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | if (user == null) { |
| | | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "用户未登录"); |
| | | return; |
| | | } |
| | | |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | String pdfFileName = "contract_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(pdfDir, pdfFileName); |
| | | |
| | | if (!pdfFile.exists()) { |
| | | response.sendError(HttpServletResponse.SC_NOT_FOUND, "合同文件不存在,请先生成合同"); |
| | | return; |
| | | } |
| | | |
| | | long fileLength = pdfFile.length(); |
| | | if (fileLength == 0) { |
| | | log.error("PDF文件大小为0: {}", pdfFile.getAbsolutePath()); |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "PDF文件为空"); |
| | | return; |
| | | } |
| | | |
| | | FileInputStream checkFis = new FileInputStream(pdfFile); |
| | | byte[] header = new byte[4]; |
| | | checkFis.read(header); |
| | | checkFis.close(); |
| | | String headerStr = new String(header); |
| | | if (!headerStr.startsWith("%PDF")) { |
| | | log.error("文件不是有效的PDF格式,文件头: {}", headerStr); |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "PDF文件格式错误"); |
| | | return; |
| | | } |
| | | |
| | | response.setContentType("application/pdf"); |
| | | response.setHeader("Content-Disposition", "inline; filename=\"" + |
| | | new String(pdfFileName.getBytes("UTF-8"), "ISO-8859-1") + "\""); |
| | | response.setContentLengthLong(fileLength); |
| | | response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
| | | |
| | | fis = new FileInputStream(pdfFile); |
| | | os = response.getOutputStream(); |
| | | byte[] buffer = new byte[4096]; |
| | | int bytesRead; |
| | | while ((bytesRead = fis.read(buffer)) != -1) { |
| | | os.write(buffer, 0, bytesRead); |
| | | } |
| | | |
| | | fis.close(); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | log.error("查看用户协议PDF失败", e); |
| | | log.error("查看用户合同PDF失败", e); |
| | | try { |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "查看PDF失败"); |
| | | response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "查看PDF失败: " + e.getMessage()); |
| | | } catch (IOException ex) { |
| | | log.error("发送错误响应失败", ex); |
| | | } |
| | | } finally { |
| | | if (fis != null) { |
| | | try { |
| | | fis.close(); |
| | | } catch (IOException e) { |
| | | log.error("关闭文件流失败", e); |
| | | } |
| | | } |
| | | if (os != null) { |
| | | try { |
| | | os.close(); |
| | | } catch (IOException e) { |
| | | log.error("关闭输出流失败", e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse saveAgreementContractSignature(MultipartFile signatureFile, HttpServletRequest request) { |
| | | try { |
| | | User user = iUserService.getCurrentUser(request); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户未登录"); |
| | | } |
| | | |
| | | if (signatureFile == null || signatureFile.isEmpty()) { |
| | | return ServerResponse.createByErrorMsg("签名图片不能为空"); |
| | | } |
| | | |
| | | String signatureDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | File dir = new File(signatureDir); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | |
| | | String signatureFileName = "contract_signature_" + user.getId() + ".png"; |
| | | File signatureFileLocal = new File(dir, signatureFileName); |
| | | |
| | | signatureFile.transferTo(signatureFileLocal); |
| | | |
| | | log.info("用户{}的合同签名图片已保存: {}", user.getId(), signatureFileLocal.getAbsolutePath()); |
| | | |
| | | String pdfDir = PropertiesUtil.getProperty("loca.pdf.dir"); |
| | | String pdfFileName = "contract_" + user.getId() + ".pdf"; |
| | | File pdfFile = new File(pdfDir, pdfFileName); |
| | | |
| | | if (pdfFile.exists()) { |
| | | addSignatureToContractPdf(pdfFile, signatureFileLocal, user); |
| | | |
| | | String pdfUrl = PropertiesUtil.getProperty("pdf.server.http.prefix") + "/contract_" + user.getId() + ".pdf"; |
| | | |
| | | iUserService.updateSignedAgreement(user.getId(), pdfUrl); |
| | | } |
| | | |
| | | return ServerResponse.createBySuccessMsg("签名保存成功"); |
| | | } catch (Exception e) { |
| | | log.error("保存用户合同签名失败", e); |
| | | return ServerResponse.createByErrorMsg("保存签名失败:" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | private void generateContractPdfFromTemplate(File templatePdf, File outputPdf, User user) throws Exception { |
| | | PdfReader reader = new PdfReader(new FileInputStream(templatePdf)); |
| | | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outputPdf)); |
| | | |
| | | BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); |
| | | Font font = new Font(baseFont, 12, Font.NORMAL); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | String currentDate = sdf.format(new Date()); |
| | | |
| | | int pageCount = reader.getNumberOfPages(); |
| | | |
| | | for (int pageNum = 1; pageNum <= pageCount; pageNum++) { |
| | | PdfContentByte canvas = stamper.getOverContent(pageNum); |
| | | Rectangle pageSize = reader.getPageSize(pageNum); |
| | | |
| | | replacePlaceholdersInContractPdf(canvas, pageSize, currentDate, font, pageNum); |
| | | } |
| | | |
| | | stamper.close(); |
| | | reader.close(); |
| | | } |
| | | |
| | | private void replacePlaceholdersInContractPdf(PdfContentByte canvas, Rectangle pageSize, String currentDate, Font font, int pageNum) throws Exception { |
| | | float margin = 50; |
| | | float startY = pageSize.getHeight() - 364; |
| | | if(pageNum == 2){ |
| | | replacePlaceholder(canvas, "", currentDate, margin + 320, startY, 0, font); |
| | | } |
| | | } |
| | | |
| | | private void addSignatureToContractPdf(File pdfFile, File signatureImage, User user) throws Exception { |
| | | PdfReader reader = new PdfReader(new FileInputStream(pdfFile)); |
| | | File tempPdf = new File(pdfFile.getParent(), "temp_" + pdfFile.getName()); |
| | | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(tempPdf)); |
| | | |
| | | int pageCount = reader.getNumberOfPages(); |
| | | |
| | | if (pageCount >= 2) { |
| | | PdfContentByte canvas = stamper.getOverContent(2); |
| | | Rectangle pageSize = reader.getPageSize(2); |
| | | |
| | | if (signatureImage.exists()) { |
| | | Image image = Image.getInstance(signatureImage.getAbsolutePath()); |
| | | image.scaleToFit(100, 100); |
| | | image.setAbsolutePosition(435, pageSize.getHeight() - 288); |
| | | canvas.addImage(image); |
| | | log.info("签名图片已插入到合同PDF第二页"); |
| | | } |
| | | } |
| | | |
| | | stamper.close(); |
| | | reader.close(); |
| | | |
| | | if (tempPdf.exists()) { |
| | | pdfFile.delete(); |
| | | tempPdf.renameTo(pdfFile); |
| | | log.info("合同PDF文件已更新,签名图片已插入"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 从固定目录获取模板文件 |
| | | */ |
| | | private File getTemplateFile(String templateFileName) { |
| | | try { |
| | | String templateDir = PropertiesUtil.getProperty("pdf.template.dir"); |
| | | if (StringUtils.isBlank(templateDir)) { |
| | | log.error("PDF模板目录配置不存在: pdf.template.dir"); |
| | | return null; |
| | | } |
| | | |
| | | File dir = new File(templateDir); |
| | | if (!dir.exists()) { |
| | | log.error("PDF模板目录不存在: {}", templateDir); |
| | | return null; |
| | | } |
| | | |
| | | File templateFile = new File(dir, templateFileName); |
| | | if (!templateFile.exists()) { |
| | | log.error("PDF模板文件不存在: {}", templateFile.getAbsolutePath()); |
| | | return null; |
| | | } |
| | | |
| | | log.info("使用模板文件: {}", templateFile.getAbsolutePath()); |
| | | return templateFile; |
| | | } catch (Exception e) { |
| | | log.error("获取模板文件失败: {}", templateFileName, e); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | |
| | | if (!am_flag && !pm_flag && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,不在交易时段内"); |
| | | } |
| | | if (siteProduct.getHolidayDisplay()) { |
| | | if (siteProduct.getHolidayDisplay() && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能交易!"); |
| | | } |
| | | |
| | |
| | | .getBuySameNums() + "条"); |
| | | } |
| | | |
| | | Integer transNum = findPositionNumByTimes(siteSetting.getBuyNumTimes().intValue(), user.getId()); |
| | | if (transNum.intValue() / 100 >= siteSetting.getBuyNumLots().intValue() && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("频繁交易," + siteSetting |
| | | .getBuyNumTimes() + "分钟内不能超过" + siteSetting.getBuyNumLots() + "手"); |
| | | } |
| | | |
| | | if (buyNum.intValue() < siteSetting.getBuyMinNum().intValue()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,购买数量小于" + siteSetting |
| | |
| | | log.info("【普通A股】"); |
| | | } |
| | | |
| | | if (stockListVO.getName().startsWith("ST") || stockListVO.getName().endsWith("退")) { |
| | | return ServerResponse.createByErrorMsg("ST和已退市的股票不能入仓"); |
| | | } |
| | | // if (stockListVO.getName().startsWith("ST") || stockListVO.getName().endsWith("退")) { |
| | | // return ServerResponse.createByErrorMsg("ST和已退市的股票不能入仓"); |
| | | // } |
| | | |
| | | BigDecimal zsPrice = new BigDecimal(stockListVO.getPreclose_px()); |
| | | |
| | |
| | | |
| | | BigDecimal ztRate = chaPrice.multiply(new BigDecimal("100")).divide(zsPrice, 2, 4); |
| | | |
| | | log.info("当前涨跌幅 = {} % , 涨停幅度 = {} %", Double.valueOf(stock_crease), ztRate); |
| | | if ((new BigDecimal(String.valueOf(stock_crease))).compareTo(ztRate) == 0 && buyType |
| | | .intValue() == 0 && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("当前股票已涨停不能买涨"); |
| | | } |
| | | if (stock.getStockPlate() == null || StringUtils.isEmpty(stock.getStockPlate())) { |
| | | |
| | | int maxcrease = siteSetting.getCreaseMaxPercent().intValue(); |
| | | if (stock_crease > 0.0D && |
| | | stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,股票当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | } |
| | | |
| | | |
| | | if (stock_crease < 0.0D && |
| | | -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,股票当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | |
| | | } |
| | | |
| | | } else if ("创业".equals(stock.getStockPlate())) { |
| | | |
| | | int maxcrease = siteSetting.getCyCreaseMaxPercent().intValue(); |
| | | if (stock_crease > 0.0D && |
| | | stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,创业股当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | } |
| | | |
| | | |
| | | if (stock_crease < 0.0D && |
| | | -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,创业股当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | } |
| | | } else { |
| | | |
| | | int maxcrease = siteSetting.getKcCreaseMaxPercent().intValue(); |
| | | if (stock_crease > 0.0D && |
| | | stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,科创股当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | } |
| | | |
| | | |
| | | if (stock_crease < 0.0D && |
| | | -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("挂单失败,科创股当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | } |
| | | } |
| | | // log.info("当前涨跌幅 = {} % , 涨停幅度 = {} %", Double.valueOf(stock_crease), ztRate); |
| | | // if ((new BigDecimal(String.valueOf(stock_crease))).compareTo(ztRate) == 0 && buyType |
| | | // .intValue() == 0 && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("当前股票已涨停不能买涨"); |
| | | // } |
| | | // if (stock.getStockPlate() == null || StringUtils.isEmpty(stock.getStockPlate())) { |
| | | // |
| | | // int maxcrease = siteSetting.getCreaseMaxPercent().intValue(); |
| | | // if (stock_crease > 0.0D && |
| | | // stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,股票当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | // } |
| | | // |
| | | // |
| | | // if (stock_crease < 0.0D && |
| | | // -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,股票当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | // |
| | | // } |
| | | // |
| | | // } else if ("创业".equals(stock.getStockPlate())) { |
| | | // |
| | | // int maxcrease = siteSetting.getCyCreaseMaxPercent().intValue(); |
| | | // if (stock_crease > 0.0D && |
| | | // stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,创业股当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | // } |
| | | // |
| | | // |
| | | // if (stock_crease < 0.0D && |
| | | // -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,创业股当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | // } |
| | | // } else { |
| | | // |
| | | // int maxcrease = siteSetting.getKcCreaseMaxPercent().intValue(); |
| | | // if (stock_crease > 0.0D && |
| | | // stock_crease >= maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,科创股当前涨幅:" + stock_crease + ",大于最大涨幅:" + maxcrease); |
| | | // } |
| | | // |
| | | // |
| | | // if (stock_crease < 0.0D && |
| | | // -stock_crease > maxcrease && siteProduct.getTranWithdrawDisplay()) { |
| | | // return ServerResponse.createByErrorMsg("挂单失败,科创股当前跌幅:" + stock_crease + ",大于最大跌幅:" + maxcrease); |
| | | // } |
| | | // } |
| | | ServerResponse serverResponse = this.iStockService.selectRateByDaysAndStockCode(stock |
| | | .getStockCode(), siteSetting.getStockDays().intValue()); |
| | | if (!serverResponse.isSuccess()) { |
| | | return serverResponse; |
| | | } |
| | | BigDecimal daysRate = (BigDecimal) serverResponse.getData(); |
| | | log.info("股票 {} , {} 天内 涨幅 {} , 设置的涨幅 = {}", new Object[]{stock.getStockCode(), siteSetting |
| | | .getStockDays(), daysRate, siteSetting.getStockRate()}); |
| | | |
| | | if (daysRate != null && |
| | | siteSetting.getStockRate().compareTo(daysRate) == -1 && siteProduct.getTranWithdrawDisplay()) { |
| | | return serverResponse.createByErrorMsg(siteSetting.getStockDays() + "天内涨幅超过 " + siteSetting |
| | | .getStockRate() + "不能交易"); |
| | | } |
| | | // log.info("股票 {} , {} 天内 涨幅 {} , 设置的涨幅 = {}", new Object[]{stock.getStockCode(), siteSetting |
| | | // .getStockDays(), daysRate, siteSetting.getStockRate()}); |
| | | // |
| | | // if (daysRate != null && |
| | | // siteSetting.getStockRate().compareTo(daysRate) == -1 && siteProduct.getTranWithdrawDisplay()) { |
| | | // return serverResponse.createByErrorMsg(siteSetting.getStockDays() + "天内涨幅超过 " + siteSetting |
| | | // .getStockRate() + "不能交易"); |
| | | // } |
| | | |
| | | BigDecimal buy_amt = now_price.multiply(new BigDecimal(buyNum.intValue())); |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("平仓失败,不在交易时段内"); |
| | | } |
| | | } |
| | | if (siteProduct.getHolidayDisplay()) { |
| | | if (siteProduct.getHolidayDisplay() && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能交易!"); |
| | | } |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("下单失败,当前股票不能交易"); |
| | | } |
| | | |
| | | List dbPosition = findPositionByStockCodeAndTimes(siteSetting.getBuySameTimes().intValue(), stockDz.getStockCode(), user.getId()); |
| | | if (dbPosition.size() >= siteSetting.getBuySameNums().intValue()) { |
| | | return ServerResponse.createByErrorMsg("频繁交易," + siteSetting.getBuySameTimes() + "分钟内同一股票持仓不得超过" + siteSetting |
| | | .getBuySameNums() + "条"); |
| | | } |
| | | // List dbPosition = findPositionByStockCodeAndTimes(siteSetting.getBuySameTimes().intValue(), stockDz.getStockCode(), user.getId()); |
| | | // if (dbPosition.size() >= siteSetting.getBuySameNums().intValue()) { |
| | | // return ServerResponse.createByErrorMsg("频繁交易," + siteSetting.getBuySameTimes() + "分钟内同一股票持仓不得超过" + siteSetting |
| | | // .getBuySameNums() + "条"); |
| | | // } |
| | | |
| | | Integer transNum = findPositionNumByTimes(siteSetting.getBuyNumTimes().intValue(), user.getId()); |
| | | if (transNum.intValue() / 100 >= siteSetting.getBuyNumLots().intValue()) { |
| | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) { |
| | | if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) || |
| | | StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode)) |
| | | StringUtils.isBlank(userPwd)) |
| | | { |
| | | return ServerResponse.createByErrorMsg("注册失败, 参数不能为空"); |
| | | } |
| | |
| | | String uip = IpUtils.getIp(request); |
| | | user.setRegIp(uip); |
| | | String uadd = JuheIpApi.ip2Add(uip); |
| | | user.setRegAddress(uadd); |
| | | // user.setRegAddress(uadd); |
| | | |
| | | user.setIsLogin(Integer.valueOf(0)); |
| | | |
| | |
| | | String property = PropertiesUtil.getProperty("user.cookie.name"); |
| | | // System.out.println(property); |
| | | String loginToken = request.getHeader(property); |
| | | |
| | | // 如果header中没有token,尝试从cookie获取 |
| | | if (loginToken == null) { |
| | | javax.servlet.http.Cookie[] cookies = request.getCookies(); |
| | | if (cookies != null) { |
| | | for (javax.servlet.http.Cookie cookie : cookies) { |
| | | if (property != null && property.equals(cookie.getName())) { |
| | | loginToken = cookie.getValue(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 如果cookie中也没有token,尝试从URL参数获取(用于iframe等场景) |
| | | if (loginToken == null) { |
| | | loginToken = request.getParameter("token"); |
| | | } |
| | | |
| | | if (loginToken == null) { |
| | | return null; |
| | | } |
| | |
| | | return ServerResponse.createByErrorMsg("修改失败"); |
| | | } |
| | | |
| | | @Override |
| | | public void updateSignedContract(Integer userId, String signedContract) { |
| | | this.userMapper.updateSignedContract(userId,signedContract); |
| | | } |
| | | @Override |
| | | public void updateSignedAgreement(Integer userId, String signedAgreement) { |
| | | this.userMapper.updateSignedAgreement(userId,signedAgreement); |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | @Override |
| | | public ServerResponse exchangeOp(BigDecimal amt, Integer type, HttpServletRequest request) throws Exception { |
| | |
| | | } |
| | | |
| | | |
| | | public ServerResponse auth(String realName, String idCard, String img1key, String img2key, String img3key, HttpServletRequest request) { |
| | | if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCard)){ |
| | | public ServerResponse auth(String realName, String idCard, String address, String img1key, String img2key, String img3key, HttpServletRequest request) { |
| | | if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCard) || StringUtils.isBlank(address)){ |
| | | // StringUtils.isBlank(img1key) || |
| | | // StringUtils.isBlank(img2key)) |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | |
| | | user.setNickName(realName); |
| | | user.setRealName(realName); |
| | | user.setIdCard(idCard); |
| | | user.setRegAddress(address); |
| | | |
| | | user.setImg1Key(img1key); |
| | | user.setImg2Key(img2key); |
| | |
| | | |
| | | userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt()); |
| | | userInfoVO.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt()); |
| | | userInfoVO.setIsSignedContract(user.getIsSignedContract()); |
| | | userInfoVO.setIsSignedAgreement(user.getIsSignedAgreement()); |
| | | userInfoVO.setHkAmt(user.getHkAmt()); |
| | | |
| | | BigDecimal historyProfitLoss = new BigDecimal(0); |
| | |
| | | /* |
| | | * 新聞資訊抓取 |
| | | * */ |
| | | @Scheduled(cron = "0 0/30 9-17 * * ?") |
| | | // @Scheduled(cron = "0 0/30 9-17 * * ?") |
| | | @Scheduled(cron = "0 * * * * ?") |
| | | public void NewsInfoTask() { |
| | | this.iSiteNewsService.grabNews(); |
| | | log.info("新聞資訊抓取完成"); |
| | |
| | | |
| | | private BigDecimal historyProfitLoss; |
| | | |
| | | private String isSignedContract; |
| | | |
| | | private String isSignedAgreement; |
| | | |
| | | public void setAgentId(Integer agentId) { |
| | | this.agentId = agentId; |
| | | } |
| | |
| | | ftp.server.ip=127.0.0.1 |
| | | ftp.user=ftp_red |
| | | ftp.pass=ftp_red |
| | | ftp.server.http.prefix=https://ftp.htzjgj.com/ |
| | | loca.images.dir=/www/wwwroot/ftp.htzjgj.com/ |
| | | ftp.server.http.prefix=https://ftp.shengliankeji.top/ |
| | | loca.images.dir=/www/wwwroot/ftp.shengliankeji.top/ |
| | | pdf.server.http.prefix=https://stockapdf.shengliankeji.top |
| | | loca.pdf.dir=/www/wwwroot/stock.A.PDF |
| | | pdf.template.dir=/www/wwwroot/ftp.shengliankeji.top/templates |
| | | #ftp.server.ip=47.56.200.145 |
| | | #ftp.user=ofsuccess |
| | | #ftp.pass=fdymdM34HHsS8iB6 |
| | |
| | | sina.index.market.url=https://ws.api.cnyes.com/ws/api/v4/universal/quote?type=LITQ&column=L |
| | | |
| | | sina.single.stock.url=https://hq.sinajs.cn/list= |
| | | #sina.single.stock.sort.proxy.url=http://103.30.7.134:7001/crypto/getStockSort.do? |
| | | #sina.single.stock.proxy.url=http://103.30.7.134:7001/crypto/getSinaStock?stockGid= |
| | | sina.single.stock.sort.proxy.url=http://localhost:7001/crypto/getStockSort.do? |
| | | sina.single.stock.proxy.url=http://localhost:7001/crypto/getSinaStock?stockGid= |
| | | sina.single.stock.sort.proxy.url=http://103.30.7.134:7001/crypto/getStockSort.do? |
| | | sina.single.stock.proxy.url=http://103.30.7.134:7001/crypto/getSinaStock?stockGid= |
| | | #sina.single.stock.sort.proxy.url=http://localhost:7001/crypto/getStockSort.do? |
| | | #sina.single.stock.proxy.url=http://localhost:7001/crypto/getSinaStock?stockGid= |
| | | #???? |
| | | sina.single.stock.introduction.url=https://quotes.sina.cn/cn/api/openapi.php/CompanyF10Service.getCompanyInformation?market=cn&symbol= |
| | | nq.single.stock.url=http://192.168.10.5/stock/?type= |
| | |
| | | datasource: |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | | driverClassName: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:3306/stock_hongta_101?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | username: root |
| | | password: 123456 |
| | | # url: jdbc:mysql://127.0.0.1:3306/stock_hongta_101?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | # username: stock_hongta_101 |
| | | # password: mFi7EZKGmnJFh8at |
| | | # username: root |
| | | # password: 123456 |
| | | url: jdbc:mysql://127.0.0.1:3306/stock_hongta_101?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 |
| | | username: stock_hongta_101 |
| | | password: mFi7EZKGmnJFh8at |
| | | druid: |
| | | # 初始连接数 |
| | | initialSize: 5 |
| | |
| | | <if test="stockDzDisplay != null" > |
| | | stock_dz_display = #{stockDzDisplay,jdbcType=BIT}, |
| | | </if> |
| | | <if test="stockDzDisplay != null" > |
| | | <if test="tranWithdrawDisplay != null" > |
| | | tran_withdraw_display = #{tranWithdrawDisplay,jdbcType=BIT}, |
| | | </if> |
| | | |
| | |
| | | <arg column="is_authorize" jdbcType="INTEGER" javaType="java.lang.Integer" /> |
| | | <arg column="sgzj" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="djzj" jdbcType="DECIMAL" javaType="java.math.BigDecimal" /> |
| | | <arg column="is_signed_contract" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | <arg column="is_signed_agreement" jdbcType="VARCHAR" javaType="java.lang.String" /> |
| | | </constructor> |
| | | </resultMap> |
| | | <sql id="Example_Where_Clause" > |
| | |
| | | account_type, user_amt, enable_amt, enale_withdraw_amt, hk_amt, sum_charge_amt, sum_buy_amt, |
| | | recom_phone, is_lock, is_login, reg_time, reg_ip, reg_address, img1_key, img2_key, |
| | | img3_key, is_active, auth_msg, user_index_amt, enable_index_amt, user_fut_amt, enable_fut_amt, |
| | | withdrawal_Pwd, trading_amount, is_authorize, sgzj, djzj |
| | | withdrawal_Pwd, trading_amount, is_authorize, sgzj, djzj,is_signed_contract,is_signed_agreement |
| | | </sql> |
| | | <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.nq.pojo.UserExample" > |
| | | select |
| | |
| | | img3_key, is_active, auth_msg, |
| | | user_index_amt, enable_index_amt, user_fut_amt, |
| | | enable_fut_amt, withdrawal_Pwd, trading_amount, |
| | | is_authorize, sgzj, djzj |
| | | is_authorize, sgzj, djzj,is_signed_contract,is_signed_agreement |
| | | ) |
| | | values ( #{agentId,jdbcType=INTEGER}, #{agentName,jdbcType=VARCHAR}, |
| | | #{phone,jdbcType=VARCHAR}, #{userPwd,jdbcType=VARCHAR}, #{withPwd,jdbcType=VARCHAR}, |
| | |
| | | #{img3Key,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, #{authMsg,jdbcType=VARCHAR}, |
| | | #{userIndexAmt,jdbcType=DECIMAL}, #{enableIndexAmt,jdbcType=DECIMAL}, #{userFutAmt,jdbcType=DECIMAL}, |
| | | #{enableFutAmt,jdbcType=DECIMAL}, #{withdrawalPwd,jdbcType=VARCHAR}, #{tradingAmount,jdbcType=DECIMAL}, |
| | | #{isAuthorize,jdbcType=INTEGER}, #{sgzj,jdbcType=DECIMAL}, #{djzj,jdbcType=DECIMAL} |
| | | #{isAuthorize,jdbcType=INTEGER}, #{sgzj,jdbcType=DECIMAL}, #{djzj,jdbcType=DECIMAL}, #{isSignedContract,jdbcType=VARCHAR}, #{isSignedAgreement,jdbcType=VARCHAR} |
| | | ) |
| | | </insert> |
| | | <insert id="insertSelective" parameterType="com.nq.pojo.User" > |
| | |
| | | <if test="djzj != null" > |
| | | djzj, |
| | | </if> |
| | | <if test="withdrawalPwd != null" > |
| | | is_signed_contract, |
| | | </if> |
| | | <if test="withdrawalPwd != null" > |
| | | is_signed_agreement, |
| | | </if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides="," > |
| | | #{id,jdbcType=INTEGER}, |
| | |
| | | </if> |
| | | <if test="djzj != null" > |
| | | #{djzj,jdbcType=DECIMAL}, |
| | | </if> |
| | | <if test="isSignedContract != null" > |
| | | #{isSignedContract,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="isSignedAgreement != null" > |
| | | #{isSignedAgreement,jdbcType=VARCHAR}, |
| | | </if> |
| | | </trim> |
| | | </insert> |
| | |
| | | <if test="record.djzj != null" > |
| | | djzj = #{record.djzj,jdbcType=DECIMAL}, |
| | | </if> |
| | | <if test="record.isSignedContract != null" > |
| | | is_signed_contract = #{record.isSignedContract,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="record.isSignedAgreement != null" > |
| | | is_signed_agreement = #{record.isSignedAgreement,jdbcType=VARCHAR}, |
| | | </if> |
| | | </set> |
| | | <if test="_parameter != null" > |
| | | <include refid="Update_By_Example_Where_Clause" /> |
| | |
| | | trading_amount = #{record.tradingAmount,jdbcType=DECIMAL}, |
| | | is_authorize = #{record.isAuthorize,jdbcType=INTEGER}, |
| | | sgzj = #{record.sgzj,jdbcType=DECIMAL}, |
| | | djzj = #{record.djzj,jdbcType=DECIMAL} |
| | | djzj = #{record.djzj,jdbcType=DECIMAL}, |
| | | is_signed_contract = #{record.isSignedContract,jdbcType=VARCHAR}, |
| | | is_signed_agreement = #{record.isSignedAgreement,jdbcType=VARCHAR} |
| | | <if test="_parameter != null" > |
| | | <include refid="Update_By_Example_Where_Clause" /> |
| | | </if> |
| | |
| | | <if test="djzj != null" > |
| | | djzj = #{djzj,jdbcType=DECIMAL}, |
| | | </if> |
| | | <if test="isSignedContract != null" > |
| | | is_signed_contract = #{isSignedContract,jdbcType=VARCHAR}, |
| | | </if> |
| | | <if test="isSignedAgreement != null" > |
| | | is_signed_agreement = #{isSignedAgreement,jdbcType=VARCHAR}, |
| | | </if> |
| | | </set> |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </update> |
| | | <update id="updateSignedContract"> |
| | | update user set is_signed_contract=#{signedContract,jdbcType=VARCHAR} where id = #{userId,jdbcType=INTEGER} |
| | | </update> |
| | | <update id="updateSignedAgreement"> |
| | | update user set is_signed_agreement=#{signedAgreement,jdbcType=VARCHAR} where id = #{userId,jdbcType=INTEGER} |
| | | </update> |
| | | <update id="updateByPrimaryKey" parameterType="com.nq.pojo.User" > |
| | | update user |
| | |
| | | trading_amount = #{tradingAmount,jdbcType=DECIMAL}, |
| | | is_authorize = #{isAuthorize,jdbcType=INTEGER}, |
| | | sgzj = #{sgzj,jdbcType=DECIMAL}, |
| | | djzj = #{djzj,jdbcType=DECIMAL} |
| | | djzj = #{djzj,jdbcType=DECIMAL}, |
| | | is_signed_contract = #{record.isSignedContract,jdbcType=VARCHAR}, |
| | | is_signed_agreement = #{record.isSignedAgreement,jdbcType=VARCHAR} |
| | | where id = #{id,jdbcType=INTEGER} |
| | | </update> |
| | | |