@Override public Passport apply(PassCode passCode) { log.info("Gugong Apply Code: " + passCode.getSerialNo()); Passport passport = new Passport(); passport.setEventType(PassportConstant.PASSCODE_TYPE.APPLAYCODE.name()); passport.setSendSms(PassportConstant.PASSCODE_SMS_SENDER.LVMAMA.name()); try { sendOrder(passCode, passport); } catch (Exception e) { passport.setStatus(PassportConstant.PASSCODE_STATUS.FAILED.name()); passport.setErrorNO(PassportConstant.PASSCODE_ERROR.APPLY.name()); passport.setComLogContent(e.getMessage()); this.reapplySet(passport, passCode.getReapplyCount()); log.error("Gugong Apply Exception message:", e); } return passport; }
private Passport sendOrder(PassCode passCode, Passport passport) { String orderInfo = buildOrderInfo(passCode); log.info("GugongOrderRequest:" + orderInfo); GugongOrderResponse response = null; Long startTime = 0L; try { if (orderInfo.isEmpty()) { throw new RuntimeException("由于未获取到支付信息,未生成订单信息"); } startTime = System.currentTimeMillis(); response = GugongHTTPUtil.sendOrder(orderInfo); log.info( "Gugong Apply serialNo :" + passCode.getSerialNo() + " UseTime:" + (System.currentTimeMillis() - startTime) / 1000); } catch (ClientProtocolException e) { this.reapplySet(passport, passCode.getReapplyCount()); passport.setComLogContent( "故宫对接推单:地址" + GugongConstant.GUGONG_URLS.GUGONG_URLS_ORDER.getUrl() + " 客户端协议异常" + e); log.error(e); } catch (ParseException e) { this.reapplySet(passport, passCode.getReapplyCount()); passport.setComLogContent("解析永乐方返回的推单结果:异常" + e); log.error(e); } catch (IOException e) { this.reapplySet(passport, passCode.getReapplyCount()); passport.setComLogContent( "故宫对接推单:地址" + GugongConstant.GUGONG_URLS.GUGONG_URLS_ORDER.getUrl() + " 网络异常" + e); log.error(e); } catch (Exception e) { log.error( "Gugong Apply serialNo Error :" + passCode.getSerialNo() + " UseTime:" + (System.currentTimeMillis() - startTime) / 1000); this.reapplySet(passport, passCode.getReapplyCount()); passport.setComLogContent(e.getMessage()); log.error(e); } boolean flag = false; if (response != null) { if (response.isSuccess()) { String ylorderId = response.getYlorderid(); passport.setStatus(PassportConstant.PASSCODE_STATUS.SUCCESS.name()); passport.setSerialno(passCode.getSerialNo()); passport.setAddCode(ylorderId); passport.setExtId(ylorderId); passport.setCode(cardNum); // 故宫产品code则存放证件号 passport.setMessageWhenApplySuccess(""); // 清空状态描述信息 flag = true; } } if (!flag) { passport.setErrorNO(PassportConstant.PASSCODE_ERROR.APPLY.name()); // 如果推单失败原因是由永乐方业务代码不成功,而非系统异常,申码失败且不重申码 passport.setStatus(PassportConstant.PASSCODE_STATUS.FAILED.name()); if (response != null) { passport.setComLogContent( GugongConstant.getInstance().getCodeMsg(response.getResultcode())); } else { passport.setComLogContent("供应商返回信息为空"); } } return passport; }