<?php

use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\DataCenter\DataCenterController;
use App\Http\Controllers\Role\RolesController;
use App\Http\Controllers\Shop\ShipController;
use App\Http\Controllers\UploadController;
use App\Http\Controllers\Shop\ShopsController;
use App\Http\Controllers\Goods\GoodsSkusController;
use App\Http\Controllers\Business\BusinessGoodsSkusController;
use App\Http\Controllers\Group\GroupsController;
use App\Http\Controllers\Business\BusinessOrderController;
use App\Http\Controllers\Goods\GoodsSkuLocationController;
use App\Http\Controllers\Goods\GoodsCombinationController;
use App\Http\Controllers\Supplier\DailyStockRecordController;
use App\Http\Controllers\Supplier\LossRecordController;
use App\Http\Controllers\Supplier\PurchaseRecordController;
use App\Http\Controllers\Business\BusinessAfterSaleOrderController;
use App\Http\Controllers\Goods\GoodsTypesController;
use App\Http\Controllers\User\UsersController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware(['auth:api', 'check.permissions'])->group(function () {
    // 用户
    Route::resource('users', 'User\UsersController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    // 商品种类
    Route::resource('goods_types', 'Goods\GoodsTypesController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    // 商品品牌
    Route::resource('goods_brands', 'Goods\GoodsBrandsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    // 日志
    Route::resource('logs', 'Log\LogsController', ['only' => ['index']]);
    // 商品
    Route::resource('goods', 'Goods\GoodsController', ['only' => ['index', 'store']]);
    Route::resource('goods_combination', 'Goods\GoodsCombinationController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    // 商品规格
    Route::resource('goods_skus', 'Goods\GoodsSkusController', ['only' => ['index', 'show', 'update', 'store']]);
    Route::patch('batch/goods_skus', [GoodsSkusController::class, 'batchUpdate'])->name('goods_sku.batch_update');
    Route::patch('single/goods_skus/{id}', [GoodsSkusController::class, 'updateField'])->name('goods_sku.single_update');
    // 店铺
    Route::resource('shops', 'Shop\ShopsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    Route::get('count/orders/num', [ShopsController::class, 'countOrdersNumWithSkuCode'])->name('goods_sku.orders_num');
    Route::get('download/{id}/goods', [ShopsController::class, 'downloadGoods'])->name('business.goods_sku.download');
    Route::put('sync/shop/stock', [ShopsController::class, 'syncStock'])->name('business.shop.sync_stock');
    Route::get('order/reset', [ShopsController::class, 'orderReset'])->name('order.reset_count');
    // 角色
    Route::resource('roles', 'Role\RolesController', ['only' => ['index', 'store', 'show', 'update']]);
    Route::post('roles/{id}/permissions', [RolesController::class, 'addPermissions'])->name('roles.permission');
    // 权限
    Route::resource('permissions', 'Permission\PermissionsController', ['only' => ['index',
//        'store', 'show', 'update', 'destroy'
    ]]);
    // 平台
    Route::resource('plat_goods', 'Business\BusinessGoodsSkusController', ['only' => ['index', 'update', 'destroy']]);
    Route::get('plat_orders', [BusinessOrderController::class, 'index'])->name('plat.orders.index');
    Route::get('plat_group_activity/{shopId}', [BusinessOrderController::class, 'groupActivity'])->name('plat.activity.list');
    Route::post('plat/sync/{id}/stock', [BusinessGoodsSkusController::class, 'syncStock'])->name('plat.sync.stock');
    // 团购
    Route::resource('group', 'Group\GroupsController', ['only' => ['index', 'store', 'show', 'update', 'destroy']]);
    // 商品货架
    Route::get('goods_sku_location', [GoodsSkuLocationController::class, 'index'])->name('goods_sku_location.index');
    Route::put('goods_sku_location', [GoodsSkuLocationController::class, 'update'])->name('goods_sku_location.update');
    Route::delete('goods_sku_location', [GoodsSkuLocationController::class, 'delete'])->name('goods_sku_location.delete');
    // 电子面单
    Route::get('shop/ship', [ShipController::class, 'index'])->name('shop_ship.index');
    Route::get('print/orders', [BusinessOrderController::class, 'print'])->name('order.print');
    Route::put('print/success', [BusinessOrderController::class, 'printSuccess'])->name('order.printSuccess');
    Route::get('waybill/queryTrace', [\App\Http\Controllers\Business\WaybillController::class, 'queryTrace']);
    Route::post('waybill/cancel', [\App\Http\Controllers\Business\WaybillController::class, 'cancel']);
    // 发货信息
    Route::get('shop/ship/senders', [ShipController::class, 'getSenders'])->name('shop_ship.senders.get');
    Route::post('shop/ship/senders', [ShipController::class, 'saveSenders'])->name('shop_ship.senders.save');
    Route::resource('shop_sends', 'Shop\ShopSendsController', ['only' => ['index', 'store']]);

    // 数据中心
    Route::get('data_center/sales_report', [DataCenterController::class, 'salesReport'])->name('sales_report.index');
    //供应商
    Route::resource('supplier', 'Supplier\SuppliersController', ['only' => ['index', 'update', 'store','destroy']]);
    //站内信
    Route::resource('website_message', 'Message\WebsiteMessageController', ['only' => ['index', 'update']]);
    Route::post('website_message/batchRead', [\App\Http\Controllers\Message\WebsiteMessageController::class, 'batchRead']);

    //仓库管理-采购单
    Route::resource('supplier/purchase_record', 'Supplier\PurchaseRecordController',['only' => ['index', 'store','update']]);
    //报损单
    Route::resource('supplier/loss_record', 'Supplier\LossRecordController',['only' => ['index', 'store','update']]);
    //仓库管理-盘点
    Route::resource('supplier/daily_stock_record', 'Supplier\DailyStockRecordController',['only' => ['index', 'store']]);

    // 数据中心 销售报表
    Route::get('data_center/sale_statistics', [DataCenterController::class, 'saleStatistics'])->name('data_center.sale_statistics');
    Route::get('data_center/spu_sale_statistics', [DataCenterController::class, 'spuSaleStatistics'])->name('data_center.spu_sale_statistics');
    Route::get('data_center/gmv_statistics', [DataCenterController::class, 'gmvStatistics'])->name('data_center.gmv_statistics');
    Route::get('data_center/loss_record_statistics', [DataCenterController::class, 'lossRecordStatistics'])->name('data_center.loss_record_statistics');

    Route::get('plat_after_sale_orders', [BusinessAfterSaleOrderController::class, 'index'])->name('plat_after_sale_orders.index');
    //获取树
    Route::get('goodsTypes/tree', [GoodsTypesController::class, 'tree'])->name('goods_types.tree');

    Route::post('loss_record/loss_batch_store', [LossRecordController::class, 'lossBatchStore'])->name('loss_record.loss_batch_store');
    Route::post('purchase_record/purchase_batch_store', [PurchaseRecordController::class, 'purchaseBatchStore'])->name('purchase_record.purchase_batch_store');
    Route::post('daily_stock_record/inventory_batch_store', [DailyStockRecordController::class, 'inventoryBatchStore'])->name('daily_stock_record.inventory_batch_store');

    Route::post('purchase_record/purchase_batch_check', [PurchaseRecordController::class, 'purchaseBatchCheck'])->name('purchase_record.purchase_batch_check');

    Route::get('user/user_roles', [UsersController::class, 'userRoles'])->name('users.user_roles');

});
Route::get('stock/goods_skus', [GoodsSkusController::class, 'stockNum'])->middleware('auth:api');
Route::get('goods/filter/{title}', [GoodsCombinationController::class, 'goodsSkus'])->middleware('auth:api');
// 登录
Route::post('/auth/login', [LoginController::class, 'login'])->name('auth.login');

// 菜单
Route::resource('menus', 'Menu\MenusController', ['only' => ['index',
//        'store', 'show', 'update', 'destroy'
]])->middleware('auth:api');

// 获取平台列表
Route::get('shop_platforms', [ShopsController::class, 'getPlatList'])->name('plat.list')->middleware('auth:api');

// 团购商品添加列表
Route::get('goodsList', [GroupsController::class, 'goodsList'])->name('goods.list')->middleware('auth:api');
Route::get('groupGoods', [GroupsController::class, 'getGoods'])->name('group.get_goods')->middleware('auth:api');
Route::post('groupGoods', [GroupsController::class, 'addGroupGoods'])->name('group.add_goods')->middleware('auth:api');
Route::get('addGoods', [GroupsController::class, 'addGoods'])->name('group.add_goods')->middleware('auth:api');

// 妙选商城数据推送
Route::post('business', [ShopsController::class, 'business'])->name('shop.put.business');

// 盘点导入
Route::post('inventory/goods_skus', [GoodsSkusController::class, 'inventoryImport'])->name('goods_sku.inventory');
// 上新导入
Route::post('new/set/goods_skus', [GoodsSkusController::class, 'newSetImport'])->name('goods_sku.new_set');
// 商品货架导入
Route::post('goods_sku_location', [GoodsSkuLocationController::class, 'import'])->name('goods_sku_location.import');
// 组合商品导入
Route::post('combination/goods', [GoodsCombinationController::class, 'import'])->name('goods_combination.import');
// 今日价格导入
Route::post('today/price', [BusinessGoodsSkusController::class, 'todayPriceImport'])->name('plat.today_price.import');
// 文件上传
Route::post('upload', [UploadController::class, 'store'])->name('upload.file');
// 商品列表
Route::get('goodsSkusList', [GoodsSkusController::class, 'goodsSkusList'])->name('goods_sku.list_for_goods_sku');

// 采购导入
Route::post('purchase_record/purchase_import', [PurchaseRecordController::class, 'purchaseImport'])->name('supplier.purchase_record.purchase_import');

//报损导入
Route::post('supplier/loss_record/loss_import', [LossRecordController::class, 'lossImport'])->name('supplier.loss_record.loss_import');

//新版盘点导入
Route::post('supplier/daily_stock_record/inventory_import', [DailyStockRecordController::class, 'inventoryImport'])->name('supplier.daily_stock_record.inventory_import');

//在售库存导入
Route::post('goods_skus/saleStockImport', [GoodsSkusController::class, 'saleStockImport'])->name('goods_skus.saleStockImport');

