use of com.itrus.portal.db.OnlinePayExample in project portal by ixinportal.
the class TransferController method list.
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "message", required = false) Integer message, @RequestParam(value = "status", required = false) Integer status, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "page2", required = false) Integer page2, @RequestParam(value = "size2", required = false) Integer size2, Model uiModel) throws Exception {
// page,size
if (page == null || page < 1)
page = 1;
if (size == null || size < 1)
size = 10;
// count,pages
Integer count = sqlSession.selectOne("com.itrus.portal.db.TransferMapper.countByExample", null);
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
// page, size
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
// query data
Integer offset = size * (page - 1);
TransferExample transferex = new TransferExample();
// projectex.or().andIdIsNotNull();
transferex.setOffset(offset);
transferex.setLimit(size);
List transferall = sqlSession.selectList("com.itrus.portal.db.TransferMapper.selectByExample", transferex);
uiModel.addAttribute("transfers", transferall);
// itemcount
uiModel.addAttribute("itemcount", transferall.size());
uiModel.addAttribute("message", message == null ? "" : "要删除的发票存在关联,无法删除");
// page,size
if (page2 == null || page2 < 1)
page2 = 1;
if (size2 == null || size2 < 1)
size2 = 10;
// count,pages
Integer count2 = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.countByExample", null);
uiModel.addAttribute("count2", count2);
uiModel.addAttribute("pages2", (count2 + size2 - 1) / size2);
// page, size
if (page2 > 1 && size2 * (page2 - 1) >= count2) {
page2 = (count2 + size2 - 1) / size;
}
uiModel.addAttribute("page2", page2);
uiModel.addAttribute("size2", size2);
// query data
Integer offset2 = size2 * (page2 - 1);
OnlinePayExample onlinepayex = new OnlinePayExample();
// projectex.or().andIdIsNotNull();
onlinepayex.setOffset(offset2);
onlinepayex.setLimit(size2);
List onlinepayexall = sqlSession.selectList("com.itrus.portal.db.OnlinePayMapper.selectOnlinePays", onlinepayex);
uiModel.addAttribute("onlinepays", onlinepayexall);
PayConfigExample payconfigex = new PayConfigExample();
Map<Long, PayConfig> payconfigmap = sqlSession.selectMap("com.itrus.portal.db.PayConfigMapper.selectByExample", payconfigex, "id");
uiModel.addAttribute("payconfigmap", payconfigmap);
// itemcount
uiModel.addAttribute("itemcount", onlinepayexall.size());
uiModel.addAttribute("message", message == null ? "" : "要删除的发票存在关联,无法删除");
uiModel.addAttribute("status", status);
return "transfer/list";
}
use of com.itrus.portal.db.OnlinePayExample in project portal by ixinportal.
the class OnlinePayServiceImpl method removeOnlinePayWithOutClientFw.
/**
* 移除不属于服务型客户的在线支付,只返回服务型客户的在线支付
* @return
*/
public String[] removeOnlinePayWithOutClientFw(String[] onpay) {
String ClientFwPayConfigId = systemConfigService.getClientfwPayConfigIds();
if (StringUtils.isNotBlank(ClientFwPayConfigId)) {
String[] ClientFwPayConfigIds = ClientFwPayConfigId.split(",");
List<Long> payConfigIds = new ArrayList<>();
for (String string : ClientFwPayConfigIds) {
payConfigIds.add(Long.valueOf(string));
}
OnlinePayExample example = new OnlinePayExample();
OnlinePayExample.Criteria criteria = example.or();
criteria.andPayConfigIn(payConfigIds);
List<OnlinePay> onlinePayList = selectByExample(example);
if (null == onlinePayList || onlinePayList.isEmpty()) {
return onpay;
}
List<Long> onlinePayIds = new ArrayList<>();
for (OnlinePay onlinePay : onlinePayList) {
onlinePayIds.add(onlinePay.getId());
}
// 将要匹配的服务型客户端的支付加入数组中,然后返回
List<String> newOnpayList = new ArrayList<>();
for (String string : onpay) {
if (onlinePayIds.contains(Long.valueOf(string))) {
newOnpayList.add(string);
}
}
String[] strings = new String[newOnpayList.size()];
return newOnpayList.toArray(strings);
} else {
return onpay;
}
}
use of com.itrus.portal.db.OnlinePayExample in project portal by ixinportal.
the class ClientPayWebController 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);
BillExample be = new BillExample();
BillExample.Criteria bc = be.createCriteria();
bc.andBillIdEqualTo(billId);
bc.andBillStatusIn(Arrays.asList(new Integer[] { 1, 11 }));
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", be);
if (null == bill) {
return;
}
bill.setBillStatus(3);
bill.setPayTime(new Date(Long.parseLong(payTime)));
// 产品
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
// pfx流程判断begin
DigitalCert digitalCert = null;
if (null != product.getCert()) {
digitalCert = digitalCertService.getDigitalCert(product.getCert());
if (null != digitalCert && null != digitalCert.getCertType() && digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX)) {
// 这个用户,这个企业,这个项目,有通过了实名认证的订单,则直接进入待下载,
List<Bill> bills = billService.hasAuthticationLevel(bill.getUniqueId(), bill.getEnterprise(), product.getProject());
if (null != bills && bills.size() > 0 && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2)) {
bill.setBillStatus(ComNames.BILL_STATUS_13);
// 新增审核通过的记录
reviewService.agreeBillReview(bill);
}
}
}
// 解锁产品流程判断gegin
if (null != product.getKeyUnlockType()) {
bill = unLockKeyBillService.updateBillStatusWhileHasPay(bill, product);
}
// 解锁产品流程判断end
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(transactionId);
OnlinePayExample ope = new OnlinePayExample();
OnlinePayExample.Criteria opc = ope.createCriteria();
opc.andPayConfigEqualTo(payConfigId);
// 1支付宝 2微信
opc.andWayEqualTo((Integer.parseInt(payType) == 0 ? 1 : 2));
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);
} 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.OnlinePayExample 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.OnlinePayExample 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