store excel
parent
8fcfc148e9
commit
fddb704877
|
|
@ -17,21 +17,22 @@ class HomeController extends Controller
|
||||||
public function index(Content $content)
|
public function index(Content $content)
|
||||||
{
|
{
|
||||||
return $content
|
return $content
|
||||||
->header('首页')
|
->header('首页')
|
||||||
->description('首页')
|
->description('首页')
|
||||||
->body(function (Row $row) {
|
->body(function (Row $row) {
|
||||||
$row->column(6, function (Column $column) {
|
$user = Admin::user();
|
||||||
|
$row->column(6, function (Column $column) use ($user) {
|
||||||
$column->row(Dashboard::title());
|
$column->row(Dashboard::title());
|
||||||
if (Admin::user()->can('dcat.admin.home.statistics')) {
|
if ($user->can('dcat.admin.home.statistics')) {
|
||||||
$column->row(new StatisticsTotal());
|
$column->row(new StatisticsTotal());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$row->column(6, function (Column $column) {
|
$row->column(6, function (Column $column) use ($user) {
|
||||||
if (Admin::user()->can('dcat.admin.home.new_users')) {
|
if ($user->can('dcat.admin.home.new_users')) {
|
||||||
$column->row(new NewUsers());
|
$column->row(new NewUsers());
|
||||||
}
|
}
|
||||||
if (Admin::user()->can('dcat.admin.home.orders')) {
|
if ($user->can('dcat.admin.home.orders')) {
|
||||||
$column->row(new Orders());
|
$column->row(new Orders());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class StoreProduct
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$storeName = $cells[$index];// 店铺名称
|
$storeName = $cells[$index];// 店铺名称
|
||||||
$goodsName = $cells[++$index];// 商品名称
|
$goodsName = $cells[++$index];// 商品名称
|
||||||
|
$stock = $cells[++$index];// 库存
|
||||||
$goodsTitle = $cells[++$index];// 商品副标题
|
$goodsTitle = $cells[++$index];// 商品副标题
|
||||||
$categoryName = $cells[++$index];// 分类名称
|
$categoryName = $cells[++$index];// 分类名称
|
||||||
$goodsImage = $cells[++$index];// 商品图片
|
$goodsImage = $cells[++$index];// 商品图片
|
||||||
|
|
@ -47,65 +48,62 @@ class StoreProduct
|
||||||
// https://qiniu.abcdefg.fun/banner/banner4.png,https://qiniu.abcdefg.fun/banner/banner5.png
|
// https://qiniu.abcdefg.fun/banner/banner4.png,https://qiniu.abcdefg.fun/banner/banner5.png
|
||||||
$goodsContent = $cells[++$index];
|
$goodsContent = $cells[++$index];
|
||||||
|
|
||||||
$stock = $cells[++$index];// 库存
|
|
||||||
|
|
||||||
$store = Store::where(['title' => $storeName])->first();
|
$store = Store::where(['title' => $storeName])->first();
|
||||||
if (!$store) {
|
if (!$store) {
|
||||||
throw new ImportException('门店 '.$storeName.' 不存在');
|
throw new ImportException('门店 '.$storeName.' 不存在');
|
||||||
}
|
}
|
||||||
|
|
||||||
$goods = [
|
$product = ProductSpu::where('name', $goodsName)->first();
|
||||||
'name' => $goodsName,
|
|
||||||
'subtitle' => $goodsTitle,
|
|
||||||
'shipping_template_id' => 1,
|
|
||||||
];
|
|
||||||
$category = ProductCategory::where('name', $categoryName)->first();
|
|
||||||
if (!$category) {
|
|
||||||
throw new ImportException('分类 '.$categoryName.' 不存在');
|
|
||||||
}
|
|
||||||
$goods['category_id'] = $category->id;
|
|
||||||
|
|
||||||
// 图片组
|
|
||||||
if ($goodsImage) {
|
|
||||||
if (Str::startsWith($goodsImage, ['http://', 'https://'])) {
|
|
||||||
$images = explode(',', $goodsImage);
|
|
||||||
} else {
|
|
||||||
$images = $this->getImageUrlFromPath($goodsImage);
|
|
||||||
}
|
|
||||||
if (count($images) > 0) {
|
|
||||||
$goods['cover'] = $images[0];
|
|
||||||
$goods['images'] = $images;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 运费模板
|
|
||||||
if ($shipTemplate) {
|
|
||||||
$goods['shipping_template_id'] = $shipTemplate;
|
|
||||||
}
|
|
||||||
// 重量
|
|
||||||
if ($goodsWeight) {
|
|
||||||
$goods['weight'] = $goodsWeight;
|
|
||||||
}
|
|
||||||
// 详细描述
|
|
||||||
if ($goodsContent) {
|
|
||||||
$description = '';
|
|
||||||
foreach(explode(',', $goodsContent) as $item) {
|
|
||||||
$description .= '<p><img src="'.$item.'"/></p>';
|
|
||||||
}
|
|
||||||
$goods['description'] = $description;
|
|
||||||
}
|
|
||||||
|
|
||||||
$goods = array_merge($goods, [
|
|
||||||
'sell_price' => $salePrice * 100,
|
|
||||||
'market_price' => $marketPrice * 100,
|
|
||||||
'cost_price' => $costPrice * 100,
|
|
||||||
'vip_price' => $vipPrice * 100,
|
|
||||||
'sales_value' => $saleValue,
|
|
||||||
'stock' => $stock,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$product = ProductSpu::where('name', $goods['name'])->first();
|
|
||||||
if (!$product) {
|
if (!$product) {
|
||||||
|
$goods = [
|
||||||
|
'name' => $goodsName,
|
||||||
|
'subtitle' => $goodsTitle,
|
||||||
|
'shipping_template_id' => 1,
|
||||||
|
];
|
||||||
|
$category = ProductCategory::where('name', $categoryName)->first();
|
||||||
|
if (!$category) {
|
||||||
|
throw new ImportException('分类 '.$categoryName.' 不存在');
|
||||||
|
}
|
||||||
|
$goods['category_id'] = $category->id;
|
||||||
|
|
||||||
|
// 图片组
|
||||||
|
if ($goodsImage) {
|
||||||
|
if (Str::startsWith($goodsImage, ['http://', 'https://'])) {
|
||||||
|
$images = explode(',', $goodsImage);
|
||||||
|
} else {
|
||||||
|
$images = $this->getImageUrlFromPath($goodsImage);
|
||||||
|
}
|
||||||
|
if (count($images) > 0) {
|
||||||
|
$goods['cover'] = $images[0];
|
||||||
|
$goods['images'] = $images;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 运费模板
|
||||||
|
if ($shipTemplate) {
|
||||||
|
$goods['shipping_template_id'] = $shipTemplate;
|
||||||
|
}
|
||||||
|
// 重量
|
||||||
|
if ($goodsWeight) {
|
||||||
|
$goods['weight'] = $goodsWeight;
|
||||||
|
}
|
||||||
|
// 详细描述
|
||||||
|
if ($goodsContent) {
|
||||||
|
$description = '';
|
||||||
|
foreach(explode(',', $goodsContent) as $item) {
|
||||||
|
$description .= '<p><img src="'.$item.'"/></p>';
|
||||||
|
}
|
||||||
|
$goods['description'] = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
$goods = array_merge($goods, [
|
||||||
|
'sell_price' => $salePrice * 100,
|
||||||
|
'market_price' => $marketPrice * 100,
|
||||||
|
'cost_price' => $costPrice * 100,
|
||||||
|
'vip_price' => $vipPrice * 100,
|
||||||
|
'sales_value' => $saleValue,
|
||||||
|
'stock' => $stock,
|
||||||
|
]);
|
||||||
$product = ProductSpu::create($goods);
|
$product = ProductSpu::create($goods);
|
||||||
// 属性规格
|
// 属性规格
|
||||||
if ($rowAttrs) {
|
if ($rowAttrs) {
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ class AdminPermissionSeeder extends Seeder
|
||||||
'name'=>'主页',
|
'name'=>'主页',
|
||||||
'curd' => false,
|
'curd' => false,
|
||||||
'children' =>[
|
'children' =>[
|
||||||
'home.statistics'=>['name' =>'统计预览'],
|
'statistics'=>['name' =>'统计预览'],
|
||||||
'home.new_users'=>['name' =>'新注册'],
|
'new_users'=>['name' =>'新注册'],
|
||||||
'home.orders'=>['name' =>'订单'],
|
'orders'=>['name' =>'订单'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'users'=>[
|
'users'=>[
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue