Commit b11affbb by 蒋勇

d

parent b10dd13c
...@@ -8,19 +8,19 @@ class ProductpriceService extends ServiceBase { ...@@ -8,19 +8,19 @@ class ProductpriceService extends ServiceBase {
* @param {*} pname 产品名称 * @param {*} pname 产品名称
* @param {*} spname 服务商名称 * @param {*} spname 服务商名称
*/ */
async findRegionsByProductName(productname, spname) { async findRegionsByProductName (productname, spname) {
let ps = await this.dao.model.findAll({ let ps = await this.dao.model.findAll({
where: { where: {
sptags: { [this.db.Op.like]: "%" + spname + "%" }, sptags: { [this.db.Op.like]: "%" + spname + "%" },
pname: { [this.db.Op.like]: "%" + productname + "%" }, pname: { [this.db.Op.like]: "%" + productname + "%" },
isEnabled:true isEnabled: true
}, attributes: ['pname','strategyitems'], raw: true }, attributes: ['pname', 'strategyitems'], raw: true
}) })
//查询出地区 //查询出地区
let rs = await this.db.models.region.findAll({ attributes: ['code', 'name'], raw: true }) let rs = await this.db.models.region.findAll({ attributes: ['code', 'name'], raw: true })
//获取地区JSON 对象 //获取地区JSON 对象
let psrtn = [] let psrtn = []
let cacheregions={} let cacheregions = {}
ps.forEach(r => { ps.forEach(r => {
let rpathstr = r.pname.split("~")[1] let rpathstr = r.pname.split("~")[1]
let rpatharray = rpathstr.split("/") let rpatharray = rpathstr.split("/")
...@@ -28,32 +28,32 @@ class ProductpriceService extends ServiceBase { ...@@ -28,32 +28,32 @@ class ProductpriceService extends ServiceBase {
let regionName = rpatharray[lstindex] let regionName = rpatharray[lstindex]
let regioninfo = {} let regioninfo = {}
regioninfo["label"] = regionName regioninfo["label"] = regionName
let exAttrTmp=r.strategyitems let exAttrTmp = r.strategyitems
//按照名字去取地区编码 //按照名字去取地区编码
let areainfos = rs.filter(f => { let areainfos = rs.filter(f => {
if (f.name.indexOf(regionName)>=0) { if (f.name.indexOf(regionName) >= 0) {
return true return true
} else { } else {
return false return false
} }
}) })
let codeval=String(areainfos[0].code).padEnd(6,'0') let codeval = String(areainfos[0].code).padEnd(6, '0')
if(areainfos[0].name.indexOf("天津")>=0 ||areainfos[0].name.indexOf("北京")>=0 || areainfos[0].name.indexOf("上海") >=0 || areainfos[0].name.indexOf("重庆")>=0){ if (productname.indexOf("icp") < 0 && productname.indexOf("edi") < 0 && areainfos[0].name.indexOf("天津") >= 0 || areainfos[0].name.indexOf("北京") >= 0 || areainfos[0].name.indexOf("上海") >= 0 || areainfos[0].name.indexOf("重庆") >= 0) {
codeval=String(areainfos[0].code+"01").padEnd(6,'0') codeval = String(areainfos[0].code + "01").padEnd(6, '0')
} }
if(!cacheregions[codeval]){ if (!cacheregions[codeval]) {
cacheregions[codeval]=regioninfo cacheregions[codeval] = regioninfo
regioninfo["code"] = codeval regioninfo["code"] = codeval
regioninfo["exAttr"]=[exAttrTmp] regioninfo["exAttr"] = [exAttrTmp]
psrtn.push(regioninfo) psrtn.push(regioninfo)
}else{ } else {
let cacheObj=cacheregions[codeval] let cacheObj = cacheregions[codeval]
cacheObj["exAttr"].push(exAttrTmp) cacheObj["exAttr"].push(exAttrTmp)
} }
}) })
return psrtn return psrtn
} }
async updownProduct(uid) { async updownProduct (uid) {
let p = await this.dao.findById(uid) let p = await this.dao.findById(uid)
p.isEnabled = !p.isEnabled p.isEnabled = !p.isEnabled
await p.save() await p.save()
......
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