Commit bfd813e2 by 王昆

gsb

parent f460c0de
......@@ -5,6 +5,10 @@ class ActionAPI extends APIBase {
constructor() {
super();
this.iinvoiceSve = system.getObject("service.invoice.iinvoiceSve");
this.iproductSve = system.getObject("service.product.iproductSve");
this.iprocessSve = system.getObject("service.product.iprocessSve");
}
/**
* 接口跳转
......@@ -40,9 +44,8 @@ class ActionAPI extends APIBase {
case "productDics": // 查询产品字典
// opResult = await this.oproductSve.productDics(action_body);
break;
case "allProcess": // 查询业务进度
// opResult = await this.oprocessSve.allNames(action_body);
opResult = await this.iprocessSve.allNames(action_body);
break;
// case "verificationAndCalculation": // 发票试算接口
......
......@@ -10,9 +10,8 @@ class IInvoiceDao extends Dao {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) as total");
sql.push("FROM `invoice` t1");
sql.push("INNER JOIN `invoice_apply` t2 ON t1.`id` = t2.`id`");
sql.push("WHERE 1 = 1 and t2.status in('1070','1080','1090')");
sql.push("FROM `i_invoice` t1");
sql.push("WHERE 1 = 1 ");
this.setCondition(params, sql);
......@@ -27,8 +26,7 @@ class IInvoiceDao extends Dao {
var sql = [];
sql.push("SELECT");
sql.push("t1.*");
sql.push("FROM `invoice` t1");
sql.push("INNER JOIN `invoice_apply` t2 ON t1.`id` = t2.`id`");
sql.push("FROM `i_invoice` t1");
sql.push("WHERE 1 = 1 ");
this.setCondition(params, sql);
......@@ -41,116 +39,115 @@ class IInvoiceDao extends Dao {
}
setCondition(params, sql) {
var complateTax = params.complateTax;
if (complateTax != "-1") {
params.complateTax = Number(complateTax);
sql.push("AND t1.`complate_tax` = :complateTax");
}
// invoiceTimeBegin 2019-01-01 2019-01-01 00:00:00
// invoiceTimeEnd 2019-11-01 2019-11-01 23:59:59
if(params.invoiceTimeBegin) {
sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin");
}
if(params.invoiceTimeEnd) {
sql.push("AND t1.`invoice_time` <= :invoiceTimeEnd");
}
if(params.invoiceTime){
sql.push("AND t1.`invoice_time` >= :invoiceTime");
}
if(params.applyNo) {
sql.push("AND t2.`apply_no` = :applyNo");
if(params.apply_no) {
sql.push("AND t2.`apply_no` = :apply_no");
}
if(params.redStatus) {
sql.push("AND t1.`red_status` = :redStatus");
}
if (params.type) {
sql.push("AND t2.`type` = :type");
if(params.status) {
sql.push("AND t2.`status` = :status");
}
if(params.statuses && params.statuses.length > 0){
sql.push("AND t2.`status` in (:statuses)");
}
}
/**
* 红冲列表总计
* @param {*} params
*/
async countRedRushListByParams(params){
var sql = [];
sql.push(`select count(1) as count from invoice_apply a inner join invoice_deliverer b on a.deliverer_id =b.id
inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
if (params.delivererId) {
sql.push(` AND b.deliverer_id = :delivererId`);
if(params.invoice_type) {
sql.push("AND t2.`invoice_type` = :invoice_type");
}
if (params.applyNo) {
sql.push(` AND a.apply_no = :applyNo`);
}
if (params.invoiceNo) {
sql.push(` AND c.invoice_no = :invoiceNo`);
}
if (params.startTime) {
sql.push(`and a.invoice_time >= :startTime`);
}
if (params.endTime) {
sql.push(`and a.invoice_time <= :endTime`);
}
if(params.invoiceTime){
sql.push(`and a.invoice_time >= :invoiceTime`);
}
if (params.type) {
sql.push(`and a.type = :type`);
}
if (params.redStatus) {
sql.push(`and c.red_status = :redStatus`);
if(params.invoiceTimeBegin) {
sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin");
}
if (params.status) {
sql.push(`and c.status = :status`);
if(params.invoiceTimeEnd) {
sql.push("AND t1.`invoice_time` <= :invoiceTimeEnd");
}
return await this.customQuery(sql.join(" "), params);
}
/**
* 红冲列表
* @param {*} params
*/
async redRushListByParams(params){
var sql = [];
sql.push(`select a.apply_no,a.type,a.invoice_amount,a.invoice_time,c.status,
a.merchant_name,a.businessmen_name,a.id,b.deliverer_id from invoice_apply a
inner join invoice_deliverer b on a.deliverer_id =b.id
inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
if (params.delivererId) {
sql.push(` AND b.deliverer_id = :delivererId`);
}
if (params.applyNo) {
sql.push(` AND a.apply_no = :applyNo`);
if(params.red_status) {
sql.push("AND t1.`red_status` = :red_status");
}
if (params.startTime) {
sql.push(`and a.invoice_time >= :startTime`);
if(params.deliver_id) {
sql.push("AND t2.`deliver_id` = :deliver_id");
}
if (params.endTime) {
sql.push(`and a.invoice_time <= :endTime`);
if(params.bd_id) {
sql.push("AND t2.`bd_id` = :bd_id");
}
if(params.invoiceTime){
sql.push(`and a.invoice_time >= :invoiceTime`);
if(params.bd_path) {
params.bd_path_like = params.bd_path + "%";
sql.push("AND t2.`bd_path` = :bd_path_like");
}
if (params.type) {
sql.push(`and a.type = :type`);
}
if (params.redStatus) {
sql.push(`and c.red_status = :redStatus`);
}
sql.push("ORDER BY c.id DESC");
sql.push("LIMIT :statRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
}
// /**
// * 红冲列表总计
// * @param {*} params
// */
// async countRedRushListByParams(params){
// var sql = [];
// sql.push(`select count(1) as count from invoice_apply a inner join invoice_deliverer b on a.deliverer_id =b.id
// inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
// if (params.delivererId) {
// sql.push(` AND b.deliverer_id = :delivererId`);
// }
// if (params.applyNo) {
// sql.push(` AND a.apply_no = :applyNo`);
// }
// if (params.invoiceNo) {
// sql.push(` AND c.invoice_no = :invoiceNo`);
// }
// if (params.startTime) {
// sql.push(`and a.invoice_time >= :startTime`);
// }
// if (params.endTime) {
// sql.push(`and a.invoice_time <= :endTime`);
// }
// if(params.invoiceTime){
// sql.push(`and a.invoice_time >= :invoiceTime`);
// }
// if (params.type) {
// sql.push(`and a.type = :type`);
// }
// if (params.redStatus) {
// sql.push(`and c.red_status = :redStatus`);
// }
// if (params.status) {
// sql.push(`and c.status = :status`);
// }
// return await this.customQuery(sql.join(" "), params);
// }
// /**
// * 红冲列表
// * @param {*} params
// */
// async redRushListByParams(params){
// var sql = [];
// sql.push(`select a.apply_no,a.type,a.invoice_amount,a.invoice_time,c.status,
// a.merchant_name,a.businessmen_name,a.id,b.deliverer_id from invoice_apply a
// inner join invoice_deliverer b on a.deliverer_id =b.id
// inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
// if (params.delivererId) {
// sql.push(` AND b.deliverer_id = :delivererId`);
// }
// if (params.applyNo) {
// sql.push(` AND a.apply_no = :applyNo`);
// }
// if (params.startTime) {
// sql.push(`and a.invoice_time >= :startTime`);
// }
// if (params.endTime) {
// sql.push(`and a.invoice_time <= :endTime`);
// }
// if(params.invoiceTime){
// sql.push(`and a.invoice_time >= :invoiceTime`);
// }
// if (params.type) {
// sql.push(`and a.type = :type`);
// }
// if (params.redStatus) {
// sql.push(`and c.red_status = :redStatus`);
// }
// sql.push("ORDER BY c.id DESC");
// sql.push("LIMIT :statRow, :pageSize");
// return await this.customQuery(sql.join(" "), params);
// }
}
module.exports = IInvoiceDao;
\ No newline at end of file
......@@ -6,6 +6,21 @@ class IinvoicedeliverDao extends Dao {
this.tableName = this.model.tableName;
}
async findMapByIds(ids) {
var result = {};
var sql = `SELECT * FROM ${this.tableName} WHERE id IN (:ids)`;
var 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;
}
//交付商业务概览
async countStat(params) {
var sql = [];
......
......@@ -7,16 +7,16 @@ class IInvoiceprocessDao extends Dao {
this.tableName = this.model.tableName;
}
async delByOrderId(order_id) {
if (!order_id) {
async delByInvoiceId(invoice_id) {
if (!invoice_id) {
return;
}
let sql = `DELETE FROM ${this.tableName} WHERE order_id = :order_id`;
await this.customUpdate(sql, {order_id: order_id});
let sql = `DELETE FROM ${this.tableName} WHERE invoice_id = :invoice_id`;
await this.customUpdate(sql, {invoice_id: invoice_id});
}
async findByOrderIdAndStatus(orderId, status) {
if (!orderId || !status) {
async findByInvoiceIdAndStatus(invoiceId, status) {
if (!invoiceId || !status) {
return null;
}
let sql = [];
......@@ -24,19 +24,19 @@ class IInvoiceprocessDao extends Dao {
sql.push("*");
sql.push("FROM");
sql.push(this.tableName);
sql.push("WHERE order_id = :orderId");
sql.push("WHERE invoice_id = :invoiceId");
sql.push("AND `status` = :status");
let list = await this.customQuery(sql.join(" "), {orderId: orderId, status: status});
let list = await this.customQuery(sql.join(" "), {invoiceId: invoiceId, status: status});
if (!list || list.length == 0) {
return null;
}
return list[0];
}
async listByOrderIdsAndStatus(orderIds, statuses) {
async listByInvoiceIdsAndStatus(invoiceIds, statuses) {
var result = {};
if (!orderIds || orderIds.length == 0 || !statuses || statuses.length == 0) {
if (!invoiceIds || invoiceIds.length == 0 || !statuses || statuses.length == 0) {
return result;
}
let sql = [];
......@@ -44,21 +44,21 @@ class IInvoiceprocessDao extends Dao {
sql.push("*");
sql.push("FROM");
sql.push(this.tableName);
sql.push("WHERE order_id IN (:orderIds)");
sql.push("WHERE invoice_id IN (:invoiceIds)");
sql.push("AND `status` IN (:statuses)");
return await this.customQuery(sql.join(" "), {orderIds: orderIds, statuses: statuses});
return await this.customQuery(sql.join(" "), {invoiceIds: invoiceIds, statuses: statuses});
}
async mapByOrderIdsAndStatus(orderIds, statuses) {
async mapByInvoiceIdsAndStatus(invoiceIds, statuses) {
var result = {};
let list = await this.listByOrderIdsAndStatus(orderIds, statuses);
let list = await this.listByInvoiceIdsAndStatus(invoiceIds, statuses);
if (!list || list.length == 0) {
return result;
}
for (let item of list) {
result[item.order_id + "_" + item.status] = item;
result[item.invoice_id + "_" + item.status] = item;
}
return result;
}
......
......@@ -23,62 +23,10 @@ class IInvoiceService extends ServiceBase {
* 发票申请
* @param {*} params
*/
async invoiceApply(params){
async invoiceApply(params) {
}
//********************************************** 代码分隔 总统在上面写 *********************************************************** */
//**********************************************以下是旧版本************************************************************ */
/**
* 构建产品流程对象
* @param productPid
* @param chooseProductIds
* @returns {Promise<void>}
*/
async buildProcess(params) {
let productPid = params.productPid || 50010000;
// 查询产品流程
let productProcessList = await this.iproductprocessDao.byProductPid(productPid);
if (!productProcessList || productProcessList.length == 0) {
return [];
}
let invoiceProcessList = [];
// 批量查流程
let processMap = await this.iprocessDao.mapAll();
for (let productProcess of productProcessList) {
// 风还钻该处理每一个子项流程 变为 订单流程对象
let process = processMap[productProcess.process_id];
let nextArr = this.trim(productProcess.next_status).split(",");
let nextStatus = [];
for (let nextId of nextArr) {
nextId = Number(nextId || 0);
let nextObj = processMap[nextId];
if (!nextObj) {
continue;
}
nextStatus.push({ next_status: nextObj.status, next_name: nextObj.name });
}
let orderProcess = {
product_id: productPid,
name: process.name,
status: process.status,
func: productProcess.func,
next_status: JSON.stringify(nextStatus),
name1: productProcess.name1,
name2: productProcess.name2,
name3: productProcess.name3,
name4: productProcess.name4,
sort: productProcess.sort,
autoIncrement: true
};
invoiceProcessList.push(orderProcess);
}
return invoiceProcessList;
}
}
module.exports = IInvoiceService;
\ 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