| | |
| | | import com.dsh.account.util.ResultUtil; |
| | | import com.dsh.account.util.TokenUtil; |
| | | import com.dsh.account.util.ToolUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import springfox.documentation.swagger2.mappers.ModelMapper; |
| | | |
| | |
| | | @Resource |
| | | private CoursePackageClient coursePackageClient; |
| | | |
| | | /** |
| | | * 注销账号保留业务记录,但不计入后台累计用户、累计学员统计。 |
| | | */ |
| | | private List<Integer> getActiveUserIds(List<Integer> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | return Collections.singletonList(-1); |
| | | } |
| | | List<Integer> activeUserIds = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .in(TAppUser::getId, ids) |
| | | .ne(TAppUser::getState, 3)) |
| | | .stream() |
| | | .map(TAppUser::getId) |
| | | .collect(Collectors.toList()); |
| | | return activeUserIds.isEmpty() ? Collections.singletonList(-1) : activeUserIds; |
| | | } |
| | | |
| | | /** |
| | | * MyBatis-Plus 会将空集合拼成 IN (),ShardingSphere 无法解析该 SQL。 |
| | | * 空集合按无匹配用户处理,使用不可能的 ID 进行查询。 |
| | | */ |
| | | private List<Integer> normalizeQueryIds(List<Integer> ids) { |
| | | return ids == null || ids.isEmpty() ? Collections.singletonList(-1) : ids; |
| | | } |
| | | |
| | | /** |
| | | * 查询玩湃惠民卡绑定学员列表信息 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping("/base/student/getStudentByIds/{ids}") |
| | | public List<TStudent> getStudentByIds(@PathVariable("ids") String ids) { |
| | | List<TStudent> list = studentService.list(new LambdaQueryWrapper<TStudent>() |
| | | .in(TStudent::getId, Arrays.asList(ids.split(",")))); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 添加学员 |
| | |
| | | return new ArrayList<>(); |
| | | } |
| | | } |
| | | @PostMapping("/student/getStudentById") |
| | | @ResponseBody |
| | | TStudent getStudentById(Integer studentId) { |
| | | TStudent byId = studentService.getById(studentId); |
| | | return byId; |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/student/queryStudentCom") |
| | | |
| | | public List<Map<String, Object>> queryStudentCom(@RequestBody Integer id) { |
| | | |
| | | List<Map<String, Object>> list = studentService.queryCom(id); |
| | |
| | | return studentService.listOne(id); |
| | | } |
| | | |
| | | /** 仅供管理端超级管理员经受控接口查看学员完整敏感信息。 */ |
| | | @PostMapping("/internal/sensitive/student/{id}") |
| | | public Map<String, Object> sensitiveStudent(@PathVariable("id") Integer id, |
| | | @RequestHeader(value = "X-Internal-Sensitive-Access", required = false) String access) { |
| | | if (!"true".equalsIgnoreCase(access)) { |
| | | throw new IllegalStateException("Sensitive data access is restricted to the management service"); |
| | | } |
| | | TStudent student = studentService.getById(id); |
| | | if (student == null) return null; |
| | | Map<String, Object> result = new HashMap<String, Object>(); |
| | | result.put("id", student.getId()); |
| | | result.put("appUserId", student.getAppUserId()); |
| | | result.put("name", student.getName()); |
| | | result.put("phone", student.getPhone()); |
| | | result.put("idCard", student.getIdCard()); |
| | | return result; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/student/update") |
| | | public void update(@RequestBody TStudent tStudent) { |
| | | System.out.println("======tStudent======" + tStudent); |
| | | // 管理端不会回显加密手机号;空值代表未修改,必须保留数据库中的原始值。 |
| | | if (StringUtils.isEmpty(tStudent.getPhone()) && tStudent.getId() != null) { |
| | | TStudent originalStudent = studentService.getById(tStudent.getId()); |
| | | if (originalStudent != null) { |
| | | tStudent.setPhone(originalStudent.getPhone()); |
| | | } |
| | | } |
| | | studentService.updateById(tStudent); |
| | | } |
| | | |
| | |
| | | if (ids.size() == 0) { |
| | | ids.add(-1); |
| | | } |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @PostMapping("/student/getUserYYs") |
| | | @ResponseBody |
| | | public List<Integer> getUserYYs(@RequestBody Integer id) { |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId, id)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 2) |
| | | .eq(TAppUser::getAddUserId, id) |
| | | .ne(TAppUser::getState, 3)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @PostMapping("/student/getUserStore") |
| | | @ResponseBody |
| | | public List<Integer> getUserStore(@RequestBody Integer id) { |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId, id)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 3) |
| | | .eq(TAppUser::getAddUserId, id) |
| | | .ne(TAppUser::getState, 3)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @PostMapping("/student/getUserYys") |
| | | @ResponseBody |
| | | public List<Integer> getUserYys(@RequestBody Integer id) { |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId, id)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 2) |
| | | .eq(TAppUser::getAddUserId, id) |
| | | .ne(TAppUser::getState, 3)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/student/getUserPtVip") |
| | | public List<Integer> getUserPtVip() { |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip, 1)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 1) |
| | | .eq(TAppUser::getIsVip, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | return list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | } |
| | | |
| | |
| | | public HashMap<String, Object> userAndVipPt(@RequestBody Integer type) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | // 所有的 |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allUser", list.size()); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip, 1)); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 1) |
| | | .eq(TAppUser::getIsVip, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allVip", list1.size()); |
| | | |
| | | |
| | |
| | | public HashMap<String, Object> stuPt() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | // 所有的 |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .eq(TAppUser::getInsertType, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | List<Integer> collect1 = list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | if (collect1.size() == 0) { |
| | | collect1.add(-1); |
| | |
| | | @PostMapping("/student/stuYys") |
| | | public HashMap<String, Object> stuYys(@RequestBody List<Integer> ids) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TStudent> students = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, ids)); |
| | | List<Integer> activeUserIds = getActiveUserIds(ids); |
| | | List<TStudent> students = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, activeUserIds)); |
| | | map.put("allUser", students.size()); |
| | | |
| | | ArrayList<Object> integers = new ArrayList<>(); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/student/stuStores") |
| | | public HashMap<String, Object> stuStores(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | |
| | | List<TStudent> students = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, ids)); |
| | | List<Integer> activeUserIds = getActiveUserIds(ids); |
| | | List<TStudent> students = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, activeUserIds)); |
| | | map.put("allUser", students.size()); |
| | | |
| | | ArrayList<Object> integers = new ArrayList<>(); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/student/userAndVipYys") |
| | | public HashMap<String, Object> userAndVipYys(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | |
| | | // 所有的 |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .in(TAppUser::getId, ids) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allUser", list.size()); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids).eq(TAppUser::getIsVip, 1)); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .in(TAppUser::getId, ids) |
| | | .eq(TAppUser::getIsVip, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allVip", list1.size()); |
| | | |
| | | |
| | |
| | | @ResponseBody |
| | | @PostMapping("/student/userAndVipStore") |
| | | public HashMap<String, Object> userAndVipStore(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | // 所有的 |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .in(TAppUser::getId, ids) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allUser", list.size()); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids).eq(TAppUser::getIsVip, 1)); |
| | | List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>() |
| | | .in(TAppUser::getId, ids) |
| | | .eq(TAppUser::getIsVip, 1) |
| | | .ne(TAppUser::getState, 3)); |
| | | map.put("allVip", list1.size()); |
| | | |
| | | |
| | |
| | | if (ToolUtil.isNotEmpty(data)) { |
| | | String stime = data.split(" - ")[0] + " 00:00:00"; |
| | | String etime = data.split(" - ")[1] + " 23:59:59"; |
| | | vipPaymentLambdaQueryWrapper.between(VipPayment::getInsertTime, stime, etime); |
| | | vipPaymentLambdaQueryWrapper.between(VipPayment::getPayTime, stime, etime); |
| | | } |
| | | vipPaymentLambdaQueryWrapper.in(VipPayment::getAppUserId, ids); |
| | | vipPaymentLambdaQueryWrapper.eq(VipPayment::getPayStatus, 2); |
| | | vipPaymentLambdaQueryWrapper.eq(VipPayment::getState, 1); |
| | | List<VipPayment> list = vipPaymentService.list(vipPaymentLambdaQueryWrapper); |
| | | double sum = list.stream().mapToDouble(VipPayment::getAmount).sum(); |
| | | |
| | |
| | | if (ToolUtil.isNotEmpty(data)) { |
| | | String stime = data.split(" - ")[0] + " 00:00:00"; |
| | | String etime = data.split(" - ")[1] + " 23:59:59"; |
| | | rechargeRecordsLambdaQueryWrapper.between(RechargeRecords::getInsertTime, stime, etime); |
| | | rechargeRecordsLambdaQueryWrapper.between(RechargeRecords::getPayTime, stime, etime); |
| | | } |
| | | rechargeRecordsLambdaQueryWrapper.in(RechargeRecords::getAppUserId, ids); |
| | | rechargeRecordsLambdaQueryWrapper.eq(RechargeRecords::getPayStatus, 2); |
| | | rechargeRecordsLambdaQueryWrapper.eq(RechargeRecords::getState, 1); |
| | | List<RechargeRecords> list1 = rechargeRecordsService.list(rechargeRecordsLambdaQueryWrapper); |
| | | double sum1 = list1.stream().map(RechargeRecords::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).doubleValue(); |
| | | |
| | |
| | | @PostMapping("/student/queryUserAge1") |
| | | public HashMap<String, Object> queryUserAge1() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1) |
| | | .isNotNull(TAppUser::getPhone) |
| | | .ne(TAppUser::getState,3) |
| | | .isNotNull(TAppUser::getCity)); |
| | | Set<String> strings2 = new HashSet<>(list.stream().filter(e -> e.getCity().equals("[]")).collect(Collectors.groupingBy(TAppUser::getProvince)).keySet()); |
| | | List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | if (collect.size() == 0) { |
| | | collect.add(-1); |
| | | } |
| | | |
| | | |
| | | Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet(); |
| | | Set<String> strings = new HashSet<>(list.stream() |
| | | .filter(e -> !e.getCity().equals("[]") && StringUtils.hasLength(e.getCity())) |
| | | .collect(Collectors.groupingBy(TAppUser::getCity)) |
| | | .keySet()); |
| | | strings.addAll(strings2); |
| | | ArrayList<String> strings1 = new ArrayList<>(); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | |
| | | for (String string : strings) { |
| | | if (string.equals("中华人民共和国")) { |
| | | continue; |
| | | } |
| | | int a = 0; |
| | | strings1.add(string); |
| | | for (TAppUser tAppUser : list) { |
| | | if (tAppUser.getCity().equals(string)) { |
| | | if (tAppUser.getCity()!=null&&tAppUser.getCity().equals(string)) { |
| | | a++; |
| | | }else if (tAppUser.getProvince()!=null&&tAppUser.getProvince().equals(string)){ |
| | | a++; |
| | | } |
| | | } |
| | | integers.add(a); |
| | | } |
| | | |
| | | map.put("cityData", strings1); |
| | | map.put("cityNum", integers); |
| | | int age1 = 0; |
| | |
| | | |
| | | @PostMapping("/student/queryUserAgeYys") |
| | | public HashMap<String, Object> queryUserAgeYys(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids) |
| | | .isNotNull(TAppUser::getPhone) |
| | | .ne(TAppUser::getState,3) |
| | | .isNotNull(TAppUser::getCity)); |
| | | Set<String> strings2 = new HashSet<>(list.stream().filter(e -> e.getCity().equals("[]")).collect(Collectors.groupingBy(TAppUser::getProvince)).keySet()); |
| | | List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | if (collect.size() == 0) { |
| | | collect.add(-1); |
| | | } |
| | | |
| | | |
| | | Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet(); |
| | | Set<String> strings = new HashSet<>(list.stream() |
| | | .filter(e -> !e.getCity().equals("[]") && StringUtils.hasLength(e.getCity())) |
| | | .collect(Collectors.groupingBy(TAppUser::getCity)) |
| | | .keySet()); |
| | | strings.addAll(strings2); |
| | | ArrayList<String> strings1 = new ArrayList<>(); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | |
| | |
| | | int a = 0; |
| | | strings1.add(string); |
| | | for (TAppUser tAppUser : list) { |
| | | if (tAppUser.getCity().equals(string)) { |
| | | if (tAppUser.getCity()!=null&&tAppUser.getCity().equals(string)) { |
| | | a++; |
| | | }else if (tAppUser.getProvince()!=null&&tAppUser.getProvince().equals(string)){ |
| | | a++; |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping("/student/queryUserAgeStore") |
| | | public HashMap<String, Object> queryUserAgeStore(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids)); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids) |
| | | .isNotNull(TAppUser::getPhone) |
| | | .ne(TAppUser::getState,3) |
| | | .isNotNull(TAppUser::getCity)); |
| | | List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | | if (collect.size() == 0) { |
| | | collect.add(-1); |
| | | } |
| | | Set<String> strings2 = new HashSet<>(list.stream().filter(e -> e.getCity().equals("[]")).collect(Collectors.groupingBy(TAppUser::getProvince)).keySet()); |
| | | |
| | | |
| | | Set<String> strings = list.stream().collect(Collectors.groupingBy(TAppUser::getCity)).keySet(); |
| | | Set<String> strings = new HashSet<>(list.stream() |
| | | .filter(e -> !e.getCity().equals("[]") && StringUtils.hasLength(e.getCity())) |
| | | .collect(Collectors.groupingBy(TAppUser::getCity)) |
| | | .keySet()); |
| | | strings.addAll(strings2); |
| | | ArrayList<String> strings1 = new ArrayList<>(); |
| | | ArrayList<Integer> integers = new ArrayList<>(); |
| | | |
| | |
| | | int a = 0; |
| | | strings1.add(string); |
| | | for (TAppUser tAppUser : list) { |
| | | if (tAppUser.getCity().equals(string)) { |
| | | if (tAppUser.getCity()!=null&&tAppUser.getCity().equals(string)) { |
| | | a++; |
| | | }else if (tAppUser.getProvince()!=null&&tAppUser.getProvince().equals(string)){ |
| | | a++; |
| | | } |
| | | } |
| | |
| | | |
| | | @PostMapping("/student/queryUserAgeYys1") |
| | | public HashMap<String, Object> queryUserAgeYys1(@RequestBody List<Integer> ids) { |
| | | ids = normalizeQueryIds(ids); |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().in(TAppUser::getId, ids)); |
| | | List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList()); |
| | |
| | | map.put("boy", boy); |
| | | map.put("girl", girl); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/student/queryExpiredList") |
| | | public List<TStudent> queryExpiredList(){ |
| | | List<TStudent> list = studentService.list(new QueryWrapper<TStudent>().eq("state", 1).last(" and DATE_FORMAT(now(), '%Y-%m-%d') > validity")); |
| | | return list; |
| | | } |
| | | } |