Commit 32765cbf by linboxuan

lin add productType

parent 5040f82b
......@@ -36,10 +36,10 @@ class ProductAPI extends WEBBase {
opResult = await this.utilsProductSve.getProductDetail(pobj, pobj.actionBody);
break;
case "getProductPrice":
opResult = await this.utilsProductSve.getProductPrice(pobj,pobj.actionBody)
opResult = await this.utilsProductSve.getProductPrice(pobj, pobj.actionBody)
break;
case "getProductRecommend":
opResult = await this.utilsProductSve.getProductRecommend(pobj,pobj.actionBody);
opResult = await this.utilsProductSve.getProductRecommend(pobj, pobj.actionBody);
break;
// case "updateProductPrice":
// opResult = await this.utilsProductSve.updateProductPrice(pobj,pobj.actionBody);
......@@ -48,11 +48,20 @@ class ProductAPI extends WEBBase {
opResult = await this.utils360Sve.getGoodsLowestPrice(pobj.actionBody);
break;
case "getRegProducePrice":
opResult = await this.utilsProductSve.getRegProducePrice(pobj,pobj.actionBody)
opResult = await this.utilsProductSve.getRegProducePrice(pobj, pobj.actionBody)
break;
case "getAllProducts":
opResult = await this.utilsProductSve.getAllProducts(pobj);
break;
case "getAllProductType":// 获取产品大类
opResult = await this.utilsProductSve.getAllProductType(pobj);
break;
case "submitProductType":// 创建产品大类
opResult = await this.utilsProductSve.submitProductType(pobj);
break;
case "editProductType":// 修改产品大类
opResult = await this.utilsProductSve.editProductType(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
}
......
......@@ -121,7 +121,7 @@ class AccessAuthAPI extends WEBBase {
case "submitService"://创建渠道(app)
opResult = await this.utilsAuthSve.submitService(pobj);
break;
case "editService"://创建渠道(app)
case "editService"://修改渠道(app)
opResult = await this.utilsAuthSve.editService(pobj);
break;
default:
......
......@@ -314,7 +314,7 @@ class UtilsAuthService extends AppServiceBase {
}
/**
* 创建渠道(信息更全一些)
* 创建渠道
* @returns {Promise<void>}
*/
async submitService(pobj) {
......@@ -324,7 +324,7 @@ class UtilsAuthService extends AppServiceBase {
}
/**
* 修改渠道(信息更全一些)
* 修改渠道
* @returns {Promise<void>}
*/
async editService(pobj) {
......
......@@ -19,7 +19,7 @@ class UtilsProductService extends AppServiceBase {
if (!actionBody.pathCode) {
return system.getResult(null, "actionBody.pathCode can not be empty,100330");
}
if(actionBody.name){
if (actionBody.name) {
pobj.actionBody.productName = actionBody.name;
}
pobj.actionBody.pathCode = "/" + actionBody.pathCode + "/";
......@@ -41,15 +41,15 @@ class UtilsProductService extends AppServiceBase {
pobj.actionBody.pathCode = "/" + actionBody.pathCode + "/";
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
let list = await this.restPostUrl(pobj, url);
if(!list.data){
return system.getResult(null,'product data is empty')
if (!list.data) {
return system.getResult(null, 'product data is empty')
}
for(let item of list.data){
for (let item of list.data) {
pobj.actionType = 'getMinPrice';
pobj.actionBody = {
product_id:item.product_id
product_id: item.product_id
}
let re = await this.restPostUrl(pobj,url);
let re = await this.restPostUrl(pobj, url);
item.price = re.data ? re.data.price : 0;
}
return list;
......@@ -75,7 +75,7 @@ class UtilsProductService extends AppServiceBase {
* @param actionBody
* @returns {Promise<{msg: *, data, bizmsg: *|string, status: number}>}
*/
async getProductPrice(pobj,actionBody){
async getProductPrice(pobj, actionBody) {
pobj.actionType = 'getProductPrice'
let url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
......@@ -87,7 +87,7 @@ class UtilsProductService extends AppServiceBase {
* @param actionBody
* @returns {Promise<{msg: *, data, bizmsg: *|string, status: number}>}
*/
async getRegProducePrice(pobj,actionBody){
async getRegProducePrice(pobj, actionBody) {
pobj.actionType = 'getRegProducePrice'
let url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
......@@ -98,35 +98,35 @@ class UtilsProductService extends AppServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async getProductRecommend(pobj,actionBody){
async getProductRecommend(pobj, actionBody) {
const type = actionBody.type;
if(!type){
return system.getResult(-1,'type can be not empty')
if (!type) {
return system.getResult(-1, 'type can be not empty')
}
switch (type) {
case 1:
if(!actionBody.companyName){
return system.getResultFail(-1,'companyName can be not empty')
if (!actionBody.companyName) {
return system.getResultFail(-1, 'companyName can be not empty')
}
break;
case 2:
if(!actionBody.companyName){
return system.getResultFail(-1,'companyName can be not empty')
if (!actionBody.companyName) {
return system.getResultFail(-1, 'companyName can be not empty')
}
if(!actionBody.productCode){
return system.getResultFail(-1,'productCode can be not empty')
if (!actionBody.productCode) {
return system.getResultFail(-1, 'productCode can be not empty')
}
break;
case 3:
if(!actionBody.productCode){
return system.getResultFail(-1,'productCode can be not empty')
if (!actionBody.productCode) {
return system.getResultFail(-1, 'productCode can be not empty')
}
break;
default:
return system.getResultFail(-1,'type 参数错误');
return system.getResultFail(-1, 'type 参数错误');
}
let url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj,url);
return await this.restPostUrl(pobj, url);
}
/**
......@@ -135,22 +135,55 @@ class UtilsProductService extends AppServiceBase {
* @param actionBody
* @returns {Promise<void>}
*/
async updateProductPrice(pobj,actionBody){
if(!actionBody.data || actionBody.data.length == 0){
return system.getResultFail(-1,'data is empty!');
async updateProductPrice(pobj, actionBody) {
if (!actionBody.data || actionBody.data.length == 0) {
return system.getResultFail(-1, 'data is empty!');
}
let url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj,url);
return await this.restPostUrl(pobj, url);
}
/**
* 获取全部产品
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async getAllProducts(pobj){
async getAllProducts(pobj) {
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'getAllProducts'
let result = await this.restPostUrl(pobj,url);
let result = await this.restPostUrl(pobj, url);
return result;
}
/**
* 获取全部产品大类
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async getAllProductType(pobj) {
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'getAllProductType'
let result = await this.restPostUrl(pobj, url);
return result;
}
/**
* 创建产品大类
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async submitProductType(pobj) {
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'submitProductType'
let result = await this.restPostUrl(pobj, url);
return result;
}
/**
* 修改产品大类
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async editProductType(pobj) {
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'editProductType'
let result = await this.restPostUrl(pobj, url);
return result;
}
......@@ -159,32 +192,32 @@ class UtilsProductService extends AppServiceBase {
* @param pobj
* @returns {Promise<{msg: string, data, bizmsg: *|string, status: number}|any>}
*/
async getAllPathName(pobj){
async getAllPathName(pobj) {
let url = settings.centerAppUrl() + 'action/opProduct/springBoard';
pobj.actionType = 'getAllPathName';
let result = await this.restPostUrl(pobj,url);
if(result.status !=0){
return system.getResultFail(-1,'获取数据失败,请稍后再试!');
let result = await this.restPostUrl(pobj, url);
if (result.status != 0) {
return system.getResultFail(-1, '获取数据失败,请稍后再试!');
}
let data = result.data;
let map = new Map();
for(let i =0;i<data.length;i++){
for (let i = 0; i < data.length; i++) {
let item = data[i];
let strs = item.path_name.split('/');
let classOne = strs[1];
let classTwo = strs[2];
if(map.has(classOne)){
if (map.has(classOne)) {
let val = map.get(classOne);
val.push(classTwo)
map.set(classOne,val);
}else{
map.set(classOne, val);
} else {
let arr = [];
arr.push(classTwo)
map.set(classOne,arr);
map.set(classOne, arr);
}
}
let resultData = [];
map.forEach((v,k) =>{
map.forEach((v, k) => {
let obj = {};
obj['key'] = k;
obj['data'] = v;
......
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