Commit 892b06ad by 兰国旗

laolan

parent d8252066
......@@ -25,5 +25,10 @@ class ProductTypeCtl extends CtlBase {
const res = await this.service.getProductTypeInfo(pobj);
return res;
}
async delete(pobj, qobj, req) {
const up = await this.service.delete(pobj);
return up;
}
}
module.exports = ProductTypeCtl;
......@@ -6,52 +6,54 @@ class BottommenuconfigService extends ServiceBase {
super("aggregation", ServiceBase.getDaoName(BottommenuconfigService));
}
async create(pobj) {
if (!pobj.button_name) {
return system.getResultFail(-101, "按钮文案不能为空");
}
if (!pobj.is_distinguishtime) {
return system.getResultFail(-102, "分时策略不能为空");
}
if (!pobj.strategy_date) {
return system.getResultFail(-103, "策略日期不能为空");
}
if (!pobj.strategy_time) {
return system.getResultFail(-104, "策略时段不能为空");
}
if (!pobj.button_type) {
return system.getResultFail(-105, "按钮形式不能为空");
}
if (!pobj.button_name) {
return system.getResultFail(-106, "按钮文案不能为空");
}
if (!pobj.button_name) {
return system.getResultFail(-101, "按钮文案不能为空");
}
if (!pobj.is_distinguishtime) {
return system.getResultFail(-102, "分时策略不能为空");
}
if (!pobj.strategy_date) {
return system.getResultFail(-103, "策略日期不能为空");
}
if (!pobj.strategy_time) {
return system.getResultFail(-104, "策略时段不能为空");
}
if (!pobj.button_type) {
return system.getResultFail(-105, "按钮形式不能为空");
}
if (!pobj.button_name) {
return system.getResultFail(-106, "按钮文案不能为空");
}
if (!pobj.call_number) {
return system.getResultFail(-107, "呼叫号码不能为空");
}
if (!pobj.else_button_type) {
return system.getResultFail(-108, "其他按钮形式不能为空");
}
if (!pobj.else_button_name) {
return system.getResultFail(-109, "其他按钮文案不能为空");
}
if (!pobj.else_call_number) {
return system.getResultFail(-110, "其他呼叫号码不能为空");
}
if (!pobj.call_number) {
return system.getResultFail(-107, "呼叫号码不能为空");
}
if (!pobj.else_button_type) {
return system.getResultFail(-108, "其他按钮形式不能为空");
}
if (!pobj.else_button_name) {
return system.getResultFail(-109, "其他按钮文案不能为空");
}
if (!pobj.else_call_number) {
return system.getResultFail(-110, "其他呼叫号码不能为空");
}
return system.getResultSuccess(this.dao.create(pobj));
}
async update(pobj) {
var functionName = "bottomMenuConfig";
await this.redisdel.redisInfo(functionName);
return system.getResultSuccess(this.dao.update(pobj));
}
}
......
......@@ -20,6 +20,14 @@ class CycleproductService extends ServiceBase {
try {
var functionName = "cycleProduct";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
......
......@@ -18,9 +18,17 @@ class PopularrecommendationService extends ServiceBase {
if (pobj.pic_describe && pobj.pic_describe.length > 19) {
return system.getResultFail(-105, "图片描述最多20位字符");
}
var functionName = "popularRecommendationList";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
return system.getResultSuccess(this.dao.update(pobj));
}
}
......
......@@ -15,6 +15,14 @@ class ProductService extends ServiceBase {
async update(pobj) {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
return system.getResultSuccess(this.dao.update(pobj));
}
......@@ -24,14 +32,14 @@ class ProductService extends ServiceBase {
* @param pobj
* @returns {Promise<void>}
*/
async getProductsByType(pobj){
const type = await this.producttypeDao.findOne({code:pobj.typeName},[]);
if(!type){
return system.getResultFail(-1,'获取产品类型数据失败');
async getProductsByType(pobj) {
const type = await this.producttypeDao.findOne({ code: pobj.typeName }, []);
if (!type) {
return system.getResultFail(-1, '获取产品类型数据失败');
}
let products = await this.dao.model.findAll({
attributes:["code","name"],
where:{product_type_id:type.id,is_enabled:1},raw:true
attributes: ["code", "name"],
where: { product_type_id: type.id, is_enabled: 1 }, raw: true
});
return system.getResult(products)
}
......
......@@ -5,12 +5,12 @@ class ProducttypeService extends ServiceBase {
constructor() {
super("aggregation", ServiceBase.getDaoName(ProducttypeService));
}
async findAndCountAll (obj) {
async findAndCountAll(obj) {
let res = await this.dao.findAndCountAll(obj);
if(obj && obj.search && obj.search.p_id === 0 && res && res.results && res.results.rows && res.results.rows.length>0){
for(var i=0;i<res.results.rows.length;i++){
if(res.results.rows[i].id){
var count = await this.dao.findCount({ where: {p_id:res.results.rows[i].id} });
if (obj && obj.search && obj.search.p_id === 0 && res && res.results && res.results.rows && res.results.rows.length > 0) {
for (var i = 0; i < res.results.rows.length; i++) {
if (res.results.rows[i].id) {
var count = await this.dao.findCount({ where: { p_id: res.results.rows[i].id } });
res.results.rows[i].dataValues.childCount = count;
}
}
......@@ -30,7 +30,7 @@ class ProducttypeService extends ServiceBase {
if (!pobj.sequence) {
return system.getResultFail(-103, "排序不能为空");
}
if (!pobj.name) {
return system.getResultFail(-105, "名称不能为空");
}
......@@ -39,19 +39,19 @@ class ProducttypeService extends ServiceBase {
// return system.getResultFail(-106, "名称最多4位字符");
// }
// }
if(pobj.p_code){
if (pobj.p_code) {
// if (pobj.name && pobj.name.length > 5) {
// return system.getResultFail(-106, "请输入5字以内名称");
// }
var p_type = await this.dao.model.findOne({
where:{code:pobj.p_code,p_id:0},raw:true
where: { code: pobj.p_code, p_id: 0 }, raw: true
});
if(!p_type){
return system.getResultFail(-300,"产品一类不存在");
if (!p_type) {
return system.getResultFail(-300, "产品一类不存在");
}
pobj.p_id = p_type.id;
pobj.p_name = p_type.name;
}else if (!pobj.jump_link_type || !pobj.jump_link) {
} else if (!pobj.jump_link_type || !pobj.jump_link) {
return system.getResultFail(-104, "连接不能为空");
}
return system.getResultSuccess(this.dao.create(pobj));
......@@ -60,7 +60,7 @@ class ProducttypeService extends ServiceBase {
if (!pobj.pic_url) {
return system.getResultFail(-101, "图标不能为空");
}
if (!pobj.sequence && pobj.sequence!==0) {
if (!pobj.sequence && pobj.sequence !== 0) {
return system.getResultFail(-102, "排序不能为空");
}
// if (!pobj.jump_link_type || !pobj.jump_link) {
......@@ -72,30 +72,58 @@ class ProducttypeService extends ServiceBase {
// if (pobj.name && pobj.name.length > 4) {
// return system.getResultFail(-106, "名称最多4位字符");
// }
try {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.update(pobj));
}
//获取产品类型信息-用于后台管理页面
async getProductTypeInfo(obj){
async getProductTypeInfo(obj) {
// if(!obj || !obj.company_id){
// return system.getResultFail();
// }
var typeones = await this.dao.model.findAll({
attributes:["id","code","name","pic_url","jump_link_type","jump_link"],
where:{p_id:0},raw:true,
order:[["sequence","desc"]]
attributes: ["id", "code", "name", "pic_url", "jump_link_type", "jump_link"],
where: { p_id: 0 }, raw: true,
order: [["sequence", "desc"]]
});
for(var i=0;i<typeones.length;i++){
if(typeones[i] && typeones[i].id)
var typetwos = await this.dao.model.findAll({
attributes:["id","code","name","pic_url"],
where:{p_id:typeones[i].id},raw:true,
order:[["sequence","desc"]]
});
for (var i = 0; i < typeones.length; i++) {
if (typeones[i] && typeones[i].id)
var typetwos = await this.dao.model.findAll({
attributes: ["id", "code", "name", "pic_url"],
where: { p_id: typeones[i].id }, raw: true,
order: [["sequence", "desc"]]
});
typeones[i]["children"] = typetwos
}
return system.getResultSuccess(typeones);
}
async delete(pobj){
try {
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.delete(pobj));
}
}
module.exports = ProducttypeService;
// var task = new ProducttypeService();
......
......@@ -56,6 +56,14 @@ class RotationchartService extends ServiceBase {
try {
var functionName = "rotationChartList";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
......@@ -66,6 +74,14 @@ class RotationchartService extends ServiceBase {
try {
var functionName = "rotationChartList";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
......
......@@ -16,6 +16,20 @@ class SecondlevelneedconfigService extends ServiceBase {
if (!pobj.recommend_product_quantity) {
return system.getResultFail(-103, "推荐产品数量不能为空");
}
try {
var functionName = "popularRecommendationList";
await this.redisdel.redisInfo(functionName);
var functionName1 = "productTypeFirst";
await this.redisdel.redisInfo(functionName1);
var functionName2 = "productTypeSecend";
await this.redisdel.redisInfo(functionName2);
var functionName3 = "productList";
await this.redisdel.redisInfo(functionName3);
var functionName4 = "productDetail";
await this.redisdel.redisInfo(functionName4);
} catch (error) {
console.log(error)
}
return system.getResultSuccess(this.dao.update(pobj));
}
}
......
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