Commit c2778533 by 杨树贤

案例关联商品

parent eeb76392
...@@ -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
...@@ -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;
......
...@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment