Commit 021ae7d5 by 孙亚楠

d

parent 46fd01aa
......@@ -44,6 +44,9 @@ class ActionAPI extends APIBase {
case "updEorderStatus":// 更改订单状态
opResult = await this.eorderSve.updEorderStatus(action_body);
break;
case "updOrderSimple":// 更新订单(单表更新)
opResult = await this.eorderSve.updOrderSimple(action_body);
break;
case "getEorderById":// 查看订单
opResult = await this.eorderSve.getEorderById(action_body);
break;
......@@ -68,6 +71,9 @@ class ActionAPI extends APIBase {
case "pageEorderSignLog":// 签约日志列表
opResult = await this.eordersignlogSve.pageEorderSignLog(action_body);
break;
case "pageEorderContract":// 合同列表(分页)
opResult = await this.eordersignlogSve.pageEorderContract(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -82,5 +82,42 @@ 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');
}
}
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 `);
sql.push(`FROM e_order_sign_log t1 inner join e_order t2 on t2.order_id =t1.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;
......@@ -368,6 +368,39 @@ class EorderService extends ServiceBase {
}
}
}
/**
* fn:简单的单表更新
* @param params
* @returns {Promise<void>}
*/
async updOrderSimple(params){
if(!params.id){
return system.getResult(null, `参数错误 订单ID 不能为空`);
}
let orderBean = await this.dao.model.findOne({
where:{
id: this.trim(params.id)
}
});
if(!orderBean){
return system.getResult(null, `订单【${params.id}】不存在`);
}
if(params.trade_id){
orderBean.trade_id = this.trim(params.trade_id);
}
try{
await orderBean.save();
return system.getResultSuccess();
}catch (e) {
console.log(e);
return system.getResult(null,`系统错误`);
}
}
}
......
......@@ -81,6 +81,35 @@ class EordersignlogService 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.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'],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