Commit 67c5e7ba by 蒋勇

d

parent 5dbe1ca8
...@@ -4,11 +4,51 @@ class ProductpriceService extends ServiceBase { ...@@ -4,11 +4,51 @@ class ProductpriceService extends ServiceBase {
constructor() { constructor() {
super("product", ServiceBase.getDaoName(ProductpriceService)); super("product", ServiceBase.getDaoName(ProductpriceService));
} }
async updownProduct(uid){ /**
let p= await this.dao.findById(uid) * @param {*} pname 产品名称
p.isEnabled=!p.isEnabled * @param {*} spname 服务商名称
await p.save() */
return {} async findRegionsByProductName(productname, spname) {
let ps = await this.dao.model.findAll({
where: {
sptags: { [this.db.Op.like]: "%" + spname + "%" },
pname: { [this.db.Op.like]: "%" + productname + "%" },
}, attributes: ['pname'], raw: true
})
//查询出地区
let rs = await this.db.models.region.findAll({ attributes: ['code', 'name'], raw: true })
//获取地区JSON 对象
let psrtn = []
ps.forEach(r => {
let rpathstr = r.pname.split("~")[0]
let rpatharray = rpathstr.split("/")
let lstindex = rpatharray.length - 1
let regionName = rpatharray[lstindex]
let regioninfo = {}
regioninfo["label"] = regionName
//按照名字去取地区编码
let areainfos = rs.filter(f => {
if (f.name == regionName) {
return true
} else {
return false
}
})
regioninfo["code"] = areainfos[0].code
psrtn.push(regioninfo)
})
return psrtn
}
async updownProduct(uid) {
let p = await this.dao.findById(uid)
p.isEnabled = !p.isEnabled
await p.save()
return {}
} }
} }
module.exports = ProductpriceService; module.exports = ProductpriceService;
\ No newline at end of file
// let p=new ProductpriceService()
// p.findRegionsByProductName("个体户注册","gao").then((res)=>{
// console.log(res)
// })
\ No newline at end of file
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