package com.sptg.gateway.controller;

import java.io.IOException;
import java.util.*;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.github.tobato.fastdfs.domain.StorePath;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.common.core.constant.HttpConstant;
import com.sptg.common.core.constant.SysLogConstant;
import com.sptg.common.core.util.Base64DecodeMultipartFileUtils;
import com.sptg.common.core.util.CookieUtils;
import com.sptg.common.core.util.WebUtils;
import com.sptg.estate.api.dto.ApplyUserDto;
import com.sptg.estate.api.entity.MemberAndUser;
import com.sptg.estate.api.feigns.ApplyUserFeign;
import com.sptg.estate.api.feigns.MemberAndUserFeign;
import com.sptg.gateway.entity.AccessToKenDto;
import com.sptg.gateway.entity.DataDto;
import com.sptg.gateway.util.JwtUtil;
import com.sptg.permissions.api.dto.AccountOauthDto;
import com.sptg.permissions.api.dto.LoginDto;
import com.sptg.permissions.api.entity.*;
import com.sptg.permissions.api.feigns.*;
import com.sptg.permissions.api.thirdauth.constants.CtwingAuthConstants;
import com.sptg.permissions.api.thirdauth.request.AuthCtwingRequest;
import com.sptg.permissions.api.thirdauth.util.ByteFormat;
import com.sptg.permissions.api.thirdauth.util.XXTeaUtil;
import com.sptg.statistics.api.entity.SysOperationLog;
import com.xkcoding.http.util.MapUtil;
import me.zhyd.oauth.model.AuthToken;
import me.zhyd.oauth.model.AuthUser;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.common.core.util.JsonUtils;
import com.sptg.estate.api.dto.MemberDto;
import com.sptg.estate.api.entity.Member;
import com.sptg.estate.api.feigns.MemberFeign;
import com.sptg.gateway.util.DataCheck;
import com.sptg.gateway.util.PojoToApi;
import com.sptg.statistics.api.entity.AppMemberLoginRecords;
import com.sptg.statistics.api.feigns.AppMemberLoginRecordsFeign;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import static com.sptg.permissions.api.thirdauth.util.AuthRequestUtil.getAuthRequest;

