From b3068671b4eab47d9cec1e7f2a763db247ea0d10 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期五, 11 四月 2025 14:18:36 +0800
Subject: [PATCH] 1
---
cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java | 318 +++++++++++++++++++++++++++++++---------------------
1 files changed, 188 insertions(+), 130 deletions(-)
diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
index 870a43f..9dacfdf 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
@@ -1,5 +1,9 @@
package com.dsh.account.service.impl;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.request.AlipayTradeOrderSettleRequest;
+import com.alipay.api.response.AlipayTradeOrderSettleResponse;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -48,6 +52,9 @@
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -101,6 +108,8 @@
@Resource
private ParticipantClient participantClient;
+ @Autowired
+ private CoursePackageClient coursePackageClient;
@Autowired
private PayMoneyUtil payMoneyUtil;
@@ -119,11 +128,12 @@
@Override
public ResultUtil addStuOfAppUser(StuDetailsReq stu, Integer appUserId) throws Exception {
TStudent student = new TStudent();
- if (ToolUtil.isNotEmpty(stu.getName()) && ToolUtil.isNotEmpty(stu.getIdCard())) {
- Boolean aBoolean = JuHeUtil.idcardAuthentication(stu.getIdCard(), stu.getName());
- if (!aBoolean) {
- return ResultUtil.error("身份证和姓名不匹配");
- }
+ if(ToolUtil.isEmpty(stu.getIdCard())){
+ return ResultUtil.error("请填写身份证号");
+ }
+ Boolean aBoolean = JuHeUtil.idcardAuthentication(stu.getIdCard(), stu.getName());
+ if (!aBoolean) {
+ return ResultUtil.error("身份证和姓名不匹配");
}
student.setAppUserId(appUserId);
student.setName(stu.getName());
@@ -163,6 +173,7 @@
saveParticipant.setWeight(student.getWeight());
saveParticipant.setPhone(student.getPhone());
saveParticipant.setIdcard(student.getIdCard());
+
participantClient.saveParticipant(saveParticipant);
return ResultUtil.success();
}
@@ -234,107 +245,7 @@
@Override
public List<PurchaseRecordVo> queryDeduRecordDetails(RecordTimeRequest timeRequest, Integer appUserId) {
- List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>();
- String time = timeRequest.getTime();
-
List<PurchaseRecordVo> record1 = sessionNameClient.getRecord(timeRequest);
-
-//
-// Date monthStart = null;
-// Date monthEnd = null;
-// if (StringUtils.hasText(time)) {
-// monthStart = DateTimeHelper.getCurrentIdetMouthStart(time);
-// monthEnd = DateTimeHelper.getCurrentIdeaMouthEnd(time);
-// } else {
-// monthStart = DateTimeHelper.getCurrentMouthStart();
-// monthEnd = DateTimeHelper.getCurrentMouthEnd();
-// }
-//
-// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM");
-// Date startTime = DateTimeHelper.getCurrentIdetMouthStart(simpleDateFormat.format(monthStart));
-// Date endTime = DateTimeHelper.getCurrentIdeaMouthEnd(simpleDateFormat.format(monthEnd));
-// GetStuSourseList getStuSourseList = new GetStuSourseList();
-// getStuSourseList.setStartTime(startTime);
-// getStuSourseList.setEndTime(endTime);
-// getStuSourseList.setAppUserId(appUserId);
-// // 报名赛事
-// List<PurchaseRecordVo> stuSourseList = dcttClient.getStuSourseList1(getStuSourseList);
-// purchaseRecordVoList.addAll(stuSourseList);
-//
-// GetStuSessionList sessionList = new GetStuSessionList();
-// sessionList.setStartTime(startTime);
-// sessionList.setEndTime(endTime);
-// sessionList.setStuId(timeRequest.getStuId());
-// sessionList.setAppUserId(appUserId);
-// List<PurchaseRecordVo> cancelCourseList = cancelcClient.getCancelCourseList(sessionList);
-//
-// purchaseRecordVoList.addAll(cancelCourseList);
-// GetStuSessionList getStuSessionList = new GetStuSessionList();
-// getStuSessionList.setStartTime(startTime);
-// getStuSessionList.setEndTime(endTime);
-// getStuSessionList.setStuId(timeRequest.getStuId());
-// getStuSessionList.setAppUserId(appUserId);
-// // 购买课包
-// List<PurchaseRecordVo> purchaseRecordVos = sessionNameClient.queryCourseDetails(getStuSessionList);
-// purchaseRecordVoList.addAll(purchaseRecordVos);
-// List<TAppUser> tAppUsers = tauMapper.selectList(new QueryWrapper<TAppUser>()
-// .eq("referralUserId",appUserId )
-// .between("insertTime",startTime ,endTime));
-// if (ToolUtil.isNotEmpty(tAppUsers)){
-// List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList());
-// IntrduceOfUserRequest request = new IntrduceOfUserRequest();
-// request.setStartTime(startTime);
-// request.setEndTime(endTime);
-// request.setUserIds(userIds);
-// // 介绍有礼
-// List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(request);
-// purchaseRecordVoList.addAll(purchaseRecordVos1);
-// }
-//
-// LambdaQueryWrapper<TCourseInfoRecord> eq = new LambdaQueryWrapper<TCourseInfoRecord>().eq(TCourseInfoRecord::getUserId, appUserId);
-// if(timeRequest.getType()!=null){
-// eq.eq(TCourseInfoRecord::getType,timeRequest.getType());
-// }
-// if (timeRequest.getLessionId()!=null){
-// eq.eq(TCourseInfoRecord::getCourseId,timeRequest.getLessionId());
-//
-// }
-// // 2.0其他记录
-// List<TCourseInfoRecord> list = courseInfoRecordService.list(eq);
-// List<PurchaseRecordVo> list1=new ArrayList<>();
-// for (TCourseInfoRecord tCourseInfoRecord : list) {
-// PurchaseRecordVo purchaseRecordVo = new PurchaseRecordVo();
-// purchaseRecordVo.setPurchaseTime(new SimpleDateFormat("MM-dd HH:mm").format(tCourseInfoRecord.getTime()));
-// purchaseRecordVo.setPurchaseType(tCourseInfoRecord.getName());
-// if(tCourseInfoRecord.getType()==1){
-// purchaseRecordVo.setPurchaseAmount("+"+tCourseInfoRecord.getNum());
-// }else {
-// purchaseRecordVo.setPurchaseAmount("-"+tCourseInfoRecord.getNum());
-// }
-// list1.add(purchaseRecordVo);
-// }
-// purchaseRecordVoList.addAll(list1);
-//
-// if (purchaseRecordVoList.size() > 0 ){
-// purchaseRecordVoList = purchaseRecordVoList.stream()
-// .filter(record -> {
-// String fieldValue = record.getPurchaseAmount();
-// if (ToolUtil.isNotEmpty(timeRequest.getType())){
-// switch (timeRequest.getType()){
-// case 2:
-// return fieldValue != null && !fieldValue.isEmpty() && fieldValue.charAt(0) == '-';
-// case 1:
-// return fieldValue != null && !fieldValue.isEmpty() && fieldValue.charAt(0) == '+';
-// default:
-// break;
-// }
-// }
-// return true;
-// })
-// .collect(Collectors.toList());
-// }
-//
-// purchaseRecordVoList = dealDataOfTime(purchaseRecordVoList);
return record1;
}
@@ -480,14 +391,14 @@
packagePayment.setStatus(1);
packagePayment.setState(1);
packagePayment.setInsertTime(new Date());
- couPayClient.savePaymentCoursePackage(packagePayment);
+// couPayClient.savePaymentCoursePackage(packagePayment);
Integer hour = couPayClient.getClassHour(request.getCourseConfigId());
try {
switch (request.getPayType()) {
case 1:
- return WeChatPayment(code, request.getPayAmount(), hour);
+ return WeChatPayment(code, request.getPayAmount(), hour,request.getLessonId());
case 2:
return AlipayPayment(code, request.getPayAmount(), hour);
case 3:
@@ -512,8 +423,19 @@
}
- public ResultUtil WeChatPayment(String code, BigDecimal amount, Integer hour) throws Exception {
- ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费", "", code, amount.toString(),
+ public ResultUtil WeChatPayment(String code, BigDecimal amount, Integer hour,Integer lessonId) throws Exception {
+ // 判断这个课包是属于哪个运营商的
+ CoursePackage coursePackage = coursePackageClient.queryCoursePackageById(lessonId);
+ Integer storeId = coursePackage.getStoreId();
+ Store store = storeClient.queryStoreById(storeId);
+ // 是否分账 0否1是
+ int isFenZhang= 1;
+ String merchantNumber = "";
+ if (store.getOperatorId()==null || store.getOperatorId()==0){
+ // 平台
+ isFenZhang = 0;
+ }
+ ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费"+"-"+isFenZhang, "", code, amount.toString(),
"/base/coursePackage/wechatPaymentCallback", "APP", "");
if (weixinpay.getCode() == 200) {
new Thread(new Runnable() {
@@ -544,7 +466,7 @@
Map<String, String> data1 = resultUtil.getData();
String s = data1.get("trade_state");
String transaction_id = data1.get("transaction_id");
- if ("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) {
+ if ("REFUND".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10) {
coursePackagePayment.setState(3);
couPayClient.delPaymentCoursePackage(coursePackagePayment.getId());
break;
@@ -555,9 +477,29 @@
coursePackagePayment.setLaveClassHours(hour);
coursePackagePayment.setOrderNumber(transaction_id);
couPayClient.updatePaymentCoursePackage(coursePackagePayment);
+ if (store.getOperatorId()!=null && store.getOperatorId()!=0){
+ // 休眠两分钟后再调用分账接口 避免提示订单正在处理中
+ Thread.sleep(120000);
+ // 根据运营商id获取对应运营商分账比例 返回格式: 微信分账比例,支付宝分账比例
+ String proportionByOperatorId = storeClient.getProportionByOperatorId(store.getOperatorId());
+ String[] split = proportionByOperatorId.split(",");
+ String s1 = split[0];
+ if (!s1.equals("未设置")){
+ BigDecimal bigDecimal = new BigDecimal(s1);
+ // 分账比例
+ BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(100)).setScale(2);
+ // 微信商户号
+ String s2 = storeClient.getmerchantNumberByOperatorId(store.getOperatorId());
+
+ ResultUtil fenzhang = payMoneyUtil.fenzhang(transaction_id, amount.multiply(bigDecimal1), s2,"课包续费分账");
+ if (!fenzhang.getCode().equals(500)){
+ System.err.println("分账失败 原因是:"+fenzhang.getMsg());
+ }
+ }
+ }
break;
}
- if ("USERPAYING".equals(s)) {
+ if ("USERPAYING".equals(s) || "NOTPAY".equals(s)) {
num++;
}
}
@@ -570,9 +512,24 @@
}
return weixinpay;
}
-
+ private String smid = "2088330203191220";//平台支付宝商户号
public ResultUtil AlipayPayment(String code, BigDecimal amount, Integer hour) {
- ResultUtil alipay = payMoneyUtil.alipay("课包续费", "课包续费", "", code, amount.toString(),
+ TCoursePackagePayment coursePackagePayment = couPayClient.getCoursePackagePaymentByCode(code);
+ Integer coursePackageId = coursePackagePayment.getCoursePackageId();
+ // 判断这个课包是属于哪个运营商的
+ CoursePackage coursePackage = coursePackageClient.queryCoursePackageById(coursePackageId);
+ Integer storeId = coursePackage.getStoreId();
+ Store store = storeClient.queryStoreById(storeId);
+ String smid1= "";
+ if (store.getOperatorId()==null){
+ // 平台
+ smid1 = smid;
+ }else{
+ String smidByOperatorId = storeClient.getSMIDByOperatorId(store.getOperatorId());
+ smid1 = smidByOperatorId;
+ }
+
+ ResultUtil alipay = payMoneyUtil.alipay(smid1,"课包续费", "课包续费", "", code, amount.toString(),
"/base/coursePackage/alipayPaymentCallback");
if (alipay.getCode() == 200) {
new Thread(new Runnable() {
@@ -590,7 +547,6 @@
break;
}
AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code);
-
if (resultUtil.getCode().equals("10000") && coursePackagePayment.getPayStatus() == 1) {
/**
* WAIT_BUYER_PAY(交易创建,等待买家付款)、
@@ -615,8 +571,25 @@
coursePackagePayment.setLaveClassHours(hour);
coursePackagePayment.setOrderNumber(tradeNo);
couPayClient.updatePaymentCoursePackage(coursePackagePayment);
-
-
+ Integer coursePackageId = coursePackagePayment.getCoursePackageId();
+ // 判断这个课包是属于哪个运营商的
+ CoursePackage coursePackage = coursePackageClient.queryCoursePackageById(coursePackageId);
+ Integer storeId = coursePackage.getStoreId();
+ Store store = storeClient.queryStoreById(storeId);
+ String smid1= "";
+ if (store.getOperatorId()==null || store.getOperatorId() == 0){
+ // 平台
+ smid1 = smid;
+ // 属于平台 不做资金冻结 不做分账处理
+ payMoneyUtil.confirm(smid1,code,tradeNo,amount.toString());
+ }else{
+ String smidByOperatorId = storeClient.getSMIDByOperatorId(store.getOperatorId());
+ smid1 = smidByOperatorId;
+ payMoneyUtil.confirm1(smid1,code,tradeNo,amount.toString());
+ // 分账处理
+ extracted(store.getOperatorId(), amount, tradeNo);
+ }
+
break;
}
if ("WAIT_BUYER_PAY".equals(tradeStatus)) {
@@ -632,7 +605,51 @@
}
return alipay;
}
-
+ private void extracted(Integer operatorId, BigDecimal coursePackageOrder1, String tradeNo) throws Exception {
+ // 分账
+ AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",
+ "2021004105665036",
+ "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCi5i9nW/hGLJ3A06cZxTQdviFC7THpdSihoTYGLr9q006hu0V26ecBMY/o4w5bvIX0Ok/yofmZsVcCJpAPvbXL/uqVrIjnRRxXiaeBFThlxoBUTdunvbUSDYfzlEhJr5NvUKI6H6lz2niXlQGx4qy8Hau4ccWit9kM8jwUvsBVQoFgJA+xrjMvooA7YLopQtpOD+UJr5thApTSf1xrnr1W12yolTLEH15JmNV372cqXrYUuqnY0QsaPtxeqJUGAOcGdVLllQ7easEznP8DFBvDdHATcmp2SHNQDUEWN6MCVPbMgY06NQVqAXxqjTAYSVh+6TRu6bofPmpYC3TZB003AgMBAAECggEBAJAcR2+PA3NBYUYHeFrqBRMS8uX8ZR19kjZ7IgoSLTFaQsP9opRylPSPXhrPVBKAE5leRQAHn4MCSlESwHvMfxo7KFjFTFAc6dffZZpipYQUOc9bGampwJh58/3e/pyBgVMG6J23CPf/HJQtNFSkjd/V9+ayb/9l2dUEL3bC0fAZ/dbx8HsxdLw8wn3fLlWLj68hOMqa2deCZe3JdSVsPbeWqkh56FFsMLug0Nd+Ar4TgRl9/jnhXF0JWiD0LmPUYLhboY7EfUBzN4w1iYbDi1P+3zvoOYsiVKAXox9GMhQ2VzOO2UcSTuizSza2e98mGpabl/GpKmCz+RDFjtkX6eECgYEA2MyCij65eO3aGIm3FUe93DULRBYTfX8qJQSJq2WOWA3mmQlEW6L3O2B5/lG2h+8WmN6iLEs9eHpgycGYp7vAqgrANEn16ACVcuyx0scFtrZfZ+kmHMzFfiUWxJjVYk/6YngsGVBLdw6ueM42C8TTP67X9tU5TdVGoGWuqEj4W98CgYEAwFqwprXOch5Pqk/RPbb49r0Ou03K/UbciWnWWKzUhFFNS8MdlQPoDvQZbMwHLeWsa2VhaKITK3x5biLQb3U+0GLOn6lTvEyrEUH+ucREyLgVYTRAvwBPtnvlrzpyxPk2HnslQjju8WrvvLLBMKWUjlTrTOzhaHT21gz3pHMiOakCgYEAhLmfaXdBITGshb054sNLDtdCkGpbgEcrzAHdLps769iGxkYQHXHFngpQZUwtTUcoNGqIKknd1jZFrv7gsD+XkgKG7PwimehRlkwmCX5ilxtLiVgJRzRt6+5U5AMVD90a0tHzXYP0z2yjj73fBJF5KtGl0a10KZxaYrQdm1UhB00CgYBZZgzx/k9rtHC8LAqIj1CYhHejT92G53c6Gkl3vyOqN4sgKhfGmSEySfrDGPRBPZxr8ZtbIPCd5mUdberH0osWGMYFaJI1UsCy7aQwvGpniz7MhZeN7dweaOjwDs8mgtjHQ96mL4XGCDhR0BZ/wIURvZ/6iaGdhbbu9unlsWj3uQKBgQCmZYdsbbZkd3ev6f8rwyvMz+DrCQyYpY44cegBYuJgrZiQnL2fJioeN7ixX0UM48SfwsZEIrzshP/LGAwnc2MdjxKUl4jLN8SEe0NAjXOnz9Zaw740+aOmLpXcLWdP4uM2gIhWsvW1tEkQZCXmm7c9s/RsU8Pmzv+YL3+fSijOzA==",
+ "json", "GBK",
+ "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmu8n/4yTHWbn7VOrNc9OsLtDL1bEQ8gC1dHkj8Wy5z0mkaOsjJRIG/28ze12M0V8jdCKuuDr5Z1OPKiqf+XO3ypguEh+mYUVMBM/cZodDFQfTY1TKLWjvQCuaqlA+QUTCK6f7T7stsgyQ1o9Jj0rXZDz6PM4QHSTzjrLIBaeqM5WIBvH+fy/X+QG5Utd+/UT0kc0JyvuKhZ65yVUd/C9VcwJJAPliRsAQNrqYterwAJ9zvw9tF11wj9W0XgJ8Ccu4x3gR1vrlLRJJo/OA97RmxPQ+5hSacWQZCUd1dwiBq+YCrKVHGTj14izRHXrLc0yBlRXo7tBOIqcy3IsvKVthQIDAQAB",
+ "RSA2");
+ AlipayTradeOrderSettleRequest request = new AlipayTradeOrderSettleRequest();
+ String randomCode = UUIDUtil.getRandomCode(16);
+ String proportionByOperatorId1 = storeClient.getProportionByOperatorId(operatorId);
+ // 支付宝分账比例
+ String s1 = proportionByOperatorId1.split(",")[1];
+ double i = Double.parseDouble(s1);
+ double v = i * 0.01;
+ BigDecimal bigDecimal1 = new BigDecimal(String.valueOf(v));
+ // 分账金额
+ BigDecimal bigDecimal2 = coursePackageOrder1.multiply(bigDecimal1).setScale(2, RoundingMode.DOWN);
+ request.setBizContent("{" +
+ " \"out_request_no\":\"" + randomCode + "\"," +
+ " \"trade_no\":\"" + tradeNo + "\"," +
+ " \"royalty_parameters\":[" +
+ " {" +
+ " \"royalty_type\":\"transfer\"," +
+ " \"trans_out\":\"" + storeClient.getSMIDByOperatorId(operatorId)+ "\"," +
+ " \"trans_out_type\":\"userId\"," +
+ " \"trans_in_type\":\"userId\"," +
+ " \"trans_in\":\"" + smid + "\"," +
+ " \"amount\":" + bigDecimal2 + "," +
+ " \"desc\":\"平台服务费\"," +
+ " \"royalty_scene\":\"平台服务费\"," +
+ " }" +
+ " ]," +
+ " \"extend_params\":{" +
+ " \"royalty_finish\":\"true\"" +
+ " }," +
+ " \"royalty_mode\":\"async\"" +
+ "}");
+ AlipayTradeOrderSettleResponse response = alipayClient.execute(request);
+ if (response.isSuccess()) {
+ System.out.println("调用成功");
+ } else {
+ System.out.println("调用失败");
+ }
+ }
public int PlaypaiGoldPayment(String code, ClasspaymentRequest request) {
PlayPaiGoldCoursePackage paiGoldCoursePackage = new PlayPaiGoldCoursePackage();
paiGoldCoursePackage.setCoursePackageId(request.getLessonId());
@@ -703,10 +720,19 @@
.filter(record -> {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- String substring = record.getTimeFrame().substring(11);
+ String substring = record.getTimeFrame().substring(0,16);
Date time = sdf.parse(substring);
- return !time.before(lastWeekStartDate) && !time.after(lastOfDate);
+ Instant instant = time.toInstant();
+ LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
+ // 获取今天的日期
+ LocalDate today = LocalDate.now();
+ // 计算一周前的日期
+ LocalDate oneWeekAgo = today.minusWeeks(1);
+ // 计算一周后的日期
+ LocalDate oneWeekLater = today.plusWeeks(1);
+ return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
} catch (ParseException e) {
+ e.printStackTrace();
return false;
}
})
@@ -717,10 +743,20 @@
recordAppoints = recordAppoints.stream()
.filter(record -> {
try {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- Date time = sdf.parse(record.getTimeFrame().substring(11));
- return !time.before(lastMonthStartDate) && !time.after(lastOfDate);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ String substring = record.getTimeFrame().substring(0,16);
+ Date time = sdf.parse(substring);
+ Instant instant = time.toInstant();
+ LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
+ // 获取今天的日期
+ LocalDate today = LocalDate.now();
+ // 计算一周前的日期
+ LocalDate oneWeekAgo = today.minusMonths(1);
+ // 计算一周后的日期
+ LocalDate oneWeekLater = today.plusMonths(1);
+ return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
} catch (ParseException e) {
+ e.printStackTrace();
return false;
}
})
@@ -732,9 +768,19 @@
.filter(record -> {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- Date time = sdf.parse(record.getTimeFrame().substring(11));
- return !time.before(lastYearStartDate) && !time.after(lastOfDate);
+ String substring = record.getTimeFrame().substring(0,16);
+ Date time = sdf.parse(substring);
+ Instant instant = time.toInstant();
+ LocalDate dateToCheck = instant.atZone(ZoneId.systemDefault()).toLocalDate();
+ // 获取今天的日期
+ LocalDate today = LocalDate.now();
+ // 计算一周前的日期
+ LocalDate oneWeekAgo = today.minusYears(1);
+ // 计算一周后的日期
+ LocalDate oneWeekLater = today.plusYears(1);
+ return dateToCheck.isAfter(oneWeekAgo) && dateToCheck.isBefore(oneWeekLater);
} catch (ParseException e) {
+ e.printStackTrace();
return false;
}
})
@@ -781,18 +827,16 @@
citycodeResp.setLatitude(longitude);
List<StoreDetailList> queryStoreList = storeClient.getQueryStoreList(citycodeResp);
if (queryStoreList.size() > 0) {
- if (ToolUtil.isEmpty(space) || space == 2) {
+ if (ToolUtil.isEmpty(space) || space ==1) {
+ queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
+ } else {
queryStoreList = queryStoreList.stream()
.sorted(Comparator.comparing(StoreDetailList::getStoreDistance).reversed())
.collect(Collectors.toList());
-
- } else {
- queryStoreList = queryStoreList.stream().sorted(Comparator.comparing(o -> o.getStoreDistance())).collect(Collectors.toList());
}
if (ToolUtil.isNotEmpty(search)) {
queryStoreList = queryStoreList.stream().filter(o -> o.getStoreName().contains(search)).collect(Collectors.toList());
}
-
}
return queryStoreList;
}
@@ -879,9 +923,23 @@
return this.baseMapper.getGiftSelect(giftSearchDto);
}
+ @Resource
+ private SiteClient siteClient;
+
+
@Override
public List<Map<String, Object>> queryCom(Integer id) {
- return this.baseMapper.queryCom(id);
+ List<Map<String, Object>> maps = this.baseMapper.queryCom(id);
+ for (Map<String, Object> map : maps) {
+ Integer coachId = (Integer) map.get("coachId");
+ System.err.println("==============XXXXXXXXXXXX"+coachId);
+ if (coachId!=null) {
+ User name = siteClient.queryUserName(coachId);
+ map.put("name",name.getName());
+ }
+ }
+
+ return maps;
}
--
Gitblit v1.7.1