@Override
  @Transactional
  public OrderPayment genOrderPayment(Long buyerId, Long masterOrderId) {

    OrderMasterDTO master = orderService.loadOrderMasterDTO(masterOrderId);
    if (master != null
        && master.getBuyerId().longValue() == buyerId.longValue()
        && master.getPaymentType().intValue() == OrderConstants.PaymentType.ONLINE_PAY.getValue()) {
      if (master.getStatus().intValue() == OrderConstants.OrderMasterStatus.WAIT_PAY.getValue()) {
        OrderPayment query = new OrderPayment();
        query.setMasterOrderId(master.getId());
        query.setBuyerId(buyerId);
        OrderPayment payment = dao.selectOne(query);
        if (payment != null) {
          if (payment.getPayStatus().intValue() == OrderConstants.PaymentStatus.PAYED.getValue()) {
            throw new BizException("order.payment.has.payed");
          }
        } else {
          payment = new OrderPayment();
          payment.setId(null);
          payment.setPayNo("P" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmssSSS"));
          payment.setMasterOrderId(master.getId());
          payment.setMasterOrderNo(master.getMasterOrderNo());
          payment.setTradeNo("");
          payment.setNeedPayAmount(master.getNeedPayAmount());
          payment.setPayedAmount(null);
          payment.setRefundAmount(null);
          payment.setPayStatus(OrderConstants.PaymentStatus.WAITING_PAY.getValue());
          payment.setPaymentType(master.getPaymentType());
          payment.setPayMethod(null);
          //			    payment.setAccountType(accountType);
          //			    payment.setAccountName(accountName);
          //			    payment.setBankCode(bankCode);
          //			    payment.setAccountNo(accountNo);
          payment.setSubmitTime(new Date());
          payment.setPayedTime(null);
          //			    payment.setpayeeId;
          //			    payment.setpayeeName;
          //			    payment.setpayeeTime;
          payment.setBuyerId(buyerId);
          dao.insert(payment);
        }
        return payment;
      } else {
        throw new BizException("order.payment.status.invalid");
      }
    } else {
      throw new BizException("order.payment.parameter.invalid");
    }
  }
 @Override
 public WXPrepayOrder genWxPrepayOrder(Long orderPaymentId) {
   OrderPayment payment = dao.selectById(orderPaymentId);
   if (payment == null) {
     throw new BizException("payment.order.not.exist");
   }
   return null;
 }