/**
 * title: MimiProgramController
 * package: com.sptg.gateway.controller
 * description: 小程序接口控制类
 *
 *
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/app/miniprogram")
public class MimiProgramController {

    private final RestTemplate restTemplate;
    private final OrgFeign orgFeign;
    private final MemberFeign memberFeign;
    private final RedisTemplate<String,String> redisTemplate;
    private final AppMemberLoginRecordsFeign appMemberLoginRecordsFeign;
    private final WeiXinConfFeign weiXinConfFeign;
    private final ApiDockingConfFeign apiDockingConfFeign;
    private final MemberAndUserFeign memberAndUserFeign;
    private final FastFileStorageClient fastFileStorageClient;
    private final ConfFeign confFeign;
    private final JwtUtil jwtUtil;
    /**
     * 短信缓存名称
     */
    private final static String VERIFICATION_CODE = "verification:code";

    /**
     * 自动生成二维码请求路径
     */
    private String GENERATE_CODE_URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit";

    /**
     * 功能描述: 获取微信小程序openid
     * @param map {
     *            js_code : 微信小程序端获取的js_code，时效5分钟,
     *            org_id  : 机构授权org_id，机构id
     *            token   : 对接令牌
     *            }
     * @return ResultBean<hashMap> 返回结果
     *
     *
     */
    @PostMapping(value = "/getOpenid")
    public Map<String,Object> getOpenid(@RequestBody Map<String,String> map){
        log.warn("============================小程序获取微信openid(/app/miniprogram/getOpenid)请求数据==============================");
        log.warn(JsonUtils.objectToJson(map));
        Map<String,Object> hashMap = new HashMap<>();
        //result_code:0-失败  1-成功
        hashMap.put("result_code", 0);
        hashMap.put("result_msg", "openid获取失败");
        try{
            String js_code = map.get("js_code");
            String org_id = map.get("org_id");
            String token = map.get("token");
            String name = map.get("name");
            if(DataCheck.checkOrgId(hashMap, org_id, orgFeign)) {
                return hashMap;
            }
            if(DataCheck.checkToken(hashMap, org_id, token,apiDockingConfFeign)){
                return hashMap;
            }
            if(StringUtils.isBlank(js_code)){
                hashMap.put("result_msg", "js_code不能为空");
                return hashMap;
            }
//            WeiXinConf conf = this.weiXinConfFeign.selectEntityById(Long.valueOf(org_id));
            WeiXinConf weiXinConf = new WeiXinConf();
            weiXinConf.setOrgId(Long.valueOf(org_id));
            weiXinConf.setName(name);
            WeiXinConf conf = this.weiXinConfFeign.selectEntityByOrgIdAndName(weiXinConf);
            if(conf == null){
                hashMap.put("result_msg", "机构未配置微信参数，请联系管理员");
                return hashMap;
            }
            //获取openid的微信接口
            String wxURI = "https://api.weixin.qq.com/sns/jscode2session?appid="+conf.getMiniAppID()+"&secret="+conf.getMiniAppSecret()+"&grant_type=authorization_code";
            wxURI = wxURI+"&js_code="+js_code;
            ResponseEntity<String> responseEntity = restTemplate.getForEntity(wxURI, String.class);
            //返回正常
            if(responseEntity.getStatusCodeValue()==200){
                String body = responseEntity.getBody();
                System.out.println(body);
                Map<String,String> result = JsonUtils.jsonToPojo(body, Map.class);
                String openid = result.get("openid");
                String session_key = result.get("session_key");
                if(StringUtils.isNotBlank(openid)&&StringUtils.isNotBlank(session_key)){
                    hashMap.put("result_code", 1);
                    hashMap.put("result_msg", "openid和sessionKey获取成功");
                    hashMap.put("openid", result.get("openid"));
                    hashMap.put("session_key",result.get("session_key"));
                    hashMap.put("appletType", conf.getAppletType());
                }else{
                    log.warn("从微信接口获取openid失败:"+body);
                }
            }else{
                hashMap.put("result_msg", "从微信接口获取openid失败");
                log.warn("从微信接口获取openid失败:"+responseEntity.getStatusCodeValue()+":"+responseEntity.getStatusCode());
            }
        }catch (Exception e){
            log.error("异常", e);
            hashMap.put("result_msg", "后台程序异常");
        }
        return hashMap;
    }

    /**
     * 功能描述: 通过openid获取会员信息
     * @param map {
     *            openid    :   微信小程序账号下的微信账号唯一标识,
     *            org_id    :   机构授权org_id，机构id
     *            token     :   对接令牌
     *            }
     * @return ResultBean<hashMap> 返回结果
     *
     *
     */
    @PostMapping(value = "/getMemberByOpenid")
    public Map<String,Object> getMemberByOpenid(@RequestBody Map<String,String> map){
        log.warn("============================小程序通过微信openid获取会员(/app/miniprogram/getMemberByOpenid)请求数据==============================");
        log.warn(JsonUtils.objectToJson(map));
        Map<String,Object> hashMap = new HashMap<>();
        //result_code:0-失败  1-成功
        hashMap.put("result_code", 0);
        hashMap.put("result_msg", "没有获取到相关会员信息");
        try{
            String org_id = map.get("org_id");
            String openid = map.get("openid");
            String token = map.get("token");
            if(DataCheck.checkOrgId(hashMap, org_id, orgFeign)) {
                return hashMap;
            }
            if(DataCheck.checkToken(hashMap, org_id, token,apiDockingConfFeign)){
                return hashMap;
            }
            if(StringUtils.isBlank(openid)){
                hashMap.put("result_msg", "openid不能为空");
                return hashMap;
            }
            MemberDto memberDto = new MemberDto();
            memberDto.setOrgId(Long.valueOf(org_id));
            memberDto.setOpenid(openid);
            ResultBean<Member> resultBean = this.memberFeign.getMemberByOpenid(memberDto);
            Member member = resultBean.getData();
            ApplyUserDto applyUserDto = new ApplyUserDto();
            applyUserDto.setMemberId(member.getId());
            boolean anyHousePass = false;
            MemberAndUser memAndUser = new MemberAndUser();
            memAndUser.setMemberId(member.getId());
            List<MemberAndUser> memAndUserList = this.memberAndUserFeign.getByCondition(memAndUser);
            if (memAndUserList != null && memAndUserList.size() > 0){
                anyHousePass = true;
            }
            if(member!=null){
                hashMap.put("result_code", 1);
                hashMap.put("result_msg", "获取会员信息成功");
                hashMap.put("member", PojoToApi.memberToApi(member));
                hashMap.put("anyHousePass",anyHousePass);
                //统计---会员登录
                AppMemberLoginRecords a = new AppMemberLoginRecords();
                a.setMemberId(member.getId());
                //登录类型 0-小程序登录 1-app登录
                a.setLoginType(OperationConstant.ZERO);
                a.setLoginDate(new Date());
                a.setRootOrgId(member.getRootOrgId());
                a.setOrgPosition(member.getOrgPosition());
                this.appMemberLoginRecordsFeign.addAppMemberLoginRecords(a);
            }
        }catch (Exception e){
            log.error("异常", e);
            hashMap.put("result_msg", "后台程序异常");
        }
        return hashMap;
    }

    @PostMapping(value = "/getMemberById")
    public Map<String,Object> getMemberById(@RequestBody Map<String,String> map){
        log.warn("============================小程序通过微信openid获取会员(/app/miniprogram/getMemberById)请求数据==============================");
        log.warn(JsonUtils.objectToJson(map));
        Map<String,Object> hashMap = new HashMap<>();
        //result_code:0-失败  1-成功
        hashMap.put("result_code", 0);
        hashMap.put("result_msg", "没有获取到相关会员信息");
        try{
            String org_id = map.get("org_id");
            String memberId = map.get("memberId");
            String token = map.get("token");
            if(DataCheck.checkOrgId(hashMap, org_id, orgFeign)) {
                return hashMap;
            }
            if(StringUtils.isBlank(memberId)){
                hashMap.put("result_msg", "memberId不能为空");
                return hashMap;
            }
            MemberDto memberDto = new MemberDto();
            memberDto.setOrgId(Long.valueOf(org_id));
            memberDto.setId(Long.valueOf(memberId));
            ResultBean<Member> resultBean = this.memberFeign.getMemberById(memberDto);
            Member member = resultBean.getData();
            ApplyUserDto applyUserDto = new ApplyUserDto();
            applyUserDto.setMemberId(member.getId());
            boolean anyHousePass = false;
            MemberAndUser memAndUser = new MemberAndUser();
            memAndUser.setMemberId(member.getId());
            List<MemberAndUser> memAndUserList = this.memberAndUserFeign.getByCondition(memAndUser);
            if (memAndUserList != null && memAndUserList.size() > 0){
                anyHousePass = true;
            }
            if(member!=null){
                hashMap.put("result_code", 1);
                hashMap.put("result_msg", "获取会员信息成功");
                hashMap.put("member", PojoToApi.memberToApi(member));
                hashMap.put("anyHousePass",anyHousePass);
                //统计---会员登录
                AppMemberLoginRecords a = new AppMemberLoginRecords();
                a.setMemberId(member.getId());
                //登录类型 0-小程序登录 1-app登录
                a.setLoginType(OperationConstant.ZERO);
                a.setLoginDate(new Date());
                a.setRootOrgId(member.getRootOrgId());
                a.setOrgPosition(member.getOrgPosition());
                this.appMemberLoginRecordsFeign.addAppMemberLoginRecords(a);
            }
        }catch (Exception e){
            log.error("异常", e);
            hashMap.put("result_msg", "后台程序异常");
        }
        return hashMap;
    }

    /**
     * 功能描述:会员注册--小程序
     * @param map {
     *             name         :   姓名,
     *             tel          :   手机号码,
     *             verify_code  :   验证码,
     *             openid       :   微信openid，----小程序端注册时必填
     *             org_id       :   机构授权org_id机构id
     *             token        :   对接令牌
     *            }
     * @return
     *
     *
     */
    @PostMapping(value = "/memberRegister")
    public Map<String,Object> memberRegister(@RequestBody Map<String,String> map){
        log.warn("============================小程序会员注册(/app/miniprogram/memberRegister)请求数据==============================");
        log.warn(JsonUtils.objectToJson(map));
        Map<String,Object> hashMap = new HashMap<>();
        //result_code:0-失败  1-成功
        hashMap.put("result_code", 0);
        try {
            String name = map.get("name");
            String tel =  map.get("tel");
            String verify_code = map.get("verify_code");
            String openid = map.get("openid");
            String org_id =  map.get("org_id");
            String token = map.get("token");
            Organization organization = null;
            if(org_id==null){
                hashMap.put("result_msg", "org_id不能为空");
                return hashMap;
            }else{
                organization = orgFeign.getOrgById(Long.valueOf(org_id));
                if(organization==null){
                    hashMap.put("result_msg", "org_id没有对应的机构，无权限");
                    return hashMap;
                }
            }
            if(DataCheck.checkToken(hashMap, org_id, token,apiDockingConfFeign)){
                return hashMap;
            }
            if(StringUtils.isBlank(name)){
                hashMap.put("result_msg", "姓名不能为空");
                return hashMap;
            }
            if(StringUtils.isBlank(tel)){
                hashMap.put("result_msg", "手机号码不能为空");
                return hashMap;
            }
            if(StringUtils.isBlank(verify_code)){
                hashMap.put("result_msg", "验证码不能为空");
                return hashMap;
            }
            if(StringUtils.isBlank(openid)){
                hashMap.put("result_msg", "openid不能为空");
                return hashMap;
            }
            //获取存在redis上的验证码
            String key = VERIFICATION_CODE + tel + org_id;
            String redis_verify_code = this.redisTemplate.opsForValue().get(key);
            //验证码过期 || 没有获取验证码操作
            if(redis_verify_code==null){
                hashMap.put("result_msg", "验证码过期，或者无效验证码");
                return hashMap;
            }
            if(!verify_code.equals(redis_verify_code)){
                hashMap.put("result_msg", "验证码不正确");
                return hashMap;
            }
            //检测机构下面一个手机号码只能注册一个会员
            Member checkMember = new Member();
            checkMember.setOrgId(Long.valueOf(org_id));
            checkMember.setTel(tel);
            ResultBean<Boolean> checkTel = memberFeign.checkMemberTel(checkMember);
            ResultBean<Boolean> resultBean;
            //号码已经注册
            if(checkTel.getData()){
                //检测名字是否匹配
                checkMember.setName(name);
                ResultBean<Boolean> checkTelAndName = memberFeign.checkMemberTel(checkMember);
                //匹配成功
                if(checkTelAndName.getData()){
                    //关联会员
                    checkMember.setOpenid(openid);
                    resultBean = memberFeign.updateMemberOpenId(checkMember);
                }else{
                    //手机号码已注册--名字不匹配
                    hashMap.put("result_msg", "手机号码已注册，姓名不匹配，注册失败");
                    return hashMap;
                }
            }else{
                Member member = new Member();
                member.setName(name);
                member.setTel(tel);
                //create_type : 会员注册来源，0-小程序注册 1-app注册,
                member.setCreateType(0);
                member.setCreateDate(new Date());
                member.setOpenid(openid);
                member.setOrgId(Long.valueOf(org_id));
                member.setRootOrgId(organization.getRootOrgId());
                member.setOrgPosition(organization.getPosition());
                //新增会员--注册
                resultBean = this.memberFeign.memberRegister(member);
            }
            //注册成功
            if(resultBean.getCode().equals("200") && resultBean.getData()){
                hashMap.put("result_code", 1);
                hashMap.put("result_msg", "注册成功");
            }else{
                hashMap.put("result_code", "注册失败");
            }
        }catch (Exception e){
            log.error("异常", e);
            hashMap.put("result_msg", "后台程序异常");
        }
        return hashMap;
    }

    @PostMapping(value = "/ws/geocoder/v1/location")
    public Map<String,Object> wxLocation(@RequestBody Map<String,String> map){
        log.warn("============================小程序获取腾讯地图行政区划(/app/miniprogram/ws/geocoder/v1/location)请求数据==============================");
        log.warn(JsonUtils.objectToJson(map));
        RestTemplate restTemplate = new RestTemplate();
        String location = map.get("location");
        String[] latitude_longitude = location.split(",");
        String latitude = latitude_longitude[0];
        String longitude = latitude_longitude[1];
        String confKey = map.get("key");
        //获取腾讯地图接口
        String wxMapApi = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + latitude + "," + longitude + "&key=" + confKey;
        ResponseEntity<String> responseEntity = restTemplate.getForEntity(wxMapApi, String.class);
        //返回正常
        Map<String,Object> hashMap = new HashMap<>();
        hashMap.put("result_code", 0);
        if(responseEntity.getStatusCodeValue()==200) {
            String body = responseEntity.getBody();
            Map<String, String> result = JsonUtils.jsonToPojo(body, Map.class);
            hashMap.put("result_code", 1);
            hashMap.put("result_msg", "获取行政区域成功");
            hashMap.put("result", result);
        }else{
            hashMap.put("result_msg", "获取行政区域失败");
        }
        return hashMap;
    }

    @PostMapping(value = "/ws/district/v1/getchildren")
    public Map<String,Object> getchildren(@RequestBody Map<String,String> map){
        RestTemplate restTemplate = new RestTemplate();
        String id = map.get("id");

        String key = map.get("key");
        //获取腾讯地图接口
        String wxMapApi = "https://apis.map.qq.com/ws/district/v1/getchildren?&id="+id+"&key=" + key;
        ResponseEntity<String> responseEntity = restTemplate.getForEntity(wxMapApi, String.class);
        //返回正常
        Map<String,Object> hashMap = new HashMap<>();
        hashMap.put("result_code", 0);
        if(responseEntity.getStatusCodeValue()==200) {
            String body = responseEntity.getBody();
            Map<String, String> result = JsonUtils.jsonToPojo(body, Map.class);
            hashMap.put("result_code", 1);
            hashMap.put("result_msg", "获取成功");
            hashMap.put("result", result);
        }else{
            hashMap.put("result_msg", "获取失败");
        }
        return hashMap;
    }

    @PostMapping("/getOpenData")
    public String getOpenData (@RequestBody DataDto dataDto){
        byte[] key = Base64.getDecoder().decode(dataDto.getSessionKey().replaceAll(" ","+"));
        byte[] iv = Base64.getDecoder().decode(dataDto.getIv().replaceAll(" ","+"));
        byte[] content = Base64.getDecoder().decode(dataDto.getEncryptedData().replaceAll(" ","+"));
        AES aes = new AES(Mode.CBC, Padding.PKCS5Padding,key,iv);
        return new String(aes.decrypt(content));
    }


    @PostMapping("/generateCode")
    public String generateCode(@RequestBody Map<String,String> params) throws IOException {
        log.warn("============================小程序生成小程序二维码(/app/miniprogram/generateCode)请求数据==============================");
        log.warn(JsonUtils.objectToJson(params));
        String url = GENERATE_CODE_URL+"?access_token="+params.get("access_token");
        params.remove("access_token");
        params.remove("org_id");
        params.remove("token");
        HttpResponse response = HttpRequest.post(url)
                .body(JSON.toJSONString(params),"application/json")
                .execute();
        byte[] bytes = response.bodyBytes();
        String base64 = Base64.getEncoder().encodeToString(bytes);
        MultipartFile multipartFile  = Base64DecodeMultipartFileUtils.base64ToMultipart(Base64DecodeMultipartFileUtils.imageFormatToPng("data:image/png;base64," + base64));
        //图片上传
        StorePath storePath = fastFileStorageClient.uploadFile(
                multipartFile.getInputStream(),multipartFile.getSize(),
                FilenameUtils.getExtension(multipartFile.getOriginalFilename()),null);
        return "https://community.58fo.com/fdsfile/"+storePath.getFullPath();
    }



    @PostMapping("/getAccessToken")
    public String getAccessToken (@RequestBody AccessToKenDto accessToKenDto){
        HttpResponse response = HttpRequest.get("https://api.weixin.qq.com/cgi-bin/token"+"?appid="+accessToKenDto.getAppId()+"&secret="+accessToKenDto.getSecret()+"&grant_type="+accessToKenDto.getGrantType()).execute();
        return response.body();
    }


    @RequestMapping("/oauth/login/{source}")
    public Map<String, Object> miniLogin(@PathVariable("source") String source, @RequestBody Map<String, String> requestMap) {
        AuthToken authToken = null;
        Map<String, Object> returnMap = new HashMap<>(1);
        returnMap.put("errorMsg", "授权登录失败");
        if("CTWING".equals(source)){
            try {
                // XXTea解密非公共加密参数
                String decValue = new String(XXTeaUtil.decrypt(ByteFormat.hexToBytes(requestMap.get("paras")), CtwingAuthConstants.APP_SECRET.getBytes(CtwingAuthConstants.DEFAULT_CHARSET)));
                Map<String, String> resultMap = MapUtil.parseStringToMap(decValue, false);
                if(0 == Integer.valueOf(resultMap.get("result"))) {
                    authToken = new AuthToken();
                    authToken.setAccessToken(resultMap.get("accessToken"));
                    authToken.setUid(resultMap.get("openId"));
                    AuthCtwingRequest authRequest = (AuthCtwingRequest) getAuthRequest(source);
                    AuthUser data = authRequest.getUserInfo(authToken);
                    AccountOauthDto accountOauthDto = new AccountOauthDto();
                    accountOauthDto.setMobile(data.getUsername());
                    accountOauthDto.setUuId(data.getUuid());
                    accountOauthDto.setSource(source);
                    Member checkMember = new Member();
                    checkMember.setTel(accountOauthDto.getMobile());
                    checkMember.setOrgId(1L);
                    Member memberByTel = this.memberFeign.findMemberByTel(checkMember);
                    ResultBean<Boolean> resultBean;
                    if (memberByTel == null) {
                        Member newMember = new Member();
                        newMember.setName(data.getUsername());
                        newMember.setTel(accountOauthDto.getMobile());
                        //create_type : 会员注册来源，0-小程序添加 1-后台添加  2-后台导入 3-app添加
                        newMember.setCreateType(OperationConstant.FOUR);
                        newMember.setCreateDate(new Date());
                        //密码md5加密
//                        member.setPassword(DigestUtils.md5Hex(PWD_SALT + password));
                        newMember.setOrgId(1L);
                        newMember.setRootOrgId(1L);
                        newMember.setOrgPosition("0/1/");
                        //新增会员--注册
                        resultBean = this.memberFeign.memberRegister(newMember);
                        if (resultBean.getCode().equals("200") && resultBean.getData()) {
                            returnMap.put("result_code", 1);
                            returnMap.put("result_msg", "授权登录成功");
                        } else {
                            returnMap.put("result_code", "授权登录异常");
                        }
                    } else {
                        if (Integer.valueOf(OperationConstant.TWO).equals(memberByTel.getEnable())) {
                            returnMap.put("result_msg", "该账号已禁用");
                            return returnMap;
                        }
                        //判断是否已存在房屋认证
                        ApplyUserDto applyUserDto = new ApplyUserDto();
                        applyUserDto.setMemberId(memberByTel.getId());
                        boolean anyHousePass = false;
                        MemberAndUser memAndUser = new MemberAndUser();
                        memAndUser.setMemberId(memberByTel.getId());
                        List<MemberAndUser> memAndUserList = this.memberAndUserFeign.getByCondition(memAndUser);
                        if (memAndUserList != null && memAndUserList.size() > 0) {
                            anyHousePass = true;
                        }
                        returnMap.put("result_code", 1);
                        returnMap.put("result_msg", "登录成功");
                        if (StringUtils.isNotBlank(memberByTel.getHeadImage())) {
                            memberByTel.setHeadImage(confFeign.getFileServerHost() + memberByTel.getHeadImage());
                        }
                        returnMap.put("member", PojoToApi.memberToApi(memberByTel));
                        returnMap.put("anyHousePass", anyHousePass);
                    }
                    String tokenCode = jwtUtil.create(accountOauthDto.getMobile(), "");
                    returnMap.put("token", tokenCode);
                    return returnMap;
                }else{
                    return returnMap;
                }
            } catch (Exception e) {
                e.printStackTrace();
                return returnMap;
            }
        }else{
            return returnMap;
        }
    }


}
