付智勇

no message

@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 var status = require('../util/resTemplate') 2 var status = require('../util/resTemplate')
3 var studentMeetingService = require('../services/studentMeetingService') 3 var studentMeetingService = require('../services/studentMeetingService')
4 var uuid = require('../util/UuidUtil') 4 var uuid = require('../util/UuidUtil')
  5 +const moment = require('moment')
5 var emailUtil = require('../util/emailUtil') 6 var emailUtil = require('../util/emailUtil')
6 7
7 8
@@ -24,6 +25,7 @@ studentMeetingController.prototype.addStudentMeeting = async(ctx, next)=>{ @@ -24,6 +25,7 @@ studentMeetingController.prototype.addStudentMeeting = async(ctx, next)=>{
24 var id32 = await uuid.db32(); 25 var id32 = await uuid.db32();
25 body.id = id32; 26 body.id = id32;
26 body.status = 0; 27 body.status = 0;
  28 + body.createTime = moment(new Date()).format("YYYY-MM-DD HH:MM:SS ");
27 let studentMeetings= await studentMeetingService.addStudentMeeting(body); 29 let studentMeetings= await studentMeetingService.addStudentMeeting(body);
28 return studentMeetings; 30 return studentMeetings;
29 } catch (error) { 31 } catch (error) {
@@ -25,6 +25,11 @@ var studentMeeting = sequelize.define('3m_student_meeting', { @@ -25,6 +25,11 @@ var studentMeeting = sequelize.define('3m_student_meeting', {
25 allowNull: false, 25 allowNull: false,
26 type:Sequelize.STRING(32), 26 type:Sequelize.STRING(32),
27 field: "status" 27 field: "status"
  28 + },
  29 + createTime: {
  30 + allowNull: false,
  31 + type:Sequelize.STRING(32),
  32 + field: "create_time"
28 } 33 }
29 },{ 34 },{
30 timestamps: false, 35 timestamps: false,
1 var sutudentMeeting = require('../model/studentMeetingModel'); 1 var sutudentMeeting = require('../model/studentMeetingModel');
  2 +var userModel = require('../model/userModel');
2 var status = require('../util/resTemplate'); 3 var status = require('../util/resTemplate');
3 var saitMd5 = require('../util/saltMD5'); 4 var saitMd5 = require('../util/saltMD5');
4 var sequelize = require('../config'); 5 var sequelize = require('../config');
@@ -13,7 +14,17 @@ function sutudentMeetingService(){ @@ -13,7 +14,17 @@ function sutudentMeetingService(){
13 14
14 sutudentMeetingService.prototype.addStudentMeeting = async(body)=>{ 15 sutudentMeetingService.prototype.addStudentMeeting = async(body)=>{
15 try { 16 try {
16 - var t = await sequelize.transaction({ autocommit: true }) 17 + var t = await sequelize.transaction({ autocommit: true })
  18 + let user = await userModel.findOne({where:{id:body.studentId}});
  19 + if(!user){
  20 + t.rollback();
  21 + return {code:300,msg:'用户不存在'}
  22 + }
  23 + let oldSutudentMeeting = await sutudentMeeting.findOne({where:{studentId:body.studentId,meetingId:body.meetingId}});
  24 + if(oldSutudentMeeting){
  25 + t.rollback();
  26 + return {code:300,msg:'您已预约这堂课',data:oldSutudentMeeting}
  27 + }
17 let Meeting = await meetingModel.findOne({where:{id:body.meetingId}}); 28 let Meeting = await meetingModel.findOne({where:{id:body.meetingId}});
18 if(!Meeting){ 29 if(!Meeting){
19 t.rollback(); 30 t.rollback();