diff --git a/app/Admin/Controllers/Store/StockTotalController.php b/app/Admin/Controllers/Store/StockTotalController.php index f0724476..9d1cd2d8 100644 --- a/app/Admin/Controllers/Store/StockTotalController.php +++ b/app/Admin/Controllers/Store/StockTotalController.php @@ -47,6 +47,8 @@ class StockTotalController extends AdminController $filter->equal('store_id', '门店')->select(Store::pluck('title', 'id'))->width(3); $filter->equal('category_id', '分类')->select(ProductCategory::selectOptions())->width(3); $filter->equal('product_name', '商品')->width(3); + $filter->equal('tag_id', '类目')->select(StockLog::tags()->pluck('name', 'id'))->width(3); + // $filter->in('tag_id', '类目')->multipleSelect(StockLog::tags()->pluck('name', 'id'))->width(3); $filter->between('date', '时间')->date()->width(6); }); diff --git a/app/Admin/Repositories/StoreTockRepository.php b/app/Admin/Repositories/StoreTockRepository.php index aedeceaf..9e937b78 100644 --- a/app/Admin/Repositories/StoreTockRepository.php +++ b/app/Admin/Repositories/StoreTockRepository.php @@ -7,6 +7,7 @@ use App\Models\Store\{StockLog, ProductSku}; use Dcat\Admin\Repositories\Repository; use Illuminate\Support\Facades\DB; use Carbon\Carbon; +use Illuminate\Support\Arr; class StoreTockRepository extends Repository { @@ -70,17 +71,25 @@ class StoreTockRepository extends Repository 'productSku.category', 'stockLogs' => function ($q) use ($model) { $q->select('id', 'product_sku_id', DB::raw('abs(`amount`) as `amount`'), 'tag_id'); - if ($start = $model->filter()->input('date.start')) { + $filter = $model->filter(); + if ($start = $filter->input('date.start')) { $start = Carbon::createFromFormat('Y-m-d', $start)->startOfDay(); $q->where('created_at', '>=', $start); } - if ($end = $model->filter()->input('date.end')) { + if ($end = $filter->input('date.end')) { $end = Carbon::createFromFormat('Y-m-d', $end)->endOfDay(); $q->where('created_at', '<=', $end); } - if ($store_id = $model->filter()->input('store_id')) { + if ($store_id = $filter->input('store_id')) { $q->where('store_id', $store_id); } + // $tag_ids = data_get($filter->filters(), 3); + // if ($tag_ids && $tag_ids->getValue()) { + // $q->whereIn('tag_id', $tag_ids->getValue()); + // } + if ($tag_id = $filter->input('tag_id')) { + $q->where('tag_id', $tag_id); + } }, 'stockLog' => function ($q) use ($model) { if ($store_id = $model->filter()->input('store_id')) { diff --git a/app/Endpoint/Api/Http/Controllers/AliOssController.php b/app/Endpoint/Api/Http/Controllers/AliOssController.php index 50a6691b..65d33a62 100644 --- a/app/Endpoint/Api/Http/Controllers/AliOssController.php +++ b/app/Endpoint/Api/Http/Controllers/AliOssController.php @@ -20,4 +20,21 @@ class AliOssController extends Controller 'domain'=>config('filesystems.disks.aliyun.domain'), ], $aliStsService->createSts($request->user()?->phone))); } + + public function signature(Request $request, AliStsService $aliStsService) + { + $request->validate([ + 'filename' => 'required' + ]); + $path = $request->input('path', 'uploads').'/'.date('Y-m-d'); + + $data = [ + "accessid" => "", + "host" => "https://post-test.oss-cn-hangzhou.aliyuncs.com", + "policy" => "eyJleHBpcmF0aW9uIjoiMjAxNS0xMS0wNVQyMDoyMzoyM1oiLCJjxb25kaXRpb25zIjpbWyJjcb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDQ4NTc2MDAwXSxbInN0YXJ0cy13aXRoIiwiJGtleSIsInVzZXItZGlyXC8i****", + "signature" => "VsxOcOudx******z93CLaXPz+4s=", + "expire" => 1446727949, + "dir" => $path.'/'.$request->input('filename'), + ]; + } } diff --git a/app/Services/AliStsService.php b/app/Services/AliStsService.php index 0f07d0b6..00bf5758 100644 --- a/app/Services/AliStsService.php +++ b/app/Services/AliStsService.php @@ -66,4 +66,18 @@ class AliStsService } return []; } + + public function signatureUpload($file) + { + $config = config('filesystems.disks.aliyun'); + $host = (data_get($config, 'use_ssl') ? 'https://' : 'http://') . data_get($config, 'bucket') . '.' . data_get($config, 'endpoint'); + $data = [ + "accessid" => $this->accessId, + "host" => $host, + "policy" => "eyJleHBpcmF0aW9uIjoiMjAxNS0xMS0wNVQyMDoyMzoyM1oiLCJjxb25kaXRpb25zIjpbWyJjcb250ZW50LWxlbmd0aC1yYW5nZSIsMCwxMDQ4NTc2MDAwXSxbInN0YXJ0cy13aXRoIiwiJGtleSIsInVzZXItZGlyXC8i****", + "signature" => "VsxOcOudx******z93CLaXPz+4s=", + "expire" => 1446727949, + "dir" => $file, + ]; + } }