refactor: 修改产品购买链接分布接口
This commit is contained in:
@@ -71,6 +71,7 @@ class ProductPurchaseLink
|
|||||||
return success('获取成功', []);
|
return success('获取成功', []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取购买链接数据
|
||||||
$others = ProductPurchaseLinkModel::alias('pl')
|
$others = ProductPurchaseLinkModel::alias('pl')
|
||||||
->field([
|
->field([
|
||||||
'pl.product_id',
|
'pl.product_id',
|
||||||
@@ -99,6 +100,36 @@ class ProductPurchaseLink
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取平台数据
|
||||||
|
$platforms = ProductPurchaseLinkPlatformModel::field(['id', 'platform'])
|
||||||
|
->language(request()->lang_id)
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
$platforms_map = [];
|
||||||
|
foreach ($platforms as $k => $v) {
|
||||||
|
$platforms_map[$v['id']] = [
|
||||||
|
'platform_id' => $v['id'],
|
||||||
|
'platform_name' => $v['platform'],
|
||||||
|
'link_id' => 0,
|
||||||
|
'link' => ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// 没有购买链接的,补全平台数据
|
||||||
|
$links->each(function ($item) use($platforms_map) {
|
||||||
|
if (empty($item['rowspan'])) {
|
||||||
|
$item['rowspan'] = array_values($platforms_map);
|
||||||
|
} else if (count($item['rowspan']) < count($platforms_map)) {
|
||||||
|
foreach ($item['rowspan'] as $k => $v) {
|
||||||
|
if (!empty($platforms_map[$v['platform_id']])) {
|
||||||
|
unset($platforms_map[$v['platform_id']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item['rowspan'] = array_merge($item['rowspan'], array_values($platforms_map));
|
||||||
|
}
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
return success('获取成功', $links);
|
return success('获取成功', $links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user