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
027e538b
Commit
027e538b
authored
Mar 16, 2021
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'恒昌小程序导出数据'
parent
241621ec
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
218 additions
and
62 deletions
+218
-62
xgg-web/app/base/db/impl/bmuserbizDao.js
+29
-0
xgg-web/app/base/db/impl/connection.js
+29
-35
xgg-web/app/base/db/metadata/index.js
+1
-1
xgg-web/app/base/service/impl/bmuserbizSve.js
+4
-0
xgg-web/app/base/utils/excelClient.js
+102
-26
xgg-web/app/base/wxapplet/impl/xggApplet.js
+45
-0
xgg-web/app/config/routes/applet.js
+2
-0
xgg-web/app/front/entry/audit_page.ejs
+1
-0
xgg-web/app/front/entry/public/js/audit_page.js
+5
-0
No files found.
xgg-web/app/base/db/impl/bmuserbizDao.js
View file @
027e538b
...
@@ -87,5 +87,34 @@ class BmuserbizDao extends Dao{
...
@@ -87,5 +87,34 @@ class BmuserbizDao extends Dao{
sql
.
push
(
"AND t1.idcard = :idcard"
);
sql
.
push
(
"AND t1.idcard = :idcard"
);
}
}
}
}
async
findExportAll
()
{
let
sql
=
[];
sql
.
push
(
"SELECT "
);
sql
.
push
(
"t1.id,"
);
sql
.
push
(
"t1.legal_name,"
);
sql
.
push
(
"t1.legal_mobile,"
);
sql
.
push
(
"t1.idcard,"
);
sql
.
push
(
"t1.idcard_front,"
);
sql
.
push
(
"t1.idcard_back,"
);
sql
.
push
(
"REPLACE(t1.companyNames, '#com#', ',') AS names,"
);
sql
.
push
(
"t1.bank,"
);
sql
.
push
(
"t1.bankno,"
);
sql
.
push
(
"t1.bank_front,"
);
sql
.
push
(
"t1.bank_back,"
);
sql
.
push
(
"t1.bankMobile,"
);
sql
.
push
(
"t1.`front_half_img`,"
);
sql
.
push
(
"t1.`declaration_file`,"
);
sql
.
push
(
"DATE_FORMAT(t1.created_at, '%Y-%m-%d') AS submit_time,"
);
sql
.
push
(
"CASE t2.audit_status WHEN '0' THEN '待审核' WHEN '1' THEN '审核通过' WHEN '2' THEN '审核失败' ELSE '' END AS audit_status_name,"
);
sql
.
push
(
"t2.reject_reason"
);
sql
.
push
(
"FROM"
);
sql
.
push
(
"`bm_user_biz` t1"
);
sql
.
push
(
"INNER JOIN `bm_order` t2 ON t1.`orderId` = t2.`id`"
);
sql
.
push
(
"WHERE 1 = 1"
);
sql
.
push
(
"ORDER BY id DESC"
);
return
await
this
.
customQuery
(
sql
.
join
(
" "
));
}
}
}
module
.
exports
=
BmuserbizDao
;
module
.
exports
=
BmuserbizDao
;
xgg-web/app/base/db/impl/connection.js
View file @
027e538b
const
Sequelize
=
require
(
'sequelize'
);
const
Sequelize
=
require
(
'sequelize'
);
const
settings
=
require
(
"../../../config/settings"
)
const
settings
=
require
(
"../../../config/settings"
)
const
fs
=
require
(
"fs"
)
const
fs
=
require
(
"fs"
)
const
path
=
require
(
"path"
);
const
path
=
require
(
"path"
);
class
DbFactory
{
class
DbFactory
{
constructor
(){
constructor
()
{
const
dbConfig
=
settings
.
database
();
const
dbConfig
=
settings
.
database
();
this
.
db
=
new
Sequelize
(
dbConfig
.
dbname
,
this
.
db
=
new
Sequelize
(
dbConfig
.
dbname
,
dbConfig
.
user
,
dbConfig
.
user
,
dbConfig
.
password
,
dbConfig
.
password
,
dbConfig
.
config
);
dbConfig
.
config
);
this
.
db
.
Sequelize
=
Sequelize
;
this
.
db
.
Op
=
Sequelize
.
Op
;
this
.
db
.
Sequelize
=
Sequelize
;
this
.
db
.
Op
=
Sequelize
.
Op
;
this
.
initModels
();
this
.
initModels
();
this
.
initRelations
();
this
.
initRelations
();
}
}
async
initModels
(){
async
initModels
()
{
var
self
=
this
;
var
self
=
this
;
var
modelpath
=
path
.
normalize
(
path
.
join
(
__dirname
,
'..'
))
+
"/models/"
;
var
modelpath
=
path
.
normalize
(
path
.
join
(
__dirname
,
'..'
))
+
"/models/"
;
var
models
=
fs
.
readdirSync
(
modelpath
);
var
models
=
fs
.
readdirSync
(
modelpath
);
models
.
forEach
(
function
(
m
)
{
models
.
forEach
(
function
(
m
)
{
self
.
db
.
import
(
modelpath
+
m
);
self
.
db
.
import
(
modelpath
+
m
);
});
});
console
.
log
(
"init models...."
);
console
.
log
(
"init models...."
);
}
}
async
initRelations
(){
async
initRelations
()
{
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立用户和角色之间的关系*/
this
.
db
.
models
.
user
.
belongsToMany
(
this
.
db
.
models
.
role
,
{
as
:
"Roles"
,
through
:
'p_userrole'
,
constraints
:
false
,});
this
.
db
.
models
.
role
.
belongsToMany
(
this
.
db
.
models
.
user
,
{
as
:
"Users"
,
through
:
'p_userrole'
,
constraints
:
false
,});
/*建立频道和文章之间的关系*/
this
.
db
.
models
.
article
.
belongsTo
(
this
.
db
.
models
.
newschannel
,{
constraints
:
false
,});
this
.
db
.
models
.
newschannel
.
hasMany
(
this
.
db
.
models
.
article
,{
constraints
:
false
,});
}
}
//async getCon(){,用于使用替换table模型内字段数据使用
//async getCon(){,用于使用替换table模型内字段数据使用
getCon
()
{
getCon
()
{
var
that
=
this
;
var
that
=
this
;
// await this.db.authenticate().then(()=>{
// await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.');
// console.log('Connection has been established successfully.');
// }).catch(err => {
// }).catch(err => {
...
@@ -49,9 +37,15 @@ class DbFactory{
...
@@ -49,9 +37,15 @@ class DbFactory{
// throw err;
// throw err;
// });
// });
//同步模型
//同步模型
if
(
settings
.
env
==
"dev"
){
if
(
settings
.
env
==
"dev"
)
{}
}
return
this
.
db
;
return
this
.
db
;
}
}
getSettleDBCon
()
{
var
that
=
this
;
if
(
settings
.
env
==
"dev"
)
{}
return
this
.
settledb
;
}
}
}
module
.
exports
=
DbFactory
;
module
.
exports
=
DbFactory
;
xgg-web/app/base/db/metadata/index.js
View file @
027e538b
...
@@ -42,7 +42,7 @@ function initRsTree(appjson,appidfolder,objJson,parentCodePath){
...
@@ -42,7 +42,7 @@ function initRsTree(appjson,appidfolder,objJson,parentCodePath){
}
}
}
}
}
}
fs
.
readdirSync
(
appsPath
,{
withFileTypes
:
true
}
).
forEach
(
f
=>
{
fs
.
readdirSync
(
appsPath
).
forEach
(
f
=>
{
const
ff
=
path
.
join
(
appsPath
,
f
);
const
ff
=
path
.
join
(
appsPath
,
f
);
delete
require
.
cache
[
ff
];
delete
require
.
cache
[
ff
];
var
appJson
=
require
(
ff
);
var
appJson
=
require
(
ff
);
...
...
xgg-web/app/base/service/impl/bmuserbizSve.js
View file @
027e538b
...
@@ -92,6 +92,10 @@ class BmuserbizService extends ServiceBase {
...
@@ -92,6 +92,10 @@ class BmuserbizService extends ServiceBase {
}
}
return
page
;
return
page
;
}
}
async
findExportAll
()
{
return
await
this
.
dao
.
findExportAll
();
}
}
}
module
.
exports
=
BmuserbizService
;
module
.
exports
=
BmuserbizService
;
xgg-web/app/base/utils/excelClient.js
View file @
027e538b
var
excel
=
require
(
'exceljs'
);
var
excel
=
require
(
'exceljs'
);
const
system
=
require
(
"../system"
);
const
system
=
require
(
"../system"
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
uuidv4
=
require
(
'uuid/v4'
);
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
xlsx
=
require
(
'node-xlsx'
)
const
json2csv
=
require
(
'json2csv'
);
class
ExcelClient
{
class
ExcelClient
{
constructor
()
{
constructor
()
{
this
.
columns
=
[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
];
this
.
columns
=
[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
];
this
.
ossClient
=
system
.
getObject
(
"util.ossClient"
);
this
.
ossClient
=
system
.
getObject
(
"util.ossClient"
);
this
.
filedownloadDao
=
system
.
getObject
(
"db.filedownloadDao
"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient
"
);
}
}
async
download
(
params
)
{
async
download
(
params
,
cb
)
{
var
self
=
this
;
var
self
=
this
;
var
title
=
params
.
title
||
""
;
var
title
=
params
.
title
||
""
;
...
@@ -18,49 +19,123 @@ class ExcelClient {
...
@@ -18,49 +19,123 @@ class ExcelClient {
var
fileName
=
params
.
fileName
||
code
+
".xlsx"
;
var
fileName
=
params
.
fileName
||
code
+
".xlsx"
;
var
filePath
=
params
.
filePath
||
"/tmp/"
+
fileName
;
var
filePath
=
params
.
filePath
||
"/tmp/"
+
fileName
;
var
rows
=
params
.
rows
||
[];
var
rows
=
params
.
rows
||
[];
var
user
=
params
.
user
||
{};
var
wb
=
new
excel
.
Workbook
();
var
wb
=
new
excel
.
Workbook
();
wb
.
properties
.
date1904
=
true
;
wb
.
properties
.
date1904
=
true
;
var
sheet
=
wb
.
addWorksheet
(
"sheet1"
);
var
sheet
=
wb
.
addWorksheet
(
"sheet1"
);
var
headers
=
rows
[
0
];
var
headers
=
rows
[
0
];
console
.
log
(
headers
,
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers"
);
console
.
log
(
headers
,
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 headers"
);
if
(
title
)
{
if
(
title
)
{
sheet
.
addRow
([
title
]);
sheet
.
addRow
([
title
]);
sheet
.
getCell
(
"A1"
).
font
=
{
sheet
.
getCell
(
"A1"
).
font
=
{
name
:
'微软雅黑'
,
name
:
'微软雅黑'
,
family
:
4
,
family
:
4
,
size
:
12
,
size
:
12
,
bold
:
true
bold
:
true
};
sheet
.
getCell
(
'A1'
).
alignment
=
{
vertical
:
'middle'
,
horizontal
:
'center'
};
};
sheet
.
getCell
(
'A1'
).
alignment
=
{
vertical
:
'middle'
,
horizontal
:
'center'
};
var
colkey
=
0
;
var
colkey
=
0
;
if
(
headers
.
length
>
0
)
{
if
(
headers
.
length
>
0
)
{
colkey
=
headers
.
length
-
1
;
colkey
=
headers
.
length
-
1
;
}
}
var
endColumn
=
this
.
columns
[
colkey
]
||
"A"
;
var
endColumn
=
this
.
columns
[
colkey
]
||
"A"
;
sheet
.
mergeCells
(
"A1:"
+
endColumn
+
"1"
);
sheet
.
mergeCells
(
"A1:"
+
endColumn
+
"1"
);
}
}
for
(
var
r
of
rows
)
{
for
(
var
r
of
rows
)
{
sheet
.
addRow
(
r
);
sheet
.
addRow
(
r
);
}
}
wb
.
xlsx
.
writeFile
(
filePath
).
then
(
async
function
(
d
)
{
wb
.
xlsx
.
writeFile
(
filePath
).
then
(
async
function
(
d
)
{
var
rtn
=
await
self
.
ossClient
.
upfile
(
fileName
,
filePath
);
var
rtn
=
await
self
.
ossClient
.
upfile
(
fileName
,
filePath
);
fs
.
unlink
(
filePath
,
function
(
err
){});
// fs.unlink(filePath, function (err) {});
var
obj
=
{
fs
.
unlinkSync
(
filePath
);
user_id
:
user
.
id
||
0
,
if
(
cb
)
{
userName
:
user
.
userName
||
""
,
cb
(
rtn
.
url
);
code
:
code
,
}
fileName
:
fileName
,
filePath
:
rtn
.
url
||
""
,
isDownload
:
false
,
}
var
obj
=
await
self
.
filedownloadDao
.
create
(
obj
);
});
});
}
}
async
readExcel
(
id
,
ossurl
)
{
var
result
=
{
code
:
0
,
data
:
[],
};
var
names
=
[];
var
filePath
=
"/tmp/ecompany_contract_"
+
id
+
".xlsx"
;
try
{
await
this
.
restClient
.
execDownload
(
"'"
+
ossurl
+
"'"
,
filePath
);
var
sheets
=
xlsx
.
parse
(
filePath
);
// fs.unlink(filePath, e => {
// console.log("fail");
// });
fs
.
unlinkSync
(
filePath
);
if
(
!
sheets
||
sheets
.
length
==
0
)
{
return
result
;
}
var
sheet
=
sheets
[
0
];
if
(
!
sheet
||
!
sheet
.
data
||
sheet
.
data
.
length
==
0
)
{
return
result
;
}
var
rows
=
sheet
.
data
;
for
(
var
idx
in
rows
)
{
if
(
idx
==
0
)
{
continue
;
}
var
cells
=
rows
[
idx
];
if
(
!
cells
||
cells
.
length
==
0
||
!
cells
[
0
])
{
continue
;
}
var
c
=
cells
[
0
];
if
(
names
.
indexOf
(
c
)
>
-
1
)
{
continue
;
}
names
.
push
(
c
);
}
console
.
log
(
sheet
);
result
.
code
=
1
;
result
.
data
=
names
;
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
.
stack
);
return
result
;
}
}
async
exportCsv
(
req
,
res
,
csvobj
)
{
var
userAgent
=
(
req
.
headers
[
'user-agent'
]
||
''
).
toLowerCase
();
var
fileName
=
csvobj
.
fileName
||
new
Date
().
getTime
();
if
(
userAgent
.
indexOf
(
'msie'
)
>=
0
||
userAgent
.
indexOf
(
'chrome'
)
>=
0
)
{
await
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename='
+
encodeURIComponent
(
fileName
));
}
else
if
(
userAgent
.
indexOf
(
'firefox'
)
>=
0
)
{
await
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename*="utf8
\'\'
'
+
encodeURIComponent
(
fileName
)
+
'"'
);
}
else
{
await
res
.
setHeader
(
'Content-Disposition'
,
'attachment; filename='
+
new
Buffer
(
fileName
).
toString
(
'binary'
));
}
await
res
.
writeHead
(
200
,{
'Content-Type'
:
'application/octet-stream;charset=utf-8'
});
let
csv
=
json2csv
.
parse
(
csvobj
.
rows
,
csvobj
.
opts
);
if
(
csvobj
.
headers
)
{
for
(
var
field
of
csvobj
.
opts
.
fields
)
{
csv
=
csv
.
replace
(
field
,
csvobj
.
headers
[
field
]);
}
}
await
res
.
write
(
"
\
uFEFF"
+
csv
);
await
res
.
write
(
'
\
n'
);
}
}
}
module
.
exports
=
ExcelClient
;
module
.
exports
=
ExcelClient
;
\ No newline at end of file
xgg-web/app/base/wxapplet/impl/xggApplet.js
View file @
027e538b
...
@@ -22,6 +22,7 @@ class xggApplet extends AppletBase {
...
@@ -22,6 +22,7 @@ class xggApplet extends AppletBase {
this
.
uploadCtl
=
system
.
getObject
(
"web.uploadCtl"
);
this
.
uploadCtl
=
system
.
getObject
(
"web.uploadCtl"
);
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
excelClient
=
system
.
getObject
(
"util.excelClient"
);
this
.
merchantId
=
1
;
this
.
merchantId
=
1
;
}
}
...
@@ -569,5 +570,48 @@ class xggApplet extends AppletBase {
...
@@ -569,5 +570,48 @@ class xggApplet extends AppletBase {
return
{
code
:
500
};
return
{
code
:
500
};
}
}
}
}
async
exportAll
(
gobj
,
req
,
res
){
try
{
let
list
=
await
this
.
bmuserbizSve
.
findExportAll
();
let
csvobj
=
{
fileName
:
"恒昌小程序数据"
+
moment
().
format
(
"YYYYMMDDHHmmss"
)
+
".csv"
,
rows
:
list
,
opts
:
{
fields
:
[
'id'
,
'legal_name'
,
'legal_mobile'
,
'idcard'
,
'idcard_front'
,
'idcard_back'
,
'names'
,
'bank'
,
'bankno'
,
'bank_front'
,
'bank_back'
,
'bankMobile'
,
'front_half_img'
,
'declaration_file'
,
'submit_time'
,
'audit_status_name'
,
'reject_reason'
],
unwind
:
[],
unwindBlank
:
true
,
excelStrings
:
true
,
},
headers
:
{
'id'
:
'编号'
,
'legal_name'
:
'姓名'
,
'legal_mobile'
:
'手机号'
,
'idcard'
:
'身份证'
,
'idcard_front'
:
'身份证正面'
,
'idcard_back'
:
'身份证反面'
,
'names'
:
'注册名称'
,
'bank'
:
'开户行'
,
'bankno'
:
'银行卡号'
,
'bank_front'
:
'银行卡正面'
,
'bank_back'
:
'银行卡背面'
,
'bankMobile'
:
'预留手机号'
,
'front_half_img'
:
'半身照'
,
'declaration_file'
:
'声明书'
,
'submit_time'
:
'提交时间'
,
'audit_status_name'
:
'审核状态'
,
'reject_reason'
:
'不通过原因'
,
},
};
await
this
.
excelClient
.
exportCsv
(
req
,
res
,
csvobj
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getErrResult2
(
"您的网络不稳, 请稍后重试"
);
}
}
}
}
module
.
exports
=
xggApplet
;
module
.
exports
=
xggApplet
;
\ No newline at end of file
xgg-web/app/config/routes/applet.js
View file @
027e538b
...
@@ -27,6 +27,7 @@ module.exports = function (app) {
...
@@ -27,6 +27,7 @@ module.exports = function (app) {
}
}
}
}
params
.
push
(
req
);
params
.
push
(
req
);
params
.
push
(
res
);
var
p
=
null
;
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"applet."
+
classPath
);
var
invokeObj
=
System
.
getObject
(
"applet."
+
classPath
);
if
(
invokeObj
[
methodName
])
{
if
(
invokeObj
[
methodName
])
{
...
@@ -65,6 +66,7 @@ module.exports = function (app) {
...
@@ -65,6 +66,7 @@ module.exports = function (app) {
var
cacheManager
=
System
.
getObject
(
"db.cacheManager"
);
var
cacheManager
=
System
.
getObject
(
"db.cacheManager"
);
params
.
push
(
req
);
params
.
push
(
req
);
params
.
push
(
res
);
var
key
=
req
.
body
.
key
;
var
key
=
req
.
body
.
key
;
if
(
key
)
{
if
(
key
)
{
//如果是 创富 merchantId=3 key = merchant_openId
//如果是 创富 merchantId=3 key = merchant_openId
...
...
xgg-web/app/front/entry/audit_page.ejs
View file @
027e538b
...
@@ -228,6 +228,7 @@
...
@@ -228,6 +228,7 @@
<div>
<div>
<div
style=
"line-height: 36px;padding-bottom: 20px;"
>
<div
style=
"line-height: 36px;padding-bottom: 20px;"
>
<span
style=
"float:left;color:#2F2F2F;font-size: 14px;"
>
共{{search.total}}条记录
</span>
<span
style=
"float:left;color:#2F2F2F;font-size: 14px;"
>
共{{search.total}}条记录
</span>
<el-button
@
click=
"exportAll()"
style=
"float:right;width:110px;height:36px;color: #FFFFFF;font-weight: 400;border-radius: 4px;font-size: 14px;background-color: #59C1A6;padding-top:11px"
>
导出全部
</el-button>
</div>
</div>
<div>
<div>
<el-table
<el-table
...
...
xgg-web/app/front/entry/public/js/audit_page.js
View file @
027e538b
...
@@ -135,6 +135,11 @@ var app = new Vue({
...
@@ -135,6 +135,11 @@ var app = new Vue({
self
.
auditLoading
=
false
;
self
.
auditLoading
=
false
;
});
});
},
},
exportAll
(){
console
.
log
(
'export all'
);
window
.
open
(
"/applet/xggApplet/exportAll"
);
},
topic_preview
(
filed
)
{
topic_preview
(
filed
)
{
let
url
=
this
.
auditItem
[
filed
||
""
];
let
url
=
this
.
auditItem
[
filed
||
""
];
if
(
url
)
{
if
(
url
)
{
...
...
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