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 { ...@@ -41,6 +41,10 @@ class PricestrategyService extends ServiceBase {
} }
makedks(rows) { makedks(rows) {
var mid = [] var mid = []
if(rows.length==1){
mid=rows[0]
return mid
}
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
if (mid.length == 0) { if (mid.length == 0) {
console.log("in..........") console.log("in..........")
......
...@@ -20,6 +20,7 @@ class ProductService extends ServiceBase { ...@@ -20,6 +20,7 @@ class ProductService extends ServiceBase {
} }
//策略ids //策略ids
let stragetyids = p.sts let stragetyids = p.sts
let skucodemap=p.skucodemap
var self = this; var self = this;
return this.db.transaction(async function (t) { return this.db.transaction(async function (t) {
let pnew = await self.dao.create(p, t) let pnew = await self.dao.create(p, t)
...@@ -27,6 +28,9 @@ class ProductService extends ServiceBase { ...@@ -27,6 +28,9 @@ class ProductService extends ServiceBase {
//按照策略id查询出定价策略集合 //按照策略id查询出定价策略集合
let tmpdic=await self.findPriceStrategys(stragetyids,t) let tmpdic=await self.findPriceStrategys(stragetyids,t)
stragetyids.forEach(stragetyid => { stragetyids.forEach(stragetyid => {
if(skucodemap){
p.skucode=skucodemap[stragetyid]
}
let pps = { let pps = {
product_id: pnew.id, product_id: pnew.id,
pricestrategy_id: stragetyid, pricestrategy_id: stragetyid,
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const fs=require("fs")
class XProductService extends ServiceBase { class XProductService extends ServiceBase {
constructor() { constructor() {
super("xproduct", ServiceBase.getDaoName(XProductService)); super("xproduct", ServiceBase.getDaoName(XProductService));
...@@ -10,38 +11,66 @@ class XProductService extends ServiceBase { ...@@ -10,38 +11,66 @@ class XProductService extends ServiceBase {
} }
} }
module.exports = XProductService; module.exports = XProductService;
function findTitlePath(items,findstr,results){ /*
items.forEach(item=>{ function findTitlePath(items, findstr, results) {
if(item.title.indexOf(findstr)<0){ items.forEach(item => {
if(item.children && item.children.length>0){ if (item.title.indexOf(findstr) < 0) {
return findTitlePath(item.children,findstr,results) if (item.children && item.children.length > 0) {
return findTitlePath(item.children, findstr, results)
} }
}else{ } else {
results.push(item.titlepath) results.push(item.titlepath)
return return
} }
}) })
} }
let ps = new XProductService() (async () => {
let ts=system.getObject("service.common.treearchSve") let ps = new XProductService()
let products=[] let ts = system.getObject("service.common.treearchSve")
ps.buildProductCat().then(res => { let products = []
// console.log(JSON.stringify(res)) let res = await ps.buildProductCat();
ts.getRegions().then(rs=>{ let rs = await ts.getRegions()
res.forEach(xp=>{ let tags=[]
let product={} for(let xp of res){
product.code=xp.path_code+xp.id let product = {}
results=[] product.code = xp.path_code + xp.id
findTitlePath(rs,xp.region_name,results) results = []
product.regionpath=results[0] findTitlePath(rs, xp.region_name, results)
product.productcatpath="产品分类"+xp.path_name if(results.length==0 || !results[0]){
product.name= product.productcatpath+"~"+ product.regionpath fs.writeFileSync("./a.txt",xp.region_name)
product.sptags=xp.servicer_name }
products.push(product) product.regionpath = results[0]
}) product.productcatpath = "产品分类" + xp.path_name
console.log(JSON.stringify(products)) 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)
}
let productS=system.getObject("service.product.productSve")
for(let p of products){
await productS.create(p)
}
console.log(JSON.stringify(tags))
// { id: 128, // { id: 128,
// path_code: '/ic/gsreg/'+id,----->code // path_code: '/ic/gsreg/'+id,----->code
// path_name: '/工商服务/公司注册/',+产品分类---->productcatpath // path_name: '/工商服务/公司注册/',+产品分类---->productcatpath
...@@ -50,7 +79,7 @@ ps.buildProductCat().then(res => { ...@@ -50,7 +79,7 @@ ps.buildProductCat().then(res => {
//通过region_name--解析出regionpath //通过region_name--解析出regionpath
//path_name--添加“产品分类” //path_name--添加“产品分类”
//code,regionpath,productcatpath,name //code,regionpath,productcatpath,name
...@@ -109,4 +138,5 @@ ps.buildProductCat().then(res => { ...@@ -109,4 +138,5 @@ ps.buildProductCat().then(res => {
// root.children.push(treedata[k]) // root.children.push(treedata[k])
// }) // })
// console.log(JSON.stringify(root)) // 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