wechat

拦截器

package com.ahies.ija.management.configer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ahies.ija.management.aoplog.RequireWechatOauth;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import java.lang.reflect.Method;


/**
 * 微信获取用户信息的拦截器
 * 
 * 
 * @author pc
 *
 */
@Component
@Aspect
public class WeiXinInterceptor {
	
	@Before("@annotation(com.ahies.ija.management.aoplog.RequireWechatOauth)")// 拦截被TestAnnotation注解的方法;如果你需要拦截指定package指定规则名称的方法,可以使用表达式execution(...),具体百度一下资料一大堆
	public void beforeTest(JoinPoint point ) throws Throwable {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
		HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse();
		// all http://localhost:8080/deptmeeting/meet/byhall/1
		String allurl = request.getRequestURL().toString();
		// url /deptmeeting/meet/byhall/1
		String url = request.getRequestURI();
		// System.out.println(allurl);
		// System.out.println(url);
		// false 没有手机号和微信用户的openid
		// /deptmeeting
		String contenpath = request.getContextPath();

		// System.out.println(contenpath);
		url = url.replace(contenpath, "");
		String appid = "wx10aa64b285851297";
		String redirect_uri = "";
		String state = url;
		redirect_uri = allurl.replace(url, "");
		String authURL = "/weixinoauth/oauth";
		redirect_uri = redirect_uri+authURL;
		// System.out.println(url);
//		https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${meePlatPath}/wechatOAuth_oauth.shtml&response_type=code&scope=snsapi_userinfo&state=login#wechat_redirect
		// response.sendRedirect("http://blog.csdn.net/kepoon/article/details/53024841?locationNum=9&fps=1");
		String redirectURL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="
				+appid+ "&redirect_uri="+redirect_uri+"&response_type=code&scope=snsapi_userinfo&state="+state+"#wechat_redirect";
		response.sendRedirect(redirectURL);
	}

	@After("@annotation(com.ahies.ija.management.aoplog.RequireWechatOauth)")
	public void afterTest(JoinPoint point ) {

	}
}

注解

package com.ahies.ija.management.aoplog;

import java.lang.annotation.*;

/**
 * @Description TODO
 * @Date 2019/3/8 11:43
 * @Author zsj
 */
@Documented
@Target({ElementType.METHOD,ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequireWechatOauth {
}

请求

package com.ahies.ija.management.controller;

import cn.hutool.core.map.MapUtil;
import com.ahies.cloud.common.response.ResponseUtill;
import com.ahies.ija.management.aoplog.ControllerLog;
import com.ahies.ija.management.aoplog.OperateModule;
import com.ahies.ija.management.aoplog.RequireWechatOauth;
import com.ahies.ija.management.model.AppointmentBind;
import com.ahies.ija.management.model.AppointmentManagement;
import com.ahies.ija.management.model.SubscribeManagement;
import com.ahies.ija.management.service.AppointmentManagementService;
import com.ahies.ija.management.service.SubscribeManagementService;
import com.ahies.ija.management.service.UserService;
import com.ahies.ija.management.service.WxService;
import com.ahies.ija.management.util.DateUtil;
import com.ahies.system.common.response.ResponseMap;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;


@RestController
@RequestMapping("/wxSelfhelp")
public class WxController {



    /**
     *
     *
     */
    @RequireWechatOauth
    @RequestMapping("/getWechatInfo")
    public Map<String, Object> getWechatInfo()  {
        return new HashMap<>();

    }

  
    @RequestMapping("/getWechat")
    public Map<String, Object> getWechat()  {
        return new HashMap<>();

    }



}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Python 微信支付 wechatsdk 是一个用于处理微信支付功能的 Python 第三方库。它提供了一系列的接口和方法,用于实现微信支付交易的各种功能,包括创建订单、查询订单状态、申请退款等。 使用 wechatsdk,我们可以方便地集成微信支付功能到 Python 项目中。首先,我们需要通过在微信商户平台上注册账号,并获得相应的密钥和证书文件。然后,在 Python 项目中引入 wechatsdk 库,并根据接口文档的要求设置好相关的配置参数,例如商户 ID、商户密钥等。 接下来,我们可以使用 wechatsdk 提供的接口进行各种支付交易操作。例如,创建订单时我们可以使用统一下单接口,传入必要的参数例如商品描述、订单金额等。wechatsdk 会自动将收到的参数进行签名,并生成一个支付链接。用户在微信客户端打开支付链接后,可以进行支付操作。 支付成功后,wechatsdk 提供了查询订单接口,用于查询订单的支付状态。根据订单号或其他标识,我们可以向微信服务器发起查询请求,获取订单的详细信息,例如支付状态、支付金额等。 退款功能也可以通过 wechatsdk 来实现。我们可以使用申请退款接口传入相应的参数,并进行退款操作。微信服务器会根据退款申请的参数进行处理,并返回相应的结果。 总之,Python 微信支付 wechatsdk 是一个方便易用的库,可以帮助开发者快速集成微信支付功能到他们的 Python 项目中。无论是处理支付交易、查询订单状态还是申请退款,都可以借助 wechatsdk 轻松实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

非ban必选

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值