Пример #1
0
 private ResultModel<Object> validatePayment(PaymentsModel payment) {
   ResultModel<Object> result = new ResultModel<Object>();
   if (StringUtil.isEmpty(payment.getOutTradeNo())) {
     result.setMsg("商户订单号不能为空");
     result.setCode(ResultCons.FAIL);
   } else if (payment.getTradeFee() == null) {
     result.setMsg("订单金额不能为空");
     result.setCode(ResultCons.FAIL);
   } else if (payment.getTradeFee() <= 0) {
     result.setMsg("订单金额不能小于0");
     result.setCode(ResultCons.FAIL);
   } else {
     result.setMsg(ResultCons.SUCCESS_MSG);
     result.setCode(ResultCons.SUCCESS);
   }
   // 金额转成分
   Double tradeFee = payment.getTradeFee();
   payment.setTradeFee(tradeFee * 100);
   // 超时支付
   String overtime = payment.getOvertime();
   if (StringUtil.isNotEmpty(overtime)) {
     Calendar currentTime = Calendar.getInstance();
     currentTime.add(Calendar.MINUTE, Integer.parseInt(overtime));
     String _overtime = DateUtil.fmtDateToStr(currentTime.getTime(), "yyyyMMddHHmmss");
     payment.setOvertime(_overtime);
   } else {
     Calendar currentTime = Calendar.getInstance();
     currentTime.add(Calendar.DATE, 30);
     String _overtime = DateUtil.fmtDateToStr(currentTime.getTime(), "yyyyMMddHHmmss");
     payment.setOvertime(_overtime);
   }
   if (StringUtil.isEmpty(payment.getBody())) {
     payment.setBody("银联渠道");
   }
   return result;
 }
Пример #2
0
 /**
  * 支付参数校验
  *
  * @param payment 支付对象
  * @return result
  */
 public static ResultModel<Object> validatePayment(PaymentsModel payment) {
   ResultModel<Object> result = new ResultModel<Object>();
   if (StringUtil.isEmpty(payment.getOutTradeNo())) {
     result.setMsg("商户订单号不能为空");
     result.setCode(ResultCons.FAIL);
   } else if (payment.getTradeFee() == null) {
     result.setMsg("订单金额不能为空");
     result.setCode(ResultCons.FAIL);
   } else if (payment.getTradeFee() <= 0) {
     result.setMsg("订单金额不能小于0");
     result.setCode(ResultCons.FAIL);
   } else {
     result.setMsg(ResultCons.SUCCESS_MSG);
     result.setCode(ResultCons.SUCCESS);
   }
   String body = payment.getBody();
   if (StringUtil.isNotEmpty(body) && body.length() > 20) {
     body = body.substring(0, 20).concat("...");
     payment.setBody(body);
   }
   String overTime = payment.getOvertime();
   if (StringUtil.isEmpty(overTime)) {
     if (payment.getChannel() == Channel.ALIPAY_WAP.getCode()) {
       payment.setOvertime(AlipayConfig.pay_expire);
     } else {
       payment.setOvertime(AlipayConfig.it_b_pay);
     }
   } else {
     if (payment.getChannel() == Channel.ALIPAY_WAP.getCode()) {
       payment.setOvertime(overTime);
     } else {
       payment.setOvertime(overTime.concat("m"));
     }
   }
   return result;
 }