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
a5e3f9b5
Commit
a5e3f9b5
authored
Jul 01, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
e2fdfef5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
484 deletions
+0
-484
esign-sve-merchant/app/base/api/impl/op/action.js
+0
-33
esign-sve-merchant/app/base/db/impl/account/accountDao.js
+0
-57
esign-sve-merchant/app/base/db/impl/account/accounttradeDao.js
+0
-96
esign-sve-merchant/app/base/db/models/account/account.js
+0
-51
esign-sve-merchant/app/base/db/models/account/accounttrade.js
+0
-53
esign-sve-merchant/app/base/service/impl/account/accountSve.js
+0
-172
esign-sve-merchant/app/base/service/impl/account/accounttradeSve.js
+0
-22
No files found.
esign-sve-merchant/app/base/api/impl/op/action.js
View file @
a5e3f9b5
...
...
@@ -5,7 +5,6 @@ var settings = require("../../../../config/settings");
class
ActionAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
accountSve
=
system
.
getObject
(
"service.account.accountSve"
);
this
.
merchantSve
=
system
.
getObject
(
"service.merchant.merchantSve"
);
this
.
merchanttradeSve
=
system
.
getObject
(
"service.merchant.merchanttradeSve"
);
this
.
merchantaccountSve
=
system
.
getObject
(
"service.merchant.merchantaccountSve"
);
...
...
@@ -37,38 +36,6 @@ class ActionAPI extends APIBase {
async
handleRequest
(
action_process
,
action_type
,
action_body
)
{
var
opResult
=
null
;
switch
(
action_type
)
{
// 测试
case
"test"
:
opResult
=
await
this
.
accountSve
.
test
(
action_body
);
break
;
// 创建账户
case
"accountCreate"
:
opResult
=
await
this
.
accountSve
.
createAccount
(
action_body
);
break
;
// 账户余额查询
case
"accountInfo"
:
opResult
=
await
this
.
accountSve
.
accountInfo
(
action_body
);
break
;
// 账户充值
case
"accountRecharge"
:
opResult
=
await
this
.
accountSve
.
accountRecharge
(
action_body
);
break
;
// 账户充值
case
"accountRefund"
:
opResult
=
await
this
.
accountSve
.
accountRefund
(
action_body
);
break
;
case
"accountTrade"
:
opResult
=
await
this
.
accountSve
.
accountTrade
(
action_body
);
break
;
case
"accountTradePage"
:
opResult
=
await
this
.
accountSve
.
accountTradePage
(
action_body
);
break
;
// 账户交易
case
"test4"
:
opResult
=
await
this
.
accountSve
.
test
(
action_body
);
break
;
//商户管理
// 增加或修改商户
case
"addModifyMerchants"
:
...
...
esign-sve-merchant/app/base/db/impl/account/accountDao.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
AccountDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
AccountDao
));
}
async
incrementBalance
(
id
,
balance
,
t
)
{
let
sql
=
[];
sql
.
push
(
"UPDATE"
);
sql
.
push
(
this
.
model
.
tableName
);
sql
.
push
(
"SET"
);
sql
.
push
(
"balance = balance + :balance"
);
sql
.
push
(
"WHERE id = :id AND balance + :balance >= 0"
);
let
res
=
await
this
.
customUpdate
(
sql
.
join
(
" "
),
{
id
:
id
,
balance
:
balance
},
t
);
console
.
log
(
res
);
if
(
res
.
length
<
2
)
{
return
0
;
}
return
res
[
1
]
||
0
;
}
async
listByIds
(
ids
,
attrs
)
{
if
(
!
ids
||
ids
.
length
==
0
)
{
return
[];
}
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
attrs
||
"*"
);
sql
.
push
(
"FROM"
);
sql
.
push
(
this
.
model
.
tableName
);
sql
.
push
(
"WHERE id IN (:ids)"
);
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
{
ids
:
ids
})
||
[];
}
async
mapByIds
(
ids
,
attrs
)
{
var
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
return
result
;
}
var
list
=
await
this
.
listByIds
(
ids
,
attrs
);
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
}
for
(
var
item
of
list
)
{
result
[
item
.
id
]
=
item
;
}
return
result
;
}
}
module
.
exports
=
AccountDao
;
esign-sve-merchant/app/base/db/impl/account/accounttradeDao.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
AccountTradeDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
AccountTradeDao
));
}
async
listByIds
(
ids
,
attrs
)
{
if
(
!
ids
||
ids
.
length
==
0
)
{
return
[];
}
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
attrs
||
"*"
);
sql
.
push
(
"FROM"
);
sql
.
push
(
this
.
model
.
tableName
);
sql
.
push
(
"WHERE id IN (:ids)"
);
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
{
ids
:
ids
})
||
[];
}
async
mapByIds
(
ids
,
attrs
)
{
var
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
return
result
;
}
var
list
=
await
this
.
findListByIds
(
ids
,
attrs
);
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
}
for
(
var
item
of
list
)
{
result
[
item
.
id
]
=
item
;
}
return
result
;
}
async
countByCondition
(
params
)
{
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
"count(1) as num"
);
sql
.
push
(
"FROM"
);
sql
.
push
(
this
.
model
.
tableName
);
sql
.
push
(
"WHERE deleted_at IS NULL"
);
this
.
setCondition
(
sql
,
params
);
var
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
if
(
!
list
||
list
.
length
==
0
)
{
return
0
;
}
return
list
[
0
].
num
;
}
async
listByCondition
(
params
)
{
params
.
startRow
=
Number
(
params
.
startRow
||
0
);
params
.
pageSize
=
Number
(
params
.
pageSize
||
10
);
var
sql
=
[];
sql
.
push
(
"SELECT"
);
sql
.
push
(
params
.
attrs
||
"*"
);
sql
.
push
(
"FROM"
);
sql
.
push
(
this
.
model
.
tableName
);
sql
.
push
(
"WHERE deleted_at IS NULL"
);
this
.
setCondition
(
sql
,
params
);
sql
.
push
(
"ORDER BY created_at DESC"
);
sql
.
push
(
"LIMIT :startRow, :pageSize"
);
return
await
this
.
customQuery
(
sql
.
join
(
" "
),
params
);
}
setCondition
(
sql
,
params
)
{
if
(
!
params
||
!
sql
)
{
return
;
}
if
(
params
.
account_id
)
{
sql
.
push
(
"AND account_id = :account_id"
);
}
if
(
params
.
trade_no
)
{
sql
.
push
(
"AND trade_no = :trade_no"
);
}
if
(
params
.
trade_type
)
{
sql
.
push
(
"AND trade_type = :trade_type"
);
}
if
(
params
.
tradeTimeBegin
)
{
sql
.
push
(
"AND created_at >= :tradeTimeBegin"
);
}
if
(
params
.
tradeTimeEnd
)
{
sql
.
push
(
"AND created_at <= :tradeTimeEnd"
);
}
}
}
module
.
exports
=
AccountTradeDao
;
esign-sve-merchant/app/base/db/models/account/account.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"account"
,
{
app_id
:
DataTypes
.
STRING
,
// 应用id
app_data_id
:
DataTypes
.
STRING
,
// 应用数据id
balance
:
DataTypes
.
BIGINT
,
// 账户余额
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'be_account'
,
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}]
// }
],
});
}
\ No newline at end of file
esign-sve-merchant/app/base/db/models/account/accounttrade.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
settings
=
require
(
"../../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
appKey
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"accounttrade"
,
{
account_id
:
DataTypes
.
BIGINT
,
// 应用id
trade_type
:
DataTypes
.
INTEGER
,
// 交易类型 1账户交易 2消费交易
trade_no
:
DataTypes
.
STRING
,
// 交易流水号
trade_amt
:
DataTypes
.
BIGINT
,
// 交易金额
trade_desc
:
DataTypes
.
STRING
,
// 交易描述
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'be_account_trade'
,
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}]
// }
],
});
}
\ No newline at end of file
esign-sve-merchant/app/base/service/impl/account/accountSve.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
class
AccountService
extends
ServiceBase
{
constructor
()
{
super
(
"account"
,
ServiceBase
.
getDaoName
(
AccountService
));
this
.
accounttradeDao
=
system
.
getObject
(
"db.account.accounttradeDao"
);
this
.
dictionary
=
system
.
getObject
(
"util.dictionary"
);
}
async
createAccount
(
params
)
{
let
app_id
=
this
.
trim
(
params
.
app_id
);
let
app_data_id
=
this
.
trim
(
params
.
app_data_id
);
let
apps
=
this
.
dictionary
.
getDict
(
"APP"
,
"app_id"
)
||
{};
if
(
!
apps
[
app_id
])
{
return
system
.
getResult
(
null
,
`非法的app_id[
${
app_id
}
]`
);
}
if
(
!
app_data_id
)
{
return
system
.
getResult
(
null
,
`请输入app_data_id[
${
app_data_id
}
]`
);
}
let
account
=
await
this
.
dao
.
findOne
({
app_id
:
app_id
,
app_data_id
:
app_data_id
});
if
(
account
)
{
return
system
.
getResult
(
null
,
`app_id[
${
app_id
}
],app_data_id[
${
app_data_id
}
]账户已创建,请不要重复创建`
);
}
account
=
await
this
.
dao
.
create
({
autoIncrement
:
true
,
app_id
:
app_id
,
app_data_id
:
app_data_id
,
balance
:
0
,
});
return
system
.
getResultSuccess
({
account_id
:
account
.
id
});
}
async
accountInfo
(
params
)
{
let
account
=
await
this
.
dao
.
getById
(
params
.
account_id
);
return
system
.
getResultSuccess
(
account
);
}
async
accountRecharge
(
params
)
{
let
p
=
{
trade_type
:
2
};
p
.
account_id
=
params
.
account_id
;
p
.
trade_amt
=
Number
(
params
.
trade_amt
);
p
.
trade_no
=
this
.
trim
(
params
.
trade_no
);
p
.
trade_desc
=
params
.
trade_desc
||
"充值"
;
try
{
return
await
this
.
trade
(
p
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
"交易错误"
);
}
}
async
accountRefund
(
params
)
{
let
p
=
{
trade_type
:
3
};
p
.
account_id
=
params
.
account_id
;
p
.
trade_amt
=
Number
(
params
.
trade_amt
);
p
.
trade_no
=
this
.
trim
(
params
.
trade_no
);
p
.
trade_desc
=
params
.
trade_desc
||
"退款"
;
try
{
return
await
this
.
trade
(
p
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
"交易错误"
);
}
}
async
accountTrade
(
params
)
{
let
p
=
{
trade_type
:
1
};
p
.
account_id
=
params
.
account_id
;
p
.
trade_amt
=
Number
(
params
.
trade_amt
);
p
.
trade_no
=
this
.
trim
(
params
.
trade_no
);
p
.
trade_desc
=
params
.
trade_desc
||
"消费"
;
try
{
return
await
this
.
trade
(
p
);
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
"交易错误"
);
}
}
async
trade
(
params
)
{
let
accountId
=
params
.
account_id
;
let
trade_no
=
this
.
trim
(
params
.
trade_no
);
let
trade_type
=
params
.
trade_type
;
let
trade_amt
=
Number
(
params
.
trade_amt
||
0
);
if
(
trade_amt
<
0
)
{
return
system
.
getResult
(
null
,
"金额不能为负数"
);
}
let
balance_amt
=
trade_type
==
2
?
trade_amt
:
-
1
*
trade_amt
;
let
trade_desc
=
params
.
trade_desc
;
if
(
!
accountId
)
{
return
system
.
getResult
(
null
,
"account_id不存在"
);
}
if
(
!
trade_no
)
{
return
system
.
getResult
(
null
,
"交易流水号不存在"
);
}
if
(
!
trade_desc
)
{
return
system
.
getResult
(
null
,
"请填写交易描述信息"
);
}
let
_trade
=
await
this
.
accounttradeDao
.
findOne
({
account_id
:
accountId
,
trade_type
:
trade_type
,
trade_no
:
trade_no
,
});
if
(
_trade
)
{
return
system
.
getResult
(
null
,
`账户[
${
accountId
}
]已存在交易流水号[
${
trade_no
}
]`
);
}
let
res
=
await
this
.
db
.
transaction
(
async
t
=>
{
//更新oorder订单记录
let
bres
=
await
this
.
dao
.
incrementBalance
(
accountId
,
balance_amt
,
t
);
console
.
log
(
bres
);
if
(
bres
===
0
)
{
return
system
.
getResult
(
null
,
"余额不足"
);
}
//创建orderdeliver记录
await
this
.
accounttradeDao
.
create
({
account_id
:
accountId
,
trade_type
:
trade_type
,
trade_no
:
trade_no
,
trade_amt
:
trade_amt
,
trade_desc
:
trade_desc
,
},
t
);
return
system
.
getResultSuccess
();
});
return
res
;
}
async
accountTradePage
(
params
)
{
if
(
!
params
.
account_id
)
{
return
{
count
:
0
,
rows
:
[]};
}
return
await
this
.
tradePageByCondition
(
params
);
}
async
tradePageByCondition
(
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
.
accounttradeDao
.
countByCondition
(
params
);
if
(
page
.
count
==
0
)
{
return
system
.
getResultSuccess
(
page
);
}
page
.
rows
=
await
this
.
accounttradeDao
.
listByCondition
(
params
);
this
.
dictionary
.
setRowsName
(
"ACCOUNT_TRADE"
,
page
.
rows
,
[
"trade_type"
]);
this
.
handleRowsDate
(
page
.
rows
,
[
"created_at"
,
"updated_at"
]);
return
system
.
getResultSuccess
(
page
);
}
async
test
(
params
)
{
return
system
.
getResultSuccess
(
"test"
);
}
}
module
.
exports
=
AccountService
;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
esign-sve-merchant/app/base/service/impl/account/accounttradeSve.js
deleted
100644 → 0
View file @
e2fdfef5
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
class
AccountTradeService
extends
ServiceBase
{
constructor
()
{
super
(
"account"
,
ServiceBase
.
getDaoName
(
AccountTradeService
));
this
.
dictionary
=
system
.
getObject
(
"util.dictionary"
);
}
async
test
(
params
)
{
return
system
.
getResultSuccess
(
"test"
);
}
}
module
.
exports
=
AccountTradeService
;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ 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