Commit 12e518aa by linboxuan

Merge branch 'center-app' of http://gitlab.gongsibao.com/jiangyong/zhichan into center-app

parents 0f1ac400 a0f62b88
......@@ -53,7 +53,7 @@ class APIBase {
async doexec(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
if (["getTokenByHosts", "receiveCallBackNotify", "getAppInfo", "getPayInfo", "verifyAliPayReturnSign", "test"].indexOf(methodname) < 0) {
if (["getTokenByHosts", "receiveCallBackNotify", "getAppInfo", "getAppInfoByAppKey", "getPayInfo", "verifyAliPayReturnSign", "test"].indexOf(methodname) < 0) {
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
......
......@@ -50,6 +50,9 @@ class OpProductAPI extends APIBase {
case "getMinPrice"://最低价
opResult = await this.productSve.getMinPrice(pobj);
break;
case "getProductRecommend":
opResult = await this.productSve.getProductRecommend(pobj.actionBody,pobj.appInfo);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -50,5 +50,9 @@ class PaymentAPI extends APIBase {
async getAppInfo(pobj, qobj, req) {
return await this.utilstlbankSve.getAppItem(pobj.uappId);
}
async getAppInfoByAppKey(pobj,qobj,req){
return await this.utilstlbankSve.getAppItemByAppkey(pobj.appKey)
}
}
module.exports = PaymentAPI;
\ No newline at end of file
......@@ -29,5 +29,13 @@ class AppDao extends Dao {
raw: true
});
}
async getItemByAppKey(appKey) {
return this.model.findOne({
where: {
uapp_key: appKey
},
raw: true
});
}
}
module.exports = AppDao;
......@@ -14,6 +14,9 @@ class ProductService extends ServiceBase {
*/
async getProductList(actionBody, appInfo) {
var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and path_code like '" + actionBody.pathCode + "%'";
if(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);
return system.getResultSuccess(list);
}
......@@ -208,5 +211,48 @@ class ProductService extends ServiceBase {
}
return system.getResultSuccess(data);
}
/**
* 获取推荐产品列表
* @param pobj
* @returns {Promise<void>}
*/
async getProductRecommend(actionBody,appInfo){
const type = actionBody.type;
let sql=``;
let paramsWhere ={};
if(type ==1 ){
sql = `select DISTINCT(recommend_code) from p_company_recommend where company_name = :companyName`;
paramsWhere['companyName'] = actionBody.companyName;
}
if(type ==2 ){
sql = `select DISTINCT(recommend_code) from p_company_recommend where company_name = :companyName and product_code = :productCode`;
paramsWhere['companyName'] = actionBody.companyName;
paramsWhere['productCode'] = actionBody.productCode;
}
if(type ==3 ){
sql = `select DISTINCT(recommend_code) from p_product_recommend where product_code = :productCode`;
paramsWhere['productCode'] = actionBody.productCode;
}
let result = await this.customQuery(sql,paramsWhere);
if(result.length==0){
return system.getResultFail(-1,'暂无配置数据')
}
let codes = [];
result.forEach(item =>{
if(item.recommend_code){
codes.push(item.recommend_code)
}
})
paramsWhere ={};
let productSql = `select * from v_product where channel_item_code in (:codes) and uapp_id = :uapp_id`
paramsWhere['uapp_id'] = appInfo.uapp_id;
let rtn={};
if(codes.length>0){
paramsWhere['codes'] = codes;
rtn = await this.customQuery(productSql,paramsWhere);
}
return system.getResult(rtn);
}
}
module.exports = ProductService;
......@@ -31,6 +31,14 @@ class utilsTlBankSve extends AppServiceBase {
}
return system.getResultSuccess(item);
}
async getAppItemByAppkey(uappId) {//根据appKey获取应用信息
var item = await this.appDao.getItemByAppKey(uappId);
if (!item) {
return system.getResult(null, "应用数据为空");
}
return system.getResultSuccess(item);
}
//-------------------------------------------h5支付-----------------开始
/**
......
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