Commit b11affbb by 蒋勇

d

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