Search in sources :

Example 1 with Bwdjrecord

use of com.itrus.portal.db.Bwdjrecord in project portal by ixinportal.

the class ClientWebController method downLoadLicenseByBillId.

@RequestMapping("/downLoadLicense")
@ResponseBody
public Map<String, Object> downLoadLicenseByBillId(@RequestParam(value = "billId", required = true) Long Id, HttpServletRequest request, HttpServletResponse response, Model uiModel) {
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    HttpSession session = request.getSession();
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (null == webenterprise || null == webuserInfo) {
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    ExtraBill bill = extraBillService.selectByPrimaryKey(Id);
    if (null == bill) {
        retMap.put("retMsg", "登录已经失效,订单不存在");
        return retMap;
    }
    if (!bill.getUniqueId().equals(webuserInfo.getId())) {
        retMap.put("retMsg", "您无权操作该订单");
        return retMap;
    }
    if (!(bill.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_7))) {
        retMap.put("retMsg", "订单尚未能下载注册码.请等待服务商审核通过或者订单完成之后才能下载");
        return retMap;
    }
    Bwdjrecord bwdjrecord = BWDJRecordService.getBwdjrecordByExtraBillId(Id);
    OutputStream os = null;
    try {
        String downLoadUrl = bwdjrecord.getDownLoadUrl();
        URL url = new URL(downLoadUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        // 设置超时间为3秒
        conn.setConnectTimeout(3 * 1000);
        // 防止屏蔽程序抓取而返回403错误
        conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
        // 得到输入流
        InputStream inputStream = conn.getInputStream();
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String license = "";
        String currentLine = "";
        while ((currentLine = reader.readLine()) != null) {
            license = license + currentLine.trim();
        }
        retMap.put("retCode", 1);
        retMap.put("license", license);
        return retMap;
    // 获取自己数组
    // byte[] getData = readInputStream(inputStream);
    // response.setHeader("Pragma", "no-cache");
    // response.setHeader("Cache-Control", "no-cache");
    // response.setDateHeader("Expires", 0);
    // os = response.getOutputStream();
    // os.write(getData);
    // os.close();
    } catch (Exception e) {
        log.error(e.getMessage());
        retMap.put("retMsg", "出现异常,请联系系统管理员,异常信息:" + e.getMessage());
        return retMap;
    } finally {
        // 关闭流!
        try {
            if (null != os) {
                os.close();
            }
        } catch (IOException e) {
        }
    }
}
Also used : Bwdjrecord(com.itrus.portal.db.Bwdjrecord) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ExtraBill(com.itrus.portal.db.ExtraBill) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) UserInfo(com.itrus.portal.db.UserInfo) IOException(java.io.IOException) URL(java.net.URL) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) HttpURLConnection(java.net.HttpURLConnection) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) BufferedReader(java.io.BufferedReader) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with Bwdjrecord

use of com.itrus.portal.db.Bwdjrecord in project portal by ixinportal.

the class BWDJRecordServiceImpl method getBwdjrecordByExtraBillId.

public Bwdjrecord getBwdjrecordByExtraBillId(Long id) {
    BwdjrecordExample example = new BwdjrecordExample();
    BwdjrecordExample.Criteria criteria = example.or();
    criteria.andExtraBillEqualTo(id);
    Bwdjrecord bwdjrecord = new Bwdjrecord();
    bwdjrecord = sqlSession.selectOne("com.itrus.portal.db.BwdjrecordMapper.selectByExample", example);
    return bwdjrecord;
}
Also used : Bwdjrecord(com.itrus.portal.db.Bwdjrecord) BwdjrecordExample(com.itrus.portal.db.BwdjrecordExample)

Example 3 with Bwdjrecord

use of com.itrus.portal.db.Bwdjrecord in project portal by ixinportal.

the class BWDJRecordServiceImpl method selectByPrimaryKey.

public Bwdjrecord selectByPrimaryKey(Long id) {
    Bwdjrecord bwdjrecord = new Bwdjrecord();
    bwdjrecord = sqlSession.selectOne("com.itrus.portal.db.BwdjrecordMapper.selectByPrimaryKey", id);
    return bwdjrecord;
}
Also used : Bwdjrecord(com.itrus.portal.db.Bwdjrecord)

Example 4 with Bwdjrecord

use of com.itrus.portal.db.Bwdjrecord in project portal by ixinportal.

the class BWDJRecordServiceImpl method insertOneRecored.

/**
 *	 返回报文:
 *	<?xml version="1.0" encoding="utf-8"?>
 *	<business id="CXSQJG" version='1.0'>
 *	<head>
 *	</head>
 *	<body>
 *	<sq_date>申请日期</sq_date>
 *	<yxqq>有效期起</yxqq>
 *	<yxqz>有效期止</yxqz>
 *	<kt_date>开通日期</kt_date>
 *	<downloadurl>下载地址</downloadurl>
 *	<returncode>返回</returncode>
 *	<returnmsg>返回信息</returnmsg>
 *	</body>
 *	</business>
 */
/**
 *		<?xml version="1.0" encoding="utf-8"?>
 *		<business id="CXSQJG" version='1.0'>
 *		<head></head><body>
 *		<sq_date>2017-07-28 14:41:22</sq_date>
 *		<yxqq>2017-08-01</yxqq>
 *		<yxqz>null</yxqz>
 *		<kt_date>2017-08-01 09:44:04</kt_date>
 *		<downloadurl>http://fp.easyunion.net:9083/dwonloadcode?name=skph911101020170728001</downloadurl>
 *		<returncode>0</returncode>
 *		<returnmsg>审核通过</returnmsg></body></business>
 *
 *		<?xml version="1.0" encoding="utf-8"?><business id="CXSQJG" version='1.0'>
 *		<head></head>
 *		<body><sq_date>2017-08-22 11:31:25</sq_date>
 *		<yxqq>20170822</yxqq>
 *		<yxqz>20180822</yxqz>
 *		<kt_date>2017-08-22 11:36:00</kt_date>
 *		<downloadurl>http://fp.easyunion.net:19900/fpfw/rcode/dwonloadcode?name=499000143955</downloadurl>
 *		<returncode>0</returncode>
 *		<returnmsg>审核通过</returnmsg></body></business>
 * @param resultMap
 * @param extraBill
 * @throws ParseException
 */
