Commit 8963ffd5 by Sxy

fix: 代码规范

parent 8ee442cc
......@@ -23,25 +23,35 @@ class CacheInfoCtl extends CtlBase {
rarr.cacheInfo = rs.cache_info;
if (rarr.cacheInfo && rarr.cacheInfo != 'undefined') {
if (rarr.cacheInfo.cmpContactInfo.contactsPhone && rarr.cacheInfo.cmpContactInfo.contactsPhone != 'undefined') {
rarr.cacheInfo.cmpContactInfo.contactsPhone = system.decryptStr(rarr.cacheInfo.cmpContactInfo.contactsPhone);
rarr.cacheInfo.cmpContactInfo.contactsPhone = (
system.decryptStr(rarr.cacheInfo.cmpContactInfo.contactsPhone)
);
}
if (rarr.cacheInfo.positionData && rarr.cacheInfo.positionData.length > 0) {
for (var i = 0; i < rarr.cacheInfo.positionData.length;i++) {
for (let i = 0; i < rarr.cacheInfo.positionData.length; i++) {
if (rarr.cacheInfo.positionData[i].fixedPhone && rarr.cacheInfo.positionData[i].fixedPhone != 'undefined') {
rarr.cacheInfo.positionData[i].fixedPhone = system.decryptStr(rarr.cacheInfo.positionData[i].fixedPhone);
rarr.cacheInfo.positionData[i].fixedPhone = (
system.decryptStr(rarr.cacheInfo.positionData[i].fixedPhone)
);
}
if (rarr.cacheInfo.positionData[i].mobilePhone && rarr.cacheInfo.positionData[i].mobilePhone != 'undefined') {
rarr.cacheInfo.positionData[i].mobilePhone = system.decryptStr(rarr.cacheInfo.positionData[i].mobilePhone);
rarr.cacheInfo.positionData[i].mobilePhone = (
system.decryptStr(rarr.cacheInfo.positionData[i].mobilePhone)
);
}
}
}
if (rarr.cacheInfo.contributionData && rarr.cacheInfo.contributionData.length > 0) {
for (var i = 0; i < rarr.cacheInfo.contributionData.length;i++) {
for (let i = 0; i < rarr.cacheInfo.contributionData.length; i++) {
if (rarr.cacheInfo.contributionData[i].phoneNumber && rarr.cacheInfo.contributionData[i].phoneNumber != 'undefined') {
rarr.cacheInfo.contributionData[i].phoneNumber = system.decryptStr(rarr.cacheInfo.contributionData[i].phoneNumber);
rarr.cacheInfo.contributionData[i].phoneNumber = (
system.decryptStr(rarr.cacheInfo.contributionData[i].phoneNumber)
);
}
if (rarr.cacheInfo.contributionData[i].IdentificationNumber && rarr.cacheInfo.contributionData[i].IdentificationNumber != 'undefined') {
rarr.cacheInfo.contributionData[i].IdentificationNumber = system.decryptStr(rarr.cacheInfo.contributionData[i].IdentificationNumber);
rarr.cacheInfo.contributionData[i].IdentificationNumber = (
system.decryptStr(rarr.cacheInfo.contributionData[i].IdentificationNumber)
);
}
}
}
......@@ -72,27 +82,35 @@ class CacheInfoCtl extends CtlBase {
try {
if (pobj.cacheInfo.cmpContactInfo && pobj.cacheInfo.cmpContactInfo != 'undefined') {
if (pobj.cacheInfo.cmpContactInfo.contactsPhone && pobj.cacheInfo.cmpContactInfo.contactsPhone != 'undefined') {
pobj.cacheInfo.cmpContactInfo.contactsPhone = system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone);
pobj.cacheInfo.cmpContactInfo.contactsPhone = (
system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone)
);
}
}
if (pobj.cacheInfo.positionData && pobj.cacheInfo.positionData.length > 0) {
for (var i = 0; i < pobj.cacheInfo.positionData.length;i++) {
for (let i = 0; i < pobj.cacheInfo.positionData.length; i++) {
if (pobj.cacheInfo.positionData[i].fixedPhone && pobj.cacheInfo.positionData[i].fixedPhone != 'undefined') {
pobj.cacheInfo.positionData[i].fixedPhone = system.encryptStr(pobj.cacheInfo.positionData[i].fixedPhone);
}
if (pobj.cacheInfo.positionData[i].mobilePhone && pobj.cacheInfo.positionData[i].mobilePhone != 'undefined') {
pobj.cacheInfo.positionData[i].mobilePhone = system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone);
pobj.cacheInfo.positionData[i].mobilePhone = (
system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone)
);
}
}
}
if (pobj.cacheInfo.contributionData && pobj.cacheInfo.contributionData.length > 0) {
for (var i = 0; i < pobj.cacheInfo.contributionData.length;i++) {
for (let i = 0; i < pobj.cacheInfo.contributionData.length; i++) {
if (pobj.cacheInfo.contributionData[i].phoneNumber && pobj.cacheInfo.contributionData[i].phoneNumber != 'undefined') {
pobj.cacheInfo.contributionData[i].phoneNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber);
pobj.cacheInfo.contributionData[i].phoneNumber = (
system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber)
);
}
if (pobj.cacheInfo.contributionData[i].IdentificationNumber && pobj.cacheInfo.contributionData[i].IdentificationNumber != 'undefined') {
pobj.cacheInfo.contributionData[i].IdentificationNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber);
pobj.cacheInfo.contributionData[i].IdentificationNumber = (
system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber)
);
}
}
}
......@@ -115,27 +133,35 @@ class CacheInfoCtl extends CtlBase {
try {
if (pobj.cacheInfo.cmpContactInfo && pobj.cacheInfo.cmpContactInfo != 'undefined') {
if (pobj.cacheInfo.cmpContactInfo.contactsPhone && pobj.cacheInfo.cmpContactInfo.contactsPhone != 'undefined') {
pobj.cacheInfo.cmpContactInfo.contactsPhone = system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone);
pobj.cacheInfo.cmpContactInfo.contactsPhone = (
system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone)
);
}
}
if (pobj.cacheInfo.positionData && pobj.cacheInfo.positionData.length > 0) {
for (var i = 0; i < pobj.cacheInfo.positionData.length;i++) {
for (let i = 0; i < pobj.cacheInfo.positionData.length; i++) {
if (pobj.cacheInfo.positionData[i].fixedPhone && pobj.cacheInfo.positionData[i].fixedPhone != 'undefined') {
pobj.cacheInfo.positionData[i].fixedPhone = system.encryptStr(pobj.cacheInfo.positionData[i].fixedPhone);
}
if (pobj.cacheInfo.positionData[i].mobilePhone && pobj.cacheInfo.positionData[i].mobilePhone != 'undefined') {
pobj.cacheInfo.positionData[i].mobilePhone = system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone);
pobj.cacheInfo.positionData[i].mobilePhone = (
system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone)
);
}
}
}
if (pobj.cacheInfo.contributionData && pobj.cacheInfo.contributionData.length > 0) {
for (var i = 0; i < pobj.cacheInfo.contributionData.length;i++) {
for (let i = 0; i < pobj.cacheInfo.contributionData.length; i++) {
if (pobj.cacheInfo.contributionData[i].phoneNumber && pobj.cacheInfo.contributionData[i].phoneNumber != 'undefined') {
pobj.cacheInfo.contributionData[i].phoneNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber);
pobj.cacheInfo.contributionData[i].phoneNumber = (
system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber)
);
}
if (pobj.cacheInfo.contributionData[i].IdentificationNumber && pobj.cacheInfo.contributionData[i].IdentificationNumber != 'undefined') {
pobj.cacheInfo.contributionData[i].IdentificationNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber);
pobj.cacheInfo.contributionData[i].IdentificationNumber = (
system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber)
);
}
}
}
......
......@@ -87,7 +87,7 @@ class DeliverybillCtl extends CtlBase {
}
} else {
robj.relatedProducts = '无';
};
}
robj.payAmount = this.FenToYuan(element.selling_price);// 交付单金额
robj.selling_price = this.FenToYuan(element.selling_price);// 交付单金额-shousuo
robj.deliverStatus = element.delivery_status;// 交付单状态
......@@ -240,13 +240,19 @@ class DeliverybillCtl extends CtlBase {
rarr.companyInfo = ms.company_info;// 公司详情
rarr.registeredInfo = ms.registered_info;// 注册信息
rarr.contributionInfo = ms.contribution_info;// 出资比例信息
if (rarr.contributionInfo && rarr.contributionInfo.contributionData && rarr.contributionInfo.contributionData.length > 0) {
for (var i = 0; i < rarr.contributionInfo.contributionData.length; i++) {
if (rarr.contributionInfo
&& rarr.contributionInfo.contributionData
&& rarr.contributionInfo.contributionData.length > 0) {
for (let i = 0; i < rarr.contributionInfo.contributionData.length; i++) {
if (rarr.contributionInfo.contributionData[i].phoneNumber && rarr.contributionInfo.contributionData[i].phoneNumber != 'undefined') {
rarr.contributionInfo.contributionData[i].phoneNumber = system.decryptStr(rarr.contributionInfo.contributionData[i].phoneNumber);
rarr.contributionInfo.contributionData[i].phoneNumber = (
system.decryptStr(rarr.contributionInfo.contributionData[i].phoneNumber)
);
}
if (rarr.contributionInfo.contributionData[i].IdentificationNumber && rarr.contributionInfo.contributionData[i].IdentificationNumber != 'undefined') {
rarr.contributionInfo.contributionData[i].IdentificationNumber = system.decryptStr(rarr.contributionInfo.contributionData[i].IdentificationNumber);
rarr.contributionInfo.contributionData[i].IdentificationNumber = (
system.decryptStr(rarr.contributionInfo.contributionData[i].IdentificationNumber)
);
}
}
}
......@@ -260,12 +266,16 @@ class DeliverybillCtl extends CtlBase {
}
if (position_t_info.positionData && position_t_info.positionData.length > 0) {
for (var i = 0; i < pobj.positionInfo.positionData.length; i++) {
for (let i = 0; i < pobj.positionInfo.positionData.length; i++) {
if (position_t_info.positionData[i].fixedPhone && position_t_info.positionData[i].fixedPhone != 'undefined') {
position_t_info.positionData[i].fixedPhone = system.decryptStr(position_t_info.positionData[i].fixedPhone);
position_t_info.positionData[i].fixedPhone = (
system.decryptStr(position_t_info.positionData[i].fixedPhone)
);
}
if (position_t_info.positionData[i].mobilePhone && position_t_info.positionData[i].mobilePhone != 'undefined') {
position_t_info.positionData[i].mobilePhone = system.decryptStr(position_t_info.positionData[i].mobilePhone);
position_t_info.positionData[i].mobilePhone = (
system.decryptStr(position_t_info.positionData[i].mobilePhone)
);
}
}
}
......@@ -671,12 +681,16 @@ class DeliverybillCtl extends CtlBase {
if (pobj.contributionInfo) {
if (pobj.contributionInfo.contributionData && pobj.contributionInfo.contributionData.length > 0) {
for (var i = 0; i < pobj.contributionInfo.contributionData.length; i++) {
for (let i = 0; i < pobj.contributionInfo.contributionData.length; i++) {
if (pobj.contributionInfo.contributionData[i].phoneNumber && pobj.contributionInfo.contributionData[i].phoneNumber != 'undefined') {
pobj.contributionInfo.contributionData[i].phoneNumber = system.encryptStr(pobj.contributionInfo.contributionData[i].phoneNumber);
pobj.contributionInfo.contributionData[i].phoneNumber = (
system.encryptStr(pobj.contributionInfo.contributionData[i].phoneNumber)
);
}
if (pobj.contributionInfo.contributionData[i].IdentificationNumber && pobj.contributionInfo.contributionData[i].IdentificationNumber != 'undefined') {
pobj.contributionInfo.contributionData[i].IdentificationNumber = system.encryptStr(pobj.contributionInfo.contributionData[i].IdentificationNumber);
pobj.contributionInfo.contributionData[i].IdentificationNumber = (
system.encryptStr(pobj.contributionInfo.contributionData[i].IdentificationNumber)
);
}
}
}
......@@ -684,12 +698,16 @@ class DeliverybillCtl extends CtlBase {
if (pobj.positionInfo) {
if (pobj.positionInfo.positionData && pobj.positionInfo.positionData.length > 0) {
for (var i = 0; i < pobj.positionInfo.positionData.length; i++) {
for (let i = 0; i < pobj.positionInfo.positionData.length; i++) {
if (pobj.positionInfo.positionData[i].fixedPhone && pobj.positionInfo.positionData[i].fixedPhone != 'undefined') {
pobj.positionInfo.positionData[i].fixedPhone = system.encryptStr(pobj.positionInfo.positionData[i].fixedPhone);
pobj.positionInfo.positionData[i].fixedPhone = (
system.encryptStr(pobj.positionInfo.positionData[i].fixedPhone)
);
}
if (pobj.positionInfo.positionData[i].mobilePhone && pobj.positionInfo.positionData[i].mobilePhone != 'undefined') {
pobj.positionInfo.positionData[i].mobilePhone = system.encryptStr(pobj.positionInfo.positionData[i].mobilePhone);
pobj.positionInfo.positionData[i].mobilePhone = (
system.encryptStr(pobj.positionInfo.positionData[i].mobilePhone)
);
}
}
}
......@@ -770,11 +788,15 @@ class DeliverybillCtl extends CtlBase {
pobj.businessType = appconfig.pdict.dyDict[pobj.businessType];
if (pobj.companyInfo.companyPropertiesName && pobj.companyInfo.companyPropertiesName != 'undefined') {
if (pobj.businessName == '公司注册') {
pobj.companyInfo.companyProperties = appconfig.pdict.companyNatureDictT[pobj.companyInfo.companyPropertiesName];
pobj.companyInfo.companyProperties = (
appconfig.pdict.companyNatureDictT[pobj.companyInfo.companyPropertiesName]
);
pobj.baseInfo.companyProperties = pobj.companyInfo.companyProperties;
pobj.baseInfo.companyType = pobj.companyInfo.companyProperties;
} else if (pobj.businessName == '云上园区注册') {
pobj.companyInfo.companyProperties = appconfig.pdict.registeredTypeDictT[pobj.companyInfo.companyPropertiesName];
pobj.companyInfo.companyProperties = (
appconfig.pdict.registeredTypeDictT[pobj.companyInfo.companyPropertiesName]
);
pobj.baseInfo.companyProperties = pobj.companyInfo.companyProperties;
pobj.baseInfo.companyType = pobj.companyInfo.companyProperties;
} else {
......@@ -1006,11 +1028,11 @@ class DeliverybillCtl extends CtlBase {
}
toDecimal2(x) {
var f = parseFloat(x);
let f = parseFloat(x);
if (isNaN(f)) {
return false;
}
var f = Math.round(x * 100) / 100;
f = Math.round(x * 100) / 100;
let s = f.toString();
let rs = s.indexOf('.');
if (rs < 0) {
......
......@@ -12,15 +12,18 @@ class CachSearchesCtl extends CtlBase {
async findAndCountAll(pobj, gobj, req) {
pobj.opCacheUrl = req.session.app.opCacheUrl;
pobj.appid = req.appid;
return await this.service.findAndCountAllCache(pobj);
const result = await this.service.findAndCountAllCache(pobj);
return result;
}
async delCache(queryobj, qobj, req) {
const param = { key: queryobj.key, appid: req.appid, opCacheUrl: req.session.app.opCacheUrl };
return await this.service.delCache(param);
const result = await this.service.delCache(param);
return result;
}
async clearAllCache(queryobj, qobj, req) {
const param = { appid: req.appid, opCacheUrl: req.session.app.opCacheUrl };
return await this.service.clearAllCache(param);
const result = await this.service.clearAllCache(param);
return result;
}
}
module.exports = CachSearchesCtl;
const CacheBase = require('../cache.base');
const system = require('../../system');
// 缓存首次登录的赠送的宝币数量
class CacheLocker extends CacheBase {
constructor() {
super();
this.prefix = 'locker_';
}
desc() {
}
prefix() {
}
async init(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, '1', 1800);
}
async enter(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpop(key);
}
async release(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, '1', 1800);
}
}
module.exports = CacheLocker;
......@@ -9,9 +9,11 @@ class UserDao extends Dao {
return this.model.findOne({
where: { id: userid },
include: [{ model: self.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'] },
{ model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{
model: self.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: self.db.models.product, as: 'Products', attributes: ['id', 'code'] },
] },
],
},
],
});
}
......@@ -20,17 +22,18 @@ class UserDao extends Dao {
const tUser = await this.model.findOne({
where: { userName: username, app_id: app.id },
include: [{ model: this.db.models.app, raw: true },
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
] },
] }, { transaction: t });
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
],
},
],
}, { transaction: t });
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return tUser;
}
async getUserByOpenId(popenid, appkey, t) {
......@@ -38,13 +41,14 @@ class UserDao extends Dao {
let tUser = await this.model.findOne({
where: { openId: popenid },
include: [{ model: this.db.models.app, raw: true },
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.account, attributes: ['id', 'isSuper', 'referrerOnlyCode'], raw: true },
{
model: this.db.models.role, as: 'Roles', attributes: ['id', 'code'], include: [
{ model: this.db.models.product, as: 'Products', attributes: ['id', 'code'], raw: true },
] },
] }, { transaction: t });
],
},
],
}, { transaction: t });
if (tUser != null) {
tUser = tUser.get({ plain: true });
tUser.partnerinfo = await this.partnerinfoDao.model.findOne({ where: { onlyCode: tUser.onlyCode }, raw: true });
......@@ -64,9 +68,11 @@ class UserDao extends Dao {
}
extraModelFilter() {
// return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return { key: 'include', value: [
{ model: this.db.models.app },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }] };
return {
key: 'include', value: [
{ model: this.db.models.app },
{ model: this.db.models.role, as: 'Roles', attributes: ['id', 'name'] }],
};
}
extraWhere(obj, w, qc, linkAttrs) {
if (obj.bizpath && obj.bizpath != '') {
......
......@@ -35,7 +35,8 @@ class BizoptDao extends Dao {
/* 根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj) {
const qcwhere = { demand_code: qobj.businessMode };
return await this.findOne(qcwhere);
const result = await this.findOne(qcwhere);
return result;
}
/* 更新商机状态*/
......@@ -47,7 +48,8 @@ class BizoptDao extends Dao {
setobj.close_reason = '';
}
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
const result = await this.updateByWhere(setobj, whereobj, t);
return result;
}
/* 更新业务员信息*/
......@@ -55,24 +57,25 @@ class BizoptDao extends Dao {
const setobj = {};
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
setobj.salesman_id = qobj.salesmanId;
};
}
if (qobj.salesmanName && qobj.salesmanName != 'undefined') {
setobj.salesman_name = qobj.salesmanName;
};
}
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
setobj.salesman_opcode = qobj.salesmanOpcode;
};
}
if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
setobj.salesman_phone = qobj.salesmanPhone;
};
}
if (qobj.facilitatorId && qobj.facilitatorId != 'undefined') {
setobj.facilitator_id = qobj.facilitatorId;
};
}
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName;
};
}
const whereobj = { demand_code: qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
const result = await this.updateByWhere(setobj, whereobj, t);
return result;
}
/* 插入商机信息*/
......@@ -134,7 +137,8 @@ class BizoptDao extends Dao {
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') {
obj.salesman_phone = qobj.clerkPhone;
}
return await this.create(obj, t);
const result = await this.create(obj, t);
return result;
}
}
module.exports = BizoptDao;
......@@ -22,14 +22,16 @@ class CacheinfoDao extends Dao {
/* 根据订单id获取缓存信息详情*/
async findInfoByDeliverId(qobj) {
const qcwhere = { deliver_id: qobj.deliverNumber };
return await this.findOne(qcwhere);
const result = await this.findOne(qcwhere);
return result;
}
/* 更加订单id更新缓存信息*/
async updateInfoByDeliverId(qobj, t) {
const setobj = { cache_info: qobj.cacheInfo };
const whereobj = { deliver_id: qobj.deliverNumber };
return await this.updateByWhere(setobj, whereobj, t);
const result = await this.updateByWhere(setobj, whereobj, t);
return result;
}
/* 插入缓存信息*/
......@@ -38,7 +40,8 @@ class CacheinfoDao extends Dao {
deliver_id: qobj.deliverNumber,
cache_info: qobj.cacheInfo,
};
return await this.create(obj, t);
const result = await this.create(obj, t);
return result;
}
}
module.exports = CacheinfoDao;
......@@ -89,7 +89,8 @@ class DbFactory {
// pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true}));
// });
// await this.db.models.user.create({nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"})
// await this.db.models.user.create({
// nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"})
// .then(function(user){
// var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"});
// acc.save().then(a=>{
......
......@@ -11,7 +11,8 @@ class AuthService extends ServiceBase {
// var newattrs=rolecodestr.split(",");
const aths = await this.dao.model.findAll({
attributes: ['bizcode', 'authstrs', 'codepath'],
where: { role_id: { [this.db.Op.in]: roleids }, app_id: appid, company_id: comid } });
where: { role_id: { [this.db.Op.in]: roleids }, app_id: appid, company_id: comid },
});
return aths;
}
async saveAuths(auths, appid, cmid) {
......@@ -20,8 +21,8 @@ class AuthService extends ServiceBase {
console.log('yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv');
console.log(auths);
return self.db.transaction(async (t) => {
for (let i = 0;i < auths.length;i++) {
var tmpAuth = auths[i];
for (let i = 0; i < auths.length; i++) {
const tmpAuth = auths[i];
tmpAuth.app_id = appid;
tmpAuth.company_id = cmid;
const objrtn = await self.dao.model.findOrCreate({
......@@ -33,10 +34,21 @@ class AuthService extends ServiceBase {
console.log(objrtn);
if (!objrtn[1].created) {
// 就执行更新操作
await objrtn[0].update(tmpAuth, { where: { role_id: tmpAuth.role_id, bizcode: tmpAuth.bizcode }, transaction: t });
await objrtn[0].update(tmpAuth, {
where:
{
role_id: tmpAuth.role_id,
bizcode: tmpAuth.bizcode,
}, transaction: t,
});
}
}
const aths = await self.dao.model.findAll({ where: { role_id: tmpAuth.role_id, app_id: tmpAuth.app_id }, transaction: t });
const aths = await self.dao.model.findAll({
where: {
role_id: tmpAuth.role_id,
app_id: tmpAuth.app_id,
}, transaction: t,
});
return aths;
});
}
......
......@@ -77,25 +77,35 @@ class BizOptService extends ServiceBase {
/* 根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj) {
return await this.dao.findInfoByDemandCode(qobj);
const result = await this.dao.findInfoByDemandCode(qobj);
return result;
}
/* 根据商机编号更新商机状态 */
async updateStatusByDemandCode(qobj) {
const self = this;
return self.db.transaction(async t => await self.dao.updateStatusByDemandCode(qobj, t));
return self.db.transaction(async (t) => {
const result = await self.dao.updateStatusByDemandCode(qobj, t);
return result;
});
}
/* 更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj) {
const self = this;
return self.db.transaction(async t => await self.dao.updateSalesmanInfoByDemandCode(qobj, t));
return self.db.transaction(async (t) => {
const result = await self.dao.updateSalesmanInfoByDemandCode(qobj, t);
return result;
});
}
/* 插入商机信息*/
async insertInfo(qobj) {
const self = this;
return self.db.transaction(async t => await self.dao.insertInfo(qobj, t));
return self.db.transaction(async (t) => {
const result = await self.dao.insertInfo(qobj, t);
return result;
});
}
}
module.exports = BizOptService;
......@@ -14,19 +14,26 @@ class CacheInfoService extends ServiceBase {
/* 根据交付单id获取缓存详情*/
async findInfoByDeliverId(qobj) {
return await this.dao.findInfoByDeliverId(qobj);
const result = await this.dao.findInfoByDeliverId(qobj);
return result;
}
/* 根据交付单id更新缓存信息 */
async updateInfoByDeliverId(qobj) {
const self = this;
return self.db.transaction(async t => await self.dao.updateInfoByDeliverId(qobj, t));
return self.db.transaction(async (t) => {
const result = await self.dao.updateInfoByDeliverId(qobj, t);
return result;
});
}
/* 插入缓存信息*/
async insertInfo(qobj) {
const self = this;
return self.db.transaction(async t => await self.dao.insertInfo(qobj, t));
return self.db.transaction(async (t) => {
const result = await self.dao.insertInfo(qobj, t);
return result;
});
}
}
module.exports = CacheInfoService;
......@@ -6,11 +6,13 @@ class SchemeService extends ServiceBase {
async findById(qobj) { // 根据id获取方案信息
const oid = qobj.id;
return await this.dao.findById(oid);
const result = await this.dao.findById(oid);
return result;
}
async findInfoByDemandCode(qobj) { // 根据方案编号获取方案详情
return await this.dao.findInfoByDemandCode(qobj);
const result = await this.dao.findInfoByDemandCode(qobj);
return result;
}
async updateStatusByDemandCode(qobj) { // 根据商机编号号更新方案状态及原因
......@@ -30,7 +32,8 @@ class SchemeService extends ServiceBase {
async insertInfo(qobj) { // 插入方案信息
const self = this;
return await self.db.transaction(async t => await self.dao.insertInfo(qobj, t));
const result = await self.db.transaction(async t => await self.dao.insertInfo(qobj, t));
return result;
}
}
module.exports = SchemeService;
......@@ -14,7 +14,7 @@ class AppService extends ServiceBase {
const app = this.cacheManager.AppCache.cache(p.appkey, null);
return app;
}
async upFrontRoute(jsonObject, app_id) {
async upFrontRoute(jsonObject, appId) {
const self = this;
return this.db.transaction(async (t) => {
const keyfile = `${self.getUUID()}.json`;
......@@ -23,7 +23,7 @@ class AppService extends ServiceBase {
fs.writeFileSync(tmpdirfile, str);
const result = await self.ossC.upfile(keyfile, tmpdirfile);
fs.unlinkSync(tmpdirfile);
await self.db.models.app.update({ docUrl: result.url, id: app_id }, { where: { id: app_id }, transaction: t });
await self.db.models.app.update({ docUrl: result.url, id: appId }, { where: { id: appId }, transaction: t });
return result;
});
}
......
......@@ -10,7 +10,7 @@ class CachSearchesSve {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
async buildCacheRtn(pageValues) {
......@@ -27,24 +27,28 @@ class CachSearchesSve {
const { pageSize } = obj.pageInfo;
const limit = pageSize;
const offset = (pageNo - 1) * pageSize;
const search_name = obj.search && obj.search.name ? obj.search.name : '';
const searchName = obj.search && obj.search.name ? obj.search.name : '';
const cacheCacheKeyPrefix = `sadd_base_appkeys:${settings.appKey}_cachekey`;
if (obj.appid == settings.platformid) {
let cacheList = await this.cacheManager.MagCache.getCacheSmembersByKey(cacheCacheKeyPrefix);
if (search_name) {
cacheList = cacheList.filter(f => f.indexOf(search_name) >= 0);
if (searchName) {
cacheList = cacheList.filter(f => f.indexOf(searchName) >= 0);
}
const pageValues = cacheList.slice(offset, offset + limit);
const kobjs = await this.buildCacheRtn(pageValues);
var tmpList = { results: { rows: kobjs, count: cacheList.length } };
const tmpList = {
results: {
rows: kobjs, count: cacheList.length,
},
};
return system.getResult(tmpList);
}
const body = {
pageInfo: obj.pageInfo,
search: obj.search,
};
var tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl);
const tmpList = await this.opOtherAppCache('findAndCountAll', body, obj.opCacheUrl);
return tmpList;
}
async delCache(obj) {
......@@ -60,7 +64,8 @@ class CachSearchesSve {
const body = {
del_cachekey: obj.key,
};
return await this.opOtherAppCache('delCache', body, obj.opCacheUrl);
const result = await this.opOtherAppCache('delCache', body, obj.opCacheUrl);
return result;
}
}
async clearAllCache(obj) {
......@@ -68,24 +73,25 @@ class CachSearchesSve {
await this.cacheManager.MagCache.clearAll();
return { status: 0 };
}
return await this.opOtherAppCache('clearAllCache', {}, obj.opCacheUrl);
const result = await this.opOtherAppCache('clearAllCache', {}, obj.opCacheUrl);
return result;
}
// app调用次数
async findAndCountAlldetail(obj) {
const apicallAccu = await this.cacheManager.ApiAccuCache.getApiCallAccu(obj);
const result = { rows: [], count: 0 };
const keys = await this.cacheManager.MagCache.keys(`api_call_${appkey}*`);
var detail = null;
let detail = null;
for (let j = 0; j < keys.length; j++) {
const d = keys[j];
const pathdetail = d.substr(d.lastIndexOf('_') + 1, d.length);
const apicalldetailAccu = await this.cacheManager.ApiCallCountCache.getApiCallCount(appkey, pathdetail);
var detail = { detailPath: d, detailCount: apicalldetailAccu.callcount };
detail = { detailPath: d, detailCount: apicalldetailAccu.callcount };
}
result.rows = detail;
}
// 操作别的应用的缓存
async opOtherAppCache(action_type, body = null, opCacheUrl) {
async opOtherAppCache(actionType, body = null, opCacheUrl) {
const appData = await this.authUtils.getTokenInfo(settings.appKey, settings.secret);
if (appData.status != 0) {
return appData;
......@@ -94,7 +100,7 @@ class CachSearchesSve {
const restS = await system.getObject('util.restClient');
const restResult = await restS.execPostWithAK(
{
action_type,
action_type: actionType,
body,
},
opCacheUrl, appData.data.accessKey,
......
......@@ -7,7 +7,7 @@ class AuthUtils {
}
getUUID() {
const uuid = uuidv4();
const u = uuid.replace(/\-/g, '');
const u = uuid.replace(/-/g, '');
return u;
}
/**
......
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