Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
6b9bafd0
Commit
6b9bafd0
authored
Sep 06, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
order fix
parent
5f254f75
Pipeline
#13478
passed with stage
in 31 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
9 deletions
+57
-9
callrisk.js
app/service/credit/callrisk.js
+6
-1
order.js
app/service/credit/order.js
+51
-8
No files found.
app/service/credit/callrisk.js
View file @
6b9bafd0
...
...
@@ -26,6 +26,8 @@ class CallriskService extends Service {
const
report
=
await
this
.
formatReport
();
const
ret
=
await
this
.
formatHeadExplainMsg
(
report
);
return
ret
;
}
...
...
@@ -38,18 +40,21 @@ class CallriskService extends Service {
if
(
!
basics
||
!
basics
.
id
)
{
ctx
.
failed
(
'error report_id'
);
}
const
report_id
=
basics
.
id
;
const
call_overview
=
await
this
.
getCallOverview
(
report_id
);
const
call_type
=
await
this
.
getCallType
(
report_id
);
const
call_active
=
await
this
.
getCallActive
(
report_id
);
const
call_behavior
=
await
this
.
getCallBehavior
(
report_id
);
//订单是否在有效期内
const
report_valid
=
await
ctx
.
service
.
credit
.
order
.
getReportValid
(
2
,
report_id
);
const
report
=
{
basics
:
{
data
:
basics
},
call_overview
:
{
data
:
call_overview
},
call_type
:
{
data
:
call_type
},
call_active
:
{
data
:
call_active
},
call_behavior
:
{
data
:
call_behavior
},
report_valid
,
};
const
ret
=
this
.
formatHeadExplainMsg
(
report
);
...
...
app/service/credit/order.js
View file @
6b9bafd0
...
...
@@ -11,6 +11,7 @@ class OrderService extends Service {
async
getHistoryOrders
(
order_type
)
{
const
{
ctx
}
=
this
;
const
type_obj
=
{
'blacklist'
:
1
,
'callrisk'
:
2
,
...
...
@@ -21,24 +22,25 @@ class OrderService extends Service {
const
order_records
=
await
ctx
.
prometheusModel
.
CreditOrder
.
all
({
where
:
{
type
}
});
const
worth_h
=
[];
const
worth_l
=
[];
const
worth_time
=
type
===
1
?
15
:
30
;
const
now_time
=
moment
().
valueOf
();
for
(
let
i
in
order_records
)
{
const
order
=
order_records
[
i
];
const
expire_time
=
moment
(
order
.
state_time
).
valueOf
()
+
worth_time
*
86400
;
const
apply
=
{
phone
:
'15968762898'
,
report_no
:
'51gjj201909050100001'
};
const
order
=
await
this
.
updateOrderState
(
order_records
[
i
]);
if
(
order
.
state
===
'已失效'
)
continue
;
const
is_expire
=
await
this
.
checkOrderExpire
(
order
);
const
apply
=
{
phone
:
'15968762898'
,
report_no
:
'51gjj201909050100001'
};
//TODO query apply
const
item
=
{
order_id
:
order
.
id
,
order_no
:
order
.
order_no
,
report_id
:
apply
.
report_id
,
type
:
order_type
,
created_time
:
order
.
created_
time
,
created_time
:
order
.
created_
at
,
phone
:
apply
.
phone
.
replace
(
apply
.
phone
.
substring
(
3
,
7
),
"****"
),
state
:
order
.
state
,
state_text
:
order
.
state
===
'已支付'
?
''
:
order
.
state
,
};
if
(
order
.
pay_status
===
1
&&
order
.
state
===
'已支付'
&&
expire_time
>
now_tim
e
)
{
if
(
is_expir
e
)
{
worth_h
.
push
(
item
);
}
else
{
worth_l
.
push
(
item
);
...
...
@@ -48,6 +50,47 @@ class OrderService extends Service {
return
{
worth_h
,
worth_l
}
}
//更新订单状态
async
updateOrderState
(
order
)
{
const
{
ctx
}
=
this
;
const
{
id
,
created_at
,
state
,
pay_status
}
=
order
;
if
(
!
id
||
!
created_at
||
!
state
||
typeof
(
pay_status
)
===
'undefined'
)
{
return
order
;
}
const
expire_time
=
moment
(
created_at
).
valueOf
()
+
24
*
3600
;
const
now_time
=
moment
().
valueOf
();
const
state_time
=
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
);
if
(
expire_time
<
now_time
&&
state
===
'待支付'
&&
pay_status
===
0
)
{
const
ret
=
await
ctx
.
prometheusModel
.
CreditOrder
.
update
({
state
:
'已失效'
,
state_time
:
state_time
},
{
where
:
{
id
}
});
if
(
ret
||
ret
[
0
])
{
order
.
state
=
'已失效'
;
order
.
state_time
=
state_time
;
}
}
return
order
;
}
//检查订单报告是否 还在规定的时间内 是否具有高价值 0:具有高价值 1:生成时间过长-低价值
async
checkOrderExpire
(
order
)
{
const
{
ctx
}
=
this
;
const
{
id
,
type
,
state_time
,
state
,
pay_status
}
=
order
;
if
(
!
id
||
!
type
||
!
state_time
||
!
state
||
typeof
(
pay_status
)
===
'undefined'
)
{
return
0
;
}
const
worth_time
=
type
===
1
?
15
:
30
;
const
expire_time
=
moment
(
state_time
).
valueOf
()
+
worth_time
*
86400
;
const
now_time
=
moment
().
valueOf
();
if
(
pay_status
===
1
&&
state
===
'已支付'
&&
expire_time
>
now_time
)
{
//还在规定的有效期内 高价值报告
return
0
;
}
return
1
;
}
/**
*
* @param {*} type 报告类型(黑名单1通话2)
...
...
@@ -69,7 +112,7 @@ class OrderService extends Service {
};
let
orderInfo
=
await
ctx
.
prometheusModel
.
CreditOrder
.
findOne
(
orderFilter
);
if
(
orderInfo
!=
null
)
{
if
(
orderInfo
.
state
===
'已支付'
&&
moment
(
orderInfo
.
state_time
).
add
(
timeLine
,
'days'
).
format
(
'YYYY-MM-DD HH:
ii:ss'
)
>
moment
().
format
(
'YYYY-MM-DD HH:ii
:ss'
))
{
if
(
orderInfo
.
state
===
'已支付'
&&
moment
(
orderInfo
.
state_time
).
add
(
timeLine
,
'days'
).
format
(
'YYYY-MM-DD HH:
mm:ss'
)
>
moment
().
format
(
'YYYY-MM-DD HH:mm
:ss'
))
{
valid
=
1
;
}
}
...
...
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