コード例 #1
0
  @Override
  public Page<Device> queryDeviceByCon(
      String batchNo, String devSn, String devKsn, int startIndex, int pageSize) throws Exception {

    if (StringUtils.isBlank(batchNo) && StringUtils.isBlank(devSn) && StringUtils.isBlank(devKsn)) {
      return null;
    }

    List<Object> params = new ArrayList<Object>();
    StringBuilder sb = new StringBuilder();

    sb.append("from " + Device.class.getName() + " dev");

    sb.append(" where 1=1");

    if (StringUtils.isNotBlank(batchNo)) {
      sb.append(" and dev.batchNo like ?");
      params.add("%" + batchNo + "%");
    }

    if (StringUtils.isNotBlank(devSn)) {
      sb.append(" and dev.devSn like ?");
      params.add("%" + devSn + "%");
    }

    if (StringUtils.isNotBlank(devKsn)) {
      sb.append(" and dev.devKsn like ?");
      params.add("%" + devKsn + "%");
    }

    sb.append(" order by dev.devId asc");

    return find(sb.toString(), startIndex, pageSize, params.toArray(new Object[params.size()]));
  }
コード例 #2
0
 @Override
 public RemittanceAccountResponsePage queryRmtAccount(Long usrId, String mrchNo) {
   RemittanceAccountResponsePage remittanceAccountResponsePage =
       new RemittanceAccountResponsePage();
   // 是否设置是否密码
   boolean isSetPayPwd = false;
   MrchUsr mrchUsr = mrchUsrService.findById(usrId);
   if (mrchUsr != null) {
     if (StringUtils.isNotBlank(mrchUsr.getPayPwd())) {
       isSetPayPwd = true;
     }
   }
   // 查询账户信息
   List<RemittanceAccountResponse> lists = new ArrayList<RemittanceAccountResponse>();
   try {
     lists = remitProcess.queryRmtAccount(mrchNo);
     remittanceAccountResponsePage.setMrchNo(mrchNo);
     remittanceAccountResponsePage.setIsRegisterRemit(true);
   } catch (Exception e) {
     remittanceAccountResponsePage.setIsRegisterRemit(false);
   }
   remittanceAccountResponsePage.setIsSetPayPwd(isSetPayPwd);
   remittanceAccountResponsePage.setRmtAccounts(lists);
   return remittanceAccountResponsePage;
 }
