package com.qhyf.app.bl.controller; import club.newepoch.persistent.db.common.Db; import club.newepoch.persistent.db.exception.ActiveRecordException; import club.newepoch.utils.StringUtils; import java.util.ArrayList; import java.util.LinkedHashSet; import org.plutext.jaxb.xslfo.StartingStateType; import com.jfinal.core.ActionKey; import com.jfinal.core.action.Rest; import com.jfinal.core.pojo.RestMethod; import com.mysql.fabric.xmlrpc.base.Array; import com.qhyf.app.bl.base.controller.QhyfController; importnet.sf.json.JSONArray; Import net.sf.json.JSONObject; / ** * notify the customer to fill out the account number to confirm Interface * @author LX * / public class InterfaceAffirmAccountController the extends QhyfController { @Rest (Method = RestMethod.POST) @ ActionKey ( "/ API / qhyf / Confirm / Account /" ) public void affirmAccount () throws ActiveRecordException { // return data json the JSONObject returnJson = new new the JSONObject (); the JSONArray data = new newJSONArray (); // Data Verification successfully identify boolean checkFlag = to true ; // store the error message StringBuffer errmsgSb = new new StringBuffer (); // store The errcode StringBuffer errcodeSb = new new StringBuffer (); the try { // get payment confirmation number String = payCode the this .getPara ( "pay_code" ); // Get out of account complement reasons String reason = the this .getPara ( "reason" ); IF (StringUtils.isBlank (reason)) { errmsgSb.append ("Fill out the account reason can not be empty;" ); // missing parameters errcodeSb.append ( "3001 ,;" ); // returnJson.put ( "The errcode", errcodeSb.append ( "3001;")); checkFlag = to false ; } IF (StringUtils.isBlank (payCode)) { errmsgSb.append ( "payment confirmation number can not be empty;" ); // missing parameters errcodeSb.append ( "3001 ,;" ); // returnJson.put ( "The errcode",); checkFlag = to false ; } payment confirmation number is not empty, detect the presence in the DB// IF (StringUtils.notBlank (payCode)) { String SQL = "uuid from biz_pay_comfirm_info the SELECT and the WHERE pay_id sys_status = 1 =?" ; // get uuid String uuid = Db.queryStr (SQL, payCode); IF (StringUtils. isBlank (uuid)) { // If uuid is empty, then errmsgSb.append ( "payment confirmation number does not exist;" ); // missing argument errcodeSb.append ( "4001" ); // returnJson.put ( "the errcode" , errcodeSb.append ( "4001")) ; checkFlag = false ; } } // variables stored error code is not empty IF (errcodeSb.length ()> 0 ) { the StringBuffer The errcode = clearRepetition (errcodeSb); // add to the data returned to json returnJson.put ( "errcode " , errcode.toString ()); } // check by IF (checkFlag) { // business logic returnJson.put ( " The errcode "," 0 " ); returnJson.put ( " ErrMsg "," " ); } else { // check does not pass through returnJson.put ( "ErrMsg" , errmsgSb.toString ()); } returnJson.put ( "Data" , Data); } the catch (Exception E) { // exception handling returnJson.put ( "errcode "," 9999 " ); returnJson.put ( " ErrMsg "," internal service handling exceptions! " ); returnJson.put ( " Data " , Data); } // return result the this .renderJson (returnJson); } / ** * remove duplicate error code * @param errcodeSb * @return * / Public the StringBuffer clearRepetition (the StringBuffer errcodeSb) { // definition of error code stored in the temporary variable the ArrayList <String> List = new new the ArrayList <String> (); // the StringBuffer turn a string array String [] strArray = errcodeSb.toString () .split ( ";" ); // traverse the list of error messages, the deduplication the errcode for (String STR: strArray) { // the error message into a collection List.add (STR); } // remove duplicate set inside The errcode a LinkedHashSet <String> SET = new new a LinkedHashSet <String> (list.size ()); set.addAll (List); list.clear (); list.addAll (SET); // List Object set transfected array Object [] = errcodes List.toArray (); the StringBuffer The errcode = new new the StringBuffer (); // iterate and the StringBuffer go for (ER Object: errcodes) { errcode.append (ER); } // Get errcode stored inside the last character .. String laString = errcode.toString () substring (errcode.toString () length ( ) --1 ); // If the last character is "", then remove the IF ( "" .equals (laString)) { errcode.deleteCharAt (errcode.length () -. 1 ); } return errcode; } }
Notify the customer to fill out the account confirmed Interface