コード例 #1
0
 @Action(
     value = "savePayment",
     results = {
       @Result(
           name = "success",
           location = "spPayment",
           type = "redirectAction",
           params = {"model.id", "${id}"}),
       @Result(name = "input", type = "tiles", location = "/payment.tiles")
     })
 public String save() {
   if (payment != null && payment.hashCode() != paymentHash) {
     if (doctorID != null && doctorID.equals("")) {
       addFieldError("doctorID", Messages.getString("DoctorSessionAction.CheckDoctor"));
       return INPUT;
     }
     if (!payment.getPaymentMethod().equals(PaymentMethod.MONEY_BACK) && payment.getValue() <= 0) {
       addFieldError("value", Messages.getString("PaymentAction.WrongValue"));
       return INPUT;
     }
     if (Messages.getCustomer("customer").trim().equals(Customer.degfim.toString().trim())
         && getDoctors() != null) {
       if (!payment.getPaymentMethod().equals(PaymentMethod.MONEY_BACK)) {
         if (payment.getValue() > checkVal()) {
           addFieldError("value", "Мөнгөн дүн " + checkVal() + " -аас дээш байж болохгүй");
           return INPUT;
         }
       } else {
         if (payment.getValue() > getDoctorSessionValue()) {
           addFieldError(
               "value", "Мөнгөн дүн " + getDoctorSessionValue() + " -аас дээш байж болохгүй");
           return INPUT;
         }
       }
     }
     if (numberService.findAll().size() == 0)
       numberService.saveOrUpdate(new PaymentNumberCounter());
     PaymentMethod method = payment.getPaymentMethod();
     List<Patient> patientList = patientService.searchById(id);
     payment.setPatient(patientList.get(0));
     if (method.equals(PaymentMethod.MONEY_BACK) && payment.getValue() > 0) {
       payment.setValue(payment.getValue() * (-1));
     }
     if (doctorID != null) payment.setDoctor(doctorService.get(Long.parseLong(doctorID)));
     payment.setPaymentNumber(numberService.getNextPaymentNumber(method));
     payment.setId(null);
     paymentService.saveOrUpdate(payment);
     ssm.logInfo(payment);
     return SUCCESS;
   }
   return INPUT;
 }
コード例 #2
0
 @Action(
     value = "editPayment",
     results = {
       @Result(
           name = "success",
           location = "spPaymentEdit",
           type = "redirectAction",
           params = {"model.id", "${id,patient.id}"}),
       @Result(name = "input", type = "tiles", location = "/paymentEdit.tiles")
     })
 public String edit() {
   if (payment != null && payment.hashCode() != paymentHash) {
     PaymentMethod method = payment.getPaymentMethod();
     List<Patient> paymentList = patientService.searchById(payment.getPatient().getId());
     payment.setPatient(paymentList.get(0));
     payment.setPaymentNumber(numberService.getNextPaymentNumber(method));
     paymentService.update(payment);
     ssm.logInfo(payment);
     return SUCCESS;
   }
   return INPUT;
 }