From 372158ed763865d6bd70733b696e214f05eda5b9 Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Thu, 3 Mar 2022 16:56:24 +0800
Subject: [PATCH 01/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Renderable/UserSalesValueLogSimpleTable.php | 13 +++++++++----
app/Services/AfterSaleService.php | 10 +++++++---
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/app/Admin/Renderable/UserSalesValueLogSimpleTable.php b/app/Admin/Renderable/UserSalesValueLogSimpleTable.php
index 5d44c41e..b4450197 100644
--- a/app/Admin/Renderable/UserSalesValueLogSimpleTable.php
+++ b/app/Admin/Renderable/UserSalesValueLogSimpleTable.php
@@ -5,6 +5,7 @@ namespace App\Admin\Renderable;
use App\Models\SalesValueLog;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
+use Illuminate\Support\Facades\Request;
class UserSalesValueLogSimpleTable extends LazyRenderable
{
@@ -14,6 +15,12 @@ class UserSalesValueLogSimpleTable extends LazyRenderable
$builder = SalesValueLog::query();
return Grid::make($builder, function (Grid $grid) use ($userId) {
$grid->model()->where('user_id', $userId);
+ // $start = now()->subDays(30)->toDateString();
+ // $end = now()->toDateString();
+ // $timeZone = Request::get('app-admin-renderable-usersalesvaluelogsimpletable_created_at', []);
+ // if (empty($timeZone)) {
+ // $grid->model()->whereBetween('created_at', [$start, $end]);
+ // }
$grid->column('type')->using([
1=>'个人',
2=>'团队',
@@ -46,10 +53,8 @@ class UserSalesValueLogSimpleTable extends LazyRenderable
return "
个人消费值:".$salesValue1.'
团队消费值:'.$salesValue2.'
';
});
$grid->filter(function (Grid\Filter $filter) {
- $filter->between('created_at', '时间')->date()->default([
- 'start'=>now()->subDays(30)->toDateString(),
- 'end'=>now()->toDateString(),
- ]);
+ $filter->expand(false);
+ $filter->between('created_at', '时间')->date();
});
});
}
diff --git a/app/Services/AfterSaleService.php b/app/Services/AfterSaleService.php
index f3eca310..d8058d96 100644
--- a/app/Services/AfterSaleService.php
+++ b/app/Services/AfterSaleService.php
@@ -38,6 +38,10 @@ class AfterSaleService
throw new BizException('赠品不能发起退款/退款退货操作');
}
+ if ($orderProduct->order->total_amount == 0 && in_array($params['type'], [AfterSale::TYPE_REFUND, Aftersale::TYPE_REFUND_AND_RETURN])) {
+ throw new BizException('订单支付金额为0的商品不能发起退款/退款退货操作');
+ }
+
$amount = ($num == $orderProduct->quantity) ? $orderProduct->total_amount : bcmul(bcdiv($orderProduct->total_amount, $orderProduct->quantity), $num);
if ($amount == 0 && in_array($params['type'], [AfterSale::TYPE_REFUND])) {
@@ -275,7 +279,7 @@ class AfterSaleService
* @param string $remarks
* @return void
*/
- public function shippingFail(AfterSale $afterSale, $remarks ='仓库验收未通过')
+ public function shippingFail(AfterSale $afterSale, $remarks = '仓库验收未通过')
{
if ($this->isWaitShipping($afterSale)) {
$afterSale->update([
@@ -324,7 +328,7 @@ class AfterSaleService
* @param string $remarks
* @return void
*/
- public function shipping(AfterSale $afterSale, $remarks ='仓库验收通过')
+ public function shipping(AfterSale $afterSale, $remarks = '仓库验收通过')
{
if ($this->isWaitShipping($afterSale)) {
$afterSale->update([
@@ -346,7 +350,7 @@ class AfterSaleService
*
* @return void
*/
- public function finance(AfterSale $afterSale, $remarks ='退款成功')
+ public function finance(AfterSale $afterSale, $remarks = '退款成功')
{
if ($this->isWaitFinance($afterSale)) {
$order = $afterSale->order;
From 1777186ba616941fca78038e7d70712599fea878 Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Thu, 3 Mar 2022 16:57:59 +0800
Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=91=E8=B5=B7?=
=?UTF-8?q?=E5=94=AE=E5=90=8E=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Services/AfterSaleService.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Services/AfterSaleService.php b/app/Services/AfterSaleService.php
index d8058d96..ca6319e9 100644
--- a/app/Services/AfterSaleService.php
+++ b/app/Services/AfterSaleService.php
@@ -38,8 +38,8 @@ class AfterSaleService
throw new BizException('赠品不能发起退款/退款退货操作');
}
- if ($orderProduct->order->total_amount == 0 && in_array($params['type'], [AfterSale::TYPE_REFUND, Aftersale::TYPE_REFUND_AND_RETURN])) {
- throw new BizException('订单支付金额为0的商品不能发起退款/退款退货操作');
+ if ($orderProduct->order->is_change && in_array($params['type'], [AfterSale::TYPE_REFUND, Aftersale::TYPE_REFUND_AND_RETURN])) {
+ throw new BizException('换货后的商品不能发起退款/退款退货操作');
}
$amount = ($num == $orderProduct->quantity) ? $orderProduct->total_amount : bcmul(bcdiv($orderProduct->total_amount, $orderProduct->quantity), $num);
From 0791f685e2dbcb4e4c3b422e64ee1331032f5056 Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Fri, 4 Mar 2022 17:52:54 +0800
Subject: [PATCH 03/10] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=80=81=E9=85=8D?=
=?UTF-8?q?=E9=A2=9D=E6=89=A3=E5=87=8F=E6=91=B80=E6=93=8D=E4=BD=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Services/QuotaV1Service.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/Services/QuotaV1Service.php b/app/Services/QuotaV1Service.php
index afab09a4..1e905b5e 100644
--- a/app/Services/QuotaV1Service.php
+++ b/app/Services/QuotaV1Service.php
@@ -11,13 +11,13 @@ class QuotaV1Service
* 变老配额余额
*
* @param \App\Models\User $user
- * @param int $changeBalance
+ * @param float $changeBalance
* @param int $action
* @param string|null $remarks
* @param mixed $loggable
* @return void
*/
- public function changeBalance(User $user, int $changeBalance, int $action, ?string $remarks = null, $loggable = null)
+ public function changeBalance(User $user, float $changeBalance, int $action, ?string $remarks = null, $loggable = null)
{
if ($changeBalance === 0) {
return;
From a557725c912389c8420172926cc75b0dd29204eb Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Mon, 7 Mar 2022 09:47:58 +0800
Subject: [PATCH 04/10] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8E=E5=8F=B0?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=81=E9=85=8D=E9=A2=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Forms/QuotaV1Deduction.php | 2 +-
app/Admin/Forms/QuotaV1Recharge.php | 2 +-
app/Models/QuotaV1Log.php | 13 ++++++++
app/Models/User.php | 8 +++++
app/Services/QuotaV1Service.php | 2 +-
..._before_balance_to_quota_v1_logs_table.php | 33 +++++++++++++++++++
6 files changed, 57 insertions(+), 3 deletions(-)
create mode 100644 database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
diff --git a/app/Admin/Forms/QuotaV1Deduction.php b/app/Admin/Forms/QuotaV1Deduction.php
index d3cf0096..acfd94ff 100644
--- a/app/Admin/Forms/QuotaV1Deduction.php
+++ b/app/Admin/Forms/QuotaV1Deduction.php
@@ -63,7 +63,7 @@ class QuotaV1Deduction extends Form implements LazyRenderable
public function form()
{
$this->select('user_id', '用户手机号')->ajax(admin_route('api.users'))->required();
- $this->currency('change_balance', '扣减配额')->symbol('¥')->required();
+ $this->currency('change_balance', '扣减配额')->digits(3)->symbol('¥')->required();
$this->confirm('是否确认扣减?', '提交后该动作无法逆转');
}
}
diff --git a/app/Admin/Forms/QuotaV1Recharge.php b/app/Admin/Forms/QuotaV1Recharge.php
index ecd0f1c8..9e84af27 100644
--- a/app/Admin/Forms/QuotaV1Recharge.php
+++ b/app/Admin/Forms/QuotaV1Recharge.php
@@ -63,7 +63,7 @@ class QuotaV1Recharge extends Form implements LazyRenderable
public function form()
{
$this->select('user_id', '用户手机号')->ajax(admin_route('api.users'))->required();
- $this->currency('change_balance', '增加配额')->symbol('¥')->required();
+ $this->currency('change_balance', '增加配额')->digits(3)->required();
$this->confirm('是否确认增加老配额?', '提交后该动作无法逆转');
}
}
diff --git a/app/Models/QuotaV1Log.php b/app/Models/QuotaV1Log.php
index 6271df3d..e8440b3c 100644
--- a/app/Models/QuotaV1Log.php
+++ b/app/Models/QuotaV1Log.php
@@ -11,4 +11,17 @@ class QuotaV1Log extends Model
public const ACTION_ADMIN_RECHARGE = 7;
public const ACTION_ADMIN_DEDUCTION = 8;
+
+ /**
+ * @var array
+ */
+ protected $fillable = [
+ 'user_id',
+ 'loggable_id',
+ 'loggable_type',
+ 'action',
+ 'before_balance',
+ 'change_balance',
+ 'remarks',
+ ];
}
diff --git a/app/Models/User.php b/app/Models/User.php
index fe8e0d74..f793e61f 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -368,6 +368,14 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
return $this->hasMany(QuotaLog::class);
}
+ /**
+ * 用户的配额日志
+ */
+ public function quotaV1Logs()
+ {
+ return $this->hasMany(QuotaV1Log::class);
+ }
+
/**
* 属于此用户的团队销售值(含自己的销售值)
*/
diff --git a/app/Services/QuotaV1Service.php b/app/Services/QuotaV1Service.php
index 1e905b5e..922ab5a8 100644
--- a/app/Services/QuotaV1Service.php
+++ b/app/Services/QuotaV1Service.php
@@ -45,7 +45,7 @@ class QuotaV1Service
$user->userInfo()->decrement('quota_v1', $_changeBalance);
}
- $user->walletLogs()->create([
+ $user->quotaV1Logs()->create([
'loggable_id' => $loggable?->id,
'loggable_type' => $loggable?->getMorphClass(),
'before_balance' => $beforeBalance,
diff --git a/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
new file mode 100644
index 00000000..4391ca78
--- /dev/null
+++ b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
@@ -0,0 +1,33 @@
+string('before_balance', 12, 3)->change();
+ $table->decimal('change_balance', 12, 3)->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('quota_v1_logs', function (Blueprint $table) {
+ //
+ });
+ }
+}
From ee06382d9f390b0767a9df6e438ec0e87bc89214 Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Mon, 7 Mar 2022 10:13:51 +0800
Subject: [PATCH 05/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/QuotaV1LogController.php | 87 ++++++++++++++++++
.../Controllers/QuotaV1SendJobController.php | 3 +
app/Admin/Repositories/QuotaV1Log.php | 16 ++++
app/Admin/routes.php | 1 +
app/Models/QuotaV1Log.php | 7 ++
..._before_balance_to_quota_v1_logs_table.php | 2 +-
database/seeders/AdminPermissionSeeder.php | 1 +
dcat_admin_ide_helper.php | 92 +++++++++++--------
resources/lang/zh_CN/quota-v1-log.php | 20 ++++
9 files changed, 192 insertions(+), 37 deletions(-)
create mode 100644 app/Admin/Controllers/QuotaV1LogController.php
create mode 100644 app/Admin/Repositories/QuotaV1Log.php
create mode 100644 resources/lang/zh_CN/quota-v1-log.php
diff --git a/app/Admin/Controllers/QuotaV1LogController.php b/app/Admin/Controllers/QuotaV1LogController.php
new file mode 100644
index 00000000..12847eb3
--- /dev/null
+++ b/app/Admin/Controllers/QuotaV1LogController.php
@@ -0,0 +1,87 @@
+column('id')->sortable();
+ $grid->column('user.phone', '手机号')->copyable();
+ $grid->column('user.userInfo.nickname', '昵称');
+ // $grid->column('loggable_type');
+ // $grid->column('loggable_id');
+ // $grid->column('action');
+ $grid->column('before_balance');
+ $grid->column('change_balance');
+ $grid->column('remarks');
+ $grid->model()->orderBy('created_at', 'desc');
+ $grid->column('created_at')->sortable();
+ // $grid->column('updated_at')->sortable();
+ $grid->disableActions();
+ $grid->filter(function (Grid\Filter $filter) {
+ $filter->panel();
+ $filter->like('user.phone', '手机号')->width(3);
+ // $filter->equal('id');
+ });
+ });
+ }
+
+ /**
+ * Make a show builder.
+ *
+ * @param mixed $id
+ *
+ * @return Show
+ */
+ protected function detail($id)
+ {
+ return Show::make($id, new QuotaV1Log(), function (Show $show) {
+ $show->field('id');
+ $show->field('user_id');
+ $show->field('loggable_type');
+ $show->field('loggable_id');
+ $show->field('action');
+ $show->field('before_balance');
+ $show->field('change_balance');
+ $show->field('remarks');
+ $show->field('created_at');
+ $show->field('updated_at');
+ });
+ }
+
+ /**
+ * Make a form builder.
+ *
+ * @return Form
+ */
+ protected function form()
+ {
+ return Form::make(new QuotaV1Log(), function (Form $form) {
+ $form->display('id');
+ $form->text('user_id');
+ $form->text('loggable_type');
+ $form->text('loggable_id');
+ $form->text('action');
+ $form->text('before_balance');
+ $form->text('change_balance');
+ $form->text('remarks');
+
+ $form->display('created_at');
+ $form->display('updated_at');
+ });
+ }
+}
diff --git a/app/Admin/Controllers/QuotaV1SendJobController.php b/app/Admin/Controllers/QuotaV1SendJobController.php
index 1f10a622..3a036a6d 100644
--- a/app/Admin/Controllers/QuotaV1SendJobController.php
+++ b/app/Admin/Controllers/QuotaV1SendJobController.php
@@ -34,6 +34,9 @@ class QuotaV1SendJobController extends AdminController
if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.deduction')) {
$tools->append(new Deduction());
}
+ if (Admin::user()->can('dcat.admin.quota_v1_send_jobs.logs_index')) {
+ $tools->append(' 变动记录');
+ }
});
$grid->column('amount')->display(function ($value) {
return bcdiv($value, 100, 2);
diff --git a/app/Admin/Repositories/QuotaV1Log.php b/app/Admin/Repositories/QuotaV1Log.php
new file mode 100644
index 00000000..d9ffa971
--- /dev/null
+++ b/app/Admin/Repositories/QuotaV1Log.php
@@ -0,0 +1,16 @@
+names('quota_v1_send_jobs');
$router->get('quota-v1-send-jobs/{job}/log-list', 'QuotaV1SendJobController@logList')->name('quota_v1_send_jobs.log_list');
+ $router->get('quota-v1-send-jobs/logs-index', 'QuotaV1LogController@index')->name('quota_v1_send_jobs.logs_index');
$router->resource('order-refunds', 'OrderRefundLogController')->only([
'index',
diff --git a/app/Models/QuotaV1Log.php b/app/Models/QuotaV1Log.php
index e8440b3c..603887be 100644
--- a/app/Models/QuotaV1Log.php
+++ b/app/Models/QuotaV1Log.php
@@ -2,12 +2,14 @@
namespace App\Models;
+use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class QuotaV1Log extends Model
{
use HasFactory;
+ use HasDateTimeFormatter;
public const ACTION_ADMIN_RECHARGE = 7;
public const ACTION_ADMIN_DEDUCTION = 8;
@@ -24,4 +26,9 @@ class QuotaV1Log extends Model
'change_balance',
'remarks',
];
+
+ public function user()
+ {
+ return $this->belongsTo(User::class);
+ }
}
diff --git a/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
index 4391ca78..09b42f6b 100644
--- a/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
+++ b/database/migrations/2022_03_04_180530_change_before_balance_to_quota_v1_logs_table.php
@@ -14,7 +14,7 @@ class ChangeBeforeBalanceToQuotaV1LogsTable extends Migration
public function up()
{
Schema::table('quota_v1_logs', function (Blueprint $table) {
- $table->string('before_balance', 12, 3)->change();
+ $table->decimal('before_balance', 12, 3)->change();
$table->decimal('change_balance', 12, 3)->change();
});
}
diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php
index 8e6103e6..389bd35b 100644
--- a/database/seeders/AdminPermissionSeeder.php
+++ b/database/seeders/AdminPermissionSeeder.php
@@ -307,6 +307,7 @@ class AdminPermissionSeeder extends Seeder
'log_list'=>['name' =>'分红记录'],
'recharge'=>['name' =>'增加配额'],
'deduction'=>['name' =>'扣减配额'],
+ 'logs_index'=>['name' =>'变动日志'],
],
],
'dealers' =>[
diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php
index a2d41b6c..d1d1dab1 100644
--- a/dcat_admin_ide_helper.php
+++ b/dcat_admin_ide_helper.php
@@ -12,13 +12,25 @@ namespace Dcat\Admin {
/**
* @property Grid\Column|Collection width
+ * @property Grid\Column|Collection content
+ * @property Grid\Column|Collection coupons_rule
+ * @property Grid\Column|Collection cover
* @property Grid\Column|Collection created_at
- * @property Grid\Column|Collection dimensions
+ * @property Grid\Column|Collection ended_at
+ * @property Grid\Column|Collection gifts_rule
* @property Grid\Column|Collection id
+ * @property Grid\Column|Collection is_use
+ * @property Grid\Column|Collection started_at
+ * @property Grid\Column|Collection updated_at
+ * @property Grid\Column|Collection activity_id
+ * @property Grid\Column|Collection coupon_id
+ * @property Grid\Column|Collection qty
+ * @property Grid\Column|Collection sku_id
+ * @property Grid\Column|Collection part_id
+ * @property Grid\Column|Collection dimensions
* @property Grid\Column|Collection is_show
* @property Grid\Column|Collection key
* @property Grid\Column|Collection name
- * @property Grid\Column|Collection updated_at
* @property Grid\Column|Collection detail
* @property Grid\Column|Collection type
* @property Grid\Column|Collection version
@@ -72,8 +84,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection article_id
* @property Grid\Column|Collection author_name
* @property Grid\Column|Collection category_id
- * @property Grid\Column|Collection content
- * @property Grid\Column|Collection cover
* @property Grid\Column|Collection likes
* @property Grid\Column|Collection media_content
* @property Grid\Column|Collection media_type
@@ -91,7 +101,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection transferable
* @property Grid\Column|Collection continue_click_times
* @property Grid\Column|Collection last_click_at
- * @property Grid\Column|Collection coupon_id
* @property Grid\Column|Collection is_enable
* @property Grid\Column|Collection ranges
* @property Grid\Column|Collection administrator_id
@@ -128,7 +137,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection last_consignor_id
* @property Grid\Column|Collection new_consignor_id
* @property Grid\Column|Collection price
- * @property Grid\Column|Collection qty
* @property Grid\Column|Collection sale_price
* @property Grid\Column|Collection reason
* @property Grid\Column|Collection allocated_at
@@ -212,7 +220,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection gift_for_sku_id
* @property Grid\Column|Collection reduced_amount
* @property Grid\Column|Collection remain_quantity
- * @property Grid\Column|Collection sku_id
* @property Grid\Column|Collection specs
* @property Grid\Column|Collection spu_id
* @property Grid\Column|Collection vip_discount_amount
@@ -238,7 +245,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection gift_sku_id
* @property Grid\Column|Collection remaining
* @property Grid\Column|Collection attrs
- * @property Grid\Column|Collection part_id
* @property Grid\Column|Collection applicant_id
* @property Grid\Column|Collection reviewer_id
* @property Grid\Column|Collection buynote_id
@@ -256,7 +262,6 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection message_type
* @property Grid\Column|Collection change_quota
* @property Grid\Column|Collection order_user_id
- * @property Grid\Column|Collection is_use
* @property Grid\Column|Collection size
* @property Grid\Column|Collection x
* @property Grid\Column|Collection y
@@ -311,13 +316,25 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection status_remark
*
* @method Grid\Column|Collection width(string $label = null)
+ * @method Grid\Column|Collection content(string $label = null)
+ * @method Grid\Column|Collection coupons_rule(string $label = null)
+ * @method Grid\Column|Collection cover(string $label = null)
* @method Grid\Column|Collection created_at(string $label = null)
- * @method Grid\Column|Collection dimensions(string $label = null)
+ * @method Grid\Column|Collection ended_at(string $label = null)
+ * @method Grid\Column|Collection gifts_rule(string $label = null)
* @method Grid\Column|Collection id(string $label = null)
+ * @method Grid\Column|Collection is_use(string $label = null)
+ * @method Grid\Column|Collection started_at(string $label = null)
+ * @method Grid\Column|Collection updated_at(string $label = null)
+ * @method Grid\Column|Collection activity_id(string $label = null)
+ * @method Grid\Column|Collection coupon_id(string $label = null)
+ * @method Grid\Column|Collection qty(string $label = null)
+ * @method Grid\Column|Collection sku_id(string $label = null)
+ * @method Grid\Column|Collection part_id(string $label = null)
+ * @method Grid\Column|Collection dimensions(string $label = null)
* @method Grid\Column|Collection is_show(string $label = null)
* @method Grid\Column|Collection key(string $label = null)
* @method Grid\Column|Collection name(string $label = null)
- * @method Grid\Column|Collection updated_at(string $label = null)
* @method Grid\Column|Collection detail(string $label = null)
* @method Grid\Column|Collection type(string $label = null)
* @method Grid\Column|Collection version(string $label = null)
@@ -371,8 +388,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection article_id(string $label = null)
* @method Grid\Column|Collection author_name(string $label = null)
* @method Grid\Column|Collection category_id(string $label = null)
- * @method Grid\Column|Collection content(string $label = null)
- * @method Grid\Column|Collection cover(string $label = null)
* @method Grid\Column|Collection likes(string $label = null)
* @method Grid\Column|Collection media_content(string $label = null)
* @method Grid\Column|Collection media_type(string $label = null)
@@ -390,7 +405,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection transferable(string $label = null)
* @method Grid\Column|Collection continue_click_times(string $label = null)
* @method Grid\Column|Collection last_click_at(string $label = null)
- * @method Grid\Column|Collection coupon_id(string $label = null)
* @method Grid\Column|Collection is_enable(string $label = null)
* @method Grid\Column|Collection ranges(string $label = null)
* @method Grid\Column|Collection administrator_id(string $label = null)
@@ -427,7 +441,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection last_consignor_id(string $label = null)
* @method Grid\Column|Collection new_consignor_id(string $label = null)
* @method Grid\Column|Collection price(string $label = null)
- * @method Grid\Column|Collection qty(string $label = null)
* @method Grid\Column|Collection sale_price(string $label = null)
* @method Grid\Column|Collection reason(string $label = null)
* @method Grid\Column|Collection allocated_at(string $label = null)
@@ -511,7 +524,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection gift_for_sku_id(string $label = null)
* @method Grid\Column|Collection reduced_amount(string $label = null)
* @method Grid\Column|Collection remain_quantity(string $label = null)
- * @method Grid\Column|Collection sku_id(string $label = null)
* @method Grid\Column|Collection specs(string $label = null)
* @method Grid\Column|Collection spu_id(string $label = null)
* @method Grid\Column|Collection vip_discount_amount(string $label = null)
@@ -537,7 +549,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection gift_sku_id(string $label = null)
* @method Grid\Column|Collection remaining(string $label = null)
* @method Grid\Column|Collection attrs(string $label = null)
- * @method Grid\Column|Collection part_id(string $label = null)
* @method Grid\Column|Collection applicant_id(string $label = null)
* @method Grid\Column|Collection reviewer_id(string $label = null)
* @method Grid\Column|Collection buynote_id(string $label = null)
@@ -555,7 +566,6 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection message_type(string $label = null)
* @method Grid\Column|Collection change_quota(string $label = null)
* @method Grid\Column|Collection order_user_id(string $label = null)
- * @method Grid\Column|Collection is_use(string $label = null)
* @method Grid\Column|Collection size(string $label = null)
* @method Grid\Column|Collection x(string $label = null)
* @method Grid\Column|Collection y(string $label = null)
@@ -615,13 +625,25 @@ namespace Dcat\Admin {
/**
* @property Show\Field|Collection width
+ * @property Show\Field|Collection content
+ * @property Show\Field|Collection coupons_rule
+ * @property Show\Field|Collection cover
* @property Show\Field|Collection created_at
- * @property Show\Field|Collection dimensions
+ * @property Show\Field|Collection ended_at
+ * @property Show\Field|Collection gifts_rule
* @property Show\Field|Collection id
+ * @property Show\Field|Collection is_use
+ * @property Show\Field|Collection started_at
+ * @property Show\Field|Collection updated_at
+ * @property Show\Field|Collection activity_id
+ * @property Show\Field|Collection coupon_id
+ * @property Show\Field|Collection qty
+ * @property Show\Field|Collection sku_id
+ * @property Show\Field|Collection part_id
+ * @property Show\Field|Collection dimensions
* @property Show\Field|Collection is_show
* @property Show\Field|Collection key
* @property Show\Field|Collection name
- * @property Show\Field|Collection updated_at
* @property Show\Field|Collection detail
* @property Show\Field|Collection type
* @property Show\Field|Collection version
@@ -675,8 +697,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection article_id
* @property Show\Field|Collection author_name
* @property Show\Field|Collection category_id
- * @property Show\Field|Collection content
- * @property Show\Field|Collection cover
* @property Show\Field|Collection likes
* @property Show\Field|Collection media_content
* @property Show\Field|Collection media_type
@@ -694,7 +714,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection transferable
* @property Show\Field|Collection continue_click_times
* @property Show\Field|Collection last_click_at
- * @property Show\Field|Collection coupon_id
* @property Show\Field|Collection is_enable
* @property Show\Field|Collection ranges
* @property Show\Field|Collection administrator_id
@@ -731,7 +750,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection last_consignor_id
* @property Show\Field|Collection new_consignor_id
* @property Show\Field|Collection price
- * @property Show\Field|Collection qty
* @property Show\Field|Collection sale_price
* @property Show\Field|Collection reason
* @property Show\Field|Collection allocated_at
@@ -815,7 +833,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection gift_for_sku_id
* @property Show\Field|Collection reduced_amount
* @property Show\Field|Collection remain_quantity
- * @property Show\Field|Collection sku_id
* @property Show\Field|Collection specs
* @property Show\Field|Collection spu_id
* @property Show\Field|Collection vip_discount_amount
@@ -841,7 +858,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection gift_sku_id
* @property Show\Field|Collection remaining
* @property Show\Field|Collection attrs
- * @property Show\Field|Collection part_id
* @property Show\Field|Collection applicant_id
* @property Show\Field|Collection reviewer_id
* @property Show\Field|Collection buynote_id
@@ -859,7 +875,6 @@ namespace Dcat\Admin {
* @property Show\Field|Collection message_type
* @property Show\Field|Collection change_quota
* @property Show\Field|Collection order_user_id
- * @property Show\Field|Collection is_use
* @property Show\Field|Collection size
* @property Show\Field|Collection x
* @property Show\Field|Collection y
@@ -914,13 +929,25 @@ namespace Dcat\Admin {
* @property Show\Field|Collection status_remark
*
* @method Show\Field|Collection width(string $label = null)
+ * @method Show\Field|Collection content(string $label = null)
+ * @method Show\Field|Collection coupons_rule(string $label = null)
+ * @method Show\Field|Collection cover(string $label = null)
* @method Show\Field|Collection created_at(string $label = null)
- * @method Show\Field|Collection dimensions(string $label = null)
+ * @method Show\Field|Collection ended_at(string $label = null)
+ * @method Show\Field|Collection gifts_rule(string $label = null)
* @method Show\Field|Collection id(string $label = null)
+ * @method Show\Field|Collection is_use(string $label = null)
+ * @method Show\Field|Collection started_at(string $label = null)
+ * @method Show\Field|Collection updated_at(string $label = null)
+ * @method Show\Field|Collection activity_id(string $label = null)
+ * @method Show\Field|Collection coupon_id(string $label = null)
+ * @method Show\Field|Collection qty(string $label = null)
+ * @method Show\Field|Collection sku_id(string $label = null)
+ * @method Show\Field|Collection part_id(string $label = null)
+ * @method Show\Field|Collection dimensions(string $label = null)
* @method Show\Field|Collection is_show(string $label = null)
* @method Show\Field|Collection key(string $label = null)
* @method Show\Field|Collection name(string $label = null)
- * @method Show\Field|Collection updated_at(string $label = null)
* @method Show\Field|Collection detail(string $label = null)
* @method Show\Field|Collection type(string $label = null)
* @method Show\Field|Collection version(string $label = null)
@@ -974,8 +1001,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection article_id(string $label = null)
* @method Show\Field|Collection author_name(string $label = null)
* @method Show\Field|Collection category_id(string $label = null)
- * @method Show\Field|Collection content(string $label = null)
- * @method Show\Field|Collection cover(string $label = null)
* @method Show\Field|Collection likes(string $label = null)
* @method Show\Field|Collection media_content(string $label = null)
* @method Show\Field|Collection media_type(string $label = null)
@@ -993,7 +1018,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection transferable(string $label = null)
* @method Show\Field|Collection continue_click_times(string $label = null)
* @method Show\Field|Collection last_click_at(string $label = null)
- * @method Show\Field|Collection coupon_id(string $label = null)
* @method Show\Field|Collection is_enable(string $label = null)
* @method Show\Field|Collection ranges(string $label = null)
* @method Show\Field|Collection administrator_id(string $label = null)
@@ -1030,7 +1054,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection last_consignor_id(string $label = null)
* @method Show\Field|Collection new_consignor_id(string $label = null)
* @method Show\Field|Collection price(string $label = null)
- * @method Show\Field|Collection qty(string $label = null)
* @method Show\Field|Collection sale_price(string $label = null)
* @method Show\Field|Collection reason(string $label = null)
* @method Show\Field|Collection allocated_at(string $label = null)
@@ -1114,7 +1137,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection gift_for_sku_id(string $label = null)
* @method Show\Field|Collection reduced_amount(string $label = null)
* @method Show\Field|Collection remain_quantity(string $label = null)
- * @method Show\Field|Collection sku_id(string $label = null)
* @method Show\Field|Collection specs(string $label = null)
* @method Show\Field|Collection spu_id(string $label = null)
* @method Show\Field|Collection vip_discount_amount(string $label = null)
@@ -1140,7 +1162,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection gift_sku_id(string $label = null)
* @method Show\Field|Collection remaining(string $label = null)
* @method Show\Field|Collection attrs(string $label = null)
- * @method Show\Field|Collection part_id(string $label = null)
* @method Show\Field|Collection applicant_id(string $label = null)
* @method Show\Field|Collection reviewer_id(string $label = null)
* @method Show\Field|Collection buynote_id(string $label = null)
@@ -1158,7 +1179,6 @@ namespace Dcat\Admin {
* @method Show\Field|Collection message_type(string $label = null)
* @method Show\Field|Collection change_quota(string $label = null)
* @method Show\Field|Collection order_user_id(string $label = null)
- * @method Show\Field|Collection is_use(string $label = null)
* @method Show\Field|Collection size(string $label = null)
* @method Show\Field|Collection x(string $label = null)
* @method Show\Field|Collection y(string $label = null)
diff --git a/resources/lang/zh_CN/quota-v1-log.php b/resources/lang/zh_CN/quota-v1-log.php
new file mode 100644
index 00000000..db69b27f
--- /dev/null
+++ b/resources/lang/zh_CN/quota-v1-log.php
@@ -0,0 +1,20 @@
+ [
+ 'QuotaV1Log' => '老配额变动日志',
+ 'quota-v1-send-jobs' => '老配额分红',
+ 'logs-index'=>'变动日志',
+ ],
+ 'fields' => [
+ 'user_id' => '用户',
+ 'loggable_type' => '类型',
+ 'loggable_id' => '关联ID',
+ 'action' => '操作类型',
+ 'before_balance' => '变更前的余额',
+ 'change_balance' => '变动余额',
+ 'remarks' => '备注',
+ ],
+ 'options' => [
+ ],
+];
From f046e3a4d3445d5ddb3da637bf71424c331342e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?=
Date: Mon, 7 Mar 2022 11:07:05 +0800
Subject: [PATCH 06/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20InfoBox=20=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Widgets/InfoBox.php | 110 ++++++++++++++++++
.../vendor/admin/widgets/info-box.blade.php | 31 +++++
2 files changed, 141 insertions(+)
create mode 100644 app/Admin/Widgets/InfoBox.php
create mode 100644 resources/views/vendor/admin/widgets/info-box.blade.php
diff --git a/app/Admin/Widgets/InfoBox.php b/app/Admin/Widgets/InfoBox.php
new file mode 100644
index 00000000..32cc3db9
--- /dev/null
+++ b/app/Admin/Widgets/InfoBox.php
@@ -0,0 +1,110 @@
+title($title);
+ $this->content($content);
+ $this->icon($icon);
+ }
+
+ /**
+ * Info Box 图标
+ *
+ * @param string $icon
+ * @return $this
+ */
+ public function icon(string $icon = null)
+ {
+ $this->icon = $icon;
+
+ return $this;
+ }
+
+ /**
+ * Info Box 内容
+ *
+ * @param string $content
+ * @return $this
+ */
+ public function content($content)
+ {
+ $this->content = $content;
+
+ return $this;
+ }
+
+ /**
+ * Info Box 标题
+ *
+ * @param string $title
+ * @return $this
+ */
+ public function title($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * Add style.
+ *
+ * @param string $style
+ * @return $this
+ */
+ public function style($style = 'info')
+ {
+ $this->style = $style;
+
+ return $this;
+ }
+
+ /**
+ * Variables in view.
+ *
+ * @return array
+ */
+ public function defaultVariables()
+ {
+ $this->class('info-box');
+
+ return [
+ 'title' => $this->title,
+ 'content' => $this->content,
+ 'icon' => $this->icon,
+ 'style' => $this->style,
+ 'attributes' => $this->formatHtmlAttributes(),
+ ];
+ }
+}
diff --git a/resources/views/vendor/admin/widgets/info-box.blade.php b/resources/views/vendor/admin/widgets/info-box.blade.php
new file mode 100644
index 00000000..639dbe5b
--- /dev/null
+++ b/resources/views/vendor/admin/widgets/info-box.blade.php
@@ -0,0 +1,31 @@
+
+
+
+ @if($icon)
+
+
+
+ @endif
+
+
+ {{ $title }}
+ {!! $content !!}
+
+
From 99f0c8cbac76dd25b02813ff9fe3320d186041b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?=
Date: Mon, 7 Mar 2022 11:30:05 +0800
Subject: [PATCH 07/10] =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=B4=A5=E8=B4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Grid/DealerManagerSubsidyBatchPay.php | 51 +++++++
.../Actions/Grid/DealerManagerSubsidyPay.php | 44 ++++++
.../DealerManageSubsidyLogController.php | 1 +
.../DealerManagerSubsidyController.php | 127 ++++++++++++++++++
app/Admin/routes.php | 5 +-
app/Enums/DealerManagerSubsidyStatus.php | 21 +++
app/Models/DealerManagerSubsidy.php | 31 +++++
app/Services/Dealer/ManagerSubsidyService.php | 43 ++++++
database/seeders/AdminMenuSeeder.php | 2 +-
database/seeders/AdminPermissionSeeder.php | 8 ++
10 files changed, 331 insertions(+), 2 deletions(-)
create mode 100644 app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php
create mode 100644 app/Admin/Actions/Grid/DealerManagerSubsidyPay.php
create mode 100644 app/Admin/Controllers/DealerManagerSubsidyController.php
create mode 100644 app/Services/Dealer/ManagerSubsidyService.php
diff --git a/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php
new file mode 100644
index 00000000..39365184
--- /dev/null
+++ b/app/Admin/Actions/Grid/DealerManagerSubsidyBatchPay.php
@@ -0,0 +1,51 @@
+ 付款';
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.dealer_manager_subsidies.batch_pay');
+ }
+
+ // 确认弹窗信息
+ public function confirm()
+ {
+ return '您确定要支付选中的管理者津贴吗?';
+ }
+
+ // 处理请求
+ public function handle(Request $request)
+ {
+ try {
+ DB::transaction(function () {
+ foreach ($this->getKey() as $id) {
+ $dealerManagerSubsidy = DealerManagerSubsidy::lockForUpdate()->settled()->find($id);
+
+ if ($dealerManagerSubsidy?->isPending()) {
+ (new ManagerSubsidyService())->pay($dealerManagerSubsidy);
+ }
+ }
+ });
+ } catch (Throwable $e) {
+ return $this->response()->error('操作失败:'.$e->getMessage())->refresh();
+ }
+
+ return $this->response()->success('操作成功')->refresh();
+ }
+}
diff --git a/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php b/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php
new file mode 100644
index 00000000..0c706e8c
--- /dev/null
+++ b/app/Admin/Actions/Grid/DealerManagerSubsidyPay.php
@@ -0,0 +1,44 @@
+ 付款';
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.dealer_manager_subsidies.pay');
+ }
+
+ // 确认弹窗信息
+ public function confirm()
+ {
+ return '您确定要支付选中的管理者津贴吗?';
+ }
+
+ // 处理请求
+ public function handle(Request $request)
+ {
+ DB::transaction(function () {
+ $id = $this->getKey();
+
+ (new ManagerSubsidyService())->pay(
+ DealerManagerSubsidy::lockForUpdate()->settled()->findOrFail($id)
+ );
+ });
+
+ return $this->response()->success('操作成功')->refresh();
+ }
+}
diff --git a/app/Admin/Controllers/DealerManageSubsidyLogController.php b/app/Admin/Controllers/DealerManageSubsidyLogController.php
index c08155fc..cf7fc89e 100644
--- a/app/Admin/Controllers/DealerManageSubsidyLogController.php
+++ b/app/Admin/Controllers/DealerManageSubsidyLogController.php
@@ -19,6 +19,7 @@ class DealerManageSubsidyLogController extends AdminController
protected function grid()
{
$builder = DealerManageSubsidyLog::with(['user', 'order', 'product']);
+
return Grid::make($builder, function (Grid $grid) {
$grid->model()->orderBy('id', 'desc');//默认ID倒叙
$grid->column('id')->sortable();
diff --git a/app/Admin/Controllers/DealerManagerSubsidyController.php b/app/Admin/Controllers/DealerManagerSubsidyController.php
new file mode 100644
index 00000000..5875b766
--- /dev/null
+++ b/app/Admin/Controllers/DealerManagerSubsidyController.php
@@ -0,0 +1,127 @@
+settled();
+
+ return Grid::make($builder, function (Grid $grid) {
+ $grid->model()->orderBy('id', 'desc');
+
+ $grid->column('settle_period', '结算周期')->display(function () {
+ return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d');
+ })->link(function () {
+ return admin_route('dealer_manager_sales_logs.index', [
+ 'user[phone]' => $this->user?->phone,
+ 'order_completed_at[start]' => $this->start_at->toDateTimeString(),
+ 'order_completed_at[end]' => $this->end_at->toDateTimeString(),
+ ]);
+ });
+ $grid->column('user.phone', '手机号');
+ $grid->column('userinfo.nickname', '昵称');
+ $grid->column('is_manager', '管理者')->bool();
+ $grid->column('lvl', '经销商等级')->display(function () {
+ return $this->lvl->text();
+ });
+ $grid->column('total_amount', '津贴总额')->prepend('¥');
+ $grid->column('fee', '手续费')->prepend('¥')->help('手续费=津贴总额*手续费率');
+ $grid->column('real_amount', '总收入')->prepend('¥')->help('总收入=津贴总额-手续费');
+ $grid->column('fee_rate', '手续费率')->append('%');
+ $grid->column('remark', '备注')->display('查看')->modal(function ($modal) {
+ $modal->title('备注');
+
+ return "".nl2br($this->remark).'
';
+ });
+ $grid->column('status', '状态')->display(function ($v) {
+ return ' '.$v->text();
+ });
+ $grid->column('earning.pay_at', '付款时间');
+
+ $grid->showRowSelector();
+
+ $grid->tools(function ($tools) {
+ $tools->batch(function ($batch) {
+ $batch->disableDelete();
+
+ if (Admin::user()->can('dcat.admin.dealer_manager_subsidies.batch_pay')) {
+ $batch->add(new DealerManagerSubsidyBatchPay());
+ }
+ });
+ });
+
+ $grid->actions(function (Grid\Displayers\Actions $actions) {
+ if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_manager_subsidies.pay')) {
+ $actions->append(new DealerManagerSubsidyPay());
+ }
+ });
+
+ $grid->filter(function (Grid\Filter $filter) {
+ $filter->panel();
+
+ $filter->equal('user.phone', '手机号')->width(3);
+ $filter->equal('status', '状态')->select(DealerManagerSubsidyStatus::texts())->width(3);
+ $filter->whereBetween('settle_period', function ($query) {
+ $start = $this->input['start'] ?? null;
+ $end = $this->input['end'] ?? null;
+
+ $query->when($start, function ($query, $start) {
+ $query->where('start_at', '>=', "{$start} 00:00:00");
+ });
+
+ $query->when($end, function ($query, $end) {
+ $query->where('end_at', '<=', "{$end} 23:59:59");
+ });
+ }, '结算周期')->date()->width(6);
+ });
+
+ $grid->header(function ($collection) use ($grid) {
+ return tap(new Row(), function ($row) use ($grid) {
+ $query = DealerManagerSubsidy::query();
+
+ $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
+ if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
+ return;
+ }
+
+ $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ });
+
+ $totalAmount = (clone $query)->sum('total_amount');
+ $totalFee = (clone $query)->sum('fee');
+
+ $row->column(3, new InfoBox('津贴总额', $totalAmount, 'fa fa-cny'));
+ $row->column(3, new InfoBox('手续费', $totalFee, 'fa fa-cny'));
+ });
+ });
+ });
+ }
+}
diff --git a/app/Admin/routes.php b/app/Admin/routes.php
index 804eac4d..04304fc5 100644
--- a/app/Admin/routes.php
+++ b/app/Admin/routes.php
@@ -186,8 +186,11 @@ Route::group([
$router->get('dealer-earnings-manager', 'DealerEarningController@index')->name('dealer_earnings.manager');
$router->get('dealer-earnings-purchase', 'DealerEarningController@index')->name('dealer_earnings.purchase');
- //批零明细
+ // 管理者津贴
+ $router->get('dealer-manager-subsidies', 'DealerManagerSubsidyController@index')->name('dealer_manager_subsidies.index');
$router->get('dealer-manager-sales-logs', 'DealerManagerSalesLogController@index')->name('dealer_manager_sales_logs.index');
+
+ //批零明细
$router->get('dealer-manage-subsidy-logs', 'DealerManageSubsidyLogController@index')->name('dealer_manage_subsidy_logs.index');
$router->get('dealer-purchase-logs', 'DealerPurchaseLogController@index')->name('dealer_purchase_logs.index');
diff --git a/app/Enums/DealerManagerSubsidyStatus.php b/app/Enums/DealerManagerSubsidyStatus.php
index 8400c0a1..e18c013c 100644
--- a/app/Enums/DealerManagerSubsidyStatus.php
+++ b/app/Enums/DealerManagerSubsidyStatus.php
@@ -5,4 +5,25 @@ namespace App\Enums;
enum DealerManagerSubsidyStatus: int {
case Pending = 0;
case Completed = 5;
+
+ public function color(): string
+ {
+ return match ($this) {
+ static::Pending => '#5b69bc',
+ static::Completed => '#21b978',
+ };
+ }
+
+ public function text(): string
+ {
+ return static::texts()[$this->value] ?? 'Unknown';
+ }
+
+ public static function texts(): array
+ {
+ return [
+ static::Pending->value => '待付款',
+ static::Completed->value => '已付款',
+ ];
+ }
}
diff --git a/app/Models/DealerManagerSubsidy.php b/app/Models/DealerManagerSubsidy.php
index caea0024..42d1e89e 100644
--- a/app/Models/DealerManagerSubsidy.php
+++ b/app/Models/DealerManagerSubsidy.php
@@ -38,6 +38,27 @@ class DealerManagerSubsidy extends Model
'is_settle',
];
+ /**
+ * 仅查询已结算的订单
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeSettled($query)
+ {
+ return $query->where('is_settle', true);
+ }
+
+ public function user()
+ {
+ return $this->belongsTo(User::class, 'user_id');
+ }
+
+ public function userinfo()
+ {
+ return $this->belongsTo(UserInfo::class, 'user_id', 'user_id');
+ }
+
/**
* 此管理津贴所属的经销商
*/
@@ -51,6 +72,16 @@ class DealerManagerSubsidy extends Model
return $this->morphOne(DealerEarning::class, 'earningable');
}
+ /**
+ * 仅查询待付款的管理津贴
+ *
+ * @return bool
+ */
+ public function isPending(): bool
+ {
+ return $this->is_settle && $this->status === DealerManagerSubsidyStatus::Pending;
+ }
+
public function isCompleted()
{
return $this->status === DealerManagerSubsidyStatus::Completed;
diff --git a/app/Services/Dealer/ManagerSubsidyService.php b/app/Services/Dealer/ManagerSubsidyService.php
new file mode 100644
index 00000000..ab766710
--- /dev/null
+++ b/app/Services/Dealer/ManagerSubsidyService.php
@@ -0,0 +1,43 @@
+isPending()) {
+ throw new BizException('管理者津贴 不是待付款状态');
+ }
+
+ $dealerManagerSubsidy->update([
+ 'status' => DealerManagerSubsidyStatus::Completed,
+ ]);
+
+ $dealerManagerSubsidy->earning->update([
+ 'pay_way' => DealerEarning::PAY_WAY_WALLET,
+ 'pay_at' => now(),
+ 'pay_info' => null,
+ 'status' => DealerEarningStatus::Completed,
+ ]);
+
+ (new WalletService())->changeBalance(
+ $dealerManagerSubsidy->user,
+ $dealerManagerSubsidy->real_amount,
+ DealerWalletAction::ManagerSubsidyIn,
+ '收入-管理者津贴',
+ $dealerManagerSubsidy
+ );
+ }
+}
diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php
index 6f0a37bd..f87da2cc 100644
--- a/database/seeders/AdminMenuSeeder.php
+++ b/database/seeders/AdminMenuSeeder.php
@@ -342,7 +342,7 @@ class AdminMenuSeeder extends Seeder
[
'title'=>'管理者津贴',
'icon' => '',
- 'uri' => 'dealer-earnings-manager?filter-earningable_type[]=dealer_manager_subsidy',
+ 'uri' => 'dealer-manager-subsidies',
],
[
'title'=>'管理者津贴明细',
diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php
index 389bd35b..eaec93ee 100644
--- a/database/seeders/AdminPermissionSeeder.php
+++ b/database/seeders/AdminPermissionSeeder.php
@@ -352,6 +352,14 @@ class AdminPermissionSeeder extends Seeder
'pay'=>['name' =>'确认打款'],
],
],
+ 'dealer_manager_subsidies' => [
+ 'name' =>'管理者津贴',
+ 'curd' => ['index'],
+ 'children' => [
+ 'pay' => ['name' => '付款'],
+ 'batch_pay' => ['name' => '批量付款'],
+ ],
+ ],
'dealer_manager_sales_logs'=>[
'name' =>'管理者津贴明细',
'curd' => ['index'],
From 2a013b503731da03aa12a96826723ec7f5fd8c40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?=
Date: Mon, 7 Mar 2022 15:24:49 +0800
Subject: [PATCH 08/10] =?UTF-8?q?=E3=80=90=E5=90=8E=E5=8F=B0=E3=80=91?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86=E8=80=85=E6=B4=A5=E8=B4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DealerManagerSubsidyController.php | 9 +++++----
app/Admin/Repositories/DealerManagerSubsidy.php | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 4 deletions(-)
create mode 100644 app/Admin/Repositories/DealerManagerSubsidy.php
diff --git a/app/Admin/Controllers/DealerManagerSubsidyController.php b/app/Admin/Controllers/DealerManagerSubsidyController.php
index 5875b766..ffa4f236 100644
--- a/app/Admin/Controllers/DealerManagerSubsidyController.php
+++ b/app/Admin/Controllers/DealerManagerSubsidyController.php
@@ -4,9 +4,10 @@ namespace App\Admin\Controllers;
use App\Admin\Actions\Grid\DealerManagerSubsidyBatchPay;
use App\Admin\Actions\Grid\DealerManagerSubsidyPay;
+use App\Admin\Repositories\DealerManagerSubsidy;
use App\Admin\Widgets\InfoBox;
use App\Enums\DealerManagerSubsidyStatus;
-use App\Models\DealerManagerSubsidy;
+use App\Models\DealerManagerSubsidy as DealerManagerSubsidyModel;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
@@ -32,10 +33,10 @@ class DealerManagerSubsidyController extends AdminController
CSS
);
- $builder = DealerManagerSubsidy::with(['dealer', 'user', 'userinfo', 'earning'])->settled();
+ $builder = DealerManagerSubsidy::with(['dealer', 'user', 'userinfo', 'earning']);
return Grid::make($builder, function (Grid $grid) {
- $grid->model()->orderBy('id', 'desc');
+ $grid->model()->settled()->orderBy('id', 'desc');
$grid->column('settle_period', '结算周期')->display(function () {
return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d');
@@ -105,7 +106,7 @@ class DealerManagerSubsidyController extends AdminController
$grid->header(function ($collection) use ($grid) {
return tap(new Row(), function ($row) use ($grid) {
- $query = DealerManagerSubsidy::query();
+ $query = DealerManagerSubsidyModel::query();
$grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
diff --git a/app/Admin/Repositories/DealerManagerSubsidy.php b/app/Admin/Repositories/DealerManagerSubsidy.php
new file mode 100644
index 00000000..02b314a2
--- /dev/null
+++ b/app/Admin/Repositories/DealerManagerSubsidy.php
@@ -0,0 +1,16 @@
+
Date: Mon, 7 Mar 2022 15:40:03 +0800
Subject: [PATCH 09/10] =?UTF-8?q?=E3=80=90=E5=90=8E=E5=8F=B0=E3=80=91?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AE=A1=E7=90=86=E6=B4=A5=E8=B4=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Grid/DealerManageSubsidyBatchPay.php | 51 ++++++
.../Actions/Grid/DealerManageSubsidyPay.php | 44 +++++
.../DealerManageSubsidyController.php | 167 ++++++++++++++++++
.../DealerManageSubsidyLogController.php | 26 +++
.../Repositories/DealerManageSubsidy.php | 16 ++
app/Admin/routes.php | 4 +-
app/Enums/DealerManageSubsidyStatus.php | 21 +++
app/Models/DealerManageSubsidy.php | 31 ++++
app/Services/Dealer/ManageSubsidyService.php | 43 +++++
database/seeders/AdminMenuSeeder.php | 2 +-
database/seeders/AdminPermissionSeeder.php | 8 +
11 files changed, 411 insertions(+), 2 deletions(-)
create mode 100644 app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php
create mode 100644 app/Admin/Actions/Grid/DealerManageSubsidyPay.php
create mode 100644 app/Admin/Controllers/DealerManageSubsidyController.php
create mode 100644 app/Admin/Repositories/DealerManageSubsidy.php
create mode 100644 app/Services/Dealer/ManageSubsidyService.php
diff --git a/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php b/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php
new file mode 100644
index 00000000..caa4546d
--- /dev/null
+++ b/app/Admin/Actions/Grid/DealerManageSubsidyBatchPay.php
@@ -0,0 +1,51 @@
+ 付款';
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.dealer_manage_subsidies.batch_pay');
+ }
+
+ // 确认弹窗信息
+ public function confirm()
+ {
+ return '您确定要支付选中的管理津贴吗?';
+ }
+
+ // 处理请求
+ public function handle(Request $request)
+ {
+ try {
+ DB::transaction(function () {
+ foreach ($this->getKey() as $id) {
+ $dealerManageSubsidy = DealerManageSubsidy::lockForUpdate()->settled()->find($id);
+
+ if ($dealerManageSubsidy?->isPending()) {
+ (new ManageSubsidyService())->pay($dealerManageSubsidy);
+ }
+ }
+ });
+ } catch (Throwable $e) {
+ return $this->response()->error('操作失败:'.$e->getMessage())->refresh();
+ }
+
+ return $this->response()->success('操作成功')->refresh();
+ }
+}
diff --git a/app/Admin/Actions/Grid/DealerManageSubsidyPay.php b/app/Admin/Actions/Grid/DealerManageSubsidyPay.php
new file mode 100644
index 00000000..6f21ea8d
--- /dev/null
+++ b/app/Admin/Actions/Grid/DealerManageSubsidyPay.php
@@ -0,0 +1,44 @@
+ 付款';
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.dealer_manage_subsidies.pay');
+ }
+
+ // 确认弹窗信息
+ public function confirm()
+ {
+ return '您确定要支付选中的管理津贴吗?';
+ }
+
+ // 处理请求
+ public function handle(Request $request)
+ {
+ DB::transaction(function () {
+ $id = $this->getKey();
+
+ (new ManageSubsidyService())->pay(
+ DealerManageSubsidy::lockForUpdate()->settled()->findOrFail($id)
+ );
+ });
+
+ return $this->response()->success('操作成功')->refresh();
+ }
+}
diff --git a/app/Admin/Controllers/DealerManageSubsidyController.php b/app/Admin/Controllers/DealerManageSubsidyController.php
new file mode 100644
index 00000000..e643f44e
--- /dev/null
+++ b/app/Admin/Controllers/DealerManageSubsidyController.php
@@ -0,0 +1,167 @@
+model()->settled()->orderBy('id', 'desc');
+
+ $grid->column('settle_period', '结算周期')->display(function () {
+ return $this->start_at->rawFormat('Y/m/d') . '-' . $this->end_at->rawFormat('Y/m/d');
+ })->link(function () {
+ return admin_route('dealer_manage_subsidy_logs.index', [
+ 'user[phone]' => $this->user?->phone,
+ 'order_completed_at[start]' => $this->start_at->toDateTimeString(),
+ 'order_completed_at[end]' => $this->end_at->toDateTimeString(),
+ ]);
+ });
+ $grid->column('user.phone', '手机号');
+ $grid->column('userinfo.nickname', '昵称');
+ $grid->column('lvl', '经销商等级')->display(function () {
+ return $this->lvl->text();
+ });
+ $grid->column('total_amount', '津贴总额')->prepend('¥');
+ $grid->column('fee', '手续费')->prepend('¥')->help('手续费=津贴总额*手续费率');
+ $grid->column('real_amount', '总收入')->prepend('¥')->help('总收入=津贴总额-手续费');
+ $grid->column('fee_rate', '手续费率')->append('%');
+ $grid->column('remark', '备注')->display('查看')->modal(function ($modal) {
+ $modal->title('备注');
+
+ return "".nl2br($this->remark).'
';
+ });
+ $grid->column('status', '状态')->display(function ($v) {
+ return ' '.$v->text();
+ });
+ $grid->column('earning.pay_at', '付款时间');
+
+ $grid->showRowSelector();
+
+ $grid->tools(function ($tools) {
+ $tools->batch(function ($batch) {
+ $batch->disableDelete();
+
+ if (Admin::user()->can('dcat.admin.dealer_manage_subsidies.batch_pay')) {
+ $batch->add(new DealerManageSubsidyBatchPay());
+ }
+ });
+ });
+
+ $grid->actions(function (Grid\Displayers\Actions $actions) {
+ if ($actions->row->isPending() && Admin::user()->can('dcat.admin.dealer_manage_subsidies.pay')) {
+ $actions->append(new DealerManageSubsidyPay());
+ }
+ });
+
+ $grid->filter(function (Grid\Filter $filter) {
+ $filter->panel();
+
+ $filter->equal('user.phone', '手机号')->width(3);
+ $filter->equal('status', '状态')->select(DealerManageSubsidyStatus::texts())->width(3);
+ $filter->whereBetween('settle_period', function ($query) {
+ $start = $this->input['start'] ?? null;
+ $end = $this->input['end'] ?? null;
+
+ $query->when($start, function ($query, $start) {
+ $query->where('start_at', '>=', "{$start} 00:00:00");
+ });
+
+ $query->when($end, function ($query, $end) {
+ $query->where('end_at', '<=', "{$end} 23:59:59");
+ });
+ }, '结算周期')->date()->width(6);
+ });
+
+ $grid->header(function ($collection) use ($grid) {
+ return tap(new Row(), function ($row) use ($grid) {
+ $query = DealerManageSubsidyModel::query();
+
+ $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
+ if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
+ return;
+ }
+
+ $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ });
+
+ $totalAmount = (clone $query)->sum('total_amount');
+ $totalFee = (clone $query)->sum('fee');
+
+ $row->column(3, new InfoBox('津贴总额', $totalAmount, 'fa fa-cny'));
+ $row->column(3, new InfoBox('手续费', $totalFee, 'fa fa-cny'));
+ });
+ });
+ });
+
+ return Grid::make($builder, function (Grid $grid) {
+ $grid->model()->orderBy('id', 'desc');//默认ID倒叙
+ $grid->column('id')->sortable();
+ $grid->column('user.phone', '手机号')->copyable();
+ $grid->column('lvl', '等级')->display(function () {
+ return $this->lvl->text();
+ });
+ $grid->column('order.sn', '订单编号');
+ $grid->column('product.name', '商品名称');
+ $grid->column('sales_volume', '销量');
+ $grid->column('total_amount', '金额');
+ $grid->column('order_completed_at', '结算时间')->sortable();
+ $grid->column('created_at')->sortable();
+
+ $grid->disableCreateButton();
+ $grid->disableActions();
+ $grid->header(function ($collection) use ($grid) {
+ $query = DealerManageSubsidyLogModel::query();
+
+ // 拿到表格筛选 where 条件数组进行遍历
+ $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
+ if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
+ return;
+ }
+
+ $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ });
+
+ // 查出统计数据
+ $totalAmount = (clone $query)->sum('total_amount');
+ // 自定义组件
+ return "金额:".$totalAmount.' 元
';
+ });
+ $grid->filter(function (Grid\Filter $filter) {
+ $filter->panel(false);
+ $filter->equal('user.phone', '手机号')->width(3);
+ $filter->between('order_completed_at', '结算时间')->dateTime()->width(7);
+ });
+ });
+ }
+}
diff --git a/app/Admin/Controllers/DealerManageSubsidyLogController.php b/app/Admin/Controllers/DealerManageSubsidyLogController.php
index cf7fc89e..6057badc 100644
--- a/app/Admin/Controllers/DealerManageSubsidyLogController.php
+++ b/app/Admin/Controllers/DealerManageSubsidyLogController.php
@@ -3,10 +3,13 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\DealerManageSubsidyLog;
+use App\Admin\Widgets\InfoBox;
use App\Models\DealerManageSubsidyLog as DealerManageSubsidyLogModel;
+use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Row;
use Dcat\Admin\Show;
class DealerManageSubsidyLogController extends AdminController
@@ -18,10 +21,20 @@ class DealerManageSubsidyLogController extends AdminController
*/
protected function grid()
{
+ Admin::style(
+ <<model()->orderBy('id', 'desc');//默认ID倒叙
+
$grid->column('id')->sortable();
$grid->column('user.phone', '手机号')->copyable();
$grid->column('lvl', '等级')->display(function () {
@@ -37,6 +50,19 @@ class DealerManageSubsidyLogController extends AdminController
$grid->disableCreateButton();
$grid->disableActions();
$grid->header(function ($collection) use ($grid) {
+ return tap(new Row(), function ($row) use ($grid) {
+ $query = DealerManageSubsidyLogModel::query();
+
+ $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
+ if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
+ return;
+ }
+
+ $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ });
+
+ $row->column(3, new InfoBox('津贴总额', (clone $query)->sum('total_amount'), 'fa fa-cny'));
+ });
$query = DealerManageSubsidyLogModel::query();
// 拿到表格筛选 where 条件数组进行遍历
diff --git a/app/Admin/Repositories/DealerManageSubsidy.php b/app/Admin/Repositories/DealerManageSubsidy.php
new file mode 100644
index 00000000..32f3343a
--- /dev/null
+++ b/app/Admin/Repositories/DealerManageSubsidy.php
@@ -0,0 +1,16 @@
+get('dealer-manager-subsidies', 'DealerManagerSubsidyController@index')->name('dealer_manager_subsidies.index');
$router->get('dealer-manager-sales-logs', 'DealerManagerSalesLogController@index')->name('dealer_manager_sales_logs.index');
- //批零明细
+ // 管理津贴
+ $router->get('dealer-manage-subsidies', 'DealerManageSubsidyController@index')->name('dealer_manage_subsidies.index');
$router->get('dealer-manage-subsidy-logs', 'DealerManageSubsidyLogController@index')->name('dealer_manage_subsidy_logs.index');
+
$router->get('dealer-purchase-logs', 'DealerPurchaseLogController@index')->name('dealer_purchase_logs.index');
//批零余额提现
diff --git a/app/Enums/DealerManageSubsidyStatus.php b/app/Enums/DealerManageSubsidyStatus.php
index 2a6ed321..3dac0ed1 100644
--- a/app/Enums/DealerManageSubsidyStatus.php
+++ b/app/Enums/DealerManageSubsidyStatus.php
@@ -5,4 +5,25 @@ namespace App\Enums;
enum DealerManageSubsidyStatus: int {
case Pending = 0;
case Completed = 5;
+
+ public function color(): string
+ {
+ return match ($this) {
+ static::Pending => '#5b69bc',
+ static::Completed => '#21b978',
+ };
+ }
+
+ public function text(): string
+ {
+ return static::texts()[$this->value] ?? 'Unknown';
+ }
+
+ public static function texts(): array
+ {
+ return [
+ static::Pending->value => '待付款',
+ static::Completed->value => '已付款',
+ ];
+ }
}
diff --git a/app/Models/DealerManageSubsidy.php b/app/Models/DealerManageSubsidy.php
index 3c4f3a5c..fd7b74f0 100644
--- a/app/Models/DealerManageSubsidy.php
+++ b/app/Models/DealerManageSubsidy.php
@@ -38,6 +38,17 @@ class DealerManageSubsidy extends Model
'is_settle',
];
+ /**
+ * 仅查询已结算的管理津贴
+ *
+ * @param \Illuminate\Database\Eloquent\Builder $query
+ * @return \Illuminate\Database\Eloquent\Builder
+ */
+ public function scopeSettled($query)
+ {
+ return $query->where('is_settle', true);
+ }
+
/**
* 此管理津贴所属的经销商
*/
@@ -46,11 +57,31 @@ class DealerManageSubsidy extends Model
return $this->belongsTo(Dealer::class, 'user_id', 'user_id');
}
+ public function user()
+ {
+ return $this->belongsTo(User::class, 'user_id');
+ }
+
+ public function userinfo()
+ {
+ return $this->belongsTo(UserInfo::class, 'user_id', 'user_id');
+ }
+
public function earning()
{
return $this->morphOne(DealerEarning::class, 'earningable');
}
+ /**
+ * 仅查询待付款的管理津贴
+ *
+ * @return bool
+ */
+ public function isPending(): bool
+ {
+ return $this->is_settle && $this->status === DealerManageSubsidyStatus::Pending;
+ }
+
public function isCompleted()
{
return $this->status === DealerManageSubsidyStatus::Completed;
diff --git a/app/Services/Dealer/ManageSubsidyService.php b/app/Services/Dealer/ManageSubsidyService.php
new file mode 100644
index 00000000..24a50bdd
--- /dev/null
+++ b/app/Services/Dealer/ManageSubsidyService.php
@@ -0,0 +1,43 @@
+isPending()) {
+ throw new BizException('管理津贴 不是待付款状态');
+ }
+
+ $dealerManageSubsidy->update([
+ 'status' => DealerManageSubsidyStatus::Completed,
+ ]);
+
+ $dealerManageSubsidy->earning->update([
+ 'pay_way' => DealerEarning::PAY_WAY_WALLET,
+ 'pay_at' => now(),
+ 'pay_info' => null,
+ 'status' => DealerEarningStatus::Completed,
+ ]);
+
+ (new WalletService())->changeBalance(
+ $dealerManageSubsidy->user,
+ $dealerManageSubsidy->real_amount,
+ DealerWalletAction::ManageSubsidyIn,
+ '收入-管理津贴',
+ $dealerManageSubsidy
+ );
+ }
+}
diff --git a/database/seeders/AdminMenuSeeder.php b/database/seeders/AdminMenuSeeder.php
index f87da2cc..3b2a3654 100644
--- a/database/seeders/AdminMenuSeeder.php
+++ b/database/seeders/AdminMenuSeeder.php
@@ -342,7 +342,7 @@ class AdminMenuSeeder extends Seeder
[
'title'=>'管理者津贴',
'icon' => '',
- 'uri' => 'dealer-manager-subsidies',
+ 'uri' => 'dealer-earnings-manage?filter-earningable_type[]=dealer_manager_subsidy',
],
[
'title'=>'管理者津贴明细',
diff --git a/database/seeders/AdminPermissionSeeder.php b/database/seeders/AdminPermissionSeeder.php
index eaec93ee..6589ac4c 100644
--- a/database/seeders/AdminPermissionSeeder.php
+++ b/database/seeders/AdminPermissionSeeder.php
@@ -364,6 +364,14 @@ class AdminPermissionSeeder extends Seeder
'name' =>'管理者津贴明细',
'curd' => ['index'],
],
+ 'dealer_manage_subsidies' => [
+ 'name' =>'管理津贴',
+ 'curd' => ['index'],
+ 'children' => [
+ 'pay' => ['name' => '付款'],
+ 'batch_pay' => ['name' => '批量付款'],
+ ],
+ ],
'dealer_manage_subsidy_logs'=>[
'name' =>'管理津贴明细',
'curd' => ['index'],
From 4697f7f6b524c973edfb404e033df2c5009c05a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?=
Date: Mon, 7 Mar 2022 17:19:43 +0800
Subject: [PATCH 10/10] =?UTF-8?q?=E3=80=90=E5=90=8E=E5=8F=B0=E3=80=91?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=9B=E8=B4=A7=E8=A1=A5=E8=B4=B4=E6=98=8E?=
=?UTF-8?q?=E7=BB=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DealerPurchaseLogController.php | 34 ++++++++++++-------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/app/Admin/Controllers/DealerPurchaseLogController.php b/app/Admin/Controllers/DealerPurchaseLogController.php
index 8a3349ec..6a4e68ae 100644
--- a/app/Admin/Controllers/DealerPurchaseLogController.php
+++ b/app/Admin/Controllers/DealerPurchaseLogController.php
@@ -3,11 +3,14 @@
namespace App\Admin\Controllers;
use App\Admin\Repositories\DealerPurchaseLog;
+use App\Admin\Widgets\InfoBox;
use App\Models\DealerPurchaseLog as DealerPurchaseLogModel;
use App\Models\User;
+use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Row;
use Dcat\Admin\Show;
use Illuminate\Support\Facades\Request;
@@ -20,6 +23,15 @@ class DealerPurchaseLogController extends AdminController
*/
protected function grid()
{
+ Admin::style(
+ <<column('created_at')->sortable();
$grid->header(function ($collection) use ($grid) {
- $query = DealerPurchaseLogModel::query();
+ return tap(new Row(), function ($row) use ($grid) {
+ $query = DealerPurchaseLogModel::query();
- // 拿到表格筛选 where 条件数组进行遍历
- $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
- if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
- return;
- }
+ $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) {
+ if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) {
+ return;
+ }
- $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
+ });
+
+ $row->column(3, new InfoBox('进货业绩', (clone $query)->sum('total_amount'), 'fa fa-cny'));
});
-
- // 查出统计数据
- $totalAmount = (clone $query)->sum('total_amount');
- // 自定义组件
- return "金额:".$totalAmount.' 元
';
});
$grid->filter(function (Grid\Filter $filter) {