Zory 12 часов назад
Родитель
Сommit
d107597991

+ 84 - 0
app/controller/admin/Complaint.php

@@ -0,0 +1,84 @@
+<?php
+
+namespace app\controller\admin;
+
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasComplaint;
+use app\service\saas\ComplaintService;
+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;
+
+#[Controller("/api/complaint"),Middleware(AuthMiddleware::class)]
+class Complaint extends Base
+{
+
+
+    #[Inject]
+    protected ComplaintService $service;
+
+    #[Inject]
+    protected SaasComplaint $model;
+
+    #[GetMapping('list')]
+    public function getDataList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $data = $this->service->setModel()->getList($param,['store' => function($query){
+                $query->field("poi_id,poi_name,poi_address,nick_name");
+            },'orders' => function($query){
+                $query->field("out_order_no,product_id");
+            }]);
+            return successTrans("success.data",pageFormat($data),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    #[GetMapping('detail')]
+    public function getDataDetail(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"    => trans("empty.require")
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("id",$param["id"])->with(['store' => function($query){
+                $query->field("poi_id,poi_name,poi_address,poi_city");
+            }])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            return successTrans("success.data",$data->toArray());
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
+
+    #[PostMapping('save')]
+    public function setDataDetail(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => trans("empty.require"),
+                "remark.require"    => trans("empty.require")
+            ],$request->method());
+            $data = $this->model->where("id",$param["id"])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            if ($data['status'] <> 0) return error("请勿重复回复");
+            $data->remark = $param['remark'];
+            $state = $data->save();
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
+}

+ 209 - 0
app/controller/admin/Prints.php

@@ -0,0 +1,209 @@
+<?php
+
+namespace app\controller\admin;
+
+use app\extra\basic\Base;
+use app\extra\tools\PrintExtend;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasPrint;
+use app\service\saas\PrintService;
+use app\validate\saas\PrintValidate;
+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 Webman\RedisQueue\Redis;
+
+#[Controller("/api/prints"),Middleware(AuthMiddleware::class)]
+class Prints extends Base
+{
+
+    #[Inject]
+    protected PrintService $service;
+
+    #[Inject]
+    protected PrintValidate $validate;
+
+    #[Inject]
+    protected SaasPrint $model;
+
+
+    #[GetMapping('list')]
+    public function getStoreList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $list = $this->service->setModel()->getList($param,['poi']);
+            return successTrans("success.data",pageFormat($list),200);
+        } catch (\Throwable $throwable) {
+            echo $throwable->getFile()."\n";
+            echo $throwable->getLine()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 查询打印机状态
+     * @return Response
+     */
+    #[PostMapping('refresh')]
+    public function refreshState(): Response
+    {
+        try {
+            Redis::send("print-state",[]);
+            return successTrans("success.print-state");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 打印测试
+     * @param Request $request
+     * @return Response
+     */
+    #[PostMapping('test')]
+    public function testPrint(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "sn.require"    => trans("empty.require")
+            ],"post");
+            if (!is_array($param)) return error($param);
+            $print = $this->model->where("sn",$param["sn"])->findOrEmpty();
+            if ($print->isEmpty()) return errorTrans("empty.data");
+            $resp = (new PrintExtend)->config(['appid' => sConf('wechat.ex_appid'),'secret' => sConf('wechat.ex_secret')])->printTemplate(sConf('wechat.ex_print'),$param['sn'],[
+                [
+                    "express"   => [
+                        [
+                            "j_mobile" => "180****9980",
+                            "j_address" =>"安徽省阜阳市颍州区xxx镇xxx村xxx",
+                            "express_num" => "SF3270714680386",
+                            "name" => "测试的商品标题名称测试的商品标题名称测试的商品标题名称测试的商品标题名称测试的商品标题名称",
+                            "time" => getDateFull(),
+                            "type" => "特快",
+                            "s_name" => "王*二",
+                            "s_address" => "安徽省阜阳市颍州区xxx镇xxx村xxx",
+                            "s_mobile" => "******00982",
+                            "j_name" => "王麻子",
+                            "express_type" => "饰品",
+                            "order" => "1033999288123123"
+                        ]
+                    ]
+                ]
+            ]);
+            if (!$resp['status']) return error($resp['message']);
+            return successTrans("success.print");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 新增/编辑打印机
+     * @param Request $request
+     * @return Response
+     */
+    #[PostMapping('save')]
+    public function save(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            if (!$this->validate->check($param)) return error($this->validate->getError());
+            if (!isset($param['id'])) {
+                $resp = (new PrintExtend)->config(['appid' => sConf('wechat.ex_appid'),'secret' => sConf('wechat.ex_secret')])->bindDevice($param['sn'],$param['name']);
+                if (!$resp['status']) return error($resp['message']);
+            }
+            $state = $this->model->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            echo $throwable->getMessage()."\n";
+            echo $throwable->getFile()."\n";
+            echo $throwable->getLine()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * 新增/编辑打印机
+     * @param Request $request
+     * @return Response
+     */
+    #[PostMapping('edit')]
+    public function edit(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            if (!$this->validate->scene('edit')->check($request->post())) return error($this->validate->getError());
+            $state = $this->model->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            echo $throwable->getMessage()."\n";
+            echo $throwable->getFile()."\n";
+            echo $throwable->getLine()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
+    /**
+     * @param Request $request
+     * @return Response
+     */
+    #[PostMapping('batch')]
+    public function setBatchData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => trans("empty.require"),
+                "value.require"     => trans("empty.require"),
+                "field.require"     => trans("empty.require"),
+                "type.require"      => trans("empty.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
+     */
+    #[PostMapping('del')]
+    public function delUser(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"    => trans("empty.require"),
+                "type.default"  => "one",
+            ],"post");
+            if (!is_array($param)) return error($param);
+            if ($param['type'] == "batch") {
+                $state = $this->model->where("id","in",$param['id'])->delete();
+            } else {
+                $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());
+        }
+    }
+}

+ 51 - 0
app/controller/admin/Store.php

@@ -7,6 +7,7 @@ use app\extra\dyMini\Qrcode;
 use app\middleware\AuthMiddleware;
 use app\middleware\AuthMiddleware;
 use app\model\saas\SaasStore;
 use app\model\saas\SaasStore;
 use app\model\saas\SaasStoreCategory;
 use app\model\saas\SaasStoreCategory;
+use app\model\saas\SaasStoreExpress;
 use app\service\saas\GoodsService;
 use app\service\saas\GoodsService;
 use app\service\saas\StoreService;
 use app\service\saas\StoreService;
 use DI\Attribute\Inject;
 use DI\Attribute\Inject;
@@ -229,4 +230,54 @@ class Store extends Base
         }
         }
     }
     }
 
 
