86 lines
3.6 KiB
JavaScript
86 lines
3.6 KiB
JavaScript
'use strict';
|
|
|
|
const PROFILE_KEY = 'notaryUnionPayProfile';
|
|
|
|
function trimString(value) {
|
|
return typeof value === 'string' ? value.trim() : value;
|
|
}
|
|
|
|
function ensureArray(value) {
|
|
return Array.isArray(value) ? value.filter(Boolean) : [];
|
|
}
|
|
|
|
module.exports = {
|
|
/**
|
|
* 保存金久信公正银联资料
|
|
* @url client/user/kh/saveNotaryUnionPayProfile 前端调用的url参数地址
|
|
*/
|
|
main: async (event) => {
|
|
const {data = {}, userInfo, util} = event;
|
|
const {vk} = util;
|
|
const {uid} = data;
|
|
|
|
const currentProfile = userInfo[PROFILE_KEY] || {};
|
|
if ([0, 1].includes(currentProfile.status)) {
|
|
return {
|
|
code: -1,
|
|
msg: currentProfile.status === 1 ? '资料已审核通过,暂不可修改' : '资料审核中,暂不可修改'
|
|
};
|
|
}
|
|
|
|
const profile = {
|
|
businessLicenseFile: trimString(data.businessLicenseFile),
|
|
legalIdCardFront: trimString(data.legalIdCardFront),
|
|
legalIdCardBack: trimString(data.legalIdCardBack),
|
|
settlementAccountFiles: ensureArray(data.settlementAccountFiles),
|
|
shopPhotos: ensureArray(data.shopPhotos),
|
|
legalMobile: trimString(data.legalMobile),
|
|
hasAgent: !!data.hasAgent,
|
|
agentIdCardFront: trimString(data.agentIdCardFront),
|
|
agentIdCardBack: trimString(data.agentIdCardBack),
|
|
agentAuthorizationFiles: ensureArray(data.agentAuthorizationFiles),
|
|
platformAgreementFiles: ensureArray(data.platformAgreementFiles),
|
|
platformAuthorizationFiles: ensureArray(data.platformAuthorizationFiles),
|
|
status: 0,
|
|
refuseReason: null,
|
|
submitTime: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss"),
|
|
submitTimestamp: Date.now(),
|
|
reviewTime: null,
|
|
reviewTimestamp: null,
|
|
};
|
|
|
|
if (!profile.businessLicenseFile) return {code: -1, msg: '请上传营业执照'};
|
|
if (!profile.legalIdCardFront) return {code: -1, msg: '请上传法人身份证正面'};
|
|
if (!profile.legalIdCardBack) return {code: -1, msg: '请上传法人身份证反面'};
|
|
if (profile.settlementAccountFiles.length === 0) return {code: -1, msg: '请上传结算账户信息证明'};
|
|
if (profile.shopPhotos.length < 4) return {code: -1, msg: '请至少上传4张店铺或办公地址照片'};
|
|
if (!profile.legalMobile) return {code: -1, msg: '请填写法人手机号'};
|
|
if (!/^1\d{10}$/.test(profile.legalMobile)) return {code: -1, msg: '法人手机号格式不正确'};
|
|
if (profile.platformAgreementFiles.length === 0) return {code: -1, msg: '请上传金久信平台入驻协议'};
|
|
if (profile.platformAuthorizationFiles.length === 0) return {code: -1, msg: '请上传平台授权书'};
|
|
|
|
if (profile.hasAgent) {
|
|
if (!profile.agentIdCardFront) return {code: -1, msg: '请上传代理人身份证正面'};
|
|
if (!profile.agentIdCardBack) return {code: -1, msg: '请上传代理人身份证反面'};
|
|
if (profile.agentAuthorizationFiles.length === 0) return {code: -1, msg: '请上传代理人签约授权书'};
|
|
} else {
|
|
profile.agentIdCardFront = '';
|
|
profile.agentIdCardBack = '';
|
|
profile.agentAuthorizationFiles = [];
|
|
}
|
|
|
|
await vk.baseDao.updateById({
|
|
dbName: 'uni-id-users',
|
|
id: uid,
|
|
dataJson: {
|
|
[PROFILE_KEY]: profile
|
|
}
|
|
});
|
|
|
|
return {
|
|
code: 0,
|
|
msg: '提交成功'
|
|
};
|
|
}
|
|
}
|