Commit ee8a9911 by 孙亚楠

d

parent da56d68d
......@@ -72,7 +72,7 @@ class ActionAPI extends APIBase {
opResult = await this.eordersignlogSve.pageEorderSignLog(action_body);
break;
case "pageEorderContract":// 合同列表(分页)
opResult = await this.eordersignlogSve.pageEorderContract(action_body);
opResult = await this.eorderSve.pageEorderContract(action_body);
break;
case "getMerchantLiveProduct":// 查询商户下可用订单的产品
opResult = await this.eorderSve.getMerchantLiveProduct(action_body);
......
......@@ -31,8 +31,11 @@ class EorderDao extends Dao{
if(params.merchant_name){
sql.push('and merchant_name=:merchant_name');
}
if(params.sign_id){
sql.push('and sign_id=:sign_id');
if(params.contract_id){
sql.push('and contract_id=:contract_id');
}
if(params.contract_name){
sql.push('and contract_name=:contract_name');
}
if(params.product_id){
sql.push('and product_id=:product_id');
......@@ -129,5 +132,59 @@ class EorderDao extends Dao{
return await this.customQuery(sql.join(" "), {merchant_id: merchant_id});
}
/**
* fn: 合同列表(分页)
* @returns {Promise<void>}
*/
async countEorderContract(params){
}
/**
* 合同列表(分页)计数
* @param params
* @returns {Promise<*|*[]>}
*/
async countEorderContract(params){
let sql = [];
sql.push(`SELECT count(1) as count`);
sql.push(`FROM e_order WHERE 1 = 1 `)
this.setpageEorderContractParams(sql,params);
let list = await this.customQuery(sql.join(" "), params);
if(!list || list.length==0){
return {count:0};
}
return list[0];
}
setpageEorderContractParams(sql,params){
if(params.engine_contract_id){
sql.push('and t1.engine_contract_id=:engine_contract_id');
}
if(params.id){
sql.push('and id=:id');
}
if(params.product_id){
sql.push('and product_id=:product_id');
}
if(params.merchant_id){
sql.push('and merchant_id=:merchant_id');
}
if(params.contract_id){
sql.push('and contract_id=:contract_id');
}
}
async PageeorderContract(params){
let sql = [];
sql.push(`select id,contract_id,contract_url,contract_name,merchant_id,merchant_name,live_start,live_end,created_at`);
sql.push(`FROM e_order WHERE 1 = 1 `)
this.setpageEorderContractParams(sql,params);
sql.push("ORDER BY created_at DESC");
sql.push("LIMIT :startRow, :pageSize");
let list = await this.customQuery(sql.join(" "), params);
return list ||[];
}
}
module.exports=EorderDao;
......@@ -85,45 +85,7 @@ class EordersignlogDao extends Dao{
}
}
/**
* 合同列表(分页)计数
* @param params
* @returns {Promise<*|*[]>}
*/
async countEordersignlogContract(params){
let sql = [];
sql.push(`SELECT count(1) as count`);
sql.push(`FROM e_order_sign_log t1 inner join e_order t2 on t2.id =t1.order_id WHERE 1 = 1 `)
this.setpageEorderContractParams(sql,params);
let list = await this.customQuery(sql.join(" "), params);
if(!list || list.length==0){
return {count:0};
}
return list[0];
}
setpageEorderContractParams(sql,params){
if(params.engine_contract_id){
sql.push('and t1.engine_contract_id=:engine_contract_id');
}
if(params.order_id){
sql.push('and t1.order_id=:order_id');
}
if(params.product_id){
sql.push('and t1.product_id=:product_id');
}
}
async PageeordersignlogContract(params){
let sql = [];
sql.push(`SELECT t1.engine_contract_id,t1.engine_contract_name,t1.created_at,t2.live_start,t2.live_end,t2.merchant_name,t1.order_id,t2.contract_url `);
sql.push(`FROM e_order_sign_log t1 inner join e_order t2 on t2.id =t1.order_id WHERE 1 = 1 `)
this.setpageEorderContractParams(sql,params);
sql.push("ORDER BY t1.created_at DESC");
sql.push("LIMIT :startRow, :pageSize");
let list = await this.customQuery(sql.join(" "), params);
return list ||[];
}
}
module.exports=EordersignlogDao;
......@@ -470,6 +470,35 @@ class EorderService extends ServiceBase {
}
/**
* fn: 合同列表(分页)
* @param params
* @returns {Promise<void>}
*/
async pageEorderContract(params){
try{
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
let listContract = await this.dao.countEorderContract(params);
if(listContract.count==0){
return system.getResult({count: 0, rows: []});
}
let list =await this.dao.PageeorderContract(params);
if(!list || list.length==0){
return system.getResult({count: 0, rows: []});
}
for (let item of list) {
this.handleDate(item,['created_at','live_start','live_end'],null,null)
}
return system.getResult({count: listContract.count, rows: list});
}catch (e) {
console.log(e);
return system.getResult(`系统错误`);
}
}
}
module.exports = EorderService;
\ No newline at end of file
......@@ -80,36 +80,6 @@ class EordersignlogService extends ServiceBase {
return system.getResult(null, `系统错误`);
}
}
/**
* fn: 合同列表(分页)
* @param params
* @returns {Promise<void>}
*/
async pageEorderContract(params){
try{
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = (params.currentPage - 1) * params.pageSize;
let listContract = await this.dao.countEordersignlogContract(params);
if(listContract.count==0){
return system.getResult({count: 0, rows: []});
}
let list =await this.dao.PageeordersignlogContract(params);
if(!list || list.length==0){
return system.getResult({count: 0, rows: []});
}
for (let item of list) {
this.handleDate(item,['created_at','live_start','live_end'],null,null)
}
return system.getResult({count: listContract.count, rows: list});
}catch (e) {
console.log(e);
return system.getResult(`系统错误`);
}
}
}
module.exports = EordersignlogService;
\ 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