@@ -68,6 +68,21 @@ public class AccountVO{ | |||
private String remarks; | |||
private String session; | |||
/** | |||
* 微信昵称 | |||
*/ | |||
private String wxName; | |||
/** | |||
* 微信头像 | |||
*/ | |||
private String wxPortrait; | |||
/** | |||
* 用户对应的企业的审核状态 | |||
*/ | |||
private String auditStatus; | |||
private String vipLevel; | |||
public AccountVO(){} | |||
@@ -199,5 +214,37 @@ public class AccountVO{ | |||
public void setSession(String session) { | |||
this.session = session; | |||
} | |||
public String getWxName() { | |||
return wxName; | |||
} | |||
public void setWxName(String wxName) { | |||
this.wxName = wxName; | |||
} | |||
public String getWxPortrait() { | |||
return wxPortrait; | |||
} | |||
public void setWxPortrait(String wxPortrait) { | |||
this.wxPortrait = wxPortrait; | |||
} | |||
public String getAuditStatus() { | |||
return auditStatus; | |||
} | |||
public void setAuditStatus(String auditStatus) { | |||
this.auditStatus = auditStatus; | |||
} | |||
public String getVipLevel() { | |||
return vipLevel; | |||
} | |||
public void setVipLevel(String vipLevel) { | |||
this.vipLevel = vipLevel; | |||
} | |||
} |
@@ -52,7 +52,7 @@ public interface AccountService { | |||
/** | |||
* 微信授权登陆 | |||
*/ | |||
public DataResult<AccountVO> wxAuthorization(String wxCode); | |||
public DataResult<AccountVO> wxAuthorization(AccountVO account,String wxCode); | |||
/** | |||
* 通过微信注册 | |||
@@ -65,8 +65,8 @@ public class AuthenticationController { | |||
@RequestMapping("/wxAuthorization") | |||
@ApiOperation(value = "微信认证登陆", notes = "微信认证登陆", httpMethod = "POST") | |||
public DataResult<AccountVO> wxAuthorization(String code) { | |||
DataResult<AccountVO> result = accountService.wxAuthorization(code); | |||
public DataResult<AccountVO> wxAuthorization(@RequestBody AccountVO account,String code) { | |||
DataResult<AccountVO> result = accountService.wxAuthorization(account,code); | |||
return result; | |||
} | |||
@@ -1,6 +1,10 @@ | |||
package com.hp.user.service.dao; | |||
import com.hp.user.service.entity.Account; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.apache.ibatis.annotations.Select; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
/** | |||
@@ -12,5 +16,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface AccountMapper extends BaseMapper<Account> { | |||
@Select("select a.*,b.status as audit_status,b.vip_level from tb_account a LEFT JOIN tb_customer_company b ON (a.company_id = b.customer_id) where user_id = #{userId} and company_id is not null and a.sys_deleted = 0 ") | |||
public Account queryUserInfoAndCompanyInfo(@Param("userId")String userId); | |||
} |
@@ -76,6 +76,20 @@ public class Account implements Serializable { | |||
private String remarks; | |||
private String wxOpenId; | |||
/** | |||
* 微信昵称 | |||
*/ | |||
private String wxName; | |||
/** | |||
* 微信头像 | |||
*/ | |||
private String wxPortrait; | |||
/** | |||
* 用户对应的企业的审核状态 | |||
*/ | |||
private String auditStatus; | |||
private String vipLevel; | |||
public Account(){} | |||
@@ -206,5 +220,38 @@ public class Account implements Serializable { | |||
public void setWxOpenId(String wxOpenId) { | |||
this.wxOpenId = wxOpenId; | |||
} | |||
public String getWxName() { | |||
return wxName; | |||
} | |||
public void setWxName(String wxName) { | |||
this.wxName = wxName; | |||
} | |||
public String getWxPortrait() { | |||
return wxPortrait; | |||
} | |||
public void setWxPortrait(String wxPortrait) { | |||
this.wxPortrait = wxPortrait; | |||
} | |||
public String getAuditStatus() { | |||
return auditStatus; | |||
} | |||
public void setAuditStatus(String auditStatus) { | |||
this.auditStatus = auditStatus; | |||
} | |||
public String getVipLevel() { | |||
return vipLevel; | |||
} | |||
public void setVipLevel(String vipLevel) { | |||
this.vipLevel = vipLevel; | |||
} | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.hp.user.service.impl; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
@@ -12,6 +13,7 @@ import com.hp.user.client.service.MessageService; | |||
import com.hp.user.service.dao.AccountMapper; | |||
import com.hp.user.service.entity.Account; | |||
import com.hp.user.service.entity.CustomerCompany; | |||
import com.hp.user.service.entity.ElectricianGroup; | |||
import com.hp.user.service.utils.WeixinSignUtil; | |||
import java.util.ArrayList; | |||
@@ -124,7 +126,7 @@ public class AccountServiceImpl implements AccountService { | |||
} | |||
@Override | |||
public DataResult<AccountVO> wxAuthorization(String wxCode) { | |||
public DataResult<AccountVO> wxAuthorization(AccountVO account,String wxCode) { | |||
DataResult<AccountVO> result = new DataResult<AccountVO>(); | |||
JSONObject data = null; | |||
try { | |||
@@ -139,15 +141,22 @@ public class AccountServiceImpl implements AccountService { | |||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("wx_open_id", openid); | |||
Account findAccount = accountMapper.selectOne(queryWrapper); | |||
AccountVO account = new AccountVO(); | |||
if(null == findAccount) { | |||
account = new AccountVO(); | |||
String session = data.getString("session_key"); | |||
account.setSession(session); | |||
account.setWxOpenId(openid); | |||
result.setCode("-1"); | |||
result.setCode("6000"); | |||
result.setMessage("微信需要绑定"); | |||
result.setData(account); | |||
}else { | |||
if(null != account) { | |||
//表示需要更新微信信息 | |||
findAccount.setWxName(account.getWxName()); | |||
findAccount.setWxPortrait(account.getWxPortrait()); | |||
accountMapper.updateById(findAccount); | |||
} | |||
BeanUtils.copyProperties(findAccount, account); | |||
result.setData(account); | |||
} | |||
@@ -245,20 +254,24 @@ public class AccountServiceImpl implements AccountService { | |||
AccountVO accountVO = new AccountVO(); | |||
DataResult<AccountVO> result = new DataResult<>(); | |||
try{ | |||
Account temp = accountMapper.selectById(userId); | |||
// Account temp = accountMapper.selectById(userId); | |||
// QueryWrapper<> queryWrapper = new QueryWrapper(); | |||
Account account = accountMapper.queryUserInfoAndCompanyInfo(userId); | |||
// 这个已经被删除 | |||
if (temp == null || temp.getSysDeleted() == 1){ | |||
if (account == null){ | |||
result.setCode("-1"); | |||
result.setMessage("账号不存在/已删除"); | |||
return result; | |||
} | |||
else { | |||
BeanUtils.copyProperties(temp, accountVO); | |||
result.setCode("0"); | |||
account.setWxOpenId(null); | |||
BeanUtils.copyProperties(account, accountVO); | |||
result.setData(accountVO); | |||
} | |||
}catch(Exception e){ | |||
e.printStackTrace(); | |||
result.setCode("-1"); | |||
result.setMessage("系统错误"); | |||
} | |||
return result; | |||
} | |||