From 5c2c8cf5d036502e5c1c1759a173ab1fdc2da710 Mon Sep 17 00:00:00 2001
From: lanzu_qsy <334039090@qq.com>
Date: Mon, 31 Aug 2020 17:47:09 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=95=86=E5=8D=A1?=
=?UTF-8?q?=E7=89=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Controllers/HomeController.php | 16 +++++----
.../Examples/Community/TotalAmount.php | 15 +++++++--
.../Metrics/Examples/ServiceCard/TotalMm.php | 33 +++++++++++++++++++
.../Examples/ServiceCard/TotalStore.php | 27 +++++++++++++++
app/Admin/routes.php | 2 ++
app/Models/LanzuMmInfo.php | 18 ++++++++++
6 files changed, 101 insertions(+), 10 deletions(-)
create mode 100644 app/Admin/Metrics/Examples/ServiceCard/TotalMm.php
create mode 100644 app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php
index 72eba39..50fea62 100644
--- a/app/Admin/Controllers/HomeController.php
+++ b/app/Admin/Controllers/HomeController.php
@@ -58,11 +58,12 @@ class HomeController extends Controller
return $content->header('控制面板')
->description('欢迎回到懒族后台')
->body(function (Row $row) {
- $row->column(6, function (Column $column) {
+ $row->column(4, function (Column $column) {
+ $column->row(new Examples\Community\TotalAmount(Admin::user()->id,1));
});
- $row->column(6, function (Column $column) {
-
+ $row->column(4, function (Column $column) {
+ $column->row(new Examples\ServiceCard\TotalMm());
});
});
}
@@ -72,11 +73,12 @@ class HomeController extends Controller
return $content->header('控制面板')
->description('欢迎回到懒族后台')
->body(function (Row $row) {
- $row->column(6, function (Column $column) {
+ $row->column(3, function (Column $column) {
+ $column->row(new Examples\Community\TotalAmount(Admin::user()->id,2));
});
- $row->column(6, function (Column $column) {
-
+ $row->column(3, function (Column $column) {
+ $column->row(new Examples\ServiceCard\TotalStore());
});
});
}
@@ -106,7 +108,7 @@ class HomeController extends Controller
});
$row->column(4, function (Column $column) {
- $column->row(new Examples\Community\TotalAmount());
+ $column->row(new Examples\Community\TotalAmount(Admin::user()->id,3));
});
});
}
diff --git a/app/Admin/Metrics/Examples/Community/TotalAmount.php b/app/Admin/Metrics/Examples/Community/TotalAmount.php
index 3ad5420..7f79c75 100644
--- a/app/Admin/Metrics/Examples/Community/TotalAmount.php
+++ b/app/Admin/Metrics/Examples/Community/TotalAmount.php
@@ -3,16 +3,25 @@
namespace App\Admin\Metrics\Examples\Community;
use App\Models\LanzuUserBalance;
-use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Metrics\Card;
class TotalAmount extends Card
{
+ protected $uid;
+ protected $uType;
+
+ public function __construct($uid, $uType)
+ {
+ $this->uid = $uid;
+ $this->uType =$uType;
+ parent::__construct('可提现金额(元)');
+ }
+
protected function init()
{
parent::init();
- $this->title = '可提现金额';
- $this->content(LanzuUserBalance::getBalance(Admin::user()->id,3));
+ $this->content(LanzuUserBalance::getBalance($this->uid, $this->uType));
+
}
/**
diff --git a/app/Admin/Metrics/Examples/ServiceCard/TotalMm.php b/app/Admin/Metrics/Examples/ServiceCard/TotalMm.php
new file mode 100644
index 0000000..6bc80ea
--- /dev/null
+++ b/app/Admin/Metrics/Examples/ServiceCard/TotalMm.php
@@ -0,0 +1,33 @@
+title = '市场经理数';
+
+ $this->content(LanzuMmInfo::getMmInfoCount());
+ }
+
+ /**
+ * 渲染卡片内容
+ * @return string
+ */
+ public function renderContent()
+ {
+ $content = parent::renderContent();
+ return <<
+
{$content}
+
+HTML;
+ }
+}
diff --git a/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
new file mode 100644
index 0000000..f3d01d4
--- /dev/null
+++ b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
@@ -0,0 +1,27 @@
+title = '商户数';
+ $this->content(222);
+ }
+
+ public function renderContent()
+ {
+ $content = parent::renderContent();
+ return <<
+ {$content}
+
+HTML;
+ }
+}
diff --git a/app/Admin/routes.php b/app/Admin/routes.php
index defe207..a6102e8 100644
--- a/app/Admin/routes.php
+++ b/app/Admin/routes.php
@@ -43,4 +43,6 @@ Route::group([
$router->any('/api/stores', 'LanzuServiceSpeakerController@getStores');
//统计店铺新增用户
$router->resource('/storeUserReport', 'StoreUserReportController');
+
+ $router->any('/test', 'Test@test');
});
diff --git a/app/Models/LanzuMmInfo.php b/app/Models/LanzuMmInfo.php
index 748f29d..aeae4a5 100644
--- a/app/Models/LanzuMmInfo.php
+++ b/app/Models/LanzuMmInfo.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use Dcat\Admin\Admin;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
@@ -16,4 +17,21 @@ class LanzuMmInfo extends Model
{
return $this->hasOne('\App\Models\LanzuMmWithdraw','mm_id','id');
}
+
+ public static function getMmInfoCount()
+ {
+ $adu = Admin::user();
+ if ($adu->isRole('lanzu_mp')){
+ $mpInfo = LanzuMpInfo::where('admin_user_id',$adu->id)->select('id')->first();
+ if ($mpInfo){
+ $ids = ImsCjdcMarket::where('mp_id',$mpInfo->id)->get()->pluck('id');
+ $count = self::whereIn('market_id',$ids)->count();
+ return $count;
+ }else{
+ return 0;
+ }
+ }else{
+ return self::count();
+ }
+ }
}
From fed490fa4c55ff560d99512e79324ef8152789da Mon Sep 17 00:00:00 2001
From: lanzu_qsy <334039090@qq.com>
Date: Mon, 31 Aug 2020 20:38:57 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E5=95=86=E5=8D=A1=E7=89=87=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/ImsCjdcStoreController.php | 2 +-
.../Controllers/LanzuMmInfoController.php | 2 +-
.../Controllers/LanzuMmWithdrawController.php | 2 +-
.../Examples/ServiceCard/TotalStore.php | 18 +++++++++++++++++-
app/Models/ImsCjdcStore.php | 4 ++--
app/Models/LanzuStore.php | 2 +-
6 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/app/Admin/Controllers/ImsCjdcStoreController.php b/app/Admin/Controllers/ImsCjdcStoreController.php
index f51fb87..21f2182 100644
--- a/app/Admin/Controllers/ImsCjdcStoreController.php
+++ b/app/Admin/Controllers/ImsCjdcStoreController.php
@@ -27,7 +27,7 @@ class ImsCjdcStoreController extends AdminController
if ($user->isRole('lanzu_mm')) {
//如果登陆角色为市场经理,获取市场经理id
$mm = LanzuMmInfo::where(['admin_user_id' => $user->id])->first();
- $builder = modelStore::where(['mm_user_id' => $mm->id]);
+ $builder = modelStore::with('market')->where(['mm_user_id' => $mm->id]);
}
return Grid::make($builder, function (Grid $grid) {
$grid->id->sortable();
diff --git a/app/Admin/Controllers/LanzuMmInfoController.php b/app/Admin/Controllers/LanzuMmInfoController.php
index da6a4ea..5c0cb1b 100644
--- a/app/Admin/Controllers/LanzuMmInfoController.php
+++ b/app/Admin/Controllers/LanzuMmInfoController.php
@@ -50,7 +50,7 @@ class LanzuMmInfoController extends AdminController
return $market->name;
});
$grid->column('可提现金额')->display(function () {
- return MpBalance::getBalance($this->user_id, 0);
+ return MpBalance::getBalance($this->admin_user_id, 2);
});
$grid->id_frond->image('', 50, 50);
$grid->id_back->image('', 50, 50);
diff --git a/app/Admin/Controllers/LanzuMmWithdrawController.php b/app/Admin/Controllers/LanzuMmWithdrawController.php
index 452fca1..6053e40 100644
--- a/app/Admin/Controllers/LanzuMmWithdrawController.php
+++ b/app/Admin/Controllers/LanzuMmWithdrawController.php
@@ -68,7 +68,7 @@ class LanzuMmWithdrawController extends AdminController
$grid->money;
$grid->status('提现状态')->using([-1 => '拒绝', 0 => '审核中', 1 => '通过'])
->label([-1 => 'danger', 0 => 'default', 1 => 'success']);
- $grid->is_pay('是否到账')->using([0 => '否', 1 => '是']);
+ $grid->is_pay('是否到账')->using([0 => '否', 1 => '是'])->label([0 => 'danger', 1 => 'success']);
$grid->created_at('提现时间')->display(function ($time) {
return date('Y-m-d H:i', $time);
});
diff --git a/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
index f3d01d4..b3a8714 100644
--- a/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
+++ b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
@@ -4,15 +4,31 @@
namespace App\Admin\Metrics\Examples\ServiceCard;
+use App\Models\LanzuMmInfo;
+use App\Models\LanzuStore;
+use Dcat\Admin\Admin;
use Dcat\Admin\Widgets\Metrics\Card;
class TotalStore extends Card
{
+
protected function init()
{
parent::init();
$this->title = '商户数';
- $this->content(222);
+ $aud = Admin::user();
+ $count = 0;
+ if ($aud->isRole('lanzu_mm')){
+ $mm = LanzuMmInfo::where('admin_user_id',$aud->id)->first();
+ if ($mm){
+ $count = LanzuStore::where('mm_user_id',$mm->id)->count();
+ }
+ }elseif($aud->isRole('lanzu_mp')){
+ $count = 0;
+ }else{
+ $count = LanzuStore::count();
+ }
+ $this->content($count);
}
public function renderContent()
diff --git a/app/Models/ImsCjdcStore.php b/app/Models/ImsCjdcStore.php
index 2fa7a25..f25750f 100644
--- a/app/Models/ImsCjdcStore.php
+++ b/app/Models/ImsCjdcStore.php
@@ -10,12 +10,12 @@ use App\Models\StoreAccount;
class ImsCjdcStore extends Model
{
use HasDateTimeFormatter;
- protected $table = 'ims_cjdc_store';
+ protected $table = 'lanzu_store';
public $timestamps = false;
public function market(){
return $this->hasOne('\App\Models\ImsCjdcMarket','id','market_id');
}
-
+
public function storeAccount(){
return $this->hasMany(StoreAccount::class,'store_id','id');
}
diff --git a/app/Models/LanzuStore.php b/app/Models/LanzuStore.php
index 43a0aaf..b3fa664 100644
--- a/app/Models/LanzuStore.php
+++ b/app/Models/LanzuStore.php
@@ -9,6 +9,6 @@ use Illuminate\Database\Eloquent\Model;
class LanzuStore extends Model
{
use HasDateTimeFormatter;
- protected $table = 'ims_cjdc_store';
+ protected $table = 'lanzu_store';
protected $dateFormat = 'U';
}
From 76d9fe54283403a8e34c6e58d2e2729596a88a7d Mon Sep 17 00:00:00 2001
From: lanzu_qsy <334039090@qq.com>
Date: Tue, 1 Sep 2020 09:36:45 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E5=8D=A1=E7=89=87=E7=BB=9F=E8=AE=A1?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9C=8D=E5=8A=A1=E5=95=86=E6=95=B0=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Controllers/HomeController.php | 5 +++
.../Metrics/Examples/ServiceCard/TotalMp.php | 32 +++++++++++++++++++
2 files changed, 37 insertions(+)
create mode 100644 app/Admin/Metrics/Examples/ServiceCard/TotalMp.php
diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php
index 50fea62..12bd86b 100644
--- a/app/Admin/Controllers/HomeController.php
+++ b/app/Admin/Controllers/HomeController.php
@@ -88,6 +88,10 @@ class HomeController extends Controller
return $content->header('控制面板')
->description('欢迎回到懒族后台')
->body(function (Row $row) {
+ $row->column(4, function (Column $column) {
+ $column->row(new Examples\ServiceCard\TotalMp());
+ });
+
$row->column(4, function (Column $column) {
$column->row(new Examples\Community\TotalCommunity());
});
@@ -95,6 +99,7 @@ class HomeController extends Controller
$row->column(4, function (Column $column) {
$column->row(new Examples\Community\TotalUser());
});
+
});
}
diff --git a/app/Admin/Metrics/Examples/ServiceCard/TotalMp.php b/app/Admin/Metrics/Examples/ServiceCard/TotalMp.php
new file mode 100644
index 0000000..c8b2638
--- /dev/null
+++ b/app/Admin/Metrics/Examples/ServiceCard/TotalMp.php
@@ -0,0 +1,32 @@
+title = '服务商量数';
+ $this->content(LanzuMpInfo::count());
+ }
+
+ /**
+ * 渲染卡片内容
+ * @return string
+ */
+ public function renderContent()
+ {
+ $content = parent::renderContent();
+ return <<
+ {$content}
+
+HTML;
+ }
+}
From eddb197a7181856c8c9a1dc9acb825658b02316b Mon Sep 17 00:00:00 2001
From: lanzu_qsy <334039090@qq.com>
Date: Tue, 1 Sep 2020 14:32:04 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=95=86=E6=B5=81?=
=?UTF-8?q?=E6=B0=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/ImsCjdcStoreController.php | 5 ++++-
app/Admin/Controllers/LanzuFinancialRecord.php | 17 +++++++++--------
.../Metrics/Examples/ServiceCard/TotalStore.php | 2 +-
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/app/Admin/Controllers/ImsCjdcStoreController.php b/app/Admin/Controllers/ImsCjdcStoreController.php
index 21f2182..f9a4145 100644
--- a/app/Admin/Controllers/ImsCjdcStoreController.php
+++ b/app/Admin/Controllers/ImsCjdcStoreController.php
@@ -29,7 +29,7 @@ class ImsCjdcStoreController extends AdminController
$mm = LanzuMmInfo::where(['admin_user_id' => $user->id])->first();
$builder = modelStore::with('market')->where(['mm_user_id' => $mm->id]);
}
- return Grid::make($builder, function (Grid $grid) {
+ return Grid::make($builder, function (Grid $grid) use ($user) {
$grid->id->sortable();
$grid->name;
$grid->column('market.name', '所属市场');
@@ -39,6 +39,9 @@ class ImsCjdcStoreController extends AdminController
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableCreateButton();
+ if ($user->isRole('lanzu_mm')){
+ $grid->showCreateButton();
+ }
$grid->filter(function (Grid\Filter $filter) {
$filter->like('name')->placeholder('输入店铺名称');
$filter->equal('tel')->placeholder('输入电话');
diff --git a/app/Admin/Controllers/LanzuFinancialRecord.php b/app/Admin/Controllers/LanzuFinancialRecord.php
index 9743139..bd4be12 100644
--- a/app/Admin/Controllers/LanzuFinancialRecord.php
+++ b/app/Admin/Controllers/LanzuFinancialRecord.php
@@ -19,21 +19,22 @@ class LanzuFinancialRecord extends AdminController
protected function grid()
{
$adu = Admin::user();
+ $type = \Request::get('type');
$builder = new FinancialRecord0();
- $builder = $builder::where('user_type',4);
+ $builder = $builder::where('user_type',$type);
- if ($adu->isRole('lanzu_cs')) {
+ if ($adu->isRole('lanzu_cs')||$adu->isRole('lanzu_mp')||$adu->isRole('lanzu_mm')) {
$fr = FinancialRecord::getFinancialRecordModel($adu->id);
- $builder = $fr->where('user_id',$adu->id)->where('user_type',4);
- } else {
+ $builder = $fr->where('user_id',$adu->id)->where('user_type',$type);
+ }else {
$param = \Request::get('user_id');
if ($param) {
$fr = FinancialRecord::getFinancialRecordModel($param);
- $builder = $fr::where('user_type',4);
+ $builder = $fr::where('user_type',$type);
}
}
- return Grid::make($builder, function (Grid $grid) use ($adu) {
+ return Grid::make($builder, function (Grid $grid) use ($adu,$type) {
$grid->id;
$grid->user_id('用户')->display(function () {
if ($this->user_type == 1) {
@@ -48,9 +49,9 @@ class LanzuFinancialRecord extends AdminController
$grid->created_at('创建时间')->display(function ($time) {
return date('Y-m-d H:i', $time);
});
- $grid->filter(function (Grid\Filter $filter) use ($adu) {
+ $grid->filter(function (Grid\Filter $filter) use ($adu,$type) {
$filter->equal('id');
- if (!$adu->isRole('lanzu_cs')) {
+ if (!$adu->isRole('lanzu_cs')&&$type==4) {
$filter->equal('user_id', '社区站点')->select(LanzuCsInfo::selectCsInfo());
}
diff --git a/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
index b3a8714..2555d43 100644
--- a/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
+++ b/app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
@@ -21,7 +21,7 @@ class TotalStore extends Card
if ($aud->isRole('lanzu_mm')){
$mm = LanzuMmInfo::where('admin_user_id',$aud->id)->first();
if ($mm){
- $count = LanzuStore::where('mm_user_id',$mm->id)->count();
+ $count = LanzuStore::where('mm_user_id',$mm->user_id)->count();
}
}elseif($aud->isRole('lanzu_mp')){
$count = 0;