Commit 5e4dc718 by 王勇飞

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

parents efe68b8f f8bf46a0
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
//定价类型
return db.define("xproductprice", {
price_code:{
type: DataTypes.STRING,
allowNull: false,
},
product_name:{
type: DataTypes.STRING,
allowNull: false,
},
price_name:{
type: DataTypes.STRING,
allowNull: false,
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'tx_product_price',
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}]
// }
]
});
}
国外
\ No newline at end of file
......@@ -41,6 +41,10 @@ class PricestrategyService extends ServiceBase {
}
makedks(rows) {
var mid = []
if(rows.length==1){
mid=rows[0]
return mid
}
for (let i = 0; i < rows.length; i++) {
if (mid.length == 0) {
console.log("in..........")
......
......@@ -20,6 +20,7 @@ class ProductService extends ServiceBase {
}
//策略ids
let stragetyids = p.sts
let skucodemap=p.skucodemap
var self = this;
return this.db.transaction(async function (t) {
let pnew = await self.dao.create(p, t)
......@@ -27,6 +28,9 @@ class ProductService extends ServiceBase {
//按照策略id查询出定价策略集合
let tmpdic=await self.findPriceStrategys(stragetyids,t)
stragetyids.forEach(stragetyid => {
if(skucodemap){
p.skucode=skucodemap[stragetyid]
}
let pps = {
product_id: pnew.id,
pricestrategy_id: stragetyid,
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const fs=require("fs")
class XProductService extends ServiceBase {
constructor() {
super("xproduct", ServiceBase.getDaoName(XProductService));
......@@ -10,38 +11,66 @@ class XProductService extends ServiceBase {
}
}
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)
/*
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{
} 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
(async () => {
let ps = new XProductService()
let ts = system.getObject("service.common.treearchSve")
let products = []
let res = await ps.buildProductCat();
let rs = await ts.getRegions()
let tags=[]
for(let xp of res){
let product = {}
product.code = xp.path_code + xp.id
results = []
findTitlePath(rs, xp.region_name, results)
if(results.length==0 || !results[0]){
fs.writeFileSync("./a.txt",xp.region_name)
}
product.regionpath = results[0]
product.productcatpath = "产品分类" + xp.path_name
product.name = product.productcatpath + "~" + product.regionpath
product.sptags = xp.servicer_name
product.desc=product.name
product.company_id=1
//构造策略ids
let stsinfos = await ps.db.models.xproductprice.findAll({ where:{product_name:xp.path_code},raw: true })
let straid=[]
let skucodemap={}
for(let stinfo of stsinfos){
let tg=stinfo.price_name.replace("EDI","").replace("ICP","").replace("(",",").replace(")","").replace("章","").replace("税控","").replace("完成","").replace("\t\r\n","")
//按照price_name去策略表中查询策略id
let strategy=await ps.db.models.pricestrategy.findOne({where:{optionunion:tg}})
if(!strategy){
tags.push(tg)
}else{
straid.push(strategy.id)
skucodemap[strategy.id]=stinfo.price_code
}
}
//
// console.log(stsinfos.length,"..................")
product.sts=straid
product.skucodemap=skucodemap
products.push(product)
})
console.log(JSON.stringify(products))
})
}
let productS=system.getObject("service.product.productSve")
for(let p of products){
await productS.create(p)
}
console.log(JSON.stringify(tags))
// { id: 128,
// path_code: '/ic/gsreg/'+id,----->code
// path_name: '/工商服务/公司注册/',+产品分类---->productcatpath
......@@ -50,7 +79,7 @@ ps.buildProductCat().then(res => {
//通过region_name--解析出regionpath
//path_name--添加“产品分类”
//code,regionpath,productcatpath,name
//code,regionpath,productcatpath,name
......@@ -109,4 +138,5 @@ ps.buildProductCat().then(res => {
// root.children.push(treedata[k])
// })
// console.log(JSON.stringify(root))
})
\ No newline at end of file
}) ()
*/
\ 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