|
@@ -3,8 +3,15 @@
|
|
|
namespace app\controller\admin;
|
|
namespace app\controller\admin;
|
|
|
|
|
|
|
|
use app\extra\basic\Base;
|
|
use app\extra\basic\Base;
|
|
|
|
|
+use app\extra\service\blue\TaskService;
|
|
|
|
|
+use app\extra\tools\CodeExtend;
|
|
|
use app\extra\tools\XcJob;
|
|
use app\extra\tools\XcJob;
|
|
|
use app\middleware\AuthMiddleware;
|
|
use app\middleware\AuthMiddleware;
|
|
|
|
|
+use app\model\blue\BlueCategory;
|
|
|
|
|
+use app\model\blue\BlueExpertLevel;
|
|
|
|
|
+use app\model\blue\BlueTask;
|
|
|
|
|
+use app\model\system\SystemData;
|
|
|
|
|
+use DI\Attribute\Inject;
|
|
|
use LinFly\Annotation\Route\Controller;
|
|
use LinFly\Annotation\Route\Controller;
|
|
|
use LinFly\Annotation\Route\Middleware;
|
|
use LinFly\Annotation\Route\Middleware;
|
|
|
use LinFly\Annotation\Route\Route;
|
|
use LinFly\Annotation\Route\Route;
|
|
@@ -16,6 +23,98 @@ use support\Response;
|
|
|
class Task extends Base
|
|
class Task extends Base
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ #[Inject]
|
|
|
|
|
+ protected TaskService $service;
|
|
|
|
|
+
|
|
|
|
|
+ #[Inject]
|
|
|
|
|
+ protected BlueTask $model;
|
|
|
|
|
+
|
|
|
|
|
+ #[Route(path: "list",methods: "get")]
|
|
|
|
|
+ public function getCategoryData(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $request->all();
|
|
|
|
|
+ $list = $this->service->getList($param);
|
|
|
|
|
+ return successTrans("success.data",pageFormat($list),200);
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 编辑信息
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return Response
|
|
|
|
|
+ */
|
|
|
|
|
+ #[Route(path: "save",methods: "post")]
|
|
|
|
|
+ public function setListData(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $request->post();
|
|
|
|
|
+ if (!isset($param['id'])) {
|
|
|
|
|
+ $param['task_sn'] = CodeExtend::random(16);
|
|
|
|
|
+ $job = $this->model->where("job_id",$param['job_id'])->findOrEmpty();
|
|
|
|
|
+ if (!$job->isEmpty()) return error("该任务已添加");
|
|
|
|
|
+ }
|
|
|
|
|
+ $param['total_budget'] = !empty($param['total_budget']) ? $param['total_budget']*100 : 0;
|
|
|
|
|
+ $state = $this->model->setAutoData($param);
|
|
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
|
|
+ return successTrans("success.data");
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量操作
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return Response
|
|
|
|
|
+ */
|
|
|
|
|
+ #[Route(path: "batch",methods: "post")]
|
|
|
|
|
+ public function setGoodsBatch(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $this->_valid([
|
|
|
|
|
+ "id.require" => "参数错误",
|
|
|
|
|
+ "value.require" => "参数错误",
|
|
|
|
|
+ "field.require" => "参数错误",
|
|
|
|
|
+ "type.require" => "参数错误"
|
|
|
|
|
+ ],"post");
|
|
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
|
|
+ if ($param['type'] == "batch") {
|
|
|
|
|
+ $state = $this->model->where("id","in",$param['id'])->save([$param['field'] => $param['value']]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $state = $this->model->where("id",$param['id'])->save([$param['field'] => $param['value']]);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
|
|
+ return successTrans("success.data");
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return Response
|
|
|
|
|
+ */
|
|
|
|
|
+ #[Route(path: "del",methods: "post")]
|
|
|
|
|
+ public function delData(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $this->_valid([
|
|
|
|
|
+ "id.require" => "参数错误",
|
|
|
|
|
+ ],"post");
|
|
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
|
|
+ $data = $this->model->where("id",$param['id'])->findOrEmpty();
|
|
|
|
|
+ if ($data->isEmpty()) return errorTrans("empty.data");
|
|
|
|
|
+ $state = $data->delete();
|
|
|
|
|
+ if (!$state) return errorTrans("error.data");
|
|
|
|
|
+ return successTrans("success.data");
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取星川任务详情
|
|
* 获取星川任务详情
|
|
@@ -45,7 +144,7 @@ class Task extends Base
|
|
|
"product_selling_point" => $data['object_field_info']['object_product_info']['product_selling_point_detail']??'',
|
|
"product_selling_point" => $data['object_field_info']['object_product_info']['product_selling_point_detail']??'',
|
|
|
"target_audience" => $data['object_field_info']['object_product_info']['target_audience_desc']??'',
|
|
"target_audience" => $data['object_field_info']['object_product_info']['target_audience_desc']??'',
|
|
|
"content" => $data['object_field_info']['object_requirement_info']['author_preference']?nl2br($data['object_field_info']['object_requirement_info']['author_preference']):'',
|
|
"content" => $data['object_field_info']['object_requirement_info']['author_preference']?nl2br($data['object_field_info']['object_requirement_info']['author_preference']):'',
|
|
|
- "total_budget" => $data['object_field_info']['object_project_info']['total_budget_fen']?format_money_bit($data['object_field_info']['object_project_info']['total_budget_fen']/100):'',
|
|
|
|
|
|
|
+ "total_budget" => $data['object_field_info']['object_project_info']['total_budget_fen']?format_money($data['object_field_info']['object_project_info']['total_budget_fen']/100):'',
|
|
|
];
|
|
];
|
|
|
return success("ok",$task);
|
|
return success("ok",$task);
|
|
|
} catch (\Throwable $throwable) {
|
|
} catch (\Throwable $throwable) {
|
|
@@ -53,4 +152,27 @@ class Task extends Base
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ #[Route(path: "param",methods: "get")]
|
|
|
|
|
+ public function getTaskParam(Request $request): Response
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $param = $this->_valid([
|
|
|
|
|
+ "type.default" => "douyin"
|
|
|
|
|
+ ],$request->all());
|
|
|
|
|
+ if (!is_array($param)) return error($param);
|
|
|
|
|
+ $category = (new BlueCategory)->where("type",1)->select()->toArray();
|
|
|
|
|
+ $level = (new BlueExpertLevel)->where("status",1)->append(['start_format','end_format'])->withAttr(['start_format' => function ($data,$resp) {
|
|
|
|
|
+ return formatMoneyKw($resp['gmv_start']);
|
|
|
|
|
+ },'end_format' => function ($data,$resp) {
|
|
|
|
|
+ return formatMoneyKw($resp['gmv_end']);
|
|
|
|
|
+ }])->select()->toArray();
|
|
|
|
|
+ $dicData = (new SystemData)->where("code",$param['type'])->value("content");
|
|
|
|
|
+ $dic = empty($dicData)?[]:json_decode($dicData,true);
|
|
|
|
|
+ return success("ok",compact("category","level","dic"));
|
|
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
|
|
+ return error($throwable->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|