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
634b524f
Commit
634b524f
authored
Jun 22, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
78c9c994
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
0 additions
and
1223 deletions
+0
-1223
xggsve-chance/app/base/api/impl/op/action.js
+0
-60
xggsve-chance/app/base/db/models/auth/user.js
+0
-87
xggsve-chance/app/base/db/models/common/oplog.js
+0
-40
xggsve-chance/app/base/db/models/common/task.js
+0
-57
xggsve-chance/app/base/service/impl/auth/userSve.js
+0
-71
xggsve-chance/app/base/service/impl/common/cacheSve.js
+0
-49
xggsve-chance/app/base/service/impl/common/metaSve.js
+0
-30
xggsve-chance/app/base/service/impl/common/oplogSve.js
+0
-76
xggsve-chance/app/base/service/impl/common/taskSve.js
+0
-165
xggsve-chance/app/base/service/impl/deliver/deliverSve.js
+0
-0
xggsve-chance/app/base/service/impl/trade/storderSve.js
+0
-245
xggsve-chance/app/base/service/impl/trade/storderitemSve.js
+0
-208
xggsve-chance/app/base/service/impl/trade/stpaySve.js
+0
-135
No files found.
xggsve-chance/app/base/api/impl/op/action.js
View file @
634b524f
...
...
@@ -34,70 +34,10 @@ class ActionAPI extends APIBase {
async
handleRequest
(
action_process
,
action_type
,
action_body
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
// 图片验证码
case
"test"
:
opResult
=
await
this
.
storderSve
.
test
(
action_body
);
break
;
case
"orderPage"
:
opResult
=
await
this
.
storderSve
.
pageByCondition
(
action_body
);
break
;
case
"orderAdd"
:
opResult
=
await
this
.
storderSve
.
saveOrder
(
action_body
);
break
;
case
"orderInfo"
:
opResult
=
await
this
.
storderSve
.
info
(
action_body
);
break
;
case
"orderPay"
:
opResult
=
await
this
.
storderSve
.
pay
(
action_body
);
break
;
case
"orderAudit1"
:
opResult
=
await
this
.
storderSve
.
audit1
(
action_body
);
break
;
case
"orderAudit2"
:
opResult
=
await
this
.
storderSve
.
audit2
(
action_body
);
break
;
case
"orderTrade"
:
opResult
=
await
this
.
storderSve
.
trade
(
action_body
);
break
;
break
;
case
"itemPage"
:
opResult
=
await
this
.
storderitemSve
.
pageByCondition
(
action_body
);
break
;
case
"itemTradeOfflineCB"
:
opResult
=
await
this
.
storderitemSve
.
tradeOfflineCB
(
action_body
);
break
;
case
"itemByIds"
:
opResult
=
await
this
.
storderitemSve
.
byIds
(
action_body
);
break
;
case
"itemByInvoiceId"
:
opResult
=
await
this
.
storderitemSve
.
bySaasInvoiceId
(
action_body
);
break
;
case
"updateItemInvoice"
:
opResult
=
await
this
.
storderitemSve
.
updateInvoice
(
action_body
);
break
;
case
"cancelItemInvoice"
:
opResult
=
await
this
.
storderitemSve
.
cancelInvoice
(
action_body
);
break
;
case
"cancelInvoiceByDataIds"
:
opResult
=
await
this
.
storderitemSve
.
cancelInvoiceByDataIds
(
action_body
);
break
;
case
"invoiceTrade"
:
opResult
=
await
this
.
storderitemSve
.
invoiceTrade
(
action_body
);
break
;
case
"saveStPay"
:
opResult
=
await
this
.
stpaySve
.
saveStPay
(
action_body
);
break
;
case
"mapByBusiIds"
:
opResult
=
await
this
.
stpaySve
.
mapByBusiIds
(
action_body
);
break
;
case
"updateStatus"
:
opResult
=
await
this
.
stpaySve
.
updateStatus
(
action_body
);
break
;
case
"tradeItemBycreditCode"
:
opResult
=
await
this
.
storderitemSve
.
tradeItemBycreditCode
(
action_body
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
xggsve-chance/app/base/db/models/auth/user.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"user"
,
{
userName
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
password
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
nickName
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
sex
:
{
type
:
DataTypes
.
ENUM
,
allowNull
:
true
,
values
:
Object
.
keys
(
uiconfig
.
config
.
pdict
.
sex
),
},
mobile
:
DataTypes
.
STRING
,
mail
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
headUrl
:
DataTypes
.
STRING
,
isAdmin
:{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
isSuper
:{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
openId
:
DataTypes
.
STRING
,
app_id
:
DataTypes
.
INTEGER
,
account_id
:
DataTypes
.
INTEGER
,
isEnabled
:{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
true
},
},{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'p_user'
,
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}]
// }
]
});
}
xggsve-chance/app/base/db/models/common/oplog.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"oplog"
,
{
appid
:
DataTypes
.
STRING
,
appkey
:
DataTypes
.
STRING
,
requestId
:
DataTypes
.
STRING
,
logLevel
:
{
type
:
DataTypes
.
ENUM
,
allowNull
:
false
,
values
:
Object
.
keys
(
uiconfig
.
config
.
pdict
.
logLevel
),
defaultValue
:
"info"
,
},
op
:
DataTypes
.
STRING
,
content
:
DataTypes
.
STRING
(
5000
),
resultInfo
:
DataTypes
.
TEXT
,
clientIp
:
DataTypes
.
STRING
,
agent
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
opTitle
:
DataTypes
.
STRING
(
500
),
},
{
paranoid
:
false
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
timestamps
:
true
,
updatedAt
:
false
,
//freezeTableName: true,
// define the table's name
tableName
:
'op_log'
,
validate
:
{
},
indexes
:
[
]
});
}
xggsve-chance/app/base/db/models/common/task.js
deleted
100644 → 0
View file @
78c9c994
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"task"
,
{
app_id
:
DataTypes
.
STRING
,
//需要在后台补充
taskClassName
:
{
type
:
DataTypes
.
STRING
(
100
),
allowNull
:
false
,
unique
:
true
},
//和user的from相同,在注册user时,去创建
taskexp
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
//和user的from相同,在注册user时,去创建
desc
:
DataTypes
.
STRING
,
//需要在后台补充
},{
paranoid
:
false
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'p_task'
,
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}]
// }
]
});
}
xggsve-chance/app/base/service/impl/auth/userSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
const
settings
=
require
(
"../../../../config/settings"
)
class
UserService
extends
ServiceBase
{
constructor
()
{
super
(
"auth"
,
ServiceBase
.
getDaoName
(
UserService
));
}
async
authByCode
(
opencode
)
{
var
existedUser
=
null
;
var
rawUser
=
null
;
var
openuser
=
await
this
.
apiCallWithAk
(
settings
.
paasUrl
()
+
"api/auth/accessAuth/authByCode"
,
{
opencode
:
opencode
});
if
(
openuser
)
{
//先查看自己系统中是否已经存在当前用户
existedUser
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
ucname
:
openuser
.
userName
,
ucid
:
openuser
.
id
},
raw
:
true
});
if
(
!
existedUser
)
{
existedUser
=
await
this
.
register
(
openuser
);
}
rawUser
=
existedUser
.
get
({
raw
:
true
});
rawUser
.
Roles
=
openuser
.
Roles
;
}
return
rawUser
;
}
async
getUserLoginInfo
(
token
)
{
var
acckapp
=
await
this
.
cacheManager
[
"ApiUserCache"
].
cache
(
token
,
null
,
settings
.
usertimeout
);
}
async
register
(
openuser
)
{
var
param
=
{
ucname
:
openuser
.
userName
,
ucid
:
openuser
.
id
,
last_login_time
:
new
Date
()
}
var
cruser
=
await
this
.
dao
.
create
(
param
);
return
cruser
;
}
//在平台进行登录,返回目标认证地址
async
navSysSetting
(
user
)
{
var
sysLoginUrl
=
settings
.
paasUrl
()
+
"web/auth/userCtl/login?appKey="
+
settings
.
appKey
+
"
\
&toKey="
+
settings
.
paasKey
;
var
x
=
{
userName
:
user
.
userName
,
password
:
user
.
password
,
mobile
:
user
.
mobile
};
var
restResult
=
await
this
.
restS
.
execPost
({
u
:
x
},
sysLoginUrl
);
if
(
restResult
)
{
var
rtnres
=
JSON
.
parse
(
restResult
.
stdout
);
if
(
rtnres
.
status
==
0
)
{
return
rtnres
.
data
;
}
}
return
null
;
}
async
getUserByUserNamePwd
(
u
)
{
var
user
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
userName
:
u
.
userName
,
password
:
u
.
password
,
app_id
:
u
.
app_id
},
include
:
[
{
model
:
this
.
db
.
models
.
role
,
as
:
"Roles"
,
attributes
:
[
"id"
,
"code"
]
},
]
});
return
user
;
}
async
checkSameName
(
uname
,
appid
)
{
var
ac
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
userName
:
uname
,
app_id
:
appid
}
});
var
rtn
=
{
isExist
:
false
};
if
(
ac
)
{
rtn
.
isExist
=
true
;
}
return
rtn
;
}
}
module
.
exports
=
UserService
;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
xggsve-chance/app/base/service/impl/common/cacheSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
CacheService
{
constructor
()
{
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
async
buildCacheRtn
(
pageValues
)
{
var
ps
=
pageValues
.
map
(
k
=>
{
var
tmpList
=
k
.
split
(
"|"
);
if
(
tmpList
.
length
==
2
)
{
return
{
name
:
tmpList
[
0
],
val
:
tmpList
[
1
],
key
:
k
};
}
});
return
ps
;
}
async
findAndCountAll
(
obj
)
{
const
pageNo
=
obj
.
pageInfo
.
pageNo
;
const
pageSize
=
obj
.
pageInfo
.
pageSize
;
const
limit
=
pageSize
;
const
offset
=
(
pageNo
-
1
)
*
pageSize
;
var
search_name
=
obj
.
search
&&
obj
.
search
.
name
?
obj
.
search
.
name
:
""
;
var
cacheCacheKeyPrefix
=
"sadd_children_appkeys:"
+
settings
.
appKey
+
"_cachekey"
;
var
cacheList
=
await
this
.
cacheManager
[
"MagCache"
].
getCacheSmembersByKey
(
cacheCacheKeyPrefix
);
if
(
search_name
)
{
cacheList
=
cacheList
.
filter
(
f
=>
f
.
indexOf
(
search_name
)
>=
0
);
}
var
pageValues
=
cacheList
.
slice
(
offset
,
offset
+
limit
);
var
kobjs
=
await
this
.
buildCacheRtn
(
pageValues
);
var
tmpList
=
{
results
:
{
rows
:
kobjs
,
count
:
cacheList
.
length
}
};
return
system
.
getResultSuccess
(
tmpList
);
}
async
delCache
(
obj
)
{
var
keyList
=
obj
.
del_cachekey
.
split
(
"|"
);
if
(
keyList
.
length
==
2
)
{
var
cacheCacheKeyPrefix
=
"sadd_children_appkeys:"
+
settings
.
appKey
+
"_cachekey"
;
await
this
.
cacheManager
[
"MagCache"
].
delCacheBySrem
(
cacheCacheKeyPrefix
,
obj
.
del_cachekey
);
await
this
.
cacheManager
[
"MagCache"
].
del
(
keyList
[
0
]);
return
{
status
:
0
};
}
}
async
clearAllCache
(
obj
)
{
await
this
.
cacheManager
[
"MagCache"
].
clearAll
();
return
{
status
:
0
};
}
}
module
.
exports
=
CacheService
;
xggsve-chance/app/base/service/impl/common/metaSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
MetaService
extends
ServiceBase
{
constructor
(){
super
(
"common"
,
ServiceBase
.
getDaoName
(
MetaService
));
}
async
getApiDoc
(
appid
){
var
p
=
settings
.
basepath
+
"/app/base/db/impl/common/apiDocManager.js"
;
var
ClassObj
=
require
(
p
)
;
var
obj
=
new
ClassObj
();
return
obj
.
doc
;
}
async
getUiConfig
(
appid
){
const
cfg
=
await
this
.
cacheManager
[
"UIConfigCache"
].
cache
(
appid
,
null
,
60
);
return
cfg
;
}
async
getBaseComp
(){
var
basecomp
=
await
this
.
apiCallWithAk
(
settings
.
paasUrl
()
+
"api/meta/baseComp/getBaseComp"
,{});
return
basecomp
.
basecom
;
}
async
findAuthsByRole
(
rolesarray
,
appid
){
var
result
=
await
this
.
apiCallWithAk
(
settings
.
paasUrl
()
+
"api/auth/roleAuth/findAuthsByRole"
,{
roles
:
rolesarray
,
appid
:
appid
});
return
result
;
}
}
module
.
exports
=
MetaService
;
xggsve-chance/app/base/service/impl/common/oplogSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
OplogService
extends
ServiceBase
{
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
OplogService
));
//this.appDao=system.getObject("db.appDao");
this
.
opLogUrl
=
settings
.
apiconfig
.
opLogUrl
();
this
.
opLogEsIsAdd
=
settings
.
apiconfig
.
opLogEsIsAdd
();
}
async
create
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
return
null
;
}
var
rc
=
system
.
getObject
(
"util.execClient"
);
var
rtn
=
null
;
try
{
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj
.
optitle
=
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":"
+
qobj
.
optitle
;
if
(
this
.
opLogEsIsAdd
==
1
)
{
qobj
.
content
=
qobj
.
content
.
replace
(
"field list"
,
"字段列表"
)
qobj
.
created_at
=
(
new
Date
()).
getTime
();
//往Es中写入日志
var
addEsData
=
JSON
.
stringify
(
qobj
);
rc
.
execPost
(
qobj
,
this
.
opLogUrl
);
}
else
{
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
this
.
dao
.
create
(
qobj
);
}
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"addLog------error-----------------------*****************"
);
qobj
.
content
=
e
.
stack
;
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
this
.
dao
.
create
(
qobj
);
}
}
async
createDb
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
return
null
;
}
try
{
qobj
.
optitle
=
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":"
+
qobj
.
optitle
;
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
this
.
dao
.
create
(
qobj
);
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"addLog------error-----------------------*****************"
);
qobj
.
content
=
e
.
stack
;
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
this
.
dao
.
create
(
qobj
);
}
}
}
module
.
exports
=
OplogService
;
xggsve-chance/app/base/service/impl/common/taskSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
fs
=
require
(
"fs"
);
var
excel
=
require
(
'exceljs'
);
const
uuidv4
=
require
(
'uuid/v4'
);
var
path
=
require
(
'path'
);
class
TaskService
extends
ServiceBase
{
constructor
(){
super
(
ServiceBase
.
getDaoName
(
TaskService
));
//this.appDao=system.getObject("db.appDao");
this
.
taskManager
=
system
.
getObject
(
"db.taskManager"
);
this
.
emailClient
=
system
.
getObject
(
"util.mailClient"
);
this
.
personTaxDao
=
system
.
getObject
(
"db.individualincometaxDao"
);
this
.
ossClient
=
system
.
getObject
(
"util.ossClient"
);
}
//写文件并上传到阿里云,返回上传的路径
async
writexls
(
wb
,
sharecode
){
var
that
=
this
;
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
var
fname
=
"zc_"
+
u
+
".xlsx"
;
var
filepath
=
"/tmp/"
+
fname
;
var
promise
=
new
Promise
((
resv
,
rej
)
=>
{
wb
.
xlsx
.
writeFile
(
filepath
).
then
(
async
function
(
d
)
{
var
rtn
=
await
that
.
ossClient
.
upfile
(
fname
,
filepath
);
fs
.
unlink
(
filepath
,
function
(
err
){});
return
resv
(
rtn
);
}).
catch
(
function
(
e
){
return
rej
(
e
);
});
});
return
promise
;
}
//读取模板文件
async
readxls
(){
var
promise
=
new
Promise
((
resv
,
rej
)
=>
{
var
workbook
=
new
excel
.
Workbook
();
workbook
.
properties
.
date1904
=
true
;
var
bpth
=
path
.
normalize
(
path
.
join
(
__dirname
,
'../'
));
workbook
.
xlsx
.
readFile
(
bpth
+
"/tmpl/tmpl.xlsx"
)
.
then
(
function
()
{
return
resv
(
workbook
);
}).
catch
(
function
(
e
){
return
rej
(
e
);
});
});
return
promise
;
}
async
buildworkbook
(
taxCalcList
){
var
workbook
=
await
this
.
readxls
();
var
sheet
=
workbook
.
getWorksheet
(
1
);
sheet
.
columns
=
[
{
header
:
'年度'
,
key
:
'statisticalYear'
,
width
:
10
},
{
header
:
'月份'
,
key
:
'statisticalMonth'
,
width
:
10
},
{
header
:
'员工姓名'
,
key
:
'employeeName'
,
width
:
10
},
{
header
:
'本月税前薪资'
,
key
:
'preTaxSalary'
,
width
:
18
},
{
header
:
'累计税前薪资'
,
key
:
'accupreTaxSalary'
,
width
:
18
},
// { header: '五险一金比例', key: 'insuranceAndFund', width: 18, outlineLevel: 1 },
{
header
:
'本月五险一金'
,
key
:
'insuranceAndFund'
,
width
:
18
,
outlineLevel
:
1
},
{
header
:
'累计五险一金'
,
key
:
'accuinsuranceAndFund'
,
width
:
18
,
outlineLevel
:
1
},
{
header
:
'子女教育'
,
key
:
'childrenEducation'
,
width
:
10
},
{
header
:
'继续教育'
,
key
:
'continuingEducation'
,
width
:
10
},
{
header
:
'房贷利息'
,
key
:
'interestExpense'
,
width
:
10
},
{
header
:
'住房租金'
,
key
:
'housingRent'
,
width
:
10
},
{
header
:
'赡养老人'
,
key
:
'supportElderly'
,
width
:
10
},
{
header
:
'大病医疗'
,
key
:
'illnessMedicalTreatment'
,
width
:
10
},
{
header
:
'专项扣除合计'
,
key
:
'specialDeduction'
,
width
:
10
},
{
header
:
'累计已扣专项'
,
key
:
'accuSpecialDeduction'
,
width
:
18
,
outlineLevel
:
1
},
{
header
:
'累计已纳个税'
,
key
:
'accuPersonalIncomeTax'
,
width
:
18
},
{
header
:
'累计免征额'
,
key
:
'accuExemptionAmount'
,
width
:
10
},
{
header
:
'适用税率'
,
key
:
'taxRate'
,
width
:
10
},
{
header
:
'速算扣除'
,
key
:
'deductionNumber'
,
width
:
10
},
{
header
:
'本月应纳个税'
,
key
:
'personalIncomeTax'
,
width
:
18
},
{
header
:
'本月税后薪资'
,
key
:
'postTaxSalary'
,
width
:
18
,
outlineLevel
:
1
}
// (累计税前薪资-累计五险一金-累计免征额-累计已扣专项)*税率-速算扣除-累计已纳个税=本月应纳个税
];
taxCalcList
.
forEach
(
r
=>
{
sheet
.
addRow
(
r
);
});
return
workbook
;
}
async
makerpt
(
qobj
){
var
self
=
this
;
return
this
.
db
.
transaction
(
async
t
=>
{
const
sharecode
=
qobj
.
sharecode
;
const
email
=
qobj
.
email
;
//按照sharecode获取单位某次个税计算
var
taxCalcList
=
await
this
.
personTaxDao
.
model
.
findAll
({
where
:{
shareOnlyCode
:
sharecode
},
transaction
:
t
});
var
sheetNameSufix
=
"个税汇总表"
;
if
(
taxCalcList
&&
taxCalcList
.
length
>
0
){
var
year
=
taxCalcList
[
0
].
statisticalYear
;
var
month
=
taxCalcList
[
0
].
statisticalMonth
;
sheetNameSufix
=
year
+
month
+
sheetNameSufix
;
}
var
wb
=
await
this
.
buildworkbook
(
taxCalcList
);
//生成excel
var
result
=
await
this
.
writexls
(
wb
,
sharecode
);
//异步不等待发送邮件给
var
html
=
'<a href="'
+
result
.
url
+
'">'
+
sheetNameSufix
+
'</a>'
self
.
emailClient
.
sendMsg
(
email
,
sheetNameSufix
,
null
,
html
,
null
,
null
,[]);
//发送手机短信
//写到按咋回哦sharecode,修改下载的url
return
result
.
url
;
});
}
async
create
(
qobj
){
var
self
=
this
;
return
this
.
db
.
transaction
(
async
t
=>
{
var
task
=
await
this
.
dao
.
create
(
qobj
,
t
);
//发布任务事件
var
action
=
"new"
;
var
taskClassName
=
task
.
taskClassName
;
var
exp
=
task
.
taskexp
;
var
msg
=
action
+
"_"
+
taskClassName
+
"_"
+
exp
;
await
self
.
taskManager
.
newTask
(
msg
);
await
self
.
taskManager
.
publish
(
"task"
,
"newtask"
);
return
task
;
});
}
async
restartTasks2
(
qobj
){
return
this
.
restartTasks
(
qobj
);
}
async
restartTasks
(
qobj
){
var
self
=
this
;
var
rtn
=
{};
var
tasks
=
await
this
.
dao
.
model
.
findAll
({
raw
:
true
});
//清空任务列表
await
this
.
taskManager
.
clearlist
();
for
(
var
i
=
0
;
i
<
tasks
.
length
;
i
++
){
var
tmpTask2
=
tasks
[
i
];
try
{
(
async
(
tmpTask
,
that
)
=>
{
var
action
=
"new"
;
var
taskClassName
=
tmpTask
.
taskClassName
;
var
exp
=
tmpTask
.
taskexp
;
var
msg
=
action
+
"_"
+
taskClassName
+
"_"
+
exp
;
// await that.taskManager.newTask(msg);
// await that.taskManager.publish("task","newtask");
await
that
.
taskManager
.
addTask
(
taskClassName
,
exp
);
})(
tmpTask2
,
self
);
}
catch
(
e
)
{
rtn
=
null
;
}
}
return
rtn
;
}
async
delete
(
qobj
){
var
self
=
this
;
return
this
.
db
.
transaction
(
async
t
=>
{
var
task
=
await
this
.
dao
.
model
.
findOne
({
where
:
qobj
});
await
this
.
dao
.
delete
(
task
,
qobj
,
t
);
//发布任务事件
var
action
=
"delete"
;
var
taskName
=
task
.
taskClassName
;
var
exp
=
task
.
taskexp
;
var
msg
=
action
+
"_"
+
taskName
;
//发布任务,消息是action_taskClassName
await
this
.
taskManager
.
publish
(
"task"
,
msg
,
null
);
return
task
;
});
}
}
module
.
exports
=
TaskService
;
xggsve-chance/app/base/service/impl/deliver/deliverSve.js
deleted
100644 → 0
View file @
78c9c994
This diff is collapsed.
Click to expand it.
xggsve-chance/app/base/service/impl/trade/storderSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
class
StOrderService
extends
ServiceBase
{
constructor
()
{
super
(
"trade"
,
ServiceBase
.
getDaoName
(
StOrderService
));
this
.
storderitemDao
=
system
.
getObject
(
"db.trade.storderitemDao"
);
this
.
dictionary
=
system
.
getObject
(
"util.dictionary"
);
}
async
test
(
params
)
{
return
system
.
getResultSuccess
(
"test"
);
}
// 打款列表页
async
pageByCondition
(
params
)
{
let
page
=
{
count
:
0
,
rows
:
[]
}
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
params
.
startRow
=
(
params
.
currentPage
-
1
)
*
params
.
pageSize
;
page
.
count
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
page
.
count
==
0
)
{
return
system
.
getResultSuccess
(
page
);
}
page
.
rows
=
await
this
.
dao
.
listByCondition
(
params
);
if
(
page
.
rows
)
{
for
(
var
row
of
page
.
rows
)
{
this
.
handleDate
(
row
,
[
"created_at"
],
null
);
if
(
row
.
acc_type
==
"00"
){
row
.
acc_type_name
=
"银行"
;
}
else
if
(
row
.
acc_type
==
"01"
){
row
.
acc_type_name
=
"支付宝"
;
}
else
if
(
row
.
acc_type
=
"02"
){
row
.
acc_type_name
=
"微信"
}
else
{
row
.
acc_type_name
=
"其他"
;
}
}
this
.
dictionary
.
setRowsName
(
"ORDER"
,
page
.
rows
,
[
"order_type"
,
"acc_type"
,
"trade_mode"
,
"trade_status"
,
"check_status"
]);
}
return
system
.
getResultSuccess
(
page
);
}
async
info
(
params
)
{
let
order
=
await
this
.
dao
.
getById
(
params
.
id
);
if
(
!
order
)
{
return
system
.
getResult
(
null
,
"批次不存在"
);
}
this
.
handleDate
(
order
,
[
"created_at"
],
null
);
this
.
dictionary
.
setRowName
(
"ORDER"
,
order
,
[
"order_type"
,
"acc_type"
,
"trade_mode"
,
"trade_status"
,
"check_status"
]);
return
system
.
getResultSuccess
(
order
);
}
// 保存打款信息
async
saveOrder
(
order
)
{
if
(
!
order
)
{
return
system
.
getResult
(
null
,
"批次不存在"
);
}
let
itemList
=
order
.
itemList
||
[];
if
(
itemList
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"批次明细不存在"
);
}
let
self
=
this
;
order
=
await
this
.
db
.
transaction
(
async
t
=>
{
order
=
await
self
.
dao
.
create
(
order
,
t
);
for
(
let
item
of
itemList
)
{
item
.
autoIncrement
=
true
;
item
.
order_id
=
order
.
id
;
item
.
order_type
=
order
.
order_type
;
item
.
saas_merchant_id
=
order
.
saas_merchant_id
;
item
.
out_trade_no
=
order
.
out_trade_no
;
item
.
saas_id
=
order
.
saas_id
;
}
await
self
.
storderitemDao
.
bulkCreate
(
itemList
,
t
);
await
self
.
storderitemDao
.
genTradeNo
(
order
.
id
,
t
);
return
order
;
});
return
system
.
getResultSuccess
(
order
);
}
async
pay
(
params
)
{
let
type
=
this
.
trim
(
params
.
type
);
let
rs
;
if
(
type
===
"offline"
)
{
rs
=
await
this
.
offlinePay
(
params
);
}
else
{
return
system
.
getResult
(
null
,
"暂不支持在线付款"
);
}
return
rs
;
}
async
offlinePay
(
params
)
{
let
id
=
this
.
trim
(
params
.
id
);
let
order
=
await
this
.
dao
.
findById
(
id
);
if
(
!
order
)
{
return
system
.
getResult
(
null
,
"批次不存在"
);
}
if
(
order
.
pay_voucher
)
{
// 防止重复更新
return
system
.
getResultSuccess
();
}
if
(
!
params
.
pay_voucher
)
{
return
system
.
getResult
(
null
,
"请上传凭证"
);
}
order
.
pay_voucher
=
this
.
trim
(
params
.
pay_voucher
);
let
pay_bank_account
=
this
.
trim
(
params
.
pay_bank_account
);
if
(
pay_bank_account
)
{
order
.
pay_bank_account
=
pay_bank_account
;
}
let
pay_bank_name
=
this
.
trim
(
params
.
pay_bank_name
);
if
(
pay_bank_name
)
{
order
.
pay_bank_name
=
pay_bank_name
;
}
let
pay_bank_no
=
this
.
trim
(
params
.
pay_bank_no
);
if
(
pay_bank_no
)
{
order
.
pay_bank_no
=
pay_bank_no
;
}
// 一审
order
.
check_status
=
"01"
;
await
order
.
save
();
return
system
.
getResultSuccess
();
}
// 一审
async
audit1
(
params
)
{
let
_params
=
{
id
:
this
.
trim
(
params
.
id
),
pre
:
"01"
,
status
:
Number
(
params
.
status
||
0
)
==
1
?
"03"
:
"02"
,
remark
:
params
.
remark
,
auditType
:
1
}
return
await
this
.
doAudit
(
_params
,
async
(
order
)
=>
{
if
(
_params
.
status
!=
"02"
)
{
return
;
}
order
.
trade_status
=
"02"
;
await
order
.
save
();
// 更新order_item状态
let
rs
=
await
this
.
storderitemDao
.
updateTradeByOrderId
(
order
.
id
,
order
.
trade_status
);
console
.
log
(
rs
);
});
}
// 二审
async
audit2
(
params
)
{
let
_params
=
{
id
:
this
.
trim
(
params
.
id
),
pre
:
"03"
,
status
:
Number
(
params
.
status
||
0
)
==
1
?
"05"
:
"04"
,
remark
:
params
.
remark
,
auditType
:
2
}
let
rs
=
await
this
.
doAudit
(
_params
,
async
(
order
)
=>
{
if
(
_params
.
status
==
"05"
)
{
order
.
trade_status
=
"00"
;
}
else
if
(
_params
.
status
==
"04"
)
{
order
.
trade_status
=
"02"
;
}
await
order
.
save
();
// 更新order_item状态
let
rs
=
await
this
.
storderitemDao
.
updateTradeByOrderId
(
order
.
id
,
order
.
trade_status
);
console
.
log
(
rs
);
});
return
rs
;
}
async
doAudit
(
params
,
cb
)
{
let
id
=
this
.
trim
(
params
.
id
);
let
pre
=
this
.
trim
(
params
.
pre
);
let
status
=
params
.
status
;
let
remark
=
this
.
trim
(
params
.
remark
);
let
auditType
=
params
.
auditType
;
let
auditName
=
auditType
===
1
?
"一审"
:
"二审"
;
remark
=
this
.
trim
(
remark
);
if
(
!
remark
)
{
return
system
.
getResult
(
null
,
`请填写
${
auditName
}
备注`
);
}
let
order
=
await
this
.
dao
.
findById
(
id
);
this
.
dictionary
.
setRowName
(
"ORDER"
,
order
,
[
"check_status"
]);
if
(
!
order
)
{
return
system
.
getResult
(
null
,
"批次不存在"
);
}
if
(
order
.
check_status
!==
pre
)
{
return
system
.
getResult
(
null
,
`
${
auditName
}
失败,当前状态为[
${
order
.
check_status_name
}
]`
);
}
order
[
`check
${
auditType
}
_remark`
]
=
remark
;
order
.
check_status
=
status
;
await
order
.
save
();
if
(
cb
)
{
cb
(
order
);
}
return
system
.
getResultSuccess
(
order
);
}
// 打款
async
trade
(
params
)
{
// 打款模式 01系统打款 02手工打款
let
trade_mode
=
this
.
trim
(
params
.
trade_mode
);
if
(
!
trade_mode
||
[
"01"
,
"02"
].
indexOf
(
trade_mode
)
==
-
1
)
{
return
system
.
getResult
(
null
,
"打款模式错误"
);
}
if
(
trade_mode
==
"01"
)
{
return
system
.
getResult
(
null
,
"系统打款正在开发中,暂时只支持手工打款"
);
}
let
order
=
await
this
.
dao
.
findById
(
params
.
id
);
if
(
!
order
)
{
return
system
.
getResult
(
null
,
"批次不存在"
);
}
if
(
order
.
check_status
!=
"05"
)
{
return
system
.
getResult
(
null
,
"批次未审核通过,请等待审核操作"
);
}
if
(
order
.
trade_mode
!=
"00"
)
{
return
system
.
getResult
(
null
,
"批次已经操作过打款,不要重复操作"
);
}
order
.
trade_mode
=
trade_mode
;
order
.
trade_status
=
"01"
;
await
order
.
save
();
return
system
.
getResultSuccess
(
order
);
}
}
module
.
exports
=
StOrderService
;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
xggsve-chance/app/base/service/impl/trade/storderitemSve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
class
StOrderItemService
extends
ServiceBase
{
constructor
()
{
super
(
"trade"
,
ServiceBase
.
getDaoName
(
StOrderItemService
));
this
.
storderDao
=
system
.
getObject
(
"db.trade.storderDao"
);
this
.
dictionary
=
system
.
getObject
(
"util.dictionary"
);
}
async
pageByCondition
(
params
)
{
let
page
=
{
count
:
0
,
rows
:
[]
};
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
params
.
startRow
=
(
params
.
currentPage
-
1
)
*
params
.
pageSize
;
page
.
count
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
page
.
count
==
0
)
{
return
system
.
getResultSuccess
(
page
);
}
page
.
rows
=
await
this
.
dao
.
listByCondition
(
params
);
if
(
page
.
rows
)
{
for
(
var
row
of
page
.
rows
)
{
this
.
handleDate
(
row
,
[
"created_at"
],
null
);
}
this
.
dictionary
.
setRowsName
(
"ORDER_ITEM"
,
page
.
rows
,
[
"trade_status"
]);
}
return
system
.
getResultSuccess
(
page
);
}
async
tradeOfflineCB
(
params
)
{
let
item_ids
=
params
.
item_ids
||
[];
if
(
item_ids
.
length
==
0
)
{
return
system
.
getResultSuccess
();
}
let
trade_time
=
params
.
trade_time
;
if
(
!
trade_time
)
{
return
system
.
getResult
(
null
,
"请填写交易时间"
);
}
let
order
=
await
this
.
storderDao
.
findById
(
params
.
order_id
);
if
(
order
.
check_status
!=
"05"
)
{
return
system
.
getResult
(
null
,
"批次未审核"
);
}
if
(
order
.
trade_mode
==
"00"
)
{
return
system
.
getResult
(
null
,
"批次未触发打款"
);
}
let
itemParams
=
{
ids
:
item_ids
,
trade_status
:
params
.
trade_status
,
trade_desc
:
params
.
trade_desc
,
trade_time
:
params
.
trade_time
};
let
countParams
=
{
order_id
:
order
.
id
,
trade_status
:
"00"
};
let
orderParams
=
{
id
:
order
.
id
};
let
self
=
this
;
await
this
.
db
.
transaction
(
async
t
=>
{
await
self
.
dao
.
updateTrade
(
itemParams
,
t
);
let
count
=
await
self
.
dao
.
countItems
(
countParams
,
t
);
if
(
count
==
order
.
item_count
)
{}
orderParams
.
trade_status
=
count
==
order
.
item_count
?
"00"
:
"03"
;
await
self
.
storderDao
.
update
(
orderParams
,
t
);
return
order
;
});
return
system
.
getResultSuccess
();
}
async
tradeOnlineCB
(
params
)
{}
async
updateInvoice
(
params
)
{
let
rs
=
await
this
.
dao
.
updateInvoice
(
params
);
return
system
.
getResult
(
rs
);
}
async
cancelInvoice
(
params
)
{
let
rs
=
await
this
.
dao
.
cancelInvoice
(
params
);
return
system
.
getResult
(
rs
);
}
async
byIds
(
params
)
{
let
list
=
await
this
.
dao
.
byIds
(
params
);
return
system
.
getResultSuccess
(
list
);
}
async
bySaasInvoiceId
(
params
)
{
let
rs
=
await
this
.
dao
.
bySaasInvoiceId
(
params
);
return
system
.
getResultSuccess
(
rs
);
}
/**
* 根据 invoice_id 和 order_type 查询交易流水
* @param {*} params
*/
async
invoiceTrade
(
params
){
if
(
!
params
.
id
){
return
system
.
getResult
(
null
,
`参数错误 ID不能为空`
);
}
if
(
!
params
.
order_type
){
return
system
.
getResult
(
null
,
`订单类型不能为空`
);
}
try
{
let
tparam
=
{
order_type
:
this
.
trim
(
params
.
order_type
)};
if
(
params
.
data_ids
&&
params
.
data_ids
.
length
>
0
)
{
tparam
.
data_ids
=
params
.
data_ids
;
}
else
if
(
params
.
id
)
{
tparam
.
saas_invoice_id
=
params
.
id
;
}
else
{
return
system
.
getResult
([]);
}
let
res
=
await
this
.
dao
.
invoiceTrade
(
tparam
)
||
[];
for
(
let
item
of
res
){
this
.
handleDate
(
item
,
[
'updated_at'
,
'created_at'
],
'YYYY-MM-DD HH:mm:ss'
);
}
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
/**
* 根据统一社会信用代码获取所有的订单流水
* @param params
* @returns {Promise<void>}
*/
async
tradeItemBycreditCode
(
params
){
if
(
!
(
params
.
credit_code_array
instanceof
Array
)
&&
params
.
credit_code_array
.
length
<
0
){
return
system
.
getResult
(
null
,
`参数格式错误`
);
}
try
{
let
page
=
{
count
:
0
,
rows
:
[]
};
params
.
currentPage
=
Number
(
params
.
currentPage
||
1
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
params
.
startRow
=
(
params
.
currentPage
-
1
)
*
params
.
pageSize
;
page
.
count
=
await
this
.
dao
.
countByCondition
(
params
);
if
(
page
.
count
==
0
)
{
return
system
.
getResultSuccess
(
page
);
}
page
.
rows
=
await
this
.
dao
.
invoiceTrade
(
params
);
if
(
page
.
rows
){
for
(
let
item
of
page
.
rows
)
{
this
.
handleDate
(
item
,
[
"created_at"
,
"trade_time"
],
null
);
item
.
amt
=
system
.
f2y
(
item
.
amt
);
item
.
actual_amt
=
system
.
f2y
(
item
.
actual_amt
);
item
.
deduct_amt
=
system
.
f2y
(
item
.
deduct_amt
);
item
.
service_tax
=
system
.
f2y
(
item
.
service_tax
);
if
(
item
.
order_type
==
"10"
){
//00未设置 10平台交易 20商户交易
item
.
order_type_name
=
"平台交易"
;
}
else
if
(
item
.
order_type
==
"20"
){
item
.
order_type_name
=
"商户交易"
;
}
else
{
item
.
order_type_name
=
"未设置"
;
}
if
(
item
.
trade_status
==
"00"
){
//交易状态 00 成功 01 待处理 02 失败
item
.
trade_status_name
=
"成功"
;
}
else
if
(
item
.
trade_status
==
"01"
){
item
.
trade_status_name
=
"待处理"
;
}
else
if
(
item
.
trade_status
==
"02"
){
item
.
trade_status_name
=
"失败"
;
}
else
{
item
.
trade_status_name
=
""
;
}
}
}
return
system
.
getResult
(
page
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
/***
* fn:根据ID取消发票关联
* @param params
* @returns {Promise<void>}
*/
async
cancelInvoiceByDataIds
(
params
){
if
(
!
params
.
data_ids
||
params
.
data_ids
.
length
==
0
)
{
return
system
.
getResult
(
null
,
`参数错误 DATA_IDS 不能为空`
);
}
try
{
let
res
=
await
this
.
dao
.
cancelInvoiceByDataIds
(
params
);
return
res
;
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
`系统错误`
);
}
}
}
module
.
exports
=
StOrderItemService
;
\ No newline at end of file
xggsve-chance/app/base/service/impl/trade/stpaySve.js
deleted
100644 → 0
View file @
78c9c994
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
class
StPayService
extends
ServiceBase
{
constructor
()
{
super
(
"trade"
,
ServiceBase
.
getDaoName
(
StPayService
));
this
.
PAY_TYUPE
=
[
"1"
,
'2'
];
//支付类型 1线下支付 2...
this
.
PAY_STATUS
=
[
"10"
,
"20"
];
//支付状态 10待支付 20已支付
}
/**
* 创建交易流水
* @param params
* @returns {Promise<void>}
*/
async
saveStPay
(
params
)
{
if
(
!
params
.
busi_name
)
{
return
system
.
getResult
(
`业务名称不能为空`
);
}
if
(
!
params
.
busi_id
)
{
return
system
.
getResult
(
`业务ID不能为空`
);
}
if
(
!
this
.
PAY_TYUPE
.
includes
(
params
.
pay_type
))
{
return
system
.
getResult
(
"支付类型错误"
)
}
if
(
!
this
.
PAY_STATUS
.
includes
(
params
.
pay_status
))
{
return
system
.
getResult
(
"支付状态错误"
)
}
let
stpay
=
{
busi_id
:
this
.
trim
(
params
.
busi_id
),
busi_name
:
this
.
trim
(
params
.
busi_name
),
saas_id
:
this
.
trim
(
params
.
saas_id
),
saas_merchant_id
:
this
.
trim
(
params
.
saas_merchant_id
),
pay_type
:
this
.
trim
(
params
.
pay_type
),
amount
:
this
.
trim
(
params
.
amount
),
pay_status
:
this
.
trim
(
params
.
pay_status
),
pay_voucher_img
:
this
.
trim
(
params
.
pay_voucher_img
),
trade_no
:
this
.
trim
(
params
.
trade_no
),
account_info
:
this
.
trim
(
params
.
account_info
),
};
try
{
let
res
=
await
this
.
dao
.
create
(
stpay
);
return
system
.
getResult
(
res
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
`系统错误`
)
}
}
/**
* 更新支付记录
* @param pay_status
* @param pay_voucher_img
* @param trade_no
* @returns {Promise<void>}
*/
async
updateStatus
(
params
)
{
let
_bean
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
this
.
trim
(
params
.
id
),
}
});
if
(
!
_bean
)
{
return
system
.
getResult
(
null
,
`业务
${
_bean
.
id
}
不存在`
);
}
if
(
params
.
pay_status
){
if
(
!
this
.
PAY_STATUS
.
includes
(
params
.
pay_status
))
{
return
system
.
getResult
(
"支付状态错误"
)
}
_bean
.
pay_status
=
this
.
trim
(
params
.
pay_status
);
}
if
(
params
.
pay_voucher_img
){
_bean
.
pay_voucher_img
=
this
.
trim
(
params
.
pay_voucher_img
);
}
if
(
params
.
trade_no
){
_bean
.
trade_no
=
this
.
trim
(
params
.
trade_no
);
}
try
{
let
res
=
await
_bean
.
save
();
return
system
.
getResult
(
res
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
`系统错误`
)
}
}
/**
* 获取业务支付记录
* @param busi_name
* @param busiIds
* @returns {Promise<void>}
*/
async
mapByBusiIds
(
params
)
{
if
(
!
params
.
busi_name
)
{
return
system
.
getResult
(
`业务名称不能为空`
);
}
try
{
let
list
=
await
this
.
dao
.
model
.
findAll
({
where
:
{
busi_name
:
this
.
trim
(
params
.
busi_name
),
busi_id
:
{
[
this
.
db
.
Op
.
in
]:
params
.
busiIds
,
}
}
});
let
map
=
{};
for
(
let
element
of
list
)
{
if
(
element
.
pay_type
==
"1"
){
element
.
pay_type_name
=
"线下支付"
;
}
else
{
element
.
pay_type_name
=
"其他支付"
;
}
if
(
element
.
pay_status
==
"10"
){
element
.
pay_status_name
=
"待支付 "
;
}
else
if
(
element
.
pay_status
==
"20"
){
element
.
pay_status_name
=
"20已支付"
;
}
else
{
element
.
pay_status_name
=
""
;
}
let
temp
=
map
[
element
.
busi_id
]
||
[];
temp
.
push
(
element
);
map
[
element
.
busi_id
]
=
temp
;
}
return
system
.
getResult
(
map
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
`系统错误`
);
}
}
}
module
.
exports
=
StPayService
;
\ No newline at end of file
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