use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class ClientWebController method bugExtraProduct.
// TODO
// 用户选择了产品中的某个规格,确认进行购买,对应于确认订单:根据产品是否需要附加信息,来决定用户提交的资料,判断后台是否有这个用户对应的这些附加信息,如果有就返回给页面
@RequestMapping("/buyExtraProduct")
public String bugExtraProduct(@RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productSpecId", required = true) Long productSpecId, @RequestParam(value = "buyNumber", required = true) Long buyNumber, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
// 判断用户和企业信息是否存在了,不存在不能购买
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
if (null == enterprise || null == userInfo) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return "client/errorpage";
}
try {
ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
if (null == product) {
uiModel.addAttribute("errorMsg", "增值产品不存在");
return "client/errorpage";
}
uiModel.addAttribute("extraproduct", product);
// 选择的规格信息
ExtraProductSpec extraProductSpec = extraProductSpecService.selectByPrimaryKey(productSpecId);
if (null == extraProductSpec) {
uiModel.addAttribute("errorMsg", "增值产品规格不存在");
return "client/errorpage";
}
uiModel.addAttribute("extraProductSpec", extraProductSpec);
// 用户购买的数量:选择应该默认都是1
uiModel.addAttribute("buyNumber", buyNumber);
// 产品对应的服务商信息
Long serviceProviderId = product.getServiceProvider();
ServiceProvider serviceProvider = serviceProviderService.selectByPrimaryKey(serviceProviderId);
uiModel.addAttribute("serviceProvider", serviceProvider);
// 电子发票信息,看后台配置该产品是否能开票
String eInvoceStr = product.getEinvoice();
if (StringUtils.isNotBlank(eInvoceStr)) {
// 电子开票服务
Long[] ereceiptIds = StringTools.getLong(product.getEinvoice());
Map<Long, Ereceipt> ereceiptMap = ereceiptService.getEreceiptMap(ereceiptIds);
uiModel.addAttribute("ereceiptMap", ereceiptMap);
}
// 附加信息
if (null != product.getExtraMessage()) {
ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
// 用附加信息项的有无来判断是否需要用户填写附加信息,如果需要,则取附加信息项进行分割处理
uiModel.addAttribute("extraMessage", extraMessage);
// //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (extraMessage.getEnterpriseItems().contains("1")) {
}
if (extraMessage.getEnterpriseItems().contains("2")) {
List<BusinessLicense> businessLicenses = businessService.getBusinessLicensesNews(enterprise.getId());
if (null != businessLicenses && !businessLicenses.isEmpty()) {
session.setAttribute("webbusinessLicense", businessLicenses.get(0));
}
}
if (extraMessage.getEnterpriseItems().contains("3")) {
List<OrgCode> orgCodes = orgCodeService.getOrgCodesNews(enterprise.getId());
if (null != orgCodes && !orgCodes.isEmpty()) {
session.setAttribute("weborgCode", orgCodes.get(0));
}
}
if (extraMessage.getEnterpriseItems().contains("4")) {
List<TaxRegisterCert> taxRegisterCerts = taxCertService.getTaxRegisterCertsNews(enterprise.getId());
if (null != taxRegisterCerts && !taxRegisterCerts.isEmpty()) {
session.setAttribute("webtaxRegisterCert", taxRegisterCerts.get(0));
}
}
}
}
// field string --fieldName agentItems
if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
List<Agent> agents = agentService.getAgentsNews(enterprise.getId());
if (null != agents && !agents.isEmpty()) {
session.setAttribute("webagent", agents.get(0));
}
}
// field string --fieldName bankItems
if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
List<OpenBankInfo> openBankInfos = openBankInfoService.getOpenBankInfosNews(enterprise.getId());
if (null != openBankInfos && !openBankInfos.isEmpty()) {
session.setAttribute("webopenBankInfo", openBankInfos.get(0));
}
}
// 法人认证项
if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
List<IdentityCard> identityCards = identityCardService.getIdentityCardsNews(enterprise.getId());
if (null != identityCards && !identityCards.isEmpty()) {
session.setAttribute("webidentityCard", identityCards.get(0));
}
}
}
// logo和应用介绍信息,通过类似后台的回显方式进行加载
} catch (Exception e) {
// TODO: handle exception
}
return "client/querendingdan";
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class ClientWebController method reSubmitOrder.
/**
* 审核拒绝,重新提交信息接口
* @param enterprise
* @param userInfo
* @param einvoice
* @param businessLicense
* @param orgCode
* @param taxregisterCert
* @param agent
* @param openBankInfo
* @param identityCard
* @param request
* @return
*/
@RequestMapping("/reSubmitOrder")
@ResponseBody
public Map<String, Object> reSubmitOrder(@RequestParam(value = "extraBillId", required = true) Long id, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("agent") Agent agent, @ModelAttribute("openBankInfo") OpenBankInfo openBankInfo, @ModelAttribute("identityCard") IdentityCard identityCard, HttpServletRequest request) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 0标识失败,1标识成功
retMap.put("retCode", 0);
HttpSession session = request.getSession();
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
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;
}
ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(def);
try {
// 更新用户信息和企业信息
enterprise.setId(webenterprise.getId());
// ""字符串判断,改为Null,避免覆盖数据库中的信息
if (null != enterprise) {
if (StringUtils.isBlank(enterprise.getProvince())) {
enterprise.setProvince(null);
}
if (StringUtils.isBlank(enterprise.getCity())) {
enterprise.setCity(null);
}
if (StringUtils.isBlank(enterprise.getShortName())) {
enterprise.setShortName(null);
}
if (StringUtils.isBlank(enterprise.getNsrsbh())) {
enterprise.setNsrsbh(null);
}
}
enterprise = enterpriseService.updateByPrimaryKeySelective(enterprise);
userInfo.setId(webuserInfo.getId());
userInfo = userInfoService.updateByPrimaryKeySelective(userInfo);
// 根据订单id,获取该订单的旧认证项:
BusinessLicense oldBl = businessService.getBusinessByExtraBillId(id, null);
OrgCode oldOc = orgCodeService.getOrgCodeByExtraBillId(id, null);
TaxRegisterCert oldTc = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
IdentityCard oldIc = identityCardService.getIdentityCardByBillId(id, null);
Agent oldAgent = agentService.getAgentByExtraBillId(id, null);
OpenBankInfo oldBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
// 新认证项id置null,便于执行新增或者修改处理
businessLicense.setId(null);
orgCode.setId(null);
taxregisterCert.setId(null);
identityCard.setId(null);
agent.setId(null);
openBankInfo.setId(null);
// 获取产品需要的附加信息项
ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
// 是否有营业执照信息,默认false没有
boolean hasBl = false;
if (null != extraMessage) {
// //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (extraMessage.getEnterpriseItems().contains("2") && !webenterprise.getEnterpriseNature().equals(3)) {
// 事业单位不填写营业执照
hasBl = true;
businessLicense = businessService.saveBusinessExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, oldBl);
}
if (extraMessage.getEnterpriseItems().contains("3")) {
// 需要统一组织机构代码认证项,但是页面没有传递过来的时候,用老的
if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
1))) {
orgCode = orgCodeService.saveOrgCodeExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, oldOc);
}
}
if (extraMessage.getEnterpriseItems().contains("4")) {
if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
1))) {
// 保存税务登记证
if (// 事业单位不填写税务登记信息
!webenterprise.getEnterpriseNature().equals(3)) {
taxregisterCert = taxCertService.saveTaxCertExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, oldTc);
}
}
}
}
}
// field string --fieldName agentItems
if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
agent = agentService.saveAgentExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), agent, ComNames.ITEM_STATUS_2, oldAgent);
}
// field string --fieldName bankItems
if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
openBankInfo = openBankInfoService.saveOpenBankInfoExtraBill(webenterprise.getId(), bill.getId(), webuserInfo.getId(), openBankInfo, ComNames.ITEM_STATUS_2, oldBankInfo);
}
// field string --fieldName identityCardItems
if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
identityCard = identityCardService.saveIdentityCardExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, oldIc);
}
}
retMap.put("retCode", 1);
retMap.put("billId", bill.getId());
bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
extraBillService.updateByPrimaryKeySelective(bill);
transactionManager.commit(status);
// 更新session用户和企业信息
webenterprise = enterpriseService.getEnterpriseById(webenterprise.getId());
webuserInfo = userInfoService.getUserInfoById(webuserInfo.getId());
session.setAttribute("webenterprise", webenterprise);
session.setAttribute("webuserInfo", webuserInfo);
UserLog userlog = new UserLog();
userlog.setProject(bill.getProject());
userlog.setType("审核拒绝重新提交");
userlog.setInfo("提交成功,订单id:" + bill.getBillId());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
return retMap;
} 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.setProject(bill.getProject());
userlog.setType("审核拒绝重新提交");
userlog.setInfo("url:reSubmitOrder,详细错误:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
return retMap;
}
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class APIService method upload.
/**
* 证件图片上传
*
* @param authHmac
* hmac签名值,采用HmacSHA1算法
* @param appId
* 应用标识
* @param orderNumber
* 申请流水号
* @param image1
* 证件图片, base64形式
* @param image2
* 证件图片反面, base64形式(法定代表人和代理人证件类型为身份证时,必填)
* @param type
* 图片类型 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
* @return
*/
@PostMapping(value = "/auth/upload")
@ResponseBody
public Map<String, Object> upload(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "appId", required = false) String appId, @RequestParam(value = "orderNumber", required = false) String orderNumber, @RequestParam(value = "image1", required = false) String image1, @RequestParam(value = "image2", required = false) String image2, @RequestParam(value = "type", required = false) String type, HttpServletRequest request) {
Map<String, Object> result = new HashMap<String, Object>();
result.put("status", 0);
// 验证参数是否完整
if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(type) || StringUtils.isEmpty(orderNumber) || StringUtils.isEmpty(image1)) {
result.put("message", "提交的参数信息不完整");
return result;
}
try {
Bill bill = billService.getBillByOrderNumber(orderNumber);
if (bill == null) {
result.put("message", "申请流水号不存在");
return result;
}
UserInfo userInfo = userInfoService.getUserInfoByBillId(bill.getId());
// 得到应用信息 改成service
Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
ApplicationInfo applicationInfo = appInfoMap.get(appId);
if (applicationInfo == null) {
ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
appInfoExampleCriteria.andAppIdEqualTo(appId);
applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
}
if (applicationInfo == null) {
result.put("message", "应用标识不存在");
return result;
}
if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
result.put("status", -1);
result.put("message", "没有此服务权限");
log.error("APIService_AccsessIp : " + request.getRemoteAddr());
return result;
}
// 验证hmac有效性
try {
String macVal = CertService.hmacSha1(applicationInfo.getSecretKey().getBytes(), (appId + orderNumber + image1 + image2 + type).getBytes("utf-8"));
// sc.getAddressKey()), false);
if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
result.put("status", -2);
result.put("message", "服务密钥错误");
return result;
}
} catch (Exception e) {
result.put("status", -3);
result.put("message", "Hmac验证错误");
e.printStackTrace();
return result;
}
Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
// 1、订单状态为:未支付、支付待确认、已支付待审核、送审中的状态,其余状态不能继续往下执行
List<Integer> modifiedStatus = new ArrayList<Integer>();
modifiedStatus.add(ComNames.BILL_STATUS_3);
modifiedStatus.add(ComNames.BILL_STATUS_4);
modifiedStatus.add(ComNames.BILL_STATUS_10);
// 不在以上状态中
if (modifiedStatus.indexOf(bill.getBillStatus()) == -1) {
result.put("message", "该订单不能上传图片");
return result;
}
// 1.营业执照或事业单位法人证书 2.组织机构代码证 3.税务登记证 4.法定代表人证件 5.代理人证件 6.授权书
if (type.equals("1")) {
BusinessLicense lc = businessService.getBusinessByBillId(bill.getId(), null);
if (lc == null) {
result.put("message", "不需要上传营业执照或(事业单位)法人证书图片");
return result;
}
BusinessLicense business = businessService.portUpdateBusiness(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (business == null) {
result.put("message", "营业执照或(事业单位)法人证书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "营业执照或(事业单位)法人证书图片图片上传成功");
return result;
} else if (type.equals("2")) {
OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
if (oc == null) {
result.put("message", "不需要上传组织机构代码证书图片");
return result;
}
OrgCode orgCode = orgCodeService.portUpdateOrgCode(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (orgCode == null) {
result.put("message", "组织机构代码证书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "组织机构代码证书图片上传成功");
return result;
} else if (type.equals("3")) {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId(bill.getId(), null);
if (tc == null) {
result.put("message", "不需要上传税务登记证图片");
return result;
}
TaxRegisterCert taxRegisterCert = taxCertService.portUpdateTaxCert(bill.getId(), enterprise.getEnterpriseSn(), image1);
if (taxRegisterCert == null) {
result.put("message", "税务登记证图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "税务登记证图片上传成功");
return result;
} else if (type.equals("4")) {
IdentityCard ic = identityCardService.getIdentityCardByBillId(bill.getId(), null);
if (ic == null) {
result.put("message", "不需要上传法定代表人证件图片");
return result;
}
if (ic.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
result.put("message", "提交的参数信息不完整");
return result;
}
IdentityCard identityCard = identityCardService.portUpdateIdentityCard(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
if (identityCard == null) {
result.put("message", "法定代表人证件图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "法定代表人证件图片上传成功");
return result;
} else if (type.equals("5")) {
Agent at = agentService.getAgentByBillId(bill.getId(), null);
if (at == null) {
result.put("message", "不需要上传代理人证件图片");
return result;
}
if (at.getCardType().equals(1) && StringUtils.isEmpty(image2)) {
result.put("message", "提交的参数信息不完整");
return result;
}
Agent agent = agentService.portUpdateAgent(bill.getId(), enterprise.getEnterpriseSn(), image1, image2);
if (agent == null) {
result.put("message", "代理人证件图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "代理人证件图片上传成功");
return result;
} else if (type.equals("6")) {
Proxy py = proxyService.getProxyByBillId(bill.getId());
if (py == null) {
result.put("message", "不需要上传授权书图片");
return result;
}
Proxy proxy = proxyService.portUpdateProxy(bill.getId(), userInfo.getUniqueId(), image1);
if (proxy == null) {
result.put("message", "授权书图片上传失败");
return result;
}
result.put("status", 1);
result.put("message", "授权书图片上传成功");
return result;
} else {
result.put("message", "图片类型参数输入有误");
return result;
}
} catch (Exception e) {
e.printStackTrace();
if (e.getMessage().contains("图片大小不能")) {
result.put("status", 0);
result.put("message", e.getMessage());
return result;
}
// TODO Auto-generated catch block
result.put("status", 0);
result.put("message", "服务端出现未知错误,请联系管理员");
return result;
}
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class UserInfoController method detail.
/**
* 查看用户详情
*
* @param id
* 用户id
* @param item
* 用户关联的项(0企业、1证书、2订单、3认证)
* @param page
* @param size
* @param uiModel
* @return
*/
@RequestMapping("/detail")
public String detail(@RequestParam(value = "id", required = true) Long id, @RequestParam(value = "item", required = false) Integer item, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", id);
// 判断查询的用户是否属于当前管理员所管理的范围
Long[] manageProjectIds = getProjectLongIdsOfAdmin();
// 默认不属于当前管理员管理范围
boolean flag = false;
for (Long projectId : manageProjectIds) {
if (userInfo.getProject() == projectId) {
flag = true;
}
}
if (!flag) {
// 没有管理权限
return "status403";
}
// 根据省市区code值获取省市区最新名称
String regionCodes = userInfo.getRegionCodes();
String userAdds = userInfo.getUserAdds();
if (StringUtils.isNotBlank(regionCodes) && regionCodes.indexOf("@") >= 0) {
String[] codes = regionCodes.split("@");
String regionName = sysRegionService.getAllName(codes[1], codes[2], codes[3]);
userAdds = regionName + userAdds;
userInfo.setUserAdds(userAdds);
}
uiModel.addAttribute("userInfo", userInfo);
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 10;
}
// 总记录数
Integer count = 0;
// 当前页记录数
Integer itemcount = 0;
// null、0关联企业,1证书信息,2订单列表
if (null == item || 0 == item) {
item = 0;
// 关联企业
List<Enterprise> enterprises = new ArrayList<Enterprise>();
List<Long> enterpriseIds = userInfoEnterpriseService.getEnterpriseByUserInfo(userInfo.getId());
if (null != enterpriseIds && !enterpriseIds.isEmpty()) {
count = enterpriseIds.size();
EnterpriseExample enterpriseExample = new EnterpriseExample();
EnterpriseExample.Criteria criteria = enterpriseExample.or();
criteria.andIdIn(enterpriseIds);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
enterpriseExample.setOffset(offset);
enterpriseExample.setLimit(size);
enterpriseExample.setOrderByClause("create_time desc");
enterprises = sqlSession.selectList("com.itrus.portal.db.EnterpriseMapper.selectByExample", enterpriseExample);
}
itemcount = enterprises.size();
uiModel.addAttribute("enterprises", enterprises);
} else if (1 == item) {
item = 1;
// TODO 证书信息
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", userInfo.getId());
count = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.countByUserInfoID", userInfo.getId());
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
map.put("offset", offset);
map.put("limit", size);
List<UserCert> userCertList = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByUserInfoID", map);
itemcount = userCertList.size();
uiModel.addAttribute("userCertList", userCertList);
} else if (2 == item) {
item = 2;
// 订单列表
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
criteria.andUniqueIdEqualTo(userInfo.getId());
// criteria.andIsDeleteEqualTo(false);
count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExample);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
Integer offset = size * (page - 1);
billExample.setOffset(offset);
billExample.setLimit(size);
billExample.setOrderByClause("create_time desc");
List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
itemcount = billList.size();
uiModel.addAttribute("billList", billList);
Map<Long, Project> projectMap = billService.getProjectMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("projectMap", projectMap);
Map<Long, Product> productMap = billService.getProductMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("productMap", productMap);
Map<Long, Enterprise> enterpriseMap = billService.getEnterpriseMapByUserInfoId(userInfo.getId());
uiModel.addAttribute("enterpriseMap", enterpriseMap);
} else if (3 == item) {
item = 3;
Agent agent = sqlSession.selectOne("com.itrus.portal.db.AgentMapper.selectNewAgentByUserId", id);
uiModel.addAttribute("agent", agent);
}
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
uiModel.addAttribute("itemcount", itemcount);
uiModel.addAttribute("item", item);
return "userInfo/detail";
}
use of com.itrus.portal.db.Agent in project portal by ixinportal.
the class MakeCertController method push.
/**
* 手动推送
*
* @param id
* @param uiModel
* @return
*/
@RequestMapping(value = "/{id}/{type}", method = RequestMethod.GET, produces = "text/html")
@ResponseBody
public String push(@PathVariable("id") Long id, @PathVariable("type") Long type, Model uiModel) {
SignatureConfig sc = null;
JSONObject data = null;
JSONObject org = null;
JSONObject result = null;
Bill bill = null;
/*if(type==1){
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()="+bill.getMcstatus()+"bill="+bill);
if(null == bill) {
//log.error(bill.getMcstatus()+"---------------------------------------------"+bill);
//System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey",
product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "" : tc.getCertNo());
}
org.put("papersType", "营业执照");
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey",
bill.getUniqueId());
org.put("businessNum", userInfo.getTelephone());
// IdentityCard ic =
// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
// null);
org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
Agent agent = agentService.getAgentByBillId((id), null);
org.put("transactorName", agent == null ? enterprise.getEnterpriseName() : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());
if (data == null) {
data = new JSONObject();
}
data.put("appId", sc.getAppId());
data.put("timestamp", System.currentTimeMillis());
data.put("user", org);
data.put("autoCert", true);
data.put("autoSeal", true);
// String content =
// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
// bill =
// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
// map.get("id"));
if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
// return "redirect:/makecert";
return null;
}
log.error("打印data="+data.toString());
log.error("----------接口地址**************"+sc.getAddress() + USER_URL+"***********服务密钥**********"+sc.getAddressKey());
result = JSONObject
.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
log.equals("MakeCert_push_result : " + result);
if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户",
bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
}else */
if (type == 1) {
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
if (null == bill) {
// System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "orgCode" : tc.getCertNo());
}
org.put("papersType", "营业执照");
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
org.put("businessNum", userInfo.getTelephone() == null ? "businessNum" : userInfo.getTelephone());
// null);
if (bl != null) {
org.put("legalPersonName", bl.getLegalPerson() == null ? "legalPersonName" : bl.getLegalPerson());
} else {
org.put("legalPersonName", "legalPersonName");
}
Agent agent = agentService.getAgentByBillId((id), null);
org.put("transactorName", agent == null ? "transactorName" : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
} else {
org.put("transactorIdCardNum", "transactorIdCardNum");
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());
if (data == null) {
data = getJSONRequest(sc.getAppId());
}
data.put("autoCert", true);
data.put("autoSeal", true);
// data.put("appId", sc.getAppId());
// data.put("timestamp", System.currentTimeMillis());
data.put("user", org);
// String content =
// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
// bill =
// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
// map.get("id"));
/*if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
// return "redirect:/makecert";
return null;
}*/
log.error("打印data=" + data.toString());
log.error("----------接口地址**************" + sc.getAddress() + USER_URL + "***********服务密钥**********" + sc.getAddressKey());
result = JSONObject.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
log.equals("MakeCert_push_result : " + result);
if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
} else {
try {
bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
if (null == bill) {
// System.out.println(bill.getMcstatus()+"=******************************="+bill);
return "该订单无法推送";
}
Product product = productService.getProductById(bill.getProduct());
sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
BusinessLicense bl = businessService.getBusinessByBillId((id), null);
/*if (org == null) {
org = new JSONObject();
}
org.put("userType", 1);
org.put("fullName", bl.getEnterpriseName());
if (bl != null && bl.getBusinessType() == 1) {
org.put("orgCode", bl.getLicenseNo());
} else {
TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
org.put("orgCode", tc == null ? "" : tc.getCertNo());
}
org.put("papersType", "营业执照");*/
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
// org.put("businessNum", userInfo.getTelephone());
// IdentityCard ic =
// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
// null);
// org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
Agent agent = agentService.getAgentByBillId((id), null);
/*org.put("transactorName", agent == null ? "" : agent.getName());
if (agent != null && agent.getCardType() == 1) {
org.put("transactorIdCardNum", agent.getIdCode());
}
org.put("transactorMobile", userInfo.getmPhone());
org.put("realInfoOrder", bill.getBillId());
org.put("realInfoUid", bill.getUniqueId());*/
if (data == null) {
data = new JSONObject();
}
Map<String, Object> treeMap = Maps.newTreeMap();
treeMap.put("app_id", sc.getAppId());
treeMap.put("order_number", bill.getBillId());
treeMap.put("user_name", enterprise.getEnterpriseName());
treeMap.put("user_email", userInfo.getEmail());
treeMap.put("user_phone", userInfo.getmPhone());
treeMap.put("user_type", "organization");
/*String cardType = null;
if(agent!=null && agent.getCardType()!=null){
if(agent.getCardType()==1){
cardType = "IdentityCard";
}else if(agent.getCardType()==2){
cardType = "NationalPassport";
}else{
cardType = "Other";
}
treeMap.put("identification_number",agent.getIdCode());
}
*/
String cardType = null;
String sn = null;
BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
if (businessLicense != null && businessLicense.getBusinessType() == 1) {
sn = businessLicense.getLicenseNo();
cardType = "UniformSocialCreditCode";
}
if (businessLicense == null || businessLicense.getBusinessType() != 1) {
// 不是五证合一
OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
if (oc != null) {
sn = oc.getOrgCode();
cardType = "OrganizationCode";
}
}
treeMap.put("identification_number", sn);
treeMap.put("identity_type", cardType);
String jsondata = JSONObject.toJSONString(treeMap);
String data1 = mapToQueryString(treeMap);
log.error(data1);
result = JSONObject.parseObject(RequestUtils.post1(sc.getAddress(), jsondata.toString(), data1, sc.getAddressKey(), "HMAC-SHA256"));
log.equals("MakeCert_push_result : " + result);
if (result.getString("code") != null && "SUCCESS".equals(result.getString("code").toString())) {
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
bill.setMcstatus(1);
bill.setBillStatus(8);
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
sqlSession.flushStatements();
// return "redirect:/makecert";
return null;
}
LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
// uiModel.addAttribute("error", "错误:" +
// result.getString("message"));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
// uiModel.addAttribute("error", "错误:" + e);
return "错误【" + e + "】";
}
}
return "错误【" + result.getString("message") + "】";
}
Aggregations