fix 发送微信消息,日期格式有误

This commit is contained in:
2023-07-24 20:29:36 +08:00
parent 10d244b79c
commit 4c09422a45
3 changed files with 97 additions and 1 deletions

View File

@@ -1,11 +1,21 @@
package com.sv.api.controller;
import com.enums.VenueTypeEnum;
import com.sv.entity.Constants;
import com.sv.entity.Venue;
import com.sv.entity.VenueLesson;
import com.sv.service.api.VenueLessonService;
import com.sv.service.api.VenueService;
import com.sv.service.api.util.DateUtilCard;
import com.sv.service.common.SmsService;
import com.sv.service.message.SendMsg;
import com.sv.service.message.WeiXinSendUtils;
import com.ydd.framework.core.common.dto.ResponseDTO;
import com.ydd.framework.core.controller.BaseApiController;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@@ -50,4 +60,32 @@ public class SmsController extends BaseApiController {
smsService.sendUpdatePhoneCaptcha(mobile);
return ResponseDTO.ok();
}
@Resource
VenueLessonService venueLessonService;
@Resource
VenueService venueService;
@RequestMapping(value = "/test/send/wx/message",method = RequestMethod.GET)
public String sendTestMessage() {
VenueLesson venueLesson = venueLessonService.findById(30858);
String hello = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString() + "-" + venueLesson.getEndTime().toString();
System.out.println(hello);
String openId = "o81UzwYksMMqbNJgsOvyjhbk-7b0";
Integer venueId = venueLesson.getVenueId();
Venue venue = venueService.findById(venueId);
String lessonTime = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString();
System.out.println(lessonTime);
String typeName = VenueTypeEnum.getByValue(venue.getType()).name;
String url = Constants.VENUE_VIEW_URL + venueId;
SendMsg sendMsg = new SendMsg(venue.getName(),venueLesson.getName(),lessonTime,typeName,url);
if (!StringUtils.isEmpty(openId)) {
String[] split = openId.split(",");
for (String s : split) {
WeiXinSendUtils.sendCard(sendMsg,s);
}
}
return "OK";
}
}

View File

@@ -0,0 +1,58 @@
package com.sv.wx;
import com.WeiXinApplication;
import com.enums.VenueTypeEnum;
import com.sv.entity.Constants;
import com.sv.entity.Venue;
import com.sv.entity.VenueLesson;
import com.sv.service.api.VenueLessonService;
import com.sv.service.api.VenueService;
import com.sv.service.api.util.DateUtilCard;
import com.sv.service.message.SendMsg;
import com.sv.service.message.WeiXinSendUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
@RunWith(SpringRunner.class)
@SpringBootTest(classes={WeiXinApplication.class})
public class SendMessageTest {
@Resource
VenueLessonService venueLessonService;
@Resource
VenueService venueService;
@Test
public void testTask(){
VenueLesson venueLesson = venueLessonService.findById(30858);
String hello = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString() + "-" + venueLesson.getEndTime().toString();
System.out.println(hello);
String openId = "o81UzwYksMMqbNJgsOvyjhbk-7b0";
Integer venueId = venueLesson.getVenueId();
Venue venue = venueService.findById(venueId);
if (venue == null) {
return;
}
if (venueLesson == null) {
return;
}
String lessonTime = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString();
System.out.println(lessonTime);
String typeName = VenueTypeEnum.getByValue(venue.getType()).name;
String url = Constants.VENUE_VIEW_URL + venueId;
SendMsg sendMsg = new SendMsg(venue.getName(),venueLesson.getName(),lessonTime,typeName,url);
if (!StringUtils.isEmpty(openId)) {
String[] split = openId.split(",");
for (String s : split) {
WeiXinSendUtils.sendCard(sendMsg,s);
}
}
}
}

View File

@@ -400,7 +400,7 @@ public class MemberLessonTicketService extends BaseServiceImpl {
if (venueLesson == null) {
return;
}
String lessonTime = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString() + "-" + venueLesson.getEndTime().toString();
String lessonTime = DateUtilCard.getStrFromDate(venueLesson.getDate()) + " " + venueLesson.getStartTime().toString();
String typeName = VenueTypeEnum.getByValue(venue.getType()).name;
String url = Constants.VENUE_VIEW_URL + venueId;
AsyncTaskUtil.INSTANCE.submit(new NotifyAdminMsgThread(venue.getName(),venueLesson.getName(),lessonTime,typeName,url));