Файловый менеджер - Редактировать - /home/freeclou/app.optimyar.com/front-web/build/assets/fonts/iran-yekan/beflpn/user-course.zip
Назад
PK sg[p��K= = config/routes.jsonnu �[��� { "routes": [ { "method": "GET", "path": "/user-courses", "handler": "user-course.find", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/count", "handler": "user-course.count", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/getCourseUsers/:levelId", "handler": "user-course.getCourseUsers", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/getTeacherUsers", "handler": "user-course.getTeacherUsers", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/getFactorInfo/:id", "handler": "user-course.getFactorInfo", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/isCourseLive/:id", "handler": "user-course.isCourseLive", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/joinUserToMeeting/:id", "handler": "user-course.joinUserToMeeting", "config": { "policies": [] } }, { "method": "GET", "path": "/user-courses/:id", "handler": "user-course.findOne", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses", "handler": "user-course.create", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses/paycallBack", "handler": "user-course.paycallBack", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses/pay", "handler": "user-course.pay", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses/checkOfflineAccess", "handler": "user-course.checkOfflineAccess", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses/verifyPay", "handler": "user-course.verifyPay", "config": { "policies": [] } }, { "method": "POST", "path": "/user-courses/updateAccess", "handler": "user-course.updateAccess", "config": { "policies": [] } }, { "method": "PUT", "path": "/user-courses/:id", "handler": "user-course.update", "config": { "policies": [] } }, { "method": "DELETE", "path": "/user-courses/:id", "handler": "user-course.delete", "config": { "policies": [] } } ] } PK sg[&`/hG hG controllers/user-course.jsnu �[��� 'use strict'; const fs = require("fs"); const moment = require("jalali-moment"); const {parseMultipartData, sanitizeEntity} = require('strapi-utils'); const url = require("url"); module.exports = { async getCourseUsers(ctx){ //const {user} = ctx.state; const {levelId} = ctx.params; const confirmUsers = await strapi.services["user-course"].find({ course_levels_in: [levelId], _limit :-1, isConfirm: true }); let result={}; if (confirmUsers && confirmUsers.length){ result ={courseTitle:confirmUsers[0].course_levels[0].title,items:[]} result.items = confirmUsers.map(cu => { if (cu.expiredDate==null){ let expiredDate = cu.expiredDate; if (!expiredDate){ expiredDate= strapi.services.helpers.addDays(cu.factorDate,366); } cu.expiredDate= expiredDate; } return { name:cu.user.name, phoneNo:cu.user.phoneNo, buyDate:cu.buyDate, expiredDate:cu.expiredDate, inactiveLicense:cu.inactiveLicense, canDownload:cu.canDownload, buyPrice:cu.buyPrice, payBy:cu.payBy, expiredInDays: strapi.services.helpers.howMuchDaysLeft(cu.expiredDate) } }); } ctx.send(result); }, async getTeacherUsers(ctx) { const {user} = ctx.state; const teacherCourse = await strapi.services["course-level"].getTeacherLevels(user.id); if (teacherCourse.result) { const levelIds = teacherCourse.entity.map(x => x.id); const confirmUsers = await strapi.services["user-course"].find({ course_levels_in: levelIds, _limit :-1, isConfirm: true }); const result = []; confirmUsers.map(cu => { let exist = result.find(x => x.id === cu.user.id); if (!exist) { exist = {id: cu.user.id, name: cu.user.name + " " + (cu.user.family? cu.user.family:''), phoneNo: cu.user.phoneNo, courses: []}; result.push(exist); } if (!exist.courses.find(x => x.id === cu.id)) { exist.courses.push({ id: cu.id, buyDate: cu.buyDate, discountAmount: cu.discount ? cu.discount.amount : 0, buyPrice: cu.buyPrice, level: cu.course_levels[0].title, canDownload: cu.canDownload, inactiveLicense: cu.inactiveLicense }) } }); ctx.send(result); } else { return ctx.badRequest(null, teacherCourse.entity); } }, async updateAccess(ctx) { const {list} = ctx.request.body; try { list.map(async x => { await strapi.services["user-course"].update({id: x.id}, x); }); return ctx.send(true); } catch (ex) { return ctx.badRequest(null, ex.message); } }, async paycallBack(ctx){ console.log("BODY:::",ctx.request.body); let {RefId,ResCode,SaleOrderId,SaleReferenceId,CardHolderPan,FinalAmount} = ctx.request.body; const userCourse = await strapi.services["user-course"].findOne({authority:RefId}); if (ResCode==='0' && userCourse.buyPrice * 10 != Number(FinalAmount) ){ ResCode= 'InAmount'; } await strapi.services["user-course"].update({id: userCourse.id}, { bankRefNo: ResCode=='0'? SaleReferenceId: SaleOrderId, payCardNo:CardHolderPan }); return ctx.redirect(`https://app.optimyar.com/paycallBack?refId=${RefId}&resCode=${ResCode}`); }, async verifyPay(ctx) { const {authority,isMellat} = ctx.request.body; const {user} = ctx.state; let userCourse = await strapi.services["user-course"].findOne({user: user.id, authority}); if (userCourse === null) { return ctx.badRequest(null, "errors.factorNotFound") } let result=null; if (isMellat){ result = await strapi.services.helpers.verifyMellatPay(userCourse.factorNumber, userCourse.buyPrice,Number(userCourse.bankRefNo)); }else{ result = await strapi.services.helpers.verifyZarinpalPay(authority, userCourse.buyPrice); } const titles = userCourse.course_levels.map(x => x.title); const productName = titles.join(" - "); if (result.result === false) { strapi.services.helpers.sendEmail(userCourse.user.email, "ثبت نام دوره آپتیم یار", `<p style="color: red;font-size: 24px">ثبت نام شما با خطا مواجه شده است</p><p>دوره مد نظز شما : ${productName}</p><p>شماره فاکتور : ${userCourse.factorNumber}</p>`).then(); return ctx.badRequest(null, result.entity); } if (result.entity.code === 100 || result.entity.code === 101) { const buyDate = new Date(); await strapi.services["user-course"].update({id: userCourse.id}, { buyDate, bankRefNo: isMellat? userCourse.bankRefNo: result.entity.ref_id.toString(), isConfirm: true, payCardNo: isMellat? userCourse.payCardNo: result.entity.card_pan, payBy: isMellat ? "Mellat" : "Zarinpal" }); let inputData = [{ "course_title": productName, }]; //delete if discount is disposable if (userCourse.discount && userCourse.discount.disposable) { //may user use with together is same time const discount = await strapi.services.discount.verifyDiscountForUse(userCourse.discount); if (discount.result === false) { return ctx.badRequest(null, discount.entity); } await strapi.services.discount.update({id: userCourse.discount.id}, {isEnabled: false}); } await strapi.services.helpers.sendSms(userCourse.user.phoneNo, "jvcbauf2c5", inputData); const data = fs.readFileSync('resources/emailTemplate/Factor.html', 'utf8'); const faBuyDate = moment.from(buyDate.toUTCString(), 'en').locale("fa").format("YYYY/MM/DD HH:mm"); const html = data.replace(/COURSE_TITLE/g, productName) .replace(/FACTOR_NUMBER/g, userCourse.factorNumber) .replace(/PAY_AMOUNT/g, userCourse.buyPrice + " تومان ") .replace(/COURSE_LEVEL_ID/g, userCourse.course_levels[0].id) .replace(/USER_PHONE_NO/g, userCourse.user.phoneNo) .replace(/USER_FULL_NAME/g, userCourse.user.name) .replace(/BUY_Date/g, faBuyDate); strapi.services.helpers.sendEmail(userCourse.user.email, "تاییدیه ثبتنام و شرکت در دورههای آکادمی آموزشی و پژوهشی آپتیمیار", html).then(); const invite= fs.readFileSync('resources/emailTemplate/InvitToTelegram.html', 'utf8'); const inviteHtml = invite.replace(/COURSE_TITLE/g, productName) .replace(/USER_FULL_NAME/g, userCourse.user.name); strapi.services.helpers.sendEmail(userCourse.user.email, "آکادمی آموزشی و پژوهشی آپتیمیار", inviteHtml).then(); inputData = [{ "name": userCourse.user.name, }]; await strapi.services.helpers.sendSms(userCourse.user.phoneNo, "drmdp9hfi60p8hc", inputData); return ctx.send({ bankRefNo: isMellat? userCourse.authority: result.entity.ref_id, factorNumber: userCourse.factorNumber, paidAmount: userCourse.buyPrice, isOk: true, productName }); } else { strapi.services.helpers.sendEmail(userCourse.user.email, "ثبت نام دوره آپتیم یار", `<p style="color: red;font-size: 24px">ثبت نام شما با خطا مواجه شده است</p><p>دوره مد نظز شما : ${productName}</p><p>شماره فاکتور : ${userCourse.factorNumber}</p>`).then(); return ctx.send({ errorCode: result.entity.code, isOk: false, productName }) } }, async pay(ctx) { const {id,payType} = ctx.request.body; const userCourse = await strapi.services["user-course"].findOne({id}); if (userCourse == null) { return ctx.badRequest(null, "buyCourse.errors.factorNotFound"); } let discount; if (userCourse.discount && userCourse.discount.id) { discount = await strapi.services.discount.verifyDiscountForUse(userCourse.discount); if (discount.result === false) { return ctx.badRequest(null, discount.entity); } } const levels = await strapi.services["course-level"].getByIds(userCourse.course_levels); const prices = levels.map(x => x.price); userCourse.buyPrice = await strapi.services["user-course"].calculatePrice(userCourse.groupCount, prices, discount ? discount.entity.amount : 0); const amount = userCourse.buyPrice; const description = `فاکتور شماره ${userCourse.factorNumber} آکادمی آموزشی و پژوهشی آپتیم یار`; const mobile = userCourse.user.phoneNo.toString(); const email = userCourse.user.email; let result=null; if (payType===2){ result = await strapi.services.helpers.verifyForPayZarinpal(amount, description, mobile, email); }else{ //result = await strapi.services.helpers.verifyForPayZarinpal(amount, description, mobile, email); result = await strapi.services.helpers.requestForPayBP(amount, description, mobile, email,userCourse.factorNumber); } if (result.result === false) { return ctx.badRequest(null, result.entity); } const update = await strapi.services["user-course"].update({id: userCourse.id}, { authority: result.entity.authority }); return ctx.send(result.entity); //const userCourse= await strapi.services["user-course"].verifyBeforePay(factorId); }, async create(ctx) { let entity; if (ctx.is('multipart')) { const {data, files} = parseMultipartData(ctx); entity = await strapi.services["user-course"].create(data, {files}); } else { const {user} = ctx.state; const model = ctx.request.body; const {discountCode} = ctx.request.body; let discount; if (discountCode) { discount = await strapi.services.discount.verifyGetByCodeAndCourse(discountCode, model.course_levels[0]); if (discount.result === false) { return ctx.badRequest(null, discount.entity); } } const levels = await strapi.services["course-level"].getByIds(model.course_levels); let isValid = await strapi.services["user-course"].isValidData(model, discount ? discount.entity : null, levels); if (isValid !== true) { return ctx.badRequest(null, isValid); } model.discount = discount ? discount.entity.id : null; model.factorDate = new Date(); model.factorNumber = await strapi.services["user-course"].getNextFactorNumber(); model.user = user.id; if (discount && discount.entity.isFreePay) { model.buyPrice = 0; model.isConfirm = true; model.buyDate = model.factorDate; model.payBy = "FreePayDiscount"; model.bankRefNo = "1000"; //delete if discount is disposable if (discount && discount.entity.disposable) { //may user use with together is same time discount = await strapi.services.discount.verifyDiscountForUse(discount.entity); if (discount.result === false) { return ctx.badRequest(null, discount.entity); } await strapi.services.discount.update({id: discount.entity.id}, {isEnabled: false}); } //-------------------- const titles = levels.map(x => x.title); const productName = titles.join(" - "); let inputData = [{ "course_title": productName, }]; await strapi.services.helpers.sendSms(user.phoneNo, "jvcbauf2c5", inputData); const data = fs.readFileSync('resources/emailTemplate/Factor.html', 'utf8'); const faBuyDate = moment.from(model.buyDate.toUTCString(), 'en').locale("fa").format("YYYY/MM/DD HH:mm"); const html = data.replace(/COURSE_TITLE/g, productName) .replace(/FACTOR_NUMBER/g, model.factorNumber) .replace(/PAY_AMOUNT/g, " رایگان ") .replace(/COURSE_LEVEL_ID/g, levels[0].id) .replace(/USER_PHONE_NO/g, user.phoneNo) .replace(/USER_FULL_NAME/g, user.name) .replace(/BUY_Date/g, faBuyDate); strapi.services.helpers.sendEmail(user.email, "تاییدیه ثبتنام و شرکت در دورههای آکادمی آموزشی و پژوهشی آپتیمیار", html).then(); const invite= fs.readFileSync('resources/emailTemplate/InvitToTelegram.html', 'utf8'); const inviteHtml = invite.replace(/COURSE_TITLE/g, productName) .replace(/USER_FULL_NAME/g, user.name); strapi.services.helpers.sendEmail(user.email, "آکادمی آموزشی و پژوهشی آپتیمیار", inviteHtml).then(); inputData = [{ "name": user.name, }]; await strapi.services.helpers.sendSms(user.phoneNo, "drmdp9hfi60p8hc", inputData); } else { const prices = levels.map(x => x.price); model.buyPrice = await strapi.services["user-course"].calculatePrice(model.groupCount, prices, discount ? discount.entity.amount : 0); } entity = await strapi.services["user-course"].create(model); } return sanitizeEntity(entity, {model: strapi.models["user-course"]}); }, async isCourseLive(ctx){ const {user} = ctx.state; const {id} = ctx.params; const response={ isAdobe:false, isLive:false, link:'', liveLevelId:null } const uc = await strapi.services["user-course"].findOne({id}); const liveLevelId = await strapi.services["user-course"].isUserCourseMeetingRunning(uc.course_levels[0]); if (liveLevelId && liveLevelId.isAdobe) { response.isAdobe = true; link.link = liveLevelId.link } else { response.isLive = liveLevelId != null; response.liveLevelId = liveLevelId; } return ctx.send(response); }, async joinUserToMeeting(ctx) { const {user} = ctx.state; const {id} = ctx.params; //we can use this function to join just registerd user to adobe meeting //https://helpx.adobe.com/adobe-connect/webservices/create-meetings.html const userCourse = await strapi.services["user-course"].findOne({id}); if (userCourse.user.id !== user.id || !userCourse.isConfirm) { return ctx.badRequest(null, "buyCourse.errors.courseIsNotConfirm"); } const liveLevelId = await strapi.services["user-course"].isUserCourseMeetingRunning(userCourse.course_levels[0]); if (liveLevelId == null) { return ctx.badRequest(null, "errors.classIsNotLive"); } const info = await strapi.services.helpers.getBBBMeetingInfo(liveLevelId); let fullName = user.name + " "; if (user.family){ fullName += user.family; } const userId= user.id+"-"+user.phoneNo; const result = { joinUrl: await strapi.services.helpers.joinUserToMeeting(fullName, info.meetingID, info.attendeePW, userId, false), disallowRecording: !userCourse.inactiveLicense && info.metadata.disallowrecording }; return ctx.send(result); }, async checkOfflineAccess(ctx){ const {fileName}= ctx.request.body; const {user} = ctx.state; const session = await strapi.services.session.findOne({internalMeetingID:fileName}); if (!session){ return ctx.send({result:false,error:"مشخصات جلسه مرتبط یافت نشد"}); } const levelId = session.course_level.id; const userCourse= await strapi.services["user-course"].findOne({course_levels_in:[levelId],user:user.id,isConfirm:true}); if (!userCourse){ return ctx.send({result:false,error:"شما دسترسی به این دوره ندارید"}); } if (!userCourse.canDownload){ return ctx.send({result:false,error:"شما اجازه پخش آفلاین جلسات این دوره را ندارید"}); } return ctx.send({result:true}); }, async getFactorInfo(ctx){ const {id} = ctx.params; const entity = await strapi.services["user-course"].findOne({id}); return sanitizeEntity(entity, {model: strapi.models["user-course"]}); }, async find(ctx) { const isVersionOk= await strapi.services.helpers.checkVersion(ctx); if (!isVersionOk){ return ctx.badRequest(null, "NEW VERSION RELEASED"); } let entities; const {user} = ctx.state; const {query} = ctx; delete query.version; if (!strapi.services.helpers.isAdmin(user)) { query["user_eq"] = user.id; } else { const teacherLevels = await strapi.query("course-level").find({teacher: user.id}); query["course_levels_in"] = teacherLevels.map(x => x.id); query["user_ne"]=null; } //query["_sort"]="updateAt:DESC"; if (query._q) { entities = await strapi.services["user-course"].search(query); } else { entities = await strapi.services["user-course"].find(query); } entities.map(uc => { uc.course_levels[0].isLive = false; }); return entities.map(entity => sanitizeEntity(entity, {model: strapi.models["user-course"]})); }, }; PK sg[V� ��� �� $ documentation/1.0.0/user-course.jsonnu �[��� { "paths": { "/user-courses": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "_limit", "in": "query", "required": false, "description": "Maximum number of results possible", "schema": { "type": "integer" }, "deprecated": false }, { "name": "_sort", "in": "query", "required": false, "description": "Sort according to a specific field.", "schema": { "type": "string" }, "deprecated": false }, { "name": "_start", "in": "query", "required": false, "description": "Skip a specific number of entries (especially useful for pagination)", "schema": { "type": "integer" }, "deprecated": false }, { "name": "=", "in": "query", "required": false, "description": "Get entries that matches exactly your input", "schema": { "type": "string" }, "deprecated": false }, { "name": "_ne", "in": "query", "required": false, "description": "Get records that are not equals to something", "schema": { "type": "string" }, "deprecated": false }, { "name": "_lt", "in": "query", "required": false, "description": "Get record that are lower than a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_lte", "in": "query", "required": false, "description": "Get records that are lower than or equal to a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_gt", "in": "query", "required": false, "description": "Get records that are greater than a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_gte", "in": "query", "required": false, "description": "Get records that are greater than or equal a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_contains", "in": "query", "required": false, "description": "Get records that contains a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_containss", "in": "query", "required": false, "description": "Get records that contains (case sensitive) a value", "schema": { "type": "string" }, "deprecated": false }, { "name": "_in", "in": "query", "required": false, "description": "Get records that matches any value in the array of values", "schema": { "type": "array", "items": { "type": "string" } }, "deprecated": false }, { "name": "_nin", "in": "query", "required": false, "description": "Get records that doesn't match any value in the array of values", "schema": { "type": "array", "items": { "type": "string" } }, "deprecated": false } ] }, "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewUser-course" } } } } } }, "/user-courses/count": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [] } }, "/user-courses/getCourseUsers/{levelId}": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "levelId", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] } }, "/user-courses/getTeacherUsers": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [] } }, "/user-courses/getFactorInfo/{id}": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] } }, "/user-courses/isCourseLive/{id}": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] } }, "/user-courses/joinUserToMeeting/{id}": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] } }, "/user-courses/{id}": { "get": { "deprecated": false, "description": "", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] }, "put": { "deprecated": false, "description": "Update a record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/NewUser-course" } } } }, "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] }, "delete": { "deprecated": false, "description": "Delete a record", "responses": { "200": { "description": "deletes a single record based on the ID supplied", "content": { "application/json": { "schema": { "type": "integer", "format": "int64" } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "parameters": [ { "name": "id", "in": "path", "description": "", "deprecated": false, "required": true, "schema": { "type": "string" } } ] } }, "/user-courses/paycallBack": { "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } } } }, "/user-courses/pay": { "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } } } }, "/user-courses/checkOfflineAccess": { "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } } } }, "/user-courses/verifyPay": { "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } } } }, "/user-courses/updateAccess": { "post": { "deprecated": false, "description": "Create a new record", "responses": { "200": { "description": "response", "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } }, "403": { "description": "Forbidden", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "404": { "description": "Not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }, "default": { "description": "unexpected error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } }, "summary": "", "tags": [ "User-course" ], "requestBody": { "description": "", "required": true, "content": { "application/json": { "schema": { "properties": { "foo": { "type": "string" } } } } } } } } }, "components": { "schemas": { "User-course": { "required": [ "id", "factorDate", "factorNumber" ], "properties": { "id": { "type": "string" }, "user": { "required": [ "id", "username", "email", "name", "phoneNo" ], "properties": { "id": { "type": "string" }, "username": { "type": "string" }, "email": { "type": "string" }, "provider": { "type": "string" }, "password": { "type": "string" }, "resetPasswordToken": { "type": "string" }, "confirmed": { "type": "boolean" }, "blocked": { "type": "boolean" }, "role": { "type": "string" }, "name": { "type": "string" }, "family": { "type": "string" }, "phoneNo": { "type": "integer" }, "avatarImage": { "type": "string" }, "nationalCode": { "type": "string" }, "created_by": { "type": "string" }, "updated_by": { "type": "string" } } }, "course_levels": { "type": "array", "items": { "required": [ "id", "title", "price", "fromDate", "toDate" ], "properties": { "id": { "type": "string" }, "title": { "type": "string" }, "coverImage": { "type": "string" }, "price": { "type": "integer" }, "desc": { "type": "string" }, "enableDiscount": { "type": "boolean" }, "sessions": { "type": "array", "items": { "type": "string" } }, "fromDate": { "type": "string" }, "toDate": { "type": "string" }, "status": { "type": "string", "enum": [ "register", "progress", "finish", "preRegister", "registerFinish" ] }, "location": { "type": "string" }, "infoLink": { "type": "string" }, "isLive": { "type": "boolean" }, "isGeneral": { "type": "boolean" }, "course": { "type": "string" }, "teacher": { "type": "string" }, "desc2": { "type": "string" }, "created_by": { "type": "string" }, "updated_by": { "type": "string" } } } }, "discount": { "required": [ "id", "code", "amount", "fromDate", "toDate", "key" ], "properties": { "id": { "type": "string" }, "code": { "type": "string" }, "amount": { "type": "number" }, "fromDate": { "type": "string" }, "toDate": { "type": "string" }, "isEnabled": { "type": "boolean" }, "title": { "type": "string" }, "isAutoGenerated": { "type": "boolean" }, "key": { "type": "string" }, "minGroupCount": { "type": "integer" }, "isGroup": { "type": "boolean" }, "disposable": { "type": "boolean" }, "course_levels": { "type": "array", "items": { "type": "string" } }, "isFreePay": { "type": "boolean" }, "maxUseCount": { "type": "integer" }, "created_by": { "type": "string" }, "updated_by": { "type": "string" } } }, "factorDate": { "type": "string", "format": "date-time" }, "factorNumber": { "type": "integer" }, "groupCount": { "type": "integer" }, "buyDate": { "type": "string", "format": "date-time" }, "buyPrice": { "type": "integer" }, "isConfirm": { "type": "boolean", "default": false }, "bankRefNo": { "type": "string" }, "payDocument": { "required": [ "id", "name", "hash", "mime", "size", "url", "provider" ], "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "alternativeText": { "type": "string" }, "caption": { "type": "string" }, "width": { "type": "integer" }, "height": { "type": "integer" }, "formats": { "type": "object" }, "hash": { "type": "string" }, "ext": { "type": "string" }, "mime": { "type": "string" }, "size": { "type": "number" }, "url": { "type": "string" }, "previewUrl": { "type": "string" }, "provider": { "type": "string" }, "provider_metadata": { "type": "object" }, "related": { "type": "string" }, "created_by": { "type": "string" }, "updated_by": { "type": "string" } } }, "payCardNo": { "type": "string" }, "payBy": { "type": "string", "enum": [ "Zarinpal", "Receipt", "Mellat", "FreePayDiscount" ] }, "authority": { "type": "string" }, "canDownload": { "type": "boolean" }, "inactiveLicense": { "type": "boolean" }, "expiredDate": { "type": "string", "format": "date" } } }, "NewUser-course": { "required": [ "factorDate", "factorNumber" ], "properties": { "user": { "type": "string" }, "course_levels": { "type": "array", "items": { "type": "string" } }, "discount": { "type": "string" }, "factorDate": { "type": "string", "format": "date-time" }, "factorNumber": { "type": "integer" }, "groupCount": { "type": "integer" }, "buyDate": { "type": "string", "format": "date-time" }, "buyPrice": { "type": "integer" }, "isConfirm": { "type": "boolean", "default": false }, "bankRefNo": { "type": "string" }, "payCardNo": { "type": "string" }, "payBy": { "type": "string", "enum": [ "Zarinpal", "Receipt", "Mellat", "FreePayDiscount" ] }, "authority": { "type": "string" }, "canDownload": { "type": "boolean" }, "inactiveLicense": { "type": "boolean" }, "expiredDate": { "type": "string", "format": "date" }, "created_by": { "type": "string" }, "updated_by": { "type": "string" } } } } }, "tags": [] }PK sg[��ٮ � models/user-course.jsnu �[��� 'use strict'; /** * Read the documentation (https://strapi.io/documentation/v3.x/concepts/models.html#lifecycle-hooks) * to customize this model */ module.exports = {}; PK sg[�@�� � models/user-course.settings.jsonnu �[��� { "kind": "collectionType", "collectionName": "user_courses", "info": { "name": "userCourse", "description": "" }, "options": { "increments": true, "timestamps": true, "draftAndPublish": false }, "attributes": { "user": { "plugin": "users-permissions", "model": "user" }, "course_levels": { "collection": "course-level" }, "discount": { "model": "discount" }, "factorDate": { "type": "datetime", "required": true }, "factorNumber": { "type": "integer", "required": true }, "groupCount": { "type": "integer" }, "buyDate": { "type": "datetime", "required": false }, "buyPrice": { "type": "integer", "required": false }, "isConfirm": { "type": "boolean", "default": false, "required": false }, "bankRefNo": { "type": "string", "required": false }, "payDocument": { "model": "file", "via": "related", "allowedTypes": [ "files", "images" ], "plugin": "upload", "required": false, "pluginOptions": {} }, "payCardNo": { "type": "string" }, "payBy": { "type": "enumeration", "enum": [ "Zarinpal", "Receipt", "Mellat", "FreePayDiscount" ] }, "authority": { "type": "string" }, "canDownload": { "type": "boolean" }, "inactiveLicense": { "type": "boolean" }, "expiredDate": { "type": "date" } } } PK sg[�vV2U U services/user-course.jsnu �[��� 'use strict'; const axios = require('axios'); const xml2js = require('xml2js'); /** * Read the documentation (https://strapi.io/documentation/v3.x/concepts/services.html#core-services) * to customize this service */ module.exports = { isValidData(buyData, discount, levels = null) { if (discount && discount.isGroup && discount.minGroupCount > buyData.groupCount) { return "buyCourse.errors.invalidGroupCount" } if (levels != null) { const preLevels = levels.filter(x => x.status === "preRegister"); if (preLevels.length > 0) { return "buyCourse.errors.courseIsNotForBuy"; } } return true; }, async getNextFactorNumber() { const obj = await strapi.query('user-course').find({_limit: 1, _sort: 'factorNumber:desc'}); if (obj == null || obj.length === 0) { return 990001;//start number } else { return obj[0].factorNumber + 1;//next number } }, async isLevelRunning(levelId) { try { const mInfo = await strapi.services.helpers.getBBBMeetingInfo(levelId); return mInfo.returncode === "SUCCESS" && mInfo.running === true && !mInfo.metadata.isprivate; } catch (ex) { strapi.services["system-log"].create({ type: "getBBBMeetingInfo", message: ex }); return false; } }, async isUserCourseMeetingRunning(courseLevelInfo) { let adobeInfo = await strapi.services.helpers.isAdobeRunning(courseLevelInfo.id, true); if (adobeInfo !== false) { return {isAdobe: true, link: adobeInfo}; } else { let levelId = courseLevelInfo.id; let isRunning = await this.isLevelRunning(courseLevelInfo.id); let isAdobe = null; if (!isRunning && courseLevelInfo.isGeneral && courseLevelInfo.course) { const courseInfo = await strapi.services.course.findOne({id: courseLevelInfo.course}); const arr = courseInfo.course_levels.map(level => { return new Promise(async resolve => { adobeInfo = await strapi.services.helpers.isAdobeRunning(level.id, true); if (adobeInfo !== false) { resolve({isAdobe: true, link: adobeInfo}); } else { const result = await this.isLevelRunning(level.id); if (result) { resolve(level.id); } else { resolve(false); } } }) }); const result = await Promise.all(arr); isAdobe = result.find(x => x.isAdobe); levelId = result.find(x => x !== false); isRunning = levelId != null; } if (isAdobe != null) { return isAdobe } return isRunning ? levelId : null; } }, calculatePrice(buyCount, prices, discountPercent) { let sum = prices.reduce((a, b) => { return a + b; }, 0); sum = sum * buyCount; return sum - (sum * discountPercent / 100); }, async areValidForBuy(levels) { const preLevels = levels.filter(x => x.status === "preRegister"); return preLevels.length === 0; } }; PK sg[p��K= = config/routes.jsonnu �[��� PK sg[&`/hG hG controllers/user-course.jsnu �[��� PK sg[V� ��� �� $ 1S documentation/1.0.0/user-course.jsonnu �[��� PK sg[��ٮ � 6� models/user-course.jsnu �[��� PK sg[�@�� � )� models/user-course.settings.jsonnu �[��� PK sg[�vV2U U � services/user-course.jsnu �[��� PK �
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0.07 |
proxy
|
phpinfo
|
Настройка