public void insertOneRecored(Map<String, Object> resultMap, Long extraBill) throws ParseException {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
    SimpleDateFormat simpleDateFormatTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date sq_date = null;
    Date yxqq = null;
    Date yxqz = null;
    Date kt_date = null;
    sq_date = simpleDateFormatTime.parse(resultMap.get("sq_date").toString());
    yxqq = simpleDateFormat.parse(resultMap.get("yxqq").toString());
    // {body=, downloadurl=http://fp.easyunion.net:9083/dwonloadcode?name=skph911101020170728001, yxqz=null, returncode=0, sq_date=2017-07-28 14:41:22, yxqq=2017-08-01, returnmsg=审核通过, head=, kt_date=2017-08-01 09:44:04}
    String yxqzString = resultMap.get("yxqz").toString();
    boolean flag = StringUtils.isNotBlank(yxqzString) && !yxqzString.equals("null");
    if (flag) {
        yxqz = simpleDateFormat.parse(yxqzString);
    }
    kt_date = simpleDateFormatTime.parse(resultMap.get("kt_date").toString());
    Bwdjrecord record = new Bwdjrecord();
    record.setCreateTime(new Date());
    record.setDownLoadUrl((String) resultMap.get("downloadurl"));
    record.setExtraBill(extraBill);
    record.setKtTime(kt_date);
    record.setSqTime(sq_date);
    record.setYxqqTime(yxqq);
    record.setYxqzTime(yxqz);
    insert(record);
}
Also used : Bwdjrecord(com.itrus.portal.db.Bwdjrecord) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with Bwdjrecord

use of com.itrus.portal.db.Bwdjrecord in project portal by ixinportal.

the class BaiWangEmailServiceImpl method sendEmailToUser.

public Map<String, Object> sendEmailToUser(ExtraBill bill) throws MessagingException, Exception {
    Map<String, Object> retMap = new HashMap<>();
    retMap.put("retCode", 0);
    Project project = projectService.selectByPrimaryKey(bill.getProject());
    ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
    UserInfo userInfo = userInfoService.getUserInfoById(bill.getUniqueId());
    if (StringUtils.isBlank(userInfo.getEmail())) {
        retMap.put("retMsg", "尚未登记邮箱,请登记邮箱并验证");
        return retMap;
    }
    if (null == userInfo.getTrustEmail() || userInfo.getTrustEmail().equals(false)) {
        retMap.put("retMsg", "您的邮箱尚未通过验证,请验证通过后再处理");
        return retMap;
    }
    Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
    MailTemplate mailTemplate = mailTemplateService.getMailTemplatesByProjectIdAndType(bill.getProject(), ComNames.MAIL_TEMPLATE_BWDJTZ);
    if (null == mailTemplate) {
        retMap.put("retMsg", "服务端出现未知错误,请联系系统管理员,错误代码:bwtz001");
        LogUtil.syslog(sqlSession, "邮件模版异常", "项目:" + bill.getProject() + ", 未配置百望单机通知邮件模版");
        return retMap;
    }
    // 给订单对应的用户发送邮件信息
    String[] mailOfUser = new String[] { userInfo.getEmail() };
    Map<String, File> proxyMap = new HashMap<String, File>();
    String instructions = product.getInstructions();
    File filePath = extraProductService.getFilePathById(product.getId());
    if (!filePath.exists()) {
        filePath.mkdir();
    }
    File file = new File(filePath, instructions);
    proxyMap.put("单机版开票软件操作指南.fdf", file);
    String subject = mailTemplate.getName().replace("projectname", project.getName()).replace("productname", product.getAppName());
    Bwdjrecord bwdjrecord = bwdjRecordService.getBwdjrecordByExtraBillId(bill.getId());
    String content = mailTemplate.getContent().replace("downloadurl", bwdjrecord.getDownLoadUrl());
    sendEmailService.sendEmail(content, mailOfUser, subject, false, proxyMap);
    retMap.put("retCode", 1);
    return retMap;
}
Also used : Bwdjrecord(com.itrus.portal.db.Bwdjrecord) HashMap(java.util.HashMap) UserInfo(com.itrus.portal.db.UserInfo) Project(com.itrus.portal.db.Project) ExtraProduct(com.itrus.portal.db.ExtraProduct) Enterprise(com.itrus.portal.db.Enterprise) MailTemplate(com.itrus.portal.db.MailTemplate) File(java.io.File)

Aggregations

Bwdjrecord (com.itrus.portal.db.Bwdjrecord)5 Enterprise (com.itrus.portal.db.Enterprise)2 UserInfo (com.itrus.portal.db.UserInfo)2 HashMap (java.util.HashMap)2 BwdjrecordExample (com.itrus.portal.db.BwdjrecordExample)1 ExtraBill (com.itrus.portal.db.ExtraBill)1 ExtraProduct (com.itrus.portal.db.ExtraProduct)1 MailTemplate (com.itrus.portal.db.MailTemplate)1 Project (com.itrus.portal.db.Project)1 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)1 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)1 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 HttpURLConnection (java.net.HttpURLConnection)1