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
fba8af9a
Commit
fba8af9a
authored
Sep 09, 2021
by
王悦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix接口
parent
7c6a9353
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
1 deletions
+145
-1
center-tmtransaction/app/base/service/impl/tm/trademarktransactionSve.js
+82
-1
center-tmtransaction/app/base/utils/aliClient.js
+63
-0
No files found.
center-tmtransaction/app/base/service/impl/tm/trademarktransactionSve.js
View file @
fba8af9a
...
...
@@ -2,6 +2,7 @@ const system = require("../../../system");
const
{
PDICT
}
=
require
(
"../../../../config/platform"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
{
reqbyget
,
buildobj
}
=
require
(
"../../../utils/aliClient"
);
var
fs
=
require
(
'fs'
);
class
TrademarktransactionService
extends
ServiceBase
{
constructor
()
{
...
...
@@ -564,7 +565,7 @@ class TrademarktransactionService extends ServiceBase {
* @apiErrorExample {json} 失败示例:
* {"error": ""}
*/
async
tmStatusUpdate
(
pobj
,
actionBody
)
{
/*
async tmStatusUpdate(pobj, actionBody) {
if (!pobj || !pobj.actionBody || !pobj.actionBody.tm) {
return system.getResultFail(-103, "actionBody is empty");
}
...
...
@@ -620,6 +621,86 @@ class TrademarktransactionService extends ServiceBase {
return system.getResultFail(-111, "修改状态错误");
}
return system.getResultSuccess(tmUpdateResult);
}*/
async
tmStatusUpdate
(
pobj
,
actionBody
)
{
if
(
!
pobj
||
!
pobj
.
actionBody
||
!
pobj
.
actionBody
.
tm
)
{
return
system
.
getResultFail
(
-
103
,
"actionBody is empty"
);
}
if
(
actionBody
.
tm
.
length
==
0
)
{
return
system
.
getResultFail
(
-
110
,
"actionBody.tm is empty"
);
}
let
ids
=
[]
let
downids
=
[]
for
(
let
i
=
0
;
i
<
actionBody
.
tm
.
length
;
i
++
)
{
ids
.
push
(
actionBody
.
tm
[
i
].
id
)
}
let
status
switch
(
actionBody
.
status
)
{
// 如果下架 全部下架
case
"lowershelf"
:
status
=
"FAIL_END"
break
;
case
"uppershelf"
:
ids
=
[]
status
=
"ON_SALE"
// 如果上架 去查询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"
,[
this
.
db
.
Op
.
not
]:
[{
id
:[
actionBody
.
tm
[
i
].
id
]}]
},
attributes
:
[
"id"
,
"platform_quoted_price"
],
raw
:
true
});
// 如果没有 随意更改
if
(
!
tmInfo
)
{
ids
.
push
(
actionBody
.
tm
[
i
].
id
)
}
// 如果有并 价格低于之前上架的
else
if
(
actionBody
.
tm
[
i
].
platform_quoted_price
<
tmInfo
.
platform_quoted_price
)
{
//修改之前的为下架
downids
.
push
(
tmInfo
.
id
)
//修改需要上架的
ids
.
push
(
actionBody
.
tm
[
i
].
id
)
}
}
break
;
case
"oversales"
:
await
this
.
dao
.
model
.
update
({
publish_status
:
"oversales"
},{
where
:
{
id
:
{
$in
:
ids
}
}
})
break
;
default
:
return
system
.
getResultFail
(
-
111
,
"修改状态错误"
);
}
if
(
ids
.
length
>
0
)
this
.
updateAli
(
ids
,
status
)
if
(
downids
.
length
>
0
)
this
.
updateAli
(
ids
,
"FAIL_END"
)
return
system
.
getResultSuccess
();
}
async
updateAli
(
ids
,
status
)
{
let
action
=
status
===
"ON_SALE"
?
"UploadTrademarkOnSale"
:
"UpdateTrademarkOnsale"
let
res
=
await
this
.
dao
.
model
.
findAll
({
where
:
{
id
:
{
$in
:
ids
}}})
for
(
const
item
of
res
)
{
let
obj
=
buildobj
(
item
,
status
)
if
(
obj
)
{
let
err
=
await
reqbyget
({
action
,
reqbody
:
obj
})
if
(
err
){
item
.
fail_reason
=
err
item
.
publish_status
=
"fail"
item
.
publish_status_name
=
"发布失败"
}
else
{
item
.
publish_status
=
status
===
"ON_SALE"
?
"uppershelf"
:
"lowershelf"
item
.
publish_status_name
=
status
===
"ON_SALE"
?
"在售"
:
"下架"
}
item
.
save
()
}
}
}
/**
* @api {post} /tmtransaction/action/trademarktransaction/springBoard 修改
...
...
center-tmtransaction/app/base/utils/aliClient.js
0 → 100644
View file @
fba8af9a
var
RPCClient
=
require
(
'@alicloud/pop-core'
).
RPCClient
;
getAliTMClient
=
()
=>
{
return
new
RPCClient
({
accessKeyId
:
'LTAI4FmyipY1wuLHjLhMWiPa'
,
accessKeySecret
:
'hp4FF18IDCSym1prqzxrAjnnhNH3ju'
,
endpoint
:
'https://trademark.aliyuncs.com'
,
apiVersion
:
'2018-07-24'
}
);
}
//阿里接口
exports
.
reqbyget
=
async
(
obj
)
=>
{
var
action
=
obj
.
action
;
var
reqbody
=
obj
.
reqbody
;
try
{
var
reqAliclient
=
getAliTMClient
();
if
(
obj
.
apiVersion
)
{
reqAliclient
.
apiVersion
=
obj
.
apiVersion
;
}
var
res
=
await
reqAliclient
.
request
(
action
,
reqbody
,
{
timeout
:
10000
,
// default 3000 ms 2020 0916 lin修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction
:
true
,
// default true, format the action to Action
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
method
:
'GET'
,
// set the http method, default is GET
headers
:
{},
// set the http request headers
});
// console.log(obj.reqbody.tmNumber,"---",obj.reqbody.tmName,"---","成功");
}
catch
(
e
)
{
// console.log(obj.reqbody.tmNumber,"---",obj.reqbody.tmName,"---",e.data.Message);
return
e
.
data
.
Message
}
}
exports
.
buildobj
=
(
sqlobj
,
status
)
=>
{
try
{
if
(
!
sqlobj
.
tm_ncl_third
||
!
sqlobj
.
tm_group
)
return
null
return
{
"beginTime"
:
1574388139000
,
"classificationCode"
:
sqlobj
.
ncl_one_code
,
"description"
:
JSON
.
parse
(
sqlobj
.
tm_ncl_third
).
join
(
","
),
"endTime"
:
1668089537981
,
"label"
:
"商标标签"
,
"originalPrice"
:
sqlobj
.
platform_quoted_price
,
"ownerEnName"
:
""
,
"ownerName"
:
sqlobj
.
tm_applier
,
"partnerCode"
:
"gong_si_bao"
,
"regAnnDate"
:
new
Date
(
sqlobj
.
tm_regist_day
).
getTime
(),
"secondaryClassification"
:
JSON
.
parse
(
sqlobj
.
tm_group
).
join
(
","
),
"status"
:
status
,
"thirdClassification"
:
JSON
.
parse
(
sqlobj
.
tm_ncl_third
).
join
(
","
),
"tmIcon"
:
sqlobj
.
pic_url
,
"tmName"
:
sqlobj
.
name
,
"tmNumber"
:
sqlobj
.
code
}
}
catch
(
e
){
return
null
}
}
\ 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