Browse Source

上级unoin

小么熊🐻 2 years ago
parent
commit
405d6fb94c

+ 3 - 1
nbjk-admin/src/main/java/com/miaxis/system/controller/system/SysLoginController.java

@@ -198,7 +198,7 @@ public class SysLoginController
      */
     @PostMapping("/login/jscode")
     @ApiOperation("小程序jscode登录")
-    public Response<TokenDTO> getInfo(String jscode){
+    public Response<TokenDTO> getInfo(String jscode,String pUnionId){
         String result = wxService.getWxInfo(xcxAppid, xcxAppSecret, jscode,"authorization_code");
         JSONObject jsonString = JSONObject.parseObject(result);
         WxResult wxResult = JSONObject.toJavaObject(jsonString, WxResult.class);
@@ -212,6 +212,8 @@ public class SysLoginController
             ServletUtils.getRequest().setAttribute("nickName",wxUserInfo.getNickname());
             ServletUtils.getRequest().setAttribute("openid",wxUserInfo.getOpenid());
             ServletUtils.getRequest().setAttribute("xcxOpenid",wxUserInfo.getOpenid());
+            ServletUtils.getRequest().setAttribute("xcxOpenid",wxUserInfo.getOpenid());
+            ServletUtils.getRequest().setAttribute("pUnionId",pUnionId);
             String token = loginService.login(wxUserInfo.getUnionid(),null, StudentLoginTypeEnum.AUTHORIZATION_XCX_LOGIN.getCode());
             tokenDTO.setToken(token);
             tokenDTO.setThirdResult(wxUserInfo);

+ 6 - 0
nbjk-common/src/main/java/com/miaxis/common/core/domain/entity/UserInfo.java

@@ -89,5 +89,11 @@ public class UserInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "联合id")
     private String unionId;
 
+    /** 微信开放平台 */
+    @Excel(name = "上级联合id")
+    @TableField("p_union_id")
+    @ApiModelProperty(value = "上级联合id")
+    private String pUnionId;
+
 
 }

+ 2 - 0
nbjk-framework/src/main/java/com/miaxis/framework/web/service/UserDetailsServiceImpl.java

@@ -117,6 +117,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
             {
                 UserInfo userInfoGetByUnionId = userService.getStudentByUnionId(identification);
                 String openid = (String)ServletUtils.getRequest().getAttribute("openid");
+                String pUnionId = (String)ServletUtils.getRequest().getAttribute("pUnionId");
                 UserInfo userInfoGetByOpenId = userService.getStudentByOpenId(openid);
                 if (userInfoGetByUnionId == null ) {
                     UserInfo userInfo = new UserInfo();
@@ -125,6 +126,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
                     userInfo.setXcxOpenid(openid);
                     userInfo.setUnionId(identification);
                     userInfo.setIsVip(0);
+                    userInfo.setPUnionId(pUnionId);
                     userService.saveUserInfo(userInfo);
                     return createLoginUser(userService.getStudentByUnionId(identification),"XCX");
                 }else {

+ 1 - 1
nbjk-service/src/main/java/com/miaxis/wx/service/impl/WxGzhServiceImpl.java

@@ -108,7 +108,7 @@ public class WxGzhServiceImpl implements IWxGzhService {
         try {
             log.info("1....");
             cn.hutool.json.JSONObject decryptMap = XML.toJSONObject(IOUtils.toString(request.getInputStream()));
-            cn.hutool.json.JSONObject jsonObjectData = decryptMap.getJSONObject("xml");
+            cn.hutool.json.JSONObject jsonObjectData = decryptMap.getJSONObject("xml");  //解析XML
 
 //            cn.hutool.json.JSONObject jsonObjectData = new cn.hutool.json.JSONObject("{\"CreateTime\":1666169539,\"ToUserName\":\"gh_8e0c71ce615b\",\"MsgType\":\"text\",\"MsgId\":23853813438069304,\"Content\":\"a12345\",\"FromUserName\":\"o_DwY68a6UHmFhmovdFB0gANaC_U\"}");
             log.info("2-----jsonObjectData------"+jsonObjectData);

+ 2 - 2
nbjk-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -113,8 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where name = #{name}
 	</select>
 	<insert id="saveUserInfo" parameterType="com.miaxis.common.core.domain.entity.UserInfo" >
-		insert into user_info (head_image,nick_name,xcx_openid,app_openid,union_id,gzh_openid)
-		values (#{headImage},#{nickName},#{xcxOpenid},#{appOpenid},#{unionId},#{gzhOpenid})
+		insert into user_info (head_image,nick_name,xcx_openid,app_openid,union_id,gzh_openid,p_union_id)
+		values (#{headImage},#{nickName},#{xcxOpenid},#{appOpenid},#{unionId},#{gzhOpenid},#{pUnionId})
 	</insert>
 
 	<select id="getAgentList" resultType="com.miaxis.common.core.domain.vo.AgentVO">