Commit 7d1b1761 by 王昆

gsb

parent 72722482
const system = require("../../../system");
const Dao = require("../../dao.base");
class IInvoiceinforegDao extends Dao {
constructor() {
super(Dao.getModelName(IInvoiceinforegDao));
this.tableName = this.model.tableName;
}
}
module.exports = IInvoiceinforegDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class IInvoiceprocessDao extends Dao {
constructor() {
super(Dao.getModelName(IInvoiceprocessDao));
this.tableName = this.model.tableName;
}
async delByOrderId(order_id) {
if (!order_id) {
return;
}
let sql = `DELETE FROM ${this.tableName} WHERE order_id = :order_id`;
await this.customUpdate(sql, {order_id: order_id});
}
async findByOrderIdAndStatus(orderId, status) {
if (!orderId || !status) {
return null;
}
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM");
sql.push(this.tableName);
sql.push("WHERE order_id = :orderId");
sql.push("AND `status` = :status");
let list = await this.customQuery(sql.join(" "), {orderId: orderId, status: status});
if (!list || list.length == 0) {
return null;
}
return list[0];
}
async listByOrderIdsAndStatus(orderIds, statuses) {
var result = {};
if (!orderIds || orderIds.length == 0 || !statuses || statuses.length == 0) {
return result;
}
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM");
sql.push(this.tableName);
sql.push("WHERE order_id IN (:orderIds)");
sql.push("AND `status` IN (:statuses)");
return await this.customQuery(sql.join(" "), {orderIds: orderIds, statuses: statuses});
}
async mapByOrderIdsAndStatus(orderIds, statuses) {
var result = {};
let list = await this.listByOrderIdsAndStatus(orderIds, statuses);
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
result[item.order_id + "_" + item.status] = item;
}
return result;
}
}
module.exports = IInvoiceprocessDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class IInvoicesummaryinfoDao extends Dao {
constructor() {
super(Dao.getModelName(IInvoicesummaryinfoDao));
}
}
module.exports = IInvoicesummaryinfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class IprocessDao extends Dao {
constructor() {
super(Dao.getModelName(IprocessDao));
this.tableName = this.model.tableName;
}
async getAll(attrs) {
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.tableName} ORDER BY status ASC`;
return await this.customQuery(sql);
}
async mapAll(attrs) {
let result = {};
let list = await this.getAll(attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async findMapByIds(ids, attrs) {
let result = {};
if (!ids || ids.length == 0) {
return result;
}
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.tableName} WHERE id IN (:ids)`;
let list = await this.customQuery(sql, {
ids: ids
});
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = IprocessDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IproductDao extends Dao {
constructor() {
super(Dao.getModelName(IproductDao));
this.tableName = this.model.tableName;
}
async dics(params) {
let sql = [];
sql.push("SELECT");
sql.push("id, `name`, `desc`, pid");
sql.push("FROM");
sql.push(this.tableName);
sql.push("WHERE 1 = 1");
if (params.pid) {
sql.push("AND pid = :pid");
}
if (params.hasOwnProperty("is_choose")) {
sql.push("AND is_choose = :is_choose");
}
return this.customQuery(sql.join(" "), params);
}
async findListByPid(pid) {
let sql = `SELECT * FROM ${this.tableName} WHERE pid = :pid ORDER BY sort ASC`;
return await this.customQuery(sql, {pid: pid});
}
async findMapByPid(pid) {
let result = {};
let list = await this.findListByPid(pid);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return item.id;
}
/**
* 条件查询所有符合条件的产品
* @param {*} params
*/
async listByIds(ids){
if(!ids || ids.length == 0) {
return [];
}
let sql = [];
sql.push(`SELECT * FROM ${this.tableName} WHERE id in (:productIdList)`);
return await this.customQuery(sql.join(" "), {productIdList: ids});
}
async mapByIds(params) {
let list = await this.listByIds(params);
var result = {};
for(let item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = IproductDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class IproductprocessDao extends Dao {
constructor() {
super(Dao.getModelName(IproductprocessDao));
}
/**
* 根据 productId 和 status 查询 商品
* @param {*} productId
* @param {*} status
*/
async findByProductIdAndStatus(productId, status) {
try {
let _productProcess = await this.model.findOne({
where: {
productId: productId,
status: status
}
});
return _productProcess || {};
} catch (error) {
console.log(`系统错误 错误信息 ${error}`);
return {};
}
}
async findMapByProductProductIds(productPid, productIds) {
let result = {};
let sql = [];
sql.push("SELECT");
sql.push("*");
sql.push("FROM");
sql.push(this.model.tableName)
sql.push("WHERE product_pid = :productPid");
if (productIds && productIds.length > 0) {
sql.push("AND product_id IN (:productIds)");
}
sql.push("ORDER BY sort ASC");
let list = await this.customQuery(sql.join(" "), {productPid: productPid, productIds: productIds});
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
let productId = item.product_id;
let items = result[productId];
if (!items) {
items = [];
}
items.push(item);
result[productId] = items;
}
return result;
}
}
module.exports = IproductprocessDao;
\ No newline at end of file
'use strict'
/**
* 流程表
*/
module.exports = function (db, DataTypes) {
return db.define('iinvoiceinforeg', {
invoice_id: { type: DataTypes.STRING, allowNull: true, comment: '订单号'},
deliver_id: { type: DataTypes.STRING, allowNull: true, comment: '交付商id'},
deliver_name: { type: DataTypes.STRING, allowNull: true, comment: '交付商名称'},
deliver_divide: { type: DataTypes.BIGINT, allowNull: true, comment: '订单分成'},
deliver_mail_addr: { type: DataTypes.STRING, allowNull: true, comment: '交付地址'},
deliver_mail_to: { type: DataTypes.STRING, allowNull: true, comment: '收件人'},
deliver_mail_mobile: { type: DataTypes.STRING, allowNull: true, comment: '联系电话'},
audit_content: { type: DataTypes.STRING, allowNull: true, comment: '交付审核内容'},
deliver_content: { type: DataTypes.STRING, allowNull: true, comment: '交付内容'},
deliver_mail_no: { type: DataTypes.STRING, allowNull: true, comment: '交付商交付快递单号'},
deliver_img: { type: DataTypes.STRING, allowNull: true, comment: '交接单'},
operator_id: { type: DataTypes.INTEGER, allowNull: true, comment: '交付商业务员id'},
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_invoice_info_reg',
comment: '发票平台交付详情',
});
}
\ No newline at end of file
'use strict'
/**
* 流程表
*/
module.exports = function (db, DataTypes) {
return db.define('iinvoiceprocess', {
product_id: { type: DataTypes.BIGINT, field: 'product_id', allowNull: true, comment: '一级产品id' },
invoice_id: { type: DataTypes.BIGINT, field: 'invoice_id', allowNull: true, comment: '发票id' },
name: { type: DataTypes.STRING, field: 'name', allowNull: false, defaultValue: "", comment: '产品名称' },
status: { type: DataTypes.STRING, field: 'status', allowNull: true, comment: '状态' },
func: { type: DataTypes.STRING, field: 'func', allowNull: false, comment: '状态执行方法名称' },
next_status: { type: DataTypes.STRING, field: 'next_status', allowNull: true, comment: '下一个状态' },
name1: { type: DataTypes.STRING, field: 'name1', allowNull: true, comment: '状态1' },
name2: { type: DataTypes.STRING, field: 'name2', allowNull: true, comment: '状态2' },
name3: { type: DataTypes.STRING, field: 'name3', allowNull: true, comment: '状态3' },
name4: { type: DataTypes.STRING, field: 'name4', allowNull: true, comment: '状态4' },
sort: { type: DataTypes.BIGINT, field: 'sort', allowNull: false, defaultValue: 1000, comment: '排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_product_process',
comment: '发票产品流程表',
});
}
\ No newline at end of file
'use strict'
/**
* 流程表
*/
module.exports = function (db, DataTypes) {
return db.define('iinvoicesummaryinfo', {
invoice_id : { type: DataTypes.STRING, allowNull: true, comment: '发票id'},
invoice_type : { type: DataTypes.STRING, allowNull: true, comment: '发票类型'},
summary_content : { type: DataTypes.STRING, allowNull: true, comment: '摘要内容'},
specification : { type: DataTypes.STRING, allowNull: true, comment: '规格型号'},
unit : { type: DataTypes.STRING, allowNull: true, comment: '单位'},
number : { type: DataTypes.INTEGER, allowNull: true, comment: '数量'},
unit_price : { type: DataTypes.INTEGER, allowNull: true, comment: '单价'},
amount : { type: DataTypes.INTEGER, allowNull: true, comment: '金额'},
tax_rate : { type: DataTypes.INTEGER, allowNull: true, comment: '税率'},
tax_amount : { type: DataTypes.INTEGER, allowNull: true, comment: '税额'},
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_invoice_summary_info',
comment: '发票平台交付详情',
});
}
\ No newline at end of file
'use strict'
/**
* 流程表
*/
module.exports = function (db, DataTypes) {
return db.define('iprocess', {
name: { type: DataTypes.STRING, field: 'name', allowNull: false, defaultValue: '', comment: '流程名称' },
status: { type: DataTypes.STRING, field: 'status', allowNull: false, defaultValue: '', comment: '流程状态' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true }
},
{
timestamps: true,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_process',
comment: '发票产品流程表',
});
}
/**
* 产品表
*/
'use strict'
module.exports = function (db, DataTypes) {
return db.define('iproduct', {
name: { type: DataTypes.STRING, field: 'name', allowNull: true, comment: '产品名称' },
desc: { type: DataTypes.STRING, field: 'desc', allowNull: false, defaultValue: "", comment: '产品描述' },
pid: { type: DataTypes.BIGINT, field: 'pid', allowNull: true, comment: '父ID' },
is_choose: { type: DataTypes.BOOLEAN, field: 'is_choose', allowNull: false, defaultValue: false, comment: '是否选择' },
sort: { type: DataTypes.INTEGER, field: 'sort', allowNull: false, defaultValue: 1000, comment: '排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: false,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_product',
comment: '发票产品表',
});
}
/**
* 状态表
*/
'use strict'
module.exports = function (db, DataTypes) {
return db.define('iproductprocess', {
product_pid: { type: DataTypes.STRING, field: 'product_pid', allowNull: true, comment: '一级产品id' },
product_id: { type: DataTypes.STRING, field: 'product_id', allowNull: true, comment: '产品ID' },
process_id: { type: DataTypes.STRING, field: 'process_id', allowNull: true, comment: '产品ID' },
func: { type: DataTypes.STRING, field: 'func', allowNull: false, comment: '状态执行方法名称' },
next_status: { type: DataTypes.STRING, field: 'next_status', allowNull: true, comment: '下一个状态' },
name1: { type: DataTypes.STRING, field: 'name1', allowNull: true, comment: '状态1' },
name2: { type: DataTypes.STRING, field: 'name2', allowNull: true, comment: '状态2' },
name3: { type: DataTypes.STRING, field: 'name3', allowNull: true, comment: '状态3' },
name4: { type: DataTypes.STRING, field: 'name4', allowNull: true, comment: '状态4' },
sort: { type: DataTypes.INTEGER, field: 'sort', allowNull: false, defaultValue: 1, comment: '排序' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, field: 'deleted_at', allowNull: true },
},
{
timestamps: true,
underscore: true,
paranoid: true,
version: true,
tableName: 'i_product_process',
comment: '发票产品流程表',
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IInvoiceinforegService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(IInvoiceprocessService));
}
}
module.exports = IInvoiceprocessService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IInvoiceprocessService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(IInvoiceprocessService));
}
}
module.exports = IInvoiceprocessService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IInvoicesummaryinfoService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(IInvoicesummaryinfoService));
}
}
module.exports = IInvoicesummaryinfoService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IprocessService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(IprocessService));
}
async allNames() {
let all = await this.dao.getAll("status, name");
return system.getResultSuccess(all);
}
}
module.exports = IprocessService
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IproductService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(IproductService));
this.iproductprocessDao = system.getObject("db.product.iproductprocessDao");
}
async productDics(params) {
let list = await this.dao.dics(params);
return system.getResultSuccess(list);
}
}
module.exports = IproductService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
class IproductprocessService extends ServiceBase {
constructor() {
super("product", ServiceBase.getDaoName(IproductprocessService));
}
}
module.exports = IproductprocessService;
\ 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