zory 1 сар өмнө
parent
commit
7bdfc569e1

+ 3 - 0
app/controller/api/Cart.php

@@ -302,6 +302,9 @@ class Cart extends Base
             }
             $cartData = [];
             foreach ($wordData as $key=>$val) {
+                if ($val['total'] <= 0) {
+                    return error("请检查上传文档是否有显示页数");
+                }
                 $cartData[$key] = [
                     "money"         => ($val['total'] * $moneyMode['price'] * 100) + ($extraMoney * $val['total']),
                     "extra_money"   => $extraMoney,

+ 80 - 1
app/controller/api/Notify.php

@@ -3,7 +3,9 @@
 namespace app\controller\api;
 
 use app\extra\basic\Base;
+use app\model\saas\SaasCart;
 use app\model\saas\SaasOrder;
+use app\model\saas\SaasOrderDetail;
 use app\model\saas\SaasShop;
 use app\model\saas\SaasShopLog;
 use app\model\saas\SaasUser;
@@ -35,7 +37,51 @@ class Notify extends Base
             if (empty($payResp)) return $wechat->getNotifySuccessReply();
             $data = $wechat->getNotify($payResp);
             if (empty($data)) return $wechat->getNotifySuccessReply();
-            $orderSn = $data['result']['out_refund_no'];
+            $orderSn = explode("-",$data['result']['out_refund_no']);
+            $order = (new SaasOrder)->where("order_sn",$orderSn[0])->with(['shop' => function($query){
+                $query->field('shop_id,shop_name,shop_address');
+            }])->findOrEmpty();
+            if ($order->isEmpty()) return $wechat->getNotifySuccessReply();
+            if ($order['status'] <> 4) return $wechat->getNotifySuccessReply();
+            $order->status = 6;
+            $order->save();
+            (new SaasOrderDetail)->where("order_sn",$order['order_sn'])->update(['status' => 6]);
+            // 商家账户额度退款
+            $shop = (new SaasShop)->where("shop_id",$order['shop_id'])->with(['wx' => function($query){
+                $query->field("shop_id,openid,is_msg");
+            }])->findOrEmpty();
+            if ($shop->isEmpty()) return $this->getNotifySuccessReply();
+            $shop->balance = Db::raw("balance-".$order['discount']);
+            $shop->total_balance = Db::raw("total_balance-".$order['discount']);
+            $shop->save();
+            (new SaasShopLog)->insertGetId([
+                "shop_id"   => $order['shop_id'],
+                "money"     => $order['discount'],
+                "balance"   => $shop->balance,
+                "remark"    => "订单退款【{$order['order_sn']}】",
+                "type"      => 2
+            ]);// 推送消息-公众号
+            if (!empty($shop['wx'])) {
+                $obj = \We::WeChatTemplate([
+                    "appid" => sConf("wechat.appid"),
+                    "appsecret" => sConf("wechat.secret"),
+                    "token" => sConf("wechat.token"),
+                    "encodingaeskey" => sConf("wechat.aeskey")
+                ]);
+                foreach ($shop['wx'] as $val) {
+                    if ($val['is_msg'] == 1) {
+                        $obj->send([
+                            "touser" => $val['openid'],
+                            "template_id" => "WboxN-32rdHORBQHzaVvQb9kPN7rLaXAPS_BL2yfb5w",
+                            "data" => [
+                                "amount3" => ["value" => format_money($order['money']/100)],
+                                "character_string1" => ["value" => $order['old_order']],
+                                "time4" => ["value" => date('Y-m-d H:i')]
+                            ]
+                        ]);
+                    }
+                }
+            }
 
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());
@@ -281,4 +327,37 @@ class Notify extends Base
         ];
     }
 
