Micro-channel Order Tracking

Directly attached some small code logic is very simple query interface is not another blog post: https://www.cnblogs.com/yi1036943655/p/7211275.html

{
             // According to Merchant order number and find DB 
            OrderInfo orderInfo = orderInfoMapper.selectByOutTradeNo (outTradeNo); 
            logger.info ( "according to Merchant order number and find order data JSON:" + JSONObject.toJSONString (orderInfo));
             IF (! OrderInfo = null ) {
                 // check your order successfully
                 // determine order status 
                iF (1 == orderInfo.getPayStatus ()) {
                     // wait for proof of payment is not micro-channel callback we 
                    logger.info ( "order status: waiting for micro payment inquiry letter ends if payment success" );
                     // create a hashmap (Order Tracking) 
                    SortedMap <String, String> paraMap =new new the TreeMap <String, String> ();
                     // set the random string 
                    String nonceStr = UUID.randomUUID () toString () the replaceAll ( "-", ".". );
                     // set the request parameter (applet ID) 
                    paraMap .put ( "AppID" , AppID);
                     // set the request parameter (merchant number) 
                    paraMap.put ( "mch_id" , mch_id);
                     // set the request parameter (merchant order number) 
                    paraMap.put ( "out_trade_no" , outTradeNo) ;
                     // set request parameters (random string) 
                    paraMap.put ( "nonce_str" , nonceStr);
                    //Call logical arguments passed in accordance with the ASCII code field names from small to large (lexicographical) 
                    String stringA = formatUrlMap (paraMap, false , false );
                     // second step, in the final stitching key stringA get stringSignTemp string, and stringSignTemp MD5 operation performed, then the resulting character string is converted to uppercase all, to obtain sign value signValue. (Signed) 
                    String = Sign MD5Util.MD5 (stringA + "& Key =" + Key) .toUpperCase ();
                     // will prepare for the XML format 
                    StringBuffer paramBuffer = new new StringBuffer (); 
                    paramBuffer.append ( "<xml>" ); 
                    paramBuffer .append ( "<AppID>" AppID + + "</ AppID>" );"<mch_id>"+mch_id+"</mch_id>");
                    paramBuffer.append("<out_trade_no>"+paraMap.get("out_trade_no")+"</out_trade_no>");
                    paramBuffer.append("<nonce_str>"+paraMap.get("nonce_str")+"</nonce_str>");
                    paramBuffer.append("<sign>"+sign+"</sign>");
                    paramBuffer.append("</xml>");
                    new new
                        the Map <String, String> Map = doXMLParse (getRemotePortData (selectOrderUrl,send the request (POST) (obtained packet ID) (note that there is a place where if you do not transcoded to ISO8859-1 will tell you that even if your body is not UTF8 encoded into UTF8 encoding, too bad so so modified to ISO8859-1)//{
                        the tryString (paramBuffer.toString () getBytes (), "ISO8859-1." ))); 
                        Logger.info ( "micro query letter orders the interface returns the result in JSON format:" + JSONObject.toJSONString (the Map));
                         // Avoid null 
                        IF (Map =! null ) {
                             // determine success 
                            String as map.get the return_code = ( "the return_code" ); 
                            String RESULT_CODE = as map.get ( "RESULT_CODE" );
                             iF ( "sUCCESS" .equals (the return_code) && "sUCCESS" .equals (RESULT_CODE)) { 
                                logger.info ( "Query Interface Query successful micro-channel Order " );
                                = as map.get outTradeNo ( "out_trade_no" ); 
                                logger.info ( "micro-channel merchant server returns the order number" + outTradeNo); 
                                String the userId = sessionUserInfo.getUserId (); 
                                String tradeState = as map.get ( "trade_state" ); 
                                Logger. info ( "micro-channel Order status Back side:" + tradeState); 
                                String tradeStateDesc = as map.get ( "trade_state_desc" ); 
                                logger.info ( "micro-channel server returns Order status description:" + tradeStateDesc);
                                String payStatus = Null ; 
                            } 
                        } 
                    } the catch (Exception E) { 
                        logger.info ( "micro-channel Order query Exception:" + e.getMessage ()); 
                    } 
                } the else { 
                    logger.info ( "check orders, micro-channel over the interface has a callback state database has changed, the state is returned to the front end " ); 
                } 
            } 
        }

 

Guess you like

Origin www.cnblogs.com/yi1036943655/p/10979803.html