数据库
EnrollJoinModel.DB_STRUCTURE = {
_pid: 'string|true', ENROLL_JOIN_ID: 'string|true', ENROLL_JOIN_ENROLL_ID: 'string|true|comment=报名PK', ENROLL_JOIN_IS_ADMIN: 'int|true|default=0|comment=是否管理员添加 0/1', ENROLL_JOIN_USER_ID: 'string|true|comment=用户ID', ENROLL_JOIN_FORMS: 'array|true|default=[]|comment=表单', ENROLL_JOIN_STATUS: 'int|true|default=1|comment=状态 0=待审核 1=报名成功, 99=审核未过', ENROLL_JOIN_REASON: 'string|false|comment=审核拒绝或者取消理由', ENROLL_JOIN_LAST_TIME: 'int|true|default=0', ENROLL_JOIN_ADD_TIME: 'int|true', ENROLL_JOIN_EDIT_TIME: 'int|true', ENROLL_JOIN_ADD_IP: 'string|false', ENROLL_JOIN_EDIT_IP: 'string|false',
}; EnrollModel.DB_STRUCTURE = {
_pid: 'string|true', ENROLL_ID: 'string|true', ENROLL_TITLE: 'string|true|comment=标题', ENROLL_STATUS: 'int|true|default=1|comment=状态 0=未启用,1=使用中', ENROLL_CATE_ID: 'string|true|default=0|comment=分类', ENROLL_CATE_NAME: 'string|false|comment=分类冗余', ENROLL_CANCEL_SET: 'int|true|default=1|comment=取消设置 0=不允,1=允许,2=仅截止前可取消,3=审核后不可取消', ENROLL_EDIT_SET: 'int|true|default=1|comment=修改 0=不允,1=允许,2=仅截止前可,3=审核后不可修改', ENROLL_CHECK_SET: 'int|true|default=0|comment=审核 0=不需要审核,1=需要审核', ENROLL_MAX_CNT: 'int|true|default=20|comment=人数上限 0=不限', ENROLL_START: 'int|false|comment=开始时间', ENROLL_END: 'int|false|comment=截止时间', ENROLL_ORDER: 'int|true|default=9999', ENROLL_VOUCH: 'int|true|default=0', ENROLL_FORMS: 'array|true|default=[]', ENROLL_OBJ: 'object|true|default={}', ENROLL_JOIN_FORMS: 'array|true|default=[]', ENROLL_QR: 'string|false', ENROLL_VIEW_CNT: 'int|true|default=0', ENROLL_JOIN_CNT: 'int|true|default=0', ENROLL_ADD_TIME: 'int|true', ENROLL_EDIT_TIME: 'int|true', ENROLL_ADD_IP: 'string|false', ENROLL_EDIT_IP: 'string|false',
};
核心逻辑
async enrollJoin(userId, enrollId, forms) { // 登记是否结束 let whereEnroll = { _id: enrollId, ENROLL_STATUS: EnrollModel.STATUS.COMM
} let enroll = await EnrollModel.getOne(whereEnroll); if (!enroll) this.AppError('该' + ENROLL_NAME + '不存在或者已经停止'); // 是否登记开始 if (enroll.ENROLL_START > this._timestamp) this.AppError('该' + ENROLL_NAME + '尚未开始'); // 是否过了登记截止期 if (enroll.ENROLL_END < this._timestamp) this.AppError('该' + ENROLL_NAME + '已经截止'); // 人数是否满 if (enroll.ENROLL_MAX_CNT > 0) { let whereCnt = { ENROLL_JOIN_ENROLL_ID: enrollId, ENROLL_JOIN_STATUS: ['in', [EnrollJoinModel.STATUS.WAIT, EnrollJoinModel.STATUS.SUCC]]
} let cntJoin = await EnrollJoinModel.count(whereCnt); if (cntJoin >= enroll.ENROLL_MAX_CNT) this.AppError('该' + ENROLL_NAME + '人数已满');
} // 自己是否已经有登记 let whereMy = { ENROLL_JOIN_USER_ID: userId, ENROLL_JOIN_ENROLL_ID: enrollId, ENROLL_JOIN_STATUS: ['in', [EnrollJoinModel.STATUS.WAIT, EnrollJoinModel.STATUS.SUCC]]
} let my = await EnrollJoinModel.getOne(whereMy); if (my) { if (my.ENROLL_JOIN_STATUS == EnrollJoinModel.STATUS.WAIT) this.AppError('您已经填报,正在等待审核,无须重复填报'); else this.AppError('您已经填报成功,无须重复填报');
} // 入库 let data = { ENROLL_JOIN_USER_ID: userId, ENROLL_JOIN_ENROLL_ID: enrollId, ENROLL_JOIN_STATUS: (enroll.ENROLL_CHECK_SET == 0) ? EnrollJoinModel.STATUS.SUCC : EnrollJoinModel.STATUS.WAIT, ENROLL_JOIN_FORMS: forms
} let enrollJoinId = await EnrollJoinModel.insert(data); // 统计数量 this.statEnrollJoin(enrollId); let check = enroll.ENROLL_CHECK_SET; return { enrollJoinId, check }
}
UI设计
后台
联系我们
友情链接:
小程序开发 小程序定制开发 小程序商店 微信小程序开发文档 分销商城小程序 电商小程序开发 百家号 商城小程序 微信小程序开发API 小程序定制 生鲜小程序 全平台开发 网站建设 外包开发 自主研发产品 sitemap robots热门地区:
松江开发公司 青浦开发公司 崇明开发公司 杨浦开发公司 宝山开发公司 奉贤开发公司 虹口开发公司 闵行开发公司 长宁开发公司 静安开发公司 黄浦开发公司 嘉定开发公司 徐汇开发公司 金山开发公司 上海开发公司 南昌开发公司 杭州开发公司 上饶开发公司COPYRIGHT 2009-2016 www.guanzhiweb.com ALL RIGHTS RESERVED
版权所有 上海观智网络科技有限公司