use of com.itrus.portal.db.OnlinePay in project portal by ixinportal.
the class UnlockKeyBillController method zhifuPage.
/**
* 3进入支付页面
*
* @param billId
* @param request
* @param uiModel
* @return
*/
@RequestMapping("/zhifu/{billId}")
public String zhifuPage(@PathVariable("billId") Long billId, @RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
String ip = request.getRemoteAddr();
uiModel.addAttribute("ip", ip);
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
if (null == bill) {
return "resourceNotFound";
}
// 产品
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
if (null == product) {
// 产品不存在
uiModel.addAttribute("errorMsg", "您购买的产品不存在");
return ComNames.CLIENTFW_ERRORPAGE;
}
if (null == product.getOnpay() && StringUtils.isBlank(product.getPay()) && bill.getBillSum().equals(0.00)) {
// 跳转到订单支付成功页面,并将订单状态设置为3已支付 待审核
if (null != product.getKeyUnlockType()) {
bill = unLockKeyBillService.updateBillStatusWhileHasPay(bill, product);
} else {
bill.setBillStatus(ComNames.BILL_STATUS_3);
}
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
session.setAttribute("webbill", bill);
if (null != product.getKeyUnlockType()) {
UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
return "redirect:/doUnlockKey/toUnlockKeyPage?" + "billId=" + billId + "&certSn=" + userCert.getCertSn() + "&keySn=" + userCert.getKeySn() + "&enterpriseName=" + enterprise.getEnterpriseName();
} else {
return "redirect:/billClient";
}
}
// 获取产品对应的线上支付服务
if (product.getOnpay() != null && product.getOnpay() != "") {
List<Long> onlinepays = new ArrayList<Long>();
String[] onpay = (product.getOnpay()).split(",");
// 过滤掉不是服务型客户的在线支付
onpay = onlinePayService.removeOnlinePayWithOutClientFw(onpay);
Map<Integer, String> map = new HashMap<Integer, String>();
for (int i = 0; i < onpay.length; i++) {
OnlinePay op = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onpay[i]);
map.put(op.getSort(), onpay[i]);
}
Set<Integer> set = map.keySet();
Object[] obj = set.toArray();
Arrays.sort(obj);
for (int i = (onpay.length - 1); i >= 0; i--) {
String a = map.get(obj[i]);
onlinepays.add(Long.parseLong(a));
}
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
uiModel.addAttribute("onlinepays", onlinepays);
Map<Long, PayConfig> pcMap = sqlSession.selectMap("com.itrus.portal.db.PayConfigMapper.selectByExample", "id");
uiModel.addAttribute("pcMap", pcMap);
}
// 获取产品对应的银行汇款服务
if (!StringUtils.isBlank(product.getPay())) {
Transfer transfer = sqlSession.selectOne("com.itrus.portal.db.TransferMapper.selectByPrimaryKey", Long.parseLong(product.getPay()));
uiModel.addAttribute("transfer", transfer);
}
if (null != product.getTransferNotes()) {
product.setTransferNotes(product.getTransferNotes().replace("\r\n", "<br/><span ></span>"));
}
// 解锁订单,返回keysn,certsn,enterprisename
if (null != product.getKeyUnlockType() && (StringUtils.isBlank(keySn) || StringUtils.isBlank(certSn) || StringUtils.isBlank(enterpriseName))) {
Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
enterpriseName = enterprise.getEnterpriseName();
UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
if (null != userCert && StringUtils.isNotBlank(userCert.getKeySn())) {
keySn = userCert.getKeySn();
}
if (null != userCert && StringUtils.isNotBlank(userCert.getCertSn())) {
certSn = userCert.getCertSn();
}
}
uiModel.addAttribute("product", product);
uiModel.addAttribute("certSn", certSn);
uiModel.addAttribute("keySn", keySn);
uiModel.addAttribute("enterpriseName", enterpriseName);
session.setAttribute("webbill", bill);
if (null != product.getCert()) {
// 产品关联的数字证书
DigitalCert digitalCert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
// 用于获取产品期限(数字证书的期限)
uiModel.addAttribute("digitalCert", digitalCert);
}
return "clientFW/pay";
}
use of com.itrus.portal.db.OnlinePay in project portal by ixinportal.
the class ExtraBillWebController method refuse.
// 审核拒绝重新提交页面
@RequestMapping(value = "/resubmit/{id}", produces = "text/html")
public String refuse(@PathVariable("id") Long id, Model uiModel, HttpServletRequest request) {
HttpSession session = request.getSession();
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
if (null == webenterprise || null == webuserInfo) {
uiModel.addAttribute("errorMsg", "登录失效");
return "client/errorpage";
}
ExtraBill bill = extraBillService.selectByPrimaryKey(id);
if (null == bill) {
uiModel.addAttribute("errorMsg", "未找到该订单");
return "client/errorpage";
}
if (!bill.getUniqueId().equals(webuserInfo.getId())) {
uiModel.addAttribute("errorMsg", "您无权操作该订单");
return "client/errorpage";
}
// 获取订单在线支付方式
if (null != bill.getOnPayInfo()) {
// 第三方在线支付记录信息
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
// 在线支付方式配置,目前有微信和支付宝两种
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
// 订单
uiModel.addAttribute("bill", bill);
// 产品
ExtraProduct product = sqlSession.selectOne("com.itrus.portal.db.ExtraProductMapper.selectByPrimaryKey", bill.getExtraProduct());
uiModel.addAttribute("product", product);
// 用户
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
uiModel.addAttribute("userInfo", userInfo);
// 企业
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
uiModel.addAttribute("enterprise", enterprise);
FileInputStream fis = null;
try {
if (null != product.getExtraMessage()) {
ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
// 用附加信息项的有无来判断是否需要用户填写附加信息,如果需要,则取附加信息项进行分割处理
uiModel.addAttribute("extraMessage", extraMessage);
File file = new File(systemConfigService.getTrustDir().getPath() + File.separator + enterprise.getEnterpriseSn());
if (!file.exists()) {
file.mkdir();
}
// //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (extraMessage.getEnterpriseItems().contains("2")) {
// 营业执照
BusinessLicense businessLicense = businessService.getBusinessByExtraBillId(id, null);
if (null != businessLicense) {
File imgFile = new File(file, businessLicense.getImgFile());
fis = new FileInputStream(imgFile);
businessLicense.setImgFile(ImageToBase64Utils.GetFileBase64(fis));
fis.close();
uiModel.addAttribute("businessLicense", businessLicense);
}
}
if (extraMessage.getEnterpriseItems().contains("3")) {
// 组织机构代码
OrgCode orgCode = orgCodeService.getOrgCodeByExtraBillId(id, null);
if (null != orgCode) {
File imgFile = new File(file, orgCode.getImgFile());
fis = new FileInputStream(imgFile);
orgCode.setImgFile(ImageToBase64Utils.GetFileBase64(fis));
fis.close();
uiModel.addAttribute("orgCode", orgCode);
}
}
if (extraMessage.getEnterpriseItems().contains("4")) {
// 税务登记
TaxRegisterCert taxRegisterCert = taxCertService.getTaxRegisterCertByExtraBillId(id, null);
if (null != taxRegisterCert) {
File imgFile = new File(file, taxRegisterCert.getImgFile());
fis = new FileInputStream(imgFile);
taxRegisterCert.setImgFile(ImageToBase64Utils.GetFileBase64(fis));
fis.close();
uiModel.addAttribute("taxRegisterCert", taxRegisterCert);
}
}
}
// field string --fieldName agentItems
if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
Agent agent = agentService.getAgentByExtraBillId(id, null);
if (null != agent) {
File imgFile = new File(file, agent.getFrontImg());
fis = new FileInputStream(imgFile);
agent.setFrontImg(ImageToBase64Utils.GetFileBase64(fis));
if (StringUtils.isNotBlank(agent.getBackImg())) {
File backImgFile = new File(file, agent.getBackImg());
fis = new FileInputStream(backImgFile);
agent.setBackImg(ImageToBase64Utils.GetFileBase64(fis));
fis.close();
}
uiModel.addAttribute("agent", agent);
}
}
// field string --fieldName bankItems
if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
OpenBankInfo openBankInfo = openBankInfoService.getOpenBankInfoByExtraBillId(id, null);
if (null != openBankInfo) {
uiModel.addAttribute("openBankInfo", openBankInfo);
}
}
// 法人认证项
if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
IdentityCard identityCard = identityCardService.getIdentityCardByExtraBillId(id, null);
if (null != identityCard) {
File imgFile = new File(file, identityCard.getFrontImg());
fis = new FileInputStream(imgFile);
identityCard.setFrontImg(ImageToBase64Utils.GetFileBase64(fis));
if (StringUtils.isNotBlank(identityCard.getBackImg())) {
File backImgFile = new File(file, identityCard.getBackImg());
fis = new FileInputStream(backImgFile);
identityCard.setBackImg(ImageToBase64Utils.GetFileBase64(fis));
fis.close();
}
uiModel.addAttribute("identityCard", identityCard);
}
}
}
} catch (Exception e) {
// TODO: handle exception
UserLog userlog = new UserLog();
userlog.setProject(bill.getProject());
userlog.setType("审核拒绝重新提交");
userlog.setInfo("url:resubmit,详细错误:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
} finally {
if (null != fis) {
try {
fis.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
}
return "client/shenhejujue_chongxintijiao";
}
use of com.itrus.portal.db.OnlinePay in project portal by ixinportal.
the class ExtraBillWebController method refusePage.
// 审核拒绝页面
@RequestMapping(value = "/refusebill/{id}.html", produces = "text/html")
public String refusePage(@PathVariable("id") Long id, @RequestParam(value = "processProgress", required = false) Long processProgress, Model uiModel, HttpServletRequest request) {
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";
}
ExtraBill bill = extraBillService.selectByPrimaryKey(id);
if (null == bill) {
uiModel.addAttribute("errorMsg", "订单不存在");
return "client/errorpage";
}
uiModel.addAttribute("bill", bill);
if (!bill.getUniqueId().equals(userInfo.getId())) {
uiModel.addAttribute("errorMsg", "您无权操作该订单");
return "client/errorpage";
}
// 订单对应的产品信息
ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
uiModel.addAttribute("product", product);
// 订单对应的规格信息
ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec());
uiModel.addAttribute("productSpec", productSpec);
// 银行卡支付记录信息
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
// 获取订单在线支付方式
if (null != bill.getOnPayInfo()) {
// 第三方在线支付记录信息
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
// 在线支付方式配置,目前有微信和支付宝两种
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
// 电子发票信息
if (null != bill.geteInvoice()) {
Einvoice einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", bill.geteInvoice());
uiModel.addAttribute("einvoice", einvoice);
}
// 纸票模版
Map<Long, Receipt> receiptmap = sqlSession.selectMap("com.itrus.portal.db.ReceiptMapper.selectByExample", null, "id");
uiModel.addAttribute("receiptmap", receiptmap);
// 电票开票模版
Map<Long, Ereceipt> ereceiptmap = sqlSession.selectMap("com.itrus.portal.db.EreceiptMapper.selectByExample", null, "id");
uiModel.addAttribute("ereceiptmap", ereceiptmap);
return "client/shenhejujue";
}
use of com.itrus.portal.db.OnlinePay in project portal by ixinportal.
the class PayExtraBillWebController method updatePayInfo.
private void updatePayInfo(String billId, Long payConfigId, String transactionId, String payType, String payTime) throws Exception {
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus s = null;
try {
s = transactionManager.getTransaction(def);
ExtraBill bill = extraBillService.getExtraBillByBillId(billId);
if (null == bill) {
return;
}
bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
bill.setPayTime(new Date(Long.parseLong(payTime)));
extraBillService.updateByPrimaryKeySelective(bill);
OnPayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
payInfo.setPayStatus(1);
payInfo.setWcTime(bill.getPayTime());
payInfo.setPayNo(transactionId);
OnlinePayExample ope = new OnlinePayExample();
OnlinePayExample.Criteria opc = ope.createCriteria();
opc.andPayConfigEqualTo(payConfigId);
// 1支付宝
opc.andWayEqualTo((Integer.parseInt(payType) == 0 ? 1 : 2));
// 2微信
OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByExample", ope);
payInfo.setOnlinePay(onlinePay.getId());
sqlSession.update("com.itrus.portal.db.OnPayInfoMapper.updateByPrimaryKeySelective", payInfo);
transactionManager.commit(s);
} catch (Exception e) {
LogUtil.syslog(sqlSession, "在线支付_增值订单", billId + "回调更新数据库错误:" + e.toString());
throw new Exception(billId + "回调增值订单更新数据库错误:" + e.toString());
} finally {
if (null != s && !s.isCompleted()) {
transactionManager.rollback(s);
}
}
}
use of com.itrus.portal.db.OnlinePay in project portal by ixinportal.
the class PayWebController method notifyUrl.
/**
* 客户服务器回调页面
* [callback]<xml>
* <nonce_str><![CDATA[1639324264]]></nonce_str>
* <out_trade_no><![CDATA[TWCX20160629144115177012]]></out_trade_no>
* <return_code><![CDATA[SUCCESS]]></return_code>
* <return_msg><![CDATA[姣浠瀹氦骀]]></return_msg>
* <total_fee><![CDATA[0.01]]></total_fee>
* <transaction_id><![CDATA[2016071521001004860279928780]]></transaction_id>
* <sign>321D99F194DE952B6699C3E23361C06C</sign>
* <nonce_str>1639324264</nonce_str>
* </xml>
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/notifyUrl")
public String notifyUrl(HttpServletRequest request, HttpServletResponse response) {
String line = null;
String notifyXml = "";
// DefaultTransactionDefinition def = new DefaultTransactionDefinition();
// def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
// TransactionStatus s = null;
Map<String, String> m = null;
try {
if ((line = request.getReader().readLine()) != null) {
notifyXml += line;
}
m = PayUtil.parseXmlToList2(notifyXml);
String sign = m.get("sign");
PayConfigExample pce = new PayConfigExample();
PayConfigExample.Criteria pcc = pce.createCriteria();
pcc.andAppIdEqualTo(m.get("appid"));
PayConfig pc = sqlSession.selectOne("com.itrus.portal.db.PayConfigMapper.selectByExample", pce);
APP_SECRET_KEY = pc.getSecretKey();
boolean validate = PayUtil.validate(sign, m, APP_SECRET_KEY);
if (validate) {
if (("SUCCESS").equals(m.get("return_code"))) {
// m.get("return_msg");//返回信息
// m.get("out_trade_no");//交易订单号
// s = transactionManager.getTransaction(def);
BillExample be = new BillExample();
BillExample.Criteria bc = be.createCriteria();
bc.andBillIdEqualTo(m.get("out_trade_no"));
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", be);
bill.setBillStatus(3);
bill.setPayTime(new Date());
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
OnPayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", bill.getOnPayInfo());
payInfo.setPayStatus(1);
payInfo.setWcTime(bill.getPayTime());
payInfo.setPayNo(m.get("transaction_id"));
OnlinePayExample ope = new OnlinePayExample();
OnlinePayExample.Criteria opc = ope.createCriteria();
opc.andPayConfigEqualTo(pc.getId());
// 1支付宝 2微信
opc.andWayEqualTo((Integer.parseInt(m.get("pay_type")) == 0 ? 2 : 1));
OnlinePay onlinePay = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByExample", ope);
payInfo.setOnlinePay(onlinePay.getId());
// payInfo.setComment(m.get("return_msg"));
sqlSession.update("com.itrus.portal.db.OnPayInfoMapper.updateByPrimaryKeySelective", payInfo);
// transactionManager.commit(s);
// 标示成功接收到
PayUtil.sendToCFT(response, "SUCCESS");
// m.get("total_fee");//金额
// m.get("attach");//附加数据 在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
} else if (("FAIL").equals(m.get("return_code"))) {
// 第三方返回支付失败的情况
PayUtil.sendToCFT(response, "SUCCESS");
LogUtil.syslog(sqlSession, "在线支付", m.get("out_trade_no") + "回调错误:[callback FAIL]FAIL" + notifyXml);
} else {
// 标示没接收到
PayUtil.sendToCFT(response, "FAIL");
LogUtil.syslog(sqlSession, "在线支付", m.get("out_trade_no") + "回调错误:[callback FAIL]" + notifyXml);
}
// if("FAIL".equals(m.get("result_code"))) {
// m.get("err_code");//错误码 有:SYSTEMERROR\SIGNERROR\LACK_PARAMS\PARAMS_ERROR\WECHAT_EMPTY\WECHAT_SIGNERROR\ALI_EMPTY\ALI_SIGNERROR
// m.get("err_code_des");//错误描述 有:系统错误\平台签名失败\缺少参数\参数不合规范或域名不匹配\微信报文为空\微信签名错误\支付宝报文为空\支付宝验签失败
// }
}
// for (Entry<String, String> s : m.entrySet()) {
// System.out.println(s.getKey()+"#################"+s.getValue());
// }
} catch (Exception e) {
LogUtil.syslog(sqlSession, "在线支付", m.get("out_trade_no") + "回调错误:" + e.toString() + notifyXml);
log.error(m.get("out_trade_no") + "[callback FAIL]" + e.toString());
e.printStackTrace();
}
// }
return null;
}
Aggregations