Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mancheng
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
Administrator
mancheng
Commits
dfe9f4b7
Commit
dfe9f4b7
authored
Apr 04, 2023
by
dong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix20230404
parent
7d25946b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
apps/models.py
+1
-0
apps/view_xiaocx/view.py
+28
-30
No files found.
apps/models.py
View file @
dfe9f4b7
...
...
@@ -1707,6 +1707,7 @@ class CustomerConsultation(db.Model):
__tablename__
=
"customer_consultation"
__table_args__
=
({
'comment'
:
'小程序-客户咨询信息表'
})
# 添加表注释
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
,
comment
=
'主键id'
)
user_id
=
db
.
Column
(
db
.
Integer
,
comment
=
'访客id,属于哪位访客'
)
project_name
=
db
.
Column
(
db
.
String
(
200
),
comment
=
'项目名称'
)
investor
=
db
.
Column
(
db
.
String
(
100
),
comment
=
'投资方名称'
)
investor_place
=
db
.
Column
(
db
.
String
(
100
),
default
=
''
,
comment
=
'投资方所在地'
)
...
...
apps/view_xiaocx/view.py
View file @
dfe9f4b7
...
...
@@ -473,7 +473,7 @@ def company_detail():
# 投资咨询
@api_xiaocx.route
(
'/Consultation'
,
methods
=
[
'POST'
])
#
@login_required
@login_required
def
consultation
():
req_dict
=
request
.
get_json
()
project_name
=
req_dict
.
get
(
"project_name"
)
...
...
@@ -486,8 +486,16 @@ def consultation():
linkman
=
req_dict
.
get
(
"linkman"
)
link_mobile
=
req_dict
.
get
(
"link_mobile"
)
consultation_time
=
datetime
.
datetime
.
now
()
token
=
request
.
headers
[
'token'
]
try
:
user_obj
=
verify_token
(
token
)
flag
=
user_obj
.
flag
user_id
=
user_obj
.
id
except
:
return
jsonify
(
code
=
RET
.
SESSIONERR
,
msg
=
"Query error!"
)
try
:
cons_obj
=
CustomerConsultation
()
cons_obj
.
user_id
=
user_id
cons_obj
.
project_name
=
project_name
cons_obj
.
investor
=
investor
cons_obj
.
investor_place
=
investor_place
...
...
@@ -509,18 +517,27 @@ def consultation():
# 投资咨询信息列表
@api_xiaocx.route
(
'/ConsultationList'
,
methods
=
[
'POST'
])
#
@login_required
@login_required
def
consultation_list
():
req_dict
=
request
.
get_json
()
page
=
req_dict
.
get
(
"page"
)
perpage
=
req_dict
.
get
(
"perpage"
)
token
=
request
.
headers
[
'token'
]
try
:
user_obj
=
verify_token
(
token
)
flag
=
user_obj
.
flag
user_id
=
user_obj
.
id
except
:
return
jsonify
(
code
=
RET
.
SESSIONERR
,
msg
=
"Query error!"
)
try
:
cons_obj_list
=
CustomerConsultation
.
query
.
paginate
(
page
,
perpage
)
.
items
if
flag
==
1
:
# 外部访客智能看到自己的信息
cons_obj_list
=
CustomerConsultation
.
query
.
filter
(
CustomerConsultation
.
user_id
==
user_id
)
.
order_by
(
CustomerConsultation
.
consultation_time
.
desc
())
.
paginate
(
page
,
perpage
)
.
items
else
:
cons_obj_list
=
CustomerConsultation
.
query
.
order_by
(
CustomerConsultation
.
consultation_time
.
desc
())
.
paginate
(
page
,
perpage
)
.
items
cons_count
=
CustomerConsultation
.
query
.
count
()
data_li
=
[]
for
cons_obj
in
cons_obj_list
:
print
(
cons_obj
)
data
=
{
data
=
[{
"id"
:
cons_obj
.
id
,
"project_name"
:
cons_obj
.
project_name
,
"investor"
:
cons_obj
.
investor
,
...
...
@@ -533,31 +550,12 @@ def consultation_list():
"link_mobile"
:
cons_obj
.
link_mobile
,
"flag"
:
cons_obj
.
flag
,
"reply_content"
:
cons_obj
.
reply_content
,
"consultation_time"
:
cons_obj
.
consultation_time
.
strftime
(
"
%
Y-
%
m-
%
d"
)
if
cons_obj
.
consultation_time
else
""
,
# "reply_time": cons_obj.reply_time.strftime("%Y-%m-%d") if cons_obj.reply_time else "",
}
data_li
.
append
(
data
)
# data = [{
# "id": cons_obj.id,
# "project_name": cons_obj.project_name,
# "investor": cons_obj.investor,
# "investor_place": cons_obj.investor_place,
# "project_type": cons_obj.project_type,
# "investment_volume": cons_obj.investment_volume,
# "basic_information": cons_obj.basic_information,
# "land_area": cons_obj.land_area,
# "linkman": cons_obj.linkman,
# "link_mobile": cons_obj.link_mobile,
# "flag": cons_obj.flag,
# "reply_content": cons_obj.reply_content,
# "consultation_time": cons_obj.consultation_time.strftime("%Y-%m-%d") if cons_obj.consultation_time else "",
# "reply_time": cons_obj.reply_time.strftime("%Y-%m-%d") if cons_obj.reply_time else "",
# } for cons_obj in cons_obj_list]
data
=
sorted
(
data_li
,
key
=
lambda
x
:
x
[
"consultation_time"
],
reverse
=
True
)
"consultation_time"
:
cons_obj
.
consultation_time
,
"reply_time"
:
cons_obj
.
reply_time
,
}
for
cons_obj
in
cons_obj_list
]
except
Exception
as
e
:
current_app
.
logger
.
error
(
e
)
return
jsonify
(
code
=
RET
.
SESSION
ERR
,
msg
=
"Query error!"
)
return
jsonify
(
code
=
RET
.
DB
ERR
,
msg
=
"Query error!"
)
return
jsonify
(
code
=
RET
.
OK
,
data
=
{
"data"
:
data
,
"size"
:
cons_count
},
msg
=
'Data query success!'
)
...
...
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