配额日志
parent
b67600d552
commit
e35656f87d
|
|
@ -49,14 +49,18 @@ class PreIncomeSettleCommand extends Command
|
||||||
);
|
);
|
||||||
|
|
||||||
// 计算配额
|
// 计算配额
|
||||||
$quota = round(bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4), 3);
|
$changeQuota = bcmul($preIncome->total_revenue, app_settings('distribution.quota_v2_rate', 0), 4);
|
||||||
|
$changeQuota = round($changeQuota, 3);
|
||||||
|
|
||||||
$preIncome->user->userInfo()->update([
|
$preIncome->user->userInfo()->update([
|
||||||
'quota_v2' => DB::raw("quota_v2+{$quota}"),
|
'quota_v2' => DB::raw("quota_v2+{$changeQuota}"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$preIncome->user->quotaLogs()->create([
|
$preIncome->user->quotaLogs()->create([
|
||||||
'loggable_id' => $preIncome->id,
|
'loggable_id' => $preIncome->id,
|
||||||
'loggable_type' => $preIncome->getMorphClass(),
|
'loggable_type' => $preIncome->getMorphClass(),
|
||||||
'change_quota' => $quota,
|
'change_quota' => $changeQuota,
|
||||||
|
'remarks' => $preIncome->type_text.'得配额',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// 将预收益标记为已结算
|
// 将预收益标记为已结算
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Endpoint\Api\Http\Controllers\Merchant;
|
||||||
|
|
||||||
|
use App\Endpoint\Api\Http\Controllers\Controller;
|
||||||
|
use App\Endpoint\Api\Http\Resources\QuotaLogResource;
|
||||||
|
use App\Helpers\Paginator as PaginatorHelper;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class QuotaLogController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 配额日志
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
$perPage = PaginatorHelper::resolvePerPage('per_page', 20, 50);
|
||||||
|
|
||||||
|
$quotaLogs = $request->user()
|
||||||
|
->quotaLogs()
|
||||||
|
->latest('id')
|
||||||
|
->simplePaginate($perPage);
|
||||||
|
|
||||||
|
return QuotaLogResource::collection($quotaLogs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Endpoint\Api\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class QuotaLogResource 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 [
|
||||||
|
'change_quota' => $this->change_quota,
|
||||||
|
'remarks' => (string) $this->remarks,
|
||||||
|
'created_at' => $this->created_at->toDateTimeString(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -182,9 +182,11 @@ Route::group([
|
||||||
],
|
],
|
||||||
], function () {
|
], function () {
|
||||||
Route::get('account', [Merchant\UserController::class, 'account']);
|
Route::get('account', [Merchant\UserController::class, 'account']);
|
||||||
// 个人销售值
|
// 配额日志
|
||||||
|
Route::get('quota-logs', [Merchant\QuotaLogController::class, 'index']);
|
||||||
|
// 个人销售值日志
|
||||||
Route::get('sales-value-logs', [Merchant\SalesValueLogController::class, 'index']);
|
Route::get('sales-value-logs', [Merchant\SalesValueLogController::class, 'index']);
|
||||||
// 团队销售值
|
// 团队销售值日志
|
||||||
Route::get('team-sales-value-logs', [Merchant\TeamSalesValueLogController::class, 'index']);
|
Route::get('team-sales-value-logs', [Merchant\TeamSalesValueLogController::class, 'index']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class DistributionPreIncome extends Model
|
||||||
public static $typeTexts = [
|
public static $typeTexts = [
|
||||||
self::TYPE_PRICE_DIFF => '推粉丝赚差价',
|
self::TYPE_PRICE_DIFF => '推粉丝赚差价',
|
||||||
self::TYPE_LEVEL_SAME => '平级奖励',
|
self::TYPE_LEVEL_SAME => '平级奖励',
|
||||||
self::TYPE_LEVEL_DIFF => '级差奖金',
|
self::TYPE_LEVEL_DIFF => '级差奖励',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -117,4 +117,14 @@ class DistributionPreIncome extends Model
|
||||||
{
|
{
|
||||||
return UserInfo::$agentLevelTexts[$this->agent_level] ?? '未知';
|
return UserInfo::$agentLevelTexts[$this->agent_level] ?? '未知';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取类型文本
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTypeTextAttribute(): string
|
||||||
|
{
|
||||||
|
return static::$typeTexts[$this->type] ?? '其它';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,6 @@ class QuotaLog extends Model
|
||||||
'loggable_id',
|
'loggable_id',
|
||||||
'loggable_type',
|
'loggable_type',
|
||||||
'change_quota',
|
'change_quota',
|
||||||
|
'remarks',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddRemarksToQuotaLogsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('quota_logs', function (Blueprint $table) {
|
||||||
|
$table->string('remarks')->nullable()->comment('备注');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('quota_logs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['remarks']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue