添加老配额接口
parent
f376f58fe2
commit
71ed5fd889
|
|
@ -46,7 +46,7 @@ class DistributionPreIncomeController extends AdminController
|
|||
1=>'danger',
|
||||
2=>'success',
|
||||
]);
|
||||
$grid->column('remarks');
|
||||
// $grid->column('remarks');
|
||||
$grid->column('completed_at');
|
||||
$grid->column('created_at')->sortable();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,14 @@ class OrderController extends AdminController
|
|||
$builder = Order::with(['user', 'tags']);
|
||||
|
||||
return Grid::make($builder, function (Grid $grid) {
|
||||
// $grid->column('id')->sortable();
|
||||
$grid->column('id')->sortable()->if(function () {
|
||||
return Admin::user()->can('dcat.admin.orders.show');
|
||||
})->then(function (Column $column) {
|
||||
$column->link(function ($value) {
|
||||
return admin_route('orders.show', ['order' => $value]);
|
||||
});
|
||||
});
|
||||
|
||||
$grid->tools(function (Grid\Tools $tools) {
|
||||
//设置规格
|
||||
if (Admin::user()->can('dcat.admin.orders.export_shipping_orders')) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ class Distribution extends Form
|
|||
|
||||
// dd($appSettings, app_settings('distribution'));
|
||||
|
||||
$this->number('quota_v1_receive', '老配额分红领取时间(小时)')
|
||||
->min(0)->value($appSettings['quota_v1_receive'] ?? 0)
|
||||
->help('从发放配额分红开始后N小时内可以领取');
|
||||
|
||||
$this->text('settle_days', '订单结算时间(天)')
|
||||
->value($appSettings['settle_days'] ?? 0)
|
||||
->rules('required|numeric|min:0')
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Endpoint\Api\Http\Controllers\Auth;
|
||||
|
||||
use App\Constants\Device;
|
||||
use App\Endpoint\Api\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
|
|
@ -17,6 +18,24 @@ class LogoutController extends Controller
|
|||
{
|
||||
if ($user = $request->user()) {
|
||||
$user->currentAccessToken()->delete();
|
||||
|
||||
// 获取登录设备
|
||||
$device = $request->header('client-app', Device::UNIAPP);
|
||||
|
||||
switch ($device) {
|
||||
case Device::MERCHANT:
|
||||
//解绑用户商家端cid
|
||||
$user->cid->update([
|
||||
'm_cid'=>null,
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
//解绑用户商城端cid
|
||||
$user->cid->update([
|
||||
'u_cid'=>null,
|
||||
]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->noContent();
|
||||
|
|
|
|||
|
|
@ -4,8 +4,15 @@ namespace App\Endpoint\Api\Http\Controllers\Merchant;
|
|||
|
||||
use App\Endpoint\Api\Http\Controllers\Controller;
|
||||
use App\Endpoint\Api\Http\Resources\QuotaLogResource;
|
||||
use App\Endpoint\Api\Http\Resources\QuotaV1LogResource;
|
||||
use App\Exceptions\BizException;
|
||||
use App\Helpers\Paginator as PaginatorHelper;
|
||||
use App\Models\QuotaV1SendLog;
|
||||
use App\Models\WalletLog;
|
||||
use App\Services\WalletService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class QuotaLogController extends Controller
|
||||
{
|
||||
|
|
@ -26,4 +33,38 @@ class QuotaLogController extends Controller
|
|||
|
||||
return QuotaLogResource::collection($quotaLogs);
|
||||
}
|
||||
|
||||
public function quotaV1Logs(Request $request)
|
||||
{
|
||||
$perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50);
|
||||
return QuotaV1LogResource::collection(
|
||||
QuotaV1SendLog::where('user_id', $request->user()->id)
|
||||
->receive()->latest('id')
|
||||
->simplePaginate($perPage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取老配额分红
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function receiveQuotaV1(Request $request, WalletService $walletService)
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
foreach (QuotaV1SendLog::where('user_id', $user->id)->waitReceive()->cursor() as $log) {
|
||||
$log->update(['status'=>1]);
|
||||
$walletService->changeBalance($user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
|
||||
}
|
||||
DB::commit();
|
||||
} catch (Throwable $th) {
|
||||
DB::rollBack();
|
||||
report($th);
|
||||
|
||||
throw new BizException('领取失败,稍后再试');
|
||||
}
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Endpoint\Api\Http\Controllers\Controller;
|
|||
use App\Endpoint\Api\Http\Resources\Merchant\UserInfoResource;
|
||||
use App\Endpoint\Api\Http\Resources\UserBalanceResource;
|
||||
use App\Endpoint\Api\Http\Resources\UserWalletResource;
|
||||
use App\Models\QuotaV1SendLog;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UserController extends Controller
|
||||
|
|
@ -46,6 +47,8 @@ class UserController extends Controller
|
|||
'sales_value' => $user->userInfo->growth_value,
|
||||
// 总预收益
|
||||
'total_pre_revenue' => $user->getTotalPreRevenue(),
|
||||
// 待领取老配额分红
|
||||
'wait_receive_quota_v1_amount' => bcdiv(QuotaV1SendLog::where('user_id', $user->id)->waitReceive()->sum('amount'), 100, 2),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class AfterSaleResource extends JsonResource
|
|||
'description' => $this->description,
|
||||
'remarks' => $this->remarks,
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
'amount'=> $this->amount_format,
|
||||
// 'logs' => AfterSaleLogResource::make($this->whenLoaded('logs')),
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Endpoint\Api\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class QuotaV1LogResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'remarks' => (string) '老配额分红',
|
||||
'amount' => $this->amount_format,
|
||||
'created_at' => $this->created_at->toDateTimeString(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -202,5 +202,9 @@ Route::group([
|
|||
Route::get('agent-statistics', [Merchant\AgentController::class, 'statistics']);
|
||||
// 消息列表
|
||||
Route::get('messages', [Merchant\MessageController::class, 'index']);
|
||||
// 领取老配额分红
|
||||
Route::post('receive-quota-v1', [Merchant\QuotaLogController::class, 'receiveQuotaV1']);
|
||||
// 老配额领取记录
|
||||
Route::get('quota-v1-logs', [Merchant\QuotaLogController::class, 'quotaV1Logs']);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -77,6 +77,16 @@ class AfterSale extends Model
|
|||
return $afterSaleState;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取格式化售后金额
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAmountFormatAttribute()
|
||||
{
|
||||
return trim_trailing_zeros(bcdiv($this->attributes['amount'], 100, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅查询处理中的售后订单
|
||||
*
|
||||
|
|
|
|||
|
|
@ -31,4 +31,30 @@ class QuotaV1SendLog extends Model
|
|||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function scopeReceive($query)
|
||||
{
|
||||
return $query->where('status', static::STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
public function scopeWaitReceive($query)
|
||||
{
|
||||
$query->where('status', static::STATUS_FAILED);
|
||||
|
||||
if ($hours = app_settings('quota_v1_receive', 0)) {
|
||||
return $query->where('created_at', '>', now()->subHours($hours));
|
||||
} else {
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取格式化售后金额
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAmountFormatAttribute()
|
||||
{
|
||||
return trim_trailing_zeros(bcdiv($this->attributes['amount'], 100, 2));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@ class AppSettingSeeder extends Seeder
|
|||
'lvl_same_bonus_fee_rate' => '0',
|
||||
// 级差奖励手续费
|
||||
'lvl_diff_bonus_fee_rate' => '0.10',
|
||||
// 老配额分红领取过期时间(小时)
|
||||
'quota_v1_receive' => 72,
|
||||
|
||||
// 代理等级分润规则
|
||||
'rules' => [
|
||||
|
|
|
|||
Loading…
Reference in New Issue