Commit 86694369 by 王勇飞

Merge branch 'center-manage' of gitlab.gongsibao.com:jiangyong/zhichan into center-manage

parents 9f42d5de 29b8d137
...@@ -26,11 +26,11 @@ class AccessAuthAPI extends APIBase { ...@@ -26,11 +26,11 @@ class AccessAuthAPI extends APIBase {
} }
async getBizUserForBizChance(p,q,req){ async getBizUserForBizChance(p,q,req){
let s= await this.userSve.getBizUserForBizChance(p.clientMobile,p.spName,p.productCatName) let s= await this.userSve.getBizUserForBizChance(p.clientMobile,p.spName,p.productCatName,p.regionName)
return system.getResult(s) return system.getResult(s)
} }
async getBizUserForDelivery(p,q,req){ async getBizUserForDelivery(p,q,req){
let s= await this.userSve.getBizUserForDelivery(p.clientMobile,p.spName,p.productCatName,p.skucode) let s= await this.userSve.getBizUserForDelivery(p.clientMobile,p.spName,p.productCatName,p.skucode,,p.regionName)
return system.getResult(s) return system.getResult(s)
} }
classDesc() { classDesc() {
......
...@@ -52,6 +52,10 @@ module.exports = (db, DataTypes) => { ...@@ -52,6 +52,10 @@ module.exports = (db, DataTypes) => {
opath:DataTypes.STRING,//作业务时,需要在业务表冗余当前处理人的opath opath:DataTypes.STRING,//作业务时,需要在业务表冗余当前处理人的opath
ptags:DataTypes.STRING,//权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据 ptags:DataTypes.STRING,//权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据
skilltags:DataTypes.STRING,// 技能标签 skilltags:DataTypes.STRING,// 技能标签
regiontags:{
type: DataTypes.STRING,
allowNull: true,
}// 区域标签
},{ },{
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -4,6 +4,18 @@ const appconfig=system.getSysConfig(); ...@@ -4,6 +4,18 @@ const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
//定价类型 //定价类型
return db.define("product", { return db.define("product", {
sptags:{//交付商标签
type: DataTypes.STRING,
allowNull: true,
},
channeltags:{//渠道标签
type: DataTypes.STRING,
allowNull: true,
},
industrytags:{//行业标签
type: DataTypes.STRING,
allowNull: true,
},
code:{ code:{
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false,
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
//定价类型
return db.define("xproduct", {
path_code:{
type: DataTypes.STRING,
allowNull: false,
},
path_name:{
type: DataTypes.STRING,
allowNull: false,
},
region_id:{
type: DataTypes.STRING,
allowNull: false,
},
region_name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
servicer_name:{
type: DataTypes.STRING,
allowNull: false,
}
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'x_product',
getterMethods: {
spName() {
return servicer_name
}
},
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
...@@ -369,8 +369,9 @@ class UserService extends ServiceBase { ...@@ -369,8 +369,9 @@ class UserService extends ServiceBase {
* @param {*} clientMobile 客户电话 * @param {*} clientMobile 客户电话
* @param {*} spName 服务商名称 * @param {*} spName 服务商名称
* @param {*} productCatName 产品类型名称 * @param {*} productCatName 产品类型名称
* @param {*} regionName 区域
*/ */
async getBizUserForBizChance(clientMobile, spName, productCatName) { async getBizUserForBizChance(clientMobile, spName, productCatName,regionName) {
var self = this var self = this
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称 //按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
...@@ -398,11 +399,20 @@ class UserService extends ServiceBase { ...@@ -398,11 +399,20 @@ class UserService extends ServiceBase {
console.log(companyFind) console.log(companyFind)
let users = companyFind.us let users = companyFind.us
let cansels = users.filter(u => { let cansels = users.filter(u => {
if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0) { if(regionName && regionName!=""){
return true if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0 && u.regiontags.indexOf(regionName)>=0) {
} else { return true
return false } else {
return false
}
}else{
if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0) {
return true
} else {
return false
}
} }
}) })
let lngth = cansels.length let lngth = cansels.length
if (lngth > 0) { if (lngth > 0) {
...@@ -437,8 +447,9 @@ class UserService extends ServiceBase { ...@@ -437,8 +447,9 @@ class UserService extends ServiceBase {
* @param {*} spName 服务商名称 * @param {*} spName 服务商名称
* @param {*} productCatName 产品类型名称 * @param {*} productCatName 产品类型名称
* @param {*} skucode 最小销售货品编码,来自渠道上架的码 * @param {*} skucode 最小销售货品编码,来自渠道上架的码
* @param {*} regionName 区域
*/ */
async getBizUserForDelivery(xclientMobile, spName, productCatName, skucode) { async getBizUserForDelivery(xclientMobile, spName, productCatName, skucode,regionName) {
let clientMobile='fordeliver'+xclientMobile let clientMobile='fordeliver'+xclientMobile
var self = this var self = this
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称 //按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
...@@ -486,10 +497,18 @@ class UserService extends ServiceBase { ...@@ -486,10 +497,18 @@ class UserService extends ServiceBase {
}); });
let users = companyFind.us let users = companyFind.us
let cansels = users.filter(u => { let cansels = users.filter(u => {
if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0) { if(regionName && regionName!=""){
return true if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0 && u.regiontags.indexOf(regionName)>=0) {
} else { return true
return false } else {
return false
}
}else{
if (u.isAllocated && u.skilltags.indexOf(productCatName) >= 0) {
return true
} else {
return false
}
} }
}) })
let lngth = cansels.length let lngth = cansels.length
......
...@@ -16,7 +16,7 @@ class ProductService extends ServiceBase { ...@@ -16,7 +16,7 @@ class ProductService extends ServiceBase {
} }
async create(p) { async create(p) {
if (!p.name || p.name == "") { if (!p.name || p.name == "") {
p.name = p.regionpath + "~" + p.productcatpath p.name = p.productcatpath+ "~" + p.regionpath
} }
//策略ids //策略ids
let stragetyids = p.sts let stragetyids = p.sts
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
class XProductService extends ServiceBase {
constructor() {
super("xproduct", ServiceBase.getDaoName(XProductService));
}
async buildProductCat() {
let ps = await this.dao.model.findAll({ raw: true })
return ps
}
}
module.exports = XProductService;
function findTitlePath(items,findstr,results){
items.forEach(item=>{
if(item.title.indexOf(findstr)<0){
if(item.children && item.children.length>0){
return findTitlePath(item.children,findstr,results)
}
}else{
results.push(item.titlepath)
return
}
})
}
let ps = new XProductService()
let ts=system.getObject("service.common.treearchSve")
let products=[]
ps.buildProductCat().then(res => {
// console.log(JSON.stringify(res))
ts.getRegions().then(rs=>{
res.forEach(xp=>{
let product={}
product.code=xp.path_code+xp.id
results=[]
findTitlePath(rs,xp.region_name,results)
product.regionpath=results[0]
product.productcatpath="产品分类"+xp.path_name
product.name= product.productcatpath+"~"+ product.regionpath
product.sptags=xp.servicer_name
products.push(product)
})
console.log(JSON.stringify(products))
})
// { id: 128,
// path_code: '/ic/gsreg/'+id,----->code
// path_name: '/工商服务/公司注册/',+产品分类---->productcatpath
// region_id: '320400',
// region_name: '常州'}--->regionpath
//通过region_name--解析出regionpath
//path_name--添加“产品分类”
//code,regionpath,productcatpath,name
// let treedata={}
// res.forEach(item=>{
// let pathcodes=item.path_code.split("/")
// let pathnames=item.path_name.split("/")
// let pathcoderesults=pathcodes.slice(1,3)
// let pathnameresults=pathnames.slice(1,3)
// let codekey=pathcoderesults[0]
// if(!treedata[codekey]){
// let tmp={}
// tmp["code"]=pathcoderesults[0]
// tmp["title"]=pathnameresults[0]
// tmp["orgpath"]="/"+pathcoderesults[0]
// tmp["titlepath"]="/"+pathnameresults[0]
// tmp.children=[
// {
// code:pathcoderesults[1],
// title:pathnameresults[1],
// orgpath:item.path_code,
// titlepath:item.path_name
// }
// ]
// treedata[codekey]= tmp
// }else{
// let f=treedata[codekey].children.filter(it=>{
// if(it.code==pathcoderesults[1]){
// return true
// }else{
// return false
// }
// })
// if(f.length==0){
// let n={
// code:pathcoderesults[1],
// title:pathnameresults[1],
// orgpath:item.path_code,
// titlepath:item.path_name
// }
// treedata[codekey].children.push(n)
// }
// }
// })
// let root = {
// title: "产品分类",
// code: "root",
// orgpath: "root",
// children: [
// ]
// }
// Object.keys(treedata).forEach(k=>{
// root.children.push(treedata[k])
// })
// console.log(JSON.stringify(root))
})
\ 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