コード例 #3
0
  @Override
  public CCPCBillInfo queryCCPCBillInfo(String mrchNo, String rmtAccNo, String payNo) {
    CCPCBillInfo billInfo = null;
    PayCCPC payCCPC = payCCPCService.findPayCCPCByPayNoAndMrchNo(payNo, mrchNo);
    if (payCCPC != null) {
      if (StringUtils.isNotBlank(rmtAccNo)) {
        if (payCCPC.getRmtAccNo().equals(rmtAccNo)) {
          throw new AppRTException(
              AppExCode.ILLEGAL_PARAMS,
              "非法数据,transRefNo["
                  + payNo
                  + "]对应rmtAccNo["
                  + rmtAccNo
                  + "],但查出的是rmtAccNo["
                  + payCCPC.getRmtAccNo()
                  + "]");
        }
      }
      billInfo = XPOSPClientUtils.payCCPCToCCPCBillInfo(payCCPC);

      String elecsignsPath =
          XpospSysProperty.getESignaturePath()
              + payCCPC.getMrchNo()
              + File.separatorChar
              + payCCPC.getStoreNo()
              + File.separatorChar;
      String rmtElecSignDataFileName =
          payNo + "-rmt" + "." + XPOSPClientUtils.ESIGNATURE_PICTURE_SUFFIX;
      String bnyElecSignDataFileName =
          payNo + "-bny" + "." + XPOSPClientUtils.ESIGNATURE_PICTURE_SUFFIX;
      File remitElecSignDataFile = new File(elecsignsPath + rmtElecSignDataFileName);
      File bnyElecSignDataFile = new File(elecsignsPath + bnyElecSignDataFileName);
      if (remitElecSignDataFile.exists()) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        BufferedImage image;
        try {
          image = ImageIO.read(remitElecSignDataFile);
          ImageIO.write(image, XPOSPClientUtils.BILLINFO_PICTURE_SUFFIX, out);
          billInfo.setRmtElecsignData(CodecUtils.hexString(out.toByteArray()));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      if (bnyElecSignDataFile.exists()) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        BufferedImage image;
        try {
          image = ImageIO.read(bnyElecSignDataFile);
          ImageIO.write(image, XPOSPClientUtils.BILLINFO_PICTURE_SUFFIX, out);
          billInfo.setBnyElecsignData(CodecUtils.hexString(out.toByteArray()));
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    return billInfo;
  }
コード例 #4
0
 @Override
 public boolean addPayPwd(Long usrId, String payPwd) {
   boolean addSuccess = false;
   MrchUsr mrchUsr = mrchUsrService.findById(usrId);
   if (mrchUsr == null || (!mrchUsr.isUsrState())) {
     logger.info("用户[" + usrId + "]不存在或者用户被禁用");
     throw new AppRTException(AppExCode.MRCH_USR_UNAVAILABLE, "用户不存在或者用户被禁用!");
   }
   if (StringUtils.isNotBlank(mrchUsr.getPayPwd())) {
     throw new AppRTException(AppExCode.PAY_PWD_SETTED, "支付密码已设置,无法重新设置!");
   }
   mrchUsr.setPayPwd(StringUtils.trim(payPwd));
   mrchUsrService.updateMrchUsr(mrchUsr);
   addSuccess = true;
   return addSuccess;
 }
コード例 #5
0
  @Override
  public PayInfoResponse pay(PayInfoRequest request) {
    Long usrId = request.getUsrId();
    Assert.notNull(usrId, "usrId should not be null!");
    // 支付密码校验
    MrchUsr mrchUsr = mrchUsrService.findById(usrId);
    if (mrchUsr == null || (!mrchUsr.isUsrState())) {
      throw new AppRTException(
          AppExCode.MRCH_USR_UNAVAILABLE, "mrchUsr[" + usrId + "] not exist or disable!");
    }
    if (StringUtils.isBlank(mrchUsr.getPayPwd())) {
      throw new AppRTException(
          AppExCode.PAY_PWD_NOT_EXIST, "mrchUsr[" + usrId + "] payPwd not exitst");
    }
    if (!mrchUsr.getPayPwd().equalsIgnoreCase(request.getPayPwd())) {
      throw new AppRTException(AppExCode.PAY_PWD_ERROR, "payPwd error");
    }
    // 商户、门店校验
    Merchant merchant = merchantService.findMerchantByMrchNo(request.getMrchNo());
    if (merchant == null || !merchant.isAvailable()) {
      throw new AppRTException(
          AppExCode.MERCHANT_NOT_AVAILABLE, "merchant not exist!" + request.getMrchNo());
    }

    Store store = null;
    if (StringUtils.isNotBlank(request.getStoreNo())) {
      store = storeService.findByStoreNo(request.getStoreNo());
      if (store == null || !store.isAvailable()) {
        throw new AppRTException(
            AppExCode.STORE_NOT_AVAILABLE, "store not exist!" + request.getStoreNo());
      }
    }
    /** 交易流水是否重复* */
    String upSno = request.getTransToken();
    PayCCPC tempPayCCPC = payCCPCService.findPayCCPCByUpSno(upSno);
    if (tempPayCCPC != null) {
      logger.error("payCCPC[upSno:" + upSno + "] exist!!!");
      throw new AppRTException(AppExCode.TRADE_EXIST, "payCCPC[upSno:" + upSno + "] exist");
    }

    // 设置常用联系人 如果不存在则新增
    if (request.getIsFavoriteBnyAcc() != null) {
      if (request.getIsFavoriteBnyAcc()) {
        CCPCAccount temp =
            cCPCAccountService.findCCPCAccount(mrchUsr.getUsrLogin(), request.getBnyAccNo());
        if (temp == null) {
          CCPCAccount ccpcAccount = new CCPCAccount();
          ccpcAccount.setMrchNo(request.getMrchNo());
          ccpcAccount.setUsrLogin(mrchUsr.getUsrLogin());
          ccpcAccount.setRmtAccNo(request.getRmtAccNo());
          ccpcAccount.setBnyAccNo(request.getBnyAccNo());
          ccpcAccount.setBnyAccName(request.getBnyAccName());
          ccpcAccount.setBnyBankName(request.getBnyBankName());
          CCPCBank ccpcBank = ccpcBankService.findCCPCBankByBankName(request.getBnyBankName());
          ccpcAccount.setAbbrName(ccpcBank == null ? "DEFAULT" : ccpcBank.getAbbrName());
          cCPCAccountService.addCCPCAccount(ccpcAccount);
        }
      }
    }

    /** 构造支付流水* */
    String payNo = payNoGenerator.generate();
    Coordinate location = request.getLocation();

    /** 保存电子签名* */
    // 电子签名格式 payNo-transType.png
    boolean isSaveRmtEsignSuccess = false;
    boolean isSaveBnyEsignSuccess = false;
    if (request.getIsNeedBillInfo() != null && request.getIsNeedBillInfo()) {
      String rmtElecSignDataFileName =
          payNo + "-rmt" + "." + XPOSPClientUtils.ESIGNATURE_PICTURE_SUFFIX;
      String bnyElecSignDataFileName =
          payNo + "-bny" + "." + XPOSPClientUtils.ESIGNATURE_PICTURE_SUFFIX;
      isSaveRmtEsignSuccess =
          XPOSPClientUtils.saveElecsignPic(
              rmtElecSignDataFileName,
              request.getMrchNo(),
              request.getStoreNo(),
              request.getRmtElecsignData());
      isSaveBnyEsignSuccess =
          XPOSPClientUtils.saveElecsignPic(
              bnyElecSignDataFileName,
              request.getMrchNo(),
              request.getStoreNo(),
              request.getBnyElecsignData());
      request.setRmtElecsignData(null); // 由于电子签名数据量大,保存成功后清空
      request.setBnyElecsignData(null); // 由于电子签名数据量大,保存成功后清空
    }

    PayCCPC payCCPC = new PayCCPC();
    payCCPC.setPayNo(payNo);
    payCCPC.setMrchNo(request.getMrchNo());
    payCCPC.setMrchName(merchant.getMrchName());
    payCCPC.setStoreNo(request.getStoreNo());
    payCCPC.setStoreName(store == null ? null : store.getStoreName());
    payCCPC.setOperatorName(mrchUsr.getUsrName());
    payCCPC.setUpSno(upSno);
    payCCPC.setImei(request.getImei());
    payCCPC.setLatitude(location == null ? null : location.getLatitude());
    payCCPC.setLongitude(location == null ? null : location.getLongitude());
    payCCPC.setRmtAccNo(request.getRmtAccNo());
    payCCPC.setRmtBankName(request.getRmtBankName());
    payCCPC.setBnyAccNo(request.getBnyAccNo());
    payCCPC.setBnyAccName(request.getBnyAccName());
    payCCPC.setBnyBankName(request.getBnyBankName());
    payCCPC.setIsNeedBillInfo(
        request.getIsNeedBillInfo() == null ? false : request.getIsNeedBillInfo());
    payCCPC.setNotifyMobile(request.getNotifyMobile());
    payCCPC.setRmtElecsignStatus(
        isSaveRmtEsignSuccess ? Const.VLDSTATE_VALID : Const.VLDSTATE_INVALID);
    payCCPC.setBnyElecsignStatus(
        isSaveBnyEsignSuccess ? Const.VLDSTATE_VALID : Const.VLDSTATE_INVALID);
    payCCPC.setCnaps(request.getCnaps());
    payCCPC.setBnyAmt(request.getBnyAmt());
    payCCPC.setBnyRealAmt(request.getBnyAmt());
    payCCPC.setRemitStatus(CCPCConfig.REMIT_STATUS_CCPC_PROCESSING);
    payCCPC.setUsrLogin(mrchUsr.getUsrLogin());
    payCCPC.setRemark(request.getRemark());
    payCCPCService.addPayCCPC(payCCPC);
    // 对外付款
    payCCPC = remitProcess.pay(payCCPC);
    PayInfoResponse response = payCCPCToPayInfoResponse(payCCPC);
    return response;
  }