![f1319ec8ec4c5cfdc7a6ae7b3406f30f.png](https://i-blog.csdnimg.cn/blog_migrate/d94f6c643d7b3b9a58ad0997f9a3cacb.png)
package com.fh.controller.wxlogin;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.security.AlgorithmParameters;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.spec.InvalidParameterSpecException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Resource;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fh.controller.base.BaseController;
import com.fh.controller.common.Base64Util;
import com.fh.controller.common.HttpRequest;
import com.fh.entity.system.WxUser;
import com.fh.service.wxlogin.WxuserService;
import com.fh.util.AppUtil;
import com.fh.util.Const;
import com.fh.util.DateUtil;
import com.fh.util.PageData;
import com.fh.util.wxPayUtils.WxPayConfig;
import net.sf.json.JSONObject;
@Controller
@RequestMapping(value="/wxuser")
public class WxLogin extends BaseController{
@Resource(name="wxuserService")
private WxuserService wxuserService;
@RequestMapping(value="/login",method = RequestMethod.POST)
@ResponseBody
public Object doLogin(Model model,
@RequestParam(value = "code",required = false) String code,
@RequestParam(value = "user_info",required = false) String rawData,
@RequestParam(value = "encrypted_data",required = false) String encrypteData,
@RequestParam(value = "iv",required = false) String iv,
@RequestParam(value = "signature",required = false) String signature
) {
System.out.println("进入");
Map map = new HashMap();
if(code.equals("")||code==null) {
map.put("errmsg","code为空!");
return map;
}if(rawData.equals("")||rawData==null) {
map.put("errmsg","rawData为空!");
return map;
}
if(encrypteData.equals("")||encrypteData==null) {
map.put("errmsg","encrypteData为空!");
return map;
}
if(iv.equals("")||iv==null) {
map.put("errmsg","iv为空!");
return map;
}
if(signature.equals("")||signature==null) {
map.put("errmsg","signature为空!");
return map;
}
/*
* JsonOb