+    /**
+     * 检测权限是否开通
+     * @param Request $request
+     * @return Response
+     */
+    #[GetMapping("express")]
+    public function getExpressData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "poi.require"        => trans("empty.require")
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("poi_id",$param['poi'])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("error.data");
+            $express = (new SaasStoreExpress)->where("poi_id",$param['poi'])->findOrEmpty();
+            $return = $express->toArray();
+            if ($express->isEmpty()) {
+                $return = null;
+            }
+            return successTrans("success.data",compact('return'));
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    #[PostMapping("express/save")]
+    public function setExpressData(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.default"        => 0,
+                "status.require"    => trans("empty.require"),
+                "poi_id.require"    => trans("empty.require"),
+                "type.default"      => "sfexpress",
+                "rule.default"      => [],
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("poi_id",$param['poi_id'])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("error.data");
+            $express = (new SaasStoreExpress)->where("poi_id",$param['poi_id'])->findOrEmpty();
+            $param['rule'] = json_encode($param['rule']);
+            $state = $express->setAutoData($param);
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
 }
 }

+ 83 - 0
app/controller/merchant/Complaint.php

@@ -0,0 +1,83 @@
+<?php
+
+namespace app\controller\merchant;
+
+use app\extra\basic\Base;
+use app\middleware\AuthMiddleware;
+use app\model\saas\SaasComplaint;
+use app\service\saas\ComplaintService;
+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;
+
+
+#[Controller("/api/merchant/complaint"),Middleware(AuthMiddleware::class)]
+class Complaint extends Base
+{
+
+    #[Inject]
+    protected ComplaintService $service;
+
+    #[Inject]
+    protected SaasComplaint $model;
+
+    #[GetMapping('list')]
+    public function getDataList(Request $request): Response
+    {
+        try {
+            $param = $request->all();
+            $param['poi_id'] = $request->user['store_id'];
+            $data = $this->service->setModel()->getList($param,['orders' => function($query){
+                $query->field("out_order_no,product_id");
+            }]);
+            return successTrans("success.data",pageFormat($data),200);
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
+    #[GetMapping('detail')]
+    public function getDataDetail(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"    => trans("empty.require")
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $data = $this->model->where("id",$param["id"])->with(['store' => function($query){
+                $query->field("poi_id,poi_name,poi_address,poi_city");
+            }])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            return successTrans("success.data",$data->toArray());
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
+
+    #[PostMapping('save')]
+    public function setDataDetail(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"        => trans("empty.require"),
+                "remark.require"    => trans("empty.require")
+            ],$request->method());
+            $data = $this->model->where("id",$param["id"])->findOrEmpty();
+            if ($data->isEmpty()) return errorTrans("empty.data");
+            if ($data['status'] <> 0) return error("请勿重复回复");
+            $data->status = 1;
+            $data->remark = $param['remark'];
+            $state = $data->save();
+            if (!$state) return errorTrans("error.data");
+            return successTrans("success.data");
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
+}

+ 3 - 1
app/controller/merchant/Goods.php

@@ -155,8 +155,10 @@ class Goods extends Base
                     $skuData[$key]['specs'] = json_encode($value['specs']);
                     $skuData[$key]['specs'] = json_encode($value['specs']);
                 }
                 }
             }
             }
