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
93bdb4a6
Commit
93bdb4a6
authored
Dec 20, 2019
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加创富小程序需要的接口
parent
68a71290
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
92 additions
and
20 deletions
+92
-20
xgg-web/app/base/db/impl/bmmerchantbusinessscopeDao.js
+9
-0
xgg-web/app/base/db/models/bmmerchantbusinessscope.js
+17
-0
xgg-web/app/base/db/models/bmuser.js
+1
-0
xgg-web/app/base/service/impl/bmmerchantbusinessscopeSve.js
+8
-0
xgg-web/app/base/wxapplet/applet.base.js
+8
-6
xgg-web/app/base/wxapplet/impl/chuangfuApplet.js
+42
-11
xgg-web/app/config/localsettings.js
+3
-3
xgg-web/app/config/routes/applet.js
+4
-0
No files found.
xgg-web/app/base/db/impl/bmmerchantbusinessscopeDao.js
0 → 100644
View file @
93bdb4a6
const
system
=
require
(
"../../system"
);
const
Dao
=
require
(
"../dao.base"
);
class
BmmerchantbusinessscopeDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
BmmerchantbusinessscopeDao
));
}
}
module
.
exports
=
BmmerchantbusinessscopeDao
;
xgg-web/app/base/db/models/bmmerchantbusinessscope.js
0 → 100644
View file @
93bdb4a6
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"bmmerchantbusinessscope"
,
{
id
:
{
type
:
DataTypes
.
BIGINT
(
20
),
autoIncrement
:
true
,
primaryKey
:
true
,
unique
:
true
},
name
:
{
type
:
DataTypes
.
STRING
(
100
),
comment
:
'商户名称'
},
merchantId
:
{
type
:
DataTypes
.
BIGINT
(
32
),
field
:
'merchant_id'
,
comment
:
'商户ID'
}
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'bm_merchant_businessscope'
,
validate
:
{}
});
}
\ No newline at end of file
xgg-web/app/base/db/models/bmuser.js
View file @
93bdb4a6
module
.
exports
=
(
db
,
DataTypes
)
=>
{
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"bmuser"
,
{
return
db
.
define
(
"bmuser"
,
{
openId
:
DataTypes
.
STRING
(
100
),
openId
:
DataTypes
.
STRING
(
100
),
merchantId
:
{
type
:
DataTypes
.
STRING
(
32
),
field
:
'merchant_id'
,
comment
:
'商户ID'
},
mobile
:
DataTypes
.
STRING
(
30
),
mobile
:
DataTypes
.
STRING
(
30
),
passwd
:
DataTypes
.
STRING
(
64
),
passwd
:
DataTypes
.
STRING
(
64
),
nickname
:
DataTypes
.
STRING
(
64
),
nickname
:
DataTypes
.
STRING
(
64
),
...
...
xgg-web/app/base/service/impl/bmmerchantbusinessscopeSve.js
0 → 100644
View file @
93bdb4a6
const
system
=
require
(
"../../system"
);
const
ServiceBase
=
require
(
"../sve.base"
);
class
BmmerchantbusinessscopeService
extends
ServiceBase
{
constructor
(){
super
(
ServiceBase
.
getDaoName
(
BmmerchantbusinessscopeService
));
}
}
module
.
exports
=
BmmerchantbusinessscopeService
;
xgg-web/app/base/wxapplet/applet.base.js
View file @
93bdb4a6
...
@@ -10,10 +10,6 @@ class AppletBase {
...
@@ -10,10 +10,6 @@ class AppletBase {
this
.
cacheManager
=
system
.
getObject
(
"db.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.cacheManager"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
rc
=
system
.
getObject
(
"util.execClient"
);
this
.
rc
=
system
.
getObject
(
"util.execClient"
);
// this.wxConfig = {
// appid: "wx3fa4626b74d1e944",
// secret: "238cdac5b7d3102a367e2eafc0eaa5da"
// };
if
(
!
config
)
{
if
(
!
config
)
{
throw
new
Error
(
"请传入小程序appid和secret配置"
);
throw
new
Error
(
"请传入小程序appid和secret配置"
);
}
}
...
@@ -35,8 +31,14 @@ class AppletBase {
...
@@ -35,8 +31,14 @@ class AppletBase {
return
null
;
return
null
;
}
}
}
}
async
getUserInfo
(
openid
)
{
async
getUserInfo
(
openid
,
merchantId
)
{
return
this
.
cacheManager
[
"AppletUserinfoCache"
].
get
(
openid
);
let
key
;
if
(
merchantId
){
key
=
merchantId
+
"_"
+
openid
;
}
else
{
key
=
openid
;
}
return
this
.
cacheManager
[
"AppletUserinfoCache"
].
get
(
key
);
}
}
async
decryptData
(
obj
)
{
async
decryptData
(
obj
)
{
...
...
xgg-web/app/base/wxapplet/impl/chuangfuApplet.js
View file @
93bdb4a6
...
@@ -2,19 +2,22 @@ var system = require("../../system")
...
@@ -2,19 +2,22 @@ var system = require("../../system")
const
http
=
require
(
"http"
)
const
http
=
require
(
"http"
)
const
querystring
=
require
(
'querystring'
);
const
querystring
=
require
(
'querystring'
);
var
settings
=
require
(
"../../../config/settings"
);
var
settings
=
require
(
"../../../config/settings"
);
const
AppletBase
=
require
(
"../
chuangfu.
applet.base"
);
const
AppletBase
=
require
(
"../applet.base"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
logCtl
=
system
.
getObject
(
"web.oplogCtl"
);
const
fs
=
require
(
"fs"
);
const
fs
=
require
(
"fs"
);
const
moment
=
require
(
"moment"
);
const
moment
=
require
(
"moment"
);
class
xgg
Applet
extends
AppletBase
{
class
Chuangfu
Applet
extends
AppletBase
{
constructor
()
{
constructor
()
{
super
();
super
({
appid
:
"wx427b4e988444908f"
,
secret
:
"3d092eb22c3451618a9c0656b1861ac6"
});
this
.
bmuserSve
=
system
.
getObject
(
"service.bmuserSve"
);
this
.
bmuserSve
=
system
.
getObject
(
"service.bmuserSve"
);
this
.
bmuserbizSve
=
system
.
getObject
(
"service.bmuserbizSve"
);
this
.
bmuserbizSve
=
system
.
getObject
(
"service.bmuserbizSve"
);
this
.
bmmerchantSve
=
system
.
getObject
(
"service.bmmerchantSve"
);
this
.
bmmerchantSve
=
system
.
getObject
(
"service.bmmerchantSve"
);
this
.
bmorderSve
=
system
.
getObject
(
"service.bmorderSve"
);
this
.
bmorderSve
=
system
.
getObject
(
"service.bmorderSve"
);
this
.
bmmerchantbusinessscopeSve
=
system
.
getObject
(
"service.bmmerchantbusinessscopeSve"
);
this
.
dictUtils
=
system
.
getObject
(
"util.dictUtils"
);
this
.
dictUtils
=
system
.
getObject
(
"util.dictUtils"
);
this
.
uploadCtl
=
system
.
getObject
(
"web.uploadCtl"
);
this
.
uploadCtl
=
system
.
getObject
(
"web.uploadCtl"
);
...
@@ -25,7 +28,7 @@ class xggApplet extends AppletBase {
...
@@ -25,7 +28,7 @@ class xggApplet extends AppletBase {
// 设置登录缓存
// 设置登录缓存
async
setLoginUser
(
id
)
{
async
setLoginUser
(
id
)
{
var
user
=
await
this
.
bmuserSve
.
findById
(
id
);
var
user
=
await
this
.
bmuserSve
.
findById
(
id
);
await
this
.
cacheManager
[
"BMUserCache"
].
set
(
user
.
openId
,
JSON
.
stringify
(
user
));
await
this
.
cacheManager
[
"BMUserCache"
].
set
(
this
.
merchantId
+
"_"
+
user
.
openId
,
JSON
.
stringify
(
user
));
return
user
;
return
user
;
}
}
...
@@ -51,10 +54,11 @@ class xggApplet extends AppletBase {
...
@@ -51,10 +54,11 @@ class xggApplet extends AppletBase {
// TODO 找文档,看失效时间
// TODO 找文档,看失效时间
this
.
redisClient
.
set
(
"session_key_"
+
decryptData
.
openId
,
wxSession
.
session_key
);
this
.
redisClient
.
set
(
"session_key_"
+
decryptData
.
openId
,
wxSession
.
session_key
);
console
.
log
(
"wx ------------------------------------ login"
);
console
.
log
(
"wx ------------------------------------ login"
);
user
=
await
this
.
bmuserSve
.
findOne
({
openId
:
decryptData
.
openId
});
user
=
await
this
.
bmuserSve
.
findOne
({
openId
:
decryptData
.
openId
,
merchantId
:
this
.
merchantId
});
if
(
!
user
)
{
if
(
!
user
)
{
user
=
{
user
=
{
openId
:
decryptData
.
openId
,
openId
:
decryptData
.
openId
,
merchantId
:
this
.
merchantId
,
mobile
:
""
,
mobile
:
""
,
passwd
:
""
,
passwd
:
""
,
nickname
:
decryptData
.
nickName
,
nickname
:
decryptData
.
nickName
,
...
@@ -66,7 +70,7 @@ class xggApplet extends AppletBase {
...
@@ -66,7 +70,7 @@ class xggApplet extends AppletBase {
//创建用户信息
//创建用户信息
user
=
await
this
.
bmuserSve
.
create
(
user
);
user
=
await
this
.
bmuserSve
.
create
(
user
);
}
}
this
.
cacheManager
[
"BMUserCache"
].
set
(
decryptData
.
openId
,
JSON
.
stringify
(
user
));
this
.
cacheManager
[
"BMUserCache"
].
set
(
this
.
merchantId
+
"_"
+
decryptData
.
openId
,
JSON
.
stringify
(
user
));
}
}
return
{
return
{
code
:
1
,
code
:
1
,
...
@@ -233,6 +237,7 @@ class xggApplet extends AppletBase {
...
@@ -233,6 +237,7 @@ class xggApplet extends AppletBase {
bank
:
obj
.
bank
,
bank
:
obj
.
bank
,
bankno
:
obj
.
bankno
,
bankno
:
obj
.
bankno
,
bankMobile
:
obj
.
bankMobile
||
""
,
bankMobile
:
obj
.
bankMobile
||
""
,
businessScope
:
obj
.
businessScope
||
""
};
};
rs
.
code
=
1
;
rs
.
code
=
1
;
...
@@ -253,6 +258,7 @@ class xggApplet extends AppletBase {
...
@@ -253,6 +258,7 @@ class xggApplet extends AppletBase {
pageSize
:
pobj
.
pageSize
||
10
,
pageSize
:
pobj
.
pageSize
||
10
,
currentPage
:
pobj
.
currentPage
||
1
,
currentPage
:
pobj
.
currentPage
||
1
,
userId
:
loginUser
.
id
,
userId
:
loginUser
.
id
,
merchantId
:
this
.
merchantId
}
}
var
page
=
await
this
.
bmorderSve
.
pageByCondition
(
params
);
var
page
=
await
this
.
bmorderSve
.
pageByCondition
(
params
);
...
@@ -274,8 +280,6 @@ class xggApplet extends AppletBase {
...
@@ -274,8 +280,6 @@ class xggApplet extends AppletBase {
stack
:
e
.
stack
stack
:
e
.
stack
};
};
}
}
console
.
log
(
decryptData
);
}
}
async
idcardValid
(
gobj
,
pobj
,
req
,
loginUser
){
async
idcardValid
(
gobj
,
pobj
,
req
,
loginUser
){
...
@@ -309,5 +313,32 @@ class xggApplet extends AppletBase {
...
@@ -309,5 +313,32 @@ class xggApplet extends AppletBase {
return
{
code
:
500
};
return
{
code
:
500
};
}
}
}
}
/**
* 经营范围
* @param {*} gobj
* @param {*} pobj
* @param {*} req
* @param {*} loginUser
*/
async
businessscopes
(
gobj
,
pobj
,
req
,
loginUser
){
try
{
let
where
=
{};
if
(
loginUser
){
where
.
merchantId
=
loginUser
.
merchantId
;
}
else
{
where
.
merchantId
=
this
.
merchantId
;
}
let
res
=
await
this
.
bmmerchantbusinessscopeSve
.
dao
.
model
.
findAll
({
where
:
where
});
for
(
let
item
of
res
)
{
item
.
dataValues
.
type
=
false
;
}
return
res
;
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
}
module
.
exports
=
xggApplet
;
module
.
exports
=
ChuangfuApplet
;
\ No newline at end of file
\ No newline at end of file
xgg-web/app/config/localsettings.js
View file @
93bdb4a6
...
@@ -7,10 +7,10 @@ var settings={
...
@@ -7,10 +7,10 @@ var settings={
},
},
database
:{
database
:{
dbname
:
"xgg"
,
dbname
:
"xgg"
,
user
:
"
root
"
,
user
:
"
write
"
,
password
:
"
root
"
,
password
:
"
write
"
,
config
:
{
config
:
{
host
:
'192.168.18.
110
'
,
host
:
'192.168.18.
237
'
,
dialect
:
'mysql'
,
dialect
:
'mysql'
,
operatorsAliases
:
false
,
operatorsAliases
:
false
,
pool
:
{
pool
:
{
...
...
xgg-web/app/config/routes/applet.js
View file @
93bdb4a6
...
@@ -67,6 +67,10 @@ module.exports = function (app) {
...
@@ -67,6 +67,10 @@ module.exports = function (app) {
params
.
push
(
req
);
params
.
push
(
req
);
var
key
=
req
.
body
.
key
;
var
key
=
req
.
body
.
key
;
if
(
key
)
{
if
(
key
)
{
//如果是 创富 merchantId=3 key = merchant_openId
if
(
classPath
==
"chuangfuApplet"
){
key
=
"3_"
+
key
;
}
params
.
push
(
JSON
.
parse
(
await
cacheManager
[
"BMUserCache"
].
get
(
key
)));
params
.
push
(
JSON
.
parse
(
await
cacheManager
[
"BMUserCache"
].
get
(
key
)));
}
}
var
p
=
null
;
var
p
=
null
;
...
...
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