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
7892d432
Commit
7892d432
authored
May 19, 2020
by
zhaoxiqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
a7d0a16c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
189 additions
and
10 deletions
+189
-10
bpo-web/app/base/api/impl/dkcontractApi.js
+6
-0
bpo-web/app/base/api/impl/econtractApi.js
+40
-1
bpo-web/app/base/api/impl/testApi.js
+2
-2
bpo-web/app/base/api/impl/yzcontractApi.js
+10
-1
bpo-web/app/base/db/impl/econtractofflineDao.js
+12
-0
bpo-web/app/base/db/models/econtractoffline.js
+56
-0
bpo-web/app/base/service/impl/econtractofflineSve.js
+52
-0
bpo-web/app/base/utils/redisLock.js
+10
-5
bpo-web/app/config/settings.js
+1
-1
No files found.
bpo-web/app/base/api/impl/dkcontractApi.js
View file @
7892d432
...
...
@@ -2,6 +2,7 @@ var system = require("../../system")
const
md5
=
require
(
"MD5"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
moment
=
require
(
"moment"
);
const
uuidv1
=
require
(
'uuid/v1'
);
class
DKcontractApi
{
constructor
()
{
...
...
@@ -10,6 +11,7 @@ class DKcontractApi {
this
.
esettleSve
=
system
.
getObject
(
"service.esettleSve"
);
this
.
dkcontractSve
=
system
.
getObject
(
"service.dkcontractSve"
);
this
.
etemplatebusiSve
=
system
.
getObject
(
"service.etemplatebusiSve"
);
this
.
redisLock
=
system
.
getObject
(
"util.redisLock"
);
}
async
syncSignedFile
()
{
...
...
@@ -97,7 +99,11 @@ class DKcontractApi {
}
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
dkcontractSve
.
autoSign
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
bpo-web/app/base/api/impl/econtractApi.js
View file @
7892d432
...
...
@@ -2,7 +2,7 @@ var system = require("../../system")
const
md5
=
require
(
"MD5"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
moment
=
require
(
"moment"
);
const
uuidv1
=
require
(
'uuid/v1'
);
class
EcontractApi
{
constructor
()
{
this
.
ecompanySve
=
system
.
getObject
(
"service.ecompanySve"
);
...
...
@@ -26,6 +26,9 @@ class EcontractApi {
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
smsS
=
system
.
getObject
(
"util.smsClient"
);
this
.
econtractofflineSve
=
system
.
getObject
(
"service.econtractofflineSve"
);
this
.
redisLock
=
system
.
getObject
(
"util.redisLock"
);
}
async
syncSignedFile
()
{
...
...
@@ -970,7 +973,11 @@ class EcontractApi {
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSign
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -1071,7 +1078,11 @@ class EcontractApi {
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSign4
(
param
);
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -1168,7 +1179,11 @@ class EcontractApi {
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSigns
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -1328,7 +1343,11 @@ class EcontractApi {
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSignPersonalTwo
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -1740,14 +1759,26 @@ class EcontractApi {
for
(
var
idO
of
idsOCOunt
)
{
accountMap
[
idO
.
userName
+
"_"
+
idO
.
personsSign
]
=
1
;
}
var
coids
=
await
this
.
findecontractoffline
(
mtchId
,
idNoList
,
idNameList
);
for
(
var
id
in
coids
){
accountMap
[
id
.
id_name
+
"_"
+
id
.
id_no
]
=
1
;
}
}
if
(
templateIds
.
idsT
.
length
>
0
)
{
var
idsTCount
=
await
this
.
usereaccountSve
.
getSignAccounts_dk
(
templateIds
.
idsT
,
idNoList
,
idNameList
);
for
(
var
idT
of
idsTCount
)
{
accountMap2
[
idT
.
userName
+
"_"
+
idT
.
personsSign
]
=
1
;
}
var
coids
=
await
this
.
findecontractoffline
(
mtchId
,
idNoList
,
idNameList
);
for
(
var
coid
of
coids
){
accountMap2
[
coid
.
id_name
+
"_"
+
coid
.
id_no
]
=
1
;
}
}
// 5 比对用户是否签约
for
(
var
u
of
userList
)
{
if
(
accountMap
[
u
.
idName
+
"_"
+
u
.
idNo
]
||
accountMap2
[
u
.
idName
+
"_"
+
u
.
idNo
])
{
...
...
@@ -1792,6 +1823,14 @@ class EcontractApi {
}
}
async
findecontractoffline
(
mtchId
,
idNoList
,
idNameList
){
return
this
.
econtractofflineSve
.
findSignAccount
(
mtchId
,
idNoList
,
idNameList
)
}
}
module
.
exports
=
EcontractApi
;
bpo-web/app/base/api/impl/testApi.js
View file @
7892d432
...
...
@@ -102,19 +102,19 @@ class TestApi {
try
{
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
await
this
.
sleep
(
3000
);
console
.
log
(
11111111
)
const
unLock
=
await
this
.
redisLock
.
unLock
(
key
,
id
);
console
.
log
(
'unLock: '
,
key
,
id
,
unLock
);
}
catch
(
err
)
{
console
.
log
(
'上锁失败'
,
err
);
}
}
async
sss
(
key
){
this
.
test1
(
key
.
key
)
this
.
test1
(
key
.
key
)
this
.
test1
(
key
.
key
)
}
...
...
bpo-web/app/base/api/impl/yzcontractApi.js
View file @
7892d432
const
system
=
require
(
"../../system"
);
const
md5
=
require
(
"MD5"
);
const
uuidv1
=
require
(
'uuid/v1'
);
class
YZContractApi
{
constructor
()
{
...
...
@@ -12,7 +13,7 @@ class YZContractApi {
this
.
esettleSve
=
system
.
getObject
(
"service.esettleSve"
);
this
.
etemplatebusiSve
=
system
.
getObject
(
"service.etemplatebusiSve"
);
this
.
redisLock
=
system
.
getObject
(
"util.redisLock"
);
// this.appId = "1201869719607517185";
// this.key = "bee7870e008ab144bf518b70ef91f8ac";
}
...
...
@@ -204,7 +205,11 @@ class YZContractApi {
}
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
entcontractSve
.
yzMerchantAutoSigns
(
param
,
enttemplate
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -290,7 +295,11 @@ class YZContractApi {
}
try
{
param
.
idNo
=
param
.
idNo
.
toUpperCase
();
var
key
=
param
.
idNo
+
"_"
+
param
.
ecid
const
id
=
uuidv1
();
await
this
.
redisLock
.
lock
(
key
,
id
,
20
);
var
result
=
await
this
.
econtractSve
.
autoSignNoBank
(
param
);
await
this
.
redisLock
.
unLock
(
key
,
id
);
return
result
;
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
bpo-web/app/base/db/impl/econtractofflineDao.js
0 → 100644
View file @
7892d432
const
system
=
require
(
"../../system"
);
const
Dao
=
require
(
"../dao.base"
);
class
EcontractofflineDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
EcontractofflineDao
));
}
}
module
.
exports
=
EcontractofflineDao
;
bpo-web/app/base/db/models/econtractoffline.js
0 → 100644
View file @
7892d432
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
wxconfig
.
appId
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"econtractoffline"
,
{
mchtId
:
DataTypes
.
STRING
,
mchtName
:
DataTypes
.
STRING
,
id_no
:
DataTypes
.
STRING
,
id_name
:
DataTypes
.
STRING
,
bank_no
:
DataTypes
.
STRING
,
mobile
:
DataTypes
.
STRING
,
fileurl
:
DataTypes
.
STRING
,
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'c_econtract_offline'
,
validate
:
{
},
indexes
:
[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
bpo-web/app/base/service/impl/econtractofflineSve.js
0 → 100644
View file @
7892d432
const
system
=
require
(
"../../system"
);
const
ServiceBase
=
require
(
"../sve.base"
);
const
moment
=
require
(
"moment"
);
const
md5
=
require
(
"MD5"
);
class
EcontractofflineService
extends
ServiceBase
{
constructor
()
{
super
(
ServiceBase
.
getDaoName
(
EcontractofflineService
));
this
.
etemplateSve
=
system
.
getObject
(
"service.etemplateSve"
);
this
.
usereaccountSve
=
system
.
getObject
(
"service.usereaccountSve"
);
}
async
findSignAccount
(
mtchId
,
idNoList
,
idNameList
){
var
sql
=
[];
sql
.
push
(
"SELECT "
);
sql
.
push
(
"t1.id_no, t1.id_name"
);
sql
.
push
(
"FROM c_econtract_offline t1"
);
sql
.
push
(
"WHERE t1.mchtId IN (:etemplateIds)"
);
sql
.
push
(
"AND t1.`id_no` IN (:idNoList)"
);
sql
.
push
(
"AND t1.`id_name` IN (:idNameList)"
);
var
list
=
await
this
.
dao
.
customQuery
(
sql
.
join
(
" "
),
{
etemplateIds
:
mtchId
,
idNameList
:
idNameList
,
idNoList
:
idNoList
,
});
return
list
||
[];
}
trim
(
o
)
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
returnjson
(
code
,
msg
,
data
)
{
return
{
code
:
code
,
msg
:
msg
,
data
:
data
||
null
}
}
}
module
.
exports
=
EcontractofflineService
;
bpo-web/app/base/utils/redisLock.js
View file @
7892d432
const
settings
=
require
(
"../../config/settings"
);
const
redisConfig
=
settings
.
redis
();
const
Redis
=
require
(
"ioredis"
);
const
redis
=
new
Redis
(
6379
,
"127.0.0.1"
);
const
redis
=
new
Redis
({
host
:
redisConfig
.
host
,
port
:
redisConfig
.
port
,
password
:
redisConfig
.
password
,
db
:
redisConfig
.
db
,
});
class
RedisLock
{
constructor
()
{
this
.
lockLeaseTime
=
2
;
// 默认锁过期时间 2 秒
this
.
lockTimeout
=
5
;
// 默认锁超时时间 5 秒
this
.
lockLeaseTime
=
5
;
// 默认锁过期时间 2 秒
this
.
lockTimeout
=
10
;
// 默认锁超时时间 5 秒
this
.
expiryMode
=
'EX'
;
this
.
setMode
=
'NX'
;
this
.
client
=
redis
;
...
...
@@ -31,13 +38,11 @@ class RedisLock {
console
.
log
(
`
${
key
}
${
val
}
上锁成功`
);
return
true
;
}
// 锁超时
if
(
Math
.
floor
((
Date
.
now
()
-
start
)
/
1000
)
>
self
.
lockTimeout
)
{
console
.
log
(
`
${
key
}
${
val
}
上锁重试超时结束`
);
return
false
;
}
// 循环等待重试
console
.
log
(
`
${
key
}
${
val
}
等待重试`
);
await
sleep
(
3000
);
...
...
bpo-web/app/config/settings.js
View file @
7892d432
...
...
@@ -20,7 +20,7 @@ var settings = {
secret
:
"f99d413b767f09b5dff0b3610366cc46"
,
},
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
333
3
,
port
:
process
.
env
.
NODE_PORT
||
333
4
,
reqEsAddr
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
var
localsettings
=
require
(
"./localsettings"
);
...
...
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