-            if (isset($param['id'])) {
+            if (!isset($param['id'])) {
                 $param['spu_id'] = CodeExtend::uniqidDate(18);
                 $param['spu_id'] = CodeExtend::uniqidDate(18);
+            } else {
+                $param['status'] = 0;
             }
             }
             unset($param['skuSpecs']);
             unset($param['skuSpecs']);
             $param['line_price'] = $param['line_price'] * 100;
             $param['line_price'] = $param['line_price'] * 100;

+ 3 - 3
app/controller/merchant/Order.php

@@ -66,7 +66,7 @@ class Order extends Base
                 "order.require" => trans("empty.require"),
                 "order.require" => trans("empty.require"),
             ],$request->method());
             ],$request->method());
             if (!is_array($param)) return error($param);
             if (!is_array($param)) return error($param);
-            $order = $this->model->where("out_order_no",$param['order'])->with(['product','poi','user'])->findOrEmpty();
+            $order = $this->model->where("out_order_no",$param['order'])->with(['product','poi','user','address'])->findOrEmpty();
             if ($order->isEmpty()) return errorTrans("empty.data");
             if ($order->isEmpty()) return errorTrans("empty.data");
             if ($order['poi_id'] <> $request->user['store_id'] && $request->user['is_super'] == 0) return errorTrans("empty.data");
             if ($order['poi_id'] <> $request->user['store_id'] && $request->user['is_super'] == 0) return errorTrans("empty.data");
             $order['end_time'] = timeDiff(strtotime("+30 minutes",strtotime($order['create_at'])),time());
             $order['end_time'] = timeDiff(strtotime("+30 minutes",strtotime($order['create_at'])),time());
@@ -79,10 +79,10 @@ class Order extends Base
     /**
     /**
      * 手动核销
      * 手动核销
      * @param Request $request
      * @param Request $request
-     * @return Response|void
+     * @return Response
      */
      */
     #[PostMapping('done')]
     #[PostMapping('done')]
