Search in sources :

Example 71 with Product

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

the class ProductServiceImpl method getProductByCertUid.

public Product getProductByCertUid(List<Product> products, String certDn) {
    Product defaultProduct = null;
    Product product = null;
    for (Product p : products) {
        // 是否配置了证书信息项
        if (StringUtils.isBlank(p.getCertinfo())) {
            defaultProduct = p;
            continue;
        }
        // 解析项目产品中,certinfo配置信息
        JSONArray certinfo = JSONArray.parseArray(p.getCertinfo());
        boolean hasCertMatch = false;
        boolean matchError = false;
        for (int i = 0; i < certinfo.size(); i++) {
            JSONObject obj = certinfo.getJSONObject(i);
            String certMatch = obj.getString("certMatch");
            if (null == certMatch)
                continue;
            hasCertMatch = true;
            // 处理多个certMatch条件
            if (!certDn.contains(certMatch)) {
                matchError = true;
                break;
            }
        }
        // 包括匹配条件,并且没有出现错误
        if (hasCertMatch && !matchError) {
            product = p;
            break;
        } else if (!hasCertMatch) {
            defaultProduct = p;
        }
    }
    if (null == product)
        product = defaultProduct;
    return product;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) Product(com.itrus.portal.db.Product)

Example 72 with Product

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

the class ProductServiceImpl method getKeyUnlockProducts.

/**
 * 获取该项目下所有的未下架的解锁产品
 * @param projectId
 * @return
 */
public List<Product> getKeyUnlockProducts(Long projectId, Long userinfoId) {
    if (null == projectId) {
        return null;
    }
    List<Product> products = new ArrayList<>();
    ProductExample example = new ProductExample();
    ProductExample.Criteria criteria = example.or();
    criteria.andProjectEqualTo(projectId);
    criteria.andIsBanEqualTo(false);
    criteria.andKeyUnlockTypeIsNotNull();
    // 若证书没有绑定用户,则不返回自助解锁的产品
    if (null == userinfoId) {
        criteria.andKeyUnlockTypeNotEqualTo(1);
    }
    products = sqlSession.selectList("com.itrus.portal.db.ProductMapper.selectByExample", example);
    return products;
}
Also used : ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) ProductExample(com.itrus.portal.db.ProductExample)

Example 73 with Product

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

the class PersonalBillServiceImpl method getProductMapByUserInfoId.

/**
 * 根据用户id查询订单表中对应的产品Map
 *
 * @param userInfo
 * @return
 */
public Map<Long, Product> getProductMapByUserInfoId(Long userInfo) {
    Map<Long, Product> productMap = new HashMap<Long, Product>();
    List<Long> productIds = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductsByUserInfo", userInfo);
    if (null != productIds && !productIds.isEmpty()) {
        ProductExample example = new ProductExample();
        ProductExample.Criteria criteria = example.or();
        criteria.andIdIn(productIds);
        productMap = sqlSession.selectMap("com.itrus.portal.db.ProductMapper.selectByExample", example, "id");
    }
    return productMap;
}
Also used : HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) ProductExample(com.itrus.portal.db.ProductExample)

Example 74 with Product

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

the class PersonalBillServiceImpl method getProductMapByBills.

/**
 * 根据订单list获取对应产品Map
 *
 * @param bills
 * @return
 */
public Map<Long, Product> getProductMapByBills(List<PersonalBill> bills) {
    Map<Long, Product> productMap = new HashMap<Long, Product>();
    List<Long> productIds = new ArrayList<Long>();
    for (PersonalBill bill : bills) {
        productIds.add(bill.getProduct());
    }
    if (!productIds.isEmpty()) {
        ProductExample example = new ProductExample();
        ProductExample.Criteria criteria = example.or();
        criteria.andIdIn(productIds);
        productMap = sqlSession.selectMap("com.itrus.portal.db.ProductMapper.selectByExample", example, "id");
    }
    return productMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) ProductExample(com.itrus.portal.db.ProductExample)

Example 75 with Product

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

the class SendReNewInfoTask method sendReNewInfo.

/**
 * 心跳更新。启动时执行一次,之后每隔24小时执行一次
 */
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void sendReNewInfo() {
    // 筛选出所有是待更新的,而且未发送短信的订单
    BillExample billExample = new BillExample();
    BillExample.Criteria criteria = billExample.or();
    // 订单状态是12的时候,表示是待更新的订单
    criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_12);
    // 订单的短信发送时间是Null的时候,表示未发送过通知短信
    criteria.andRenewSendTimeIsNull();
    criteria.andIsDeleteEqualTo(false);
    // billExample.setLimit(100);
    List<Bill> bills = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
    if (null == bills || bills.size() < 1) {
        return;
    }
    String billSn = "";
    String mPhone = "";
    try {
        // 向每个订单发送短信通知
        for (int i = 0; i < bills.size(); i++) {
            billSn = bills.get(i).getBillId();
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bills.get(i).getUniqueId());
            mPhone = userInfo.getmPhone();
            UserCertExample userCertExample = new UserCertExample();
            UserCertExample.Criteria ucriteria = userCertExample.or();
            ucriteria.andIdEqualTo(bills.get(i).getOldUserCert());
            UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userCertExample);
            Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bills.get(i).getEnterprise());
            Long projectId = bills.get(i).getProject();
            String keySn = "";
            if (null == userCert.getKeySn()) {
                keySn = "该证书未绑定key";
            } else {
                keySn = userCert.getKeySn();
            }
            String enterpriseName = enterprise.getEnterpriseName();
            Date endTime = userCert.getCertEndTime();
            // 获取订单对应的产品信息
            Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bills.get(i).getProduct());
            String productName = product.getName();
            try {
                makeCerServiceImpl.sendReNewInfo(bills.get(i), mPhone, projectId, "ZSGX", keySn, enterpriseName, endTime, productName);
            } catch (UserInfoServiceException e) {
                String type = "发送证书更新通知失败";
                String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
                LogUtil.syslog(sqlSession, type, info);
                log.error("ERRORLOG证书更新通知 {}", info);
                return;
            } catch (Exception e) {
                String type = "发送证书更新通知失败";
                String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
                LogUtil.syslog(sqlSession, type, info);
                log.error("ERRORLOG证书更新通知 {}", info);
                return;
            }
        }
    } catch (Exception e) {
        String type = "发送证书更新通知失败";
        String info = "用户手机号:" + mPhone + ",订单号" + billSn + "错误信息:" + e.getMessage();
        LogUtil.syslog(sqlSession, type, info);
        log.error("ERRORLOG证书更新通知 {}", info);
        return;
    }
}
Also used : UserCertExample(com.itrus.portal.db.UserCertExample) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) BillExample(com.itrus.portal.db.BillExample) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) UserCert(com.itrus.portal.db.UserCert) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

Product (com.itrus.portal.db.Product)77 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)43 HashMap (java.util.HashMap)42 Bill (com.itrus.portal.db.Bill)39 Enterprise (com.itrus.portal.db.Enterprise)27 UserInfo (com.itrus.portal.db.UserInfo)27 DigitalCert (com.itrus.portal.db.DigitalCert)24 JSONObject (com.alibaba.fastjson.JSONObject)19 UserCert (com.itrus.portal.db.UserCert)19 ArrayList (java.util.ArrayList)19 IOException (java.io.IOException)18 Map (java.util.Map)17 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)17 ProductExample (com.itrus.portal.db.ProductExample)15 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 Date (java.util.Date)15 List (java.util.List)14 HttpSession (javax.servlet.http.HttpSession)14 BillExample (com.itrus.portal.db.BillExample)10 Project (com.itrus.portal.db.Project)10