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
46ecc98c
Commit
46ecc98c
authored
Apr 03, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
d560de0c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
233 additions
and
222 deletions
+233
-222
xgg-saas-merchant/app/base/system.js
+233
-222
No files found.
xgg-saas-merchant/app/base/system.js
View file @
46ecc98c
var
fs
=
require
(
"fs"
);
var
fs
=
require
(
"fs"
);
var
objsettings
=
require
(
"../config/objsettings"
);
var
objsettings
=
require
(
"../config/objsettings"
);
var
settings
=
require
(
"../config/settings"
);
var
settings
=
require
(
"../config/settings"
);
class
System
{
class
System
{
static
declare
(
ns
)
{
static
declare
(
ns
)
{
var
ar
=
ns
.
split
(
'.'
);
var
ar
=
ns
.
split
(
'.'
);
var
root
=
System
;
var
root
=
System
;
for
(
var
i
=
0
,
len
=
ar
.
length
;
i
<
len
;
++
i
)
{
for
(
var
i
=
0
,
len
=
ar
.
length
;
i
<
len
;
++
i
)
{
var
n
=
ar
[
i
];
var
n
=
ar
[
i
];
if
(
!
root
[
n
])
{
if
(
!
root
[
n
])
{
root
[
n
]
=
{};
root
[
n
]
=
{};
root
=
root
[
n
];
root
=
root
[
n
];
}
else
{
}
else
{
root
=
root
[
n
];
root
=
root
[
n
];
}
}
}
}
}
}
static
register
(
key
,
ClassObj
)
{
if
(
System
.
objTable
[
key
]
!=
null
)
{
static
register
(
key
,
ClassObj
)
{
throw
new
Error
(
"相同key的对象已经存在"
);
if
(
System
.
objTable
[
key
]
!=
null
)
{
}
else
{
throw
new
Error
(
"相同key的对象已经存在"
);
let
obj
=
new
ClassObj
();
}
else
{
System
.
objTable
[
key
]
=
obj
;
let
obj
=
new
ClassObj
();
}
System
.
objTable
[
key
]
=
obj
;
}
return
System
.
objTable
[
key
];
}
return
System
.
objTable
[
key
];
static
getResult
(
data
,
opmsg
=
"操作成功"
,
req
)
{
}
return
{
status
:
!
data
?
-
1
:
0
,
static
getResult
(
data
,
opmsg
=
"操作成功"
,
req
)
{
msg
:
opmsg
,
return
{
data
:
data
||
null
,
status
:
!
data
?
-
1
:
0
,
bizmsg
:
req
&&
req
.
session
&&
req
.
session
.
bizmsg
?
req
.
session
.
bizmsg
:
"empty"
msg
:
opmsg
,
};
data
:
data
||
null
,
}
bizmsg
:
req
&&
req
.
session
&&
req
.
session
.
bizmsg
?
req
.
session
.
bizmsg
:
"empty"
/**
};
* 请求返回成功
}
* @param {*} data 操作成功返回的数据
* @param {*} okmsg 操作成功的描述
/**
*/
* 请求返回成功
static
getResultSuccess
(
data
,
okmsg
=
"success"
)
{
* @param {*} data 操作成功返回的数据
return
{
* @param {*} okmsg 操作成功的描述
status
:
0
,
*/
msg
:
okmsg
,
static
getResultSuccess
(
data
,
okmsg
=
"success"
)
{
data
:
data
||
null
,
return
{
};
status
:
0
,
}
msg
:
okmsg
,
/**
data
:
data
||
null
,
* 请求返回失败
};
* @param {*} status 操作失败状态,默认为-1
}
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
/**
*/
* 请求返回失败
static
getResultFail
(
status
=
-
1
,
errmsg
=
"fail"
,
data
=
null
)
{
* @param {*} status 操作失败状态,默认为-1
return
{
* @param {*} errmsg 操作失败的描述,默认为fail
status
:
status
,
* @param {*} data 操作失败返回的数据
msg
:
errmsg
,
*/
data
:
data
,
static
getResultFail
(
status
=
-
1
,
errmsg
=
"fail"
,
data
=
null
)
{
};
return
{
}
status
:
status
,
static
getObject
(
objpath
)
{
msg
:
errmsg
,
var
pathArray
=
objpath
.
split
(
"."
);
data
:
data
,
var
packageName
=
pathArray
[
0
];
};
var
groupName
=
pathArray
[
1
];
}
var
filename
=
pathArray
[
2
];
var
classpath
=
""
;
static
getObject
(
objpath
)
{
if
(
filename
)
{
var
pathArray
=
objpath
.
split
(
"."
);
classpath
=
objsettings
[
packageName
]
+
"/"
+
groupName
;
var
packageName
=
pathArray
[
0
];
}
else
{
var
groupName
=
pathArray
[
1
];
classpath
=
objsettings
[
packageName
];
var
filename
=
pathArray
[
2
];
filename
=
groupName
;
var
classpath
=
""
;
}
if
(
filename
)
{
classpath
=
objsettings
[
packageName
]
+
"/"
+
groupName
;
var
objabspath
=
classpath
+
"/"
+
filename
+
".js"
;
}
else
{
if
(
System
.
objTable
[
objabspath
]
!=
null
)
{
classpath
=
objsettings
[
packageName
];
console
.
log
(
"get cached obj"
);
filename
=
groupName
;
return
System
.
objTable
[
objabspath
];
}
}
else
{
console
.
log
(
"no cached..."
);
var
objabspath
=
classpath
+
"/"
+
filename
+
".js"
;
var
ClassObj
=
require
(
objabspath
);
if
(
System
.
objTable
[
objabspath
]
!=
null
)
{
return
System
.
register
(
objabspath
,
ClassObj
);
console
.
log
(
"get cached obj"
);
}
return
System
.
objTable
[
objabspath
];
}
}
else
{
static
getUiConfig
(
appid
)
{
console
.
log
(
"no cached..."
);
var
configPath
=
settings
.
basepath
+
"/app/base/db/metadata/"
+
appid
+
"/index.js"
;
var
ClassObj
=
require
(
objabspath
);
if
(
settings
.
env
==
"dev"
)
{
return
System
.
register
(
objabspath
,
ClassObj
);
delete
require
.
cache
[
configPath
];
}
}
}
var
configValue
=
require
(
configPath
);
return
configValue
;
static
getUiConfig
(
appid
)
{
}
var
configPath
=
settings
.
basepath
+
"/app/base/db/metadata/"
+
appid
+
"/index.js"
;
static
getUiConfig2
(
appid
)
{
if
(
settings
.
env
==
"dev"
)
{
var
configPath
=
settings
.
basepath
+
"/app/base/db/metadata/index.js"
;
delete
require
.
cache
[
configPath
];
// if(settings.env=="dev"){
}
// console.log("delete "+configPath+"cache config");
var
configValue
=
require
(
configPath
);
// delete require.cache[configPath];
return
configValue
;
// }
}
delete
require
.
cache
[
configPath
];
var
configValue
=
require
(
configPath
);
static
getUiConfig2
(
appid
)
{
return
configValue
[
appid
];
var
configPath
=
settings
.
basepath
+
"/app/base/db/metadata/index.js"
;
}
// if(settings.env=="dev"){
static
get_client_ip
(
req
)
{
// console.log("delete "+configPath+"cache config");
var
ip
=
req
.
headers
[
'x-forwarded-for'
]
||
// delete require.cache[configPath];
req
.
ip
||
// }
req
.
connection
.
remoteAddress
||
delete
require
.
cache
[
configPath
];
req
.
socket
.
remoteAddress
||
var
configValue
=
require
(
configPath
);
(
req
.
connection
.
socket
&&
req
.
connection
.
socket
.
remoteAddress
)
||
''
;
return
configValue
[
appid
];
var
x
=
ip
.
match
(
/
(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
])\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
]
|0
)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
]
|0
)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
0-9
])
$/
);
}
if
(
x
)
{
return
x
[
0
];
static
get_client_ip
(
req
)
{
}
else
{
var
ip
=
req
.
headers
[
'x-forwarded-for'
]
||
return
"localhost"
;
req
.
ip
||
}
req
.
connection
.
remoteAddress
||
req
.
socket
.
remoteAddress
||
};
(
req
.
connection
.
socket
&&
req
.
connection
.
socket
.
remoteAddress
)
||
''
;
var
x
=
ip
.
match
(
/
(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
])\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
]
|0
)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
1-9
]
|0
)\.(
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
0-1
]{1}[
0-9
]{2}
|
[
1-9
]{1}[
0-9
]{1}
|
[
0-9
])
$/
);
static
y2f
(
y
)
{
if
(
x
)
{
if
(
!
y
)
{
return
x
[
0
];
return
0
;
}
else
{
}
return
"localhost"
;
return
(
Number
(
y
)
*
100
).
toFixed
(
0
);
}
}
};
static
f2y
(
f
)
{
if
(
!
f
)
{
static
y2f
(
y
)
{
return
0
;
if
(
!
y
)
{
}
return
0
;
return
parseFloat
((
Number
(
f
)
/
100
).
toFixed
(
2
));
}
}
return
(
Number
(
y
)
*
100
).
toFixed
(
0
);
}
static
f2y4list
(
list
,
fields
,
prev
)
{
if
(
!
list
||
list
.
length
==
0
||
!
fields
||
fields
.
length
==
0
)
{
static
f2y
(
f
)
{
return
;
if
(
!
f
)
{
}
return
0
;
prev
=
prev
||
""
;
}
for
(
var
item
of
list
)
{
return
parseFloat
((
Number
(
f
)
/
100
).
toFixed
(
2
));
for
(
var
f
of
fields
)
{
}
var
v
=
item
[
f
]
||
0
;
try
{
static
f2y4list
(
list
,
fields
,
prev
)
{
item
[
f
+
"_y"
]
=
prev
+
parseFloat
((
Number
(
v
)
/
100
).
toFixed
(
2
));
if
(
!
list
||
list
.
length
==
0
||
!
fields
||
fields
.
length
==
0
)
{
}
catch
(
error
)
{
return
;
console
.
log
(
error
);
}
}
prev
=
prev
||
""
;
}
for
(
var
item
of
list
)
{
}
for
(
var
f
of
fields
)
{
}
var
v
=
item
[
f
]
||
0
;
static
getUid
(
len
,
radix
)
{
try
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
item
[
f
+
"_y"
]
=
prev
+
parseFloat
((
Number
(
v
)
/
100
).
toFixed
(
2
));
var
uuid
=
[],
}
catch
(
error
)
{
i
;
console
.
log
(
error
);
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
]
=
'-'
;
static
getUid
(
len
,
radix
)
{
uuid
[
14
]
=
'4'
;
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
for
(
i
=
0
;
i
<
36
;
i
++
)
{
var
uuid
=
[],
if
(
!
uuid
[
i
])
{
i
;
r
=
0
|
Math
.
random
()
*
16
;
radix
=
radix
||
chars
.
length
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
if
(
len
)
{
}
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
}
else
{
}
var
r
;
return
uuid
.
join
(
''
);
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
}
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
static
microsetting
()
{
if
(
!
uuid
[
i
])
{
console
.
log
(
settings
.
env
,
"-------------- microsetting env ------------------"
);
r
=
0
|
Math
.
random
()
*
16
;
var
path
=
"/api/op/action/springboard"
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
if
(
settings
.
env
==
"dev"
)
{
}
// var domain = "http://192.168.18.237";
}
let
local
=
"http://127.0.0.1"
;
}
let
dev
=
"http://39.107.234.14"
;
return
uuid
.
join
(
''
);
return
{
}
// 公共服务
common
:
dev
+
":3102"
+
path
,
static
microsetting
()
{
// common: "http://127.0.0.1:3102" + path,
console
.
log
(
settings
.
env
,
"-------------- microsetting env ------------------"
);
var
path
=
"/api/op/action/springboard"
;
// 商户服务
if
(
settings
.
env
==
"dev"
)
{
merchant
:
dev
+
":3101"
+
path
,
// var domain = "http://192.168.18.237";
// merchant: "http://127.0.0.1:3101" + path,
let
local
=
"http://127.0.0.1"
;
let
dev
=
"http://39.107.234.14"
;
// 订单服务
return
{
order
:
dev
+
":3103"
+
path
,
// 公共服务
// order: "http://127.0.0.1:3103" + path,
common
:
dev
+
":3102"
+
path
,
// common: "http://127.0.0.1:3102" + path,
// 发票服务
invoice
:
dev
+
":3105"
+
path
,
// 商户服务
// invoice: "http://127.0.0.1:3105" + path,
merchant
:
dev
+
":3101"
+
path
,
// merchant: "http://127.0.0.1:3101" + path,
// 用户服务
uc
:
dev
+
":3106"
+
path
,
// 订单服务
// uc: "http://127.0.0.1:3106" + path,
order
:
dev
+
":3103"
+
path
,
// order: "http://127.0.0.1:3103" + path,
// 交易
trade
:
local
+
":3107"
+
path
,
// 发票服务
// uc: "http://127.0.0.1:3106" + path,
invoice
:
dev
+
":3105"
+
path
,
}
// invoice: "http://127.0.0.1:3105" + path,
}
else
{
var
odomain
=
"http://123.57.217.203"
// 用户服务
return
{
uc
:
dev
+
":3106"
+
path
,
common
:
"xggsvecommon-service"
+
path
,
// uc: "http://127.0.0.1:3106" + path,
merchant
:
"xggsvemerchant-service"
+
path
,
order
:
"xggsveorder-service"
+
path
,
// 交易
invoice
:
"xggsveinvoice-service"
+
path
,
trade
:
local
+
":3107"
+
path
,
uc
:
"xggsveuc-service"
+
path
,
// uc: "http://127.0.0.1:3106" + path,
trade
:
"xggsvetrade-service"
+
path
,
}
}
}
else
{
}
var
odomain
=
"http://123.57.217.203"
}
return
{
common
:
"xggsvecommon-service"
+
path
,
merchant
:
"xggsvemerchant-service"
+
path
,
order
:
"xggsveorder-service"
+
path
,
invoice
:
"xggsveinvoice-service"
+
path
,
uc
:
"xggsveuc-service"
+
path
,
trade
:
"xggsvetrade-service"
+
path
,
}
}
}
}
}
Date
.
prototype
.
Format
=
function
(
fmt
)
{
//author: meizz
Date
.
prototype
.
Format
=
function
(
fmt
)
{
//author: meizz
var
o
=
{
var
o
=
{
"M+"
:
this
.
getMonth
()
+
1
,
//月份
"M+"
:
this
.
getMonth
()
+
1
,
//月份
"d+"
:
this
.
getDate
(),
//日
"d+"
:
this
.
getDate
(),
//日
"h+"
:
this
.
getHours
(),
//小时
"h+"
:
this
.
getHours
(),
//小时
"m+"
:
this
.
getMinutes
(),
//分
"m+"
:
this
.
getMinutes
(),
//分
"s+"
:
this
.
getSeconds
(),
//秒
"s+"
:
this
.
getSeconds
(),
//秒
"q+"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
//季度
"q+"
:
Math
.
floor
((
this
.
getMonth
()
+
3
)
/
3
),
//季度
"S"
:
this
.
getMilliseconds
()
//毫秒
"S"
:
this
.
getMilliseconds
()
//毫秒
};
};
if
(
/
(
y+
)
/
.
test
(
fmt
))
if
(
/
(
y+
)
/
.
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
this
.
getFullYear
()
+
""
).
substr
(
4
-
RegExp
.
$1
.
length
));
for
(
var
k
in
o
)
for
(
var
k
in
o
)
if
(
new
RegExp
(
"("
+
k
+
")"
).
test
(
fmt
))
if
(
new
RegExp
(
"("
+
k
+
")"
).
test
(
fmt
))
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
fmt
=
fmt
.
replace
(
RegExp
.
$1
,
(
RegExp
.
$1
.
length
==
1
)
?
(
o
[
k
])
:
((
"00"
+
o
[
k
]).
substr
((
""
+
o
[
k
]).
length
)));
return
fmt
;
return
fmt
;
}
}
System
.
objTable
=
{};
System
.
objTable
=
{};
//访问token失效,请重新获取
//访问token失效,请重新获取
...
...
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