+
+
+    #[Route(path: "test",methods: "get")]
+    public function testData()
+    {
+        try {
+            $data = $this->_valid([
+                "openid.default" => "otdgy3fYZ0JBHW7mbnxmdKTQJRUU",
+                "shop.default"  => "326945519114632",
+                "order.default"  => "202604022640934408406"
+            ]);
+            $cart = (new SaasCart)->where("shop_id",$data['shop'])->where("openid",$data['openid'])->order("create_at desc")->select();
+            if ($cart->isEmpty()) return success('ok',['cart' => []]);
+            $orderDetail = [];
+            foreach ($cart->toArray() as $key=>$val)
+            {
+                unset($val['id']);
+                $orderDetail[$key] = $val;
+                $orderDetail[$key]['order_sn'] = $data['order'];
+                if ($val['extension'] == "pdf") {
+                    $orderDetail[$key]['status'] = 1;
+                } else {
+                    $orderDetail[$key]['status'] = 0;
+                }
+            }
+            print_r($orderDetail);
+            $state = (new SaasOrderDetail)->strict(false)->insertAll($orderDetail);
+            return success("ok");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
 }

+ 2 - 1
app/controller/api/Order.php

@@ -147,7 +147,7 @@ class Order extends Base
                 $totalDiscount += $v['discount']; // 折扣后金额
             }
             $orderSn = CodeExtend::uniqidDate(16).date("is").rand(1,9);
-            $totalDay = (new SaasOrder)->where("shop_id",$param['shop'])->where("openid",$request->user['openid'])->whereDay("create_at")->count();
+            $totalDay = (new SaasOrder)->where("shop_id",$param['shop'])->whereDay("create_at")->count();
             $orderData = [
                 "shop_id"       => $param['shop'], // 所属店铺
                 "parent_id"     => $param['shop'], // 消费店铺
@@ -181,6 +181,7 @@ class Order extends Base
                     "shop_id"   => $param['shop'],
                     "order_sn"  => $orderSn,
                     "money"     => $payMoney,
+                    "card_no"   => strtoupper(md5($request->user['openid'].$param['shop'])),
                     "type"      => 1,
                     "balance"   => $card->balance,
                 ]);

+ 12 - 0
app/controller/common/Common.php

@@ -31,4 +31,16 @@ class Common extends Base
         }
     }
 
+
+    #[Route(path: "test",methods: "get")]
+    public function testData()
+    {
+        try {
+            events("merge-pdf",['shop' => "326945519114632","order" => "202603263933413924333", "openid" => "otdgy3QxYqFjS_yl_YKUmLYMAtGI"]);
+            return success("ok");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
 }

+ 11 - 0
app/controller/exe/Prints.php

@@ -4,8 +4,10 @@ namespace app\controller\exe;
 
 use app\extra\basic\Base;
 use app\middleware\ExeMiddleware;
+use app\model\saas\SaasOrder;
 use app\model\saas\SaasOrderDetail;
 use app\model\saas\SaasPrintClient;
+use app\model\saas\SaasShop;
 use LinFly\Annotation\Route\Controller;
 use LinFly\Annotation\Route\Middleware;
 use LinFly\Annotation\Route\Route;
@@ -53,6 +55,7 @@ class Prints extends Base
             if (!empty($printIn)) {
                 $mode->insertAll(array_values($printIn));
             }
+            (new SaasShop)->where("shop_id",$shopId)->update(['line_time' => getDateFull()]);
             return success("ok",$param);
         } catch (\Throwable $throwable) {
             return error($throwable->getMessage());
@@ -75,6 +78,11 @@ class Prints extends Base
             if (!is_array($param)) return error($param);
             $orderId = $param['param']['jobId'];
             $order = (new SaasOrderDetail)->where("id",$orderId)->with(['orders'])->findOrEmpty();
+            $total = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 'ta' => 0];
+            foreach ((new SaasOrderDetail)->where("id",$orderId)->field('create_at,status,count(1) total')->group('status,create_at')->cursor() as $vo)
+            {
+                [$total["t{$vo['status']}"] += $vo['total'], $total['ta'] += $vo['total']];
+            }
             $outPut = $param['data']['outputArray'];
             $logData = [];
             foreach ($outPut as $key=>$val) {
@@ -87,6 +95,9 @@ class Prints extends Base
                     if ($val['code'] == 0) {
                         $order->status = 3;
                         $order->save();
+                        if (($total['t3']+1) == $total['ta']) {
+                            (new SaasOrder)->where("order_sn",$order['order_sn'])->update(['status' => 3,'print_at' => getDateFull()]);
+                        }
                     }
                 }
             }

+ 100 - 0
app/controller/merchant/Order.php

@@ -6,12 +6,16 @@ use app\extra\basic\Base;
 use app\extra\service\saas\OrderService;
 use app\middleware\AuthMiddleware;
 use app\model\saas\SaasOrder;
+use app\model\saas\SaasOrderDetail;
+use app\model\saas\SaasUser;
+use app\model\saas\SaasUserLog;
 use DI\Attribute\Inject;
 use LinFly\Annotation\Route\Controller;
 use LinFly\Annotation\Route\Middleware;
 use LinFly\Annotation\Route\Route;
 use support\Request;
 use support\Response;
+use think\facade\Db;
 
 
 #[Controller(prefix: "/api/mer/order"),Middleware(AuthMiddleware::class)]
@@ -40,6 +44,28 @@ class Order extends Base
         }
     }
 
+    /**
+     * 返回统计结果
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "fail",methods: "post")]
+    public function setOrderFail(Request $request): Response
+    {
+        try {
+            $param = $this->_valid(['order.require' => "error"],$request->method());
+            if (!is_array($param)) return error($param);
+            $order = $this->model->where("order_sn",$param['order'])->findOrEmpty();
+            if ($order->isEmpty()) return errorTrans("empty.data");
+            $order->status = 2;
+            $order->save();
+            (new SaasOrderDetail)->where("order_sn",$param['order'])->update(['status' => 3]);
+            return successTrans("success.data");
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
     /**
      * 返回统计结果
      * @param Request $request
@@ -60,4 +86,78 @@ class Order extends Base
         }
     }
 
+
+    /**
+     * 申请退款
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "refund",methods: "post")]
+    public function setRefund(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "id.require"    => trans("empty.require")
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $order = $this->model->where("id",$param['id'])->where("shop_id",$request->user['agent_id'])->findOrEmpty();
+            if ($order->isEmpty()) return errorTrans("empty.data");
+            if ($order['pay_type'] == 1) { // 微信退款
+                $wechat = new \WeChat\Pay($this->getWxConfig());
+                $resp = $wechat->createRefund([
+                    "transaction_id"    => $order['transaction_id'],
+                    "out_refund_no"     => $order['order_sn']."-".date("is"),
+                    "total_fee"         => $order['discount'],
+                    "refund_fee"        => $order['discount'],
+                    "notify_url"        => 'https://panel.huiyinduo.cn/notify/refund',
+                ]);
+                $order->status = 4;
+                $state = $order->save();
+                (new SaasOrderDetail)->where("shop_id",$request->user['agent_id'])->where("order_sn",$order['order_sn'])->update(['status' => 4]);
+            } else { // 会员卡退款
+                $card = (new SaasUser)->where("card_no",md5($order['openid'].$request->user['agent_id']))->findOrEmpty();
+                if ($card->isEmpty()) return error("会员不存在");
+                $card->balance = Db::raw("balance+".$order['discount']);
+                $card->total_consume = Db::raw("total_consume-".$order['discount']);
+                $card->save();
+                (new SaasUserLog)->insertGetId([
+                    "order_sn"  => $order['order_sn'],
+                    "openid"    => $order['openid'],
+                    "shop_id"   => $order['shop_id'],
+                    "card_no"   => md5($order['openid'].$order['shop_id']),
+                    "money"     => $order['discount'],
+                    "type"      => 2,
+                    "balance"   => $card->balance,
+                    "remark"    => "订单退款"
+                ]);
+                $order->status = 6;
+                $state = $order->save();
+                (new SaasOrderDetail)->where("shop_id",$request->user['agent_id'])->where("order_sn",$order['order_sn'])->update(['status' => 6]);
+            }
+            if (!$state) return error("申请失败");
+            return success("申请成功");
+        } catch (\Throwable $throwable) {
+            echo $throwable->getLine()."\n";
+            echo $throwable->getFile()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
+
+
+    protected function getWxConfig(): array
+    {
+        return [
+            'token'          => 'test',
+            'appid'          => sConf("wechat.mini_appid"),
+            'appsecret'      => sConf("wechat.mini_secret"),
+            'encodingaeskey' => 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5',
+            // 配置商户支付参数(可选,在使用支付功能时需要)
+            'mch_id'         => sConf("wechat.mch_id"),
+            'mch_key'        => sConf("wechat.mch_key"),
+            "ssl_cer"       => public_path().sConf("wechat.mch_ssl_cer"),
+            "ssl_key"       => public_path().sConf("wechat.mch_ssl_key"),
+        ];
+    }
+
 }

+ 3 - 0
app/controller/merchant/Qrcode.php

@@ -37,6 +37,9 @@ class Qrcode extends Base
             $list = $this->service->getList($param);
             return successTrans("success.data",pageFormat($list),200);
         } catch (\Throwable $throwable) {
+            echo $throwable->getLine()."\n";
+            echo $throwable->getFile()."\n";
+            echo $throwable->getMessage()."\n";
             return error($throwable->getMessage());
         }
     }

+ 41 - 26
app/event/CreateOrder.php

@@ -1,27 +1,42 @@
-<?php
-
-namespace app\event;
-
-use app\model\saas\SaasCart;
-use app\model\saas\SaasOrderDetail;
-
-class CreateOrder
-{
-
-    public function createOrder(array $data = [])
-    {
-        $cart = (new SaasCart)->where("shop_id",$data['shop'])->where("openid",$data['openid'])->order("create_at desc")->select();
-        if ($cart->isEmpty()) return success('ok',['cart' => []]);
-        $orderDetail = [];
-        foreach ($cart->toArray() as $key=>$val)
-        {
-            unset($val['id']);
-            $orderDetail[$key] = $val;
-            $orderDetail[$key]['order_sn'] = $data['order'];
-            $orderDetail[$key]['status'] = 1;
-        }
-        (new SaasOrderDetail)->insertAll($orderDetail);
-//        (new SaasCart)->where("shop_id",$data['shop'])->where("openid",$data['openid'])->delete();
-    }
-
+<?php
+
+namespace app\event;
+
+use app\model\saas\SaasCart;
+use app\model\saas\SaasOrderDetail;
+
+class CreateOrder
+{
+
+    public function createOrder(array $data = [])
+    {
+        try {
+            $cart = (new SaasCart)->where("shop_id",$data['shop'])->where("openid",$data['openid'])->order("create_at desc")->select();
+            if ($cart->isEmpty()) return success('ok',['cart' => []]);
+            $orderDetail = [];
+            foreach ($cart->toArray() as $key=>$val)
+            {
+                unset($val['id']);
+                $orderDetail[$key] = $val;
+                $orderDetail[$key]['order_sn'] = $data['order'];
+                if ($val['extension'] == "pdf") {
+                    $orderDetail[$key]['status'] = 1;
+                } else {
+                    $orderDetail[$key]['status'] = 0;
+                }
+            }
+            $state = (new SaasOrderDetail)->strict(false)->insertAll($orderDetail);
+            echo "写入订单详情{$data['order']}\n";
+            var_dump($state);
+            events("merge-pdf",$data);
+            (new SaasCart)->where("shop_id",$data['shop'])->where("openid",$data['openid'])->delete();
+        } catch (\Throwable $throwable) {
+            echo "写入订单详情错误\n";
+            echo $throwable->getLine()."\n";
+            echo $throwable->getFile()."\n";
+            echo $throwable->getMessage()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
 }

+ 37 - 0
app/event/MergePdf.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\event;
+
+use app\model\saas\SaasOrderDetail;
+use yzh52521\EasyHttp\Http;
+
+class MergePdf
+{
+
+    public function imgMergePdf(array $data = [])
+    {
+        if (empty($data['shop'])) return true;
+        $detail = (new SaasOrderDetail)->where(["shop_id" => $data['shop'],"openid" => $data['openid'],"order_sn" => $data['order'],'status' => 0])->select();
+        if ($detail->isEmpty()) return true;
+        foreach ($detail as $key=>$val) {
+            if ($val['extension'] !== 'pdf') {
+                $pathUri = [];
+                for ($i = 1; $i <= $val['total_page']; $i ++) {
+                    $pathUri[$i] = "https://".sConf("storage.cos_http_domain")."/".$val['path']."?ci-process=doc-preview&dstType=jpg&imageDpi=300&page={$i}";
+                }
+                $resp = Http::asJson()->withHeaders(['x-api-key' => "your-api-key-here"])->post("http://127.0.0.1:3000/api/images-to-pdf",[
+                    "imageUrls" => array_values($pathUri),
+                    "pdfName"   => $data['order']."_".$val['id'],
+                    "options"   => [
+                        "compression"   => false,
+                        "quality"       => 100
+                    ]
+                ])->array();
+                if ($resp['success']) {
+                    (new SaasOrderDetail)->where("id",$val['id'])->update(['path' => $resp['data']['pdfUrl'],'old_path' => $val['path'], 'status' => 1]);
+                }
+            }
+        }
+    }
+
+}

+ 1 - 1
app/extra/service/saas/MemberService.php

@@ -16,7 +16,7 @@ class MemberService extends Service
     public function getList(array $param = [])
     {
         $this->mode = new SaasUser();
-        return $this->searchVal($param,$this->searchFilter($param))->paginate([
+        return $this->searchVal($param,$this->searchFilter($param))->with(['shop'])->paginate([
             "list_rows" => $param['pageSize'],
             "page"      => $param['page']
         ]);

+ 3 - 1
app/extra/service/saas/OrderService.php

@@ -16,7 +16,9 @@ class OrderService extends Service
     public function getList(array $param = [])
     {
         $this->mode = new SaasOrder();
-        return $this->searchVal($param,$this->searchFilter($param))->field("*")->with(['detail'])->paginate([
+        return $this->searchVal($param,$this->searchFilter($param))->field("*")->with(['detail','shop' => function($query){
+            $query->field("shop_id,shop_name");
+        }])->paginate([
             "list_rows" => $param['pageSize'],
             "page"      => $param['page']
         ]);

+ 3 - 1
app/extra/service/saas/QrcodeService.php

@@ -16,7 +16,9 @@ class QrcodeService extends Service
     public function getList(array $param = [])
     {
         $this->mode = new SaasOrderQrcode();
-        return $this->searchVal($param,$this->searchFilter($param))->paginate([
+        return $this->searchVal($param,$this->searchFilter($param))->with(['shop' => function($query){
+            $query->field("shop_id,shop_name");
+        }])->paginate([
             "list_rows" => $param['pageSize'],
             "page"      => $param['page']
         ]);

+ 14 - 7
app/model/saas/SaasOrderQrcode.php

@@ -3,16 +3,17 @@
 namespace app\model\saas;
 
 use app\extra\basic\Model;
+use think\model\relation\HasOne;
 
 
 /**
- * @property integer $id (主键)
- * @property mixed $order_sn 
- * @property integer $agent_id 
- * @property integer $shop_id 
- * @property integer $money 
- * @property integer $status 0待支付1已支付
- * @property integer $is_order 1跟随订单
+ * @property integer $id (主键)
+ * @property mixed $order_sn 
+ * @property integer $agent_id 
+ * @property integer $shop_id 
+ * @property integer $money 
+ * @property integer $status 0待支付1已支付
+ * @property integer $is_order 1跟随订单
  * @property mixed $create_at
  */
 class SaasOrderQrcode extends Model
