Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
LC_api_news
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2778533
authored
Dec 06, 2019
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
案例关联商品
parent
eeb76392
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
8 deletions
.env
app/Services/CaseService.php
config/website.php
.env
View file @
c2778533
...
@@ -25,5 +25,7 @@ REDIS_READ_HOST=192.168.1.235
...
@@ -25,5 +25,7 @@ REDIS_READ_HOST=192.168.1.235
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379
REDIS_READ_PORT=6379
GOODS_SERVER_URL=http://lc_server_goods.cc
CACHE_DRIVER=redis
CACHE_DRIVER=redis
QUEUE_DRIVER=sync
QUEUE_DRIVER=sync
app/Services/CaseService.php
View file @
c2778533
...
@@ -28,7 +28,7 @@ class CaseService extends BaseService
...
@@ -28,7 +28,7 @@ class CaseService extends BaseService
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
unset
(
$item
[
'article_tag'
]);
}
}
unset
(
$item
);
unset
(
$item
);
...
@@ -45,6 +45,18 @@ class CaseService extends BaseService
...
@@ -45,6 +45,18 @@ class CaseService extends BaseService
return
$case
;
return
$case
;
}
}
public
function
getGoodsInfo
(
$goodsId
)
{
$url
=
config
(
'website.GoodsServerUrl'
)
.
'/synchronization'
;
$result
=
curl
(
$url
,
[
'goods_id'
=>
$goodsId
],
true
);
$result
=
json_decode
(
$result
,
true
);
if
(
isset
(
$result
[
'errcode'
])
&&
$result
[
'errcode'
]
==
0
)
{
return
$result
[
'data'
][
$goodsId
];
}
return
[];
}
private
function
caseTransform
(
$item
)
private
function
caseTransform
(
$item
)
{
{
if
(
!
empty
(
$item
))
{
if
(
!
empty
(
$item
))
{
...
@@ -53,10 +65,24 @@ class CaseService extends BaseService
...
@@ -53,10 +65,24 @@ class CaseService extends BaseService
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'publish_time'
]
=
$item
[
'publish_time'
]
?
date
(
'Y-m-d H:i:s'
,
$item
[
'publish_time'
])
:
0
;
$item
[
'brand'
]
=
$item
[
'writer'
];
$item
[
'brand'
]
=
$item
[
'writer'
];
unset
(
$item
[
'writer'
]);
unset
(
$item
[
'writer'
]);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
$item
[
'tags'
]
=
array_column
(
$item
[
'article_tag'
],
'tag'
);
unset
(
$item
[
'article_tag'
]);
unset
(
$item
[
'article_tag'
]);
#todo 要从商品的服务那里根据goods_id去获取商品基础信息
$goodsInfo
=
$this
->
getGoodsInfo
(
$item
[
'goods_id'
]);
if
(
$goodsInfo
)
{
$item
[
'goods_info'
]
=
[
'goods_name'
=>
$goodsInfo
[
'goods_name'
],
'goods_image'
=>
is_array
(
$goodsInfo
[
'goods_images'
])
?
$goodsInfo
[
'goods_images'
][
0
]
:
$goodsInfo
[
'goods_images'
],
'ladder_price'
=>
$goodsInfo
[
'ladder_price'
],
'sku_name'
=>
$goodsInfo
[
'sku_name'
],
];
}
else
{
$item
[
'goods_info'
]
=
[];
}
if
(
isset
(
$item
[
'article_addon'
]))
{
$item
[
'body'
]
=
$item
[
'article_addon'
][
'body'
];
unset
(
$item
[
'article_addon'
]);
}
}
}
return
$item
;
return
$item
;
...
...
config/website.php
View file @
c2778533
...
@@ -7,12 +7,13 @@
...
@@ -7,12 +7,13 @@
*/
*/
return
[
return
[
'SystemCode'
=>
env
(
'SYSTEM_CODE'
,
'00'
),
//系统编码,需要在tapd维护,请勿占用已使用的编码
'SystemCode'
=>
env
(
'SYSTEM_CODE'
,
'00'
),
//系统编码,需要在tapd维护,请勿占用已使用的编码
'SystemName'
=>
env
(
'SYSTEM_NAME'
,
'这家伙没设置系统'
),
//系统名称
'SystemName'
=>
env
(
'SYSTEM_NAME'
,
'这家伙没设置系统'
),
//系统名称
'BaseUrl'
=>
env
(
'BaseUrl'
,
''
),
'BaseUrl'
=>
env
(
'BaseUrl'
,
''
),
'allow_origin'
=>
[
'GoodsServerUrl'
=>
env
(
'GOODS_SERVER_URL'
,
''
),
'allow_origin'
=>
[
],
],
'language'
=>
[
'language'
=>
[
''
,
''
,
],
],
];
];
\ 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