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
b407de27
Commit
b407de27
authored
Sep 11, 2020
by
linboxuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tmStatusUpdate增加批量状态修改的接口
parent
23049e43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
center-tmtransaction/app/base/service/impl/tm/trademarktransactionSve.js
+22
-15
No files found.
center-tmtransaction/app/base/service/impl/tm/trademarktransactionSve.js
View file @
b407de27
...
...
@@ -439,17 +439,17 @@ class TrademarktransactionService extends ServiceBase {
* {
"actionType": "tmStatusUpdate",
"actionBody": {
tm
:[
"tm"
:[
{
id
:1,
code
:1,
platform_quoted_price
:1200
"id"
:1,
"code"
:1,
"platform_quoted_price"
:1200
},{
id
:2,
code;
2,
platform_quoted_price
:1200
"id"
:2,
"code":
2,
"platform_quoted_price"
:1200
}
]
,
]
status:"uppershelf/lowershelf"
}
}
...
...
@@ -505,31 +505,38 @@ class TrademarktransactionService extends ServiceBase {
// 如果下架 全部下架
case
"lowershelf"
:
for
(
var
i
=
0
;
i
<
actionBody
.
tm
.
length
;
i
++
)
{
a
ctionBody
.
tm
[
i
].
publish_status
=
"lowershelf"
a
wait
this
.
dao
.
model
.
update
({
publish_status
:
"lowershelf"
},{
where
:
{
id
:
actionBody
.
tm
[
i
].
id
}
})
}
var
tmUpdateResult
=
await
this
.
dao
.
model
.
bulkCreate
(
actionBody
.
tm
,{
updateOnDuplicate
:
true
})
// 这个方法会把其他字段改为null 不使用了
// var tmUpdateResult = await this.dao.model.bulkCreate(actionBody.tm,{updateOnDuplicate:true})
break
;
case
"uppershelf"
:
var
tmUpdateResult
=
[]
// 如果上架 去查询code相同并上架的标源,价格低于,则上。否失败
for
(
var
i
=
0
;
i
<
actionBody
.
tm
.
length
;
i
++
)
{
// 查处code相同 id不相同 状态为上架的标
var
tmInfo
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
code
:
actionBody
.
tm
[
i
].
code
,
publish_status
:
"uppershelf"
},
where
:
{
code
:
actionBody
.
tm
[
i
].
code
,
publish_status
:
"uppershelf"
,[
this
.
db
.
Op
.
not
]:
[{
id
:[
actionBody
.
tm
[
i
].
id
]}]
},
attributes
:
[
"id"
,
"platform_quoted_price"
],
raw
:
true
});
// 如果没有 随意更改
if
(
!
tmInfo
)
{
await
this
.
dao
.
model
.
update
({
publish_status
:
"uppershelf"
},{
where
:
{
id
:
actionBody
.
tm
[
i
].
id
}
})
continue
}
// 如果有并 价格低于之前上架的
if
(
actionBody
.
tm
[
i
].
platform_quoted_price
<
tmInfo
.
platform_quoted_price
)
{
//修改之前的为下架
tmInfo
.
publish_status
=
"lowershelf"
;
await
this
.
dao
.
model
.
update
(
tmInfo
)
await
this
.
dao
.
model
.
update
({
publish_status
:
"lowershelf"
},{
where
:
{
id
:
tmInfo
.
id
}
})
//修改需要上架的
actionBody
.
tm
[
i
].
publish_status
=
"uppershelf"
;
await
this
.
dao
.
model
.
update
(
actionBody
.
tm
[
i
])
await
this
.
dao
.
model
.
update
({
publish_status
:
"uppershelf"
},{
where
:
{
id
:
actionBody
.
tm
[
i
].
id
}
})
}
// 否则失败 暂时不做处理
// 可以优化的地方:比如已经是想修改的状态 怎么做跳过?其他验证是否完善?
}
break
;
default
:
...
...
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