|
|
@@ -27,6 +27,7 @@ import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
+import com.zhongzheng.modules.order.domain.Order;
|
|
|
import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
import com.zhongzheng.modules.user.bo.UserWxFollowAddBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
@@ -1206,7 +1207,6 @@ public class WxLoginService implements IWxLoginService {
|
|
|
initData();
|
|
|
String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());
|
|
|
String resultString = HttpUtils.sendGet(gzh_wxAuthUrl, param);
|
|
|
- System.out.println(resultString);
|
|
|
//解析json
|
|
|
JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
|
|
|
String access_token = String.valueOf(jsonObject.get("access_token"));
|
|
|
@@ -1232,6 +1232,36 @@ public class WxLoginService implements IWxLoginService {
|
|
|
return user;
|
|
|
}
|
|
|
|
|
|
+ //公众号获取用户信息
|
|
|
+ public User bindWxGzhUnionIdUser(WxLoginBody loginBody) {
|
|
|
+ initData();
|
|
|
+ String param = String.format(gzh_wxAuthParam, gzh_appid, gzh_appsrcret, loginBody.getCode());
|
|
|
+ String resultString = HttpUtils.sendGet(gzh_wxAuthUrl, param);
|
|
|
+ //解析json
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.parse(resultString);
|
|
|
+ String access_token = String.valueOf(jsonObject.get("access_token"));
|
|
|
+ if(access_token.equals("null")){
|
|
|
+ throw new CustomException( String.valueOf(jsonObject.get("errmsg")));
|
|
|
+ }
|
|
|
+ String openId = String.valueOf(jsonObject.get("openid"));
|
|
|
+
|
|
|
+ String userInfoParam = String.format(gzh_wxUserInfoParam, access_token, openId);
|
|
|
+ String userInfoResultString = HttpUtils.sendGet(gzh_wxUserInfoUrl, userInfoParam);
|
|
|
+
|
|
|
+ //解析json
|
|
|
+ JSONObject jsonObject1 = (JSONObject) JSONObject.parse(userInfoResultString);
|
|
|
+ String unionId = String.valueOf(jsonObject1.get("unionid"));
|
|
|
+ User user = iUserService.getOne(new LambdaQueryWrapper<User>().eq(User::getUserId,loginBody.getUserId()));
|
|
|
+ if (user == null) {
|
|
|
+ throw new CustomException("您尚未注册,请前往小程序注册");
|
|
|
+ }
|
|
|
+ if (!Validator.isNotNull(user.getGzhOpenId())) {
|
|
|
+ user.setGzhOpenId(openId);
|
|
|
+ iUserService.updateById(user);
|
|
|
+ }
|
|
|
+ return user;
|
|
|
+ }
|
|
|
+
|
|
|
public String obtainWxPhone(String iv, String encryptedData, String session_key) {
|
|
|
String userInfo = null;
|
|
|
JSONObject userInfoJSON = null;
|