Commit ba36942f by 任晓松

产品推荐

parent f28a9afe
...@@ -50,6 +50,9 @@ class OpProductAPI extends APIBase { ...@@ -50,6 +50,9 @@ class OpProductAPI extends APIBase {
case "getMinPrice"://最低价 case "getMinPrice"://最低价
opResult = await this.productSve.getMinPrice(pobj); opResult = await this.productSve.getMinPrice(pobj);
break; break;
case "getProductRecommend":
opResult = await this.productSve.getProductRecommend(pobj.actionBody,pobj.appInfo);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -15,7 +15,7 @@ class ProductService extends ServiceBase { ...@@ -15,7 +15,7 @@ class ProductService extends ServiceBase {
async getProductList(actionBody, appInfo) { async getProductList(actionBody, appInfo) {
var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and path_code like '" + actionBody.pathCode + "%'"; var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and path_code like '" + actionBody.pathCode + "%'";
if(actionBody.productName){ if(actionBody.productName){
sql += " and item_name like '%"+ actionBody.productName+"%'" sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and item_name like '" + actionBody.productName + "%'";
} }
var list = await this.customQuery(sql); var list = await this.customQuery(sql);
return system.getResultSuccess(list); return system.getResultSuccess(list);
...@@ -202,5 +202,34 @@ class ProductService extends ServiceBase { ...@@ -202,5 +202,34 @@ class ProductService extends ServiceBase {
} }
return system.getResultSuccess(data); return system.getResultSuccess(data);
} }
/**
* 获取推荐产品列表
* @param pobj
* @returns {Promise<void>}
*/
async getProductRecommend(actionBody,appInfo){
const type = actionBody.type;
let sql=``;
let result = ''
if(type ==1 ){
sql = `select DISTINCT(recommend_code) from p_company_recommend where company_name = '${actionBody.companyName}'`;
}
if(type ==2 ){
sql = `select DISTINCT(recommend_code) from p_company_recommend where company_name = '${actionBody.companyName}' and product_code = '${actionBody.productCode}'`;
}
if(type ==3 ){
sql = `select DISTINCT(recommend_code) from p_product_recommend where product_code = '${actionBody.productCode}'`;
}
result = await this.customQuery(sql);
let codes = "";
result.forEach(item =>{
codes += "'"+item.recommend_code+"',";
})
codes = codes.substring(0,codes.length-1);
let productSql = `select * from v_product where channel_item_code in (${codes}) and uapp_id = ${appInfo.uapp_id}`
let rtn = await this.customQuery(productSql);
return system.getResult(rtn);
}
} }
module.exports = ProductService; module.exports = ProductService;
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