CollegeBookingService.java 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package com.ygj.yuemum.service.college;
  2. import com.ygj.yuemum.dao.college.CollegeBookingDao;
  3. import com.ygj.yuemum.dao.college.CollegeTestDao;
  4. import com.ygj.yuemum.domain.college.*;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import java.text.SimpleDateFormat;
  8. import java.util.Date;
  9. import java.util.List;
  10. @Service
  11. public class CollegeBookingService {
  12. @Autowired
  13. private CollegeBookingDao collegeBookingDao;
  14. @Autowired
  15. private CollegeLearningDetailService collegeLearningDetailService;
  16. @Autowired
  17. private CollegeCurriculumPracticeService collegeCurriculumPracticeService;
  18. @Autowired
  19. private CollegeCurriculumExperienceService collegeCurriculumExperienceService;
  20. public List<CollegeBooking> getCollegeBookings() {
  21. List<CollegeBooking> collegeBookings = collegeBookingDao.getAll();
  22. return collegeBookings;
  23. }
  24. public CollegeBooking checkBooking(CollegeBooking collegeBooking){
  25. return collegeBookingDao.checkBooking(collegeBooking);
  26. }
  27. public CollegeBooking checkELearningBooking(CollegeBooking collegeBooking){
  28. return collegeBookingDao.checkELearningBooking(collegeBooking);
  29. }
  30. public CollegeBooking getCollegeBooking(Integer id) {
  31. return collegeBookingDao.selectByPrimaryKey(id);
  32. }
  33. public int addELearningBooking(CollegeBooking collegeBooking) {
  34. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  35. CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
  36. if( collegeBooking1 != null) {
  37. collegeBooking.setId(collegeBooking1.getId());
  38. int tt = collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
  39. return tt;
  40. } else {
  41. try {
  42. collegeBooking.setDate(sdf.format(new Date()));
  43. CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
  44. collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
  45. collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
  46. collegeLearningDetail.setDate(sdf.format(new Date()));
  47. collegeLearningDetail.setStatus(1);
  48. collegeLearningDetail.setSys_type("YueLife");
  49. collegeLearningDetail.setRate("0");
  50. collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetail);
  51. collegeBookingDao.insertSelective(collegeBooking);
  52. return 1;
  53. }catch (Exception ex){
  54. ex.printStackTrace();
  55. return 0;
  56. }
  57. }
  58. }
  59. public int addCollegeBooking(CollegeBooking collegeBooking) {
  60. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  61. CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
  62. if( collegeBooking1 != null) {
  63. collegeBooking.setId(collegeBooking1.getId());
  64. int tt = collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
  65. return tt;
  66. } else {
  67. try {
  68. collegeBooking.setDate(sdf.format(new Date()));
  69. collegeBooking.setSys_type("YueSuo");
  70. CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
  71. collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
  72. collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
  73. collegeLearningDetail.setDate(sdf.format(new Date()));
  74. collegeLearningDetail.setStatus(1);
  75. collegeLearningDetail.setSys_type("YueSuo");
  76. collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetail);
  77. collegeBookingDao.insertSelective(collegeBooking);
  78. // pcount
  79. if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
  80. collegeCurriculumPracticeService.updatePCountAdd(collegeBooking.getCollege_code());
  81. }
  82. if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
  83. collegeCurriculumExperienceService.updatePCountAdd(collegeBooking.getCollege_code());
  84. }
  85. return 1;
  86. }catch (Exception ex){
  87. ex.printStackTrace();
  88. return 0;
  89. }
  90. }
  91. }
  92. public int deleteCollegeBooking(Integer id) {
  93. return collegeBookingDao.deleteByPrimaryKey(id);
  94. }
  95. public int updateCollegeBooking(CollegeBooking collegeBooking) {
  96. return collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
  97. }
  98. public int bookingCancel(CollegeBooking collegeBooking) {
  99. try {
  100. CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
  101. if( collegeBooking1 == null) {
  102. return 0;
  103. }
  104. collegeBookingDao.bookingCancel(collegeBooking);
  105. CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
  106. collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
  107. collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
  108. collegeLearningDetailService.deleteBookingCancel(collegeLearningDetail);
  109. //pcount
  110. if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
  111. collegeCurriculumPracticeService.updatePCountCancel(collegeBooking.getCollege_code());
  112. }
  113. if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
  114. collegeCurriculumExperienceService.updatePCountCancel(collegeBooking.getCollege_code());
  115. }
  116. return 1;
  117. }catch (Exception ex) {
  118. ex.printStackTrace();
  119. return 0;
  120. }
  121. }
  122. }