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
21109c83
Commit
21109c83
authored
Jun 07, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
a7cd5183
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
179 additions
and
3 deletions
+179
-3
center-manage/app/base/controller/impl/product/pricecatCtl.js
+10
-0
center-manage/app/base/controller/impl/product/pricestrategyCtl.js
+4
-1
center-manage/app/base/controller/impl/product/productCtl.js
+13
-0
center-manage/app/base/controller/impl/product/productpriceCtl.js
+9
-0
center-manage/app/base/db/impl/product/productpriceDao.js
+26
-0
center-manage/app/base/db/models/product/product.js
+4
-0
center-manage/app/base/db/models/product/productprice.js
+5
-0
center-manage/app/base/service/impl/product/pricestrategySve.js
+57
-2
center-manage/app/base/service/impl/product/productSve.js
+51
-0
No files found.
center-manage/app/base/controller/impl/product/pricecatCtl.js
View file @
21109c83
...
...
@@ -11,5 +11,15 @@ class PricecatCtl extends CtlBase {
super
(
"product"
,
CtlBase
.
getServiceName
(
PricecatCtl
));
this
.
pricestrategyService
=
system
.
getObject
(
"service.product.pricestrategySve"
)
}
async
buildPriceStrategy
(
p
,
q
,
req
){
let
pricetypes
=
p
.
pricetypes
let
rtn
=
await
this
.
pricestrategyService
.
buildPriceStrategy
(
pricetypes
)
if
(
rtn
){
if
(
rtn
.
status
==-
1
){
return
system
.
getResult
(
null
,
rtn
.
msg
)
}
}
return
system
.
getResult
({})
}
}
module
.
exports
=
PricecatCtl
;
center-manage/app/base/controller/impl/product/pricestrategyCtl.js
View file @
21109c83
var
system
=
require
(
"../../../system"
)
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
class
PricestrategyCtl
extends
CtlBase
{
constructor
()
{
super
(
"product"
,
CtlBase
.
getServiceName
(
PricestrategyCtl
));
}
async
refQuery
(
pobj
,
qobj
,
req
)
{
let
rtn
=
await
this
.
service
.
refQuery
(
pobj
);
return
rtn
}
}
module
.
exports
=
PricestrategyCtl
;
center-manage/app/base/controller/impl/product/productCtl.js
0 → 100644
View file @
21109c83
var
system
=
require
(
"../../../system"
)
const
CtlBase
=
require
(
"../../ctl.base"
);
class
ProductCtl
extends
CtlBase
{
constructor
()
{
super
(
"product"
,
CtlBase
.
getServiceName
(
ProductCtl
));
// this.pricestrategyService=system.getObject("service.product.pricestrategySve")
}
async
create
(
p
,
q
,
req
){
let
pn
=
await
this
.
service
.
create
(
p
)
return
system
.
getResult
(
pn
)
}
}
module
.
exports
=
ProductCtl
;
center-manage/app/base/controller/impl/product/productpriceCtl.js
0 → 100644
View file @
21109c83
var
system
=
require
(
"../../../system"
)
const
CtlBase
=
require
(
"../../ctl.base"
);
class
ProductpriceCtl
extends
CtlBase
{
constructor
()
{
super
(
"product"
,
CtlBase
.
getServiceName
(
ProductpriceCtl
));
// this.pricestrategyService=system.getObject("service.product.pricestrategySve")
}
}
module
.
exports
=
ProductpriceCtl
;
center-manage/app/base/db/impl/product/productpriceDao.js
0 → 100644
View file @
21109c83
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
ProductpriceDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
ProductpriceDao
));
}
extraModelFilter
(){
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return
{
"key"
:
"include"
,
"value"
:[
{
model
:
this
.
db
.
models
.
pricestrategy
,
attributes
:[
"id"
,
"optionunion"
]},
{
model
:
this
.
db
.
models
.
product
,
attributes
:[
"id"
,
"name"
]}]};
}
}
module
.
exports
=
ProductpriceDao
;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
center-manage/app/base/db/models/product/product.js
View file @
21109c83
...
...
@@ -24,6 +24,10 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
//和user的from
stragetyids
:
{
//不需要持久化
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
//和user的from
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
...
...
center-manage/app/base/db/models/product/productprice.js
View file @
21109c83
...
...
@@ -7,22 +7,27 @@ module.exports = (db, DataTypes) => {
lowpriceref
:{
type
:
DataTypes
.
DECIMAL
(
10
,
2
)
,
allowNull
:
false
,
defaultValue
:
0.00
},
hignpriceref
:{
type
:
DataTypes
.
DECIMAL
(
10
,
2
)
,
allowNull
:
false
,
defaultValue
:
0.00
},
deliverfile
:{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
defaultValue
:
''
},
extrafile
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
defaultValue
:
''
},
//和user的from相同,在注册user时,去创建
desc
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
defaultValue
:
''
},
//和user的from
isEnabled
:{
type
:
DataTypes
.
BOOLEAN
,
...
...
center-manage/app/base/service/impl/product/pricestrategySve.js
View file @
21109c83
...
...
@@ -7,8 +7,63 @@ class PricestrategyService extends ServiceBase {
constructor
()
{
super
(
"product"
,
ServiceBase
.
getDaoName
(
PricestrategyService
));
}
async
buildPriceStrategy
(){
async
buildPriceStrategy
(
pricetypes
)
{
let
dks
=
[]
let
codeattr
=
[]
let
pricetypenames
=
[]
pricetypes
.
forEach
(
item
=>
{
dks
.
push
(
item
.
options
.
split
(
","
))
codeattr
.
push
(
item
.
code
)
pricetypenames
.
push
(
item
.
name
)
})
let
codeunion
=
codeattr
.
join
(
"~"
)
//先按照codeunion检查是否已经生成
let
se
=
await
this
.
dao
.
findOne
({
codeunion
:
codeunion
})
if
(
se
!=
null
){
return
{
status
:
-
1
,
msg
:
'定价策略已经存在,无需再次生成'
}
}
let
nameunion
=
pricetypenames
.
join
(
"~"
)
let
dkresults
=
this
.
makedks
(
dks
)
let
strategys
=
[]
for
(
let
dk
of
dkresults
){
let
tmp
=
{
"codeunion"
:
codeunion
,
"nameunion"
:
nameunion
,
"optionunion"
:
dk
.
split
(
"|"
).
join
(
","
)
}
strategys
.
push
(
tmp
)
}
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
r
=
await
self
.
dao
.
bulkCreate
(
strategys
,
t
)
return
{
status
:
0
};
});
}
makedks
(
rows
)
{
var
mid
=
[]
for
(
let
i
=
0
;
i
<
rows
.
length
;
i
++
)
{
if
(
mid
.
length
==
0
)
{
console
.
log
(
"in.........."
)
let
one
=
rows
[
i
]
let
two
=
rows
[
++
i
]
console
.
log
(
two
,
".........."
)
one
.
forEach
(
item
=>
{
two
.
forEach
(
c
=>
{
mid
.
push
(
item
+
"|"
+
c
)
})
})
}
else
{
let
next
=
rows
[
i
]
let
tmparray
=
[]
mid
.
forEach
(
m
=>
{
next
.
forEach
(
n
=>
{
tmparray
.
push
(
m
+
"|"
+
n
)
})
})
mid
=
tmparray
}
}
return
mid
;
}
}
module
.
exports
=
PricestrategyService
;
...
...
center-manage/app/base/service/impl/product/productSve.js
0 → 100644
View file @
21109c83
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
appconfig
=
system
.
getSysConfig
();
const
fs
=
require
(
"fs"
)
class
ProductService
extends
ServiceBase
{
constructor
()
{
super
(
"product"
,
ServiceBase
.
getDaoName
(
ProductService
));
this
.
priceDao
=
system
.
getObject
(
"db.product.productpriceDao"
)
}
async
create
(
p
)
{
if
(
!
p
.
name
||
p
.
name
==
""
)
{
p
.
name
=
p
.
regionpath
+
"~"
+
p
.
productcatpath
}
let
stragetyids
=
p
.
stragetyids
var
self
=
this
;
return
this
.
db
.
transaction
(
async
function
(
t
)
{
p
.
stragetyids
=
p
.
stragetyids
.
join
(
","
)
let
pnew
=
await
self
.
dao
.
create
(
p
,
t
)
let
productprices
=
[]
stragetyids
.
forEach
(
stragetyid
=>
{
let
pps
=
{
product_id
:
pnew
.
id
,
pricestrategy_id
:
stragetyid
,
}
productprices
.
push
(
pps
)
})
await
self
.
priceDao
.
bulkCreate
(
productprices
,
t
)
return
pnew
;
});
}
}
module
.
exports
=
ProductService
;
// (async ()=>{
// let u=new AppService();
// // let x=await u.cregister("jiangong")
// // console.log(x)
// // let x=await u.cunregister("jiangong")
// // console.log(x)
// // let t=await u.cmakejwt()
// // console.log(t)
// //let ux=await u.cjsonregister(AppService.newRouteUrl("test-service2"),{name:"test-service2",hosts:["ttest1.com"]})
// //let ux=await u.cjsonregister(AppService.newServiceUrl(),{name:"test-service3",url:"http://zhichan.gongsibao.com"})
// //let ux=await u.cdel(AppService.routeUrl("test-service2"))
// //let ux=await u.cdel(AppService.serviceUrl("test-service2"))
// // let ux=await u.create({name:"test4-service",backend:"zhichan-service",domainName:"domain.com"})
// // console.log(ux);
// // let delrtn=await u.delete({id:2,name:"test4-service"})
// // console.log(delrtn);
// })()
\ 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