增加服务号的扫描后自动回复消息的功能

This commit is contained in:
Wang 2026-01-21 09:53:59 +08:00
parent 3477ca2eaf
commit a09c3224ed
21 changed files with 323 additions and 45 deletions

View File

@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.SERVER_NAME, contextId = "wechatMiniProgramApi", path = "/seer/mp")
public interface WechatMiniProgramApi {
public interface MpMiniProgramApi {
@GetMapping("/wechat/sns/jscode2session")
WxMiniProgramSessionDTO code2Session(@RequestParam("code") String code);

View File

@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = ApiConstants.SERVER_NAME, contextId = "wechatOfficialAccountApi", path = "/seer/mp")
public interface WechatOfficialAccountApi {
public interface MpOfficialAccountApi {
/**
* 获取用户用户信息和授权 Token

View File

@ -0,0 +1,77 @@
package com.seer.teach.mp.admin.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean;
import com.seer.teach.mp.admin.controller.req.MpAccountPageReq;
import com.seer.teach.mp.admin.controller.req.MpAccountReq;
import com.seer.teach.mp.admin.controller.resp.AdminMpAccountResp;
import com.seer.teach.mp.admin.service.AdminMpAccountMenuService;
import com.seer.teach.mp.admin.service.AdminMpAccountService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 公众号菜单表 前端控制器
* </p>
*
* @author Wang
* @since 2025-08-02 15:45:13
*/
@Tag(name = "管理端 - 公众号菜单")
@RequiredArgsConstructor
@RestController
@RequestMapping("/mp/account")
public class AdminMpAccountMenuController {
private final AdminMpAccountMenuService adminMpAccountMenuService;
@PostMapping("/create/menu")
@Operation(summary = "创建公众号菜单")
@SaCheckPermission("admin:mp:account:menu:create")
public ResultBean<Boolean> createAccountMenu(@Valid @RequestBody MpAccountReq createReqVO) {
return ResultBean.success(adminMpAccountMenuService.createAccount(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新公众号菜单")
@SaCheckPermission("admin:mp:account:menu:update")
public ResultBean<Boolean> updateAccountMenu(@Valid @RequestBody MpAccountReq updateReqVO) {
return ResultBean.success(adminMpAccountMenuService.updateAccount(updateReqVO));
}
@DeleteMapping("/delete")
@Operation(summary = "删除公众号菜单")
@SaCheckPermission("admin:mp:account:menu:delete")
public ResultBean<Boolean> deleteAccountMenu(@RequestParam("id") Integer id) {
return ResultBean.success(adminMpAccountMenuService.deleteAccount(id));
}
@GetMapping("/detail")
@Operation(summary = "获得公众号菜单")
@SaCheckPermission("admin:mp:account:menu:query")
public ResultBean<AdminMpAccountResp> getAccountMenu(@RequestParam("id") Integer id) {
return ResultBean.success(adminMpAccountMenuService.getAccount(id));
}
@GetMapping("/list")
@Operation(summary = "获取公众号菜单信息列表")
@SaCheckPermission("admin:mp:account:menu:list")
public ResultBean<List<AdminMpAccountResp>> getAccountMenuList() {
return ResultBean.success(adminMpAccountMenuService.getAccountList());
}
}

View File

@ -11,6 +11,6 @@ public class MpActivityQueryReq extends PageRequest {
@Schema(description = "活动名称")
private String activityName;
@Schema(description = "活动状态:0-禁用1-启用")
@Schema(description = "活动状态:-1-未开始1-进行中2-已结束")
private Integer status;
}

View File

@ -0,0 +1,161 @@
package com.seer.teach.mp.admin.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.mp.admin.controller.req.MpAccountPageReq;
import com.seer.teach.mp.admin.controller.req.MpAccountReq;
import com.seer.teach.mp.admin.controller.resp.AdminMpAccountResp;
import com.seer.teach.mp.admin.convert.AdminMpAccountConvert;
import com.seer.teach.mp.api.MpOfficialAccountApi;
import com.seer.teach.mp.entity.MpAccountEntity;
import com.seer.teach.mp.factory.MpServiceFactory;
import com.seer.teach.mp.service.IMpAccountService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
@RequiredArgsConstructor
@Slf4j
@Validated
@Service
public class AdminMpAccountMenuService {
private final IMpAccountService mpAccountService;
private final MpOfficialAccountApi mpOfficialAccountApi;
@Resource
@Lazy
private MpServiceFactory mpServiceFactory;
public void loadCache() {
mpServiceFactory.init();
mpOfficialAccountApi.initMpAccountCache();
}
/**
* 创建公众号账号
*
* @param createReqVO 创建信息
* @return 公众号账号ID
*/
public boolean createAccount(@Valid MpAccountReq createReqVO) {
MpAccountEntity mpAccount = AdminMpAccountConvert.INSTANCE.convertOne(createReqVO);
boolean result = mpAccountService.save(mpAccount);
log.info("[createAccount][创建公众号账号成功,结果为:{}]", result);
loadCache();
log.info("[createAccount][刷新公众号緩存成功]");
return result;
}
/**
* 更新公众号账号
*
* @param updateReqVO 更新信息
* @return 是否更新成功
*/
public Boolean updateAccount(@Valid MpAccountReq updateReqVO) {
MpAccountEntity mpAccount = AdminMpAccountConvert.INSTANCE.convertOne(updateReqVO);
boolean updated = mpAccountService.updateById(mpAccount);
log.info("[updateAccount][更新公众号账号成功,结果为:{}]", updated);
loadCache();
log.info("[updateAccount][刷新公众号緩存成功]");
return updated;
}
/**
* 删除公众号账号
*
* @param id 公众号账号ID
* @return 是否删除成功
*/
public Boolean deleteAccount(Integer id) {
boolean removed = mpAccountService.removeById(id);
log.info("[deleteAccount][删除公众号账号成功,结果为:{}]", removed);
loadCache();
log.info("[deleteAccount][刷新公众号緩存成功]");
return removed;
}
/**
* 获取公众号账号详情
*
* @param id 公众号账号ID
* @return 公众号账号信息
*/
public AdminMpAccountResp getAccount(Integer id) {
MpAccountEntity mpAccount = mpAccountService.getById(id);
return AdminMpAccountConvert.INSTANCE.convertOne(mpAccount);
}
/**
* 分页获取公众号账号列表
*
* @param pageReq 分页查询条件
* @return 公众号账号分页结果
*/
public PageListBean<AdminMpAccountResp> getAccountPage(MpAccountPageReq pageReq) {
Page<MpAccountEntity> pageParm = new Page<>(pageReq.getPageNo(), pageReq.getPageSize());
LambdaQueryWrapper<MpAccountEntity> wrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(pageReq.getAppId())) {
wrapper.like(MpAccountEntity::getAppId, pageReq.getAppId());
}
if (StringUtils.isNotBlank(pageReq.getName())) {
wrapper.like(MpAccountEntity::getName, pageReq.getName());
}
if (StringUtils.isNotBlank(pageReq.getAccount())) {
wrapper.like(MpAccountEntity::getAccount, pageReq.getAccount());
}
IPage<MpAccountEntity> resultPage = mpAccountService.page(pageParm, wrapper);
return PageConverterUtils.convertPageListBean(resultPage, AdminMpAccountConvert.INSTANCE::convertRespList);
}
/**
* 获取所有公众号账号列表
*
* @return 公众号账号列表
*/
public List<AdminMpAccountResp> getAccountList() {
List<MpAccountEntity> accountList = mpAccountService.list();
return AdminMpAccountConvert.INSTANCE.convertRespList(accountList);
}
/**
* 生成公众号二维码
*
* @param id 公众号账号ID
* @return 是否生成成功
*/
public Boolean generateAccountQrCode(Integer id,String sceneStr) {
MpAccountEntity account = mpAccountService.getById(id);
WxMpService mpService = mpServiceFactory.getRequiredMpService(account.getAppId());
String qrCodeUrl;
try {
WxMpQrCodeTicket qrCodeTicket = mpService.getQrcodeService().qrCodeCreateLastTicket(sceneStr);
qrCodeUrl = mpService.getQrcodeService().qrCodePictureUrl(qrCodeTicket.getTicket());
} catch (WxErrorException e) {
log.error("生成公众号二维码失败", e);
return false;
}
MpAccountEntity updateAccount = new MpAccountEntity();
updateAccount.setId(id);
updateAccount.setQrCodeUrl(qrCodeUrl);
return mpAccountService.updateById(updateAccount);
}
}

View File

@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.mp.api.WechatOfficialAccountApi;
import com.seer.teach.mp.api.MpOfficialAccountApi;
import com.seer.teach.mp.admin.controller.req.MpAccountPageReq;
import com.seer.teach.mp.admin.controller.req.MpAccountReq;
import com.seer.teach.mp.admin.controller.resp.AdminMpAccountResp;
@ -36,7 +36,7 @@ public class AdminMpAccountService {
private final IMpAccountService mpAccountService;
private final WechatOfficialAccountApi wechatOfficialAccountApi;
private final MpOfficialAccountApi mpOfficialAccountApi;
@Resource
@Lazy
@ -44,7 +44,7 @@ public class AdminMpAccountService {
public void loadCache() {
mpServiceFactory.init();
wechatOfficialAccountApi.initMpAccountCache();
mpOfficialAccountApi.initMpAccountCache();
}
/**

View File

@ -8,7 +8,7 @@ import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.annotation.LogPrint;
import com.seer.teach.mp.app.controller.req.AppMpAgentActivityQrCodeQueryReq;
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
import com.seer.teach.mp.app.service.IAppAgentActivityRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
@ -38,7 +38,7 @@ import java.util.List;
@RequiredArgsConstructor
public class AppAgentActivityRelationController {
private final IAppAgentActivityParticipantService agentActivityParticipantService;
private final IAppAgentActivityRelationService agentActivityParticipantService;
@Operation(summary = "获取代理商参加的活动列表")
@GetMapping()

View File

@ -11,6 +11,6 @@ public class AppActivityQueryReq extends PageRequest {
@Schema(description = "活动名称")
private String activityName;
@Schema(description = "活动状态:0-禁用1-启用")
@Schema(description = "活动状态:-1-未开始1-进行中2-已结束")
private Integer status;
}

View File

@ -3,6 +3,8 @@ package com.seer.teach.mp.app.controller.resp;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(name = "AgentActivityParticipant", description = "代理商活动参与记录")
@Data
public class AgentActivityParticipantResp {
@ -15,7 +17,19 @@ public class AgentActivityParticipantResp {
@Schema(description = "代理商ID")
private Integer agentId;
@Schema(description = "活动名称")
private String activityName;
@Schema(description = "活动描述")
private String description;
@Schema(description = "活动开始时间")
private LocalDateTime startTime;
@Schema(description = "活动结束时间")
private LocalDateTime endTime;
@Schema(description = "活动状态:-1-未开始1-进行中2-已结束")
private Integer status;
}

View File

@ -23,7 +23,7 @@ public class AppActivityResp {
@Schema(description = "活动结束时间")
private LocalDateTime endTime;
@Schema(description = "活动状态:0-禁用1-启用")
@Schema(description = "活动状态:-1-未开始1-进行中2-已结束")
private Integer status;
@Schema(description = "创建时间")

View File

@ -13,7 +13,7 @@ import java.util.List;
* @author Lingma
* @since 2025-12-30
*/
public interface IAppAgentActivityParticipantService {
public interface IAppAgentActivityRelationService {
/**
* 根据活动ID和代理商ID获取参与记录

View File

@ -11,7 +11,7 @@ import com.seer.teach.mp.app.controller.req.MpGenerateQrCodeReq;
import com.seer.teach.mp.app.controller.resp.AgentActivityParticipantResp;
import com.seer.teach.mp.app.controller.resp.MpQrCodeResp;
import com.seer.teach.mp.app.service.AppOfficialQrCodeService;
import com.seer.teach.mp.app.service.IAppAgentActivityParticipantService;
import com.seer.teach.mp.app.service.IAppAgentActivityRelationService;
import com.seer.teach.mp.app.service.IAppAgentService;
import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -42,9 +43,9 @@ import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivityParticipantService {
public class AppAgentActivityRelationServiceImpl implements IAppAgentActivityRelationService {
private final IMpAgentActivityRelationService agentActivityParticipantService;
private final IMpAgentActivityRelationService agentActivityRelationService;
private final IAppAgentService appAgentService;
@ -63,14 +64,14 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
if(!userAgentIds.contains(agentId) ){
throw new CommonException(ResultCodeEnum.RELATION_NOT_FOUND);
}
var participants = agentActivityParticipantService.getListByAgentId(agentId);
var participants = agentActivityRelationService.getListByAgentId(agentId);
if (CollectionUtil.isEmpty(participants)) {
return List.of();
}
Set<Integer> activityIds = participants.stream().map(MpAgentActivityParticipantEntity::getActivityId).collect(Collectors.toSet());
List<MpActivityEntity> parentInfos = mpActivityService.listByIds(activityIds);
List<MpActivityEntity> parentInfos = mpActivityService.getEffectiveActivityListByIds(activityIds);
var activityInfoMap = parentInfos.stream().collect(Collectors.toMap(MpActivityEntity::getId, activity -> activity));
@ -89,10 +90,13 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
return "";
}
if(activity.getStatus() != 1){
// 检查活动是否在有效时间内且处于启用状态
LocalDateTime now = LocalDateTime.now();
boolean isWithinTimeRange = !now.isBefore(activity.getStartTime()) && !now.isAfter(activity.getEndTime());
if(activity.getStatus() != 1 || !isWithinTimeRange){
return "";
}
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
MpAgentActivityParticipantEntity relation = agentActivityRelationService.getParticipantsByActivityAndAgent(activityId, agentId);
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);
if(StringUtils.isNotBlank(relation.getQrCodeUrl())){
return relation.getQrCodeUrl();
@ -113,7 +117,7 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
relation.setQrCodeUrl(mpQrCodeResp.getQrCodeUrl());
}
}
agentActivityParticipantService.updateById(relation);
agentActivityRelationService.updateById(relation);
return mpQrCodeResp.getQrCodeUrl();
}
@ -126,6 +130,19 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
MpActivityEntity activity = activityInfoMap.get(entity.getActivityId());
if(Objects.nonNull(activity)){
resp.setActivityName(activity.getActivityName());
resp.setDescription(activity.getDescription());
resp.setStartTime(activity.getStartTime());
resp.setEndTime(activity.getEndTime());
// 根据当前时间判断活动状态
LocalDateTime now = LocalDateTime.now();
if (now.isBefore(activity.getStartTime())) {
resp.setStatus(1); // 未开始
} else if (now.isAfter(activity.getEndTime())) {
resp.setStatus(3); // 已结束
} else {
resp.setStatus(1); // 进行中
}
}
return resp;
}

View File

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequiredArgsConstructor
@RestController
public class AppMiniProgramApiImpl implements WechatMiniProgramApi{
public class AppMiniProgramApiImpl implements MpMiniProgramApi {
private final IWechatMiniProgramService wechatMiniProgramService;

View File

@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
public class AppOfficialAccountApiImpl implements WechatOfficialAccountApi{
public class AppOfficialAccountApiImpl implements MpOfficialAccountApi {
@Autowired
private MpServiceFactory mpServiceFactory;

View File

@ -3,6 +3,7 @@ package com.seer.teach.mp.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.seer.teach.mp.entity.MpActivityEntity;
import java.util.Collection;
import java.util.List;
/**
@ -32,9 +33,11 @@ public interface IMpActivityService extends IService<MpActivityEntity> {
*/
boolean deleteActivity(Integer id);
/**
* 获取代理商活动名称列表
* @return 代理商活动名称列表
/**
* 根据ID查询代理商活动
*
* @param ids 活动ID
* @return 活动实体
*/
List<String> getActivityName();
List<MpActivityEntity> getEffectiveActivityListByIds(Collection<Integer> ids);
}

View File

@ -1,10 +1,13 @@
package com.seer.teach.mp.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.common.constants.CommonConstant;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.common.utils.CommonUtils;
import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.mapper.MpAgentActivityMapper;
@ -16,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
/**
@ -106,14 +110,16 @@ public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, Mp
}
@Override
public List<String> getActivityName() {
return this.list().stream()
.map(MpActivityEntity::getActivityName).toList();
public List<MpActivityEntity> getEffectiveActivityListByIds(Collection<Integer> ids) {
if(CollectionUtil.isEmpty(ids)){
return List.of();
}
return super.list(new LambdaQueryWrapper<MpActivityEntity>().in(MpActivityEntity::getId, ids).in(MpActivityEntity::getStatus, CommonConstant.ENABLE));
}
@Override
public boolean saveOrUpdate(MpActivityEntity entity) {
boolean result = super.saveOrUpdate(entity);
return result;
return super.saveOrUpdate(entity);
}
}

View File

@ -8,7 +8,7 @@ import com.seer.teach.common.enums.RoleEnum;
import com.seer.teach.common.enums.UserRelationEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.mp.api.WechatMiniProgramApi;
import com.seer.teach.mp.api.MpMiniProgramApi;
import com.seer.teach.mp.api.resp.WxMiniProgramSessionDTO;
import com.seer.teach.user.app.auth.LoginType;
import com.seer.teach.user.app.auth.request.LoginParam;
@ -45,7 +45,7 @@ import java.util.Objects;
public class MiniProgramLoginStrategy extends AbstractLoginStrategy implements LoginStrategy {
private final WechatMiniProgramApi wechatMiniProgramApi;
private final MpMiniProgramApi mpMiniProgramApi;
private final IUserService userService;
@ -70,7 +70,7 @@ public class MiniProgramLoginStrategy extends AbstractLoginStrategy implements L
@Override
public LoginUser authenticate(LoginParam request) {
WxMiniProgramSessionDTO wxMiniProgramSessionDTO = wechatMiniProgramApi.code2Session(request.getJsCode());
WxMiniProgramSessionDTO wxMiniProgramSessionDTO = mpMiniProgramApi.code2Session(request.getJsCode());
AssertUtils.isTrue(wxMiniProgramSessionDTO.isSuccess(), ResultCodeEnum.WX_OAUTH_USED_ERROR);
UserAuthEntity userAuth = userAuthService.getOneByOpenIdAndUnionId(wxMiniProgramSessionDTO.getOpenid(), wxMiniProgramSessionDTO.getUnionid());
boolean isExistsChildren = false;

View File

@ -2,7 +2,7 @@ package com.seer.teach.user.app.auth.service.strategy;
import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.mp.api.WechatOfficialAccountApi;
import com.seer.teach.mp.api.MpOfficialAccountApi;
import com.seer.teach.mp.api.resp.WxOAuth2AccessTokenDTO;
import com.seer.teach.user.app.auth.LoginType;
import com.seer.teach.user.app.auth.request.LoginParam;
@ -26,7 +26,7 @@ import java.util.Objects;
public class OfficialAccountLoginStrategy extends AbstractLoginStrategy implements LoginStrategy {
@Autowired
private WechatOfficialAccountApi wechatOfficialAccountApi;
private MpOfficialAccountApi mpOfficialAccountApi;
@Autowired
private IUserService userService;
@ -42,7 +42,7 @@ public class OfficialAccountLoginStrategy extends AbstractLoginStrategy implemen
@Override
public LoginUser authenticate(LoginParam request) {
log.info("微信公众号登录:{}",request);
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = wechatOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(), request.getJsCode());
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = mpOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(), request.getJsCode());
log.debug("获取用户信息:{}",wxOAuth2AccessToken);
AssertUtils.notNull(wxOAuth2AccessToken, ResultCodeEnum.WX_OAUTH_USED_ERROR);
String userOpenId = wxOAuth2AccessToken.getOpenId();

View File

@ -5,7 +5,7 @@ import com.seer.teach.common.enums.ResultCodeEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.common.utils.CommonUtils;
import com.seer.teach.mp.api.WechatOfficialAccountApi;
import com.seer.teach.mp.api.MpOfficialAccountApi;
import com.seer.teach.mp.api.resp.WxOAuth2AccessTokenDTO;
import com.seer.teach.user.app.auth.LoginType;
import com.seer.teach.user.app.auth.request.LoginParam;
@ -33,7 +33,7 @@ public class OfficialOauthWithAccountLoginStrategy extends AbstractLoginStrategy
private final IUserService userService;
@Autowired
private WechatOfficialAccountApi wechatOfficialAccountApi;
private MpOfficialAccountApi mpOfficialAccountApi;
@Override
public LoginType getType() {
@ -54,7 +54,7 @@ public class OfficialOauthWithAccountLoginStrategy extends AbstractLoginStrategy
AssertUtils.notNull(accountUser, ResultCodeEnum.USERNAME_OR_PASSWORD_IS_ERROR);
String password = CommonUtils.encryptPassword(request.getPassword());
if (password.equals(accountUser.getPassword())) {
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = wechatOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(), request.getJsCode());
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = mpOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(), request.getJsCode());
log.debug("获取用户信息:{}",wxOAuth2AccessToken);
AssertUtils.notNull(wxOAuth2AccessToken, ResultCodeEnum.WX_OAUTH_USED_ERROR);
String userOpenId = wxOAuth2AccessToken.getOpenId();

View File

@ -5,7 +5,7 @@ import com.seer.teach.common.enums.RoleEnum;
import com.seer.teach.common.exception.CommonException;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.common.utils.CommonUtils;
import com.seer.teach.mp.api.WechatOfficialAccountApi;
import com.seer.teach.mp.api.MpOfficialAccountApi;
import com.seer.teach.mp.api.resp.WxOAuth2AccessTokenDTO;
import com.seer.teach.user.app.auth.LoginType;
import com.seer.teach.user.app.auth.request.LoginParam;
@ -38,7 +38,7 @@ public class WarehouseAccountLoginStrategy extends AbstractLoginStrategy impleme
private final IUserService userService;
private final WechatOfficialAccountApi wechatOfficialAccountApi;
private final MpOfficialAccountApi mpOfficialAccountApi;
private final IUserAuthService userAuthService;
@ -68,7 +68,7 @@ public class WarehouseAccountLoginStrategy extends AbstractLoginStrategy impleme
.findAny()
.orElseThrow(() -> new CommonException(ResultCodeEnum.USER_NOT_HAVE_WAREHOUSE_ROLE));
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = wechatOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(),request.getJsCode());
WxOAuth2AccessTokenDTO wxOAuth2AccessToken = mpOfficialAccountApi.getUserWxOAuth2AccessToken(request.getAppId(),request.getJsCode());
AssertUtils.notNull(wxOAuth2AccessToken, ResultCodeEnum.WX_OAUTH_USED_ERROR);
UserAuthEntity userAuthEntity = userAuthService.getOneByOpenId(wxOAuth2AccessToken.getOpenId());
if (Objects.isNull(userAuthEntity)) {

View File

@ -6,7 +6,7 @@ import com.seer.teach.common.exception.CommonException;
import com.seer.teach.common.utils.AssertUtils;
import com.seer.teach.common.utils.CommonUtils;
import com.seer.teach.iot.api.UserDeviceServiceApi;
import com.seer.teach.mp.api.WechatMiniProgramApi;
import com.seer.teach.mp.api.MpMiniProgramApi;
import com.seer.teach.mp.api.resp.WxMiniProgramSessionDTO;
import com.seer.teach.user.app.auth.LoginType;
import com.seer.teach.user.app.auth.request.LoginParam;
@ -35,7 +35,7 @@ public class WechatChildrenAccountLoginStrategy extends AbstractLoginStrategy im
private final UserDeviceServiceApi userDeviceServiceApi;
private final WechatMiniProgramApi wechatMiniProgramApi;
private final MpMiniProgramApi mpMiniProgramApi;
private final IUserRelationService userRelationService;
@ -54,7 +54,7 @@ public class WechatChildrenAccountLoginStrategy extends AbstractLoginStrategy im
AssertUtils.notNull(accountUser, ResultCodeEnum.USERNAME_OR_PASSWORD_IS_ERROR);
String password = CommonUtils.encryptPassword(request.getPassword());
if (password.equals(accountUser.getPassword())) {
WxMiniProgramSessionDTO miniProgramSessionDTO = wechatMiniProgramApi.code2Session(request.getJsCode());
WxMiniProgramSessionDTO miniProgramSessionDTO = mpMiniProgramApi.code2Session(request.getJsCode());
AssertUtils.notNull(miniProgramSessionDTO, ResultCodeEnum.WX_SESSION_CODE_USED_ERROR);
// 使用开关控制是否检查设备绑定
if (deviceCheckEnabled) {