//异步请求回应微信支付是否成功 @Transactional public String weixinNotify(String resultStr) { log.info("=========weixinPaynotify start===="); String resXml = ""; String return_code=null; String result_code=null; try { //字节流 Map<String, String> resultMap = XMLUtil.doXMLParse(resultStr); log.info("resultMap:" + JSON.toJSONString(resultMap)); String transaction_id = resultMap.get("transaction_id"); //微信交易流水号 result_code = resultMap.get("result_code"); String out_trade_no = resultMap.get("out_trade_no"); return_code = resultMap.get("return_code"); log.info("===========================微信异步回调 来了========================"+out_trade_no); // 签名验证(在网上复制而来,不知其用处故先注释) //GenericValue userLogin = delegator.findOne("UserLogin", UtilMisc.toMap("userLoginId", "admin"), false); //支付成功 修改订单状态和子订单状态 添加充电结束时间 if ("SUCCESS".equals(return_code)&&"SUCCESS".equals(result_code)) { log.info("小程序订单列表支付回调接收到了out_trade_no=========="+out_trade_no); //获取主订单 WxRechargeOrderExample wxRechargeOrderExample = new WxRechargeOrderExample(); wxRechargeOrderExample.createCriteria().andOrderNumberEqualTo(out_trade_no); WxRechargeOrder wxRechargeOrder = wxRechargeOrderMapper.selectByExample(wxRechargeOrderExample).get(0); wxRechargeOrder.setStatus(1); wxRechargeOrder.setUpdateDate(new Date()); int i = wxRechargeOrderMapper.updateByPrimaryKey(wxRechargeOrder); if( 1 == i){ //修改用户账户 WxMember wxMember = wxMemberMapper.selectByPrimaryKey(wxRechargeOrder.getMemberId()); BigDecimal addFudou = wxRechargeOrder.getFudou(); wxMember.setFudou(wxMember.getFudou().add(addFudou)); wxMember.setAmount(wxMember.getAmount().add(wxRechargeOrder.getAmount())); wxMember.setUpdateDate(new Date()); wxMemberMapper.updateByPrimaryKey(wxMember); resXml = "<xml>" + "<return_code><![CDATA[SUCCESS]]></return_code>" + "<return_msg><![CDATA[OK]]></return_msg>" + "</xml> "; } }else{ resXml = "<xml>" + "<return_code><![CDATA[FAIL]]></return_code>" + "<return_msg><![CDATA[报文为空]]></return_msg>" + "</xml> "; } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JDOMException e) { e.printStackTrace(); } catch (Exception e){ e.printStackTrace(); throw new RuntimeException("微信异步回调失败!"); } return resXml; //return return_code; }
备注:有的直接返回SUCCESS就可以,有的要返回xml,具体按项目
转载于:https://my.oschina.net/u/3559695/blog/3089943
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/39291.html