| | |
| | | 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; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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; |
| | |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.mapper.*; |
| | | import com.dsh.course.model.BillingRequest; |
| | | import com.dsh.course.model.QueryRegistrationRecord; |
| | | import com.dsh.course.model.QueryWalkInStudentList; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.model.dto.DiscountJsonDto; |
| | | import com.dsh.course.model.vo.RegisterCourseVo; |
| | | import com.dsh.course.model.vo.request.*; |
| | |
| | | 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.*; |
| | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<CoursePackagePaymentVO> listAll(CoursePackagePaymentQuery query) { |
| | | return cpConfigMapper.listAll(query); |
| | | } |
| | | |
| | | @Override |
| | | public int changeState(CoursePackagePayDTO dto) { |
| | | List<String> ids = dto.getIds(); |
| | | List<Long> list = new ArrayList<>(); |
| | | for (String id : ids) { |
| | | long value = Long.parseLong(id); |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 获取课包购买人数 |
| | |
| | | |
| | | 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(); |
| | |
| | | } |
| | | 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); |
| | |
| | | } |
| | | List<Map<String, Object>> list = this.baseMapper.queryRegistrationRecord(page, coursePackageId, userIds, studentIds); |
| | | for (Map<String, Object> map : list) { |
| | | |
| | | Long id = Long.valueOf(map.get("id").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer studentId = Integer.valueOf(map.get("studentId").toString()); |
| | | AppUser appUser = appuClient.queryAppUser(appUserId); |
| | | |
| | | TAppUser appUser = appuClient.queryAppUser1(appUserId); |
| | | map.put("userName", null != appUser ? appUser.getName() : ""); |
| | | map.put("phone", null != appUser ? appUser.getPhone() : ""); |
| | | Student student = studentClient.queryStudentById(studentId); |
| | | map.put("studentName", null != student ? student.getName() : ""); |
| | | Integer integer = cpsMapper.selectCount(new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId) |
| | | .eq("studentId", studentId).eq("coursePackagePaymentId", id).eq("signInOrNot", 1)); |
| | | .eq("studentId", studentId).eq("coursePackagePaymentId", id).eq("signInOrNot", 2)); |
| | | map.put("already", integer); |
| | | // if (student != null && student.getName().equals("杨锴1")) { |
| | | // map.put("totalClassHours", "测试"); |
| | | // } |
| | | ; |
| | | } |
| | | return list; |
| | | } |
| | |
| | | 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(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Integer> getStudentIds(Integer payId) { |
| | | return this.baseMapper.getStudentIds(payId); |
| | | public List<Integer> getStudentIds(Long payId, Integer classId, Integer appId) { |
| | | return this.baseMapper.getStudentIds(payId,classId,appId); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |