Commit 22235441 by 宋毅

tj

parent d5d373fc
......@@ -28,6 +28,9 @@ class OpProductAPI extends APIBase {
case "getProductDetail"://获取产品详情
opResult = await this.productSve.getProductDetail(pobj.actionBody, pobj.appInfo);
break;
case "getProductInterface"://获取产品接口信息
opResult = await this.productSve.getProductInterface(pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -13,6 +13,7 @@ class ProductDao extends Dao {
attributes: [
"id",
"uapp_id",
"is_enabled",
"path_code",
"path_name",
"item_code",
......
......@@ -4,5 +4,20 @@ class ProductInterfaceDao extends Dao {
constructor() {
super(Dao.getModelName(ProductInterfaceDao));
}
async getItemByProductId(productId) {
return this.model.findOne({
where: {
product_id: productId
},
attributes: [
"id",
"interface_url",
"interface_type",
"interface_type_name",
"params",
"desc"],
raw: true
});
}
}
module.exports = ProductInterfaceDao;
......@@ -23,10 +23,8 @@ module.exports = {
//定价类型
"price_type": { "mj": "每件", "mc": "每次" ,"mt":"每天","my":"每月","mn":"每年","qj":"区间"},
//请求类型
"req_type": { "bd": "本地", "yc": "远程" },
//接口类型
"interface_type": { "sjts": "商机推送", "ddcz": "订单操作" },
"interface_type": { "bd": "本地", "yc": "远程" },
//---------
"logLevel": { "debug": 0, "info": 1, "warn": 2, "error": 3, "fatal": 4 },
......
......@@ -4,17 +4,8 @@ const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("productinterface", {
product_id: DataTypes.INTEGER,
interface_url: DataTypes.STRING(255), //推送到服务商的产品编码
req_type: { //请求类型,bd本地,yc远程
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.req_type),
set: function (val) {
this.setDataValue("req_type", val);
this.setDataValue("req_type_name", uiconfig.config.pdict.req_type[val]);
},
},
req_type_name: DataTypes.STRING(255),
interface_type: { //接口类型sjts商机推送,ddcz订单操作
interface_url: DataTypes.STRING(255), //操作接口地址
interface_type: { //接口类型,bd本地,yc远程
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.interface_type),
set: function (val) {
......
......@@ -6,6 +6,7 @@ class ProductService extends ServiceBase {
constructor() {
super("dbproduct", ServiceBase.getDaoName(ProductService));
this.productpriceDao = system.getObject("db.dbproduct.productpriceDao");
this.productinterfaceDao = system.getObject("db.dbproduct.productinterfaceDao");
}
/**
* 通过产品类别编码路径获取产品列表
......@@ -25,7 +26,10 @@ class ProductService extends ServiceBase {
async getProductDetail(actionBody, appInfo) {
var item = await this.dao.getItemByChannelItemCode(actionBody.channelItemCode, appInfo.uapp_id);
if (!item) {
return system.getResult(null, "item is data empty");
return system.getResult(null, "product item is data empty !");
}
if (item.is_enabled != 1) {
return system.getResult(null, "product to item is Disable !");
}
var pList = await this.productpriceDao.model.findAll({
where: { product_id: item.id },
......@@ -34,9 +38,23 @@ class ProductService extends ServiceBase {
],
raw: true
});
if (!pList || pList.length == 0) {
return system.getResult(null, "product to price is data empty !");
}
item.price_list = pList;
return system.getResultSuccess(item);
}
/**
* 获取产品接口信息
* @param {*} actionBody productId产品id
*/
async getProductInterface(actionBody) {
var item = await this.productinterfaceDao.getItemByProductId(actionBody.productId);
if (!item) {
return system.getResult(null, "product to interface is data empty !");
}
return system.getResultSuccess(item);
}
}
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