From 9e8ce689c89c4b03bfc67a60d7da13a7d593725a Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期二, 24 十月 2023 20:33:41 +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 | 151 ++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 116 insertions(+), 35 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 5057fec..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 @@ -6,12 +6,14 @@ 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; @@ -49,6 +51,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -151,6 +154,113 @@ 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); } /** @@ -566,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()); @@ -938,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){ -- Gitblit v1.7.1