Merge remote-tracking branch 'origin/master' into dev-chenjiajian

This commit is contained in:
嘉多宝宝 2026-01-20 14:16:53 +08:00
commit 7068df5eda
17 changed files with 111 additions and 37 deletions

View File

@ -12,7 +12,7 @@ import com.seer.teach.mp.admin.service.IAdminActivityService;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
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;
@ -37,7 +37,7 @@ public class AdminActivityServiceImpl implements IAdminActivityService {
private final IMpActivityService agentActivityService; private final IMpActivityService agentActivityService;
private final IMpAgentActivityParticipantService agentActivityParticipantService; private final IMpAgentActivityRelationService agentActivityParticipantService;
@Override @Override
public PageListBean<AdminActivityResp> pageList(MpActivityQueryReq query) { public PageListBean<AdminActivityResp> pageList(MpActivityQueryReq query) {

View File

@ -19,7 +19,7 @@ import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.entity.MpAgentEntity; import com.seer.teach.mp.entity.MpAgentEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
import com.seer.teach.mp.service.IMpAgentService; import com.seer.teach.mp.service.IMpAgentService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -39,7 +39,7 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class AdminAgentActivityRelationServiceImpl implements IAdminAgentActivityRelationService { public class AdminAgentActivityRelationServiceImpl implements IAdminAgentActivityRelationService {
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService; private final IMpAgentActivityRelationService mpAgentActivityParticipantService;
private final IMpAgentService mpAgentService; private final IMpAgentService mpAgentService;

View File

@ -52,7 +52,6 @@ public class AppAgentActivityRelationController {
@PostMapping("/qrcode") @PostMapping("/qrcode")
@SaCheckPermission("mp:app:agent:activity:qrcode") @SaCheckPermission("mp:app:agent:activity:qrcode")
public ResultBean<String> getQrCode(@RequestBody AppMpAgentActivityQrCodeQueryReq req) { public ResultBean<String> getQrCode(@RequestBody AppMpAgentActivityQrCodeQueryReq req) {
Integer userId = StpUtil.getLoginIdAsInt(); return ResultBean.success(agentActivityParticipantService.getQrCode(req));
return ResultBean.success(agentActivityParticipantService.getQrCode(req,userId));
} }
} }

View File

@ -31,7 +31,10 @@ public class AppParentAgentActivityController {
@SaCheckLogin @SaCheckLogin
@Operation(summary = "家长报名参加代理商活动") @Operation(summary = "家长报名参加代理商活动")
public ResultBean<Boolean> signUpForActivity(@RequestBody @Validated AppMpSignUpActivityReq request) { public ResultBean<Boolean> signUpForActivity(@RequestBody @Validated AppMpSignUpActivityReq request) {
Integer parentId = StpUtil.getLoginIdAsInt(); Integer parentId = 0;
if (StpUtil.isLogin()) {
parentId = StpUtil.getLoginIdAsInt();
}
return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId)); return ResultBean.success(appParentAgentActivityService.signUpForActivityWithInfo(request, parentId));
} }
@ -74,4 +77,5 @@ public class AppParentAgentActivityController {
Integer parentId = StpUtil.getLoginIdAsInt(); Integer parentId = StpUtil.getLoginIdAsInt();
return ResultBean.success(appParentAgentActivityService.getChildCharacter(parentId)); return ResultBean.success(appParentAgentActivityService.getChildCharacter(parentId));
} }
} }

View File

@ -34,7 +34,7 @@ public class AppParentAgentActivityService implements IAppParentAgentActivitySer
private final IMpAgentService agentService; private final IMpAgentService agentService;
private final IMpAgentActivityParticipantService mpAgentActivityParticipantService; private final IMpAgentActivityRelationService mpAgentActivityParticipantService;
private final AiModelCallService aiModelCallService; private final AiModelCallService aiModelCallService;

View File

@ -28,8 +28,7 @@ public interface IAppAgentActivityParticipantService {
* 获取二维码 * 获取二维码
* *
* @param req 请求参数 * @param req 请求参数
* @param userId 用户Id
* @return 二维码的url * @return 二维码的url
*/ */
String getQrCode(AppMpAgentActivityQrCodeQueryReq req, Integer userId); String getQrCode(AppMpAgentActivityQrCodeQueryReq req);
} }

View File

@ -5,21 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seer.teach.common.PageListBean; import com.seer.teach.common.PageListBean;
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.PageConverterUtils; import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.mp.app.controller.req.AppActivityQueryReq; import com.seer.teach.mp.app.controller.req.AppActivityQueryReq;
import com.seer.teach.mp.app.controller.req.MpGenerateQrCodeReq;
import com.seer.teach.mp.app.controller.resp.AppActivityResp; import com.seer.teach.mp.app.controller.resp.AppActivityResp;
import com.seer.teach.mp.app.controller.resp.MpQrCodeResp;
import com.seer.teach.mp.app.convert.AppAgentActivityConvert; import com.seer.teach.mp.app.convert.AppAgentActivityConvert;
import com.seer.teach.mp.app.service.AppOfficialQrCodeService; import com.seer.teach.mp.app.service.AppOfficialQrCodeService;
import com.seer.teach.mp.app.service.IAppActivityService; import com.seer.teach.mp.app.service.IAppActivityService;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
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;
@ -44,7 +38,7 @@ public class AppActivityServiceImpl implements IAppActivityService {
private final AppOfficialQrCodeService officialQrCodeService; private final AppOfficialQrCodeService officialQrCodeService;
private final IMpAgentActivityParticipantService agentActivityParticipantService; private final IMpAgentActivityRelationService agentActivityParticipantService;
@Override @Override
public PageListBean<AppActivityResp> pageList(AppActivityQueryReq query, Integer agentId) { public PageListBean<AppActivityResp> pageList(AppActivityQueryReq query, Integer agentId) {

View File

@ -16,7 +16,7 @@ import com.seer.teach.mp.app.service.IAppAgentService;
import com.seer.teach.mp.entity.MpActivityEntity; import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
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;
@ -44,7 +44,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivityParticipantService { public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivityParticipantService {
private final IMpAgentActivityParticipantService agentActivityParticipantService; private final IMpAgentActivityRelationService agentActivityParticipantService;
private final IAppAgentService appAgentService; private final IAppAgentService appAgentService;
@ -80,15 +80,17 @@ public class AppAgentActivityParticipantServiceImpl implements IAppAgentActivity
} }
@Override @Override
public String getQrCode(AppMpAgentActivityQrCodeQueryReq req, Integer userId) { public String getQrCode(AppMpAgentActivityQrCodeQueryReq req) {
Integer activityId = req.getActivityId(); Integer activityId = req.getActivityId();
Integer agentId = req.getAgentId(); Integer agentId = req.getAgentId();
log.info("getQrCode param activityId:{},agentId:{}", activityId, agentId); log.info("getQrCode param activityId:{},agentId:{}", activityId, agentId);
MpActivityEntity activity = mpActivityService.getById(activityId); MpActivityEntity activity = mpActivityService.getById(activityId);
AssertUtils.notNull(activity, ResultCodeEnum.INVALID_ACTIVITY); if(Objects.isNull(activity)){
return "";
}
if(activity.getStatus() != 1){ if(activity.getStatus() != 1){
throw new CommonException(ResultCodeEnum.INVALID_ACTIVITY); return "";
} }
MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId); MpAgentActivityParticipantEntity relation = agentActivityParticipantService.getParticipantsByActivityAndAgent(activityId, agentId);
AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY); AssertUtils.notNull(relation, ResultCodeEnum.INVALID_ACTIVITY);

View File

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

View File

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

View File

@ -4,6 +4,7 @@ import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
import com.seer.teach.mp.factory.MpServiceFactory; import com.seer.teach.mp.factory.MpServiceFactory;
import com.seer.teach.mp.handler.LocationHandler; import com.seer.teach.mp.handler.LocationHandler;
import com.seer.teach.mp.handler.MessageReceiveHandler; import com.seer.teach.mp.handler.MessageReceiveHandler;
import com.seer.teach.mp.handler.ScanHandler;
import com.seer.teach.mp.handler.SubscribeHandler; import com.seer.teach.mp.handler.SubscribeHandler;
import com.seer.teach.mp.handler.UnsubscribeHandler; import com.seer.teach.mp.handler.UnsubscribeHandler;
import com.seer.teach.mp.service.IMpAccountService; import com.seer.teach.mp.service.IMpAccountService;
@ -30,9 +31,10 @@ public class MpConfiguration {
MessageReceiveHandler messageReceiveHandler, MessageReceiveHandler messageReceiveHandler,
SubscribeHandler subscribeHandler, SubscribeHandler subscribeHandler,
UnsubscribeHandler unsubscribeHandler, UnsubscribeHandler unsubscribeHandler,
LocationHandler locationHandler) { LocationHandler locationHandler,
ScanHandler scanHandler) {
return new MpServiceFactory(redisTemplateWxRedisOps, mpAccountService,wxMpProperties, return new MpServiceFactory(redisTemplateWxRedisOps, mpAccountService,wxMpProperties,
messageReceiveHandler, subscribeHandler, unsubscribeHandler, locationHandler); messageReceiveHandler, subscribeHandler, unsubscribeHandler, locationHandler, scanHandler);
} }
} }

