Commit 8b2ba20a by 宋毅

tj

parent 70a39091
......@@ -22,14 +22,11 @@ class OpProductAPI extends APIBase {
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getCAProductListByTypeCode"://通过产品类别编码获取产品列表
opResult = await this.productSve.findByTypeCode(pobj.actionBody, pobj.appInfo);
case "getProductList"://通过产品类别编码获取产品列表
opResult = await this.productSve.getProductList(pobj.actionBody, pobj.appInfo);
break;
case "getCAProductListByTypeOneCode"://通过产品大类编码获取产品列表
opResult = await this.productSve.findByTypeOneCode(pobj.actionBody, pobj.appInfo);
break;
case "getCAProductDetail"://获取产品详情
opResult = await this.productSve.getProductDetailByCode(pobj.actionBody.channelItemCode, pobj.appInfo.uapp_id);
case "getProductDetail"://获取产品详情
opResult = await this.productSve.getProductDetail(pobj.actionBody, pobj.appInfo);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......
......@@ -4,5 +4,28 @@ class ProductDao extends Dao {
constructor() {
super(Dao.getModelName(ProductDao));
}
async getItemByChannelItemCode(channelItemCode, uapp_id) {
return this.model.findOne({
where: {
uapp_id: uapp_id,
channel_item_code: channelItemCode
},
attributes: [
"id",
"uapp_id",
"path_code",
"path_name",
"item_code",
"item_name",
"channel_item_code",
"channel_item_name",
"pic_url",
"product_desc",
"desc_url",
"icon_url",
"productType_id"],
raw: true
});
}
}
module.exports = ProductDao;
......@@ -3,6 +3,7 @@ const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("producttype", {
uapp_id: DataTypes.INTEGER, //应用id
p_id: DataTypes.INTEGER, //父id
type_code: DataTypes.STRING(64),
type_name: DataTypes.STRING(64),
......
......@@ -8,49 +8,35 @@ class ProductService extends ServiceBase {
this.productpriceDao = system.getObject("db.dbproduct.productpriceDao");
}
/**
* 获取产品详情
* @param {*} channelItemCode 渠道产品码
* @param {*} uappid 渠道id
* 通过产品类别编码路径获取产品列表
* @param {*} actionBody pathCode 为类别编码路径,一级类下产品列表 sbfu,二级类下产品列表sbfu/sbzc
* @param {*} appInfo 应用信息
*/
async getProductDetailByCode(channelItemCode, uappid) {
var sql = "select * from v_product where uapp_id=" + uappid + " and channel_item_code='" + channelItemCode + "'";
var tmpResult = await this.customQuery(sql);
if (tmpResult && tmpResult.length > 0) {
for (var i = 0; i < tmpResult.length; i++) {
var pro = tmpResult[i];
if (pro.id) {
var ppList = await this.productpriceDao.model.findAll({
where: { product_id: pro.id },
attributes: ["price", "supply_price", "service_charge", "public_expense", "is_default", "price_type", "price_type_name",
async getProductList(actionBody, appInfo) {
var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and path_code like '" + actionBody.pathCode + "%'";
var list = await this.customQuery(sql);
return system.getResultSuccess(list);
}
/**
* 通过渠道产品编码获取产品详情
* @param {*} actionBody channelItemCode 渠道产品编码
* @param {*} appInfo 应用信息
*/
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");
}
var pList = await this.productpriceDao.model.findAll({
where: { product_id: item.id },
attributes: ["id", "price", "supply_price", "service_charge", "public_expense", "is_default", "price_type", "price_type_name",
"sort", "price_desc", "min_qty", "max_qty"
],
raw: true
});
pro.productPriceList = ppList;
}
}
}
return system.getResultSuccess(tmpResult);
item.price_list = pList;
return system.getResultSuccess(item);
}
/**
* 通过产品类别编码获取产品列表
* @param {*} actionBody
*/
async findByTypeCode(actionBody, appInfo) {
var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and type_code='" + actionBody.typeCode + "'";
var tmpResult = await this.customQuery(sql);
return system.getResultSuccess(tmpResult);
}
/**
* 通过产品大类编码获取产品列表
* @param {*} actionBody
*/
async findByTypeOneCode(actionBody, appInfo) {
var sql = "select * from v_product where uapp_id=" + appInfo.uapp_id + " and p_type_code='" + actionBody.typeOneCode + "'";
var tmpResult = await this.customQuery(sql);
return system.getResultSuccess(tmpResult);
}
}
module.exports = ProductService;
......@@ -7,11 +7,11 @@ var settings={
},
database:{
dbname : "center_app",
user: "write",
password: "write",
user: "root",
password: "root",
config: {
host: '43.247.184.35',
port: 8899,
host: '121.36.3.35',
port: 3306,
dialect: 'mysql',
operatorsAliases: false,
pool: {
......
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