6
0
Fork 0

调整批零资金返回

release
vine_liutk 2022-02-23 11:13:03 +08:00
parent 243d3700a5
commit 2a3f6c6953
7 changed files with 69 additions and 7 deletions

View File

@ -81,6 +81,11 @@ class DealerEarningController extends AdminController
return $this->payer_id ? $this->payer?->phone : '公司';
});
// $grid->column('pay_info');
$grid->column('pay_way')->using(DealerEarningModel::$payWayText)->label([
DealerEarningModel::PAY_WAY_WALLET=>'warning',
DealerEarningModel::PAY_WAY_OFFLINE=>'danger',
'none'=>'#b3b9bf',
]);
$grid->column('pay_at');
// $grid->column('pay_image');
@ -151,6 +156,11 @@ class DealerEarningController extends AdminController
$show->field('payer.phone', '打款人')->as(function () {
return $this->payer_id ? $this->payer?->phone : '公司';
});
$show->field('pay_way', '支付方式')->using(DealerEarningModel::$payWayText)->dot([
DealerEarningModel::PAY_WAY_WALLET=>'warning',
DealerEarningModel::PAY_WAY_OFFLINE=>'danger',
'none'=>'#b3b9bf',
]);
$show->field('pay_image')->image();
// $show->field('pay_info');
$show->field('pay_at');

View File

@ -30,13 +30,13 @@ class EarningController extends Controller
$user = $request->user();
switch ($cate) {
case 'pending'://
$query = $user->dealerPayEarnings()->onlyPending()->whereNotNull('settle_at');
$query = $user->dealerPayEarnings()->with('user')->onlyPending()->whereNotNull('settle_at');
break;
case 'paid':
$query = $user->dealerEarnings()->onlyPaid()->whereNotNull('settle_at');
break;
default://全部
$query = DealerEarning::where(function ($q) use ($user) {
$query = DealerEarning::with('user')->where(function ($q) use ($user) {
return $q->where('user_id', $user->id)->orWhere('payer_id', $user->id);
});
break;
@ -56,7 +56,7 @@ class EarningController extends Controller
public function show($id, Request $request)
{
$user = $request->user();
$earning = DealerEarning::where(function ($q) use ($user) {
$earning = DealerEarning::with(['user', 'user.userInfo'])->where(function ($q) use ($user) {
return $q->where('user_id', $user->id)->orWhere('payer_id', $user->id);
})->with('earningable')->findOrFail($id);
return DealerEarningResource::make($earning);
@ -90,10 +90,10 @@ class EarningController extends Controller
'pay_password' => '支付密码',
]);
$payWay = $input['pay_way'] ?? 'offline';
$payWay = $input['pay_way'] ?? DealerEarning::PAY_WAY_OFFLINE;
if (
$payWay === 'wallet' &&
$payWay === DealerEarning::PAY_WAY_WALLET &&
!$user->wallet?->verifyPassword($input['pay_password'])
) {
throw new PayPasswordIncorrectException();
@ -103,7 +103,7 @@ class EarningController extends Controller
try {
DB::beginTransaction();
switch ($payWay) {
case 'wallet':
case DealerEarning::PAY_WAY_WALLET:
//支付余额
$walletService = new WalletService();
@ -129,14 +129,16 @@ class EarningController extends Controller
$earning->update([
'status' => DealerEarningStatus::Completed,
'pay_way' => DealerEarning::PAY_WAY_WALLET,
'pay_info' => $earning->getPayInfo(),
'pay_at' => now(),
]);
break;
case 'offline':
case DealerEarning::PAY_WAY_OFFLINE:
$earning->update([
'status' => DealerEarningStatus::Paid,
'pay_way' => DealerEarning::PAY_WAY_OFFLINE,
'pay_info' => $earning->getPayInfo(),
'pay_image'=> $input['pay_image'],
'pay_at' => now(),

View File

@ -27,11 +27,16 @@ class DealerEarningResource extends JsonResource
'status' => $this->status_format,
'status_name' => $this->status_name,
'remark' => $this->remark,
'pay_way' => $this->pay_way ?? '',
'pay_info' => $this->getPayInfo(),
'pay_image' => $this->pay_image,
'pay_at' => $this->pay_at?->toDateTimeString(),
'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false,
'purchase_subsidy_logs' => $purchaseSubsidyLogs ? DealerEarningSubsidyLogResource::collection($purchaseSubsidyLogs) : null,
'beneficiary' => $this->user ? [
'nickname' => $this->user->userInfo?->nickname ?? '',
'phone'=>$this->user->phone ?? '',
] : null,
];
}
}

View File

@ -22,6 +22,7 @@ class DealerEarningSimpleResource extends JsonResource
'status' => $this->status_format,
'status_name' => $this->status_name,
'is_payer' => $this->payer_id ? ($this->payer_id == $request->user()->id) : false,
'beneficiary_phone' => $this->user?->phone ?? '',
// 'settle_at'
];
}

View File

@ -18,6 +18,9 @@ class DealerEarning extends Model
'status' => DealerEarningStatus::Pending,
];
public const PAY_WAY_WALLET = 'wallet'; // 余额
public const PAY_WAY_OFFLINE = 'offline'; // 线下支付
protected $casts = [
'lvl' => DealerLvl::class,
'status' => DealerEarningStatus::class,
@ -42,6 +45,12 @@ class DealerEarning extends Model
'settle_at',
'status',
'remark',
'pay_way',
];
public static $payWayText = [
self::PAY_WAY_WALLET => '余额支付',
self::PAY_WAY_OFFLINE => '线下打款',
];
public function user()

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPayWayToDealerEarningsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('dealer_earnings', function (Blueprint $table) {
//
$table->string('pay_way')->nullable()->comment('1线下打款,2余额');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('dealer_earnings', function (Blueprint $table) {
//
$table->dropColumn('pay_way');
});
}
}

View File

@ -27,6 +27,7 @@ return [
'status_format' => '状态',
'remark' => '备注',
'pay_image' => '打款凭证',
'pay_way'=>'支付方式',
],
'options' => [
],