Commit 251ca961 by 庄冰

prodect

parent a92a43d6
...@@ -14,6 +14,7 @@ class TmOrderAPI extends APIBase { ...@@ -14,6 +14,7 @@ class TmOrderAPI extends APIBase {
this.pushFqbossDataUrl = settings.pushFqbossDataUrl(); this.pushFqbossDataUrl = settings.pushFqbossDataUrl();
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
this.toolSve = system.getObject("service.trademark.toolSve"); this.toolSve = system.getObject("service.trademark.toolSve");
this.appProductSve = system.getObject("service.dbapp.appproductSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -174,6 +175,15 @@ class TmOrderAPI extends APIBase { ...@@ -174,6 +175,15 @@ class TmOrderAPI extends APIBase {
case "pushFqBusiness"://推送商机到峰擎 case "pushFqBusiness"://推送商机到峰擎
opResult = await this.orderSve.pushFqBusiness(action_body, pobj, req); opResult = await this.orderSve.pushFqBusiness(action_body, pobj, req);
break; break;
case "getProductDetail"://根据渠道产品码获取产品详情
opResult = await this.appProductSve.findByChannelItemCode(action_body);
break;
case "getProductListByTypeOneCode"://获取产品列表(根据产品一类编码获取)
opResult = await this.appProductSve.findByProductOneTypeCode(action_body);
break;
case "getProductListByTypeCode"://获取产品列表(根据父类产品编码获取)
opResult = await this.appProductSve.findByProductTypeCode(action_body);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -6,5 +6,90 @@ class AppProductService extends ServiceBase { ...@@ -6,5 +6,90 @@ class AppProductService extends ServiceBase {
constructor() { constructor() {
super("dbapp", ServiceBase.getDaoName(AppProductService)); super("dbapp", ServiceBase.getDaoName(AppProductService));
} }
//根据渠道产品码获取产品详情
async findByChannelItemCode(obj){
var user = obj.user;
var app = obj.app;
if(!user){
return system.getResultFail(-101, "未知用户");
}
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var channelItemCode = obj.channelItemCode;
if(!channelItemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var product = await this.dao.model.findOne({
where:{channelItemCode:channelItemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
if(!product){
return system.getResultFail(-104, "未知产品");
}
return system.getResultSuccess(product);
}
//获取产品列表(根据父类产品编码获取)
async findByProductTypeCode(obj){
var user = obj.user;
var app = obj.app;
if(!user){
return system.getResultFail(-101, "未知用户");
}
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productType_id:pProduct.id,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
return system.getResultSuccess(pList);
}
//获取产品列表(根据产品一类编码获取)
async findByProductOneTypeCode(obj){
var user = obj.user;
var app = obj.app;
if(!user){
return system.getResultFail(-101, "未知用户");
}
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productOneType_id:pProduct.id,productType_id:{ [this.db.Op.ne]: 0 },app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
return system.getResultSuccess(pList);
}
} }
module.exports = AppProductService; module.exports = AppProductService;
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