generated from liutk/owl-admin-base
Merge branch 'main' of https://gitea.hmily.club/pdkj/store-manage into main
commit
c03698fc0b
|
|
@ -120,7 +120,6 @@ class PlanController extends AdminController
|
||||||
->source(admin_url('api/keywords/tree-list?parent_key=store_category'))
|
->source(admin_url('api/keywords/tree-list?parent_key=store_category'))
|
||||||
->labelField('name')
|
->labelField('name')
|
||||||
->valueField('key')
|
->valueField('key')
|
||||||
->onlyLeaf(true)
|
|
||||||
->value('${planable.store_category_id}')
|
->value('${planable.store_category_id}')
|
||||||
->required()
|
->required()
|
||||||
->visibleOn('${planable_type == "'.$planableTypePerformance.'"}'),
|
->visibleOn('${planable_type == "'.$planableTypePerformance.'"}'),
|
||||||
|
|
|
||||||
|
|
@ -213,11 +213,17 @@ class PlanService extends BaseService
|
||||||
// 任务结束时间
|
// 任务结束时间
|
||||||
$endAt = $startAt->copy()->endOfMonth();
|
$endAt = $startAt->copy()->endOfMonth();
|
||||||
|
|
||||||
$input = [
|
// 门店分类IDs
|
||||||
'category_id' => $plan->planable->store_category_id,
|
$categoryIds = value(function ($id) {
|
||||||
'level_id' => $plan->planable->store_level_id,
|
$ids = collect();
|
||||||
];
|
if ($parent = Keyword::where('key', $id)->first()) {
|
||||||
|
/** @var \Illuminate\Support\Collection */
|
||||||
|
$ids = Keyword::where('path', 'like', "%-{$parent->id}-%")->pluck('key');
|
||||||
|
}
|
||||||
|
return $ids->push($id);
|
||||||
|
}, $plan->planable->store_category_id);
|
||||||
|
|
||||||
|
// 门店业绩统计
|
||||||
$aggregates = Ledger::select(['store_id', DB::raw('SUM(`sales`) as sales')])
|
$aggregates = Ledger::select(['store_id', DB::raw('SUM(`sales`) as sales')])
|
||||||
->whereBetween('date', [$startAt->format('Y-m-d'), $endAt->format('Y-m-d')])
|
->whereBetween('date', [$startAt->format('Y-m-d'), $endAt->format('Y-m-d')])
|
||||||
->groupBy('store_id')
|
->groupBy('store_id')
|
||||||
|
|
@ -225,7 +231,9 @@ class PlanService extends BaseService
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Collection */
|
/** @var \Illuminate\Database\Eloquent\Collection */
|
||||||
$stores = Store::filter($input, StoreFilter::class)->get(['id', 'master_id']);
|
$stores = Store::filter(['level_id' => $plan->planable->store_level_id], StoreFilter::class)
|
||||||
|
->whereIn('category_id', $categoryIds)
|
||||||
|
->get(['id', 'master_id']);
|
||||||
|
|
||||||
foreach ($stores as $store) {
|
foreach ($stores as $store) {
|
||||||
$taskable = TaskPerformance::create([
|
$taskable = TaskPerformance::create([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue