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
648426f7
Commit
648426f7
authored
Jun 10, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'xgg-saas-merchant-h5' into xgg-saas-merchant
parents
35a6cd75
6a2ba2e2
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
69 deletions
+203
-69
xgg-saas-merchant/app/base/api/api.base.js
+11
-0
xgg-saas-merchant/app/base/api/impl/h5/merchantApi.js
+190
-67
xgg-saas-merchant/app/base/service/svems.base.js
+1
-1
xgg-saas-merchant/app/base/system.js
+1
-1
No files found.
xgg-saas-merchant/app/base/api/api.base.js
View file @
648426f7
...
...
@@ -9,6 +9,17 @@ 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
();
...
...
xgg-saas-merchant/app/base/api/impl/h5/merchantApi.js
View file @
648426f7
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
();
...
...
@@ -22,27 +26,68 @@ class TestAPI extends APIBase {
this
.
smsClient
=
system
.
getObject
(
"util.smsClient"
);
}
//
async
loginUser
(
gobj
,
pobj
,
req
,
loginUser
)
{
// TODO pobj.merchant_id 前端传过来,解密
let
user
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
openid
);
return
this
.
returnSuccess
(
user
);
//H5登录获取验证码
async
sendMobileCode
(
obj
,
obj1
,
req
)
{
let
mobile
=
obj
.
mobile
;
if
(
!
mobile
)
{
return
this
.
returnFail
(
"请先填写手机号"
);
}
if
(
validation
.
isMobile
(
mobile
))
{
return
this
.
returnFail
(
"手机号格式错误"
);
}
async
uploadConfig
(
gobj
,
pobj
,
req
,
loginUser
)
{
try
{
let
data
=
await
this
.
uploadCtl
.
getOssConfig
();
return
this
.
returnSuccess
(
data
);
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
)
{
console
.
log
(
error
);
return
{
code
:
500
};
return
system
.
getResultFail
(
500
,
"接口异常:"
+
error
.
message
);
}
}
// 登录接口 post
async
login
(
o
,
obj
,
req
)
{
async
login
(
o
bj
,
obj1
,
req
)
{
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
=
decodeURIComponent
(
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
);
...
...
@@ -54,19 +99,34 @@ class TestAPI extends APIBase {
}
}
async
addLog
(
pobj
,
consume_type
)
{
let
user
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
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
);
//验证登录
async
loginUser
(
obj
)
{
let
merchant_id
=
decodeURIComponent
(
obj
.
merchant_id
);
let
user
=
await
this
.
getLoginUser
(
merchant_id
,
obj
.
openid
);
return
this
.
returnSuccess
(
user
);
}
async
uploadConfig
(
obj
,
obj1
,
req
)
{
try
{
let
data
=
await
this
.
uploadCtl
.
getOssConfig
();
return
this
.
returnSuccess
(
data
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
{
code
:
500
};
}
}
// 保存订单信息
async
saveOrder
(
gobj
,
pobj
,
req
,
loginUser
)
{
async
saveOrder
(
obj
,
obj1
,
req
)
{
try
{
// TODO this.loginUser();
let
rs
=
await
this
.
buildOrder
(
pobj
);
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnFail
(
"订单保存失败"
);
}
let
rs
=
await
this
.
buildOrder
(
obj
);
if
(
rs
.
code
===
0
)
{
return
rs
;
}
...
...
@@ -78,18 +138,19 @@ class TestAPI extends APIBase {
userBankNo
:
bminfo
.
bank_no
,
userMobile
:
bminfo
.
bank_mobile
,
});
this
.
addLog
(
p
obj
,
"bankfour"
);
// this.addLog(
obj, "bankfour");
if
(
bf
.
code
!==
0
)
{
return
this
.
returnFail
(
"银行卡四要素验证失败,请检查法人姓名,身份证,银行卡号,银行卡预留手机号正确"
);
}
let
merchant
=
await
this
.
getMerchant
(
p
obj
.
merchant_id
);
let
loginUser
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
openid
);
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
.
id
,
merchant_app_user_id
:
loginUser
.
data
.
id
,
price
:
system
.
y2f
(
merchant
.
sign
.
bm_reg_price
)
||
0
,
bminfo
:
rs
.
data
};
...
...
@@ -157,13 +218,13 @@ class TestAPI extends APIBase {
return
this
.
returnFail
(
"请填写短信验证码"
);
}
let
vcode
=
await
this
.
redisClient
.
get
(
this
.
SMS_BANK
MOBILE_KEY
+
obj
.
bank_mobile
);
if
(
!
vcode
)
{
return
this
.
returnFail
(
"短信验证码已过期,请重新发送"
);
}
if
(
vcode
!=
noteCode
)
{
return
this
.
returnFail
(
"短信验证码错误,请重新填写"
);
}
// let vcode = await this.redisClient.get(this.SMS_LOGIN
MOBILE_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
,
...
...
@@ -181,19 +242,18 @@ class TestAPI extends APIBase {
return
this
.
returnSuccess
(
bminfo
);
}
async
myOrders
(
gobj
,
pobj
,
req
)
{
async
myOrders
(
obj
,
obj1
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
openid
);
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
try
{
let
params
=
{
pageSize
:
Number
(
p
obj
.
pageSize
||
10
),
currentPage
:
Number
(
p
obj
.
currentPage
||
1
),
merchant_app_user_id
:
loginUser
.
id
,
merchant_id
:
loginUser
.
merchant_id
,
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
page
=
await
this
.
orderSve
.
page
(
params
);
...
...
@@ -223,19 +283,19 @@ class TestAPI extends APIBase {
* @param {*} req
* @param {*} loginUser
*/
async
orderInfo
(
gobj
,
pobj
,
req
)
{
async
orderInfo
(
obj
,
obj1
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
openid
);
let
loginUser
=
await
this
.
loginUser
(
obj
);
if
(
!
loginUser
)
{
return
this
.
returnSuccess
({});
}
try
{
let
rs
=
await
this
.
orderSve
.
orderInfo
(
p
obj
);
let
rs
=
await
this
.
orderSve
.
orderInfo
(
obj
);
if
(
rs
.
status
===
0
)
{
return
this
.
returnSuccess
(
rs
.
data
);
}
else
{
return
this
.
returnFail
(
page
.
msg
);
return
this
.
returnFail
(
rs
.
msg
);
}
}
catch
(
error
)
{
console
.
log
(
error
);
...
...
@@ -243,9 +303,9 @@ class TestAPI extends APIBase {
}
}
async
idNoValid
(
gobj
,
pobj
,
req
,
loginUser
)
{
async
idNoValid
(
obj
,
obj1
,
req
)
{
try
{
let
idno
=
(
p
obj
.
idno
||
""
).
trim
();
let
idno
=
(
obj
.
idno
||
""
).
trim
();
if
(
!
idno
)
{
return
{
code
:
0
,
msg
:
"请填写身份证号码"
};
}
...
...
@@ -271,9 +331,9 @@ class TestAPI extends APIBase {
async
saasorderbusinessmenPage
(
params
,
pobj2
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj2
.
merchant_id
,
pobj2
.
openid
);
p
obj2
.
merchant_app_user_id
=
loginUser
.
id
;
let
res
=
await
this
.
businessmenSve
.
saasorderbusinessmenPage
(
p
obj2
);
let
loginUser
=
await
this
.
loginUser
(
params
);
p
arams
.
merchant_app_user_id
=
loginUser
.
data
.
id
;
let
res
=
await
this
.
businessmenSve
.
saasorderbusinessmenPage
(
p
arams
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
...
...
@@ -288,16 +348,16 @@ class TestAPI extends APIBase {
* @param req
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async
saasTradeBusinessmenPage
(
pobj1
,
pobj2
,
req
)
{
async
saasTradeBusinessmenPage
(
obj
,
obj1
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj2
.
merchant_id
,
pobj2
.
openid
);
pobj2
.
merchant_app_user_id
=
loginUser
.
id
;
pobj2
.
attrs
=
[
"credit_code"
];
if
(
!
pobj2
.
merchant_app_user_id
)
{
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
(
pobj2
);
let
creditCodeArray
=
await
this
.
businessmenSve
.
assorderBusinessmenInfo
(
obj
);
if
(
creditCodeArray
.
status
!=
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
...
...
@@ -308,8 +368,8 @@ class TestAPI extends APIBase {
if
(
!
creditCodes
||
creditCodes
.
length
==
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
pobj2
.
credit_code_array
=
creditCodes
;
let
res
=
await
this
.
tradeSve
.
tradeItemBycreditCode
(
pobj2
);
obj
.
credit_code_array
=
creditCodes
;
let
res
=
await
this
.
tradeSve
.
tradeItemBycreditCode
(
obj
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
...
...
@@ -328,16 +388,16 @@ class TestAPI extends APIBase {
* @param req
* @returns {Promise<void>}
*/
async
invoiceBycreditCode
(
pobj1
,
pobj2
,
req
)
{
async
invoiceBycreditCode
(
obj
,
obj1
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj2
.
merchant_id
,
pobj2
.
openid
);
pobj2
.
merchant_app_user_id
=
loginUser
.
id
;
pobj2
.
attrs
=
[
"credit_code"
];
if
(
!
pobj2
.
merchant_app_user_id
)
{
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
(
pobj2
);
let
creditCodeArray
=
await
this
.
businessmenSve
.
assorderBusinessmenInfo
(
obj
);
if
(
creditCodeArray
.
status
!=
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
...
...
@@ -349,9 +409,9 @@ class TestAPI extends APIBase {
if
(
!
creditCodes
||
creditCodes
.
length
==
0
)
{
return
this
.
returnSuccess
({
count
:
0
,
rows
:
[]});
}
pobj2
.
credit_code_array
=
creditCodes
;
obj
.
credit_code_array
=
creditCodes
;
let
res
=
await
this
.
saasInvoiceSve
.
invoiceBycreditCode
(
pobj2
);
let
res
=
await
this
.
saasInvoiceSve
.
invoiceBycreditCode
(
obj
);
if
(
res
.
status
==
0
)
{
return
this
.
returnSuccess
(
res
.
data
);
}
else
{
...
...
@@ -370,10 +430,10 @@ class TestAPI extends APIBase {
* @param req
* @returns {Promise<void>}
*/
async
sendBankMobileCode
(
pobj1
,
pobj
,
req
)
{
async
sendBankMobileCode
(
obj
,
obj1
,
req
)
{
// TODO this.loginUser();
let
loginUser
=
await
this
.
getLoginUser
(
pobj
.
merchant_id
,
pobj
.
openid
);
let
mobile
=
p
obj
.
mobile
;
let
loginUser
=
await
this
.
loginUser
(
obj
);
let
mobile
=
obj
.
mobile
;
if
(
!
mobile
)
{
return
this
.
returnFail
(
"请先填写银行卡预留手机号"
);
}
...
...
@@ -390,7 +450,7 @@ class TestAPI extends APIBase {
await
this
.
redisClient
.
setWithEx
(
key
+
"t"
,
vcode
,
60
);
let
msg
=
"您的个体户注册手机验证码为"
+
vcode
+
", (切勿将验证码告知别人, 请在5分钟内输入完成验证, 如有问题请联系客服。)"
;
let
rs
=
await
this
.
smsClient
.
sendMsg
(
mobile
,
msg
);
this
.
addLog
(
pobj
,
"sms"
);
//
this.addLog(pobj, "sms");
console
.
log
(
rs
);
}
return
this
.
returnSuccess
(
1
);
...
...
@@ -399,6 +459,7 @@ class TestAPI extends APIBase {
}
}
getVCode
()
{
var
randomNum
=
""
+
Math
.
round
(
Math
.
random
()
*
1000000
);
while
(
randomNum
.
length
<
6
)
{
...
...
@@ -447,9 +508,69 @@ class TestAPI extends APIBase {
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
:
""
,
...
...
@@ -459,6 +580,7 @@ class TestAPI extends APIBase {
exam
:
""
,
};
}
methodDescs
()
{
return
[
{
...
...
@@ -478,4 +600,5 @@ class TestAPI extends APIBase {
];
}
}
module
.
exports
=
TestAPI
;
xgg-saas-merchant/app/base/service/svems.base.js
View file @
648426f7
...
...
@@ -220,7 +220,7 @@ class ServiceBase {
}
try
{
var
params
=
{
"action_process"
:
"
xgg-saas-platform
"
,
"action_process"
:
"
sijibao
"
,
"action_type"
:
apiName
,
"action_body"
:
params
||
{},
}
...
...
xgg-saas-merchant/app/base/system.js
View file @
648426f7
...
...
@@ -194,7 +194,7 @@ class System {
merchant
:
dev
+
":3101"
+
path
,
// 订单服务
order
:
local
+
":3103"
+
path
,
order
:
dev
+
":3103"
+
path
,
// 发票服务
invoice
:
dev
+
":3105"
+
path
,
...
...
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