Commit a00922e5 by chenjinjing

no message

parent 8a694af1
......@@ -208,6 +208,26 @@ export async function systemSendMail(userId, type) {
}
/**
* 个人中心发送验证码邮件
* @param param0
* @returns
*/
export async function sendHomePageVerificationCode(userId, mail, type, code) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId:userId}, ["userId", "name", "unitName", "memberType", "mail"]);
if (!userInfo || !userInfo.userId) throw new BizError(ERRORENUM.用户不存在);
let checkUserInfo = await findOnce(TABLEENUM.用户表, {mail}, ["userId"]);
if (checkUserInfo && checkUserInfo.userId && checkUserInfo.userId != userInfo.userId) throw new BizError(ERRORENUM.该邮箱已被注册);
let nameStr = userInfo.memberType == MEMBERTYPE.个人会员 ? userInfo.name : userInfo.unitName;
let result = await send(mail, nameStr, type, code);
return successResult();
}
......
......@@ -110,7 +110,8 @@ export async function unitMemberList({unitName, mail, phone, joinStartTime, join
* 单位所获得科研成果: "id", "startTime":开始时间, "endTime":结束时间, "describe":描述
*/
const UnitBasicConfig = ["userId", "unitName", "uscc", "legalPerson", "legalPersonPhone", "legalPersonMail", "mail", "contactPerson", "contactPersonDuties", "phone",
const UnitRegisterConfig = ["phone", "mail", "pwd"];
const UnitBasicConfig = ["userId", "unitName", "uscc", "legalPerson", "legalPersonPhone", "legalPersonMail", "contactPerson", "contactPersonDuties",
"uusinessLicenseUrl", "addres", "sheng", "shi", "qu", "applicationForm"];
const UnitConfig = ["unitMemberType", "yuanXiaoBanXueLeiXing", "yuanXiaoZhuGuanBuMen", "yuanXiaoFuZeRen", "yuanXiaoFuZeRenZhiWu", "yuanXiaoFuZeRenDianHua",
"yuanXiaoBanGongFuZeRen", "yuanXiaoBanGongFuZeRenDianHua", "ZhuYaoFuZeRenYouXiang", "yuanXiaoKeYanFuZeRen", "yuanXiaoKeYanFuZeRenDianHua",
......@@ -126,6 +127,9 @@ export async function unitMemberDetails({userId, id}) {
topInfo.session = session;
/**处理枚举值 */
let registerInfo:any = extractData(oldInfo, UnitRegisterConfig);
/**处理枚举值 */
topInfo.memberLevel = changeEnumValue(MEMBERLEVEL, topInfo.memberLevel);
let basicInfo:any = extractData(oldInfo, UnitBasicConfig);
/**获取订单表新社会信用代码和新发票抬头 */
......@@ -165,7 +169,7 @@ export async function unitMemberDetails({userId, id}) {
permission.push(ADMINLV.单位会员申请表);
}
return {topInfo, basicInfo, unitInfo, scientificResearch, permission};
return {topInfo, registerInfo, basicInfo, unitInfo, scientificResearch, permission};
}
......@@ -203,7 +207,9 @@ export async function unitMemberUpdate({form, keyanForm, id}) {
if (distinctMailInfo && distinctMailInfo.userId && distinctMailInfo.userId != oldInfo.userId) {
// throw new BizError(ERRORENUM.邮箱重复, oldInfo.loginId, oldInfo.mail );
}
form.mail = form.mail;
// form.phone = form.phone;
// form.mail = form.mail;
// form.pwd = form.pwd;
await updateOneData(TABLEENUM.用户表, {userId:id}, form);
/**删除对应userId科研成果 */
......@@ -326,14 +332,18 @@ export async function individualMemberList({name, documentId, phone, mail, joinS
* 其他附件: "cardUrlJust":身份证正面图片地址, "cardUrlBack":身份证反面图片地址, "academicCERTUrl":学历证明图片地址, "professionalCERTUrl":工作证明图片地址, "auxiliaryMaterial":其他辅助材料
*/
const RegisterConfig = ["phone", "mail", "pwd"];
const TopConfig = ["session", "memberLevel"];
const IndividualBasicConfig = ["userId", "name", "sex", "nation", "birth", "documentType", "documentId", "sheng", "shi", "qu", "phone", "mail", "addres", "photoUrl", "education", "uscc", "unitName"];
const IndividualBasicConfig = ["userId", "name", "sex", "nation", "birth", "documentType", "documentId", "sheng", "shi", "qu", "addres", "photoUrl", "education", "uscc", "unitName"];
const SpecialityConfig = ["unitName", "duties", "workTitle", "profCategory", "studyResume", "workResume", "profAchievement", "otherEMP", "otherPROF"];
export async function individualMemberDetails({userId, id}) {
let oldInfo = await findOnce(TABLEENUM.用户表, {userId:id});
if (!oldInfo || !oldInfo.userId) throw new BizError(ERRORENUM.目标数据不存在);
/**处理枚举值 */
let registerInfo:any = extractData(oldInfo, RegisterConfig);
let topInfo:any = extractData(oldInfo, TopConfig);
topInfo.memberLevel = changeEnumValue(MEMBERLEVEL, topInfo.memberLevel);
let session = "";
......@@ -367,7 +377,7 @@ export async function individualMemberDetails({userId, id}) {
permission.push(ADMINLV.会员信息修改);
}
return {topInfo, basicInfo, specialityInfo, otherAttachment, permission};
return {topInfo, registerInfo, basicInfo, specialityInfo, otherAttachment, permission};
}
......
......@@ -11,7 +11,7 @@ import { updateOneData } from "../../data/update";
import { generateSMSCode, generateToken, getTodayMs, successResult } from "../../tools/system";
import { BizError } from "../../util/bizError";
import { changeEnumValue } from "../../util/verificationEnum";
import { sendMail, sendVerificationCode } from "../mail";
import { sendHomePageVerificationCode, sendMail, sendVerificationCode } from "../mail";
import { sendALSMS } from "../sms";
......@@ -139,11 +139,151 @@ export async function changePwd({userId, phone, pwd, confirmation, code}) {
}
return successResult();
}
/**
* 个人中心修改密码
* @param param0
* @returns
*/
export async function changePwdById({userId, oldPwd, pwd, confirmation}) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["userId", "isInput", "inputUserChangePwd", "unitMemberType", "memberType", "pwd"]);
if (userInfo.pwd != oldPwd ) throw new BizError(ERRORENUM.账号或密码错误);
if (pwd.search(/^[A-Za-z0-9]{6,18}$/) < 0) throw new BizError(ERRORENUM.密码只能由618位字符和数字组成);
if (pwd != confirmation) throw new BizError(ERRORENUM.两次密码不一致);
if (userInfo.isInput && !userInfo.inputUserChangePwd && (userInfo.memberType == MEMBERTYPE.单位会员 && userInfo.unitMemberType == UNITMEMBERTYPE.院校)) {
throw new BizError(ERRORENUM.密码修改错误);
}
let pwdStr = pwd;
let updateInfo:any = {pwd:pwdStr};
await updateOneData(TABLEENUM.用户表, {userId:userInfo.userId}, updateInfo);
// await updateOneData(TABLEENUM.验证码表, {codeNum:code, phone:userInfo.phone, type:CODETYPE.修改密码, isUse:false}, {isUse:true});
return successResult();
}
/**
* 个人中心修改注册手机号【短信验证码】 success
* @param userId
* @param phone
* @returns
*/
export async function memberChangePhoneSendCode({userId, phone}) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["userId"]);
if (!userInfo || !userInfo.userId) throw new BizError(ERRORENUM.不存在该手机号的账号);
const NowMs = new Date().valueOf();
let codeSelectParam = { phone, isUse:false, type:CODETYPE.修改手机号, sendMs:{"$gt":getTodayMs()} }
let lastCodeInfo = await findOnceToSort(TABLEENUM.验证码表, codeSelectParam, {sendMs:-1});
if (lastCodeInfo && lastCodeInfo.codeNum) {
if ( (lastCodeInfo.sendMs + (60*1000)) > NowMs ) throw new BizError(ERRORENUM.频繁操作请稍后再试);
/**校验今日同类型验证码次数 */
let todayNotUseCount = await findCount(TABLEENUM.验证码表, codeSelectParam);
if (todayNotUseCount >= 4) throw new BizError(ERRORENUM.发送验证码次数超限制, `${phone} 注册验证码超过限制3`);
}
const Code = generateSMSCode();//生成短信验证码
/**发送短信模块 */
await sendALSMS(Code, phone);
let addInfo = {codeNum:Code, phone, sendMs:NowMs, type:CODETYPE.修改手机号, isUse:false};
await addOneData(TABLEENUM.验证码表, addInfo);
return {code:""};
}
/**
* 个人中心修改注册手机号
* @param param0
* @returns
*/
export async function changePhoneById({userId, phone, code}) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["userId", "isInput" ,"inputUserChangePwd", "phone", "memberType", "unitMemberType"]);
if (!userInfo.userId) {
throw new BizError(ERRORENUM.账号不存在)
}
let checkUserInfo = await findOnce(TABLEENUM.用户表, {phone}, ["userId"]);
if (checkUserInfo && checkUserInfo.userId && checkUserInfo.userId != userInfo.userId) throw new BizError(ERRORENUM.该手机号已被注册);
let codeInfo = await findOnce(TABLEENUM.验证码表, {codeNum:code, phone, type:CODETYPE.修改手机号, isUse:false});
if (!codeInfo || !codeInfo.codeNum) {
throw new BizError(ERRORENUM.验证码错误);
}
await updateOneData(TABLEENUM.用户表, {userId:userInfo.userId}, {phone});
await updateOneData(TABLEENUM.验证码表, {codeNum:code, phone, type:CODETYPE.修改手机号, isUse:false}, {isUse:true});
return successResult();
}
// ----------------------------------------------------
/**
* 个人中心修改单位邮箱【短信验证码】 success
* @param userId
* @param phone
* @returns
*/
export async function memberChangeMailSendCode({userId, mail}) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["userId"]);
if (!userInfo || !userInfo.userId) throw new BizError(ERRORENUM.不存在该手机号的账号);
const NowMs = new Date().valueOf();
let codeSelectParam = { mail, isUse:false, type:CODETYPE.修改邮箱, sendMs:{"$gt":getTodayMs()} }
let lastCodeInfo = await findOnceToSort(TABLEENUM.验证码表, codeSelectParam, {sendMs:-1});
if (lastCodeInfo && lastCodeInfo.codeNum) {
if ( (lastCodeInfo.sendMs + (60*1000)) > NowMs ) throw new BizError(ERRORENUM.频繁操作请稍后再试);
/**校验今日同类型验证码次数 */
let todayNotUseCount = await findCount(TABLEENUM.验证码表, codeSelectParam);
if (todayNotUseCount >= 4) throw new BizError(ERRORENUM.发送验证码次数超限制, `${mail} 注册验证码超过限制3`);
}
const Code = generateSMSCode();//生成短信验证码
/**发送邮件验证码模块 */
await sendHomePageVerificationCode(userId, mail, MAILTYPE.邮箱获取验证码, Code);
let addInfo = {codeNum:Code, mail, sendMs:NowMs, type:CODETYPE.修改邮箱, isUse:false};
await addOneData(TABLEENUM.验证码表, addInfo);
return {code:""};
}
/**
* 个人中心修改注册单位邮箱
* @param param0
* @returns
*/
export async function changeMailById({userId, mail, code}) {
let userInfo = await findOnce(TABLEENUM.用户表, {userId}, ["userId", "isInput" ,"inputUserChangePwd", "phone", "memberType", "unitMemberType"]);
if (!userInfo.userId) {
throw new BizError(ERRORENUM.账号不存在)
}
let checkUserInfo = await findOnce(TABLEENUM.用户表, {mail}, ["userId"]);
if (checkUserInfo && checkUserInfo.userId && checkUserInfo.userId != userInfo.userId) throw new BizError(ERRORENUM.该手机号已被注册);
let codeInfo = await findOnce(TABLEENUM.验证码表, {codeNum:code, mail, type:CODETYPE.修改邮箱, isUse:false});
if (!codeInfo || !codeInfo.codeNum) {
throw new BizError(ERRORENUM.验证码错误);
}
await updateOneData(TABLEENUM.用户表, {userId:userInfo.userId}, {mail});
await updateOneData(TABLEENUM.验证码表, {codeNum:code, mail, type:CODETYPE.修改邮箱, isUse:false}, {isUse:true});
return successResult();
}
//----------------------------------------------------
/**
* 修改密码【短信验证码】 success
* @param userId
* @param phone
......
......@@ -446,7 +446,9 @@ export enum ORDERSTATE {
*/
export enum CODETYPE {
用户注册 = 1,
修改密码
修改密码,
修改手机号,
修改邮箱
}
......
......@@ -83,7 +83,8 @@ export enum ERRORENUM {
该用户邮箱为空,
该用户邮箱与输入邮箱不匹配,
与预览邮箱不一致,
不存在该邮箱的账号
不存在该邮箱的账号,
该邮箱已被注册
}
export enum ERRORCODEENUM {
......
......@@ -539,6 +539,7 @@ const ModelArray = [
source:TABLESOURCEENUM.mongo,
schema:{
phone:{type:'String', index:true},//电话号码
mail:{type:'String', index:true},//邮箱
receiveType:"Number", //接受验证码类型
codeNum:'String',
sendMs:{type:'Number', index:true},//下发时间 时间戳
......
......@@ -460,6 +460,56 @@ export const Config = {
{key:"code", type:"String", desc:"验证码"}
],
bindBiz:userBiz.changePwd
},
{
apiName:"个人中心修改密码",
subUrl:'/changepwdbyid',
notMiddleware:true,
param:[
{key:"userId", type:"String", desc:"userId", isNull:true},
{key:"oldPwd", type:"String", desc:"旧密码"},
{key:"pwd", type:"String", desc:"新2密码"},
{key:"confirmation", type:"String", desc:"二次确认密码"}
],
bindBiz:userBiz.changePwdById
},{
apiName:"修改注册手机号用短信验证码",
subUrl:'/getchangephonecode',
notMiddleware:true,
param:[
{key:"userId", type:"String", desc:"userId", isNull:true},
{key:"phone", type:"String", desc:"绑定手机号"}
],
bindBiz:userBiz.memberChangePhoneSendCode
},{
apiName:"个人中心修改注册手机号码",
subUrl:'/changephonebyid',
notMiddleware:true,
param:[
{key:"userId", type:"String", desc:"userId", isNull:true},
{key:"phone", type:"String", desc:"绑定手机号"},
{key:"code", type:"String", desc:"验证码"}
],
bindBiz:userBiz.changePhoneById
},{
apiName:"修改单位邮箱用短信验证码",
subUrl:'/getchangemailcode',
notMiddleware:true,
param:[
{key:"userId", type:"String", desc:"userId", isNull:true},
{key:"mail", type:"String", desc:"单位邮箱"}
],
bindBiz:userBiz.memberChangeMailSendCode
},{
apiName:"个人中心修改单位邮箱",
subUrl:'/changemailbyid',
notMiddleware:true,
param:[
{key:"userId", type:"String", desc:"userId", isNull:true},
{key:"mail", type:"String", desc:"单位邮箱"},
{key:"code", type:"String", desc:"验证码"}
],
bindBiz:userBiz.changeMailById
},{
apiName:"修改密码用短信验证码",
subUrl:'/getchangepwdcode',
......@@ -557,16 +607,20 @@ export const Config = {
{
key:"form", type:"Object", sub:
{
/**注册信息 */
phone:{type:'String', desc:'注册手机号', notMustHave:true},
mail:{type:'String', desc:'单位邮箱', notMustHave:true},
pwd:{type:'String', desc:'密码', notMustHave:true},
/**基本信息 */
unitName:{type:'String', desc:'单位名称', notMustHave:true},
addres:{type:'String', desc:'通信地址', notMustHave:true},
legalPerson:{type:'String', desc:'法人代表', notMustHave:true},
legalPersonPhone:{type:'String', desc:'法人联系电话', notMustHave:true},
legalPersonMail:{type:'String', desc:'法人邮箱', notMustHave:true},
mail:{type:'String', desc:'单位电子邮箱', notMustHave:true},
// mail:{type:'String', desc:'单位电子邮箱', notMustHave:true},
contactPerson:{type:'String', desc:'日常联系人', notMustHave:true},
contactPersonDuties:{type:'String', desc:'日常联系人职务', notMustHave:true},
phone:{type:'String', desc:'日常联系人电话', notMustHave:true},
// phone:{type:'String', desc:'日常联系人电话', notMustHave:true},
sheng:{type:'String', desc:'省', notMustHave:true},
shi:{type:'String', desc:'市', notMustHave:true},
qu:{type:'String', desc:'区', notMustHave:true},
......@@ -612,6 +666,10 @@ export const Config = {
{
key:"form", type:"Object", sub:
{
/**注册信息 */
phone:{type:'String', desc:'注册手机号', notMustHave:true},
mail:{type:'String', desc:'单位邮箱', notMustHave:true},
pwd:{type:'String', desc:'密码', notMustHave:true},
/**基本信息 */
name:{type:'String', desc:'真实姓名', notMustHave:true},
sex:{type:'Number', desc:'性别', notMustHave:true},
......@@ -622,8 +680,8 @@ export const Config = {
sheng:{type:'String', desc:'省', notMustHave:true},
shi:{type:'String', desc:'市', notMustHave:true},
qu:{type:'String', desc:'区', notMustHave:true},
phone:{type:'String', desc:'手机号码', notMustHave:true},
mail:{type:'String', desc:'电子邮箱', notMustHave:true},
// phone:{type:'String', desc:'手机号码', notMustHave:true},
// mail:{type:'String', desc:'电子邮箱', notMustHave:true},
addres:{type:'String', desc:'通信地址', notMustHave:true},
photoUrl:{type:'String', desc:'蓝底证件照', notMustHave:true},
education:{type:'Number', desc:'学历', notMustHave:true},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment