zory пре 4 часа
родитељ
комит
516e8286ba

+ 71 - 0
app/controller/merchant/Plan.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace app\controller\merchant;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasLivePlan;
+use app\service\saas\PlanService;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Attributes\Route\Controller;
+use LinFly\Annotation\Attributes\Route\GetMapping;
+use LinFly\Annotation\Attributes\Route\Middleware;
+use LinFly\Annotation\Attributes\Route\PostMapping;
+use support\Request;
+use support\Response;
+use function DI\get;
+
+
+#[Controller("/api/merchant/plan"),Middleware(AuthMiddleware::class)]
+class Plan extends Base
+{
+
+    #[Inject]
+    protected PlanService $service;
+
+    #[Inject]
+    protected SaasLivePlan $model;
+
+    #[GetMapping('list')]
+    public function getPlanList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $param['poi_id'] = $request->user['store_id'];
+            $data = $this->service->setModel()->getList($param);
+            return successTrans(100010,pageFormat($data),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 发布佣金计划
+     * @param Request $request
+     * @return Response|void
+     */
+    #[PostMapping('save')]
+    public function addPlanData(Request $request)
+    {
+        try {
+            $param = $this->_valid([
+                "plan_name.require"         => trans("empty.require"),
+                "merchant_phone.require"    => trans("empty.require"),
+                "status.require"            => trans("empty.require"),
+                "goods.require"             => trans("empty.require"),
+                "star.require"              => trans("empty.require"),
+                "plan_id.default"           => 0,
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $plan = $this->model->where("plan_id",$param['plan_id'])->findOrEmpty();
+            if ($plan->isEmpty()) { // 新增
+
+            } else { // 编辑
+
+            }
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 27 - 0
app/extra/dyMini/PlanLive.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace app\extra\dyMini;
+
+use app\extra\dyLife\BasicLife;
+use yzh52521\EasyHttp\Http;
+
+class PlanLive extends BasicLife
+{
+
+    /**
+     * 发布/修改直播间定向佣金计划
+     * @param int $planId
+     * @return array
+     */
+    public function planData(int $planId = 0): array
+    {
+        $param = [
+            "plan_id"           => $planId, // 大于0 编辑
+            "merchant_phone"    => "",
+            "douyin_id_list"    => "",
+            "product_list"      => []
+        ];
+        return $this->curlPostApi("api/match/v2/poi/save_live_oriented_plan/",$param);
+    }
+
+}

+ 47 - 0
app/model/saas/SaasLivePlan.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $poi_id 门店ID
+ * @property string $plan_name 
+ * @property string $merchant_phone 
+ * @property integer $status 
+ * @property mixed $create_at
+ */
+class SaasLivePlan extends Model
+{
+    /**
+     * The connection name for the model.
+     *
+     * @var string|null
+     */
+    protected $connection = 'mysql';
+    
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected string $table = "saas_live_plan";
+    
+    /**
+     * The primary key associated with the table.
+     *
+     * @var string
+     */
+    protected string $primaryKey = "id";
+    
+    /**
+     * Indicates if the model should be timestamped.
+     *
+     * @var bool
+     */
+    public bool $timestamps = false;
+
+
+}

+ 44 - 0
app/model/saas/SaasLivePlanGoods.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $plan_id 
+ * @property mixed $goods_id
+ */
+class SaasLivePlanGoods extends Model
+{
+    /**
+     * The connection name for the model.
+     *
+     * @var string|null
+     */
+    protected $connection = 'mysql';
+    
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected string $table = "saas_live_plan_goods";
+    
+    /**
+     * The primary key associated with the table.
+     *
+     * @var string
+     */
+    protected string $primaryKey = "id";
+    
+    /**
+     * Indicates if the model should be timestamped.
+     *
+     * @var bool
+     */
+    public bool $timestamps = false;
+
+
+}

+ 44 - 0
app/model/saas/SaasLivePlanStar.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $plan_id 
+ * @property string $unique_id 抖音号
+ */
+class SaasLivePlanStar extends Model
+{
+    /**
+     * The connection name for the model.
+     *
+     * @var string|null
+     */
+    protected $connection = 'mysql';
+    
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected string $table = "saas_live_plan_star";
+    
+    /**
+     * The primary key associated with the table.
+     *
+     * @var string
+     */
+    protected string $primaryKey = "id";
+    
+    /**
+     * Indicates if the model should be timestamped.
+     *
+     * @var bool
+     */
+    public bool $timestamps = false;
+
+
+}

+ 1 - 1
app/service/saas/GoodsService.php

@@ -43,7 +43,7 @@ class GoodsService extends Service
     public function searchFilter(array $param = []): array
     {
         $filter = [];
-        !empty($param['status']) && $filter[] = ["enable", '=', $param['status']];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
         !empty($param['poi_id']) && $filter[] = ["poi_id", '=', $param['poi_id']];
         !empty($param['name']) && $filter[] = ["product_name", 'like', "%{$param['name']}%"];
         return $filter;

+ 37 - 0
app/service/saas/PlanService.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\service\saas;
+
+use app\extra\basic\Service;
+use app\model\saas\SaasLivePlan;
+
+class PlanService extends Service
+{
+
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel()
+    {
+        $this->mode = (new SaasLivePlan);
+        return $this;
+    }
+
+
+    /**
+     *
+     * @param array $param
+     * @return array
+     */
+    public function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['poi_id']) && $filter[] = ["poi_id", '=', $param['poi_id']];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['name']) && $filter[] = ["plan_name", 'like', "%{$param['name']}%"];
+        return $filter;
+    }
+
+}

+ 1 - 0
app/service/saas/StarService.php

@@ -28,6 +28,7 @@ class StarService extends Service
     {
         $filter = [];
         !empty($param['name']) && $filter[] = ["nick_name", 'like', "%{$param['name']}%"];
+        !empty($param['unique']) && $filter[] = ["unique", 'like', "%{$param['unique_id']}%"];
         return $filter;
     }