Search in sources :

Example 6 with UserLog

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

the class SmsSendService method sendSmsByEmay.

/**
 * 调用亿美短信接口发送短信
 *
 * @param smsGate
 * @param mobile
 * @param content
 * @param smsType
 * @param projectId
 * @return
 */
public boolean sendSmsByEmay(SmsGate smsGate, String mobile, String content, String smsType, Long projectId, String userSn, String keySn) {
    boolean ret = false;
    // SysUser sysUser = sqlSession.selectOne(
    // "com.itrus.portal.db.SysUserMapper.selectByPrimaryKey",
    // sysUserId);
    // if (null == sysUser) {
    // logger.error("发送失败 ,id为【" + sysUserId + "】的用户不存在");
    // return false;
    // }
    SmsLog smsLog = new SmsLog();
    smsLog.setSmsType(smsType);
    smsLog.setmPhoneNum(mobile);
    smsLog.setCreateTime(new Date());
    smsLog.setProjectId(projectId);
    // smsLog.setSysUser(sysUserId);
    // 添加用户日志
    UserLog userLog = new UserLog();
    userLog.setHostId("未知");
    String smsTypeStr = smsType;
    if ("SHJJ".equals(smsType)) {
        smsTypeStr = "审核拒绝";
    }
    userLog.setType(smsTypeStr);
    userLog.setSn(userSn);
    userLog.setProject(projectId);
    String info = "";
    int sendValue = -1;
    try {
        logger.debug(mobile + " " + content);
        // 调用亿美短信接口发送短信
        java.net.URL endpointURL = new java.net.URL(smsGate.getEmayAddress());
        javax.xml.rpc.Service service = null;
        SDKServiceBindingStub client = new SDKServiceBindingStub(endpointURL, service);
        if (0 != regValue) {
        } else {
            sendValue = client.sendSMS(smsGate.getEmaySerialnum(), smsGate.getEmayPass(), "", new String[] { mobile }, content, "", "utf-8", 5, 0);
            smsLog.setGateType(smsGate.getGateType());
            if (0 == sendValue) {
                logger.debug("发送成功");
                smsLog.setSendStatus(SMS_STATUS_SUCCESS);
                ret = true;
                info = "手机号:" + mobile + ",发送成功\n订单号:" + keySn;
            } else {
                info = "手机号:" + mobile + ",发送失败.返回码:" + sendValue + "\n订单号:" + keySn;
                smsLog.setSendStatus(SMS_STATUS_FAIL);
                smsLog.setCommentInfo("返回信息:" + sendValue);
                logger.error("发送失败 " + sendValue);
            }
        }
    } catch (IOException e) {
        info = "手机号:" + mobile + ",发送失败.返回码:" + sendValue + "\n订单号:" + keySn;
        smsLog.setSendStatus(SMS_STATUS_FAIL);
        smsLog.setCommentInfo("出现未知异常,请查看日志");
        logger.error("发送失败 " + e.toString());
    }
    if (!"sendSms4three".equals(smsType)) {
        sqlSession.insert("com.itrus.portal.db.SmsLogMapper.insert", smsLog);
        userLog.setInfo(info);
        LogUtil.userlog(sqlSession, userLog);
    }
    return ret;
}
Also used : UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) Date(java.util.Date) SDKServiceBindingStub(cn.b2m.eucp.sdkhttp.SDKServiceBindingStub) SmsLog(com.itrus.portal.db.SmsLog)

Example 7 with UserLog

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

the class SmsSendService method sendSms.

/**
 * 给单个手机发送短信(旧的发送短信接口)
 *
 * @param mobile
 * @param content
 * @param smsType
 * @param projectId
 * @param sysUserId
 * @return
 */
public boolean sendSms(SmsGate smsGate, String mobile, String content, String smsType, Long projectId, Long sysUserId, String keySn) {
    String bodyAsString;
    boolean ret = false;
    // SysUser sysUser = sqlSession.selectOne(
    // "com.itrus.portal.db.SysUserMapper.selectByPrimaryKey",
    // sysUserId);
    // if (null == sysUser) {
    // logger.error("发送失败 ,id为【" + sysUserId + "】的用户不存在");
    // return false;
    // }
    SmsLog smsLog = new SmsLog();
    smsLog.setSmsType(smsType);
    smsLog.setmPhoneNum(mobile);
    smsLog.setCreateTime(new Date());
    smsLog.setProjectId(projectId);
    // smsLog.setSysUser(sysUserId);
    // 添加用户日志
    UserLog userLog = new UserLog();
    userLog.setHostId("未知");
    userLog.setType(smsType);
    userLog.setProject(projectId);
    String info = "";
    try {
        logger.debug(mobile + " " + content);
        String md5Plaintext = mobile.substring(0, 8) + mobile.substring(mobile.length() - 10) + smsGate.getMd5Key();
        String md5Ciphertext = smsMD5Keyword(md5Plaintext);
        String sendContent = URLEncoder.encode(content, "GBK");
        StringBuilder url = new StringBuilder(smsGate.getGateAddress() + SMS_SENT_URL);
        url.append("?Username=").append(smsGate.getAccountName()).append("&Password=").append(smsGate.getAccountPass()).append("&Mobile=").append(mobile).append("&Content=").append(sendContent).append("&Keyword=").append(md5Ciphertext);
        smsLog.setGateType(smsGate.getGateType());
        HttpResponse response = client.execute(new HttpGet(url.toString()));
        bodyAsString = EntityUtils.toString(response.getEntity());
        if ("0".equals(bodyAsString)) {
            logger.debug("发送成功");
            smsLog.setSendStatus(SMS_STATUS_SUCCESS);
            ret = true;
            info = "手机号:" + mobile + ",发送成功";
        } else {
            smsLog.setSendStatus(SMS_STATUS_FAIL);
            smsLog.setCommentInfo("返回信息:" + bodyAsString);
            logger.error("发送失败 " + bodyAsString);
            info = "手机号:" + mobile + ",发送失败";
        }
    } catch (IOException e) {
        smsLog.setSendStatus(SMS_STATUS_FAIL);
        smsLog.setCommentInfo("出现未知异常,请查看日志");
        logger.error("发送失败 " + e.toString());
        info = "手机号:" + mobile + ",发送失败";
    }
    sqlSession.insert("com.itrus.portal.db.SmsLogMapper.insert", smsLog);
    userLog.setInfo(info);
    LogUtil.userlog(sqlSession, userLog);
    return ret;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) SmsLog(com.itrus.portal.db.SmsLog) Date(java.util.Date)

Example 8 with UserLog

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

the class SmsSendService method wlsendSms.

/**
 * 给单个手机发送短信(未来无线发送短信接口)
 *
 * @param mobile
 * @param content
 * @param smsType
 * @param projectId
 * @param sysUserId
 * @return
 */
public boolean wlsendSms(SmsGate smsGate, String mobile, String content, String smsType, Long projectId, Long sysUserId, String keySn) {
    String bodyAsString;
    boolean ret = false;
    SmsLog smsLog = new SmsLog();
    smsLog.setSmsType(smsType);
    smsLog.setmPhoneNum(mobile);
    smsLog.setCreateTime(new Date());
    smsLog.setProjectId(projectId);
    // smsLog.setSysUser(sysUserId);
    // 添加用户日志
    UserLog userLog = new UserLog();
    userLog.setHostId("未知");
    userLog.setType(smsType);
    userLog.setProject(projectId);
    String info = "";
    try {
        logger.debug(mobile + " " + content);
        smsLog.setGateType(smsGate.getGateType());
        String str = smsClientService.sendSms(mobile, content, smsGate.getGateAddress(), smsGate.getAccountPass(), smsGate.getAccountName(), smsGate.getMd5Key());
        String[] s = str.split(":");
        bodyAsString = s[3].substring(0, s[3].length() - 2);
        if ("0".equals(bodyAsString)) {
            logger.debug("发送成功");
            smsLog.setSendStatus(SMS_STATUS_SUCCESS);
            ret = true;
            info = "手机号:" + mobile + ",发送成功";
        } else {
            smsLog.setSendStatus(SMS_STATUS_FAIL);
            smsLog.setCommentInfo("返回信息:" + bodyAsString);
            logger.error("发送失败 " + bodyAsString);
            info = "手机号:" + mobile + ",发送失败";
        }
    } catch (IOException e) {
        smsLog.setSendStatus(SMS_STATUS_FAIL);
        smsLog.setCommentInfo("出现未知异常,请查看日志");
        logger.error("发送失败 " + e.toString());
        info = "手机号:" + mobile + ",发送失败";
    }
    sqlSession.insert("com.itrus.portal.db.SmsLogMapper.insert", smsLog);
    userLog.setInfo(info);
    LogUtil.userlog(sqlSession, userLog);
    return ret;
}
Also used : UserLog(com.itrus.portal.db.UserLog) IOException(java.io.IOException) SmsLog(com.itrus.portal.db.SmsLog) Date(java.util.Date)

Example 9 with UserLog

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

the class BillWebController method delete.

// 删除填写中订单
@RequestMapping(value = "editbill/{id}.html", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    EditBill editBill = sqlSession.selectOne("com.itrus.portal.db.EditBillMapper.selectByPrimaryKey", id);
    HttpSession session = request.getSession();
    UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
    if (editBill == null) {
        // uiModel.addAttribute("message", "未找到要删除快递");
        return "未找到要删除订单";
    } else {
        try {
            EditBillService.delectEditInfo(editBill, userInfo.getUniqueId());
            UserLog userlog = new UserLog();
            userlog.setProject(userInfo.getProject());
            userlog.setType("删除填写中订单");
            userlog.setInfo(userInfo.getmPhone() + "删除了填写中订单" + editBill.getId());
            userlog.setHostId("未知");
            userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
            LogUtil.userlog(sqlSession, userlog);
        } catch (Exception e) {
            return "要删除填写中订单【" + editBill.getId() + "】存在关联,无法删除";
        }
    }
    return null;
}
Also used : HttpSession(javax.servlet.http.HttpSession) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) EditBill(com.itrus.portal.db.EditBill) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with UserLog

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

the class BillWebController method register.

/**
 * 审核拒绝后,重新提交订单
 *
 * @param enterpriseName
 *            企业名称
 * @param enterpriseNature
 *            企业性质
 * @param billId
 *            订单id
 * @param businessLicense
 * @param orgCode
 * @param taxregisterCert
 * @param identityCard
 * @param agent
 * @param proxy
 * @param session
 * @return
 */
