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
a484205f
Commit
a484205f
authored
Jun 18, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
48567aef
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
250 additions
and
18 deletions
+250
-18
ic-deliver/app/base/api/api.base.js
+31
-18
ic-deliver/app/base/api/impl/bizDeliver/bizChance.js
+68
-0
ic-deliver/app/base/api/impl/bizDeliver/deliver.js
+68
-0
ic-deliver/app/base/service/impl/bizchance/bizoptSve.js
+30
-0
ic-deliver/app/base/service/impl/bizchance/deliverybillSve.js
+53
-0
No files found.
ic-deliver/app/base/api/api.base.js
View file @
a484205f
const
system
=
require
(
"../system"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
settings
=
require
(
"../../config/settings"
);
class
APIBase
{
class
APIBase
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
async
setContextParams
(
pobj
,
qobj
,
req
)
{
let
custtags
=
req
.
headers
[
"x-consumetag"
]?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
):
null
;
let
custtags
=
req
.
headers
[
"x-consumetag"
]
?
req
.
headers
[
"x-consumetag"
].
split
(
"|"
)
:
null
;
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req
.
xctx
=
{
appkey
:
req
.
headers
[
"xappkey"
],
//用于系统管理区分应用,比如角色
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]:
null
,
password
:
custtags
?
custtags
[
1
].
split
(
"_"
)[
1
]:
null
,
companyid
:
custtags
?
custtags
[
0
].
split
(
"_"
)[
1
]
:
null
,
password
:
custtags
?
custtags
[
1
].
split
(
"_"
)[
1
]
:
null
,
username
:
req
.
headers
[
"x-consumer-username"
],
userid
:
req
.
headers
[
"x-consumer-custom-id"
],
credid
:
req
.
headers
[
"x-credential-identifier"
],
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
companykey
:
req
.
headers
[
"x-company-key"
],
//专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath
:
req
.
headers
[
'xopath'
],
ptags
:
req
.
headers
[
'xptags'
],
}
if
(
!
req
.
xctx
.
appkey
){
return
[
-
200
,
"请求头缺少应用x-app-key"
]
}
else
{
let
app
=
await
this
.
cacheManager
[
"AppCache"
].
cache
(
req
.
xctx
.
appkey
);
req
.
xctx
.
appid
=
app
.
id
;
pobj
.
app_id
=
app
.
id
;
//传递参数对象里注入app_id
//添加组织结构路径,如果是上级,取上级
if
(
req
.
xctx
.
ptags
&&
req
.
xctx
.
ptags
!=
""
)
{
pobj
.
opath
=
req
.
xctx
.
ptags
}
else
{
pobj
.
opath
=
req
.
xctx
.
opath
}
if
(
req
.
xctx
.
userid
)
{
//在请求传递数据对象注入公司id
pobj
.
userid
=
req
.
xctx
.
userid
;
pobj
.
username
=
req
.
xctx
.
username
}
if
(
!
req
.
xctx
.
appkey
)
{
return
[
-
200
,
"请求头缺少应用x-app-key"
]
}
else
{
// let app = await this.cacheManager["AppCache"].cache(req.xctx.appkey);
// req.xctx.appid = app.id;
// pobj.app_id = app.id;//传递参数对象里注入app_id
}
//平台注册时,companyid,companykey都为空
//自由注册时,companykey不能为空
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
companykey
)
{
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
companykey
);
req
.
xctx
.
companyid
=
comptmp
.
id
;
if
(
!
req
.
xctx
.
companyid
&&
req
.
xctx
.
companykey
)
{
let
comptmp
=
await
this
.
cacheManager
[
"CompanyCache"
].
cache
(
req
.
xctx
.
companykey
);
req
.
xctx
.
companyid
=
comptmp
.
id
;
}
if
(
req
.
xctx
.
companyid
)
{
//在请求传递数据对象注入公司id
pobj
.
company_id
=
req
.
xctx
.
companyid
;
if
(
req
.
xctx
.
companyid
)
{
//在请求传递数据对象注入公司id
pobj
.
company_id
=
req
.
xctx
.
companyid
;
}
}
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
if
(
xarg
&&
xarg
[
0
]
<
0
)
{
let
xarg
=
await
this
.
setContextParams
(
pobj
,
query
,
req
);
if
(
xarg
&&
xarg
[
0
]
<
0
)
{
return
system
.
getResultFail
(...
xarg
);
}
...
...
ic-deliver/app/base/api/impl/bizDeliver/bizChance.js
0 → 100644
View file @
a484205f
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
BizChanceAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
bizChanceS
=
system
.
getObject
(
"service.bizchance.bizoptSve"
)
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async
statBizChance
(
p
,
q
,
req
){
let
companyId
=
p
.
company_id
let
userid
=
p
.
userid
let
username
=
p
.
username
let
opath
=
p
.
opath
let
rtn
=
await
this
.
bizChanceS
.
statBizChance
(
companyId
,
opath
,
username
,
userid
)
return
system
.
getResult
(
rtn
)
}
classDesc
()
{
return
{
groupName
:
"auth"
,
groupDesc
:
"认证相关的包"
,
name
:
"AccessAuthAPI"
,
desc
:
"关于认证的类"
,
exam
:
`
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`
,
};
}
methodDescs
()
{
return
[
{
methodDesc
:
"生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中"
,
methodName
:
"getAccessKey"
,
paramdescs
:
[
{
paramDesc
:
"访问appkey"
,
paramName
:
"appkey"
,
paramType
:
"string"
,
defaultValue
:
""
,
},
{
paramDesc
:
"访问secret"
,
paramName
:
"secret"
,
paramType
:
"string"
,
defaultValue
:
""
,
}
],
rtnTypeDesc
:
"返回JSON对象字符串"
,
rtnType
:
"json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam
()
{
return
``
}
}
module
.
exports
=
BizChanceAPI
;
ic-deliver/app/base/api/impl/bizDeliver/deliver.js
0 → 100644
View file @
a484205f
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
BizDeliverAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
bizDeliveryS
=
system
.
getObject
(
"service.bizchance.deliverybillSve"
)
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async
statBizDelivery
(
p
,
q
,
req
){
let
companyId
=
p
.
company_id
let
userid
=
p
.
userid
let
username
=
p
.
username
let
opath
=
p
.
opath
let
rtn
=
await
this
.
bizDeliveryS
.
statBizDelivery
(
companyId
,
opath
,
username
,
userid
)
return
system
.
getResult
(
rtn
)
}
classDesc
()
{
return
{
groupName
:
"auth"
,
groupDesc
:
"认证相关的包"
,
name
:
"AccessAuthAPI"
,
desc
:
"关于认证的类"
,
exam
:
`
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`
,
};
}
methodDescs
()
{
return
[
{
methodDesc
:
"生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中"
,
methodName
:
"getAccessKey"
,
paramdescs
:
[
{
paramDesc
:
"访问appkey"
,
paramName
:
"appkey"
,
paramType
:
"string"
,
defaultValue
:
""
,
},
{
paramDesc
:
"访问secret"
,
paramName
:
"secret"
,
paramType
:
"string"
,
defaultValue
:
""
,
}
],
rtnTypeDesc
:
"返回JSON对象字符串"
,
rtnType
:
"json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam
()
{
return
``
}
}
module
.
exports
=
BizDeliverAPI
;
ic-deliver/app/base/service/impl/bizchance/bizoptSve.js
View file @
a484205f
...
...
@@ -6,6 +6,36 @@ class BizOptService extends ServiceBase {
constructor
()
{
super
(
"bizchance"
,
ServiceBase
.
getDaoName
(
BizOptService
));
}
/**
* 公司id,平台公司ID为1
* @param {*} companyId
* @param {*} opath
* @param {*} username
* @param {*} userid
*/
async
statBizChance
(
companyId
,
opath
,
username
,
userid
){
//如果当前登录人是平台,返回所有商机
let
waittoHandledCount
=
0
let
handlingCount
=
0
let
finishedCount
=
0
let
closedCount
=
0
if
(
companyId
==
1
){
waittoHandledCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'beforeSubmission'
}})
handlingCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'beforeConfirmation'
}})
finishedCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'isFinished'
}})
closedCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'isClosed'
}})
}
else
{
waittoHandledCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'beforeSubmission'
,
salesman_opcode
:
opath
}})
handlingCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'beforeConfirmation'
,
salesman_opcode
:
opath
}})
finishedCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'isFinished'
,
salesman_opcode
:
opath
}})
closedCount
=
await
this
.
dao
.
findCount
({
where
:{
business_status
:
'isClosed'
,
salesman_opcode
:
opath
}})
}
//成单率
let
allChance
=
waittoHandledCount
+
handlingCount
+
finishedCount
+
closedCount
let
successRadio
=
Math
.
ceil
((
finishedCount
/
allChance
)
*
100
)
//如果当前登录人不是平台,那么需要按照opath查询
return
{
waittoHandledCount
:
waittoHandledCount
,
handlingCount
:
handlingCount
,
finishedCount
:
finishedCount
,
closedCount
:
closedCount
,
successRadio
:
successRadio
}
}
async
findAndCountAll
(
obj
)
{
var
self
=
this
;
const
apps
=
await
this
.
dao
.
findAndCountAll
(
obj
);
...
...
ic-deliver/app/base/service/impl/bizchance/deliverybillSve.js
View file @
a484205f
...
...
@@ -6,6 +6,59 @@ class DeliverybillService extends ServiceBase {
constructor
()
{
super
(
"bizchance"
,
ServiceBase
.
getDaoName
(
DeliverybillService
));
}
async
statBizDelivery
(
companyId
,
opath
,
username
,
userid
){
//如果当前登录人是平台,返回所有商机
let
waittoHandledCount
=
0
//received
let
handlingCount
=
0
let
finishedCount
=
0
//success
let
closedCount
=
0
//closed
let
toSettle
=
0
let
toSettleAmount
=
0
let
settling
=
0
let
settlingAmount
=
0
let
settled
=
0
let
settledAmount
=
0
if
(
companyId
==
1
){
waittoHandledCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'received'
}})
handlingCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:{[
this
.
db
.
Op
.
notIn
]:[
'received'
,
'success'
,
'closed'
]}}})
finishedCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'success'
}})
closedCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'closed'
}})
toSettle
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'waittosettle'
}})
toSettleAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'waittosettle'
}})
settling
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'settling'
}})
settlingAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'settling'
}})
settled
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'settled'
}})
settledAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'settled'
}})
}
else
{
waittoHandledCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'received'
,
salesman_opcode
:
opath
}})
handlingCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:{[
this
.
db
.
Op
.
notIn
]:[
'received'
,
'success'
,
'closed'
]},
salesman_opcode
:
opath
}})
finishedCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'success'
,
salesman_opcode
:
opath
}})
closedCount
=
await
this
.
dao
.
findCount
({
where
:{
delivery_status
:
'closed'
,
salesman_opcode
:
opath
}})
toSettle
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'waittosettle'
,
salesman_opcode
:
opath
}})
toSettleAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'waittosettle'
,
salesman_opcode
:
opath
}})
settling
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'settling'
,
salesman_opcode
:
opath
}})
settlingAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'settling'
,
salesman_opcode
:
opath
}})
settled
=
await
this
.
dao
.
findCount
({
where
:{
settle_status
:
'settled'
,
salesman_opcode
:
opath
}})
settledAmount
=
await
this
.
dao
.
findSum
(
'cost_price'
,{
where
:{
settle_status
:
'settled'
,
salesman_opcode
:
opath
}})
}
//成单率
let
allHandled
=
finishedCount
+
closedCount
//如果当前登录人不是平台,那么需要按照opath查询
return
{
waittoHandledCount
:
waittoHandledCount
,
handlingCount
:
handlingCount
,
finishedCount
:
finishedCount
,
closedCount
:
closedCount
,
allHandled
:
allHandled
,
toSettle
:
toSettle
,
toSettleAmount
:
toSettleAmount
?
toSettleAmount
:
0
,
settling
:
settling
,
settlingAmount
:
settlingAmount
?
settlingAmount
:
0
,
settled
:
settled
,
settledAmount
:
settledAmount
?
settledAmount
:
0
}
}
async
settleApply
(
ids
,
uid
,
uname
){
var
self
=
this
return
this
.
db
.
transaction
(
async
function
(
t
){
...
...
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