123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- package com.ygj.yuemum.service.college;
- import com.ygj.yuemum.dao.college.CollegeBookingDao;
- import com.ygj.yuemum.dao.college.CollegeTestDao;
- import com.ygj.yuemum.domain.college.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- @Service
- public class CollegeBookingService {
- @Autowired
- private CollegeBookingDao collegeBookingDao;
- @Autowired
- private CollegeLearningDetailService collegeLearningDetailService;
- @Autowired
- private CollegeCurriculumPracticeService collegeCurriculumPracticeService;
- @Autowired
- private CollegeCurriculumExperienceService collegeCurriculumExperienceService;
- public List<CollegeBooking> getCollegeBookings() {
- List<CollegeBooking> collegeBookings = collegeBookingDao.getAll();
- return collegeBookings;
- }
- public CollegeBooking checkBooking(CollegeBooking collegeBooking){
- return collegeBookingDao.checkBooking(collegeBooking);
- }
- public CollegeBooking checkELearningBooking(CollegeBooking collegeBooking){
- return collegeBookingDao.checkELearningBooking(collegeBooking);
- }
- public CollegeBooking getCollegeBooking(Integer id) {
- return collegeBookingDao.selectByPrimaryKey(id);
- }
- public int addELearningBooking(CollegeBooking collegeBooking) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
- if( collegeBooking1 != null) {
- collegeBooking.setId(collegeBooking1.getId());
- int tt = collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
- return tt;
- } else {
- try {
- collegeBooking.setDate(sdf.format(new Date()));
- CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
- collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
- collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
- collegeLearningDetail.setDate(sdf.format(new Date()));
- collegeLearningDetail.setStatus(1);
- collegeLearningDetail.setSys_type("YueLife");
- collegeLearningDetail.setRate("0");
- collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetail);
- collegeBookingDao.insertSelective(collegeBooking);
- return 1;
- }catch (Exception ex){
- ex.printStackTrace();
- return 0;
- }
- }
- }
- public int addCollegeBooking(CollegeBooking collegeBooking) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
- if( collegeBooking1 != null) {
- collegeBooking.setId(collegeBooking1.getId());
- int tt = collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
- return tt;
- } else {
- try {
- collegeBooking.setDate(sdf.format(new Date()));
- collegeBooking.setSys_type("YueSuo");
- CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
- collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
- collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
- collegeLearningDetail.setDate(sdf.format(new Date()));
- collegeLearningDetail.setStatus(1);
- collegeLearningDetail.setSys_type("YueSuo");
- collegeLearningDetailService.addCollegeLearningDetail(collegeLearningDetail);
- collegeBookingDao.insertSelective(collegeBooking);
- // pcount
- if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
- collegeCurriculumPracticeService.updatePCountAdd(collegeBooking.getCollege_code());
- }
- if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
- collegeCurriculumExperienceService.updatePCountAdd(collegeBooking.getCollege_code());
- }
- return 1;
- }catch (Exception ex){
- ex.printStackTrace();
- return 0;
- }
- }
- }
- public int deleteCollegeBooking(Integer id) {
- return collegeBookingDao.deleteByPrimaryKey(id);
- }
- public int updateCollegeBooking(CollegeBooking collegeBooking) {
- return collegeBookingDao.updateByPrimaryKeySelective(collegeBooking);
- }
- public int bookingCancel(CollegeBooking collegeBooking) {
- try {
- CollegeBooking collegeBooking1 = collegeBookingDao.checkBooking(collegeBooking);
- if( collegeBooking1 == null) {
- return 0;
- }
- collegeBookingDao.bookingCancel(collegeBooking);
- CollegeLearningDetail collegeLearningDetail = new CollegeLearningDetail();
- collegeLearningDetail.setOpen_id(collegeBooking.getOpenid());
- collegeLearningDetail.setC_code(collegeBooking.getCollege_code());
- collegeLearningDetailService.deleteBookingCancel(collegeLearningDetail);
- //pcount
- if(collegeBooking.getCollege_code().substring(0,1).equals("P")){
- collegeCurriculumPracticeService.updatePCountCancel(collegeBooking.getCollege_code());
- }
- if(collegeBooking.getCollege_code().substring(0,1).equals("E")){
- collegeCurriculumExperienceService.updatePCountCancel(collegeBooking.getCollege_code());
- }
- return 1;
- }catch (Exception ex) {
- ex.printStackTrace();
- return 0;
- }
- }
- }
|