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
3207e98e
Commit
3207e98e
authored
Jan 09, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'xggsve-order-dev' of gitlab.gongsibao.com:jiangyong/zhichan into xggsve-order-dev
parents
6ce71df0
aea9b21b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
120 additions
and
38 deletions
+120
-38
xggsve-order/app/base/api/api.base.js
+1
-1
xggsve-order/app/base/api/impl/op/action.js
+11
-1
xggsve-order/app/base/db/dao.base.js
+7
-3
xggsve-order/app/base/db/impl/product/oprocessDao.js
+15
-3
xggsve-order/app/base/db/impl/product/oproductprocessDao.js
+3
-3
xggsve-order/app/base/db/models/order/oorder.js
+1
-1
xggsve-order/app/base/db/models/order/oorderprocess.js
+1
-1
xggsve-order/app/base/service/impl/order/oorderSve.js
+81
-25
No files found.
xggsve-order/app/base/api/api.base.js
View file @
3207e98e
...
...
@@ -70,7 +70,7 @@ class APIBase extends DocBase {
async
doexec
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
var
requestid
=
this
.
getUUID
();
try
{
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
)
||
{}
;
rtn
.
requestid
=
requestid
;
this
.
oplogSve
.
createDb
({
...
...
xggsve-order/app/base/api/impl/op/action.js
View file @
3207e98e
...
...
@@ -17,7 +17,6 @@ class ActionAPI extends APIBase {
this
.
oorderSve
=
system
.
getObject
(
"service.order.oorderSve"
);
this
.
oorderdeliverSve
=
system
.
getObject
(
"service.order.oorderdeliverSve"
);
}
/**
* 接口跳转
...
...
@@ -44,6 +43,12 @@ class ActionAPI extends APIBase {
async
handleRequest
(
action_process
,
action_type
,
action_body
)
{
var
opResult
=
null
;
try
{
}
catch
(
e
)
{
}
switch
(
action_type
)
{
case
"orders"
:
//订单列表
...
...
@@ -59,6 +64,11 @@ class ActionAPI extends APIBase {
//******************************************************************** */
// 订单
case
"addSourceOrder"
:
//创建订单
opResult
=
await
this
.
oorderSve
.
addSourceOrder
(
action_body
);
break
;
// 订单
case
"createOrder"
:
//创建订单
opResult
=
await
this
.
iborderbaseSve
.
apiCreateOrder
(
action_body
);
break
;
...
...
xggsve-order/app/base/db/dao.base.js
View file @
3207e98e
...
...
@@ -35,16 +35,20 @@ class Dao {
}
//批量插入
async
bulkCreate
(
objs
)
{
async
bulkCreate
(
objs
,
t
)
{
if
(
!
objs
||
objs
.
length
==
0
)
{
return
;
}
for
(
var
obj
of
objs
)
{
if
(
!
obj
.
id
)
{
if
(
!
obj
.
id
&&
!
obj
.
autoIncrement
)
{
obj
.
id
=
await
this
.
redisClient
.
genrateId
(
this
.
modelName
);
}
}
return
await
this
.
model
.
bulkCreate
(
objs
);
if
(
t
)
{
return
await
this
.
model
.
bulkCreate
(
objs
,
{
transaction
:
t
});
}
else
{
return
await
this
.
model
.
bulkCreate
(
objs
);
}
}
static
getModelName
(
ClassObj
)
{
...
...
xggsve-order/app/base/db/impl/product/oprocessDao.js
View file @
3207e98e
...
...
@@ -5,15 +5,26 @@ class OprocessDao extends Dao {
super
(
Dao
.
getModelName
(
OprocessDao
));
}
async
findMapByIds
(
ids
)
{
async
findMapByIds
(
ids
,
attrs
)
{
var
result
=
{};
if
(
!
ids
||
ids
.
length
==
0
)
{
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
;
\ No newline at end of file
xggsve-order/app/base/db/impl/product/oproductprocessDao.js
View file @
3207e98e
...
...
@@ -39,8 +39,8 @@ class OproductprocessDao extends Dao {
}
sql
.
push
(
"ORDER BY sort ASC"
);
let
list
=
await
this
.
customQuery
(
sql
,
{
productPid
:
productPid
,
productIds
:
productIds
});
if
(
!
list
||
list
.
length
)
{
let
list
=
await
this
.
customQuery
(
sql
.
join
(
" "
)
,
{
productPid
:
productPid
,
productIds
:
productIds
});
if
(
!
list
||
list
.
length
==
0
)
{
return
result
;
}
...
...
@@ -51,7 +51,7 @@ class OproductprocessDao extends Dao {
items
=
[];
}
items
.
push
(
item
);
result
[
key
]
=
items
;
result
[
productId
]
=
items
;
}
return
result
;
}
...
...
xggsve-order/app/base/db/models/order/oorder.js
View file @
3207e98e
...
...
@@ -27,7 +27,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
}
},
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
paranoid
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/db/models/order/oorderprocess.js
View file @
3207e98e
...
...
@@ -20,7 +20,7 @@ module.exports = function (db, DataTypes) {
deleted_at
:
{
type
:
DataTypes
.
DATE
,
field
:
'deleted_at'
,
allowNull
:
true
},
},
{
timestamps
:
tru
e
,
timestamps
:
fals
e
,
underscore
:
true
,
paranoid
:
true
,
version
:
true
,
...
...
xggsve-order/app/base/service/impl/order/oorderSve.js
View file @
3207e98e
...
...
@@ -26,42 +26,58 @@ class OorderService extends ServiceBase {
async
addSourceOrder
(
params
)
{
// 整理参数
let
order
=
{
merchant
I
d
:
""
,
channel
OrderN
o
:
""
,
merchant
_i
d
:
""
,
channel
_order_n
o
:
""
,
busi_type
:
1
,
busi_id
:
""
,
price
:
0
,
};
order
.
product
Id
=
Number
(
params
.
productI
d
);
order
.
source
Id
=
Number
(
params
.
sourceI
d
);
order
.
source
No
=
this
.
trim
(
params
.
sourceN
o
);
order
.
product
_id
=
Number
(
params
.
product_i
d
);
order
.
source
_id
=
Number
(
params
.
source_i
d
);
order
.
source
_no
=
this
.
trim
(
params
.
source_n
o
);
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
)
{
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
)
{
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 {
* @param chooseProductIds
* @returns {Promise<void>}
*/
async
getProductProcessList
(
productPid
,
chooseProductIds
)
{
async
buildOrderProcess
(
productPid
,
chooseProductIds
)
{
// 查询所有产品子项
let
productList
=
await
this
.
oproductDao
.
findListByPid
(
productPid
);
...
...
@@ -93,7 +109,7 @@ class OorderService extends ServiceBase {
let
productIds
=
[];
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
;
}
productIds
.
push
(
product
.
id
);
...
...
@@ -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
=
[];
for
(
let
productId
of
productIds
)
{
let
currentProcess
=
processMap
[
productId
];
let
orderProcess
=
{}
;
if
(
processList
.
length
>
0
)
{
let
lastProcess
=
productList
[
processList
.
length
-
1
]
;
// 产品子项流程列表
let
productProcessList
=
productProcessMap
[
productId
]
;
if
(
!
productProcessList
||
productProcessList
.
length
==
0
)
{
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
;
}
/**
...
...
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