View File

@ -6,6 +6,7 @@ import com.google.common.collect.Maps;
import com.seer.teach.mp.entity.MpAccountEntity; import com.seer.teach.mp.entity.MpAccountEntity;
import com.seer.teach.mp.handler.LocationHandler; import com.seer.teach.mp.handler.LocationHandler;
import com.seer.teach.mp.handler.MessageReceiveHandler; import com.seer.teach.mp.handler.MessageReceiveHandler;
import com.seer.teach.mp.handler.ScanHandler;
import com.seer.teach.mp.handler.SubscribeHandler; import com.seer.teach.mp.handler.SubscribeHandler;
import com.seer.teach.mp.handler.UnsubscribeHandler; import com.seer.teach.mp.handler.UnsubscribeHandler;
import com.seer.teach.mp.service.IMpAccountService; import com.seer.teach.mp.service.IMpAccountService;
@ -51,6 +52,7 @@ public class MpServiceFactory {
private final SubscribeHandler subscribeHandler; private final SubscribeHandler subscribeHandler;
private final UnsubscribeHandler unsubscribeHandler; private final UnsubscribeHandler unsubscribeHandler;
private final LocationHandler locationHandler; private final LocationHandler locationHandler;
private final ScanHandler scanHandler;
public void init() { public void init() {
List<MpAccountEntity> accounts = mpAccountService.list(); List<MpAccountEntity> accounts = mpAccountService.list();
@ -130,7 +132,7 @@ public class MpServiceFactory {
private WxMpMessageRouter buildMpMessageRouter(WxMpService mpService) { private WxMpMessageRouter buildMpMessageRouter(WxMpService mpService) {
WxMpMessageRouter router = new WxMpMessageRouter(mpService); WxMpMessageRouter router = new WxMpMessageRouter(mpService);
// 记录所有事件的日志 // 记录所有事件的日志
router.rule().handler(messageReceiveHandler).next(); router.rule().async(true).handler(messageReceiveHandler).next();
// 关注事件 // 关注事件
router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT) router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
@ -152,6 +154,10 @@ public class MpServiceFactory {
router.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION) router.rule().async(false).msgType(WxConsts.XmlMsgType.LOCATION)
.handler(locationHandler).end(); .handler(locationHandler).end();
// 扫码事件
router.rule().async(false).msgType(WxConsts.XmlMsgType.EVENT)
.event(WxConsts.EventType.SCAN).handler(scanHandler)
.end();
return router; return router;
} }
} }

View File

@ -40,7 +40,7 @@ public class MessageReceiveHandler implements WxMpMessageHandler {
return WxMpXmlOutMessage.TEXT() return WxMpXmlOutMessage.TEXT()
.toUser(wxMessage.getFromUser()) .toUser(wxMessage.getFromUser())
.fromUser(wxMessage.getToUser()) .fromUser(wxMessage.getToUser())
.content("点击下方菜单进入seerTeach小程序") .content("欢迎使用SeerTeach AI")
.build(); .build();
} }

View File