@RequestMapping("/register")
@ResponseBody
public Map<String, Object> register(@RequestParam(value = "enterpriseName", required = true) String enterpriseName, @RequestParam(value = "enterprise_nature", required = false) Integer enterpriseNature, @RequestParam(value = "bill_id", required = true) Long billId, @RequestParam(value = "uid", required = true) String uid, @RequestParam(value = "uid1", required = false) String uid1, @RequestParam(value = "uid2", required = false) String uid2, @RequestParam(value = "uid3", required = false) String uid3, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("identityCard") IdentityCard identityCard, @ModelAttribute("agent") Agent agent, @ModelAttribute("proxy") Proxy proxy, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识失败,1标识成功
    retMap.put("retCode", 0);
    UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
    Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
    if (null == webuserInfo || null == webenterprise) {
        // 登录状态失效,跳转到注册页面
        // 2表示登录失效
        retMap.put("retCode", 2);
        retMap.put("retMsg", "登录已经失效,请重新登录");
        return retMap;
    }
    // 验证参数完整性
    if (null == enterpriseNature || 0 == enterpriseNature || null == billId) {
        retMap.put("retMsg", "提交参数信息不完整");
        return retMap;
    }
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    if (null == bill) {
        retMap.put("retMsg", "该订单不存在");
        return retMap;
    }
    if (!webuserInfo.getId().equals(bill.getUniqueId())) {
        retMap.put("retMsg", "您不能修改该订单");
        return retMap;
    }
    if (bill.getBillStatus() != ComNames.BILL_STATUS_4) {
        retMap.put("retMsg", "该订单未审核拒绝");
        return retMap;
    }
    // 根据订单id获取产品需要认证项,
    List<String> certItems = sqlSession.selectList("com.itrus.portal.db.CertificationMapper.selectCertItemsByBillId", billId);
    if (null == certItems || certItems.isEmpty()) {
        retMap.put("retMsg", "服务端出现异常,请联系管理员");
        log.error("获取订单对应产品的认证项失败:订单Id=" + billId + ".");
        return retMap;
    }
    // 记录旧的企业唯一标识:
    String oldEnterpriseSn = webenterprise.getEnterpriseSn();
    // 设置企业唯一标识
    if (enterpriseNature.equals(1) || enterpriseNature.equals(2)) {
        // 类型为企业和个体工商户:当三证合一时,企业标识为统一社会信用代码;当非三证合一时,企业标识为营业执照注册号;
        webenterprise.setEnterpriseSn(businessLicense.getLicenseNo());
    }
    if (enterpriseNature.equals(3)) {
        // 类型为政府机关/事业单位:企业标识为组织机构代码
        webenterprise.setEnterpriseSn(orgCode.getOrgCode());
    }
    // 修改企业名称
    webenterprise.setEnterpriseName(enterpriseName.trim());
    // 修改企业性质
    webenterprise.setEnterpriseNature(enterpriseNature);
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        // 删除订单关联的旧认证项,新增订单对应的新认证项
        billWebService.saveBillAuthenticationItems(certItems.get(0), enterpriseNature, billId, businessLicense, orgCode, taxregisterCert, identityCard, agent, proxy, webenterprise, webuserInfo);
        // 3、判断该订单对应的企业的认证项是否为通过,若是通过,则重新设置为不通过
        if (null != webenterprise.getAuthenticationLevel())
            webenterprise.setAuthenticationLevel(null);
        if (null != webenterprise.getHasBl())
            webenterprise.setHasBl(null);
        if (null != webenterprise.getHasOrgCode())
            webenterprise.setHasOrgCode(null);
        if (null != webenterprise.getHasTaxCert())
            webenterprise.setHasTaxCert(null);
        if (null != webenterprise.getHasIdCard())
            webenterprise.setHasIdCard(null);
        if (null != webenterprise.getHasAgent())
            webenterprise.setHasAgent(null);
        sqlSession.update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey", webenterprise);
        // 修改发票
        if (bill.getInvoice() != null && bill.getIsInvoiced() == null) {
            Invoice invoice = sqlSession.selectOne("com.itrus.portal.db.InvoiceMapper.selectByPrimaryKey", bill.getInvoice());
            invoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.InvoiceMapper.updateByPrimaryKey", invoice);
        }
        if (bill.geteInvoice() != null && bill.getIsInvoiced() == null) {
            Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
            einvoice.setName(webenterprise.getEnterpriseName());
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKey", einvoice);
        }
        if (StringUtils.isNotEmpty(uid) && !uid.equals("{}")) {
            bill.setUid(uid);
        }
        if (StringUtils.isNotEmpty(uid1) && !uid1.equals("{}")) {
            bill.setUid1(uid1);
        }
        if (StringUtils.isNotEmpty(uid2) && !uid2.equals("{}")) {
            bill.setUid2(uid2);
        }
        if (StringUtils.isNotEmpty(uid3) && !uid3.equals("{}")) {
            bill.setUid3(uid3);
        }
        // 设置订单为待审核状态
        bill.setBillStatus(ComNames.BILL_STATUS_3);
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
        transactionManager.commit(status);
        session.setAttribute("webenterprise", webenterprise);
        // 企业标识改变后,将旧目录中的图片复制到新目录中
        if (!oldEnterpriseSn.equals(webenterprise.getEnterpriseSn())) {
            CopyFile.copyFile(systemConfigService.getTrustDir().getPath() + File.separator + oldEnterpriseSn, systemConfigService.getTrustDir().getPath() + File.separator + webenterprise.getEnterpriseSn());
        }
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        UserLog userlog = new UserLog();
        userlog.setType("重新提交订单");
        userlog.setInfo("url:register,详细错误:" + e.getMessage());
        userlog.setHostId("未知");
        userlog.setProject(webuserInfo.getProject());
        LogUtil.userlog(sqlSession, userlog);
        retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
        log.error(e.getMessage());
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) Invoice(com.itrus.portal.db.Invoice) HashMap(java.util.HashMap) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserLog(com.itrus.portal.db.UserLog) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) IOException(java.io.IOException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) EncDecException(com.itrus.portal.exception.EncDecException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Einvoice(com.itrus.portal.db.Einvoice) Enterprise(com.itrus.portal.db.Enterprise) EditBill(com.itrus.portal.db.EditBill) Bill(com.itrus.portal.db.Bill) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserLog (com.itrus.portal.db.UserLog)23 UserInfo (com.itrus.portal.db.UserInfo)20 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 IOException (java.io.IOException)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 Enterprise (com.itrus.portal.db.Enterprise)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 HashMap (java.util.HashMap)15 HttpSession (javax.servlet.http.HttpSession)12 Bill (com.itrus.portal.db.Bill)9 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)9 TransactionStatus (org.springframework.transaction.TransactionStatus)8 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)8 ExtraProduct (com.itrus.portal.db.ExtraProduct)7 Product (com.itrus.portal.db.Product)7 BusinessLicense (com.itrus.portal.db.BusinessLicense)6 ExtraBill (com.itrus.portal.db.ExtraBill)6 IdentityCard (com.itrus.portal.db.IdentityCard)6 OrgCode (com.itrus.portal.db.OrgCode)6 Project (com.itrus.portal.db.Project)6