Commit 0c42cf1e by 王昆

gsb

parent 44eff855
......@@ -4,14 +4,7 @@ var settings = require("../../../../config/settings");
class ActionAPI extends APIBase {
constructor() {
super();
this.domicileSve = system.getObject("service.common.domicileSve");
this.businessscopeSve = system.getObject("service.common.businessscopeSve");
this.captchaSve = system.getObject("service.common.captchaSve");
this.deliverSve = system.getObject("service.deliver.deliverSve");
this.invoicecontentSve = system.getObject("service.common.invoicecontentSve");
this.smsinfoSve = system.getObject("service.common.smsinfoSve");
this.storderSve = system.getObject("service.trade.storderSve");
}
/**
* 接口跳转
......@@ -41,141 +34,10 @@ class ActionAPI extends APIBase {
switch (action_type) {
// 图片验证码
case "getCaptha":
opResult = await this.captchaSve.apiGenerate(action_body);
break;
case "validCaptha":
opResult = await this.captchaSve.apiValidator(action_body);
break;
// 注册地
case "domicileNameList":
opResult = await this.domicileSve.apiNameList(action_body);
break;
case "domicileTree":
opResult = await this.domicileSve.apiTree(action_body);
break;
case "domicilePage":
opResult = await this.domicileSve.apiPage(action_body);
break;
case "domicileSave":
opResult = await this.domicileSve.apiSave(action_body);
break;
case "domicileInfo":
opResult = await this.domicileSve.apiInfo(action_body);
break;
case "domicileDelete":
opResult = await this.domicileSve.apiDeleteByIds(action_body);
break;
// 经营范围
case "businessscopeByDomicileId":
opResult = await this.businessscopeSve.apiDomicileList(action_body);
break;
case "businessscopePage":
opResult = await this.businessscopeSve.apiPage(action_body);
break;
case "businessscopeSave":
opResult = await this.businessscopeSve.apiSave(action_body);
break;
case "businessscopeInfo":
opResult = await this.businessscopeSve.apiInfo(action_body);
break;
case "businessscopeDelete":
opResult = await this.businessscopeSve.apiDeleteByIds(action_body);
case "test":
opResult = await this.storderSve.test(action_body);
break;
// 交付商
case "deliverAll":
opResult = await this.deliverSve.apiAll(action_body);
break;
case "deliverPage":
opResult = await this.deliverSve.apiPage(action_body);
break;
case "deliverSave":
opResult = await this.deliverSve.apiSave(action_body);
break;
case "deliverInfo":
opResult = await this.deliverSve.apiInfo(action_body);
break;
case "deliverDelete":
opResult = await this.deliverSve.apiDeleteByIds(action_body);
break;
case "deliverResetPassword":
opResult = await this.deliverSve.updPassword(action_body);
break;
case "deliverEnable":
opResult = await this.deliverSve.enable(action_body);
break;
case "deliverLogin":
opResult = await this.deliverSve.login(action_body);
break;
case "deliverUsers":
opResult = await this.deliverSve.deliverUsers(action_body);
break;
case "deliverUserMap":
opResult = await this.deliverSve.deliverUserMap(action_body);
break;
case "deliverUserPage":
opResult = await this.deliverSve.deliverUserPage(action_body);
break;
case "deliverUserById":
opResult = await this.deliverSve.deliverUserById(action_body);
break;
case "deliverUserSave":
opResult = await this.deliverSve.deliverUserSave(action_body);
break;
case "deliverUserInfo":
opResult = await this.deliverSve.deliverUserInfo(action_body);
break;
case "deliverSynUpdate":
opResult = await this.deliverSve.deliverSynUpdate(action_body);
break;
case "orgTree":
opResult = await this.deliverSve.orgTree(action_body);
break;
case "allOrg":
opResult = await this.deliverSve.allOrg(action_body);
break;
case "orgById":
opResult = await this.deliverSve.orgById(action_body);
break;
case "orgSave":
opResult = await this.deliverSve.orgSave(action_body);
break;
// 发票内容
case "invoicecontentSave":
opResult = await this.invoicecontentSve.apiSave(action_body);
break;
case "invoicecontentDelete":
opResult = await this.invoicecontentSve.apiDelete(action_body);
break;
case "invoiceList":
opResult = await this.invoicecontentSve.apiList(action_body);
break;
case "invoicecontent":
opResult = await this.invoicecontentSve.apiGetById(action_body);
break;
case "invoicecontentAll":
opResult = await this.invoicecontentSve.getAll(action_body);
break;
// 阿里短信服务
case "sendSms": //发送短信
opResult = await this.smsinfoSve.sendSms(action_body);
break;
case "querySendDetails": //查询发送记录
opResult = await this.smsinfoSve.querySendDetails(action_body);
break;
case "querySmsInfos": //条件查询
opResult = await this.smsinfoSve.querySmsInfos(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class BusinessscopeDao extends Dao {
constructor() {
super(Dao.getModelName(BusinessscopeDao));
}
async findListByDomicileIds(domicileIds) {
if (!domicileIds || domicileIds.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, domicile_id, businessType,");
sql.push("businessscope, isEnabled, created_at ");
sql.push("FROM d_businessscope");
sql.push("WHERE domicile_id IN (:domicileIds)");
return await this.customQuery(sql.join(" "), {
domicileIds: domicileIds
}) || [];
}
async findMapByDomicileIds(domicileIds) {
var result = {};
if (!domicileIds || domicileIds.length == 0) {
return result;
}
var list = await this.findListByDomicileIds(domicileIds);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
var domicileList = result[item.domicile_id] || [];
domicileList.push(item);
result[item.domicile_id] = domicileList;
}
return result;
}
async delById(id, t) {
var sql = "DELETE FROM d_businessscope WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async delByDomicileId(domicileId, t) {
var sql = "DELETE FROM d_businessscope WHERE domicile_id = :domicileId";
return await this.customUpdate(sql, {
domicileId: domicileId
}, t);
}
}
module.exports = BusinessscopeDao;
// 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 Dao = require("../../dao.base");
class DomicileDao extends Dao {
constructor() {
super(Dao.getModelName(DomicileDao));
}
async getList(isEnabled, attrs) {
attrs = attrs || "*"
var sql = [];
sql.push("SELECT ");
sql.push(attrs);
sql.push("FROM d_domicile");
if (isEnabled == 1) {
sql.push("WHERE isEnabled = 1");
}
return await this.customQuery(sql.join(" ")) || [];
}
async delById(id, t) {
var sql = "DELETE FROM d_domicile WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async findListByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, name, isEnabled, created_at ");
sql.push("FROM d_domicile");
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = DomicileDao;
// 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 Dao=require("../../dao.base");
class InvoicecontentDao extends Dao{
constructor(){
super(Dao.getModelName(InvoicecontentDao));
}
async getByEnabled() {
let sql = "SELECT id, `name` FROM `d_invoicecontent` WHERE isEnabled = 1";
return this.customQuery(sql);
}
}
module.exports=InvoicecontentDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class SmsinfoDao extends Dao {
constructor() {
super(Dao.getModelName(SmsinfoDao));
}
}
module.exports = SmsinfoDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class DeliverDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverDao));
}
async getList(isEnabled, attrs) {
attrs = attrs || "*"
var sql = [];
sql.push("SELECT ");
sql.push(attrs);
sql.push("FROM d_deliver");
if (isEnabled == 1) {
sql.push("WHERE isEnabled = 1");
}
return await this.customQuery(sql.join(" ")) || [];
}
async delById(id, t) {
var sql = "DELETE FROM d_deliver WHERE id = :id";
return await this.customUpdate(sql, {
id: id
}, t);
}
async findListByIds(ids) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("id, name, businessmenDivide, invoiceDivide, isEnabled, created_at ");
sql.push("FROM d_deliver");
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = DeliverDao;
// 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 Dao = require("../../dao.base");
class DeliveruserDao extends Dao {
class StOrderDao extends Dao {
constructor() {
super(Dao.getModelName(DeliveruserDao));
super(Dao.getModelName(StOrderDao));
}
async findByUcname(ucname) {
let sql = "SELECT * FROM d_deliver_user WHERE ucname = :ucname";
let list = await this.customQuery(sql, {ucname: ucname});
if(!list) {
return null;
}
return list[0];
}
async findListByIds(ids) {
async findListByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM d_deliver_user");
sql.push(attrs || "*");
sql.push("FROM");
sql.push(this.model.tableName);
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
async findMapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
var list = await this.findListByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
......@@ -43,16 +35,4 @@ class DeliveruserDao extends Dao {
return result;
}
}
module.exports = DeliveruserDao;
// 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
module.exports = StOrderDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class DeliverorgDao extends Dao {
class StOrderItemDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverorgDao));
super(Dao.getModelName(StOrderItemDao));
}
async byDeliverId(deliver_id, attrs) {
attrs = attrs || "*";
var sql = [];
sql.push("SELECT");
sql.push(attrs);
sql.push("FROM d_deliver_org");
sql.push("WHERE deliver_id = :deliver_id AND deleted_at IS NULL");
return this.customQuery(sql.join(" "), {deliver_id: deliver_id});
}
async findListByIds(ids) {
async findListByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM d_deliver_org");
sql.push(attrs || "*");
sql.push("FROM");
sql.push(this.model.tableName);
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async findMapByIds(ids) {
async findMapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.findListByIds(ids);
var list = await this.findListByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
......@@ -44,19 +34,5 @@ class DeliverorgDao extends Dao {
}
return result;
}
}
module.exports = DeliverorgDao;
// 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
module.exports = StOrderItemDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("invoicecontent", {
name: DataTypes.STRING,
isEnabled: {
type:DataTypes.BOOLEAN,
allowNull:false,
defaultValue:false
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_invoicecontent',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("smsinfo", {
regionId: { type: DataTypes.STRING, field:'region_id', comment:'' },
phoneNumbers: { type: DataTypes.STRING, field:'phone_numbers', comment:'电话' },
templateCode: { type: DataTypes.STRING, field:'template_code', comment:'模板code' },
templateParam: { type: DataTypes.STRING, field:'template_param', comment:'模板参数' },
signName: { type: DataTypes.STRING, field:'sign_name', comment:'签名' },
result: { type: DataTypes.STRING, field:'result', comment:'返回结果' },
success: { type: DataTypes.STRING, field:'success', comment:'是否成功 1 成功 0 失败' },
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_sms_info',
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 settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliver", {
name: DataTypes.STRING,
businessmenDivide: DataTypes.INTEGER,
invoiceDivide: DataTypes.INTEGER,
admin_id: DataTypes.STRING,
remark: DataTypes.STRING,
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: true,
},
nt_company_id: DataTypes.STRING,
saas_id: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_deliver',
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 settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliverorg", {
deliver_id: DataTypes.STRING,
company_id: DataTypes.INTEGER,
code: DataTypes.STRING,
name: DataTypes.STRING,
parent_id: DataTypes.INTEGER,
path: DataTypes.STRING,
type: DataTypes.STRING,
group_type: DataTypes.STRING,
description: DataTypes.STRING,
del_flag: DataTypes.STRING,
crt_time: DataTypes.DATE,
crt_user: DataTypes.STRING,
crt_name: DataTypes.STRING,
crt_host: DataTypes.STRING,
upd_time: DataTypes.DATE,
upd_user: DataTypes.STRING,
upd_name: DataTypes.STRING,
upd_host: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_deliver_org',
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 settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("deliveruser", {
real_name: DataTypes.STRING,
ucname: DataTypes.STRING,
password: DataTypes.STRING,
deliver_id: DataTypes.STRING,
isAdmin: {
type: DataTypes.BOOLEAN,
allowNull: true,
},
saas_id: DataTypes.STRING,
org_id: DataTypes.INTEGER,
org_path: DataTypes.STRING,
auth: DataTypes.STRING,
nt_user_id: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_deliver_user',
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
......@@ -2,14 +2,25 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("businessscope", {
domicile_id: DataTypes.STRING,
businessType: DataTypes.STRING,
businessscope: DataTypes.STRING,
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: true,
},
return db.define("storder", {
saas_merchant_id: DataTypes.STRING, // saas商户id
out_trade_no: DataTypes.STRING, // 商户订单号
service_rate: DataTypes.INTEGER, // 商户订单号
amt: DataTypes.BIGINT, // 请求打款金额
actual_amt: DataTypes.BIGINT, // 实发金额
deduct_amt: DataTypes.BIGINT, // 扣款金额
service_tax: DataTypes.BIGINT, // 服务费
item_count: DataTypes.INTEGER, // 打款笔数
order_type: DataTypes.STRING, // 订单类型 00钱过公司宝 01 钱不过公司宝 02 微信
acc_type: DataTypes.STRING, // 打款通道 00 银行 01 支付宝 02 微信
trade_mode: DataTypes.STRING, // 打款模式 00 未选择 01 系统打款 02 手工打款
trade_status: DataTypes.STRING, // 交易状态 00 成功 01 待处理 02 失败 03 部分成功
check_status: DataTypes.STRING, // 审核状态 00 一审 01 一审失败 02 二审 03 二审失败 04 二审通过
check1_remark: DataTypes.STRING, // 一审备注
check2_remark: DataTypes.STRING, // 二审备注
pay_voucher: DataTypes.STRING, // 付款凭证 暂用此字段,以后创建交易付款
order_file: DataTypes.STRING, // 打款文件地址
saas_id: DataTypes.STRING, // saas_id
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -17,7 +28,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_businessscope',
tableName: 'st_order',
validate: {},
indexes: [
// Create a unique index on email
......
......@@ -2,12 +2,23 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("domicile", {
name: DataTypes.STRING,
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: true,
},
return db.define("storderitem", {
saas_merchant_id: DataTypes.STRING, // saas商户id
order_id: DataTypes.STRING, // 订单id
out_trade_no: DataTypes.STRING, // 商户订单号
acc_name: DataTypes.STRING, // 收款户名
acc_no: DataTypes.STRING, // 收款账号
open_bank: DataTypes.STRING, // 开户银行全称
amt: DataTypes.BIGINT, // 请求打款金额
actual_amt: DataTypes.BIGINT, // 实发金额
deduct_amt: DataTypes.BIGINT, // 扣款金额
service_tax: DataTypes.BIGINT, // 服务费
trade_status: DataTypes.STRING, // 交易状态 00 成功 01 待处理 02 失败
trade_time: DataTypes.DATE, // 交易时间
trade_desc: DataTypes.STRING, // 交易描述
trade_receipt: DataTypes.STRING, // 回执
}, {
paranoid: true, //假的删除
underscored: true,
......@@ -15,7 +26,7 @@ module.exports = (db, DataTypes) => {
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'd_domicile',
tableName: 'st_order_item',
validate: {},
indexes: [
// Create a unique index on email
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class BusinessscopeService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(BusinessscopeService));
this.domicileDao = system.getObject("db.common.domicileDao");
}
async apiPage(params) {
try {
return await this.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSave(params) {
try {
return await this.save(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDomicileList(params) {
try {
return await this.ListByDomicileId(params.domicileId);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDeleteByIds(params) {
var ids = params.ids || [];
try {
for(var id of ids) {
// 单条删除,方便以后有级联删除时使用事务
await this.delById(id);
}
return system.getResultSuccess(1);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
// where: {
// id: id
// },
// attrs: ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at",],
// raw: true
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async ListByDomicileId(domicileId) {
var list = await this.dao.findListByDomicileIds([domicileId]) || [];
for(var item of list) {
this.handleDate(item, ["created_at"], null, -8);
}
await this.setDomicile(list);
return system.getResultSuccess(list);
}
async info(params) {
var id = params.id;
var sqlWhere = {
where: {
id: id
},
attributes: ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at",],
raw: true
};
var item = await this.dao.model.findOne(sqlWhere);
if(!item) {
return system.getResult(null, "经营范围不存在");
}
this.handleDate(item, ["created_at"], null, -8);
await this.setDomicile([item]);
return system.getResultSuccess(item);
}
async delById(id) {
if(!id) {
return;
}
await this.dao.delById(id);
return system.getResultSuccess(1);
}
async save(params) {
var domicileId = params.domicileId;
if (!domicileId) {
return system, getResult(null, domicileId);
}
var id = params.id;
var bsc;
if (id) {
bsc = await this.dao.findById(id);
} else {
bsc = {domicile_id: domicileId};
}
bsc.businessType = this.trim(params.businesssType);
bsc.businessscope = this.trim(params.businessscope);
bsc.isEnabled = params.isEnabled == 1 ? true : false;
if(bsc.id) {
bsc = await bsc.save();
} else {
bsc = await this.dao.create(bsc);
}
return system.getResultSuccess(bsc);
}
async page(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.domicileId) {
where.domicile_id = params.domicileId;
}
if (params.isEnabled) {
where.isEnabled = params.isEnabled || 1;
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "domicile_id", "businessType", "businessscope", "isEnabled", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
row.isEnabled=row.isEnabled==1?'启用':'未启用';
}
await this.setDomicile(page.rows);
}
return system.getResultSuccess(page);
}
async setDomicile(rows) {
if(!rows || rows.length == 0) {
return;
}
var ids = [];
for(var item of rows) {
ids.push(item.domicile_id);
}
var map = await this.domicileDao.findMapByIds(ids);
for(var item of rows) {
item.domicile = map[item.domicile_id] || {};
this.handleDate(item.domicile, ["created_at"], null, -8);
}
}
}
module.exports = BusinessscopeService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
const uuidv4 = require('uuid/v4');
var svgCaptcha = require('svg-captcha');
class CaptchaService {
constructor() {
this.redisClient = system.getObject("util.redisClient");
}
async apiGenerate(params) {
var key = uuidv4();
var options = {
size: 4,
noise: 1,
ignoreChars: '0o1iILl'
};
options.width = this.trim(params.width) || 120;
options.height = this.trim(params.height) || 32;
options.background = this.trim(params.background) || "#E8E8E8";
var captchaPrev = this.trim(params.captchaPrev);
var expire = Number(params.expire || 3 * 60)
try {
var cap = svgCaptcha.create(options);
console.log(cap);
await this.redisClient.setWithEx(key, cap.text, expire);
return system.getResultSuccess({
key: key,
text: cap.text,
captcha: cap.data,
});
} catch (error) {
return system.getResult(null, "接口异常:" + error.message);
}
}
async apiValidator(params) {
var key = this.trim(params.key);
var code = this.trim(params.code);
var cacheCode = await this.redisClient.get(key);
if(!cacheCode) {
return system.getResult(null, "验证码已过期,请点击重试");
}
if(code.toLowerCase() != cacheCode.toLowerCase()) {
await this.redisClient.delete(key);
return system.getResult(null, "验证码输入错误,清点击重试");
}
return system.getResultSuccess(1);
}
trim(o) {
if(!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = CaptchaService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class DomicileService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(DomicileService));
this.businessscopeDao = system.getObject("db.common.businessscopeDao");
}
async apiNameList(params) {
try {
return await this.nameList();
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiTree(params) {
try {
return await this.tree(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiPage(params) {
try {
return await this.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiSave(params) {
try {
return await this.save(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiInfo(params) {
try {
return await this.info(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDeleteByIds(params) {
var ids = params.ids;
if (!ids || ids.length == 0) {
return system.getResult(null, "传入参数错误:ids=" + JSON.stringify(ids));
}
try {
for (var id of ids) {
try {
await this.delById(id);
} catch (error) {
console.log(error);
}
}
return system.getResultSuccess(1);
} catch (error) {
return system.getResult(null, "接口异常");
}
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
async info(params) {
var id = params.id;
if (!id) {
return system.getResult(null, "注册地不存在");
}
var sqlWhere = {
where: {
id: id
},
attributes: ["id", "name", "isEnabled", "created_at"],
raw: true
};
var item = await this.dao.model.findOne(sqlWhere);
if (!item) {
return system.getResult(null, "注册地不存在");
}
this.handleDate(item, ["created_at"], null, -8);
await this.setBusinessscopeList([item]);
return system.getResultSuccess(item);
}
async save(params) {
var id = params.id;
var domicile;
if (id) {
domicile = await this.dao.findById(id);
} else {
domicile = {};
}
domicile.name = this.trim(params.name);
domicile.isEnabled = params.isEnabled == 1 ? true : 0;
if (id) {
domicile = await domicile.save();
} else {
domicile = await this.dao.create(domicile);
}
return system.getResultSuccess(domicile);
}
async nameList() {
var list = await this.dao.getList(1, "id, name");
return system.getResultSuccess(list);
}
async tree(isEnabled) {
var tree = await this.dao.getList(isEnabled, "id, name, created_at");
if (tree) {
for (var row of tree) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setBusinessscopeList(tree);
}
return system.getResultSuccess(tree);
}
async delById(id) {
if (!id) {
return system.getResult(null, "删除失败");
}
var self = this;
await this.db.transaction(async function (t) {
await self.dao.delById(id, t);
await self.businessscopeDao.delByDomicileId(id, t);
});
return system.getResultSuccess(1);
}
async page(params) {
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.id > 0) {
where.id = params.id;
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "name", "isEnabled", "created_at"];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) {
for (var row of page.rows) {
this.handleDate(row, ["created_at"], null, -8);
}
await this.setBusinessscopeList(page.rows);
}
return system.getResultSuccess(page);
}
async setBusinessscopeList(rows) {
if (!rows || rows.length == 0) {
return rows;
}
var ids = [];
for (var item of rows) {
ids.push(item.id);
}
var bsmap = await this.businessscopeDao.findMapByDomicileIds(ids)
for (var row of rows) {
row.businessscopeList = bsmap[row.id] || [];
for (var item of row.businessscopeList) {
this.handleDate(item, ["created_at"], null, -8);
}
}
}
}
module.exports = DomicileService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
// var settings = require("../../../../config/settings");
class InvoicecontentService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(InvoicecontentService));
// this.invoicecontentDao=system.getObject("db.common.invoicecontentDao");
}
async apiSave(params) {
try {
return await this.save(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiGetById(params) {
try {
if(!params.id){
return system.getResult(null, "参数错误");
}
return await this.getById(params.id);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiList(params) {
try {
console.log("--"+JSON.stringify(params));
return await this.invoiceList(params);
} catch (error) {
console.log(error);
return system.getResult(null, "接口异常");
}
}
async apiDelete(params) {
var ids = params.ids;
if (!ids || ids.length == 0) {
return system.getResult(null, "传入参数错误:ids=" + JSON.stringify(ids));
}
try {
try {
await this.bulkDelete(ids);
} catch (error) {
console.log(error);
}
return system.getResultSuccess(1);
} catch (error) {
return system.getResult(null, "接口异常");
}
}
/**--------------------------------------------------------------------- */
async getById(id){
let res = await this.dao.findById(id);
return system.getResultSuccess(res);
}
async save(params) {
let id = params.id;
let invoicecontent;
if(id){
invoicecontent=await this.dao.findById(id);
}else{
invoicecontent={};
}
invoicecontent.name=this.trim(params.name);
invoicecontent.isEnabled=(params.isEnabled)==1?true:false;
if(id){
await invoicecontent.save();
}else{
invoicecontent = await this.dao.create(invoicecontent);
}
return system.getResultSuccess(invoicecontent);
}
async bulkDelete(ids) {
if (!ids || ids.length == 0) {
return system.getResult(null, "删除失败");
}
await this.dao.bulkDelete(ids);
}
async getAll(params) {
let list = await this.dao.getByEnabled(1) || [];
return system.getResultSuccess(list);
}
async invoiceList(params) {
console.log(JSON.stringify(params));
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.name) {
where.name = {
[this.db.Op.like]: "%" + decodeURIComponent(params.name) + "%"
};
}
var orderby = [
["id", 'desc']
];
var attributes = ["id", "name", "isEnabled", "created_at"];
let res = await this.dao.getPageList(currentPage, pageSize, where, orderby, attributes);
return res;
}
}
module.exports = InvoicecontentService;
const system = require("../../../system");
const settings = require("../../../../config/settings")
const Core = require('@alicloud/pop-core');
const ServiceBase = require("../../sve.base");
class SmsinfoService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(SmsinfoService));
let aliSmsConfig = settings.aliSmsConfig();
this.aliSmsConfigration = aliSmsConfig;
this.client = new Core({
accessKeyId: aliSmsConfig.accessKeyId,
accessKeySecret: aliSmsConfig.accessKeySecret,
endpoint: aliSmsConfig.endpoint,
apiVersion: aliSmsConfig.apiVersion
});
}
/**
* 发送短信
* @param {*} params
*/
async sendSms(params) {
let key = this.trim(params.templateName);
let loginTemplateConfig = this.aliSmsConfigration.template[key];
if (!loginTemplateConfig) {
return system.getResult(-1, `参数错误 模板不存在`);
}
if (!params.phoneNumbers) {
return system.getResult(null, `参数错误 手机号不能为空`);
}
let data = {
"RegionId": "cn-hangzhou",
"PhoneNumbers": params.phoneNumbers,
"TemplateCode": loginTemplateConfig.code,
"SignName": this.aliSmsConfigration.signName
}
if (params.hasOwnProperty("code")) {
data.TemplateParam = `{\"code\":\"${params.code}\"}`;
}else if(params.hasOwnProperty("name")){
data.TemplateParam = `{\"name\":\"${params.name}\"}`;
}
try {
//创建记录
let _smsInfo = await this.dao.create({
regionId: data.RegionId,
phoneNumbers: data.PhoneNumbers,
templateCode: data.TemplateCode,
templateParam: data.TemplateParam,
signName: data.SignName
});
let res = await this.client.request('SendSms', data, {
method: 'POST'
});
_smsInfo.result = JSON.stringify(res);
if (res.Code == "OK") {
_smsInfo.success = 1;
} else {
_smsInfo.success = 0;
}
await _smsInfo.save();
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询发送记录
* @param {*} params
*/
async querySendDetails(params) {
if (!params.phoneNumbers) {
return system.getResult(null, `参数错误 手机号不能为空`);
}
if (!params.sendDate) {
return system.getResult(null, `参数错误 日期不能为空`);
}
let data = {
"RegionId": "cn-hangzhou",
"PhoneNumbers": params.phoneNumbers,
"SendDate": this.trim(params.sendDate),
"PageSize": Number(this.trim(params.pageSize) || 10),
"CurrentPage": Number(this.trim(params.currentPage) || 1),
}
try {
let res = await this.client.request('QuerySendDetails', data, {
method: 'POST'
});
return system.getResult(res);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 条件查询所有的记录
* @param {*} params
*/
async querySmsInfos(params) {
let where = {};
if (params.regionId) {
where.regionId = this.trim(params.regionId);
}
if (params.phoneNumbers) {
where.phoneNumbers = this.trim(params.phoneNumbers);
}
if (params.templateCode) {
where.templateCode = this.trim(params.templateCode);
}
if (params.templateParam) {
where.templateParam = this.trim(params.templateParam);
}
if (params.signName) {
where.signName = this.trim(params.signName);
}
if (params.hasOwnProperty("success")) {
where.success = this.trim(params.success);
}
var currentPage = Number(params.currentPage || 1);
var pageSize = Number(params.pageSize || 10);
var orderby = [
["id", 'desc']
];
var attributes = ["id", "regionId", "phoneNumbers", "templateCode", "templateParam", "signName", "result", "success", "created_at"];
try {
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
return system.getResult(page);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
trim(o) {
if (!o) {
return "";
}
return o.toString().trim();
}
}
module.exports = SmsinfoService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class StOrderService extends ServiceBase {
constructor() {
super("deliver", ServiceBase.getDaoName(StOrderService));
this.deliveruserDao = system.getObject("db.deliver.deliveruserDao");
this.deliverorgDao = system.getObject("db.deliver.deliverorgDao");
}
async test(params) {
return system.getResultSuccess("test");
}
// 列表页
// 详情
// 解析打款详情 excel
// 保存打款信息
// 付款申请上传
//
async page(params) {
let currentPage = Number(params.currentPage || 1);
let pageSize = Number(params.pageSize || 10);
let where = {};
if(params.id){
where.id=this.trim(params.id);
}
if(params.name){
where.name=this.trim(params.name);
}
let orderby = [
["id", 'desc']
];
let 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);
}
await this.setUser(page.rows);
}
return system.getResultSuccess(page);
}
}
module.exports = StOrderService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
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