Zory 2 долоо хоног өмнө
parent
commit
e0d2415cc0

+ 36 - 0
app/controller/admin/OrderLife.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\extra\service\saas\LifeService;
+use app\middleware\AuthMiddleware;
+use DI\Attribute\Inject;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+use Webman\Annotation\Middleware;
+
+
+#[Controller(prefix: "/api/order/life"),Middleware(AuthMiddleware::class)]
+class OrderLife extends Base
+{
+
+    #[Inject]
+    protected LifeService $service;
+
+    #[Route(path: "list",methods: "get")]
+    public function getOrderList(Request $request): Response
+    {
+        try {
+            $param = $request->get();
+            $list = $this->service->getList($param);
+            return successTrans("success.data",pageFormat($list),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+
+}

+ 0 - 2
app/controller/mini/Auth.php

@@ -41,8 +41,6 @@ class Auth extends Base
         try {
             $param = $request->post();
             $sessionKey = (new Crypt)->config($this->getDyConfig())->getSessionKey($param['code']);
-            print_r($this->getDyConfig());
-            print_r($sessionKey);
             if (!isset($sessionKey['openid'])) return error("获取数据失败");
             $openId = $sessionKey['openid'];
             $userIn = [

+ 26 - 0
app/controller/mini/Notify.php

@@ -16,6 +16,32 @@ class Notify extends Base
 {
 
 
+    /**
+     * 小程序webhook
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "hook",methods: "post")]
+    public function webhook(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            if (empty($param['event'])) return error("参数错误");
+            if (empty($param['content'])) return error("参数错误");
+            $content = json_decode($param['content'], true);
+            switch ($param['event']) {
+                case "verify_token":
+                    return json(['challenge' => $content['challenge']]);
+                    break;
+                default:
+                    break;
+            }
+            return json([]);
+        } catch (\Throwable $e) {
+            return error($e->getMessage());
+        }
+    }
+
 
     /**
      * 核销工具解决方案-spi

+ 3 - 1
app/controller/mini/Test.php

@@ -4,6 +4,7 @@ namespace app\controller\mini;
 
 use app\extra\basic\Base;
 use app\extra\douyin\Account;
+use app\extra\douyin\Client;
 use LinFly\Annotation\Route\Controller;
 use LinFly\Annotation\Route\Route;
 use support\Request;
@@ -19,7 +20,8 @@ class Test extends Base
     {
         try {
             $uuid = ["228287898988984"];
-            $resp = (new \app\extra\douyin\Order)->config($this->getDyConfig())->token()->getOrderDetail(['1090074972073628984']);
+            $resp = (new \app\extra\douyin\Account())->config($this->getDyConfig())->token()->setWhiteSetting("7513378475235919883",1,true);
+//            $resp = (new Client)->config($this->getDyConfig())->token()->setMiniPath("7513378475235919883","1090074972073628984");
             print_r($resp);
             return success("ok");
         } catch (\Throwable $throwable) {

+ 39 - 0
app/extra/douyin/Client.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\extra\douyin;
+
+use yzh52521\EasyHttp\Http;
+
+class Client extends Base
+{
+
+
+    /**
+     * 设置小程序跳转path
+     * @param string $account
+     * @return array
+     */
+    public function setMiniPath(string $account = "",string $order = ""): array
+    {
+        $param = [
+            "account_id"        => $account,
+            "bind_biz_type"     => 0,
+            "path_data_list"    => [
+                [
+                    "path"      => "pages/order/detail?order={$order}",
+                    "path_type" => 1
+                ],
+                [
+                    "path"      => "pages/order/detail?order={$order}",
+                    "path_type" => 2
+                ],
+                [
+                    "path"      => "pages/order/detail?order={$order}",
+                    "path_type" => 3
+                ]
+            ]
+        ];
+        return Http::asJson()->withHeaders($this->header)->post($this->gateway."api/apps/trade/v2/toolkit/update_merchant_path/", $param)->array();
+    }
+
+}

+ 50 - 0
app/extra/service/saas/LifeService.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace app\extra\service\saas;
+
+use app\extra\basic\Service;
+use app\model\saas\SaasOrderLife;
+
+class LifeService extends Service
+{
+
+
+    public function getList(array $param = [])
+    {
+        $this->mode = new SaasOrderLife();
+        return $this->searchVal($param,$this->searchFilter($param))->with(['goods' => function($query){
+            $query->field("out_id,product_name,product_img,product_price");
+        },'store' => function ($query) {
+            $query->field("store_id,store_name");
+        },'agent' => function ($query) {
+            $query->field("agent_id,name");
+        }])->paginate([
+            "list_rows" => $param['pageSize'],
+            "page"      => $param['page']
+        ]);
+    }
+
+    public function getDataListMini(array $param = [])
+    {
+        $this->mode = new SaasOrderLife();
+        return $this->searchVal($param,$this->searchFilter($param))->with(['goods' => function($query){
+            $query->field("out_id,product_name,product_img,product_price");
+        }])->paginate([
+            "list_rows" => $param['size'],
+            "page"      => $param['page']
+        ]);
+    }
+
+
+    protected function searchFilter(array $param = []): array
+    {
+        $filter = [];
+        !empty($param['agent']) && $filter[] = ["agent_id", '=', $param['shop']];
+        !empty($param['open_id']) && $filter[] = ["open_id", '=', $param['open_id']];
+        !empty($param['statusLt']) && $filter[] = ["status", '=', ($param['statusLt']-1)];
+        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
+        !empty($param['order']) && $filter[] = ["order_sn", 'like', "%{$param['order']}%"];
+        return $filter;
+    }
+
+}

+ 5 - 0
app/model/saas/SaasOrderLife.php

@@ -80,4 +80,9 @@ class SaasOrderLife extends Model
         return $this->hasOne("app\model\saas\SaasAgent","agent_id","agent_id");
     }
 
+    public function goods(): HasOne
+    {
+        return $this->hasOne("app\model\saas\SaasGoods","out_id","out_id");
+    }
+
 }