-    public function doneOrder(Request $request)
+    public function doneOrder(Request $request): Response
     {
     {
         try {
         try {
             $param = $this->_valid([
             $param = $this->_valid([

+ 133 - 0
app/extra/tools/PrintExtend.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace app\extra\tools;
+
+use yzh52521\EasyHttp\Http;
+
+class PrintExtend
+{
+
+    /**
+     * 配置信息
+     * @var array
+     */
+    protected array $config = [];
+
+    /**
+     * 网关
+     * @var string
+     */
+    protected string $gateway = "https://cloud.kuaimai.com/";
+
+
+    /**
+     * 发起打印
+     * @param int $templateId
+     * @param string $sn
+     * @param array $data
+     * @param int $num
+     * [{"express":[{"j_mobile":"180****9980","j_address":"安徽省阜阳市颍州区xxx镇xxx村xxx","express_num":"SF3270714680386","name":"飞天茅台53度500ml","time":"2025-12-04 12:18:09","type":"特快","s_name":"王*二","s_address":"安徽省阜阳市颍州区xxx镇xxx村xxx","s_mobile":"******00982","j_name":"王麻子","express_type":"饰品","order":"1033999288123123"}]}]
+     * @return array
+     */
+    public function printTemplate(int $templateId,string $sn = "",array $data = [],int $num = 1): array
+    {
+        $param = [
+            "appId"         => $this->config['appid'],
+            "sn"            => $sn,
+            "templateId"    => $templateId,
+            "printTimes"    => $num,
+            "renderDataArray" => json_encode($data),
+            "timestamp"     => getDateFull()
+        ];
+        $param['sign'] = $this->getPaySign($param);
+        return Http::asJson()->post($this->gateway."api/cloud/print/tsplTemplatePrint", $param)->array();
+    }
+
+    /**
+     * 打印机状态查询下
+     * @param array $data 最多100台
+     * @return array
+     */
+    public function deviceState(array $data = []): array
+    {
+        $param = [
+            "appId"         => $this->config['appid'],
+            "snsStr"        => json_encode($data),
+            "timestamp"     => getDateFull()
+        ];
+        $param['sign'] = $this->getPaySign($param);
+        return Http::asJson()->post($this->gateway."api/cloud/device/batchStatus", $param)->array();
+    }
+
+    /**
+     * 绑定设备
+     * @param string $sn
+     * @param string $name
+     * @return array status true为成功,false为失败 message
+     */
+    public function bindDevice(string $sn = "",string $name = ""): array
+    {
+        $param = [
+            "appId"     => $this->config['appid'],
+            "sn"        => $sn,
+            "noteName"  => $name,
+            "timestamp" => getDateFull()
+        ];
+        $param['sign'] = $this->getPaySign($param);
+        return Http::asJson()->post($this->gateway."api/cloud/device/bindDevice", $param)->array();
+    }
+
+    /**
+     * 解绑设备
+     * @param string $sn
+     * @param string $deviceKey
+     * @return array status true为成功,false为失败 message
+     */
+    public function unbindDevice(string $sn = "",string $deviceKey = ""): array
+    {
+        $param = [
+            "appId"     => $this->config['appid'],
+            "sn"        => $sn,
+            "deviceKey" => $deviceKey,
+            "timestamp" => getDateFull()
+        ];
+        $param['sign'] = $this->getPaySign($param);
+        return Http::asJson()->post($this->gateway."api/cloud/device/unbindDevice", $param)->array();
+    }
+
+
+
+    /**
+     * @param array $data
+     * @return $this
+     */
+    public function config(array $data = [])
+    {
+        $this->config = $data;
+        return $this;
+    }
+
+
+    /**
+     * 生成签名
+     * @param array $data 参与签名的数据
+     * @param string $signType 参与签名的类型
+     * @param string $buff 参与签名字符串前缀
+     * @return string
+     */
+    public function getPaySign(array $data, string $signType = 'MD5', string $buff = ''): string
+    {
+        ksort($data);
+        if (isset($data['sign'])) unset($data['sign']);
+        foreach ($data as $k => $v) {
+            if ('' === $v || null === $v) continue;
+            $buff .= "{$k}{$v}";
+        }
+        $buff .= $this->config['secret'];
+        if (strtoupper($signType) === 'MD5') {
+            return md5($this->config['secret'].$buff);
+        }
+        return strtoupper(hash_hmac('SHA256', $buff, $this->config['secret']));
+    }
+
+}

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

@@ -65,4 +65,9 @@ class SaasOrder extends Model
         return $this->hasOne(SaasUserOpen::class,"openid","openid");
         return $this->hasOne(SaasUserOpen::class,"openid","openid");
     }
     }
 
 
+    public function address(): HasOne
+    {
+        return $this->hasOne(SaasOrderAddress::class,"order_sn","out_order_no");
+    }
+
 }
 }

+ 54 - 0
app/model/saas/SaasPrint.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+use think\model\relation\HasOne;
+
+
+/**
+ * @property integer $id (主键)
+ * @property mixed $poi_id 
+ * @property string $sn 序列号
+ * @property string $device_key 
+ * @property string $name 打印机名称
+ * @property string $device_state 
+ * @property string $online 
+ * @property mixed $create_at
+ */
+class SaasPrint 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_print";
+    
+    /**
+     * 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;
+
+    public function poi(): HasOne
+    {
+        return $this->hasOne(SaasStore::class,"poi_id","poi_id");
+    }
+
+}

+ 45 - 0
app/queue/redis/slow/PrintState.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace app\queue\redis\slow;
+
+use app\extra\tools\PrintExtend;
+use app\model\saas\SaasPrint;
+use Webman\RedisQueue\Consumer;
+
+class PrintState implements Consumer
+{
+
+    /**
+     * 消费队列名
+     * 更新云打印件
+     * @var string
+     */
+    public string $queue = "print-state";
+
+    /**
+     * 连接配置
+     * @var string
+     */
+    public string $connection = "default";
+
+    public function consume($data): bool
+    {
+        echo getDateFull()."===批量查询打印件状态\n";
+        $print = (new SaasPrint)->select();
+        $sn = [];
+        if ($print->isEmpty()) return true;
+        foreach ($print as $key => $value) {
+            $sn[$key] = $value['sn'];
+        }
+        $resp = (new PrintExtend)->config(['appid' => sConf('wechat.ex_appid'),'secret' => sConf('wechat.ex_secret')])->deviceState($sn);
+        if (!$resp['status']) return true;
+        if (empty($resp['data'])) return true;
+        foreach ($resp['data'] as $key => $val) {
+            echo getDateFull()."===更新序列号=={$val['sn']}=={$val['status']}=={$val['deviceStatus']}\n";
+            $state = (new SaasPrint)->where("sn",$val['sn'])->update(["online" => $val['status'],"device_state" => $val['deviceStatus']]);
+            echo "更新状态==={$state}\n";
+        }
+        return true;
+    }
+
+}

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

@@ -30,6 +30,7 @@ class ComplaintService extends Service
         !empty($param['openid']) && $filter[] = ["openid", '=', $param['openid']];
         !empty($param['openid']) && $filter[] = ["openid", '=', $param['openid']];
         !empty($param['poi_id']) && $filter[] = ["poi_id", '=', $param['poi_id']];
         !empty($param['poi_id']) && $filter[] = ["poi_id", '=', $param['poi_id']];
         !empty($param['poi']) && $filter[] = ["poi_id", '=', $param['poi']];
         !empty($param['poi']) && $filter[] = ["poi_id", '=', $param['poi']];
+        !empty($param['mobile']) && $filter[] = ["mobile", 'like', "%{$param['mobile']}%"];
         !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
         !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
         return $filter;
         return $filter;
     }
     }

+ 38 - 0
app/service/saas/PrintService.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace app\service\saas;
+
+
+use app\extra\basic\Service;
+use app\model\saas\SaasPrint;
+
+class PrintService extends Service
+{
+
+    /**
+     *
+     * @return $this
+     */
+    public function setModel()
+    {
+        $this->mode = (new SaasPrint());
+        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']-1)];
+        !empty($param['name']) && $filter[] = ["name", 'like', "%{$param['name']}%"];
+        !empty($param['sn']) && $filter[] = ["sn", 'like', "%{$param['sn']}%"];
+        return $filter;
+    }
+
+}

+ 28 - 0
app/validate/saas/PrintValidate.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace app\validate\saas;
+
+use think\Validate;
+
+class PrintValidate extends Validate
+{
+
+
+    protected $rule = [
+        "name"          => "require",
+        "sn"            => "require",
+        "device_key"    => "require"
+    ];
+
+
+    protected $message = [
+        "name.require"      => "请输入打印机名称",
+        "sn.require"        => "请输入打印机序列号",
+        "device_key.require"=> "请输入设备密钥"
+    ];
+
+    protected $scene = [
+        "edit" => ['sn']
+    ];
+
+}