From ee9cb0da4a43bcf523ebb157678f64a2895fba1a Mon Sep 17 00:00:00 2001 From: nickchange <126672920+nickchange@users.noreply.github.com> Date: 星期二, 10 十月 2023 15:30:38 +0800 Subject: [PATCH] 10.10 --- cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 156 insertions(+), 3 deletions(-) diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java index 57f34a3..619ba42 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java +++ b/cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java @@ -1,6 +1,9 @@ package com.dsh.course.service.impl; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.Person; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -9,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.course.entity.*; import com.dsh.course.entity.TAppUser; +import com.dsh.course.entity.dto.StudentQeryDto; import com.dsh.course.feignclient.account.AppUserClient; import com.dsh.course.feignclient.account.CoachClient; import com.dsh.course.feignclient.account.StudentClient; @@ -34,16 +38,19 @@ import com.dsh.course.util.*; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -130,6 +137,129 @@ list.add(value); } return cpConfigMapper.changeState(list,dto.getPayUserName(),dto.getUserId()); + } + + @Override + public void updateBytime(TCoursePackagePayment coursePackagePayment) { + this.baseMapper.updateBytime(coursePackagePayment); + } + + @Override + public List<RegisterOrderVO> listAllRegister(RegisterOrderQuery query) { + String STime = null; + String ETime = null; + if (StringUtils.hasLength(query.getRegisterTime())) { + STime = query.getRegisterTime().split(" - ")[0] + " 00:00:00"; + ETime = query.getRegisterTime().split(" - ")[1] + " 23:59:59"; + } + return cpConfigMapper.listAllRegister(query,STime,ETime,query.getAmount()); + } + + @Override + public List<Map<String, Object>> getStudentTotal(StudentQeryDto studentQeryDto) { + List<Map<String, Object>> studentTotal = this.baseMapper.getStudentTotal(studentQeryDto); + + for (Map<String, Object> student : studentTotal) { + BigDecimal cashPayment = (BigDecimal) student.get("cashPayment"); + BigDecimal totalClassHours = (BigDecimal) student.get("totalClassHours"); + BigDecimal hasHours = (BigDecimal) student.get("hasHours"); + + BigDecimal hasPayment = cashPayment.divide(totalClassHours, 2, RoundingMode.HALF_UP) + .multiply(hasHours).setScale(2, RoundingMode.HALF_UP); + student.put("hasPayment", hasPayment); + + + Integer appUserId = (Integer) student.get("appUserId"); + AppUser appUser = appuClient.queryAppUser(appUserId); + student.put("province", appUser.getProvince()); + student.put("provinceCode", appUser.getProvinceCode()); + + student.put("city", appUser.getCity()); + student.put("cityCode", appUser.getCityCode()); + + Student studentId = studentClient.queryStudentById((Integer) student.get("studentId")); + student.put("studentName", studentId.getName()); + + + } + + if (studentQeryDto.getCityCode()!=null&&studentQeryDto.getCityCode()!="") { + String value = studentQeryDto.getCityCode(); + boolean allZeros = value.substring(value.length() - 4).endsWith("0000"); + System.out.println(allZeros); // Output: true + if (allZeros){ + Iterator<Map<String, Object>> iterator = studentTotal.iterator(); + while (iterator.hasNext()) { + Map<String, Object> student = iterator.next(); + String cityCode = (String) student.get("provinceCode"); + if (!cityCode.equals(studentQeryDto.getCityCode())) { + iterator.remove(); // Remove the element from the list + } + } + }else{ + Iterator<Map<String, Object>> iterator = studentTotal.iterator(); + while (iterator.hasNext()) { + Map<String, Object> student = iterator.next(); + String cityCode = (String) student.get("cityCode"); + if (!cityCode.equals(studentQeryDto.getCityCode())) { + iterator.remove(); // Remove the element from the list + } + }} + } + + if (studentQeryDto.getStudentName()!=null&&studentQeryDto.getStudentName()!=""){ + List<Map<String, Object>> totallike = new ArrayList<>(); + for (Map<String, Object> student : studentTotal) { + String studentName = (String) student.get("studentName"); + if (studentName.contains(studentQeryDto.getStudentName())){ + totallike.add(student); + } + + } + return totallike; + } + return studentTotal; + } + + @Override + public List<Map<String, Object>> bypac(PacQueryDto pacQueryDto) { + if (pacQueryDto.getCityCode()!=null&&pacQueryDto.getCityCode()!=""){ + String value = pacQueryDto.getCityCode(); + boolean allZeros = value.substring(value.length() - 4).endsWith("0000"); + System.out.println(allZeros); // Output: true + + if (allZeros){ + pacQueryDto.setProvinceCode(pacQueryDto.getCityCode()); + pacQueryDto.setCityCode(null); + } + + } + List<Map<String, Object>> maps = this.baseMapper.pacQueryDto(pacQueryDto); + + if (pacQueryDto.getName()!=null&&pacQueryDto.getName()!=""){ + List<Map<String, Object>> totallike = new ArrayList<>(); + for (Map<String, Object> student : maps) { + String studentName = (String) student.get("name"); + if (studentName.contains(pacQueryDto.getName())){ + totallike.add(student); + } + + } + return totallike; + } + + + return maps; + } + + @Override + public List<TCoursePackagePayment> listOne(List<Integer> ids) { + return this.baseMapper.listOne(ids); + } + + @Override + public Integer listStoreId(String code) { + return this.baseMapper.queryStore(code); } /** @@ -624,6 +754,12 @@ TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); + + recordVo.setUserId(appUserId); + recordVo.setSiteId(coursePackage.getSiteId()); + List<Integer> ids = getIds(coursePackage.getSiteId()); + recordVo.setIds(ids); + recordVo.setCoursePackageName(coursePackage.getName()); recordVo.setCourseHours(tCoursePackagePayment.getClassHours()); Date date = DateUtil.getDate(); @@ -679,7 +815,23 @@ } return recordVoList; } + public List<Integer> getIds(Integer siteId) { + HttpRequest httpRequest = HttpRequest.get("https://try.daowepark.com/v7/user_api/general/get_space_area?space_id=" + siteId); + HttpResponse execute = httpRequest.execute(); + String body = execute.body(); + JSONObject jsonObject = JSONObject.parseObject(body); + Object data = jsonObject.get("data"); + JSONArray array = JSONArray.parseArray(data.toString()); + List<Integer> ids =new ArrayList<>(); + for (Object o : array) { + JSONObject jsonObject1 = JSONObject.parseObject(o.toString()); + Object id = jsonObject1.get("id"); + Integer integer = Integer.valueOf(id.toString()); + ids.add(integer); + } + return ids; + } @Override public ResultUtil insertVipPaymentCallback(String code, String orderNumber) { TCoursePackagePayment coursePackagePayment = this.baseMapper.getCoursePackagePaymentByCode(code); @@ -990,9 +1142,10 @@ student1.setCoursePackageId(tCoursePackage.getId()); student1.setCoursePackagePaymentId(tCoursePackagePayment1.getId()); student1.setCoursePackageSchedulingId(coursePackageScheduling.getId()); - student1.setSignInOrNot(0); + student1.setSignInOrNot(1); student1.setReservationStatus(1); student1.setInsertTime(new Date()); + student1.setType(1); cpsMapper.insert(student1); } catch (Exception e) { e.printStackTrace(); @@ -1039,8 +1192,8 @@ } @Override - public List<Integer> getStudentIds(Long payId) { - return this.baseMapper.getStudentIds(payId); + public List<Integer> getStudentIds(Long payId, Integer classId, Integer appId) { + return this.baseMapper.getStudentIds(payId,classId,appId); } @Override -- Gitblit v1.7.1