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
7da23c5a
Commit
7da23c5a
authored
Jan 09, 2020
by
王昆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gsb
parent
8e83344a
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
122 additions
and
37 deletions
+122
-37
xggsve-order/app/base/api/api.base.js
+1
-1
xggsve-order/app/base/api/impl/op/action.js
+14
-0
xggsve-order/app/base/db/dao.base.js
+6
-2
xggsve-order/app/base/db/impl/product/oprocessDao.js
+14
-2
xggsve-order/app/base/db/impl/product/oproductprocessDao.js
+3
-3
xggsve-order/app/base/db/models/order/oorder.js
+1
-2
xggsve-order/app/base/db/models/order/oorderprocess.js
+1
-1
xggsve-order/app/base/db/models/order/osource.js
+1
-1
xggsve-order/app/base/db/models/product/oproduct.js
+1
-1
xggsve-order/app/base/service/impl/order/oorderSve.js
+79
-23
xggsve-order/app/config/localsettings.js
+1
-1
No files found.
xggsve-order/app/base/api/api.base.js
View file @
7da23c5a
...
@@ -70,7 +70,7 @@ class APIBase extends DocBase {
...
@@ -70,7 +70,7 @@ class APIBase extends DocBase {
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
var
requestid
=
this
.
getUUID
();
var
requestid
=
this
.
getUUID
();
try
{
try
{
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
)
||
{}
;
rtn
.
requestid
=
requestid
;
rtn
.
requestid
=
requestid
;
this
.
oplogSve
.
createDb
({
this
.
oplogSve
.
createDb
({
...
...
xggsve-order/app/base/api/impl/op/action.js
View file @
7da23c5a
...
@@ -12,6 +12,9 @@ class ActionAPI extends APIBase {
...
@@ -12,6 +12,9 @@ class ActionAPI extends APIBase {
this
.
businessmenSve
=
system
.
getObject
(
"service.business.businessmenSve"
);
this
.
businessmenSve
=
system
.
getObject
(
"service.business.businessmenSve"
);
this
.
businessmencontractSve
=
system
.
getObject
(
"service.business.businessmencontractSve"
);
this
.
businessmencontractSve
=
system
.
getObject
(
"service.business.businessmencontractSve"
);
this
.
oorderSve
=
system
.
getObject
(
"service.order.oorderSve"
);
}
}
/**
/**
* 接口跳转
* 接口跳转
...
@@ -38,8 +41,19 @@ class ActionAPI extends APIBase {
...
@@ -38,8 +41,19 @@ class ActionAPI extends APIBase {
async
handleRequest
(
action_process
,
action_type
,
action_body
)
{
async
handleRequest
(
action_process
,
action_type
,
action_body
)
{
var
opResult
=
null
;
var
opResult
=
null
;
try
{
}
catch
(
e
)
{
}
switch
(
action_type
)
{
switch
(
action_type
)
{
// 订单
// 订单
case
"addSourceOrder"
:
//创建订单
opResult
=
await
this
.
oorderSve
.
addSourceOrder
(
action_body
);
break
;
// 订单
case
"createOrder"
:
//创建订单
case
"createOrder"
:
//创建订单
opResult
=
await
this
.
iborderbaseSve
.
apiCreateOrder
(
action_body
);
opResult
=
await
this
.
iborderbaseSve
.
apiCreateOrder
(
action_body
);
break
;
break
;
...
...
xggsve-order/app/base/db/dao.base.js
View file @
7da23c5a
...
@@ -35,17 +35,21 @@ class Dao {
...
@@ -35,17 +35,21 @@ class Dao {
}
}
//批量插入
//批量插入
async
bulkCreate
(
objs
)
{
async
bulkCreate
(
objs
,
t
)
{
if
(
!
objs
||
objs
.
length
==
0
)
{
if
(
!
objs
||
objs
.
length
==
0
)
{
return
;
return
;
}
}
for
(
var
obj
of
objs
)
{
for
(
var
obj
of
objs
)
{
if
(
!
obj
.
id
)
{
if
(
!
obj
.
id
&&
!
obj
.
autoIncrement
)
{
obj
.
id
=
await
this
.
redisClient
.
genrateId
(
this
.
modelName
);
obj
.
id
=
await
this
.
redisClient
.
genrateId
(
this
.
modelName
);
}
}
}
}
if
(
t
)
{
return
await
this
.
model
.
bulkCreate
(
objs
,
{
transaction
:
t
});
}
else
{
return
await
this
.
model
.
bulkCreate
(
objs
);
return
await
this
.
model
.
bulkCreate
(
objs
);
}
}
}
static
getModelName
(
ClassObj
)
{
static
getModelName
(
ClassObj
)
{
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Dao"
)).
toLowerCase
()
return
ClassObj
[
"name"
].
substring
(
0
,
ClassObj
[
"name"
].
lastIndexOf
(
"Dao"
)).
toLowerCase
()
...
...
xggsve-order/app/base/db/impl/product/oprocessDao.js
View file @
7da23c5a
...
@@ -5,15 +5,26 @@ class OprocessDao extends Dao {
...
@@ -5,15 +5,26 @@ class OprocessDao extends Dao {
super
(
Dao
.
getModelName
(
OprocessDao
));
super
(
Dao
.
getModelName
(
OprocessDao
));
}
}
async
findMapByIds
(
ids
)
{
async
findMapByIds
(
ids
,
attrs
)
{
var
result
=
{};
var
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
if
(
!
ids
||
ids
.
length
==
0
)
{
return
result
;
return
result
;
}
}
attrs
=
attrs
||
"*"
;
var
sql
=
"SELECT "
+
attrs
+
" FROM `o_process` WHERE id IN (:ids)"
;
var
sql
=
"SELECT "
;
var
list
=
await
this
.
customQuery
(
sql
,
{
ids
:
ids
});
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
}
}
for
(
var
item
of
list
)
{
result
[
item
.
id
]
=
item
;
}
return
result
;
}
}
}
module
.
exports
=
OprocessDao
;
module
.
exports
=
OprocessDao
;
\ No newline at end of file
xggsve-order/app/base/db/impl/product/oproductprocessDao.js
View file @
7da23c5a
...
@@ -39,8 +39,8 @@ class OproductprocessDao extends Dao {
...
@@ -39,8 +39,8 @@ class OproductprocessDao extends Dao {
}
}
sql
.
push
(
"ORDER BY sort ASC"
);
sql
.
push
(
"ORDER BY sort ASC"
);
let
list
=
await
this
.
customQuery
(
sql
,
{
productPid
:
productPid
,
productIds
:
productIds
});
let
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
)
,
{
productPid
:
productPid
,
productIds
:
productIds
});
if
(
!
list
||
list
.
length
)
{
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
return
result
;
}
}
...
@@ -51,7 +51,7 @@ class OproductprocessDao extends Dao {
...
@@ -51,7 +51,7 @@ class OproductprocessDao extends Dao {
items
=
[];
items
=
[];
}
}
items
.
push
(
item
);
items
.
push
(
item
);
result
[
key
]
=
items
;
result
[
productId
]
=
items
;
}
}
return
result
;
return
result
;
}
}
...
...
xggsve-order/app/base/db/models/order/oorder.js
View file @
7da23c5a
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
module
.
exports
=
function
(
db
,
DataTypes
)
{
module
.
exports
=
function
(
db
,
DataTypes
)
{
return
db
.
define
(
'oorder'
,
{
return
db
.
define
(
'oorder'
,
{
merchant_id
:
{
type
:
DataTypes
.
STRING
,
field
:
'merchant_id'
,
allowNull
:
true
,
defaultValue
:
''
,
comment
:
'商户id, 为了兼容司机宝'
},
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_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'
},
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'
},
product_id
:
{
type
:
DataTypes
.
BIGINT
,
field
:
'product_id'
,
allowNull
:
true
,
defaultValue
:
0
,
comment
:
'产品id'
},
...
@@ -27,7 +26,7 @@ module.exports = function (db, DataTypes) {
...
@@ -27,7 +26,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
},
},
{
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
underscore
:
true
,
paranoid
:
true
,
paranoid
:
true
,
version
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/db/models/order/oorderprocess.js
View file @
7da23c5a
...
@@ -20,7 +20,7 @@ module.exports = function (db, DataTypes) {
...
@@ -20,7 +20,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
},
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
},
},
},
{
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
underscore
:
true
,
paranoid
:
true
,
paranoid
:
true
,
version
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/db/models/order/osource.js
View file @
7da23c5a
...
@@ -10,7 +10,7 @@ module.exports = function (db, DataTypes) {
...
@@ -10,7 +10,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
},
},
{
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
underscore
:
true
,
paranoid
:
true
,
paranoid
:
true
,
version
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/db/models/product/oproduct.js
View file @
7da23c5a
...
@@ -15,7 +15,7 @@ module.exports = function (db, DataTypes) {
...
@@ -15,7 +15,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
},
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
},
},
},
{
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
underscore
:
true
,
paranoid
:
true
,
paranoid
:
true
,
version
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/service/impl/order/oorderSve.js
View file @
7da23c5a
...
@@ -26,42 +26,58 @@ class OorderService extends ServiceBase {
...
@@ -26,42 +26,58 @@ class OorderService extends ServiceBase {
async
addSourceOrder
(
params
)
{
async
addSourceOrder
(
params
)
{
// 整理参数
// 整理参数
let
order
=
{
let
order
=
{
merchant
I
d
:
""
,
merchant
_i
d
:
""
,
channel
OrderN
o
:
""
,
channel
_order_n
o
:
""
,
busi_type
:
1
,
busi_type
:
1
,
busi_id
:
""
,
busi_id
:
""
,
price
:
0
,
price
:
0
,
};
};
order
.
product
Id
=
Number
(
params
.
productI
d
);
order
.
product
_id
=
Number
(
params
.
product_i
d
);
order
.
source
Id
=
Number
(
params
.
sourceI
d
);
order
.
source
_id
=
Number
(
params
.
source_i
d
);
order
.
source
No
=
this
.
trim
(
params
.
sourceN
o
);
order
.
source
_no
=
this
.
trim
(
params
.
source_n
o
);
order
.
notes
=
this
.
trim
(
params
.
notes
);
order
.
notes
=
this
.
trim
(
params
.
notes
);
order
.
contactMobile
=
this
.
trim
(
params
.
contactMobile
);
order
.
contact_mobile
=
this
.
trim
(
params
.
contact_mobile
);
// 验证订单是否存在
let
exists
=
await
this
.
dao
.
findOne
({
source_id
:
order
.
source_id
,
source_no
:
order
.
source_no
});
if
(
exists
)
{
return
system
.
getResult
(
null
,
`订单号
${
order
.
source_no
}
已存在`
);
}
// 验证来源
// 验证来源
let
source
=
await
this
.
osourceDao
.
findById
(
order
.
source
I
d
);
let
source
=
await
this
.
osourceDao
.
findById
(
order
.
source
_i
d
);
if
(
!
source
)
{
if
(
!
source
)
{
return
system
.
getResult
(
null
,
"来源错误"
);
return
system
.
getResult
(
null
,
"来源错误"
);
}
}
// 验证产品
// 验证产品
let
product
=
await
this
.
oproductDao
.
findById
(
order
.
product
I
d
);
let
product
=
await
this
.
oproductDao
.
findById
(
order
.
product
_i
d
);
if
(
!
product
)
{
if
(
!
product
)
{
return
system
.
getResult
(
null
,
"产品错误"
);
return
system
.
getResult
(
null
,
"产品错误"
);
}
}
// 获取产品状态
// 构建订单流程列表
await
this
.
getProductProcessList
(
productId
,
);
let
orderProcessList
=
await
this
.
buildOrderProcess
(
order
.
product_id
);
if
(
!
orderProcessList
||
orderProcessList
.
length
==
0
)
{
// 查询产品订单状态
return
system
.
getResult
(
null
,
"产品流程未配置"
);
}
// 合并订单状态
order
.
status
=
orderProcessList
[
0
].
status
;
// 开启事务
// 开启事务
var
self
=
this
;
await
this
.
db
.
transaction
(
async
function
(
t
)
{
// 插入订单数据
// 插入订单数据
order
=
await
self
.
dao
.
create
(
order
,
t
);
// 插入订单状态数据
// 插入订单状态数据
for
(
let
op
of
orderProcessList
)
{
op
.
order_id
=
order
.
id
;
}
await
self
.
oorderprocessDao
.
bulkCreate
(
orderProcessList
,
t
);
return
order
;
});
return
order
;
}
}
/**
/**
...
@@ -85,7 +101,7 @@ class OorderService extends ServiceBase {
...
@@ -85,7 +101,7 @@ class OorderService extends ServiceBase {
* @param chooseProductIds
* @param chooseProductIds
* @returns {Promise<void>}
* @returns {Promise<void>}
*/
*/
async
getProductProcessList
(
productPid
,
chooseProductIds
)
{
async
buildOrderProcess
(
productPid
,
chooseProductIds
)
{
// 查询所有产品子项
// 查询所有产品子项
let
productList
=
await
this
.
oproductDao
.
findListByPid
(
productPid
);
let
productList
=
await
this
.
oproductDao
.
findListByPid
(
productPid
);
...
@@ -93,7 +109,7 @@ class OorderService extends ServiceBase {
...
@@ -93,7 +109,7 @@ class OorderService extends ServiceBase {
let
productIds
=
[];
let
productIds
=
[];
for
(
let
product
of
productList
)
{
for
(
let
product
of
productList
)
{
// 过滤未选择产品
// 过滤未选择产品
if
(
product
.
is_choose
&&
chooseProductIds
&&
chooseProductIds
.
indexOf
(
product
.
id
)
==
-
1
)
{
if
(
product
.
is_choose
&&
chooseProductIds
&&
chooseProductIds
.
indexOf
(
product
.
id
)
==
-
1
)
{
continue
;
continue
;
}
}
productIds
.
push
(
product
.
id
);
productIds
.
push
(
product
.
id
);
...
@@ -103,17 +119,57 @@ class OorderService extends ServiceBase {
...
@@ -103,17 +119,57 @@ class OorderService extends ServiceBase {
}
}
// 查询产品流程
// 查询产品流程
let
processMap
=
await
this
.
oproductprocessDao
.
findMapByProductProductIds
(
productPid
,
productIds
);
let
productProcessMap
=
await
this
.
oproductprocessDao
.
findMapByProductProductIds
(
productPid
,
productIds
);
// 产品流程ids
let
processIds
=
[];
for
(
var
idx
in
productProcessMap
)
{
let
plist
=
productProcessMap
[
idx
];
if
(
!
plist
)
{
continue
;
}
for
(
let
p
of
plist
)
{
processIds
.
push
(
p
.
process_id
);
}
}
// 批量查流程
let
processMap
=
await
this
.
oprocessDao
.
findMapByIds
(
processIds
);
let
orderProcessList
=
[];
let
orderProcessList
=
[];
for
(
let
productId
of
productIds
)
{
for
(
let
productId
of
productIds
)
{
let
currentProcess
=
processMap
[
productId
];
// 产品子项流程列表
let
orderProcess
=
{};
let
productProcessList
=
productProcessMap
[
productId
];
if
(
processList
.
length
>
0
)
{
if
(
!
productProcessList
||
productProcessList
.
length
==
0
)
{
let
lastProcess
=
productList
[
processList
.
length
-
1
];
continue
;
}
}
}
for
(
let
idx
=
0
;
idx
<
productProcessList
.
length
;
idx
++
)
{
// 风还钻该处理每一个子项流程 变为 订单流程对象
let
productProcess
=
productProcessList
[
idx
];
let
process
=
processMap
[
productProcess
.
process_id
];
let
orderProcess
=
{
product_id
:
productPid
,
name
:
process
.
name
,
status
:
process
.
status
,
func
:
productProcess
.
func
,
next_status
:
productProcess
.
next_status
,
name1
:
productProcess
.
name1
,
name2
:
productProcess
.
name2
,
name3
:
productProcess
.
name3
,
name4
:
productProcess
.
name4
,
sort
:
productProcess
.
sort
,
autoIncrement
:
true
};
// 上一个产品流程于当前产品流程连接
if
(
idx
==
0
&&
orderProcessList
.
length
>
0
)
{
let
lastProcess
=
orderProcessList
[
orderProcessList
.
length
-
1
];
lastProcess
.
next_status
=
productProcess
.
process_id
;
}
orderProcessList
.
push
(
orderProcess
);
}
}
return
orderProcessList
;
}
}
}
}
...
...
xggsve-order/app/config/localsettings.js
View file @
7da23c5a
...
@@ -6,7 +6,7 @@ var settings={
...
@@ -6,7 +6,7 @@ var settings={
db
:
10
,
db
:
10
,
},
},
database
:{
database
:{
dbname
:
"xgg-order"
,
dbname
:
"xgg-order
2
"
,
user
:
"write"
,
user
:
"write"
,
password
:
"write"
,
password
:
"write"
,
config
:
{
config
:
{
...
...
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