From 0379c65f03ec6ccf27eebbdc72a25cabbda28e5a Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期二, 24 十月 2023 20:22:37 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackagePaymentServiceImpl.java | 233 +++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 190 insertions(+), 43 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 0f3ac1f..336cc52 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,13 +1,19 @@ 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.alipay.api.response.AlipayTradeQueryResponse; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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; @@ -23,9 +29,7 @@ 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.*; @@ -35,16 +39,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.*; @@ -117,6 +124,144 @@ + @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); + } /** * 获取课包购买人数 @@ -531,17 +676,18 @@ if(coursePackagePayment.getPayStatus() == 2){ break; } - ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code); - if(resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1){ + AlipayTradeQueryResponse alipayTradeQueryResponse = payMoneyUtil.queryALIOrder(code); + + if(coursePackagePayment.getPayStatus() == 1){ /** * WAIT_BUYER_PAY(交易创建,等待买家付款)、 * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、 * TRADE_SUCCESS(交易支付成功)、 * TRADE_FINISHED(交易结束,不可退款) */ - Map<String, String> data1 = resultUtil.getData(); - String s = data1.get("tradeStatus"); - String tradeNo = data1.get("tradeNo"); +// Map<String, String> data1 = resultUtil.getData(); + String s = alipayTradeQueryResponse.getTradeStatus(); + String tradeNo = alipayTradeQueryResponse.getTradeNo(); if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){ coursePackagePayment.setState(3); baseMapper1.deleteById(coursePackagePayment.getId()); @@ -610,6 +756,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(); @@ -665,7 +817,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); @@ -711,17 +879,23 @@ } 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; } @@ -875,36 +1049,6 @@ return integers; } - public static void main(String[] args) { - List<Integer> week = week("周一,周二"); - // 今天周几 - int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; - - SimpleDateFormat format = new SimpleDateFormat("MM.dd"); - - ArrayList<String> strings = new ArrayList<>(); - for (Integer integer : week) { - if(integer<i){ - // 找下一周的时间 - Calendar instance = Calendar.getInstance(); - instance.add(Calendar.DATE,7-(i-integer)); - Date time = instance.getTime(); - strings.add(format.format(time)); - - }else if(integer>i) { - Calendar instance = Calendar.getInstance(); - instance.add(Calendar.DATE,integer-i); - Date time = instance.getTime(); - strings.add(format.format(time)); - }else { - Calendar instance = Calendar.getInstance(); - instance.add(Calendar.DATE,7); - Date time = instance.getTime(); - strings.add(format.format(time)); - } - } - System.out.println(strings); - } @Override @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW) public ResultUtil payCourse(PayCourseReq req,Integer userId){ @@ -970,9 +1114,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(); @@ -1019,8 +1164,8 @@ } @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 @@ -1029,4 +1174,6 @@ } + + } -- Gitblit v1.7.1