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
ce4c87d3
Commit
ce4c87d3
authored
May 31, 2020
by
sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 商机方方案功能
parent
820c29fd
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
535 additions
and
176 deletions
+535
-176
icp-deliver/app/base/controller/impl/bizchance/bizoptCtl.js
+43
-2
icp-deliver/app/base/controller/impl/bizchance/schemeCtl.js
+30
-0
icp-deliver/app/base/db/dao.base.js
+11
-13
icp-deliver/app/base/db/impl/auth/userDao.js
+110
-104
icp-deliver/app/base/db/impl/bizchance/bizoptDao.js
+30
-0
icp-deliver/app/base/db/impl/bizchance/schemeDao.js
+8
-0
icp-deliver/app/base/db/impl/bizchance/statuslogDao.js
+8
-0
icp-deliver/app/base/db/models/delivery/business_opportunity.js
+5
-1
icp-deliver/app/base/db/models/delivery/delivery_bill.js
+5
-1
icp-deliver/app/base/db/models/delivery/scheme.js
+1
-1
icp-deliver/app/base/db/models/delivery/status_log.js
+1
-1
icp-deliver/app/base/service/impl/bizchance/bizoptSve.js
+108
-0
icp-deliver/app/base/service/impl/bizchance/schemeSve.js
+86
-0
icp-deliver/app/base/service/impl/cms/articleSve.js
+53
-53
icp-deliver/app/base/system.js
+36
-0
No files found.
icp-deliver/app/base/controller/impl/bizchance/bizoptCtl.js
View file @
ce4c87d3
var
system
=
require
(
"../../../system"
)
const
http
=
require
(
"http"
)
var
system
=
require
(
"../../../system"
)
;
const
http
=
require
(
"http"
)
;
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
moment
=
require
(
"moment"
);
class
BizOptCtl
extends
CtlBase
{
constructor
()
{
super
(
"bizchance"
,
CtlBase
.
getServiceName
(
BizOptCtl
));
}
async
findAndCountAll
(
pobj
,
qobj
,
req
)
{
//设置查询条件
const
rs
=
await
this
.
service
.
findAndCountAll
(
pobj
);
if
(
rs
.
results
&&
rs
.
results
.
rows
)
{
let
result
=
[];
for
(
let
val
of
rs
.
results
.
rows
)
{
val
.
company_name
=
val
.
business_info
.
company
;
val
.
customer_number
=
val
.
business_info
.
phone
;
val
.
customer_name
=
val
.
business_info
.
person
;
val
.
updated_at
=
moment
(
val
.
updated_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
);
val
.
created_at
=
moment
(
val
.
created_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
);
result
.
push
(
val
);
}
rs
.
results
.
rows
=
result
;
}
return
system
.
getResult
(
rs
);
}
async
findBizAndSheme
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
id
)
{
return
system
.
getResult
(
null
,
"id can not be empty,100290"
);
}
const
rs
=
await
this
.
service
.
findBizAndSheme
({
id
:
pobj
.
id
});
return
system
.
getResult
(
rs
);
}
async
closeBiz
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
bizId
)
{
return
system
.
getResult
(
null
,
"bizId can not be empty,100290"
);
}
try
{
await
this
.
service
.
closeBiz
({
bizId
:
pobj
.
bizId
});
return
system
.
getResultSuccess
();
}
catch
(
err
)
{
return
system
.
getResult
(
null
,
err
.
message
)
}
}
}
module
.
exports
=
BizOptCtl
;
icp-deliver/app/base/controller/impl/bizchance/schemeCtl.js
0 → 100644
View file @
ce4c87d3
var
system
=
require
(
"../../../system"
);
const
http
=
require
(
"http"
);
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../../config/settings"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
moment
=
require
(
"moment"
);
class
SchemeCtl
extends
CtlBase
{
constructor
()
{
super
(
"bizchance"
,
CtlBase
.
getServiceName
(
SchemeCtl
));
}
async
create
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
bizopt_id
)
{
return
system
.
getResult
(
null
,
"bizopt_id can not be empty,100290"
);
}
try
{
let
data
=
await
this
.
service
.
create
(
pobj
);
return
system
.
getResult
(
data
);
}
catch
(
err
)
{
return
system
.
getResult
(
null
,
err
.
message
)
}
}
async
findOne
(
pobj
,
qobj
,
req
)
{
if
(
!
pobj
.
bizopt_id
)
{
return
system
.
getResult
(
null
,
"bizopt_id can not be empty,100290"
);
}
const
rs
=
await
this
.
service
.
findOne
({
bizopt_id
:
pobj
.
bizopt_id
});
return
system
.
getResult
(
rs
);
}
}
module
.
exports
=
SchemeCtl
;
icp-deliver/app/base/db/dao.base.js
View file @
ce4c87d3
...
...
@@ -15,8 +15,6 @@ class Dao {
async
create
(
u
,
t
)
{
var
u2
=
this
.
preCreate
(
u
);
if
(
t
)
{
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
);
console
.
log
(
this
.
model
);
return
this
.
model
.
create
(
u2
,
{
transaction
:
t
}).
then
(
u
=>
{
return
u
;
});
...
...
@@ -30,7 +28,7 @@ class Dao {
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Dao"
)).
toLowerCase
()
}
async
refQuery
(
qobj
)
{
var
w
=
qobj
.
refwhere
?
qobj
.
refwhere
:
{};
var
w
=
qobj
.
refwhere
?
qobj
.
refwhere
:
{};
if
(
qobj
.
levelinfo
)
{
w
[
qobj
.
levelinfo
.
levelfield
]
=
qobj
.
levelinfo
.
level
;
}
...
...
@@ -38,8 +36,8 @@ class Dao {
w
[
qobj
.
parentinfo
.
parentfield
]
=
qobj
.
parentinfo
.
parentcode
;
}
//如果需要控制数据权限
if
(
qobj
.
datapriv
)
{
w
[
"id"
]
=
{
[
this
.
db
.
Op
.
in
]:
qobj
.
datapriv
};
if
(
qobj
.
datapriv
)
{
w
[
"id"
]
=
{
[
this
.
db
.
Op
.
in
]:
qobj
.
datapriv
};
}
if
(
qobj
.
likestr
)
{
w
[
qobj
.
fields
[
0
]]
=
{
[
this
.
db
.
Op
.
like
]:
"%"
+
qobj
.
likestr
+
"%"
};
...
...
@@ -64,13 +62,13 @@ class Dao {
async
delete
(
qobj
,
t
)
{
var
en
=
null
if
(
t
!=
null
&&
t
!=
'undefined'
)
{
en
=
await
this
.
model
.
findOne
({
where
:
{
id
:
qobj
.
id
},
transaction
:
t
});
en
=
await
this
.
model
.
findOne
({
where
:
{
id
:
qobj
.
id
},
transaction
:
t
});
if
(
en
!=
null
)
{
await
en
.
destroy
({
transaction
:
t
});
return
en
}
}
else
{
en
=
await
this
.
model
.
findOne
({
where
:
{
id
:
qobj
.
id
}
});
en
=
await
this
.
model
.
findOne
({
where
:
{
id
:
qobj
.
id
}
});
if
(
en
!=
null
)
{
return
en
.
destroy
();
}
...
...
@@ -202,16 +200,16 @@ class Dao {
}
async
updateByWhere
(
setObj
,
whereObj
,
t
)
{
let
inWhereObj
=
{}
let
inWhereObj
=
{}
if
(
t
&&
t
!=
'undefined'
)
{
if
(
whereObj
&&
whereObj
!=
'undefined'
)
{
inWhereObj
[
"where"
]
=
whereObj
;
inWhereObj
[
"where"
]
=
whereObj
;
inWhereObj
[
"transaction"
]
=
t
;
}
else
{
inWhereObj
[
"transaction"
]
=
t
;
}
}
else
{
inWhereObj
[
"where"
]
=
whereObj
;
}
else
{
inWhereObj
[
"where"
]
=
whereObj
;
}
return
this
.
model
.
update
(
setObj
,
inWhereObj
);
}
...
...
@@ -257,13 +255,13 @@ class Dao {
if
(
includeObj
!=
null
&&
includeObj
.
length
>
0
)
{
tmpWhere
.
include
=
includeObj
;
tmpWhere
.
distinct
=
true
;
}
else
{
}
else
{
tmpWhere
.
raw
=
true
;
}
return
await
this
.
model
.
findAndCountAll
(
tmpWhere
);
}
async
findOne
(
obj
)
{
return
this
.
model
.
findOne
({
"where"
:
obj
});
return
this
.
model
.
findOne
({
"where"
:
obj
,
row
:
true
});
}
async
findById
(
oid
)
{
return
this
.
model
.
findById
(
oid
);
...
...
icp-deliver/app/base/db/impl/auth/userDao.js
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
UserDao
extends
Dao
{
constructor
(){
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
UserDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
UserDao
));
}
async
getAuths
(
userid
){
var
self
=
this
;
async
getAuths
(
userid
)
{
var
self
=
this
;
return
this
.
model
.
findOne
({
where
:{
id
:
userid
},
include
:[{
model
:
self
.
db
.
models
.
account
,
attributes
:[
"id"
,
"isSuper"
,
"referrerOnlyCode"
]},
{
model
:
self
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:[
"id"
,
"code"
],
include
:[
{
model
:
self
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:[
"id"
,
"code"
]}
]},
where
:
{
id
:
userid
},
include
:
[{
model
:
self
.
db
.
models
.
account
,
attributes
:
[
"id"
,
"isSuper"
,
"referrerOnlyCode"
]
},
{
model
:
self
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"code"
],
include
:
[
{
model
:
self
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:
[
"id"
,
"code"
]
}
]
},
],
});
}
async
getUserByUsername
(
username
,
appkey
,
t
){
var
app
=
await
this
.
appDao
.
findOne
(
appkey
);
var
tUser
=
await
this
.
model
.
findOne
({
where
:{
userName
:
username
,
app_id
:
app
.
id
},
include
:[{
model
:
this
.
db
.
models
.
app
,
raw
:
true
},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{
model
:
this
.
db
.
models
.
account
,
attributes
:[
"id"
,
"isSuper"
,
"referrerOnlyCode"
],
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:[
"id"
,
"code"
],
include
:[
{
model
:
this
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:[
"id"
,
"code"
],
raw
:
true
}
]},
]},{
transaction
:
t
});
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return
tUser
;
async
getUserByUsername
(
username
,
appkey
,
t
)
{
var
app
=
await
this
.
appDao
.
findOne
(
appkey
);
var
tUser
=
await
this
.
model
.
findOne
({
where
:
{
userName
:
username
,
app_id
:
app
.
id
},
include
:
[{
model
:
this
.
db
.
models
.
app
,
raw
:
true
},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{
model
:
this
.
db
.
models
.
account
,
attributes
:
[
"id"
,
"isSuper"
,
"referrerOnlyCode"
],
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"code"
],
include
:
[
{
model
:
this
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:
[
"id"
,
"code"
],
raw
:
true
}
]
},
]
},
{
transaction
:
t
});
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return
tUser
;
}
async
getUserByOpenId
(
popenid
,
appkey
,
t
){
var
app
=
await
this
.
appDao
.
findOne
(
appkey
);
var
tUser
=
await
this
.
model
.
findOne
({
where
:{
openId
:
popenid
},
include
:[{
model
:
this
.
db
.
models
.
app
,
raw
:
true
},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{
model
:
this
.
db
.
models
.
account
,
attributes
:[
"id"
,
"isSuper"
,
"referrerOnlyCode"
],
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:[
"id"
,
"code"
],
include
:[
{
model
:
this
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:[
"id"
,
"code"
],
raw
:
true
}
]},
]},{
transaction
:
t
});
if
(
tUser
!=
null
){
tUser
=
tUser
.
get
({
plain
:
true
});
tUser
.
partnerinfo
=
await
this
.
partnerinfoDao
.
model
.
findOne
({
where
:{
onlyCode
:
tUser
.
onlyCode
},
raw
:
true
});
}
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return
tUser
;
async
getUserByOpenId
(
popenid
,
appkey
,
t
)
{
var
app
=
await
this
.
appDao
.
findOne
(
appkey
);
var
tUser
=
await
this
.
model
.
findOne
({
where
:
{
openId
:
popenid
},
include
:
[{
model
:
this
.
db
.
models
.
app
,
raw
:
true
},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{
model
:
this
.
db
.
models
.
account
,
attributes
:
[
"id"
,
"isSuper"
,
"referrerOnlyCode"
],
raw
:
true
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"code"
],
include
:
[
{
model
:
this
.
db
.
models
.
product
,
as
:
"Products"
,
attributes
:
[
"id"
,
"code"
],
raw
:
true
}
]
},
]
},
{
transaction
:
t
});
if
(
tUser
!=
null
)
{
tUser
=
tUser
.
get
({
plain
:
true
});
tUser
.
partnerinfo
=
await
this
.
partnerinfoDao
.
model
.
findOne
({
where
:
{
onlyCode
:
tUser
.
onlyCode
},
raw
:
true
});
}
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return
tUser
;
}
async
setAccount
(
user
,
account
,
t
)
{
var
user
=
await
user
.
setAccount
(
account
,{
transaction
:
t
});
return
user
;
async
setAccount
(
user
,
account
,
t
)
{
var
user
=
await
user
.
setAccount
(
account
,
{
transaction
:
t
});
return
user
;
}
async
setApp
(
user
,
app
,
t
)
{
//按照APPId,获取app对象
var
user
=
await
user
.
setApp
(
app
,{
transaction
:
t
});
return
user
;
async
setApp
(
user
,
app
,
t
)
{
//按照APPId,获取app对象
var
user
=
await
user
.
setApp
(
app
,
{
transaction
:
t
});
return
user
;
}
extraModelFilter
(){
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
.
app
,},{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:[
"id"
,
"name"
]}]
};
return
{
"key"
:
"include"
,
"value"
:
[{
model
:
this
.
db
.
models
.
app
,
},
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"name"
]
}]
};
}
extraWhere
(
obj
,
w
,
qc
,
linkAttrs
)
{
if
(
obj
.
bizpath
&&
obj
.
bizpath
!=
""
)
{
if
(
obj
.
bizpath
.
indexOf
(
"tanents_info"
)
>
0
)
{
//说明是超级管理员的查询
w
[
"isAdmin"
]
=
true
;
}
else
{
w
[
"isAdmin"
]
=
false
;
w
[
"company_id"
]
=
obj
.
company_id
;
}
}
if
(
linkAttrs
.
length
>
0
)
{
var
search
=
obj
.
search
;
var
lnkKey
=
linkAttrs
[
0
];
var
strq
=
"$"
+
lnkKey
.
replace
(
"~"
,
"."
)
+
"$"
;
w
[
strq
]
=
{[
this
.
db
.
Op
.
like
]:
"%"
+
search
[
lnkKey
]
+
"%"
};
extraWhere
(
obj
,
w
,
qc
,
linkAttrs
)
{
if
(
obj
.
bizpath
&&
obj
.
bizpath
!=
""
)
{
if
(
obj
.
bizpath
.
indexOf
(
"tanents_info"
)
>
0
)
{
//说明是超级管理员的查询
w
[
"isAdmin"
]
=
true
;
}
else
{
w
[
"isAdmin"
]
=
false
;
w
[
"company_id"
]
=
obj
.
company_id
;
}
}
if
(
linkAttrs
.
length
>
0
)
{
var
search
=
obj
.
search
;
var
lnkKey
=
linkAttrs
[
0
];
var
strq
=
"$"
+
lnkKey
.
replace
(
"~"
,
"."
)
+
"$"
;
w
[
strq
]
=
{
[
this
.
db
.
Op
.
like
]:
"%"
+
search
[
lnkKey
]
+
"%"
};
}
return
w
;
}
return
w
;
}
async
preUpdate
(
u
){
if
(
u
.
roles
&&
u
.
roles
.
length
>=
0
)
{
var
roles
=
await
this
.
db
.
models
.
role
.
findAll
({
where
:{
id
:{[
this
.
db
.
Op
.
in
]:
u
.
roles
}}
});
u
.
roles
=
roles
async
preUpdate
(
u
)
{
if
(
u
.
roles
&&
u
.
roles
.
length
>=
0
)
{
var
roles
=
await
this
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
this
.
db
.
Op
.
in
]:
u
.
roles
}
}
});
u
.
roles
=
roles
}
return
u
;
}
async
update
(
obj
){
var
obj2
=
await
this
.
preUpdate
(
obj
);
await
this
.
model
.
update
(
obj2
,
{
where
:{
id
:
obj2
.
id
}
});
var
user
=
await
this
.
model
.
findOne
({
where
:{
id
:
obj2
.
id
}
});
if
(
obj2
.
roles
)
{
async
update
(
obj
)
{
var
obj2
=
await
this
.
preUpdate
(
obj
);
await
this
.
model
.
update
(
obj2
,
{
where
:
{
id
:
obj2
.
id
}
});
var
user
=
await
this
.
model
.
findOne
({
where
:
{
id
:
obj2
.
id
}
});
if
(
obj2
.
roles
)
{
user
.
setRoles
(
obj2
.
roles
);
}
return
user
;
}
async
findAndCountAll
(
qobj
,
t
)
{
var
users
=
await
super
.
findAndCountAll
(
qobj
,
t
);
async
findAndCountAll
(
qobj
,
t
)
{
var
users
=
await
super
.
findAndCountAll
(
qobj
,
t
);
return
users
;
}
async
preCreate
(
u
){
async
preCreate
(
u
)
{
// var roles=await this.db.models.role.findAll({where:{id:{[this.db.Op.like]:u.roles}}});
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// console.log(roles);
...
...
@@ -112,32 +120,30 @@ class UserDao extends Dao{
// u.roles=roles
return
u
;
}
async
create
(
u
,
t
){
var
self
=
this
;
var
u2
=
await
this
.
preCreate
(
u
);
if
(
t
){
console
.
log
(
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
);
console
.
log
(
u2
);
return
this
.
model
.
create
(
u2
,{
transaction
:
t
}).
then
(
user
=>
{
return
user
;
});
}
else
{
return
this
.
model
.
create
(
u2
).
then
(
user
=>
{
return
user
;
});
}
async
create
(
u
,
t
)
{
var
self
=
this
;
var
u2
=
await
this
.
preCreate
(
u
);
if
(
t
)
{
return
this
.
model
.
create
(
u2
,
{
transaction
:
t
}).
then
(
user
=>
{
return
user
;
});
}
else
{
return
this
.
model
.
create
(
u2
).
then
(
user
=>
{
return
user
;
});
}
}
//修改用户(user表)公司的唯一码
async
putUserCompanyOnlyCode
(
userId
,
company_only_code
,
result
)
{
var
customerObj
=
{
companyOnlyCode
:
company_only_code
};
var
putSqlWhere
=
{
where
:{
id
:
userId
}
};
this
.
updateByWhere
(
customerObj
,
putSqlWhere
);
return
result
;
async
putUserCompanyOnlyCode
(
userId
,
company_only_code
,
result
)
{
var
customerObj
=
{
companyOnlyCode
:
company_only_code
};
var
putSqlWhere
=
{
where
:
{
id
:
userId
}
};
this
.
updateByWhere
(
customerObj
,
putSqlWhere
);
return
result
;
}
}
module
.
exports
=
UserDao
;
module
.
exports
=
UserDao
;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
...
...
icp-deliver/app/base/db/impl/bizchance/bizoptDao.js
0 → 100644
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
BizoptDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
BizoptDao
));
}
extraWhere
(
qobj
,
qw
,
qc
)
{
qc
.
raw
=
true
;
qc
.
where
.
business_type
=
qc
.
where
.
business_type
||
{
[
this
.
db
.
Op
.
in
]:
[
system
.
SERVICECODE
.
EDI
,
system
.
SERVICECODE
.
ICP
]
}
return
qw
;
}
async
findBizAndSheme
(
id
)
{
const
result
=
await
this
.
model
.
findOne
({
where
:
{
id
},
include
:
[
{
model
:
this
.
db
.
models
.
scheme
,
raw
:
false
}
],
raw
:
false
});
return
result
;
}
}
module
.
exports
=
BizoptDao
;
icp-deliver/app/base/db/impl/bizchance/schemeDao.js
0 → 100644
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
SchemeDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
SchemeDao
));
}
}
module
.
exports
=
SchemeDao
;
icp-deliver/app/base/db/impl/bizchance/statuslogDao.js
0 → 100644
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
StatuslogDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
StatuslogDao
));
}
}
module
.
exports
=
StatuslogDao
;
icp-deliver/app/base/db/models/delivery/business_opportunity.js
View file @
ce4c87d3
...
...
@@ -22,10 +22,14 @@ module.exports = (db, DataTypes) => {
allowNull
:
false
,
type
:
DataTypes
.
JSON
},
sour
s
e_number
:
{
// 来源单号 (下单时产生的编号)
sour
c
e_number
:
{
// 来源单号 (下单时产生的编号)
allowNull
:
true
,
type
:
DataTypes
.
STRING
},
source
:
{
// 渠道来源
allowNull
:
false
,
type
:
DataTypes
.
STRING
},
address
:
{
// 区域地址
allowNull
:
false
,
type
:
DataTypes
.
STRING
...
...
icp-deliver/app/base/db/models/delivery/delivery_bill.js
View file @
ce4c87d3
...
...
@@ -10,7 +10,11 @@ module.exports = (db, DataTypes) => {
allowNull
:
false
,
type
:
DataTypes
.
STRING
},
sourse_number
:
{
// 来源单号 (订单编号)
source_number
:
{
// 来源单号 (订单编号)
allowNull
:
false
,
type
:
DataTypes
.
STRING
},
source
:
{
// 渠道来源
allowNull
:
false
,
type
:
DataTypes
.
STRING
},
...
...
icp-deliver/app/base/db/models/delivery/scheme.js
View file @
ce4c87d3
...
...
@@ -28,7 +28,7 @@ module.exports = (db, DataTypes) => {
type
:
DataTypes
.
STRING
},
remark
:
{
//备注
allowNull
:
fals
e
,
allowNull
:
tru
e
,
type
:
DataTypes
.
STRING
}
},
{
...
...
icp-deliver/app/base/db/models/delivery/status_log.js
View file @
ce4c87d3
...
...
@@ -5,7 +5,7 @@ const appconfig = system.getSysConfig();
* 状态流转记录表
*/
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"status
_
log"
,
{
return
db
.
define
(
"statuslog"
,
{
flow_type
:
{
// 流程类型 (商机、方案、交付单)
allowNull
:
false
,
type
:
DataTypes
.
STRING
...
...
icp-deliver/app/base/service/impl/bizchance/bizoptSve.js
0 → 100644
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
moment
=
require
(
"moment"
);
class
BizoptService
extends
ServiceBase
{
constructor
()
{
super
(
"bizchance"
,
ServiceBase
.
getDaoName
(
BizoptService
));
this
.
schemeDao
=
system
.
getObject
(
"db.bizchance.schemeDao"
);
this
.
statuslogDao
=
system
.
getObject
(
"db.bizchance.statuslogDao"
);
}
async
findBizAndSheme
(
pobj
)
{
let
data
=
await
this
.
dao
.
findBizAndSheme
(
pobj
.
id
);
if
(
data
)
{
data
=
JSON
.
parse
(
JSON
.
stringify
(
data
));
let
bussinessData
=
{
id
:
data
.
id
,
demand_code
:
data
.
demand_code
,
business_type
:
data
.
business_type
,
company_name
:
data
.
business_info
.
company
,
customer_name
:
data
.
business_info
.
person
,
customer_number
:
data
.
business_info
.
phone
,
annual_report
:
data
.
business_info
.
annual_report
||
false
,
content
:
data
.
business_info
.
content
,
address
:
data
.
address
,
source
:
data
.
source
,
business_status
:
data
.
business_status
,
source_number
:
data
.
source_number
,
updated_at
:
moment
(
data
.
updated_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
created_at
:
moment
(
data
.
created_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
close_reason
:
data
.
close_reason
};
let
schemeData
=
null
;
if
(
data
.
scheme
)
{
schemeData
=
{
id
:
data
.
scheme
.
id
,
scheme_number
:
data
.
scheme
.
scheme_number
,
status
:
data
.
scheme
.
status
,
address
:
data
.
address
,
reject_reason
:
data
.
scheme
.
reject_reason
||
"无"
,
company_name
:
data
.
scheme
.
scheme_info
.
company
,
address
:
data
.
scheme
.
scheme_info
.
address
,
annual_report
:
data
.
scheme
.
scheme_info
.
annual_report
||
false
,
remark
:
data
.
scheme
.
remark
||
"无"
,
updated_at
:
moment
(
data
.
scheme
.
updated_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
created_at
:
moment
(
data
.
scheme
.
created_at
).
format
(
'YYYY-MM-DD HH:mm:ss'
),
}
}
return
{
bussinessData
,
schemeData
}
}
return
data
}
async
closeBiz
(
pobj
)
{
/**
* 1. 查询 是否有权限
* 2. 判断是否可以关闭
* 3. 更改 商机、方案状态
* 4. 插入更改记录
* 5. TODO:回传给腾讯
*/
const
bizResult
=
await
this
.
dao
.
findOne
({
id
:
pobj
.
bizId
});
if
(
!
bizResult
)
{
throw
new
Error
(
"查不到该商机"
);
}
if
([
system
.
BUSSTATUS
.
CLOSED
,
system
.
BUSSTATUS
.
SUCCESS
].
includes
(
bizResult
.
business_status
))
{
throw
new
Error
(
"此商机状态下不可操作"
);
}
const
schemeResult
=
await
this
.
schemeDao
.
findOne
({
bizopt_id
:
pobj
.
bizId
});
return
this
.
db
.
transaction
(
async
(
t
)
=>
{
await
this
.
dao
.
updateByWhere
({
business_status
:
system
.
BUSSTATUS
.
CLOSED
},
{
id
:
pobj
.
bizId
},
t
);
this
.
statuslogDao
.
create
({
flow_type
:
system
.
FLOWCODE
.
BIZ
,
flow_id
:
pobj
.
bizId
,
status
:
system
.
BUSSTATUS
.
CLOSED
});
if
(
schemeResult
)
{
await
this
.
dao
.
updateByWhere
({
status
:
system
.
SCHEMESTATUS
.
CLOSED
},
{
id
:
schemeResult
.
id
},
t
);
this
.
statuslogDao
.
create
({
flow_type
:
system
.
FLOWCODE
.
SCHEME
,
flow_id
:
schemeResult
.
id
,
status
:
system
.
SCHEMESTATUS
.
CLOSED
});
}
return
"success"
})
}
}
module
.
exports
=
BizoptService
;
icp-deliver/app/base/service/impl/bizchance/schemeSve.js
0 → 100644
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
moment
=
require
(
"moment"
);
class
SchemeService
extends
ServiceBase
{
constructor
()
{
super
(
"bizchance"
,
ServiceBase
.
getDaoName
(
SchemeService
));
this
.
bizoptDao
=
system
.
getObject
(
"db.bizchance.bizoptDao"
);
this
.
statuslogDao
=
system
.
getObject
(
"db.bizchance.statuslogDao"
);
}
async
create
(
data
)
{
// TODO: 权限判断
let
bizData
=
await
this
.
bizoptDao
.
findOne
({
id
:
data
.
bizopt_id
});
if
(
!
bizData
)
{
throw
new
Error
(
"查不到该商机"
);
}
if
([
system
.
BUSSTATUS
.
CLOSED
,
system
.
BUSSTATUS
.
SUCCESS
,
system
.
BUSSTATUS
.
WAITINGCONFIRM
].
includes
(
bizData
.
business_status
))
{
throw
new
Error
(
"此商机状态下不可操作"
);
}
let
schemeData
=
await
this
.
dao
.
findOne
({
bizopt_id
:
data
.
bizopt_id
})
if
(
schemeData
&&
[
system
.
SCHEMESTATUS
.
WAITINGCONFIRM
,
system
.
SCHEMESTATUS
.
CLOSED
].
includes
(
schemeData
.
status
))
{
throw
new
Error
(
"此方案状态下不可操作"
);
}
if
(
!
schemeData
)
{
// TODO: scheme_number 提交到腾讯获取 方案编号
data
.
scheme_number
=
"TX回传"
}
return
this
.
db
.
transaction
(
async
(
t
)
=>
{
/**
* 1. 更改 商机状态
* 2. 查询 是否有方案及方案状态
* 3. 新增 或更改 方案
* 4. 添加 状态记录更改
* TODO:5. 传给腾讯状态
*/
try
{
await
this
.
bizoptDao
.
updateByWhere
({
business_status
:
system
.
BUSSTATUS
.
WAITINGCONFIRM
},
{
id
:
data
.
bizopt_id
},
t
);
this
.
statuslogDao
.
create
({
flow_type
:
system
.
FLOWCODE
.
BIZ
,
flow_id
:
data
.
bizopt_id
,
status
:
system
.
BUSSTATUS
.
WAITINGCONFIRM
});
let
scheme_id
=
null
;
if
(
schemeData
)
{
await
this
.
dao
.
updateByWhere
({
...
data
,
demand_code
:
bizData
.
demand_code
,
status
:
system
.
SCHEMESTATUS
.
WAITINGCONFIRM
},
{
id
:
schemeData
.
id
},
t
);
scheme_id
=
schemeData
.
id
}
else
{
let
schemeResult
=
await
this
.
dao
.
create
({
...
data
,
demand_code
:
bizData
.
demand_code
,
status
:
system
.
SCHEMESTATUS
.
WAITINGCONFIRM
,
bizopt_id
:
data
.
bizopt_id
},
t
);
scheme_id
=
schemeResult
.
id
;
}
this
.
statuslogDao
.
create
({
flow_type
:
system
.
FLOWCODE
.
SCHEME
,
flow_id
:
scheme_id
,
status
:
system
.
SCHEMESTATUS
.
WAITINGCONFIRM
});
return
{
bizId
:
data
.
bizopt_id
};
}
catch
(
err
)
{
console
.
log
(
err
)
}
});
}
}
module
.
exports
=
SchemeService
;
icp-deliver/app/base/service/impl/cms/articleSve.js
View file @
ce4c87d3
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
class
ArticleService
extends
ServiceBase
{
constructor
(){
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
class
ArticleService
extends
ServiceBase
{
constructor
()
{
super
(
ServiceBase
.
getDaoName
(
ArticleService
));
this
.
newschannelDao
=
system
.
getObject
(
"db.newschannelDao"
);
this
.
newschannelDao
=
system
.
getObject
(
"db.newschannelDao"
);
}
//获取频道列表
async
findChannel
(
obj
){
async
findChannel
(
obj
)
{
// const apps=await super.findAndCountAll(obj);
var
usageType
=
obj
.
usageType
;
if
(
usageType
==
null
||
usageType
==
""
||
usageType
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
if
(
usageType
==
null
||
usageType
==
""
||
usageType
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
}
try
{
var
sqlwhere
=
{
where
:
{
usageType
:
usageType
},
where
:
{
usageType
:
usageType
},
attributes
:
[
"id"
,
"code"
,
"title"
,
"bgimg"
,
"isPubed"
,
"usageType"
,
"app_id"
],
order
:
[[
"orderNo"
,
'ASC'
]],
raw
:
true
};
var
list
=
await
this
.
newschannelDao
.
model
.
findAll
(
sqlwhere
);
if
(
list
==
null
||
list
.
length
==
0
)
{
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
}
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
}
//获取该频道所有列表
async
findAndCountAll2
(
obj
){
async
findAndCountAll2
(
obj
)
{
// const apps=await super.findAndCountAll(obj);
var
newschannel
=
obj
.
newschannel_id
;
var
pageSize
=
obj
.
page_size
;
var
currentPage
=
obj
.
current_page
;
if
(
newschannel
==
null
||
newschannel
==
""
||
newschannel
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
var
pageSize
=
obj
.
page_size
;
var
currentPage
=
obj
.
current_page
;
if
(
newschannel
==
null
||
newschannel
==
""
||
newschannel
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
}
if
(
pageSize
==
null
||
pageSize
==
""
||
pageSize
==
"undefined"
)
{
pageSize
=
""
;
if
(
pageSize
==
null
||
pageSize
==
""
||
pageSize
==
"undefined"
)
{
pageSize
=
""
;
}
if
(
currentPage
==
null
||
currentPage
==
""
||
currentPage
==
"undefined"
)
{
currentPage
=
""
;
if
(
currentPage
==
null
||
currentPage
==
""
||
currentPage
==
"undefined"
)
{
currentPage
=
""
;
}
try
{
var
sqlwhere
=
{
where
:
{
newschannel_id
:
newschannel
},
attributes
:
[
"id"
,
"code"
,
"title"
,
"listimg"
,
"videourl"
,
"desc"
,
"mediaType"
,
"usageType"
,
"test"
,
"newschannel_id"
,
"app_id"
],
where
:
{
newschannel_id
:
newschannel
},
attributes
:
[
"id"
,
"code"
,
"title"
,
"listimg"
,
"videourl"
,
"desc"
,
"mediaType"
,
"usageType"
,
"test"
,
"newschannel_id"
,
"app_id"
],
order
:
[[
"orderNo"
,
'ASC'
]],
raw
:
true
};
if
(
pageSize
!=
""
&&
currentPage
!=
""
)
{
var
tPageSize
=
Number
(
pageSize
);
var
tCurrentPage
=
Number
(
currentPage
);
if
(
tCurrentPage
<
1
)
{
tCurrentPage
=
1
;
if
(
pageSize
!=
""
&&
currentPage
!=
""
)
{
var
tPageSize
=
Number
(
pageSize
);
var
tCurrentPage
=
Number
(
currentPage
);
if
(
tCurrentPage
<
1
)
{
tCurrentPage
=
1
;
}
if
(
tPageSize
>
50
)
{
tPageSize
=
50
;
if
(
tPageSize
>
50
)
{
tPageSize
=
50
;
}
if
(
tPageSize
<
1
)
{
tPageSize
=
1
;
if
(
tPageSize
<
1
)
{
tPageSize
=
1
;
}
sqlwhere
.
limit
=
tPageSize
;
sqlwhere
.
offset
=
(
tCurrentPage
-
1
)
*
tPageSize
;
sqlwhere
.
limit
=
tPageSize
;
sqlwhere
.
offset
=
(
tCurrentPage
-
1
)
*
tPageSize
;
}
var
list
=
await
this
.
dao
.
model
.
findAll
(
sqlwhere
);
if
(
list
==
null
||
list
.
length
==
0
)
{
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
}
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
// apps.forEach(a=>{
// if(a.content && a.content!=""){
...
...
@@ -96,30 +96,30 @@ class ArticleService extends ServiceBase{
}
//获取详细信息
async
findArticle
(
obj
){
async
findArticle
(
obj
)
{
// const apps=await super.findAndCountAll(obj);
var
id
=
obj
.
id
;
if
(
id
==
null
||
id
==
""
||
id
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
if
(
id
==
null
||
id
==
""
||
id
==
"undefined"
)
{
return
{
code
:
-
101
,
msg
:
"参数有误"
,
data
:
null
};
}
try
{
var
sqlwhere
=
{
where
:
{
id
:
id
},
attributes
:
[
"id"
,
"code"
,
"title"
,
"listimg"
,
"videourl"
,
"desc"
,
"content"
,
"mediaType"
,
"usageType"
,
where
:
{
id
:
id
},
attributes
:
[
"id"
,
"code"
,
"title"
,
"listimg"
,
"videourl"
,
"desc"
,
"content"
,
"mediaType"
,
"usageType"
,
"test"
,
"app_id"
],
order
:
[[
"created_at"
,
'desc'
]],
raw
:
true
};
var
list
=
await
this
.
dao
.
model
.
findOne
(
sqlwhere
);
if
(
list
==
null
||
list
.
length
==
0
)
{
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
return
{
code
:
0
,
msg
:
"没有信息"
,
data
:
null
};
}
else
{
return
{
code
:
1
,
msg
:
"操作成功"
,
data
:
list
};
}
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
catch
(
e
)
{
return
{
code
:
-
1
,
msg
:
"操作失败"
,
data
:
null
};
}
}
}
module
.
exports
=
ArticleService
;
module
.
exports
=
ArticleService
;
icp-deliver/app/base/system.js
View file @
ce4c87d3
...
...
@@ -275,6 +275,42 @@ Date.prototype.Format = function (fmt) { //author: meizz
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
return
fmt
;
}
/**
* 常用 ENUM
*/
// 表分类
System
.
FLOWCODE
=
{
"BIZ"
:
"BIZ"
,
//商机表
"SCHEME"
:
"SCHEME"
,
//方案表
"DELIVERY"
:
"DELIVERY"
//服务单表
}
// 服务名称
System
.
SERVICECODE
=
{
ICP
:
"ICP"
,
EDI
:
'EDI'
}
// 商机状态
System
.
BUSSTATUS
=
{
WAITINGSCHEME
:
"beforeSubmission"
,
//待业务员响应
WAITINGCONFIRM
:
"beforeConfirmation"
,
//待用户确认
SUCCESS
:
"isFinished"
,
//已确认
CLOSED
:
"isClosed"
//需求关闭
}
// 方案状态
System
.
SCHEMESTATUS
=
{
WAITINGCONFIRM
:
"beforeConfirmation"
,
//待用户确认.
CLOSED
:
"isClosed"
,
//方案关闭
REJECT
:
"isReject"
//方案被拒绝
}
// 服务单状态
System
.
SERVERSESTATUS
=
{
}
/*
编码说明,
1000----1999 为请求参数验证和app权限验证
...
...
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