Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
47bd9ba8
Commit
47bd9ba8
authored
Jun 21, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
a21feaf5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
29 deletions
+133
-29
center-manage/app/base/db/models/product/xproductprice.js
+67
-0
center-manage/app/base/service/impl/product/a.txt
+2
-0
center-manage/app/base/service/impl/product/pricestrategySve.js
+4
-0
center-manage/app/base/service/impl/product/productSve.js
+4
-0
center-manage/app/base/service/impl/product/xproductSve.js
+56
-29
No files found.
center-manage/app/base/db/models/product/xproductprice.js
0 → 100644
View file @
47bd9ba8
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}]
// }
]
});
}
center-manage/app/base/service/impl/product/a.txt
0 → 100644
View file @
47bd9ba8
国外
\ No newline at end of file
center-manage/app/base/service/impl/product/pricestrategySve.js
View file @
47bd9ba8
...
@@ -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.........."
)
...
...
center-manage/app/base/service/impl/product/productSve.js
View file @
47bd9ba8
...
@@ -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
,
...
...
center-manage/app/base/service/impl/product/xproductSve.js
View file @
47bd9ba8
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,65 @@ class XProductService extends ServiceBase {
...
@@ -10,38 +11,65 @@ class XProductService extends ServiceBase {
}
}
}
}
module
.
exports
=
XProductService
;
module
.
exports
=
XProductService
;
function
findTitlePath
(
items
,
findstr
,
results
)
{
function
findTitlePath
(
items
,
findstr
,
results
)
{
items
.
forEach
(
item
=>
{
items
.
forEach
(
item
=>
{
if
(
item
.
title
.
indexOf
(
findstr
)
<
0
)
{
if
(
item
.
title
.
indexOf
(
findstr
)
<
0
)
{
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
if
(
item
.
children
&&
item
.
children
.
length
>
0
)
{
return
findTitlePath
(
item
.
children
,
findstr
,
results
)
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 +78,7 @@ ps.buildProductCat().then(res => {
...
@@ -50,7 +78,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 +137,4 @@ ps.buildProductCat().then(res => {
...
@@ -109,4 +137,4 @@ 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment