feat(用户管理): 实现汇邦云用户与企业微信用户的绑定功能
新增BindQyUserCommand类用于绑定操作 在Ab98UserController中添加绑定接口 完善Ab98UserApplicationService中的绑定逻辑 修改TokenDTO以包含企业微信用户信息 调整相关服务类方法以支持双向关联查询
This commit is contained in:
parent
b65106402e
commit
4cdabe3db3
|
@ -5,6 +5,9 @@ import com.agileboot.common.core.base.BaseController;
|
||||||
import com.agileboot.common.core.dto.ResponseDTO;
|
import com.agileboot.common.core.dto.ResponseDTO;
|
||||||
import com.agileboot.common.core.page.PageDTO;
|
import com.agileboot.common.core.page.PageDTO;
|
||||||
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
import com.agileboot.common.enums.common.BusinessTypeEnum;
|
||||||
|
import com.agileboot.common.exception.ApiException;
|
||||||
|
import com.agileboot.common.exception.error.ErrorCode;
|
||||||
|
import com.agileboot.domain.ab98.user.command.BindQyUserCommand;
|
||||||
import com.agileboot.domain.ab98.user.dto.Ab98UserDetailDTO;
|
import com.agileboot.domain.ab98.user.dto.Ab98UserDetailDTO;
|
||||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||||
import com.agileboot.domain.ab98.user.Ab98UserApplicationService;
|
import com.agileboot.domain.ab98.user.Ab98UserApplicationService;
|
||||||
|
@ -17,6 +20,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -73,4 +77,15 @@ public class Ab98UserController extends BaseController {
|
||||||
userApplicationService.deleteUser(new BulkOperationCommand<>(ids));
|
userApplicationService.deleteUser(new BulkOperationCommand<>(ids));
|
||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "绑定汇邦云")
|
||||||
|
@AccessLog(title = "ab98用户管理", businessType = BusinessTypeEnum.MODIFY)
|
||||||
|
@PostMapping("/bindQyUser")
|
||||||
|
public ResponseDTO<Void> bindQyUser(@RequestBody BindQyUserCommand command) {
|
||||||
|
if (command == null || command.getQyUserId() == null || StringUtils.isBlank(command.getName()) || StringUtils.isBlank(command.getIdNum())) {
|
||||||
|
return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "参数错误"));
|
||||||
|
}
|
||||||
|
userApplicationService.bindQyUser(command);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,10 @@ import com.agileboot.domain.common.dto.CurrentLoginUserDTO;
|
||||||
import com.agileboot.domain.common.dto.TokenDTO;
|
import com.agileboot.domain.common.dto.TokenDTO;
|
||||||
import com.agileboot.domain.qywx.accessToken.AccessTokenApplicationService;
|
import com.agileboot.domain.qywx.accessToken.AccessTokenApplicationService;
|
||||||
import com.agileboot.domain.qywx.accessToken.db.QyAccessTokenEntity;
|
import com.agileboot.domain.qywx.accessToken.db.QyAccessTokenEntity;
|
||||||
|
import com.agileboot.domain.qywx.user.QyUserApplicationService;
|
||||||
|
import com.agileboot.domain.qywx.user.dto.QyUserDTO;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.SysUserQyUserApplicationService;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserEntity;
|
||||||
import com.agileboot.domain.system.menu.MenuApplicationService;
|
import com.agileboot.domain.system.menu.MenuApplicationService;
|
||||||
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
import com.agileboot.domain.system.menu.dto.RouterDTO;
|
||||||
import com.agileboot.domain.system.user.UserApplicationService;
|
import com.agileboot.domain.system.user.UserApplicationService;
|
||||||
|
@ -63,6 +67,10 @@ public class LoginController {
|
||||||
|
|
||||||
private final AccessTokenApplicationService accessTokenApplicationService;
|
private final AccessTokenApplicationService accessTokenApplicationService;
|
||||||
|
|
||||||
|
private final SysUserQyUserApplicationService sysUserQyUserApplicationService;
|
||||||
|
|
||||||
|
private final QyUserApplicationService qyUserApplicationService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问首页,提示语
|
* 访问首页,提示语
|
||||||
*/
|
*/
|
||||||
|
@ -114,7 +122,13 @@ public class LoginController {
|
||||||
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
SystemLoginUser loginUser = AuthenticationUtils.getSystemLoginUser();
|
||||||
CurrentLoginUserDTO currentUserDTO = userApplicationService.getLoginUserInfo(loginUser);
|
CurrentLoginUserDTO currentUserDTO = userApplicationService.getLoginUserInfo(loginUser);
|
||||||
|
|
||||||
return ResponseDTO.ok(new TokenDTO(token, currentUserDTO));
|
SysUserQyUserEntity sysUserQyUser = sysUserQyUserApplicationService.getBySysUserId(loginUser.getUserId());
|
||||||
|
QyUserDTO qyUserDTO = null;
|
||||||
|
if (sysUserQyUser != null) {
|
||||||
|
qyUserDTO = qyUserApplicationService.getQyUserDetail(Long.valueOf(sysUserQyUser.getQyUserId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseDTO.ok(new TokenDTO(token, currentUserDTO, qyUserDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -198,7 +198,7 @@ public class PaymentController {
|
||||||
|
|
||||||
OpenidResponse openidResponse = QywxApiUtil.convertToOpenid(qyAccessToken.getAccessToken(), userid);
|
OpenidResponse openidResponse = QywxApiUtil.convertToOpenid(qyAccessToken.getAccessToken(), userid);
|
||||||
|
|
||||||
QyUserEntity qyUserEntity = qyUserApplicationService.getUserByUserId(userid, corpid);
|
QyUserEntity qyUserEntity = qyUserApplicationService.getUserByUserIdAndCorpid(userid, corpid);
|
||||||
|
|
||||||
return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, qyUserEntity.getName()));
|
return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, qyUserEntity.getName()));
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
|
@ -246,7 +246,7 @@ public class PaymentController {
|
||||||
}
|
}
|
||||||
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, corpid);
|
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid(appid, corpid);
|
||||||
UserIdResponse userIdResponse = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), openid);
|
UserIdResponse userIdResponse = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), openid);
|
||||||
QyUserEntity qyUser = qyUserApplicationService.getUserByUserId(userIdResponse.getUserid(), corpid);
|
QyUserEntity qyUser = qyUserApplicationService.getUserByUserIdAndCorpid(userIdResponse.getUserid(), corpid);
|
||||||
if (qyUser == null) {
|
if (qyUser == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ public class PaymentController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/getBalanceByQyUserid")
|
@GetMapping("/getBalanceByQyUserid")
|
||||||
public ResponseDTO<GetBalanceResponse> getBalanceByQyUserid(@RequestParam String corpid, @RequestParam String userid) {
|
public ResponseDTO<GetBalanceResponse> getBalanceByQyUserid(@RequestParam String corpid, @RequestParam String userid) {
|
||||||
QyUserEntity qyUser = qyUserApplicationService.getUserByUserId(userid, corpid);
|
QyUserEntity qyUser = qyUserApplicationService.getUserByUserIdAndCorpid(userid, corpid);
|
||||||
|
|
||||||
// 创建响应对象(假设GetBalanceResponse包含balance字段)
|
// 创建响应对象(假设GetBalanceResponse包含balance字段)
|
||||||
GetBalanceResponse response = new GetBalanceResponse(
|
GetBalanceResponse response = new GetBalanceResponse(
|
||||||
|
|
|
@ -98,16 +98,17 @@ public class WxLoginController {
|
||||||
data.setRegistered(loginResponse.getOutputData().isRegistered());
|
data.setRegistered(loginResponse.getOutputData().isRegistered());
|
||||||
data.setTel(loginResponse.getOutputData().getTel());
|
data.setTel(loginResponse.getOutputData().getTel());
|
||||||
|
|
||||||
|
Long ab98UserId = null;
|
||||||
try {
|
try {
|
||||||
qyUserApplicationService.saveQyUserInfoByAb98(userid, loginResponse.getOutputData(), null);
|
ab98UserId = ab98UserApplicationService.saveAb98User(openid, loginResponse.getOutputData());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("保存汇邦云用户信息到企业用户失败: ", e);
|
log.error("保存汇邦云用户信息失败: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ab98UserApplicationService.saveAb98User(openid, loginResponse.getOutputData());
|
qyUserApplicationService.saveQyUserInfoByAb98(ab98UserId, userid, loginResponse.getOutputData(), null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("保存汇邦云用户信息失败: ", e);
|
log.error("保存汇邦云用户信息到企业用户失败: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseDTO.ok(data);
|
return ResponseDTO.ok(data);
|
||||||
|
@ -136,16 +137,17 @@ public class WxLoginController {
|
||||||
data.setRegistered(true);
|
data.setRegistered(true);
|
||||||
data.setTel(loginUserinfo.getPhone());
|
data.setTel(loginUserinfo.getPhone());
|
||||||
|
|
||||||
|
Long ab98UserId = null;
|
||||||
try {
|
try {
|
||||||
qyUserApplicationService.saveQyUserInfoByAb98(userid, null, loginUserinfo);
|
ab98UserId = ab98UserApplicationService.saveAb98UserByToken(openid, loginUserinfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("保存汇邦云用户信息到企业用户失败: ", e);
|
log.error("保存汇邦云用户信息失败: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ab98UserApplicationService.saveAb98UserByToken(openid, loginUserinfo);
|
qyUserApplicationService.saveQyUserInfoByAb98(ab98UserId, userid, null, loginUserinfo);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("保存汇邦云用户信息失败: ", e);
|
log.error("保存汇邦云用户信息到企业用户失败: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseDTO.ok(data);
|
return ResponseDTO.ok(data);
|
||||||
|
|
|
@ -179,6 +179,40 @@ public class Ab98ApiUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取用户信息
|
||||||
|
* @param appname
|
||||||
|
* @param appsecret
|
||||||
|
* @param idnum
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Ab98UserDto pullUserInfoByIdnum(String appname,
|
||||||
|
String appsecret,
|
||||||
|
String idnum) {
|
||||||
|
String sign = DigestUtils.md5Hex(String.format("app=%s&idnum=%s&name=&tel=%s", appname, idnum, appsecret));
|
||||||
|
String url = String.format("https://www.ab98.cn/api/pull?idnum=%s&app=%s&sign=%s"
|
||||||
|
,idnum
|
||||||
|
,appname
|
||||||
|
,sign);
|
||||||
|
|
||||||
|
String res = HttpUtil.get(url);
|
||||||
|
try {
|
||||||
|
JSONObject o = JSONUtil.parseObj(res);
|
||||||
|
String state = o.getStr("state");
|
||||||
|
if (StringUtils.equalsIgnoreCase(state, "ok")) {
|
||||||
|
return o.get("user", Ab98UserDto.class);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取登录用户信息失败", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Ab98UserDto userDto = pullUserInfoByIdnum("wxshop", "34164e41f0c6694be6bbbba0dc50c14a", "450981199505186050");
|
||||||
|
log.info("拉取用户信息: {}", JSONUtil.toJsonStr(userDto));
|
||||||
|
}
|
||||||
|
|
||||||
// 基础响应对象
|
// 基础响应对象
|
||||||
@Data
|
@Data
|
||||||
public static class BaseResponse {
|
public static class BaseResponse {
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
package com.agileboot.domain.ab98.api;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Ab98UserDto {
|
||||||
|
/**
|
||||||
|
* 统一系统的记录ID
|
||||||
|
*/
|
||||||
|
private String ssoUid;
|
||||||
|
/**
|
||||||
|
* 真实姓名
|
||||||
|
*/
|
||||||
|
private String realName;
|
||||||
|
/**
|
||||||
|
* 性别:男 女
|
||||||
|
*/
|
||||||
|
private String sex;
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
/**
|
||||||
|
* 在统一登录平台绑定的药小云公众号openid
|
||||||
|
*/
|
||||||
|
private String openid;
|
||||||
|
/**
|
||||||
|
* 微信昵称
|
||||||
|
*/
|
||||||
|
private String nickname;
|
||||||
|
/**
|
||||||
|
* 微信头像
|
||||||
|
*/
|
||||||
|
private String headimage;
|
||||||
|
/**
|
||||||
|
* 身份证地址
|
||||||
|
*/
|
||||||
|
private String idCardAddress;
|
||||||
|
/**
|
||||||
|
* 身份证号
|
||||||
|
*/
|
||||||
|
private String idCardNo;
|
||||||
|
/**
|
||||||
|
* 签发机关
|
||||||
|
*/
|
||||||
|
private String authority;
|
||||||
|
/**
|
||||||
|
* 有效期
|
||||||
|
*/
|
||||||
|
private String validdate;
|
||||||
|
/**
|
||||||
|
* 身份证正面图像链接
|
||||||
|
*/
|
||||||
|
private String idCardFront;
|
||||||
|
/**
|
||||||
|
* 身份证背面图像链接
|
||||||
|
*/
|
||||||
|
private String idCardBack;
|
||||||
|
/**
|
||||||
|
* 人脸图像链接
|
||||||
|
*/
|
||||||
|
private String facePicture;
|
||||||
|
/**
|
||||||
|
* 营业执照图片链接
|
||||||
|
*/
|
||||||
|
private String businessLicense;
|
||||||
|
/**
|
||||||
|
* 统一社会信用代码(三合一之前为注册号)
|
||||||
|
*/
|
||||||
|
private String regNum;
|
||||||
|
/**
|
||||||
|
* 公司名称
|
||||||
|
*/
|
||||||
|
private String companyName;
|
||||||
|
/**
|
||||||
|
* 注册资本
|
||||||
|
*/
|
||||||
|
private String capital;
|
||||||
|
/**
|
||||||
|
* 法定代表人
|
||||||
|
*/
|
||||||
|
private String person;
|
||||||
|
/**
|
||||||
|
* 注册地址
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
/**
|
||||||
|
* 民族
|
||||||
|
*/
|
||||||
|
private String nation;
|
||||||
|
/**
|
||||||
|
* 经营范围
|
||||||
|
*/
|
||||||
|
private String business;
|
||||||
|
/**
|
||||||
|
* 主体类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
/**
|
||||||
|
* 营业期限
|
||||||
|
*/
|
||||||
|
private String period;
|
||||||
|
/**
|
||||||
|
* 组成形式
|
||||||
|
*/
|
||||||
|
private String composingForm;
|
||||||
|
/**
|
||||||
|
* 成立日期
|
||||||
|
*/
|
||||||
|
private String setDate;
|
||||||
|
/**
|
||||||
|
* 门店图片链接
|
||||||
|
*/
|
||||||
|
private String shopPicture;
|
||||||
|
/**
|
||||||
|
* 门店环境图片链接
|
||||||
|
*/
|
||||||
|
private String environmentPicture;
|
||||||
|
/**
|
||||||
|
* 当前系统的门店老板的账号ID,此字段不为空时,表示门店老板添加员工
|
||||||
|
*/
|
||||||
|
private String parentUserId;
|
||||||
|
/**
|
||||||
|
* 人脸特征的base64字符串
|
||||||
|
*/
|
||||||
|
private String faceFeatureBase64;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员角色:0-超级管理员 1-普通管理员 2-普通用户
|
||||||
|
*/
|
||||||
|
private Integer role;
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,12 @@
|
||||||
package com.agileboot.domain.ab98.user;
|
package com.agileboot.domain.ab98.user;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.PageDTO;
|
import com.agileboot.common.core.page.PageDTO;
|
||||||
|
import com.agileboot.common.exception.ApiException;
|
||||||
|
import com.agileboot.common.exception.error.ErrorCode;
|
||||||
import com.agileboot.domain.ab98.api.Ab98ApiUtil;
|
import com.agileboot.domain.ab98.api.Ab98ApiUtil;
|
||||||
|
import com.agileboot.domain.ab98.api.Ab98UserDto;
|
||||||
import com.agileboot.domain.ab98.api.SsoLoginUserinfo;
|
import com.agileboot.domain.ab98.api.SsoLoginUserinfo;
|
||||||
|
import com.agileboot.domain.ab98.user.command.BindQyUserCommand;
|
||||||
import com.agileboot.domain.ab98.user.dto.Ab98UserDetailDTO;
|
import com.agileboot.domain.ab98.user.dto.Ab98UserDetailDTO;
|
||||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||||
import com.agileboot.domain.ab98.user.command.AddAb98UserCommand;
|
import com.agileboot.domain.ab98.user.command.AddAb98UserCommand;
|
||||||
|
@ -13,12 +17,21 @@ import com.agileboot.domain.ab98.user.dto.Ab98UserDTO;
|
||||||
import com.agileboot.domain.ab98.user.model.Ab98UserModel;
|
import com.agileboot.domain.ab98.user.model.Ab98UserModel;
|
||||||
import com.agileboot.domain.ab98.user.model.Ab98UserModelFactory;
|
import com.agileboot.domain.ab98.user.model.Ab98UserModelFactory;
|
||||||
import com.agileboot.domain.ab98.user.query.SearchAb98UserQuery;
|
import com.agileboot.domain.ab98.user.query.SearchAb98UserQuery;
|
||||||
|
import com.agileboot.domain.qywx.user.db.QyUserEntity;
|
||||||
|
import com.agileboot.domain.qywx.user.db.QyUserService;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserEntity;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserService;
|
||||||
|
import com.agileboot.domain.system.user.db.SysUserEntity;
|
||||||
|
import com.agileboot.domain.system.user.db.SysUserService;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -27,6 +40,9 @@ import org.springframework.stereotype.Service;
|
||||||
public class Ab98UserApplicationService {
|
public class Ab98UserApplicationService {
|
||||||
private final Ab98UserService userService;
|
private final Ab98UserService userService;
|
||||||
private final Ab98UserModelFactory userModelFactory;
|
private final Ab98UserModelFactory userModelFactory;
|
||||||
|
private final QyUserService qyUserService;
|
||||||
|
private final SysUserQyUserService sysUserQyUserService;
|
||||||
|
private final SysUserService sysUserService;
|
||||||
|
|
||||||
public PageDTO<Ab98UserDTO> getUserList(SearchAb98UserQuery<Ab98UserEntity> query) {
|
public PageDTO<Ab98UserDTO> getUserList(SearchAb98UserQuery<Ab98UserEntity> query) {
|
||||||
Page<Ab98UserEntity> page = userService.getUserListWithTagFilter(query);
|
Page<Ab98UserEntity> page = userService.getUserListWithTagFilter(query);
|
||||||
|
@ -74,8 +90,12 @@ public class Ab98UserApplicationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void saveAb98User(String openid, Ab98ApiUtil.LoginData loginData) {
|
public Long saveAb98User(String openid, Ab98ApiUtil.LoginData loginData) {
|
||||||
Ab98UserEntity ab98UserEntity = userService.selectByOpenidAndUserid(openid, loginData.getUserid());
|
// Ab98UserEntity ab98UserEntity = userService.selectByOpenidAndUserid(openid, loginData.getUserid());
|
||||||
|
if (loginData == null || StringUtils.isBlank(loginData.getIdnum())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Ab98UserEntity ab98UserEntity = userService.getByIdnum(loginData.getIdnum());
|
||||||
if (ab98UserEntity != null &&
|
if (ab98UserEntity != null &&
|
||||||
StringUtils.equals(loginData.getName(), ab98UserEntity.getName())
|
StringUtils.equals(loginData.getName(), ab98UserEntity.getName())
|
||||||
) {
|
) {
|
||||||
|
@ -90,6 +110,7 @@ public class Ab98UserApplicationService {
|
||||||
command.setAddress(loginData.getAddress());
|
command.setAddress(loginData.getAddress());
|
||||||
command.setRegistered(loginData.isRegistered());
|
command.setRegistered(loginData.isRegistered());
|
||||||
updateUser(command);
|
updateUser(command);
|
||||||
|
return ab98UserEntity.getAb98UserId();
|
||||||
} else {
|
} else {
|
||||||
AddAb98UserCommand command = new AddAb98UserCommand();
|
AddAb98UserCommand command = new AddAb98UserCommand();
|
||||||
command.setOpenid(openid);
|
command.setOpenid(openid);
|
||||||
|
@ -103,13 +124,22 @@ public class Ab98UserApplicationService {
|
||||||
command.setFaceImg(loginData.getFace_img());
|
command.setFaceImg(loginData.getFace_img());
|
||||||
command.setAddress(loginData.getAddress());
|
command.setAddress(loginData.getAddress());
|
||||||
command.setRegistered(loginData.isRegistered());
|
command.setRegistered(loginData.isRegistered());
|
||||||
addUser(command);
|
command.initBaseEntity();
|
||||||
|
|
||||||
|
Ab98UserModel model = userModelFactory.create();
|
||||||
|
model.loadAddCommand(command);
|
||||||
|
model.insert();
|
||||||
|
return model.getAb98UserId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void saveAb98UserByToken(String openid, SsoLoginUserinfo loginUserinfo) {
|
public Long saveAb98UserByToken(String openid, SsoLoginUserinfo loginUserinfo) {
|
||||||
Ab98UserEntity ab98UserEntity = userService.selectByOpenidAndUserid(openid, String.valueOf(loginUserinfo.getId()));
|
if (loginUserinfo == null || StringUtils.isBlank(loginUserinfo.getIdCardNo())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Ab98UserEntity ab98UserEntity = userService.selectByOpenidAndUserid(openid, String.valueOf(loginUserinfo.getId()));
|
||||||
|
Ab98UserEntity ab98UserEntity = userService.getByIdnum(loginUserinfo.getIdCardNo());
|
||||||
if (ab98UserEntity != null &&
|
if (ab98UserEntity != null &&
|
||||||
StringUtils.equals(loginUserinfo.getName(), ab98UserEntity.getName())
|
StringUtils.equals(loginUserinfo.getName(), ab98UserEntity.getName())
|
||||||
) {
|
) {
|
||||||
|
@ -124,6 +154,7 @@ public class Ab98UserApplicationService {
|
||||||
command.setAddress(loginUserinfo.getAddress());
|
command.setAddress(loginUserinfo.getAddress());
|
||||||
command.setRegistered(true);
|
command.setRegistered(true);
|
||||||
updateUser(command);
|
updateUser(command);
|
||||||
|
return ab98UserEntity.getAb98UserId();
|
||||||
} else {
|
} else {
|
||||||
AddAb98UserCommand command = new AddAb98UserCommand();
|
AddAb98UserCommand command = new AddAb98UserCommand();
|
||||||
command.setOpenid(openid);
|
command.setOpenid(openid);
|
||||||
|
@ -137,7 +168,77 @@ public class Ab98UserApplicationService {
|
||||||
command.setFaceImg(loginUserinfo.getFace());
|
command.setFaceImg(loginUserinfo.getFace());
|
||||||
command.setAddress(loginUserinfo.getAddress());
|
command.setAddress(loginUserinfo.getAddress());
|
||||||
command.setRegistered(true);
|
command.setRegistered(true);
|
||||||
addUser(command);
|
command.initBaseEntity();
|
||||||
|
|
||||||
|
Ab98UserModel model = userModelFactory.create();
|
||||||
|
model.loadAddCommand(command);
|
||||||
|
model.insert();
|
||||||
|
return model.getAb98UserId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bindQyUser(BindQyUserCommand bindQyUserCommand) {
|
||||||
|
QyUserEntity qyUser = qyUserService.getById(bindQyUserCommand.getQyUserId());
|
||||||
|
if (qyUser == null) {
|
||||||
|
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "企业微信用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Ab98UserEntity ab98UserEntity = userService.getByIdnum(bindQyUserCommand.getIdNum());
|
||||||
|
if (ab98UserEntity != null && StringUtils.equals(ab98UserEntity.getName(), bindQyUserCommand.getName())) {
|
||||||
|
saveQyUserInfoByAb98(qyUser, ab98UserEntity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ab98UserDto ab98UserDto = Ab98ApiUtil.pullUserInfoByIdnum("wxshop", "34164e41f0c6694be6bbbba0dc50c14a", bindQyUserCommand.getIdNum());
|
||||||
|
if (ab98UserDto == null) {
|
||||||
|
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "Ab98用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.equals(ab98UserDto.getRealName(), bindQyUserCommand.getName())) {
|
||||||
|
throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "姓名不匹配");
|
||||||
|
}
|
||||||
|
AddAb98UserCommand addAb98UserCommand = getAddAb98UserCommand(ab98UserDto);
|
||||||
|
Ab98UserModel model = userModelFactory.create();
|
||||||
|
model.loadAddCommand(addAb98UserCommand);
|
||||||
|
model.insert();
|
||||||
|
saveQyUserInfoByAb98(qyUser, model.selectById());
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static AddAb98UserCommand getAddAb98UserCommand(Ab98UserDto ab98UserDto) {
|
||||||
|
AddAb98UserCommand addAb98UserCommand = new AddAb98UserCommand();
|
||||||
|
addAb98UserCommand.setOpenid(ab98UserDto.getOpenid());
|
||||||
|
addAb98UserCommand.setUserid(ab98UserDto.getSsoUid());
|
||||||
|
addAb98UserCommand.setName(ab98UserDto.getRealName());
|
||||||
|
addAb98UserCommand.setTel(ab98UserDto.getPhone());
|
||||||
|
addAb98UserCommand.setSex(ab98UserDto.getSex());
|
||||||
|
addAb98UserCommand.setIdnum(ab98UserDto.getIdCardNo());
|
||||||
|
addAb98UserCommand.setIdcardFront(ab98UserDto.getIdCardFront());
|
||||||
|
addAb98UserCommand.setIdcardBack(ab98UserDto.getIdCardBack());
|
||||||
|
addAb98UserCommand.setFaceImg(ab98UserDto.getFacePicture());
|
||||||
|
addAb98UserCommand.setAddress(ab98UserDto.getAddress());
|
||||||
|
addAb98UserCommand.setRegistered(true);
|
||||||
|
addAb98UserCommand.initBaseEntity();
|
||||||
|
return addAb98UserCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveQyUserInfoByAb98(QyUserEntity qyUser, Ab98UserEntity ab98UserEntity) {
|
||||||
|
SysUserQyUserEntity sysUserQyUser = sysUserQyUserService.getByQyUserId(qyUser.getId());
|
||||||
|
SysUserEntity sysUser = null;
|
||||||
|
if (sysUserQyUser != null) {
|
||||||
|
sysUser = sysUserService.getById(sysUserQyUser.getSysUserId());
|
||||||
|
}
|
||||||
|
|
||||||
|
qyUser.setAb98UserId(ab98UserEntity.getAb98UserId());
|
||||||
|
qyUser.setAvatar(ab98UserEntity.getFaceImg());
|
||||||
|
qyUser.setGender(ab98UserEntity.getSex());
|
||||||
|
qyUser.setMobile(ab98UserEntity.getTel());
|
||||||
|
qyUser.updateById();
|
||||||
|
if (sysUser!= null) {
|
||||||
|
sysUser.setAvatar(ab98UserEntity.getFaceImg());
|
||||||
|
sysUser.setSex(ab98UserEntity.getSex().contains("女") ? 0 : 1);
|
||||||
|
sysUser.setPhoneNumber(ab98UserEntity.getTel());
|
||||||
|
sysUser.updateById();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.agileboot.domain.ab98.user.command;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BindQyUserCommand {
|
||||||
|
private Long qyUserId;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String idNum;
|
||||||
|
|
||||||
|
}
|
|
@ -26,5 +26,7 @@ public interface Ab98UserService extends IService<Ab98UserEntity> {
|
||||||
|
|
||||||
Ab98UserEntity getByUserid(String userid);
|
Ab98UserEntity getByUserid(String userid);
|
||||||
|
|
||||||
|
Ab98UserEntity getByIdnum(String idnum);
|
||||||
|
|
||||||
Ab98UserEntity selectByOpenidAndUserid(String openid, String userid);
|
Ab98UserEntity selectByOpenidAndUserid(String openid, String userid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.agileboot.domain.ab98.user.db;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.AbstractPageQuery;
|
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -40,6 +41,14 @@ public class Ab98UserServiceImpl extends ServiceImpl<Ab98UserMapper, Ab98UserEnt
|
||||||
return baseMapper.selectByUserid(userid);
|
return baseMapper.selectByUserid(userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Ab98UserEntity getByIdnum(String idnum) {
|
||||||
|
QueryWrapper<Ab98UserEntity> wrapper = new QueryWrapper<Ab98UserEntity>();
|
||||||
|
wrapper.eq("idnum", idnum)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
return this.getOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Ab98UserEntity selectByOpenidAndUserid(String openid, String userid) {
|
public Ab98UserEntity selectByOpenidAndUserid(String openid, String userid) {
|
||||||
return baseMapper.selectByOpenidAndUserid(openid, userid);
|
return baseMapper.selectByOpenidAndUserid(openid, userid);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.agileboot.domain.common.dto;
|
package com.agileboot.domain.common.dto;
|
||||||
|
|
||||||
|
import com.agileboot.domain.qywx.user.dto.QyUserDTO;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -14,4 +15,5 @@ public class TokenDTO {
|
||||||
|
|
||||||
private CurrentLoginUserDTO currentUser;
|
private CurrentLoginUserDTO currentUser;
|
||||||
|
|
||||||
|
private QyUserDTO qyUser;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.agileboot.common.constant.WeixinConstants;
|
||||||
import com.agileboot.common.core.page.PageDTO;
|
import com.agileboot.common.core.page.PageDTO;
|
||||||
import com.agileboot.domain.ab98.api.Ab98ApiUtil;
|
import com.agileboot.domain.ab98.api.Ab98ApiUtil;
|
||||||
import com.agileboot.domain.ab98.api.SsoLoginUserinfo;
|
import com.agileboot.domain.ab98.api.SsoLoginUserinfo;
|
||||||
|
import com.agileboot.domain.ab98.user.db.Ab98UserEntity;
|
||||||
|
import com.agileboot.domain.ab98.user.db.Ab98UserService;
|
||||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||||
import com.agileboot.domain.qywx.user.command.AddQyUserCommand;
|
import com.agileboot.domain.qywx.user.command.AddQyUserCommand;
|
||||||
import com.agileboot.domain.qywx.user.command.UpdateQyUserCommand;
|
import com.agileboot.domain.qywx.user.command.UpdateQyUserCommand;
|
||||||
|
@ -39,6 +41,7 @@ public class QyUserApplicationService {
|
||||||
private final SysUserQyUserService sysUserQyUserService;
|
private final SysUserQyUserService sysUserQyUserService;
|
||||||
private final SysUserService sysUserService;
|
private final SysUserService sysUserService;
|
||||||
private final SysRoleService sysRoleService;
|
private final SysRoleService sysRoleService;
|
||||||
|
private final Ab98UserService ab98UserService;
|
||||||
|
|
||||||
public PageDTO<QyUserDTO> getUserList(SearchQyUserQuery<QyUserEntity> query) {
|
public PageDTO<QyUserDTO> getUserList(SearchQyUserQuery<QyUserEntity> query) {
|
||||||
Page<QyUserEntity> page = userService.getUserList(query);
|
Page<QyUserEntity> page = userService.getUserList(query);
|
||||||
|
@ -60,6 +63,8 @@ public class QyUserApplicationService {
|
||||||
dto.setRoleName(sysRole.getRoleName());
|
dto.setRoleName(sysRole.getRoleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ab98UserEntity ab98User = ab98UserService.getById(user.getAb98UserId());
|
||||||
|
dto.setOpenid(ab98User.getOpenid());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,43 +104,50 @@ public class QyUserApplicationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public QyUserEntity getUserByUserId(String userid, String corpid) {
|
public List<QyUserEntity> getUserByUserId(String userid) {
|
||||||
return userService.getUserByUserId(userid, corpid);
|
return userService.getUserByUserId(userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveQyUserInfoByAb98(String userid, Ab98ApiUtil.LoginData data, SsoLoginUserinfo loginUserinfo) {
|
public QyUserEntity getUserByUserIdAndCorpid(String userid, String corpid) {
|
||||||
QyUserEntity qyUser = getUserByUserId(userid, WeixinConstants.corpid);
|
return userService.getUserByUserIdAndCorpid(userid, corpid);
|
||||||
if (qyUser == null) {
|
}
|
||||||
|
|
||||||
|
public void saveQyUserInfoByAb98(Long ab98UserId, String userid, Ab98ApiUtil.LoginData data, SsoLoginUserinfo loginUserinfo) {
|
||||||
|
List<QyUserEntity> qyUserList = getUserByUserId(userid);
|
||||||
|
if (qyUserList == null || qyUserList.isEmpty()) {
|
||||||
log.error("saveQyUserInfoByAb98: user not found for userid: {}", userid);
|
log.error("saveQyUserInfoByAb98: user not found for userid: {}", userid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SysUserQyUserEntity sysUserQyUser = sysUserQyUserService.getByQyUserId(qyUser.getId());
|
for (QyUserEntity qyUser : qyUserList) {
|
||||||
SysUserEntity sysUser = null;
|
SysUserQyUserEntity sysUserQyUser = sysUserQyUserService.getByQyUserId(qyUser.getId());
|
||||||
if (sysUserQyUser != null) {
|
SysUserEntity sysUser = null;
|
||||||
sysUser = sysUserService.getById(sysUserQyUser.getSysUserId());
|
if (sysUserQyUser != null) {
|
||||||
}
|
sysUser = sysUserService.getById(sysUserQyUser.getSysUserId());
|
||||||
|
|
||||||
if (data != null) {
|
|
||||||
qyUser.setAvatar(data.getFace_img());
|
|
||||||
qyUser.setGender(data.getSex());
|
|
||||||
qyUser.setMobile(data.getTel());
|
|
||||||
qyUser.updateById();
|
|
||||||
if (sysUser!= null) {
|
|
||||||
sysUser.setAvatar(data.getFace_img());
|
|
||||||
sysUser.setSex(data.getSex().contains("女") ? 0 : 1);
|
|
||||||
sysUser.setPhoneNumber(data.getTel());
|
|
||||||
sysUser.updateById();
|
|
||||||
}
|
}
|
||||||
} else if (loginUserinfo != null) {
|
|
||||||
qyUser.setAvatar(loginUserinfo.getFace());
|
qyUser.setAb98UserId(ab98UserId);
|
||||||
qyUser.setGender(loginUserinfo.getSex());
|
if (data != null) {
|
||||||
qyUser.setMobile(loginUserinfo.getPhone());
|
qyUser.setAvatar(data.getFace_img());
|
||||||
qyUser.updateById();
|
qyUser.setGender(data.getSex());
|
||||||
if (sysUser!= null) {
|
qyUser.setMobile(data.getTel());
|
||||||
sysUser.setAvatar(loginUserinfo.getFace());
|
qyUser.updateById();
|
||||||
sysUser.setSex(loginUserinfo.getSex().contains("女")? 0 : 1);
|
if (sysUser!= null) {
|
||||||
sysUser.setPhoneNumber(loginUserinfo.getPhone());
|
sysUser.setAvatar(data.getFace_img());
|
||||||
sysUser.updateById();
|
sysUser.setSex(data.getSex().contains("女") ? 0 : 1);
|
||||||
|
sysUser.setPhoneNumber(data.getTel());
|
||||||
|
sysUser.updateById();
|
||||||
|
}
|
||||||
|
} else if (loginUserinfo != null) {
|
||||||
|
qyUser.setAvatar(loginUserinfo.getFace());
|
||||||
|
qyUser.setGender(loginUserinfo.getSex());
|
||||||
|
qyUser.setMobile(loginUserinfo.getPhone());
|
||||||
|
qyUser.updateById();
|
||||||
|
if (sysUser!= null) {
|
||||||
|
sysUser.setAvatar(loginUserinfo.getFace());
|
||||||
|
sysUser.setSex(loginUserinfo.getSex().contains("女")? 0 : 1);
|
||||||
|
sysUser.setPhoneNumber(loginUserinfo.getPhone());
|
||||||
|
sysUser.updateById();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,10 @@ public class QyUserEntity extends BaseEntity<QyUserEntity> {
|
||||||
@TableField("userid")
|
@TableField("userid")
|
||||||
private String userid;
|
private String userid;
|
||||||
|
|
||||||
|
@ApiModelProperty("汇邦云用户id")
|
||||||
|
@TableField("ab98_user_id")
|
||||||
|
private Long ab98UserId;
|
||||||
|
|
||||||
@ApiModelProperty("成员名称")
|
@ApiModelProperty("成员名称")
|
||||||
@TableField("`name`")
|
@TableField("`name`")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -31,7 +31,14 @@ public interface QyUserMapper extends BaseMapper<QyUserEntity> {
|
||||||
"AND corpid = #{corpid}" +
|
"AND corpid = #{corpid}" +
|
||||||
"AND enable = '1'" +
|
"AND enable = '1'" +
|
||||||
"AND deleted = 0")
|
"AND deleted = 0")
|
||||||
QyUserEntity selectByUserid(@Param("userid") String userid, @Param("corpid") String corpid);
|
QyUserEntity selectByUseridAndCorpid(@Param("userid") String userid, @Param("corpid") String corpid);
|
||||||
|
|
||||||
|
@Select("SELECT * " +
|
||||||
|
"FROM qy_user " +
|
||||||
|
"WHERE userid = #{userid} " +
|
||||||
|
"AND enable = '1'" +
|
||||||
|
"AND deleted = 0")
|
||||||
|
List<QyUserEntity> selectByUserid(@Param("userid") String userid);
|
||||||
|
|
||||||
@Select("SELECT DISTINCT qu.userid " +
|
@Select("SELECT DISTINCT qu.userid " +
|
||||||
"FROM qy_user qu " +
|
"FROM qy_user qu " +
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.agileboot.domain.qywx.user.db;
|
package com.agileboot.domain.qywx.user.db;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.AbstractPageQuery;
|
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
|
import com.agileboot.domain.ab98.user.db.Ab98UserEntity;
|
||||||
import com.agileboot.domain.qywx.user.dto.QyUserStatsDTO;
|
import com.agileboot.domain.qywx.user.dto.QyUserStatsDTO;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
@ -22,7 +23,9 @@ public interface QyUserService extends IService<QyUserEntity> {
|
||||||
|
|
||||||
List<QyUserEntity> selectAll();
|
List<QyUserEntity> selectAll();
|
||||||
|
|
||||||
QyUserEntity getUserByUserId(String userid, String corpid);
|
List<QyUserEntity> getUserByUserId(String userid);
|
||||||
|
|
||||||
|
QyUserEntity getUserByUserIdAndCorpid(String userid, String corpid);
|
||||||
|
|
||||||
List<String> selectAdminUserIds();
|
List<String> selectAdminUserIds();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
package com.agileboot.domain.qywx.user.db;
|
package com.agileboot.domain.qywx.user.db;
|
||||||
|
|
||||||
|
import com.agileboot.common.exception.ApiException;
|
||||||
|
import com.agileboot.common.exception.error.ErrorCode;
|
||||||
|
import com.agileboot.domain.ab98.user.db.Ab98UserEntity;
|
||||||
import com.agileboot.domain.qywx.user.dto.QyUserStatsDTO;
|
import com.agileboot.domain.qywx.user.dto.QyUserStatsDTO;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserEntity;
|
||||||
|
import com.agileboot.domain.qywx.userQySys.db.SysUserQyUserMapper;
|
||||||
|
import com.agileboot.domain.system.user.db.SysUserEntity;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +45,13 @@ public class QyUserServiceImpl extends ServiceImpl<QyUserMapper, QyUserEntity> i
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QyUserEntity getUserByUserId(String userid, String corpid) {
|
public List<QyUserEntity> getUserByUserId(String userid) {
|
||||||
return baseMapper.selectByUserid(userid, corpid);
|
return baseMapper.selectByUserid(userid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QyUserEntity getUserByUserIdAndCorpid(String userid, String corpid) {
|
||||||
|
return baseMapper.selectByUseridAndCorpid(userid, corpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,6 +43,12 @@ public class QyUserDTO {
|
||||||
@ExcelColumn(name = "企业用户ID")
|
@ExcelColumn(name = "企业用户ID")
|
||||||
private String userid;
|
private String userid;
|
||||||
|
|
||||||
|
@ExcelColumn(name = "汇邦云用户ID")
|
||||||
|
private Long ab98UserId;
|
||||||
|
|
||||||
|
@ExcelColumn(name = "微信openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
@ExcelColumn(name = "用户姓名")
|
@ExcelColumn(name = "用户姓名")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class ReturnApprovalApplicationService {
|
||||||
try {
|
try {
|
||||||
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid("QWTONG_YS_WXSHOP", WeixinConstants.corpid);
|
QyAccessTokenEntity accessToken = accessTokenApplicationService.getByAppid("QWTONG_YS_WXSHOP", WeixinConstants.corpid);
|
||||||
String userid = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), orderModel.getOpenid()).getUserid();
|
String userid = QywxApiUtil.convertToUserid(accessToken.getAccessToken(), orderModel.getOpenid()).getUserid();
|
||||||
QyUserEntity qyUser = userService.getUserByUserId(userid, WeixinConstants.corpid);
|
QyUserEntity qyUser = userService.getUserByUserIdAndCorpid(userid, WeixinConstants.corpid);
|
||||||
if (null != qyUser) {
|
if (null != qyUser) {
|
||||||
qyUser.setBalance(qyUser.getBalance().add(command.getReturnAmount()));
|
qyUser.setBalance(qyUser.getBalance().add(command.getReturnAmount()));
|
||||||
qyUser.setUseBalance(qyUser.getUseBalance().subtract(command.getReturnAmount()));
|
qyUser.setUseBalance(qyUser.getUseBalance().subtract(command.getReturnAmount()));
|
||||||
|
@ -204,7 +204,7 @@ public class ReturnApprovalApplicationService {
|
||||||
if (StringUtils.isNotBlank(command.getAuditName())) {
|
if (StringUtils.isNotBlank(command.getAuditName())) {
|
||||||
model.setAuditName(command.getAuditName());
|
model.setAuditName(command.getAuditName());
|
||||||
} else if (StringUtils.isNotBlank(command.getUserid())) {
|
} else if (StringUtils.isNotBlank(command.getUserid())) {
|
||||||
QyUserEntity qyUserEntity = qyUserService.getUserByUserId(command.getUserid(), WeixinConstants.corpid);
|
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), WeixinConstants.corpid);
|
||||||
if (null != qyUserEntity) {
|
if (null != qyUserEntity) {
|
||||||
model.setAuditName(qyUserEntity.getName());
|
model.setAuditName(qyUserEntity.getName());
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ public class ReturnApprovalApplicationService {
|
||||||
|
|
||||||
// 审批人信息
|
// 审批人信息
|
||||||
if (StringUtils.isNotBlank(command.getUserid())) {
|
if (StringUtils.isNotBlank(command.getUserid())) {
|
||||||
QyUserEntity qyUserEntity = qyUserService.getUserByUserId(command.getUserid(), WeixinConstants.corpid);
|
QyUserEntity qyUserEntity = qyUserService.getUserByUserIdAndCorpid(command.getUserid(), WeixinConstants.corpid);
|
||||||
if (null != qyUserEntity) {
|
if (null != qyUserEntity) {
|
||||||
model.setAuditName(qyUserEntity.getName());
|
model.setAuditName(qyUserEntity.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class OrderApplicationService {
|
||||||
|
|
||||||
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), paymentResponse, BigDecimal.valueOf(0));
|
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), paymentResponse, BigDecimal.valueOf(0));
|
||||||
} else if (Objects.equals(command.getPaymentType(), "balance")) {
|
} else if (Objects.equals(command.getPaymentType(), "balance")) {
|
||||||
QyUserEntity qyUser = userService.getUserByUserId(command.getUserid(), command.getCorpid());
|
QyUserEntity qyUser = userService.getUserByUserIdAndCorpid(command.getUserid(), command.getCorpid());
|
||||||
// 余额不足
|
// 余额不足
|
||||||
if (qyUser.getBalance().compareTo(orderModel.getTotalAmount()) < 0) {
|
if (qyUser.getBalance().compareTo(orderModel.getTotalAmount()) < 0) {
|
||||||
throw new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "余额不足");
|
throw new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "余额不足");
|
||||||
|
|
|
@ -32,8 +32,12 @@ public class SearchShopOrderQuery<T> extends AbstractPageQuery<T> {
|
||||||
queryWrapper
|
queryWrapper
|
||||||
.eq(orderId != null, "o.order_id", orderId)
|
.eq(orderId != null, "o.order_id", orderId)
|
||||||
.eq(cellId != null, "og.cell_id", cellId)
|
.eq(cellId != null, "og.cell_id", cellId)
|
||||||
.eq(StrUtil.isNotBlank(openid), "o.openid", StringUtils.trim(openid))
|
.eq(StrUtil.isNotBlank(openid) && StrUtil.isBlank(userid), "o.openid", StringUtils.trim(openid))
|
||||||
.eq(StrUtil.isNotBlank(userid), "o.userid", StringUtils.trim(userid))
|
.eq(StrUtil.isNotBlank(userid) && StrUtil.isBlank(openid), "o.userid", StringUtils.trim(userid))
|
||||||
|
.or(StrUtil.isNotBlank(userid) && StrUtil.isNotBlank(openid),
|
||||||
|
qw -> qw.eq("o.openid", StringUtils.trim(openid))
|
||||||
|
.or()
|
||||||
|
.eq("o.userid", StringUtils.trim(userid)))
|
||||||
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
|
.eq(cabinetId != null, "cc.cabinet_id", cabinetId)
|
||||||
.eq(status != null, "o.status", status)
|
.eq(status != null, "o.status", status)
|
||||||
.eq(payStatus != null, "o.pay_status", payStatus)
|
.eq(payStatus != null, "o.pay_status", payStatus)
|
||||||
|
|
|
@ -12,4 +12,12 @@ AFTER `balance`;
|
||||||
|
|
||||||
ALTER TABLE `qy_user`
|
ALTER TABLE `qy_user`
|
||||||
ADD COLUMN `balance_limit` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '余额额度'
|
ADD COLUMN `balance_limit` DECIMAL(15,2) NOT NULL DEFAULT '0.00' COMMENT '余额额度'
|
||||||
AFTER `use_balance`;
|
AFTER `use_balance`;
|
||||||
|
|
||||||
|
ALTER TABLE `qy_user`
|
||||||
|
ADD COLUMN `ab98_user_id` bigint NULL COMMENT '汇邦云用户id'
|
||||||
|
AFTER `userid`;
|
||||||
|
|
||||||
|
ALTER TABLE `ab98_user`
|
||||||
|
ADD COLUMN `qy_user_id` bigint NULL COMMENT '企业用户id'
|
||||||
|
AFTER `userid`;
|
Loading…
Reference in New Issue