diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java index 31b1615..a417d75 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java @@ -10,6 +10,8 @@ import com.agileboot.common.exception.ApiException; import com.agileboot.common.exception.error.ErrorCode; import com.agileboot.common.exception.error.ErrorCode.Client; import com.agileboot.common.utils.OpenSignUtil; +import com.agileboot.domain.ab98.user.Ab98UserApplicationService; +import com.agileboot.domain.ab98.user.db.Ab98UserEntity; import com.agileboot.domain.common.dto.QyLoginDTO; import com.agileboot.domain.qywx.accessToken.AccessTokenApplicationService; import com.agileboot.domain.qywx.accessToken.db.QyAccessTokenEntity; @@ -68,6 +70,7 @@ public class PaymentController { private final MenuApplicationService menuApplicationService; private final PaymentApplicationService paymentApplicationService; private final PaymentOperationLogApplicationService paymentOperationLogApplicationService; + private final Ab98UserApplicationService ab98UserApplicationService; // 新增回调接口 /** @@ -199,8 +202,15 @@ public class PaymentController { OpenidResponse openidResponse = QywxApiUtil.convertToOpenid(qyAccessToken.getAccessToken(), userid); QyUserEntity qyUserEntity = qyUserApplicationService.getUserByUserIdAndCorpid(userid, corpid); + Ab98UserEntity ab98User = null; + if (qyUserEntity != null && qyUserEntity.getAb98UserId() != null) { + ab98User = ab98UserApplicationService.getByAb98UserId(qyUserEntity.getAb98UserId()); + } - return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, qyUserEntity.getName())); + return ResponseDTO.ok(new QyLoginDTO(userid, openidResponse.getOpenid(), isCabinetAdmin, + qyUserEntity == null ? 0 : qyUserEntity.getId(), + qyUserEntity == null ? "" : qyUserEntity.getName(), + ab98User)); } catch (RestClientException e) { log.error("qyLogin失败", e); return ResponseDTO.fail(new ApiException(ErrorCode.Client.COMMON_REQUEST_PARAMETERS_INVALID, "微信服务调用失败")); diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/WxLoginController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/WxLoginController.java index b84e124..8dce8b8 100644 --- a/agileboot-api/src/main/java/com/agileboot/api/controller/WxLoginController.java +++ b/agileboot-api/src/main/java/com/agileboot/api/controller/WxLoginController.java @@ -5,11 +5,14 @@ import com.agileboot.common.exception.ApiException; import com.agileboot.common.exception.error.ErrorCode; import com.agileboot.domain.ab98.api.SsoLoginUserinfo; import com.agileboot.domain.ab98.user.Ab98UserApplicationService; +import com.agileboot.domain.ab98.user.command.BindQyUserCommand; +import com.agileboot.domain.ab98.user.db.Ab98UserEntity; import com.agileboot.domain.qywx.user.QyUserApplicationService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import com.agileboot.domain.ab98.api.Ab98ApiUtil; @@ -25,6 +28,7 @@ import java.util.Map; public class WxLoginController { private final QyUserApplicationService qyUserApplicationService; private final Ab98UserApplicationService ab98UserApplicationService; + private final Ab98UserApplicationService userApplicationService; @PostMapping("/logout") @ApiOperation(value = "用户退出登录") @@ -152,4 +156,14 @@ public class WxLoginController { return ResponseDTO.ok(data); } + + @PostMapping("/bindQyUser") + @ApiOperation(value = "绑定汇邦云", notes = "通过姓名身份证绑定汇邦云") + public ResponseDTO 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, "参数错误")); + } + Ab98UserEntity ab98User = userApplicationService.bindQyUser(command); + return ResponseDTO.ok(ab98User); + } } diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/ab98/user/Ab98UserApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/ab98/user/Ab98UserApplicationService.java index d8df828..9377018 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/ab98/user/Ab98UserApplicationService.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/ab98/user/Ab98UserApplicationService.java @@ -177,7 +177,7 @@ public class Ab98UserApplicationService { } } - public void bindQyUser(BindQyUserCommand bindQyUserCommand) { + public Ab98UserEntity bindQyUser(BindQyUserCommand bindQyUserCommand) { QyUserEntity qyUser = qyUserService.getById(bindQyUserCommand.getQyUserId()); if (qyUser == null) { throw new ApiException(ErrorCode.Internal.INTERNAL_ERROR, "企业微信用户不存在"); @@ -186,7 +186,7 @@ public class Ab98UserApplicationService { Ab98UserEntity ab98UserEntity = userService.getByIdnum(bindQyUserCommand.getIdNum()); if (ab98UserEntity != null && StringUtils.equals(ab98UserEntity.getName(), bindQyUserCommand.getName())) { saveQyUserInfoByAb98(qyUser, ab98UserEntity); - return; + return ab98UserEntity; } Ab98UserDto ab98UserDto = Ab98ApiUtil.pullUserInfoByIdnum("wxshop", "34164e41f0c6694be6bbbba0dc50c14a", bindQyUserCommand.getIdNum()); @@ -201,7 +201,9 @@ public class Ab98UserApplicationService { Ab98UserModel model = userModelFactory.create(); model.loadAddCommand(addAb98UserCommand); model.insert(); - saveQyUserInfoByAb98(qyUser, model.selectById()); + ab98UserEntity = model.selectById(); + saveQyUserInfoByAb98(qyUser, ab98UserEntity); + return ab98UserEntity; } @NotNull diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/common/dto/QyLoginDTO.java b/agileboot-domain/src/main/java/com/agileboot/domain/common/dto/QyLoginDTO.java index 1cc3b27..ee422de 100644 --- a/agileboot-domain/src/main/java/com/agileboot/domain/common/dto/QyLoginDTO.java +++ b/agileboot-domain/src/main/java/com/agileboot/domain/common/dto/QyLoginDTO.java @@ -1,5 +1,6 @@ package com.agileboot.domain.common.dto; +import com.agileboot.domain.ab98.user.db.Ab98UserEntity; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,5 +11,8 @@ public class QyLoginDTO { private String userid; private String openid; private Integer isCabinetAdmin; + private Integer qyUserId; private String name; + + private Ab98UserEntity ab98User; }