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
dc421c7e
Commit
dc421c7e
authored
Dec 08, 2019
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
d4659c55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
0 deletions
+143
-0
xggsve-order/app/base/service/impl/order/iborderdzSve.js
+143
-0
No files found.
xggsve-order/app/base/service/impl/order/iborderdzSve.js
View file @
dc421c7e
...
...
@@ -6,6 +6,149 @@ const moment = require("moment");
class
IborderdzService
extends
ServiceBase
{
constructor
()
{
super
(
"order"
,
ServiceBase
.
getDaoName
(
IborderdzService
));
this
.
iborderbaseDao
=
system
.
getObject
(
"db.order.iborderbaseDao"
);
this
.
businessmenDao
=
system
.
getObject
(
"db.business.businessmenDao"
);
}
/**
* 创建订单
* @param {*} params
*/
async
createOrder
(
params
,
t
)
{
try
{
if
(
!
params
.
merchantId
)
{
return
system
.
getResult
(
null
,
`参数错误 商户ID不能为空`
);
}
if
(
!
params
.
businessmentId
)
{
return
system
.
getResult
(
null
,
`参数错误 个体户ID不能为空`
);
}
if
(
!
params
.
orderpayId
)
{
return
system
.
getResult
(
null
,
`参数错误 支付ID不能为空`
);
}
if
(
!
Number
(
params
.
price
)
<
0
)
{
return
system
.
getResult
(
null
,
`参数错误 订单金额格式错误`
);
}
this
.
trimObject
(
params
);
let
_ibOrderDk
=
await
this
.
dao
.
create
(
params
,
t
);
return
system
.
getResult
(
_ibOrderDk
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 更新数据
* @param {*} params
* @param {*} t
*/
async
updateOrder
(
params
,
t
)
{
try
{
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 ID 不能为空`
);
}
this
.
trimObject
(
params
);
return
await
this
.
dao
.
update
(
params
,
t
);
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 完善信息
* @param {*} params
* legalName
* legalMobile
* names
* creditCode
* isBank
* businessScope
*/
async
completedOrder
(
params
)
{
try
{
//1 检查个体户是否存在 (根据统一社会信用代码查个体工商户是否存在)
this
.
trimObject
(
params
);
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 ID 不能为空`
);
}
if
(
!
params
.
legalName
)
{
return
system
.
getResult
(
null
,
`参数错误 法人姓名不能为空`
);
}
if
(
!
params
.
legalMobile
)
{
return
system
.
getResult
(
null
,
`参数错误 法人电话不能为空`
);
}
if
(
!
params
.
creditCode
)
{
return
system
.
getResult
(
null
,
`参数错误 法人统一社会信用代码不能为空`
);
}
if
(
!
params
.
names
)
{
return
system
.
getResult
(
null
,
`参数错误 个体户名称不能为空`
);
}
if
(
!
params
.
businessScope
)
{
return
system
.
getResult
(
null
,
`参数错误 经营范围不能为空`
);
}
//2 如果不存在添加保存个体户 完善信息
let
_businessmenRes
=
await
this
.
businessmenDao
.
findBusinessmenByCreditCode
(
this
.
trim
(
params
.
creditCode
));
if
(
_businessmenRes
.
hasOwnProperty
(
"status"
))
{
return
_businessmenRes
;
}
if
(
_businessmenRes
.
id
)
{
//如果用户存在id 直接更新
let
_iborderbase
=
await
this
.
iborderbaseDao
.
findById
(
this
.
trim
(
params
.
id
));
if
(
!
_iborderbase
)
{
return
system
.
getResult
(
null
,
`参数错误 订单不存在`
);
}
let
self
=
this
;
//向参数中添加 是否完善信息标识
params
.
isInfoComplete
=
1
;
await
this
.
db
.
transaction
(
async
t
=>
{
//更新主表
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessmenRes
.
id
),
id
:
self
.
trim
(
params
.
id
),
isInfoComplete
:
1
},
t
);
//更新子表
await
this
.
dao
.
update
(
params
,
t
);
});
}
else
{
let
self
=
this
;
await
this
.
db
.
transaction
(
async
t
=>
{
//如果不存在id 创建后更新
let
_businessment
=
await
this
.
businessmenDao
.
create
(
params
,
t
);
//更新主表
await
self
.
iborderbaseDao
.
update
({
businessmen_id
:
self
.
trim
(
_businessment
.
id
),
id
:
self
.
trim
(
params
.
id
),
isInfoComplete
:
1
},
t
);
//更新子表
await
this
.
dao
.
update
(
params
,
t
);
});
}
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 订单办理
* @param {} params
* businessmenId 个体户ID
* id 订单ID
*/
async
handing
(
params
)
{
try
{
let
id
=
Number
(
params
.
id
);
let
baseOrder
=
this
.
iborderbaseDao
.
findById
(
id
);
let
order
=
this
.
dao
.
findById
(
id
);
baseOrder
.
status
=
"1020"
;
order
.
status
=
"1020"
;
await
baseOrder
.
save
();
await
order
.
save
();
return
system
.
getResultSuccess
();
}
catch
(
error
)
{
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
...
...
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