diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index 3bc21f0..2ca87e6 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -73,11 +73,18 @@ public class MemberController { } @PostMapping("qingxuetangLogin") - @ApiOperation("轻学堂登录 手机号") + @ApiOperation("轻学堂登录 手机号mobile") public ResponseVO qingxuetangLogin(@RequestBody QingxuetangLoginDTO qingxuetangLoginDTO){ return ResponseData.generateCreatedResponse(0,memberService.qingxuetangLogin(qingxuetangLoginDTO)); } + @PostMapping("kunchiLogin") + @ApiOperation("鲲驰登陆 authCorpName 手机号mobile nickname timestamp sign") + public ResponseVO kunchiLogin(@RequestBody QingxuetangLoginDTO qingxuetangLoginDTO){ + return ResponseData.generateCreatedResponse(0,memberService.kunchiLogin(qingxuetangLoginDTO)); + } + + @PostMapping("updatePassword") @ApiOperation("修改密码 {id password}") @LoginRequired diff --git a/src/main/java/com/subsidy/service/MemberService.java b/src/main/java/com/subsidy/service/MemberService.java index b378510..374ca1c 100644 --- a/src/main/java/com/subsidy/service/MemberService.java +++ b/src/main/java/com/subsidy/service/MemberService.java @@ -37,6 +37,8 @@ public interface MemberService extends IService { UserRoleVO qingxuetangLogin(QingxuetangLoginDTO qingxuetangLoginDTO); + UserRoleVO kunchiLogin(QingxuetangLoginDTO qingxuetangLoginDTO); + String updatePassword(MemberDO memberDO); MemberStudyPageVO studyPage(MemberDO memberDO); diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index da449c4..2f85373 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -63,6 +63,7 @@ import java.time.Duration; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -469,6 +470,13 @@ public class MemberServiceImpl extends ServiceImpl imple return null; } +// 9a79cda9ef6f4a52a8 +// 552a4147db2d4026bc4e9021acd614f8 + public static void main(String[] args) { + String uuid = UUID.randomUUID().toString().replace("-",""); + System.out.println(uuid); + } + public UserRoleVO qingxuetangLogin(QingxuetangLoginDTO qingxuetangLoginDTO) { UserRoleVO userRoleVO = new UserRoleVO(); @@ -539,15 +547,100 @@ public class MemberServiceImpl extends ServiceImpl imple throw new HttpException(10013); } - //是否登陆过 1:是 0:否 - if (0 == memberDO.getFirstLogin()) { +// //是否登陆过 1:是 0:否 +// if (0 == memberDO.getFirstLogin()) { +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictMapper.insert(oprMemDictDO); +// throw new HttpException(10015); +// } + BeanUtils.copyProperties(memberDO, userRoleVO); + + //审计日志 + OprMemDictDO oprMemDictDO = new OprMemDictDO(); + oprMemDictDO.setUserId(memberDO.getId()); + oprMemDictDO.setOprType("登录"); + oprMemDictDO.setResult(1); + oprMemDictMapper.insert(oprMemDictDO); + userRoleVO.setCompanyId(companyDictDO.getId()); + userRoleVO.setCompanyName(companyDictDO.getCompanyName()); + userRoleVO.setLogo(companyDictDO.getLogo()); + List rotationImgDictDOS = rotationImgDictMapper.selectList(new QueryWrapper() + .lambda() + .eq(RotationImgDictDO::getCompanyId, companyDictDO.getId())); + userRoleVO.setRotationImgDictDOS(rotationImgDictDOS); + String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE); + redisUtil.set(ConstantUtils.MOBILE_TERMINATE + "_" + memberDO.getId(), token); + userRoleVO.setToken(token); + return userRoleVO; + } + + public UserRoleVO kunchiLogin(QingxuetangLoginDTO qingxuetangLoginDTO){ + + UserRoleVO userRoleVO = new UserRoleVO(); + +// appId:9a79cda9ef6f4a52a8 +// appSecret:552a4147db2d4026bc4e9021acd614f8 + MemberDO memberDO = this.baseMapper.selectOne(new QueryWrapper() + .lambda() + .eq(MemberDO::getTelephone, qingxuetangLoginDTO.getMobile())); + + if (memberDO == null) { + throw new HttpException(10010); + } + + /** + * 时间戳有没有过期 + */ + if (qingxuetangLoginDTO.getTimestamp()-System.currentTimeMillis()>=5*60*1000 || System.currentTimeMillis()-qingxuetangLoginDTO.getTimestamp()>=5*60*1000){ + OprMemDictDO oprMemDictDO = new OprMemDictDO(); + oprMemDictDO.setUserId(memberDO.getId()); + oprMemDictDO.setOprType("登录"); + oprMemDictDO.setResult(0); + oprMemDictMapper.insert(oprMemDictDO); + throw new HttpException(14002); + } + + //鉴权逻辑 对不对 + String preAuthen = "appId=9a79cda9ef6f4a52a8" + +"&authCorpName="+ qingxuetangLoginDTO.getAuthCorpName() + +"&mobile="+qingxuetangLoginDTO.getMobile() + +"&nickname="+qingxuetangLoginDTO.getNickname() + +"×tamp="+qingxuetangLoginDTO.getTimestamp() + +"&appSecret=552a4147db2d4026bc4e9021acd614f8" ; + + String result = SecretUtils.getMD5String(preAuthen); + if (!qingxuetangLoginDTO.getSign().equals(result)){ OprMemDictDO oprMemDictDO = new OprMemDictDO(); oprMemDictDO.setUserId(memberDO.getId()); oprMemDictDO.setOprType("登录"); oprMemDictDO.setResult(0); oprMemDictMapper.insert(oprMemDictDO); - throw new HttpException(10015); + throw new HttpException(14001); } + + CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); + + if ("冻结".equals(memberDO.getStatus())) { + OprMemDictDO oprMemDictDO = new OprMemDictDO(); + oprMemDictDO.setUserId(memberDO.getId()); + oprMemDictDO.setOprType("登录"); + oprMemDictDO.setResult(0); + oprMemDictMapper.insert(oprMemDictDO); + throw new HttpException(10013); + } + +// //是否登陆过 1:是 0:否 +// if (0 == memberDO.getFirstLogin()) { +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictMapper.insert(oprMemDictDO); +// throw new HttpException(10015); +// } BeanUtils.copyProperties(memberDO, userRoleVO); //审计日志 diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index 0a59e39..77cc3af 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -67,60 +67,66 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl() - .lambda() - .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); - - if (classHourDictDO.getStatus() == 1) { - //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); - - //是否超过时长 没超过 false 超过 true - if (total + vodPlayHistoryDO.getPlayLength() >= classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour() * 3600 - total; - vodPlayHistoryDO.setPlayLength(playLength); - this.baseMapper.insert(vodPlayHistoryDO); - throw new HttpException(13001); + + if (vodPlayHistoryDO.getPlayLength()>3){ + MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); + //查看系统设定的时长 + ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); + + if (classHourDictDO.getStatus() == 1) { + //查看当天这个人看了多少时间 + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); + + //是否超过时长 没超过 false 超过 true + if (total + vodPlayHistoryDO.getPlayLength() >= classHourDictDO.getClassHour() * 3600) { + int playLength = classHourDictDO.getClassHour() * 3600 - total; + vodPlayHistoryDO.setPlayLength(playLength); + this.baseMapper.insert(vodPlayHistoryDO); + throw new HttpException(13001); + } } + vodPlayHistoryDO.setPlayCount(1); + this.baseMapper.insert(vodPlayHistoryDO); } - vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); return ConstantUtils.ADD_SUCCESS; } public String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO) { - //对比redis上的token - String token = redisUtil.get("mobile_"+insertHistoryNewDTO.getMemberId()).toString(); - if (!insertHistoryNewDTO.getToken().equals(token)){ - throw new HttpException(1010); - } + if (insertHistoryNewDTO.getPlayLength()>3){ + //对比redis上的token + String token = redisUtil.get("mobile_"+insertHistoryNewDTO.getMemberId()).toString(); + if (!insertHistoryNewDTO.getToken().equals(token)){ + throw new HttpException(1010); + } - VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); - BeanUtils.copyProperties(insertHistoryNewDTO,vodPlayHistoryDO); + VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); + BeanUtils.copyProperties(insertHistoryNewDTO,vodPlayHistoryDO); - MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); - //查看系统设定的时长 - ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() - .lambda() - .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); - - if (classHourDictDO.getStatus() == 1) { - //查看当天这个人看了多少时间 - Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); - - //是否超过时长 没超过 false 超过 true - if (total + vodPlayHistoryDO.getPlayLength() >= classHourDictDO.getClassHour() * 3600) { - int playLength = classHourDictDO.getClassHour() * 3600 - total; - vodPlayHistoryDO.setPlayLength(playLength); - this.baseMapper.insert(vodPlayHistoryDO); - throw new HttpException(13001); + MemberDO memberDO = memberMapper.selectById(vodPlayHistoryDO.getMemberId()); + //查看系统设定的时长 + ClassHourDictDO classHourDictDO = classHourDictMapper.selectOne(new QueryWrapper() + .lambda() + .eq(ClassHourDictDO::getCompanyId, memberDO.getCompanyId())); + + if (classHourDictDO.getStatus() == 1) { + //查看当天这个人看了多少时间 + Integer total = vodPlayHistoryMapper.memberDailyStudyLength(memberDO.getId()); + + //是否超过时长 没超过 false 超过 true + if (total + vodPlayHistoryDO.getPlayLength() >= classHourDictDO.getClassHour() * 3600) { + int playLength = classHourDictDO.getClassHour() * 3600 - total; + vodPlayHistoryDO.setPlayLength(playLength); + this.baseMapper.insert(vodPlayHistoryDO); + throw new HttpException(13001); + } } + vodPlayHistoryDO.setPlayCount(1); + this.baseMapper.insert(vodPlayHistoryDO); } - vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); + return ConstantUtils.ADD_SUCCESS; } @@ -615,10 +621,14 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl testPlays(){ - List memberDOS = memberMapper.selectList(null); + List classMemberMappingDOS = classMemberMappingMapper.selectList(new QueryWrapper() + .lambda() + .eq(ClassMemberMappingDO::getClassId,168)); + +// List memberDOS = memberMapper.selectList(null); List result = new ArrayList<>(); - for (MemberDO memberDO : memberDOS){ - List vodPlayStateVOS = vodDictMapper.testPlays(memberDO.getId()); + for (ClassMemberMappingDO classMemberMappingDO : classMemberMappingDOS){ + List vodPlayStateVOS = vodDictMapper.testPlays(classMemberMappingDO.getMemberId()); for (int i = 0 ; i < vodPlayStateVOS.size() ; i ++){ for ( int k = i+1 ; k < vodPlayStateVOS.size() ; k ++){ VodPlayStateVO vodPlayStateVO = vodPlayStateVOS.get(k); diff --git a/src/main/java/com/subsidy/util/SMSUtils.java b/src/main/java/com/subsidy/util/SMSUtils.java index a1883a2..6a8c408 100644 --- a/src/main/java/com/subsidy/util/SMSUtils.java +++ b/src/main/java/com/subsidy/util/SMSUtils.java @@ -52,7 +52,7 @@ public class SMSUtils { //必填:短信签名-可在短信控制台中找到 request.setSignName("有课互联"); //必填:短信模板-可在短信控制台中找到 - request.setTemplateCode("SMS_229640297"); + request.setTemplateCode("SMS_190945394"); //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 request.setTemplateParam("{\"code\":\""+ code +"\"}");