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
9a97377b
Commit
9a97377b
authored
Jun 11, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tool gjj loan measure fix
parent
f8ba1310
Pipeline
#8726
passed with stage
in 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
0 deletions
+113
-0
tool.js
app/service/house/v2/tool.js
+113
-0
No files found.
app/service/house/v2/tool.js
0 → 100644
View file @
9a97377b
'use strict'
;
const
Service
=
require
(
'egg'
).
Service
;
class
ToolService
extends
Service
{
async
getNewHouseMapPoint
(
area_code
,
level
)
{
const
{
ctx
}
=
this
;
let
map_points
=
[];
if
(
level
==
1
)
{
map_points
=
await
ctx
.
blockModel
.
HouseNewHousePriceMap
.
all
({
where
:
{
pid
:
area_code
}
});
}
else
{
map_points
=
await
ctx
.
blockModel
.
HouseNewHousePriceMap2
.
all
({
where
:
{
pid
:
area_code
}
});
}
if
(
!
map_points
||
map_points
.
length
===
0
)
{
return
[];
//sdfsfsfs
}
const
ret
=
[];
for
(
let
i
in
map_points
)
{
const
item
=
map_points
[
i
];
if
((
'price'
in
item
)
&&
!
item
.
price
)
{
continue
;
}
if
((
'count'
in
item
)
&&
!
item
.
count
)
{
continue
;
}
ret
.
push
({
id
:
item
.
id
,
name
:
item
.
name
,
longitude
:
item
.
longitude
,
latitude
:
item
.
latitude
,
price
:
item
.
price
,
count
:
item
.
count
,
unit
:
item
.
unit
||
'个楼盘'
,
level
,
});
}
return
ret
;
}
async
getUsedHouseMapPoint
(
area_code
,
level
)
{
const
{
ctx
}
=
this
;
let
map_points
=
[];
if
(
level
==
1
)
{
map_points
=
await
ctx
.
blockModel
.
HousePriceMap
.
all
({
where
:
{
pid
:
area_code
}
});
}
else
if
(
level
==
2
)
{
map_points
=
await
ctx
.
blockModel
.
HousePriceMap2
.
all
({
where
:
{
pid
:
area_code
}
});
}
else
{
map_points
=
await
ctx
.
blockModel
.
HousePriceMap3
.
all
({
where
:
{
pid
:
area_code
}
});
}
if
(
!
map_points
||
map_points
.
length
===
0
)
{
return
[];
}
const
ret
=
[];
for
(
let
i
in
map_points
)
{
const
item
=
map_points
[
i
];
if
((
'price'
in
item
)
&&
!
item
.
price
)
{
continue
;
}
ret
.
push
({
id
:
item
.
id
,
name
:
item
.
name
,
longitude
:
item
.
longitude
,
latitude
:
item
.
latitude
,
price
:
item
.
price
,
unit
:
item
.
unit
||
'元/平'
,
level
,
});
}
return
ret
;
}
async
generateHousePlan
(
input
)
{
const
{
ctx
}
=
this
;
const
down_payment
=
input
.
down_payment
||
0
;
//首付金额
const
invest_payment
=
input
.
invest_payment
||
0
;
//投资金额
const
prepare_time
=
input
.
prepare_time
||
6
;
const
balance
=
down_payment
-
invest_payment
;
let
notice
=
''
;
let
status
=
0
;
let
invest_items
=
[];
if
(
balance
<
0
)
{
status
=
2
;
//完全有能力买到房
notice
=
'您的资金已满足本项目首付条件,还有更多项目在您预算范围内。一键预约,轻松看房!'
;
return
{
status
,
notice
,
invest_items
};
}
const
rate
=
balance
/
invest_payment
;
if
(
rate
>=
0.5
)
{
status
=
0
;
//完全没有希望能买到房
notice
=
'非常遗憾,您的首付预算距离购买该项目尚有较大差距,您可以选择以下方案:'
;
}
else
{
status
=
1
;
//j加把劲还是有希望买到房
notice
=
'恭喜您!依据以上计划,您即将完成XXX项目首付款准备。您现阶段首付预算可以购买以下项目房源:'
;
const
invest_plans
=
await
ctx
.
blockModel
.
HouseInvestPlan
.
one
({
where
:
{
condition_min
:
{
$lt
:
rate
},
condition_max
:
{
$gte
:
rate
},
status
:
'online'
,
valid
:
1
,
period
:
prepare_time
}
});
if
(
Object
.
keys
(
invest_plans
).
length
!==
0
&&
invest_plans
.
items
)
{
invest_items
=
invest_plans
.
items
;
}
}
return
{
status
,
notice
,
invest_items
};
}
}
module
.
exports
=
ToolService
;
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