@ -0,0 +1,68 @@
package com.seer.teach.mp.handler;
import cn.hutool.core.map.MapUtil;
import cn.hutool.http.HttpUtil;
import com.seer.teach.mp.entity.MpActivityEntity;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityRelationService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
/**
* 用户扫码处理已关注后的处理
*/
@Component
@Slf4j
public class ScanHandler implements WxMpMessageHandler {
@Autowired
private IMpAgentActivityRelationService mpAgentActivityRelationService;
@Autowired
private IMpActivityService mpActivityService;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
log.info("[handle][扫码处理,内容:{}]", wxMessage);
String eventKey = wxMessage.getEventKey();
log.info("[handle][用户({})] 获取用户二维码信息:[{}]", wxMessage.getFromUser(), eventKey);
if(StringUtils.hasText(eventKey) && eventKey.startsWith("agentId") && eventKey.contains("activityId")){
Map<String, String> paramMap = HttpUtil.decodeParamMap(eventKey, StandardCharsets.UTF_8);
Integer agentId = MapUtil.getInt(paramMap,"agentId",0);
Integer activityId = MapUtil.getInt(paramMap,"activityId",0);
if(agentId > 0 && activityId > 0){
MpAgentActivityParticipantEntity participantsByActivityAndAgent = mpAgentActivityRelationService.getParticipantsByActivityAndAgent(activityId, agentId);
MpActivityEntity activity = mpActivityService.getById(activityId);
if(Objects.nonNull(participantsByActivityAndAgent)){
WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
item.setTitle(activity.getActivityName());
item.setDescription(activity.getDescription());
item.setPicUrl(participantsByActivityAndAgent.getQrCodeUrl());
item.setUrl("https://mp.seerteach.net/login?" + eventKey);
WxMpXmlOutNewsMessage build = WxMpXmlOutMessage.NEWS()
.addArticle(item)
.toUser(wxMessage.getFromUser())
.fromUser(wxMessage.getToUser())
.build();
log.info("[handle][扫码处理,内容:{}]", build);
return build;
}
}
}
return null;
}
}

View File

@ -13,7 +13,7 @@ import java.util.List;
* @author Lingma * @author Lingma
* @since 2025-12-29 * @since 2025-12-29
*/ */
public interface IMpAgentActivityParticipantService extends IService<MpAgentActivityParticipantEntity> { public interface IMpAgentActivityRelationService extends IService<MpAgentActivityParticipantEntity> {
/** /**
* 根据活动ID和代理商ID获取参与记录 * 根据活动ID和代理商ID获取参与记录

View File

@ -10,7 +10,7 @@ import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.mapper.MpAgentActivityMapper; import com.seer.teach.mp.mapper.MpAgentActivityMapper;
import com.seer.teach.mp.service.IMpActivityService; import com.seer.teach.mp.service.IMpActivityService;
import com.seer.teach.mp.service.IMpAgentActivityLogService; import com.seer.teach.mp.service.IMpAgentActivityLogService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,7 +31,7 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, MpActivityEntity> implements IMpActivityService { public class MpActivityServiceImpl extends ServiceImpl<MpAgentActivityMapper, MpActivityEntity> implements IMpActivityService {
private final IMpAgentActivityParticipantService agentActivityParticipantService; private final IMpAgentActivityRelationService agentActivityParticipantService;
private final IMpAgentActivityLogService agentActivityLogService; private final IMpAgentActivityLogService agentActivityLogService;
@Override @Override

View File

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity; import com.seer.teach.mp.entity.MpAgentActivityParticipantEntity;
import com.seer.teach.mp.mapper.MpAgentActivityParticipantMapper; import com.seer.teach.mp.mapper.MpAgentActivityParticipantMapper;
import com.seer.teach.mp.service.IMpAgentActivityLogService; import com.seer.teach.mp.service.IMpAgentActivityLogService;
import com.seer.teach.mp.service.IMpAgentActivityParticipantService; import com.seer.teach.mp.service.IMpAgentActivityRelationService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,7 +23,7 @@ import java.util.List;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class MpAgentActivityParticipantServiceImpl extends ServiceImpl<MpAgentActivityParticipantMapper, MpAgentActivityParticipantEntity> implements IMpAgentActivityParticipantService { public class MpAgentActivityRelationServiceImpl extends ServiceImpl<MpAgentActivityParticipantMapper, MpAgentActivityParticipantEntity> implements IMpAgentActivityRelationService {
private final IMpAgentActivityLogService agentActivityLogService; private final IMpAgentActivityLogService agentActivityLogService;