diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php
index cf569c79..b7e0152f 100644
--- a/app/Admin/Controllers/DealerEarningController.php
+++ b/app/Admin/Controllers/DealerEarningController.php
@@ -4,9 +4,13 @@ namespace App\Admin\Controllers;
use App\Admin\Repositories\DealerEarning;
use App\Models\DealerChannelSubsidyLog;
+use App\Models\DealerEarning as DealerEarningModel;
+use App\Models\DealerManagerSalesLog;
use App\Models\DealerManagerSubsidy;
use App\Models\DealerManageSubsidy;
+use App\Models\DealerManageSubsidyLog;
use App\Models\DealerPurchaseSubsidy;
+use App\Models\DealerPurchaseSubsidyLog;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
@@ -37,6 +41,13 @@ class DealerEarningController extends AdminController
(new DealerChannelSubsidyLog())->getMorphClass() =>'渠道补贴',
(new DealerPurchaseSubsidy())->getMorphClass() =>'进货补贴',
])->setColumnName('earningable_type'));
+ $grid->column('remark')->display('详情') // 设置按钮名称
+ ->expand(function () {
+ // 这里返回 content 字段内容,并用 Card 包裹起来
+ $card = new Card(null, $this->remark);
+
+ return "
$card
";
+ });
// $grid->column('earningable_type');
// $grid->column('earningable_id');
$grid->column('lvl')->display(function () {
@@ -48,12 +59,6 @@ class DealerEarningController extends AdminController
$grid->column('fee_rate')->append('%');
$grid->column('fee')->prepend('¥');
$grid->column('total_earnings')->prepend('¥');
- $grid->column('payer_id')->display(function () {
- return $this->payer_id ? $this->payer?->phone : '公司';
- });
- // $grid->column('pay_info');
- $grid->column('pay_at');
- $grid->column('settle_at');
$grid->column('status_format')->display(function ($value) {
return $this->status_format;
})->using([
@@ -62,14 +67,13 @@ class DealerEarningController extends AdminController
1 => '待收款',
2 => '已完成',
])->dot();
-
- $grid->column('remark')->display('详情') // 设置按钮名称
- ->expand(function () {
- // 这里返回 content 字段内容,并用 Card 包裹起来
- $card = new Card(null, $this->remark);
-
- return "$card
";
+ $grid->column('settle_at');
+ $grid->column('payer_id')->display(function () {
+ return $this->payer_id ? $this->payer?->phone : '公司';
});
+ // $grid->column('pay_info');
+ $grid->column('pay_at');
+
// $grid->column('pay_image');
$grid->column('created_at')->sortable();
$grid->actions(function (Grid\Displayers\Actions $actions) {
@@ -103,19 +107,71 @@ class DealerEarningController extends AdminController
$show->field('user.phone');
// $show->field('earningable_type');
// $show->field('earningable_id');
- $show->field('lvl');
- $show->field('is_manager');
- $show->field('total_amount');
- $show->field('total_earnings');
- $show->field('fee');
- $show->field('fee_rate');
- $show->field('payer_id');
+ $show->field('lvl')->as(function () {
+ return $this->lvl->text();
+ });
+ $show->field('is_manager')->as(function ($val) {
+ return $val ? '是' : '否';
+ });
+ $show->field('total_amount')->prepend('¥');
+ $show->field('fee_rate')->append('%');
+ $show->field('fee')->prepend('¥');
+ $show->field('total_earnings')->prepend('¥');
+ $show->field('payer.phone', '打款人')->as(function () {
+ return $this->payer_id ? $this->payer?->phone : '公司';
+ });
+ $show->field('pay_image');
// $show->field('pay_info');
$show->field('pay_at');
$show->field('settle_at');
// $show->field('status');
$show->field('remark');
- $show->field('pay_image');
+ //非(待结算)显示收款人信息
+ if ($show->model()->settle_at) {
+ $show->divider('收款信息-银行');
+ $show->field('bank_user_name', '银行-收款人')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['bank']['user_name']??'';
+ });
+ $show->field('bank_bank_name', '银行-名称')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['bank']['bank_name']??'';
+ });
+ $show->field('bank_bank_number', '银行-卡号')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['bank']['bank_number']??'';
+ });
+ $show->field('bank_bank_description', '银行-开户行')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['bank']['bank_description']??'';
+ });
+ $show->divider('收款信息-支付宝');
+ $show->field('alipay_user_name', '支付宝-真实名称')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['alipay']['user_name']??'';
+ });
+ $show->field('alipay_ali_name', '支付宝-账户')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['alipay']['ali_name']??'';
+ });
+ $show->field('alipay_image', '支付宝-收款码')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['alipay']['image']??'';
+ })->image();
+ $show->divider('收款信息-微信');
+ $show->field('wechat_user_name', '微信-真实名称')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['wechat']['user_name']??'';
+ });
+ $show->field('wechat_wechat_name', '微信-ID')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['wechat']['wechat_name']??'';
+ });
+ $show->field('wechat_image', '微信-收款码')->as(function () {
+ $payInfo = $this->getPayInfo();
+ return $payInfo['wechat']['image']??'';
+ })->image();
+ }
$show->field('created_at');
// $show->field('updated_at');
$show->panel()
@@ -126,7 +182,51 @@ class DealerEarningController extends AdminController
}));
});
$row->column(7, function ($column) use ($id) {
- $column->row(Box::make('明细记录', ''));
+ $earning = DealerEarningModel::with('earningable')->findOrFail($id);
+ $grid = '暂无记录';
+ switch (get_class($earning->earningable)) {
+ case DealerManagerSubsidy::class://管理者补贴
+ $builder = DealerManagerSalesLog::with(['order', 'product'])->where('user_id', $earning->earningable->user_id)->whereBetween('order_completed_at', [$earning->earningable->start_at, $earning->earningable->end_at]);
+ $grid = Grid::make($builder, function (Grid $grid) {
+ $grid->column('id');
+ $grid->column('order.sn', '订单编号');
+ $grid->column('product.name', '商品名称');
+ $grid->column('sales_volume', '销量');
+ $grid->column('order_completed_at', '结算时间');
+ $grid->disableCreateButton();
+ $grid->disableActions();
+ $grid->disablePagination();
+ });
+ break;
+ break;
+ case DealerManageSubsidy::class://管理补贴
+ $builder = DealerManageSubsidyLog::with(['order', 'product'])->where('user_id', $earning->earningable->user_id)->whereBetween('order_completed_at', [$earning->earningable->start_at, $earning->earningable->end_at]);
+ $grid = Grid::make($builder, function (Grid $grid) {
+ $grid->column('id');
+ $grid->column('order.sn', '订单编号');
+ $grid->column('product.name', '商品名称');
+ $grid->column('sales_volume', '销量');
+ $grid->column('total_amount', '金额');
+ $grid->column('order_completed_at', '结算时间');
+ $grid->disableCreateButton();
+ $grid->disableActions();
+ $grid->disablePagination();
+ });
+ break;
+ case DealerPurchaseSubsidy::class://进货补贴
+ $builder = DealerPurchaseSubsidyLog::where('purchase_subsidy_id', $earning->earningable_id);
+ $grid = Grid::make($builder, function (Grid $grid) {
+ $grid->column('id');
+ $grid->column('change_amount', '变更金额');
+ $grid->column('remark', '备注');
+ $grid->column('created_at', '结算时间');
+ $grid->disableCreateButton();
+ $grid->disableActions();
+ $grid->disablePagination();
+ });
+ break;
+ }
+ $column->row(Box::make('明细记录', $grid));
});
};
}
diff --git a/app/Models/DealerManageSubsidyLog.php b/app/Models/DealerManageSubsidyLog.php
index 52f7a939..0610dc25 100644
--- a/app/Models/DealerManageSubsidyLog.php
+++ b/app/Models/DealerManageSubsidyLog.php
@@ -3,10 +3,13 @@
namespace App\Models;
use App\Enums\DealerLvl;
+use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class DealerManageSubsidyLog extends Model
{
+ use HasDateTimeFormatter;
+
protected $casts = [
'lvl' => DealerLvl::class,
'order_completed_at' => 'datetime',
@@ -30,6 +33,14 @@ class DealerManageSubsidyLog extends Model
return $this->belongsTo(Dealer::class, 'user_id', 'user_id');
}
+ /**
+ * 此津贴所属订单
+ */
+ public function order()
+ {
+ return $this->belongsTo(Order::class, 'order_id');
+ }
+
/**
* 此管理津贴所属的商品
*/
diff --git a/app/Models/DealerPurchaseSubsidyLog.php b/app/Models/DealerPurchaseSubsidyLog.php
index 0dddc1a6..0dd60ca1 100644
--- a/app/Models/DealerPurchaseSubsidyLog.php
+++ b/app/Models/DealerPurchaseSubsidyLog.php
@@ -2,10 +2,13 @@
namespace App\Models;
+use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
class DealerPurchaseSubsidyLog extends Model
{
+ use HasDateTimeFormatter;
+
protected $fillable = [
'purchase_subsidy_id',
'change_from_purchase_subsidy_id',