Commit 9b97d264 by 王昆

gsb

parent ce5094f1
...@@ -7,6 +7,7 @@ class ActionAPI extends APIBase { ...@@ -7,6 +7,7 @@ class ActionAPI extends APIBase {
this.saasmainSve = system.getObject("service.main.saasmainSve"); this.saasmainSve = system.getObject("service.main.saasmainSve");
this.saaschannelSve = system.getObject("service.channel.saaschannelSve");
// -------------------------------将要弃用------------------------------------------ // -------------------------------将要弃用------------------------------------------
...@@ -43,6 +44,8 @@ class ActionAPI extends APIBase { ...@@ -43,6 +44,8 @@ class ActionAPI extends APIBase {
async handleRequest(action_process, action_type, action_body) { async handleRequest(action_process, action_type, action_body) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
// 签约主体
case "mainDics": case "mainDics":
opResult = await this.saasmainSve.dics(action_body); opResult = await this.saasmainSve.dics(action_body);
break; break;
...@@ -56,6 +59,22 @@ class ActionAPI extends APIBase { ...@@ -56,6 +59,22 @@ class ActionAPI extends APIBase {
opResult = await this.saasmainSve.save(action_body); opResult = await this.saasmainSve.save(action_body);
break; break;
// 渠道
case "channelDics":
opResult = await this.saaschannelSve.dics(action_body);
break;
case "channelPage":
opResult = await this.saaschannelSve.pageByCondition(action_body);
break;
case "channelInfo":
opResult = await this.saaschannelSve.info(action_body);
break;
case "channelSave":
opResult = await this.saaschannelSve.save(action_body);
break;
// 商户
// ------------------------------以下api为历史将要弃用的--------------------------------------- // ------------------------------以下api为历史将要弃用的---------------------------------------
// 商户api // 商户api
case "infoList": case "infoList":
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasChannelDao extends Dao {
constructor() {
super(Dao.getModelName(SaasChannelDao));
}
async listByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE id IN (:ids) `;
return await this.customQuery(sql, {
ids: ids
});
}
async mapByIds(ids, attrs) {
let result = {};
let list = await this.listByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async bySaasId(saasId, attrs) {
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE saas_id = :saasId `;
return await this.customQuery(sql, {
saasId: saasId
});
}
}
module.exports = SaasChannelDao;
...@@ -32,20 +32,8 @@ class SaasMainDao extends Dao { ...@@ -32,20 +32,8 @@ class SaasMainDao extends Dao {
attrs = attrs || "*"; attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE saas_id = :saasId `; let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE saas_id = :saasId `;
return await this.customQuery(sql, { return await this.customQuery(sql, {
ids: ids saasId: saasId
}); });
} }
} }
module.exports = SaasMainDao; module.exports = SaasMainDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("saaschannel", {
name: DataTypes.STRING,
short_name: DataTypes.STRING,
credit_code: DataTypes.STRING,
business_lincense_img: DataTypes.STRING,
residence: DataTypes.STRING,
tax_type: DataTypes.STRING,
business_scope: DataTypes.STRING,
term: DataTypes.INTEGER,
term_end: DataTypes.DATE,
idcard_front: DataTypes.STRING,
idcard_back: DataTypes.STRING,
legal_idno: DataTypes.STRING,
legal_name: DataTypes.STRING,
validity: DataTypes.INTEGER,
validity_end: DataTypes.DATE,
account_name: DataTypes.STRING,
account_bank_name: DataTypes.STRING,
account_bank_no: DataTypes.STRING,
account_mobile: DataTypes.STRING,
contact_man: DataTypes.STRING,
contact_mobile: DataTypes.STRING,
contact_email: DataTypes.STRING,
contact_addr: DataTypes.STRING,
saas_id: DataTypes.INTEGER,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'saas_channel',
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class SaasChannelService extends ServiceBase {
constructor() {
super("channel", ServiceBase.getDaoName(SaasChannelService));
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async dics(params) {
let saas_id = Number(this.trim(params.saas_id) || 0);
if (!saas_id) {
return system.getResultSuccess([]);
}
let list = await this.dao.bySaasId(Number(params.saas_id), "id, name, short_name");
return system.getResultSuccess(list);
}
async info(params) {
if (!params.id) {
return system.getResult(null, "id不存在");
}
let main = await this.dao.getById(params.id);
if (!main) {
return system.getResult(null, "签约主体不存在");
}
this.handleDate(main, ["created_at"], null, -8);
return system.getResultSuccess(main);
}
async save(params) {
let id = Number(params.id || 0);
let saas_id = Number(params.saas_id || 0);
let term = Number(params.term || 1);
let term_end = this.trim(params.term_end);
let validity = Number(params.validity || 1);
let validity_end = this.trim(params.validity_end);
if (!saas_id) {
return getResult(null, "签约主体不存在");
}
if (!this.trim(params.name)) {
return system.getResult(null, "请填写渠道名称");
}
if (!this.trim(params.short_name)) {
return system.getResult(null, "请填写渠道简称");
}
if (!this.trim(params.credit_code)) {
return system.getResult(null, "请填写统一社会信用代码");
}
// if(!this.trim(params.business_lincense_img)) {return system.getResult(null, ""); } // 营业执照暂不验证
if (!this.trim(params.tax_type)) {
return system.getResult(null, "请选择纳税人类型");
}
if (!this.trim(params.residence)) {
return system.getResult(null, "请填写住所");
}
if (!this.trim(params.business_scope)) {
return system.getResult(null, "请填写经营范围");
}
if (term == 2 && !term_end) {
return system.getResult(null, "请填写营业期限固定日期");
}
// if(!this.trim(params.idcard_front)) {return system.getResult(null, "idcard_front为空"); }
// if(!this.trim(params.idcard_back)) {return system.getResult(null, "idcard_back为空"); }
if (!this.trim(params.legal_name)) {
return system.getResult(null, "请填写法人姓名");
}
if (!this.trim(params.legal_idno)) {
return system.getResult(null, "请填写法人身份证");
}
if (validity == 2 && !validity_end) {
return system.getResult(null, "请填写有效期限固定日期");
}
if (!this.trim(params.account_name)) {
return system.getResult(null, "请填写账户名称");
}
if (!this.trim(params.account_bank_name)) {
return system.getResult(null, "请填写开户行");
}
if (!this.trim(params.account_bank_no)) {
return system.getResult(null, "请填写开户账号");
}
if (!this.trim(params.account_mobile)) {
return system.getResult(null, "请填写联系电话");
}
if (!this.trim(params.contact_man)) {
return system.getResult(null, "请填写联系人姓名");
}
if (!this.trim(params.contact_mobile)) {
return system.getResult(null, "请填写联系人电话");
}
if (!this.trim(params.contact_email)) {
return system.getResult(null, "请填写联系人邮箱");
}
if (!this.trim(params.contact_addr)) {
return system.getResult(null, "请填写联系人地址");
}
let channel;
if (id) {
channel = await this.dao.findById(id);
} else {
channel = {};
channel.saas_id = saas_id;
}
channel.name = this.trim(params.name);
channel.short_name = this.trim(params.short_name);
channel.credit_code = this.trim(params.credit_code);
channel.business_lincense_img = this.trim(params.business_lincense_img);
channel.residence = this.trim(params.residence);
channel.tax_type = this.trim(params.tax_type);
channel.business_scope = this.trim(params.business_scope);
channel.idcard_front = this.trim(params.idcard_front);
channel.idcard_back = this.trim(params.idcard_back);
channel.legal_idno = this.trim(params.legal_idno);
channel.legal_name = this.trim(params.legal_name);
channel.account_name = this.trim(params.account_name);
channel.account_bank_name = this.trim(params.account_bank_name);
channel.account_bank_no = this.trim(params.account_bank_no);
channel.account_mobile = this.trim(params.account_mobile);
channel.contact_man = this.trim(params.contact_man);
channel.contact_mobile = this.trim(params.contact_mobile);
channel.contact_email = this.trim(params.contact_email);
channel.contact_addr = this.trim(params.contact_addr);
channel.term = term;
channel.term_end = term_end;
channel.validity = validity;
channel.validity_end = validity_end;
if (channel.id) {
await channel.save();
} else {
channel = await this.dao.create(channel);
}
return system.getResultSuccess(channel);
}
async pageByCondition(params) {
var currentPage = Number(params.currentPage || 0);
var pageSize = Number(params.pageSize || 10);
var where = {
saas_id: params.saas_id,
};
if (params.name) {
where.name = {
[this.db.Op.like]: "%" + params.name + "%"
};
}
// this.addWhereTime(where, 'created_at', params.createdBegin, params.createdEnd, true);
var orderby = [
["id", 'desc']
];
var page = await this.getPageList(currentPage, pageSize, where, orderby, null);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
}
return system.getResultSuccess(page);
}
}
module.exports = SaasChannelService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
...@@ -12,7 +12,7 @@ class SaasMainService extends ServiceBase { ...@@ -12,7 +12,7 @@ class SaasMainService extends ServiceBase {
if (!saas_id) { if (!saas_id) {
return system.getResultSuccess([]); return system.getResultSuccess([]);
} }
let list = await this.dao.bySaasId(Number(params.saas_id)); let list = await this.dao.bySaasId(Number(params.saas_id), "id, name");
return system.getResultSuccess(list); return system.getResultSuccess(list);
} }
......
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