6
0
Fork 0

admin store/stock-total filter tag_id

base
panliang 2023-08-19 23:38:09 +08:00
parent 0f45a07105
commit 1d606a6049
4 changed files with 45 additions and 3 deletions

View File

@ -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);
});

View File

@ -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')) {

View File

@ -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'),
];
}
}

View File

@ -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,
];
}
}