feat: add syj promote workflow
This commit is contained in:
119
pro_v3.5.1/app/controller/admin/v1/syj/PromoteController.php
Normal file
119
pro_v3.5.1/app/controller/admin/v1/syj/PromoteController.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\controller\admin\v1\syj;
|
||||
|
||||
use app\controller\admin\AuthController;
|
||||
use app\services\syj\SyjPromoteConfigServices;
|
||||
use app\services\syj\SyjPromoteRewardTriggerServices;
|
||||
use app\services\syj\SyjPromoteSettlementServices;
|
||||
use app\services\syj\SyjPromoteTaskServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class PromoteController extends AuthController
|
||||
{
|
||||
#[Inject]
|
||||
protected SyjPromoteTaskServices $services;
|
||||
|
||||
#[Inject]
|
||||
protected SyjPromoteSettlementServices $settlementServices;
|
||||
|
||||
#[Inject]
|
||||
protected SyjPromoteConfigServices $configServices;
|
||||
|
||||
#[Inject]
|
||||
protected SyjPromoteRewardTriggerServices $triggerServices;
|
||||
|
||||
public function taskList(): mixed
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['keyword', ''],
|
||||
['status', ''],
|
||||
['reward_trigger_status', ''],
|
||||
['start_time', ''],
|
||||
['end_time', ''],
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
]);
|
||||
$page = (int)$where['page'];
|
||||
$limit = (int)$where['limit'];
|
||||
unset($where['page'], $where['limit']);
|
||||
return $this->success($this->services->adminTasks($where, $page, $limit));
|
||||
}
|
||||
|
||||
public function taskDetail(int $id): mixed
|
||||
{
|
||||
return $this->success($this->services->adminTaskDetail($id));
|
||||
}
|
||||
|
||||
public function taskRecords(int $id): mixed
|
||||
{
|
||||
return $this->success($this->services->records($id));
|
||||
}
|
||||
|
||||
public function cashoutList(): mixed
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['keyword', ''],
|
||||
['audit_status', ''],
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
]);
|
||||
$where['settle_type'] = 'early_cashout';
|
||||
$page = (int)$where['page'];
|
||||
$limit = (int)$where['limit'];
|
||||
unset($where['page'], $where['limit']);
|
||||
return $this->success($this->settlementServices->adminList($where, $page, $limit));
|
||||
}
|
||||
|
||||
public function settlementList(): mixed
|
||||
{
|
||||
$where = $this->request->getMore([
|
||||
['keyword', ''],
|
||||
['audit_status', ''],
|
||||
['settle_type', ''],
|
||||
['page', 1],
|
||||
['limit', 20],
|
||||
]);
|
||||
$page = (int)$where['page'];
|
||||
$limit = (int)$where['limit'];
|
||||
unset($where['page'], $where['limit']);
|
||||
return $this->success($this->settlementServices->adminList($where, $page, $limit));
|
||||
}
|
||||
|
||||
public function auditCashout(int $id): mixed
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['status', 1],
|
||||
['remark', ''],
|
||||
]);
|
||||
$this->settlementServices->auditCashout($id, (int)$this->adminId, (int)$data['status'], (string)$data['remark']);
|
||||
return $this->success('审核成功');
|
||||
}
|
||||
|
||||
public function getConfig(): mixed
|
||||
{
|
||||
return $this->success($this->configServices->getConfig());
|
||||
}
|
||||
|
||||
public function saveConfig(): mixed
|
||||
{
|
||||
$data = $this->request->postMore([
|
||||
['base_amount', 4333],
|
||||
['target_count', 4],
|
||||
['reward_rates', [10, 20, 30, 40]],
|
||||
['early_cashout_fee_rate', 7],
|
||||
['task_generate_timing', 'on_confirm'],
|
||||
['task_order_dedupe', 'order'],
|
||||
['reward_trigger_enable', 1],
|
||||
]);
|
||||
$this->configServices->saveConfig($data);
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
|
||||
public function retryTrigger(int $taskId): mixed
|
||||
{
|
||||
$this->triggerServices->retry($taskId);
|
||||
return $this->success('重试完成');
|
||||
}
|
||||
}
|
||||
66
pro_v3.5.1/app/controller/api/v1/syj/PromoteController.php
Normal file
66
pro_v3.5.1/app/controller/api/v1/syj/PromoteController.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\controller\api\v1\syj;
|
||||
|
||||
use app\Request;
|
||||
use app\services\syj\SyjPromoteSettlementServices;
|
||||
use app\services\syj\SyjPromoteTaskServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class PromoteController
|
||||
{
|
||||
#[Inject]
|
||||
protected SyjPromoteTaskServices $services;
|
||||
|
||||
#[Inject]
|
||||
protected SyjPromoteSettlementServices $settlementServices;
|
||||
|
||||
public function overview(Request $request): mixed
|
||||
{
|
||||
return app('json')->success($this->services->overview((int)$request->uid()));
|
||||
}
|
||||
|
||||
public function taskList(Request $request): mixed
|
||||
{
|
||||
[$page, $limit] = $this->page($request);
|
||||
$where = ['status' => $request->param('status', '')];
|
||||
return app('json')->success($this->services->userTasks((int)$request->uid(), $where, $page, $limit));
|
||||
}
|
||||
|
||||
public function taskDetail(Request $request, int $id): mixed
|
||||
{
|
||||
return app('json')->success($this->services->userTaskDetail((int)$request->uid(), $id));
|
||||
}
|
||||
|
||||
public function taskRecords(Request $request, int $id): mixed
|
||||
{
|
||||
$task = $this->services->userTaskDetail((int)$request->uid(), $id);
|
||||
return app('json')->success($task['records'] ?? []);
|
||||
}
|
||||
|
||||
public function cashout(Request $request, int $id): mixed
|
||||
{
|
||||
return app('json')->success($this->settlementServices->applyCashout((int)$request->uid(), $id), '提交成功');
|
||||
}
|
||||
|
||||
public function amountLog(Request $request): mixed
|
||||
{
|
||||
[$page, $limit] = $this->page($request);
|
||||
return app('json')->success($this->services->amountLogs((int)$request->uid(), $page, $limit));
|
||||
}
|
||||
|
||||
public function settlementList(Request $request): mixed
|
||||
{
|
||||
[$page, $limit] = $this->page($request);
|
||||
return app('json')->success($this->settlementServices->listForUser((int)$request->uid(), $page, $limit));
|
||||
}
|
||||
|
||||
private function page(Request $request): array
|
||||
{
|
||||
return [
|
||||
max(1, (int)$request->param('page', 1)),
|
||||
min(50, max(1, (int)$request->param('limit', 15))),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user