@@ -46,4 +47,10 @@ class SaasOrderQrcode extends Model
     public bool $timestamps = false;
 
 
+    public function shop(): HasOne
+    {
+        return $this->hasOne("app\model\saas\SaasShop","shop_id","shop_id");
+    }
+
+
 }

+ 72 - 65
app/wss/PrintWss.php

@@ -1,66 +1,73 @@
-<?php
-
-namespace app\wss;
-use app\model\saas\SaasOrderDetail;
-use Workerman\Connection\TcpConnection;
-
-class PrintWss
-{
-    public function onConnect(TcpConnection $connection)
-    {
-        echo "onConnect-111\n";
-    }
-
-    public function onWebSocketConnect(TcpConnection $connection, $http_buffer)
-    {
-        echo "onWebSocketConnect\n";
-    }
-
-    public function onMessage(TcpConnection $connection, $data)
-    {
-        if (empty($data)) $connection->send(['type' => 'empty','data' => []]);
-        $param = json_decode($data,true);
-        if ($param['type'] == 'get_data') {
-            $printer = explode("-",$param['printer']);
-            $printJob = (new SaasOrderDetail)->where("shop_id",$printer[1])->where("print_id",$printer[0])->where("status",1)->findOrEmpty();
-            if (!$printJob->isEmpty()) {
-                $range = Null;
-                if ($printJob['end_page'] > $printJob['start_page']) {
-                    $range = $printJob['start_page']."-".$printJob['end_page'];
-                }
-                if ($printJob['end_page'] == $printJob['start_page']) {
-                    $range = (int) $printJob['end_page'];
-                }
-                $color_mode = ($printJob['color']==1?'color':'monochrome');
-                $duplex = "simplex";
-                if ($printJob['paper_size'] == 'A4' && $printJob['duplex'] == 2) {
-                    $duplex = 'duplexshort'; // duplexlong
-                }
-                if ($printJob['paper_size'] == 'A3' && $printJob['duplex'] == 2) {
-                    $duplex = 'duplexlong'; // duplexshort
-                }
-                $data = [
-                    "type"  => "print",
-                    "data"  => [
-                        "jobId"     => $printJob['id'],
-                        "action"    => 'create',
-                        "remoteUrl" => "https://".sConf("storage.cos_http_domain")."/".$printJob['path'],
-                        "customFileName" => $printJob['order_sn'],
-                        "exe"       => ['-print-to',$printJob['print_name'],'-print-settings',"{$range},{$printJob['number']}x,{$color_mode},$duplex,paper={$printJob['paper_size']}",'-silent'],
-                    ]
-                ];
-                $printJob->status = 2;
-                $printJob->save();
-            } else {
-                $data = [];
-            }
-        }
-        $connection->send($data);
-    }
-
-    public function onClose(TcpConnection $connection)
-    {
-        echo "onClose-2222\n";
-    }
-
+<?php
+
+namespace app\wss;
+use app\model\saas\SaasOrderDetail;
+use Workerman\Connection\TcpConnection;
+
+class PrintWss
+{
+    public function onConnect(TcpConnection $connection)
+    {
+//        echo "onConnect-111\n";
+    }
+
+    public function onWebSocketConnect(TcpConnection $connection, $http_buffer)
+    {
+//        echo "onWebSocketConnect\n";
+    }
+
+    public function onMessage(TcpConnection $connection, $data)
+    {
+        if (empty($data)) $connection->send(['type' => 'empty','data' => []]);
+        $param = json_decode($data,true);
+        if ($param['type'] == "heartbeat") {
+            $version = sConf("service.version");
+            $data = [
+                "type"      => "update",
+                "version"   => $version?:'1.0.1'
+            ];
+        }
+        if ($param['type'] == 'get_data') {
+            $printer = explode("-",$param['printer']);
+            $printJob = (new SaasOrderDetail)->where("shop_id",$printer[1])->where("print_id",$printer[0])->where("status",1)->findOrEmpty();
+            if (!$printJob->isEmpty()) {
+                $range = Null;
+                if ($printJob['end_page'] > $printJob['start_page']) {
+                    $range = $printJob['start_page']."-".$printJob['end_page'];
+                }
+                if ($printJob['end_page'] == $printJob['start_page']) {
+                    $range = (int) $printJob['end_page'];
+                }
+                $color_mode = ($printJob['color']==1?'color':'monochrome');
+                $duplex = "simplex";
+                if ($printJob['paper_size'] == 'A4' && $printJob['duplex'] == 2) {
+                    $duplex = 'duplexlong'; // duplexlong
+                }
+                if ($printJob['paper_size'] == 'A3' && $printJob['duplex'] == 2) {
+                    $duplex = 'duplexshort'; // duplexshort
+                }
+                $data = [
+                    "type"  => "print",
+                    "data"  => [
+                        "jobId"     => $printJob['id'],
+                        "action"    => 'create',
+                        "remoteUrl" => "https://".sConf("storage.cos_http_domain")."/".$printJob['path'],
+                        "customFileName" => $printJob['order_sn']."_".$printJob['id'],
+                        "exe"       => ['-print-to',$printJob['print_name'],'-print-settings',"{$range},{$printJob['number']}x,{$color_mode},$duplex,fit,paper={$printJob['paper_size']}",'-silent'],
+                    ]
+                ];
+                $printJob->status = 2;
+                $printJob->save();
+            } else {
+                $data = [];
+            }
+        }
+        $connection->send($data);
+    }
+
+    public function onClose(TcpConnection $connection)
+    {
+//        echo "onClose-2222\n";
+    }
+
 }

+ 3 - 0
config/event.php

@@ -6,5 +6,8 @@ return [
     ],
     "create-order" => [
         [\app\event\CreateOrder::class,"createOrder"]
+    ],
+    "merge-pdf" => [
+        [\app\event\MergePdf::class,"imgMergePdf"]
     ]
 ];

BIN
public/uploads/card/10888572278827-pay.jpg