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
70ea71d3
Commit
70ea71d3
authored
Jan 09, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dd
parent
e3f2aae3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
253 additions
and
8 deletions
+253
-8
xggsve-order/app/base/api/impl/op/action.js
+4
-3
xggsve-order/app/base/db/impl/order/oorderstatusDao.js
+9
-0
xggsve-order/app/base/db/models/order/oorderstatus.js
+37
-0
xggsve-order/app/base/service/impl/order/oorderSve.js
+5
-5
xggsve-order/app/base/service/impl/order/oorderdeliverSve.js
+50
-0
xggsve-order/app/base/service/impl/order/oorderstatusSve.js
+148
-0
No files found.
xggsve-order/app/base/api/impl/op/action.js
View file @
70ea71d3
...
...
@@ -17,7 +17,7 @@ class ActionAPI extends APIBase {
this
.
oorderSve
=
system
.
getObject
(
"service.order.oorderSve"
);
this
.
oorderdeliverSve
=
system
.
getObject
(
"service.order.oorderdeliverSve"
);
this
.
oorderstatusSve
=
system
.
getObject
(
"service.order.oorderstatusSve"
);
this
.
oprocessSve
=
system
.
getObject
(
"service.product.oprocessSve"
);
}
/**
...
...
@@ -51,8 +51,9 @@ class ActionAPI extends APIBase {
case
"orders"
:
//订单管理(平台)
opResult
=
await
this
.
oorderSve
.
orders
(
action_body
);
break
;
case
"assignSalesman"
:
//分配业务员
opResult
=
await
this
.
oorderSve
.
assignSalesman
(
action_body
);
case
"assignSalesman"
:
//分配业务员(平台)
opResult
=
await
this
.
oorderstatusSve
.
handleStatus
(
action_body
);
break
;
case
"assignDeliver"
:
//分配交付商
opResult
=
await
this
.
oorderSve
.
assignDeliver
(
action_body
);
...
...
xggsve-order/app/base/db/impl/order/oorderstatusDao.js
0 → 100644
View file @
70ea71d3
const
system
=
require
(
"../../../system"
);
const
Dao
=
require
(
"../../dao.base"
);
class
OorderstatusDao
extends
Dao
{
constructor
()
{
super
(
Dao
.
getModelName
(
OorderstatusDao
));
}
}
module
.
exports
=
OorderstatusDao
;
\ No newline at end of file
xggsve-order/app/base/db/models/order/oorderstatus.js
0 → 100644
View file @
70ea71d3
'use strict'
/**
* 订单表
*/
module
.
exports
=
function
(
db
,
DataTypes
)
{
return
db
.
define
(
'oorderstatus'
,
{
merchant_id
:
{
type
:
DataTypes
.
STRING
,
field
:
'merchant_id'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'商户id, 为了兼容司机宝'
},
// order_id: {type: DataTypes.STRING, field: 'order_id', allowNull: true, comment:'订单ID' },
busi_type
:
{
type
:
DataTypes
.
STRING
,
field
:
'busi_type'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'业务类型 1个体户 2...暂不知道'
},
busi_id
:
{
type
:
DataTypes
.
STRING
,
field
:
'busi_id'
,
allowNull
:
false
,
defaultValue
:
''
,
comment
:
'业务id'
},
product_id
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'product_id'
,
allowNull
:
true
,
defaultValue
:
0
,
comment
:
'产品id'
},
price
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'price'
,
allowNull
:
true
,
defaultValue
:
0
,
comment
:
'订单价格'
},
status
:
{
type
:
DataTypes
.
INTEGER
,
field
:
'status'
,
allowNull
:
true
,
defaultValue
:
'0'
,
comment
:
'订单状态 业务进度'
},
assign_time
:
{
type
:
DataTypes
.
DATE
,
field
:
'assign_time'
,
allowNull
:
true
,
defaultValue
:
null
,
comment
:
'分配时间'
},
assign_user_id
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'assign_user_id'
,
allowNull
:
true
,
defaultValue
:
'0'
,
comment
:
'分配人id'
},
deliver_id
:
{
type
:
DataTypes
.
STRING
,
field
:
'deliver_id'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'交付商id common微服务下'
},
desc
:
{
type
:
DataTypes
.
STRING
,
field
:
'desc'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'订单信息'
},
bd_id
:
{
type
:
DataTypes
.
STRING
,
field
:
'bd_id'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'业务员id'
},
bd_path
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'bd_path'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'业务员权限路径'
},
service_items
:
{
type
:
DataTypes
.
STRING
,
field
:
'service_items'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'服务项json'
},
service_remark
:
{
type
:
DataTypes
.
STRING
,
field
:
'service_remark'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'服务信息备注'
},
source_id
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'source_id'
,
allowNull
:
true
,
defaultValue
:
0
,
comment
:
'来源id'
},
source_no
:
{
type
:
DataTypes
.
STRING
,
field
:
'source_no'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'来源订单号'
},
contact_mobile
:
{
type
:
DataTypes
.
STRING
,
field
:
'contact_mobile'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'联系电话'
},
created_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'created_at'
,
allowNull
:
false
,
defaultValue
:
DataTypes
.
NOW
},
updated_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'updated_at'
,
allowNull
:
false
,
defaultValue
:
DataTypes
.
NOW
},
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
tableName
:
'o_order'
,
});
}
xggsve-order/app/base/service/impl/order/oorderSve.js
View file @
70ea71d3
...
...
@@ -189,6 +189,9 @@ class OorderService extends ServiceBase {
if
(
params
.
deliver_id
)
{
where
.
deliver_id
=
this
.
trim
(
params
.
deliver_id
);
}
if
(
params
.
bd_path
)
{
where
.
bd_path
=
this
.
trim
(
params
.
bd_path
);
}
var
currentPage
=
Number
(
params
.
currentPage
||
1
);
var
pageSize
=
Number
(
params
.
pageSize
||
10
);
...
...
@@ -354,6 +357,8 @@ class OorderService extends ServiceBase {
if
(
params
.
status
!=
nextStatus
.
next_status
)
{
return
system
.
getResult
(
null
,
`订单状态错误,下一订单状态应该是
${
nextStatus
.
next_name
}
`
);
}
params
.
_order
=
_order
;
return
await
this
[
'assignDeliver'
](
params
);
}
...
...
@@ -379,11 +384,6 @@ class OorderService extends ServiceBase {
}
try
{
let
_order
=
await
this
.
findById
(
params
.
id
);
if
(
!
_order
)
{
return
system
.
getResult
(
null
,
`订单不存在`
);
}
await
this
.
statusAction
(
params
);
let
self
=
this
;
let
res
=
await
this
.
db
.
transaction
(
async
t
=>
{
//创建orderdeliver记录
...
...
xggsve-order/app/base/service/impl/order/oorderdeliverSve.js
View file @
70ea71d3
...
...
@@ -107,6 +107,56 @@ class OorderdeliverService extends ServiceBase {
console
.
log
(
orderList
);
}
/**
* 分配业务员(交付商)
* @param {*} params
* @id String 订单ID
* @operator_id String 业务员ID
* @status String 下一个状态码
*/
async
assignSalesman
(
params
)
{
if
(
!
params
.
bd_id
)
{
return
system
.
getResult
(
null
,
`参数错误 业务员ID不能为空`
);
}
try
{
//更新订单业务员
let
_order
=
await
this
.
findById
(
params
.
id
);
if
(
!
_order
)
{
return
system
.
getResult
(
null
,
`订单不存在`
);
}
//to do ... 验证下一个状态
await
this
.
statusAction
(
params
);
_order
.
bd_id
=
this
.
trim
(
params
.
bd_id
);
_order
.
status
=
this
.
trim
(
params
.
status
);
_order
.
bd_path
=
this
.
trim
(
params
.
bd_path
);
let
res
=
await
_order
.
save
();
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async
statusAction
(
params
)
{
let
_order
=
await
this
.
oorderDao
.
findById
(
params
.
id
);
if
(
!
_order
)
{
return
system
.
getResult
(
null
,
`订单不存在`
);
}
//todo ... 验证状态
let
_orderStatus
=
await
this
.
getOrderProcessStatus
(
_order
.
id
,
_order
.
status
);
let
nextStatus
=
JSON
.
parse
(
_orderStatus
.
next_status
);
if
(
params
.
status
!=
nextStatus
.
next_status
)
{
return
system
.
getResult
(
null
,
`订单状态错误,下一订单状态应该是
${
nextStatus
.
next_name
}
`
);
}
}
}
...
...
xggsve-order/app/base/service/impl/order/oorderstatusSve.js
0 → 100644
View file @
70ea71d3
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve.base"
)
/**
* 订单产品表
*/
class
OorderstatusService
extends
ServiceBase
{
constructor
()
{
super
(
"order"
,
ServiceBase
.
getDaoName
(
OorderstatusService
));
this
.
oorderinforegDao
=
system
.
getObject
(
"db.order.oorderinforegDao"
);
this
.
oorderdeliverDao
=
system
.
getObject
(
"db.order.oorderdeliverDao"
);
this
.
oorderprocessDao
=
system
.
getObject
(
"db.order.oorderprocessDao"
);
this
.
osourceDao
=
system
.
getObject
(
"db.common.osourceDao"
);
this
.
oproductDao
=
system
.
getObject
(
"db.product.oproductDao"
);
this
.
oprocessDao
=
system
.
getObject
(
"db.product.oprocessDao"
);
this
.
oproductprocessDao
=
system
.
getObject
(
"db.product.oproductprocessDao"
);
}
/**
* 验证订单状态
* @param params
* @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}>}
*/
async
handleStatus
(
params
)
{
try
{
let
_order
=
await
this
.
dao
.
findById
(
params
.
id
);
if
(
!
_order
)
{
return
system
.
getResult
(
null
,
`订单不存在`
);
}
//todo ... 验证状态
let
_orderStatus
=
await
this
.
getOrderProcessStatus
(
_order
.
id
,
_order
.
status
);
let
nextStatus
=
JSON
.
parse
(
_orderStatus
.
next_status
);
var
statuses
=
[];
for
(
var
ns
of
nextStatus
)
{
statuses
.
push
(
ns
.
next_status
);
}
if
(
statuses
.
indexOf
(
params
.
status
)
==
-
1
)
{
return
system
.
getResult
(
null
,
`订单状态错误,下一订单状态应该是
${
nextStatus
.
next_name
}
`
);
}
params
.
_order
=
_order
;
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 获取订单状态对象
* @param order_id
* @param status
* @returns {Promise<*|{}>}
*/
async
getOrderProcessStatus
(
order_id
,
status
)
{
let
map
=
await
this
.
oorderprocessDao
.
mapByOrderIdsAndStatus
([
order_id
],
[
status
]);
return
map
[
order_id
+
"_"
+
status
]
||
{};
}
/**
* 分配业务员
* @param {*} params
* @id String 订单ID
* @bd_id String 业务员ID
* @status String 下一个状态码
* @bd_path String 业务员权限
*/
async
assignSalesman
(
params
)
{
if
(
!
params
.
bd_id
)
{
return
system
.
getResult
(
null
,
`参数错误 业务员ID不能为空`
);
}
try
{
//更新订单业务员
let
_order
=
await
this
.
findById
(
params
.
id
);
if
(
!
_order
)
{
return
system
.
getResult
(
null
,
`订单不存在`
);
}
//to do ... 验证下一个状态
await
this
.
statusAction
(
params
);
_order
.
bd_id
=
this
.
trim
(
params
.
bd_id
);
_order
.
status
=
this
.
trim
(
params
.
status
);
_order
.
bd_path
=
this
.
trim
(
params
.
bd_path
);
let
res
=
await
_order
.
save
();
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
/**
* 分配交付商
* @param {*} params
* @id String 订单ID
* @deliver_id String 交付商ID
* @deliver_name String 交付商名称
* @deliver_deliver String 交付商分成
* @status String 下一个状态码
*/
async
assignDeliver
(
params
)
{
//参数验证
if
(
!
params
.
id
)
{
return
system
.
getResult
(
null
,
`参数错误 订单ID不能为空`
);
}
if
(
!
params
.
deliver_id
)
{
return
system
.
getResult
(
null
,
`参数错误 交付商ID不能为空`
);
}
if
(
!
params
.
hasOwnProperty
(
`deliver_divide`
))
{
return
system
.
getResult
(
null
,
`参数错误 交付商分成不能为空`
);
}
try
{
let
_order
=
params
.
_order
;
let
self
=
this
;
let
res
=
await
this
.
db
.
transaction
(
async
t
=>
{
//创建orderdeliver记录
await
self
.
oorderdeliverDao
.
create
({
order_id
:
self
.
trim
(
params
.
id
),
deliver_id
:
self
.
trim
(
params
.
deliver_id
),
deliver_name
:
self
.
trim
(
params
.
deliver_name
),
deliver_divide
:
self
.
trim
(
params
.
deliver_divide
),
},
t
);
//更新oorder订单记录
await
self
.
dao
.
update
({
deliver_id
:
self
.
trim
(
params
.
deliver_id
),
id
:
self
.
trim
(
params
.
id
),
status
:
self
.
trim
(
params
.
status
)
},
t
);
});
return
system
.
getResult
(
res
);
}
catch
(
error
)
{
console
.
log
(
error
);
return
system
.
getResult
(
null
,
`系统错误 错误信息
${
error
}
`
);
}
}
}
module
.
exports
=
OorderstatusService
;
\ 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