|
@@ -3,8 +3,10 @@ package com.supplier.controller;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.supplier.jwt.JWTUtil;
|
|
|
+import com.supplier.model.Supplier;
|
|
|
import com.supplier.model.User;
|
|
|
import com.supplier.service.PersonalServce;
|
|
|
+import com.supplier.util.ParsingToken;
|
|
|
import com.supplier.vx.WxLogin;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.http.HttpStatus;
|
|
@@ -100,6 +102,43 @@ public class WXLoginController {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 供应商绑定微信
|
|
|
+ * @param code 参数
|
|
|
+ * @param request 参数
|
|
|
+ * @return 返回结果
|
|
|
+ */
|
|
|
+ @RequestMapping("/notify/codeSupplier")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> codeSupplier(String code, HttpServletRequest request) {
|
|
|
+ //获取回调地址中的code
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ try{
|
|
|
+ Map<String, Object> wxMap = wxLogin(code); //微信回调数据
|
|
|
+ //调用成功
|
|
|
+ if(wxMap.get("msg") == "200"){
|
|
|
+ JSONObject jsonObject1 = (JSONObject) wxMap.get("data");
|
|
|
+ //获取token
|
|
|
+ Map<String, Object> userMap = ParsingToken.tokenParsing(request);
|
|
|
+ Supplier supplier = new Supplier()
|
|
|
+ .setWxid(jsonObject1.getString("unionid"))
|
|
|
+ .setWxtoken((String) wxMap.get("accesstoken"))
|
|
|
+ .setWxRefreshToken((String) wxMap.get("refreshtoken"))
|
|
|
+ .setWxOpenid((String) wxMap.get("openId"))
|
|
|
+ .setCode((String) userMap.get("code"));
|
|
|
+ personalServce.updatePhone(supplier);//给指定供应商添加微信标识
|
|
|
+ map.put("msg", "200");
|
|
|
+ } else { //失败
|
|
|
+ return wxMap;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ map.put("msg", "500");
|
|
|
+ map.put("errMsg", "微信登录异常");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 用户编号
|
|
|
* @param id
|