2021-11-07 开源测试版 2.4.0

This commit is contained in:
2021-11-07 15:43:36 +08:00
parent a9e17b5af7
commit 672cc966db
24 changed files with 922 additions and 1396 deletions
@@ -2,12 +2,13 @@
use DB;
use Request;
use Gdoo\Index\Services\InfoService;
use Gdoo\Index\Controllers\DefaultController;
class WidgetController extends DefaultController
{
public $permission = ['birthday'];
public $permission = ['birthday', 'customerCount', 'customerContactCount'];
// 生日提醒
public function birthday()
@@ -46,4 +47,71 @@ class WidgetController extends DefaultController
}
return $this->render();
}
/**
* 客户(个)
*/
public function customerCount()
{
$config = InfoService::getInfo('customer');
$model = DB::table('customer')->whereRaw('('.$config['sql'].')');
$model2 = DB::table('customer')->whereRaw('('.$config['sql2'].')');
$region = regionCustomer();
if ($region['authorise']) {
foreach ($region['whereIn'] as $key => $where) {
$model->whereIn($key, $where);
$model2->whereIn($key, $where);
}
}
$count = $model->count();
$count2 = $model2->count();
$rate = 0;
if ($count2 > 0) {
$rate = ($count - $count2) / $count2 * 100;
$rate = number_format($rate, 2);
}
$res = [
'count' => $count,
'count2' => $count2,
'rate' => $rate,
];
return $this->render([
'dates' => $config['dates'],
'info' => $config['info'],
'res' => $res,
]);
}
/**
* 客户联系人(个)
*/
public function customerContactCount()
{
$config = InfoService::getInfo('customer_contact');
$model = DB::table('customer_contact')->whereRaw('('.$config['sql'].')');
$model2 = DB::table('customer_contact')->whereRaw('('.$config['sql2'].')');
$count = $model->count();
$count2 = $model2->count();
$rate = 0;
if ($count2 > 0) {
$rate = ($count - $count2) / $count2 * 100;
$rate = number_format($rate, 2);
}
$res = [
'count' => $count,
'count2' => $count2,
'rate' => $rate,
];
return $this->render([
'dates' => $config['dates'],
'info' => $config['info'],
'res' => $res,
]);
}
}
+12
View File
@@ -52,6 +52,18 @@ return [
'url' => 'customer/widget/birthday',
'more_url' => 'customer/customer/birthday',
],
'info_customer_count' => [
'name' => '客户',
'type' => 2,
'url' => 'customer/widget/customerCount',
'more_url' => 'customer/customer/index',
],
'info_customer_contact_count' => [
'name' => '客户联系人',
'type' => 2,
'url' => 'customer/widget/customerContactCount',
'more_url' => 'customer/contact/index',
],
],
"listens" => [
'customer' => 'Gdoo\Customer\Hooks\CustomerHook',
@@ -0,0 +1,15 @@
<div class="panel panel-shadow info-skin1">
<div class="info-l hidden-xs" style="background-color:{{$info['color']}}">
<i class="fa fa-2x {{$info['icon']}}"></i>
</div>
<div class="info-c">
<div class="info-name">{{$info['name']}}</div>
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
<div class="text-info info-item" data-id="{{$info['id']}}" data-more_url="{{$info['more_url']}}">{{$res['count']}}</div>
</a>
</div>
<div class="info-r">
<div>比{{$dates[$info['params']['date']]}}</div>
<div class="rate @if($res['rate'] > 100) red @endif">{{$res['rate']}}%</div>
</div>
</div>
@@ -0,0 +1,15 @@
<div class="panel panel-shadow info-skin1">
<div class="info-l hidden-xs" style="background-color:{{$info['color']}}">
<i class="fa fa-2x {{$info['icon']}}"></i>
</div>
<div class="info-c">
<div class="info-name">{{$info['name']}}</div>
<a href="javascript:;" data-toggle="addtab" data-url="{{$info['more_url']}}" data-id="{{str_replace(['/', '?', '='], ['_', '_', '_'], $info['more_url'])}}" data-name="{{$info['name']}}">
<div class="text-info info-item" data-id="{{$info['id']}}" data-more_url="{{$info['more_url']}}">{{$res['count']}}</div>
</a>
</div>
<div class="info-r">
<div>比{{$dates[$info['params']['date']]}}</div>
<div class="rate @if($res['rate'] > 100) red @endif">{{$res['rate']}}%</div>
</div>
</div>