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
9e936a75
Commit
9e936a75
authored
Jun 29, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
c4874ae9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
719 deletions
+37
-719
esign-admin/app/base/api/api.base.js
+0
-10
esign-admin/app/base/api/impl/h5/merchantApi.js
+0
-668
esign-admin/app/base/api/impl/inner/aduserApi.js
+2
-2
esign-admin/app/base/controller/impl/uc/userCtl.js
+16
-32
esign-admin/app/base/db/models/common/oplog.js
+1
-1
esign-admin/app/base/service/impl/uc/userSve.js
+16
-0
esign-admin/app/base/system.js
+1
-1
esign-admin/app/config/routes/web.js
+1
-5
No files found.
esign-admin/app/base/api/api.base.js
View file @
9e936a75
...
...
@@ -9,18 +9,8 @@ class APIBase extends DocBase {
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
logCtl
=
system
.
getObject
(
"web.common.oplogCtl"
);
this
.
oplogSve
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
merchantappletuserSve
=
system
.
getObject
(
"service.uc.merchantappletuserSve"
);
}
async
getLoginUser
(
merchant_id
,
openid
,
forceUpdate
)
{
return
await
this
.
merchantappletuserSve
.
getLoginUser
({
merchant_id
:
merchant_id
,
openid
:
openid
,
forceUpdate
:
forceUpdate
});
}
async
getMerchant
(
merchant_id
)
{
return
await
this
.
merchantSve
.
getMerchantWithCache
({
id
:
merchant_id
,
forceUpdate
:
true
});
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
...
...
esign-admin/app/base/api/impl/h5/merchantApi.js
deleted
100644 → 0
View file @
c4874ae9
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
const
axios
=
require
(
"axios"
);
const
validation
=
system
.
getObject
(
"util.validation"
);
const
md5
=
require
(
"MD5"
);
class
TestAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
SMS_BANKMOBILE_KEY
=
"gtb_appl_mobile_"
;
this
.
SMS_LOGINMOBILE_KEY
=
"gtb_login_mobile_"
;
this
.
BANK_FOUR
=
"https://bpohhr.gongsibao.com/api/econtractApi/bankfour"
;
this
.
GTB_APPID
=
"gtb-mcht-applet"
;
this
.
GTB_KEY
=
"0e2e4e7249b79q50f234071651971242"
;
this
.
uploadCtl
=
system
.
getObject
(
"web.common.uploadCtl"
);
this
.
idcardClient
=
system
.
getObject
(
"util.idcardClient"
);
this
.
merchantappletuserSve
=
system
.
getObject
(
"service.uc.merchantappletuserSve"
);
this
.
orderSve
=
system
.
getObject
(
"service.saas.orderSve"
);
this
.
businessmenSve
=
system
.
getObject
(
"service.saas.businessmenSve"
);
this
.
tradeSve
=
system
.
getObject
(
"service.trade.tradeSve"
);
this
.
saasInvoiceSve
=
system
.
getObject
(
"service.saas.invoiceSve"
);
this
.
merchantSve
=
system
.
getObject
(
"service.saas.merchantSve"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
smsClient
=
system
.
getObject
(
"util.smsClient"
);
}
doMerchantId
(
obj
)
{
if
(
!
obj
.
merchant_id
)
{
return
;
}
try
{
obj
.
merchant_id
=
system
.
decryption
(
decodeURIComponent
(
obj
.
merchant_id
));
}
catch
(
e
)
{
console
.
log
(
e
);
return
;
}
}
//H5登录获取验证码
async
sendMobileCode
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
let
mobile
=
obj
.
mobile
;
if
(
!
mobile
)
{
return
this
.
returnFail
(
"请先填写手机号"
);
}
if
(
validation
.
isMobile
(
mobile
))
{
return
this
.
returnFail
(
"手机号格式错误"
);
}
try
{
let
key
=
this
.
SMS_LOGINMOBILE_KEY
+
mobile
;
let
vcode
=
await
this
.
redisClient
.
get
(
key
+
"t"
);
// let vcode;
if
(
!
vcode
)
{
vcode
=
await
this
.
getVCode
();
await
this
.
redisClient
.
setWithEx
(
key
,
vcode
,
5
*
60
);
await
this
.
redisClient
.
setWithEx
(
key
+
"t"
,
vcode
,
60
);
let
msg
=
"您的个体户注册手机验证码为"
+
vcode
+
", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"
;
let
rs
=
await
this
.
smsClient
.
sendMsg
(
mobile
,
msg
);
//this.addLog(obj, "sms");
console
.
log
(
rs
);
}
return
this
.
returnSuccess
(
1
);
}
catch
(
error
)
{
return
system
.
getResultFail
(
500
,
"接口异常:"
+
error
.
message
);
}
}
// 登录接口 post
async
login
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
try
{
if
(
!
obj
.
mobile
)
{
return
this
.
returnFail
(
"请填写手机号"
);
}
let
noteCode
=
(
obj
.
noteCode
||
""
).
trim
();
if
(
!
noteCode
)
{
return
this
.
returnFail
(
"请填写短信验证码"
);
}
// TODO 手机号验证码登录
let
key
=
this
.
SMS_LOGINMOBILE_KEY
+
obj
.
mobile
;
let
vcode
=
await
this
.
redisClient
.
get
(
key
+
"t"
);
if
(
!
vcode
)
{
return
this
.
returnFail
(
"短信验证码已过期,请重新发送"
);
}
if
(
vcode
!=
noteCode
)
{
return
this
.
returnFail
(
"短信验证码错误,请重新填写"
);
}
let
openID
=
"gtbh5_"
+
obj
.
mobile
;
let
merchant_id
=
obj
.
merchant_id
;
let
params
=
{
saas_merchant_id
:
merchant_id
,
saas_id
:
null
,
openid
:
openID
,
nickName
:
obj
.
mobile
,
avatarUrl
:
""
,
ucname
:
obj
.
mobile
,
mobile
:
obj
.
mobile
,
};
let
res
=
await
this
.
merchantappletuserSve
.
login
(
params
);
if
(
res
.
status
===
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
return
this
.
returnFail
(
res
.
msg
,
res
.
data
);
}
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
}
}
//验证登录
async
loginUser
(
obj
)
{
this
.
doMerchantId
(
obj
);
// let merchant_id = decodeURIComponent(obj.merchant_id);
// let merchant_id = system.decryption(decodeURIComponent(obj.merchant_id));
let
user
=
await
this
.
getLoginUser
(
obj
.
merchant_id
,
obj
.
openid
);
return
this
.
returnSuccess
(
user
);
}
async
uploadConfig
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
try
{
let
data
=
await
this
.
uploadCtl
.
getOssConfig
();
return
this
.
returnSuccess
(
data
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
{
code
:
500
};
}
}
// 保存订单信息
async
saveOrder
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
try
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnFail
(
"订单保存失败"
);
}
let
rs
=
await
this
.
buildOrder
(
obj
);
if
(
rs
.
code
===
0
)
{
return
rs
;
}
let
bminfo
=
rs
.
data
;
// 银行卡四要数验证
let
bf
=
await
this
.
bankfour
({
userName
:
bminfo
.
legal_name
,
userIdNo
:
bminfo
.
legal_idno
,
userBankNo
:
bminfo
.
bank_no
,
userMobile
:
bminfo
.
bank_mobile
,
});
// this.addLog(obj, "bankfour");
if
(
bf
.
code
!==
0
)
{
return
this
.
returnFail
(
"银行卡四要素验证失败,请检查法人姓名,身份证,银行卡号,银行卡预留手机号正确"
);
}
let
merchant
=
await
this
.
getMerchant
(
obj
.
merchant_id
);
//let loginUser = await this.getLoginUser(pobj.merchant_id, pobj.openid);
let
order
=
{
saas_id
:
merchant
.
saas_id
,
merchant_id
:
merchant
.
id
,
channel_id
:
merchant
.
channel_id
,
product_id
:
"10020000"
,
merchant_app_user_id
:
loginUser
.
data
.
id
,
price
:
system
.
y2f
(
merchant
.
sign
.
bm_reg_price
)
||
0
,
bminfo
:
rs
.
data
};
let
res
=
await
this
.
orderSve
.
microAdd
(
order
);
if
(
res
.
status
===
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
return
this
.
returnFail
(
res
.
msg
||
"保存订单失败"
);
}
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
return
{
code
:
-
200
,
msg
:
"error"
,
data
:
{},
stack
:
e
.
stack
};
}
}
async
buildOrder
(
obj
)
{
if
(
!
obj
.
idcard_front
)
{
return
this
.
returnFail
(
"请上传身份证人像面"
);
}
if
(
!
obj
.
idcard_back
)
{
return
this
.
returnFail
(
"请上传身份证国徽图"
);
}
if
(
!
obj
.
legal_name
)
{
return
this
.
returnFail
(
"请填写法人姓名"
);
}
if
(
!
obj
.
legal_mobile
)
{
return
this
.
returnFail
(
"请填写联系手机"
);
}
if
(
!
/^1
\d{10}
$/
.
test
(
obj
.
legal_mobile
))
{
return
this
.
returnFail
(
"联系手机格式错误"
);
}
if
(
!
obj
.
legal_idno
)
{
return
this
.
returnFail
(
"请填写身份证号码"
);
}
if
(
!
await
this
.
idcardClient
.
checkIDCard
(
obj
.
legal_idno
))
{
return
this
.
returnFail
(
"身份证号码错误,请检查后重新输入"
);
}
if
(
!
obj
.
company_names
)
{
return
this
.
returnFail
(
"请填写公司名称"
);
}
if
(
!
obj
.
bank_front
)
{
return
this
.
returnFail
(
"请上传银行卡正面"
);
}
if
(
!
obj
.
bank_back
)
{
return
this
.
returnFail
(
"请上传银行卡反面"
);
}
if
(
!
obj
.
bank_name
)
{
return
this
.
returnFail
(
"请填写银行预留手机号"
);
}
if
(
!
obj
.
bank_no
)
{
return
this
.
returnFail
(
"请填写银行预留手机号"
);
}
if
(
!
obj
.
bank_mobile
)
{
return
this
.
returnFail
(
"请填写银行预留手机号"
);
}
let
noteCode
=
(
obj
.
note_code
||
""
).
trim
();
if
(
!
noteCode
)
{
return
this
.
returnFail
(
"请填写短信验证码"
);
}
// let vcode = await this.redisClient.get(this.SMS_LOGINMOBILE_KEY + obj.bank_mobile);
// if (!vcode) {
// return this.returnFail("短信验证码已过期,请重新发送");
// }
// if (vcode != noteCode) {
// return this.returnFail("短信验证码错误,请重新填写");
// }
let
bminfo
=
{
idcard_front
:
obj
.
idcard_front
,
idcard_back
:
obj
.
idcard_back
,
legal_name
:
obj
.
legal_name
,
legal_mobile
:
obj
.
legal_mobile
,
legal_idno
:
obj
.
legal_idno
,
company_names
:
obj
.
company_names
,
bank_front
:
obj
.
bank_front
,
bank_back
:
obj
.
bank_back
,
bank_name
:
obj
.
bank_name
,
bank_no
:
obj
.
bank_no
,
bank_mobile
:
obj
.
bank_mobile
,
};
return
this
.
returnSuccess
(
bminfo
);
}
async
myOrders
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
try
{
let
params
=
{
pageSize
:
Number
(
obj
.
pageSize
||
10
),
currentPage
:
Number
(
obj
.
currentPage
||
1
),
merchant_app_user_id
:
loginUser
.
data
.
id
,
merchant_id
:
loginUser
.
data
.
saas_merchant_id
,
}
let
listRes
=
await
this
.
orderSve
.
page
(
params
);
if
(
listRes
.
status
===
0
)
{
if
(
listRes
.
status
!=
0
)
{
return
system
.
getResult
(
null
,
`系统错误`
);
}
let
source_nos
=
[];
for
(
let
item
of
listRes
.
data
.
rows
)
{
source_nos
.
push
(
item
.
id
);
}
if
(
source_nos
.
length
==
0
){
return
system
.
getResult
(
null
,
`暂无数据`
);
}
let
res
=
await
this
.
orderSve
.
queryOrderStatusBySourceNo
({
source_nos
:
source_nos
});
if
(
res
.
status
!=
0
){
return
res
;
}
let
StatusMap
=
res
.
data
;
// for(let item of listRes.data.rows){
// if(StatusMap[item.id]){
// item.handle_name = StatusMap[item.id]['name3'] || "处理中";
// }else{
// item.handle_name ="订单处理中";
// }
// }
for
(
let
item
of
listRes
.
data
.
rows
){
if
(
StatusMap
[
item
.
id
]){
item
.
handle_name
=
StatusMap
[
item
.
id
][
'name3'
]
||
"处理中"
;
}
else
if
(
item
.
pay_status
==
"10"
){
item
.
handle_name
=
"订单待处理"
;
}
else
if
(
item
.
audit_status
==
"30"
){
item
.
handle_name
=
"订单处理失败"
;
}
else
{
item
.
handle_name
=
"订单处理中"
;
}
}
return
this
.
returnSuccess
(
listRes
.
data
);
}
else
{
return
this
.
returnFail
(
listRes
.
msg
);
}
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
//日志记录
return
{
code
:
-
200
,
msg
:
"error"
,
data
:
{},
stack
:
e
.
stack
};
}
console
.
log
(
decryptData
);
}
/**
* 查询订单明细
* @param {*} gobj
* @param {*} pobj
* @param {*} req
* @param {*} loginUser
*/
async
orderInfo
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnSuccess
({});
}
try
{
let
rs
=
await
this
.
orderSve
.
orderInfo
(
obj
);
if
(
rs
.
status
===
0
)
{
return
this
.
returnSuccess
(
rs
.
data
);
}
else
{
return
this
.
returnFail
(
rs
.
msg
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
error
);
}
}
async
idNoValid
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
try
{
let
idno
=
(
obj
.
idno
||
""
).
trim
();
if
(
!
idno
)
{
return
{
code
:
0
,
msg
:
"请填写身份证号码"
};
}
let
success
=
await
this
.
idcardClient
.
checkIDCard
(
idno
);
if
(
success
)
{
return
this
.
returnSuccess
(
1
);
}
return
this
.
returnFail
(
"身份证号码格式错误"
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
{
code
:
500
,
msg
:
"服务忙,请稍后重试"
};
}
}
/**
* 个体户列表/个体户列表
* @param params
* @param pobj2
* @param req
* @returns {Promise<void>}
*/
async
saasorderbusinessmenPage
(
params
,
pobj2
,
req
)
{
this
.
doMerchantId
(
params
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
params
);
params
.
merchant_app_user_id
=
loginUser
.
data
.
id
;
let
res
=
await
this
.
businessmenSve
.
saasorderbusinessmenPage
(
params
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
this
.
returnFail
(
"请求超时 请稍后在试"
);
}
}
/**
* 获取用户下的所有交易记录
* @param pobj1
* @param pobj2
* @param req
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async
saasTradeBusinessmenPage
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
obj
.
merchant_app_user_id
=
loginUser
.
data
.
id
;
obj
.
attrs
=
[
"credit_code"
];
if
(
!
obj
.
merchant_app_user_id
)
{
return
system
.
getResult
(
null
,
`登录失效,请重新登录`
);
}
try
{
let
creditCodeArray
=
await
this
.
businessmenSve
.
assorderBusinessmenInfo
(
obj
);
if
(
creditCodeArray
.
status
!=
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
let
creditCodes
=
[];
for
(
let
val
of
creditCodeArray
.
data
)
{
creditCodes
.
push
(
val
.
credit_code
);
}
if
(
!
creditCodes
||
creditCodes
.
length
==
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
obj
.
credit_code_array
=
creditCodes
;
let
res
=
await
this
.
tradeSve
.
tradeItemBycreditCode
(
obj
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
return
this
.
returnFail
(
"请求超时 请稍后在试"
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
return
this
.
returnFail
(
"请求超时 请稍后在试"
);
}
}
/**
* 发票管理
* @param pobj1
* @param pobj2
* @param req
* @returns {Promise<void>}
*/
async
invoiceBycreditCode
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
obj
.
merchant_app_user_id
=
loginUser
.
data
.
id
;
obj
.
attrs
=
[
"credit_code"
];
if
(
!
obj
.
merchant_app_user_id
)
{
return
system
.
getResult
(
null
,
`登录失效,请重新登录`
);
}
try
{
let
creditCodeArray
=
await
this
.
businessmenSve
.
assorderBusinessmenInfo
(
obj
);
if
(
creditCodeArray
.
status
!=
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
let
creditCodes
=
[];
for
(
let
val
of
creditCodeArray
.
data
)
{
creditCodes
.
push
(
val
.
credit_code
);
}
if
(
!
creditCodes
||
creditCodes
.
length
==
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
obj
.
credit_code_array
=
creditCodes
;
let
res
=
await
this
.
saasInvoiceSve
.
invoiceBycreditCode
(
obj
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
return
this
.
returnFail
(
"请求超时 请稍后在试"
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
/**
* 银行卡预留手机号短信验证码
* @param pobj1
* @param pobj
* @param req
* @returns {Promise<void>}
*/
async
sendBankMobileCode
(
obj
,
obj1
,
req
)
{
this
.
doMerchantId
(
obj
);
// TODO this.loginUser();
let
loginUser
=
await
this
.
loginUser
(
obj
);
let
mobile
=
obj
.
mobile
;
if
(
!
mobile
)
{
return
this
.
returnFail
(
"请先填写银行卡预留手机号"
);
}
if
(
validation
.
isMobile
(
mobile
))
{
return
this
.
returnFail
(
"银行卡预留手机号格式错误"
);
}
try
{
let
key
=
this
.
SMS_LOGINMOBILE_KEY
+
mobile
;
let
vcode
=
await
this
.
redisClient
.
get
(
key
+
"t"
);
// let vcode;
if
(
!
vcode
)
{
vcode
=
await
this
.
getVCode
();
await
this
.
redisClient
.
setWithEx
(
key
,
vcode
,
5
*
60
);
await
this
.
redisClient
.
setWithEx
(
key
+
"t"
,
vcode
,
60
);
let
msg
=
"您的个体户注册手机验证码为"
+
vcode
+
", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"
;
let
rs
=
await
this
.
smsClient
.
sendMsg
(
mobile
,
msg
);
//this.addLog(pobj, "sms");
console
.
log
(
rs
);
}
return
this
.
returnSuccess
(
1
);
}
catch
(
error
)
{
return
system
.
getResultFail
(
500
,
"接口异常:"
+
error
.
message
);
}
}
getVCode
()
{
var
randomNum
=
""
+
Math
.
round
(
Math
.
random
()
*
1000000
);
while
(
randomNum
.
length
<
6
)
{
randomNum
=
"0"
+
randomNum
;
}
return
randomNum
;
}
async
bankfour
(
params
)
{
let
nonceStr
=
await
this
.
getUidStr
(
16
,
36
);
let
data
=
{
appId
:
this
.
GTB_APPID
,
userName
:
params
.
userName
,
userIdNo
:
params
.
userIdNo
,
userBankNo
:
params
.
userBankNo
,
userMobile
:
params
.
userMobile
,
nonceStr
:
nonceStr
,
};
// 签名
var
signArr
=
[];
var
keys
=
Object
.
keys
(
data
).
sort
();
for
(
var
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
var
k
=
keys
[
i
];
var
v
=
data
[
k
];
if
(
!
k
||
!
v
||
k
==
'sign'
)
{
continue
;
}
signArr
.
push
(
k
+
"="
+
v
);
}
var
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
this
.
GTB_KEY
;
var
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
sign
);
data
.
sign
=
sign
;
let
rs
=
await
axios
({
method
:
'post'
,
url
:
this
.
BANK_FOUR
,
data
:
data
,
});
try
{
console
.
log
(
rs
.
data
,
`个体户注册银行卡四要素验证request[
${
JSON
.
stringify
(
data
)}
], response[
${
JSON
.
stringify
(
rs
.
data
)}
]`
);
}
catch
(
e
)
{
console
.
log
(
e
.
stack
);
}
return
rs
.
data
||
{};
}
//日志
async
addLog
(
obj
,
consume_type
)
{
let
user
=
await
this
.
getLoginUser
(
obj
.
merchant_id
,
obj
.
openid
);
let
log
=
{
// saas_id: user.saas_id,
saas_merchant_id
:
user
.
saas_merchant_id
,
consume_type
:
consume_type
,
consume_id
:
user
.
id
};
let
rs
=
await
this
.
merchantSve
.
addConsumeLog
({
log
:
log
});
console
.
log
(
"log rs : "
,
rs
);
}
returnResult
(
code
,
msg
,
data
)
{
return
{
code
:
code
||
0
,
msg
:
msg
||
""
,
data
:
data
}
}
returnSuccess
(
data
)
{
return
this
.
returnResult
(
1
,
"success"
,
data
)
}
returnFail
(
msg
,
data
)
{
return
this
.
returnResult
(
0
,
msg
,
data
);
}
trim
(
o
)
{
if
(
!
o
)
{
return
""
;
}
return
o
.
toString
().
trim
();
}
getUidStr
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
exam
()
{
return
""
;
}
classDesc
()
{
return
{
groupName
:
""
,
groupDesc
:
""
,
name
:
""
,
desc
:
""
,
exam
:
""
,
};
}
methodDescs
()
{
return
[
{
methodDesc
:
""
,
methodName
:
""
,
paramdescs
:
[
{
paramDesc
:
""
,
paramName
:
""
,
paramType
:
""
,
defaultValue
:
""
,
}
],
rtnTypeDesc
:
""
,
rtnType
:
""
}
];
}
}
module
.
exports
=
TestAPI
;
esign-admin/app/base/api/impl/inner/aduserApi.js
View file @
9e936a75
...
...
@@ -5,8 +5,8 @@ class ADUserAPI extends APIBase {
super
();
this
.
userSve
=
system
.
getObject
(
"service.uc.userSve"
);
}
async
registerInn
er
(
pobj
,
query
,
req
)
{
var
result
=
await
this
.
userSve
.
registerInn
er
(
pobj
);
async
addAdminUs
er
(
pobj
,
query
,
req
)
{
let
result
=
await
this
.
userSve
.
saveAdminUs
er
(
pobj
);
return
result
;
}
async
resetPasswordInner
(
pobj
,
query
,
req
)
{
...
...
esign-admin/app/base/controller/impl/uc/userCtl.js
View file @
9e936a75
...
...
@@ -16,33 +16,18 @@ class UserCtl extends CtlBase {
var
loginName
=
this
.
trim
(
pobj
.
loginName
);
var
password
=
this
.
trim
(
pobj
.
password
);
try
{
var
loginUser
=
await
this
.
userSve
.
login
({
let
loginUser
=
await
this
.
userSve
.
login
({
ucname
:
loginName
,
password
:
password
,
uctype
:
1
,
});
if
(
loginUser
.
status
!=
0
)
{
return
loginUser
;
}
loginUser
=
loginUser
.
data
;
let
channel
=
await
this
.
merchantSve
.
info
({
id
:
loginUser
.
saas_merchant_id
});
if
(
channel
.
status
!=
0
)
{
return
system
.
getResult
(
null
,
`渠道【
${
loginName
}
】不存在`
);
}
channel
=
channel
.
data
;
loginUser
.
contact_man
=
channel
.
contact_man
;
loginUser
.
contact_mobile
=
channel
.
contact_mobile
;
loginUser
.
contact_email
=
channel
.
contact_email
;
loginUser
.
contact_addr
=
channel
.
contact_addr
;
var
loginsid
=
await
this
.
setLogin
(
loginUser
);
let
rs
=
{
key
:
loginsid
,
loginname
:
loginUser
.
ucname
,
menus
:
await
this
.
getMenu
(
loginUser
)
};
let
rs
=
this
.
loginDTO
(
loginUser
)
rs
.
key
=
await
this
.
setLogin
(
loginUser
);
return
system
.
getResultSuccess
(
rs
);
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -51,10 +36,10 @@ class UserCtl extends CtlBase {
}
async
setLogin
(
user
)
{
let
loginsid
=
"
saasmcth
_"
+
uuidv4
();
//
if (settings.env = "dev") {
// loginsid = "saasmcth
_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7";
//
}
let
loginsid
=
"
esa
_"
+
uuidv4
();
if
(
settings
.
env
=
"dev"
)
{
loginsid
=
"esa
_"
+
"2cb49932-fa02-44f0-90db-9f06fe02e5c7"
;
}
await
this
.
redisClient
.
setWithEx
(
loginsid
,
JSON
.
stringify
(
user
),
60
*
60
*
5
);
return
loginsid
;
}
...
...
@@ -91,16 +76,15 @@ class UserCtl extends CtlBase {
}
async
currentUser
(
qobj
,
pobj
,
req
)
{
let
saas_merchant_id
=
req
.
loginUser
.
saas_merchant_id
;
if
(
!
saas_merchant_id
){
return
system
.
getResult
(
null
,
`登录失效,请重新登录`
);
}
let
_merchant
=
await
this
.
merchantSve
.
info
({
id
:
saas_merchant_id
});
if
(
_merchant
.
status
!=
0
){
return
system
.
getResult
(
null
,
`商户不存在`
);
return
system
.
getResultSuccess
(
this
.
loginDTO
(
req
.
loginUser
));
}
loginDTO
(
user
)
{
return
{
loginName
:
user
.
ucname
,
mobile
:
user
.
mobile
,
real_name
:
user
.
real_name
,
}
req
.
loginUser
.
saas_merchant_name
=
_merchant
.
data
.
name
;
return
system
.
getResultSuccess
(
req
.
loginUser
);
}
/**
...
...
esign-admin/app/base/db/models/common/oplog.js
View file @
9e936a75
...
...
@@ -30,7 +30,7 @@ module.exports = (db, DataTypes) => {
updatedAt
:
false
,
//freezeTableName: true,
// define the table's name
tableName
:
'
xgg_
op_log'
,
tableName
:
'op_log'
,
validate
:
{
},
...
...
esign-admin/app/base/service/impl/uc/userSve.js
View file @
9e936a75
...
...
@@ -6,6 +6,22 @@ class UserService extends ServiceBase {
super
();
}
async
saveAdminUser
(
params
)
{
try
{
return
await
this
.
callms
(
"sve_uc"
,
"saveAdminUser"
,
params
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
saveMerchantUser
(
params
)
{
try
{
return
await
this
.
callms
(
"sve_uc"
,
"saveMerchantUser"
,
params
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
async
login
(
params
)
{
try
{
return
await
this
.
callms
(
"sve_uc"
,
"login"
,
params
);
...
...
esign-admin/app/base/system.js
View file @
9e936a75
...
...
@@ -194,7 +194,7 @@ class System {
engine_sign
:
local
+
":3103"
+
path
,
// 用户服务
sve_uc
:
dev
+
":3651"
+
path
,
sve_uc
:
local
+
":3651"
+
path
,
// 商户服务
sve_merchant
:
dev
+
":3103"
+
path
,
// 订单服务
...
...
esign-admin/app/config/routes/web.js
View file @
9e936a75
...
...
@@ -7,7 +7,7 @@ const redisClient = system.getObject("util.redisClient");
module
.
exports
=
function
(
app
)
{
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
var
loginsid
;
//
var jsonUser = null;
var
jsonUser
=
null
;
if
(
!
jsonUser
)
{
loginsid
=
req
.
headers
[
"esignadminsid"
]
||
""
;
jsonUser
=
await
redisClient
.
get
(
loginsid
);
...
...
@@ -61,8 +61,6 @@ module.exports = function (app) {
if
(
req
.
loginUser
)
{
req
.
query
=
req
.
query
||
{};
req
.
query
.
saas_id
=
req
.
loginUser
.
saas_id
;
req
.
query
.
saas_merchant_id
=
req
.
loginUser
.
saas_merchant_id
;
}
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
...
...
@@ -93,8 +91,6 @@ module.exports = function (app) {
req
.
body
.
classname
=
classPath
;
if
(
req
.
loginUser
)
{
req
.
body
.
saas_id
=
req
.
loginUser
.
saas_id
;
req
.
body
.
saas_merchant_id
=
req
.
loginUser
.
saas_merchant_id
;
}
params
.
push
(
methodName
);
...
...
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