Commit e52c8cf9 by 孙亚楠

d

parent 98bc5fee
......@@ -41,6 +41,9 @@ class ActionAPI extends APIBase {
case "auditEorder":// 审核订单
opResult = await this.eorderSve.auditEorder(action_body);
break;
case "updEorderStatus":// 更改订单状态
opResult = await this.eorderSve.updEorderStatus(action_body);
break;
case "getEorderById":// 查看订单
opResult = await this.eorderSve.getEorderById(action_body);
break;
......@@ -50,6 +53,9 @@ class ActionAPI extends APIBase {
case "listEorderProduct":// 查看订单列表
opResult = await this.eorderproductSve.listEorderProduct(action_body);
break;
case "listEorderProductByMerchantId":// 查看当前商户下所有的订单相关的产品(没有分页)
opResult = await this.eorderproductSve.listEorderProductByMerchantId(action_body);
break;
case "saveEorderAuthLog":// 保存身份认证日志
opResult = await this.eorderauthlogSve.saveEorderAuthLog(action_body);
break;
......
......@@ -6,7 +6,10 @@ class EorderSve extends ServiceBase {
super("eorder", ServiceBase.getDaoName(EorderSve));
this.eorderproductDao = system.getObject("db.eorder.eorderproductDao");
this.GROUP_PRODUCT_TYPE = "2";
this.AUDIT_STATUS=['10','20','30']
this.SIGNLE_PRODUCT_TYPE = "1";
this.AUDIT_STATUS=['10','20','30'];
this.PAY_STATUS=['10','20','30'];
this.PRODUCT_TYPE_ARRAY=['1','2'];
}
/**
......@@ -27,12 +30,16 @@ class EorderSve extends ServiceBase {
if(!params.product_id ){
return system.getResult(null, `参数错误 父产品ID列表不能为空`);
}
if(!params.product_type){
if(!params.product_type || !this.PRODUCT_TYPE_ARRAY.includes(this.trim(params.product_type))){
return system.getResult(null, `参数错误 未知的产品类型`);
}
if(params.product_type==this.GROUP_PRODUCT_TYPE && !params.product_unit_price){
if(params.product_type==this.SIGNLE_PRODUCT_TYPE && !params.product_unit_price){
return system.getResult(null, `参数错误 商品单价不能为空`);
}
//如果是组合产品 单价为-1
if(params.product_type==this.GROUP_PRODUCT_TYPE){
params.product_unit_price=-1;
}
if(!params.contract_url){
return system.getResult(null, `参数错误 业务合同不能为空`);
}
......@@ -142,10 +149,12 @@ class EorderSve extends ServiceBase {
let orderBean = await this.dao.getById(this.trim(params.id));
if(!orderBean){
return system.getResult(null, `订单不存在`);
return system.getResult(null, `订单${params.id}不存在`);
}
try{
await orderBean.dao.update({id:orderBean.id,audit_status:this.trim(params.audit_status),audit_remark:this.trim(params.audit_remark) || ""});
let orderProperties = {id:orderBean.id,audit_status:this.trim(params.audit_status),audit_remark:this.trim(params.audit_remark) || ""};
orderProperties.live_status = params.audit_status == '20' ? '20' : '30';
await orderBean.dao.update(orderProperties);
return system.getResultSuccess();
}catch (e) {
console.log(e);
......@@ -154,6 +163,46 @@ class EorderSve extends ServiceBase {
}
/**
* fn:更改订单状态
* @param params
* @returns {Promise<void>}
*/
async updEorderStatus(params){
if(!params.id){
return system.getResult(null, `参数错误 订单ID 不能为空`);
}
try{
let orderBean = await this.dao.model.findOne(this.trim(params.id));
if(!orderBean){
return system.getResult(null, `订单【${params.id}】不存在`);
}
//如果支付状态
if (params.pay_status && orderBean.pay_status == '10' && this.PAY_STATUS.includes(this.trim(params.pay_status))) {
orderBean.pay_status = this.trim(params.pay_status);
await orderBean.save();
return system.getResult(orderBean);
}
//如果更新的是订单审核的状态
if(params.audit_status && orderBean.pay_status=='20' && orderBean.audit_status=='10'){
orderBean.live_status = params.audit_status == '20' ? '20' : '30';
orderBean.audit_status = this.trim(params.audit_status);
await orderBean.save();
return system.getResult(orderBean);
}
//如果更新的是生效的状态
if(params.live_status && orderBean.pay_status=='20' && orderBean.audit_status=='20' && orderBean=='10'){
orderBean.live_status = this.trim(params.live_status);
await orderBean.save();
return system.getResult(orderBean);
}
return system.getResult(null, `更新状态异常`);
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
}
}
/**
* fn:根据ID查询订单信息
* @param params
* @returns {Promise<void>}
......
......@@ -25,6 +25,23 @@ class EorderproductSve extends ServiceBase {
}
}
/**
* fn:查看当前商户下所有的订单相关的产品(没有分页)
* @param params
* @returns {Promise<void>}
*/
async listEorderProductByMerchantId(params){
if(!params.merchant_id){
return system.getResult(null, `参数错误 商户ID 不能为空`);
}
let list = await this.dao.model.findAll({
where:{
merchant_id: this.trim(params.merchant)
},
attributes:['product_id']
});
return system.getResult(list);
}
}
module.exports = EorderproductSve;
\ 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