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;
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations