Zory 3 godzin temu
rodzic
commit
0c2c86113e

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

@@ -4,26 +4,251 @@ namespace app\controller\api;
 
 use app\extra\basic\Base;
 use app\middleware\WxMiddleware;
+use app\model\saas\SaasCart;
+use app\model\saas\SaasCombo;
+use app\model\saas\SaasDiscount;
+use app\model\saas\SaasPrice;
+use app\model\saas\SaasPrintClient;
+use app\model\saas\SaasShop;
+use app\model\saas\SaasUser;
+use app\model\saas\SaasUserBuy;
 use LinFly\Annotation\Route\Controller;
 use LinFly\Annotation\Route\Middleware;
 use LinFly\Annotation\Route\Route;
+use Qcloud\Cos\Client;
+use support\Request;
 use support\Response;
+use yzh52521\EasyHttp\Http;
 
 
 #[Controller(prefix: "/wx_api/cart"),Middleware(WxMiddleware::class)]
 class Cart extends Base
 {
+    protected array $noNeedLogin = [];
+    /**
+     * 颜色
+     * @var array|string[]
+     */
+    protected array $color = ["1" => "彩色", "2" => "黑白"];
+    /**
+     * 单双面
+     * @var array|string[]
+     */
+    protected array $duplex = ["1" => "单面", "2" => "双面"];
+    /**
+     * 打印方向
+     * @var array|string[]
+     */
+    protected array $direction = ["1" => "自适应","2" => "横向", "3" => "竖向"];
+    /**
+     * 配送方式
+     * @var array|string[]
+     */
+    protected array $package = ["1" => "店内打印", "2" => '远程自取' , "3" => "商家配送"];
 
+    protected array $types = [
+        '1_1_1' => ['name' => '彩色-单面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '1_2_1' => ['name' => '彩色-双面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '2_1_1' => ['name' => '黑白-单面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '2_2_1' => ['name' => '黑白-双面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+    ];
 
     /**
      * 获取打印购物车列表
      * @return Response
      */
     #[Route(path: "list",methods: "get")]
-    public function getCartList(): Response
+    public function getCartList(Request $request): Response
     {
         try {
-            return success("");
+            $param = $this->_valid([
+                "shop.require"  => trans("empty.require"),
+                "print.require" => trans("empty.require"),
+                "type.default"  => 1
+            ]);
+            if (!is_array($param)) return error($param);
+            $cart = (new SaasCart)->where("shop_id",$param['shop'])->order("create_at desc")->select();
+            if ($cart->isEmpty()) return success('ok',['cart' => []]);
+            $totalAmount = $totalDiscount = 0;
+            foreach ($cart as $k=>$v){
+                $key = $v['color'] . '_' . $v['duplex'] . '_' . $v['source'];
+                if (isset($this->types[$key])) {
+                    $this->types[$key]['quantity'] += $v['page'];
+                    $this->types[$key]['amount'] += $v['money'];
+                }
+                $cart[$k] = $v;
+                $cart[$k]['money'] = format_money($v['money'] / 100,2);
+                $cart[$k]['name'] = msubstr($v['name'],0,12);
+            }
+            $printData = (new SaasPrintClient)->where("shop_id",$param['shop'])->where("code",$param['print'])->select();
+            if ($printData->isEmpty()) return error('无可用打印机');
+            $rule = [];
+            foreach ($printData as $key=>$value) {
+                $rule[$key]['check'] = 0;
+                $nameColor = "";
+                if (empty($value['rule'])) return error("尚未配置打印机~");
+                foreach ($value['rule']['color'] as $key2=>$val) {
+                    $rule[$key]['color'][$key2][$val] = $this->color[$val];
+                    $nameColor .= $this->color[$val];
+                }
+                foreach ($value['rule']['direction'] as $key2=>$val) {
+                    $rule[$key]['direction'][$key2][$val] = $this->direction[$val];
+                }
+                foreach ($value['rule']['duplex'] as $key2=>$val) {
+                    $rule[$key]['duplex'][$key2][$val] = $this->duplex[$val];
+                }
+                foreach ($value['rule']['package'] as $key2=>$val) {
+                    $rule[$key]['package'][$key2][$val] = $this->package[$val];
+                }
+                foreach ($value['rule']['paper_size'] as $key2=>$val) {
+                    $rule[$key]['paper_size'][$key2][$val] = $val;
+                }
+                if ($param['print'] == $value['code']) {
+                    $rule[$key]['check'] = 1;
+                }
+                $rule[$key]['name'] = $nameColor."-".$value['name'];
+                $rule[$key]['code'] = $value['code'];
+            }
+            // 计算折扣
+            foreach ($this->types as $k=>$v) {
+                $discount = (new SaasDiscount)->where("shop_id",$param['shop'])->where("keys",$k)->where("number",'<',$v['quantity'])->findOrEmpty();
+                if (!$discount->isEmpty()) {
+                    $v['discount'] = round($v['amount'] * $discount['rate']);
+                    $this->types[$k]['discount'] = $v['discount'];
+                }
+                $totalAmount += $v['amount'];
+                $totalDiscount += $v['discount'];
+            }
+            $totalAmount = format_money($totalAmount / 100,2);
+            $totalDiscount = format_money($totalDiscount / 100,2);
+            if ($param['type'] <> 1) {
+                $shop = (new SaasShop)->where("shop_id",$param['shop'])->field("shop_name,shop_address,user_card,user_card_price")->find();
+                $isRecharge = (new SaasUserBuy)->where("shop_id",$param['shop'])->where("uid",$request->user['id'])->where("status",1)->sum("money");;
+                $cardPrice = [];
+                if ($shop['user_card'] < 3) {
+                    if ($shop['user_card'] == 2) { // 自定义套餐
+                        $cardPrice = array_values($shop['user_card_price']);
+                    } else {
+                        $cardPrice = (new SaasCombo)->where("type",2)->field("id,name,ROUND(money/100,2) as money,ROUND(old_money/100,2) as old_money,is_first")->where("status",1)->select()->toArray();
+                    }
+                    $cardPrice = array_filter($cardPrice, function($item) use ($isRecharge) {
+                        if ($isRecharge > 0) {
+                            return $item['is_first'] != '1'; // 注意:这里使用松散比较,因为数据中有字符串'1'
+                        } else {
+                            return $item;
+                        }
+                    });
+                    foreach ($cardPrice as $key=>$val) {
+                        $cardPrice[$key] = $val;
+                        $cardPrice[$key]['money'] = $val['money'];
+                        $cardPrice[$key]['old_money'] = $val['old_money'];
+                    }
+                    $cardPrice = array_values($cardPrice);
+                }
+                $card = (new SaasUser)->where("openid",$request->user['openid'])->where("shop_id",$param['shop'])->field("ROUND(balance/100,2) as money")->findOrEmpty();
+                if ($card->isEmpty()) {
+                    $card = null;
+                }
+                $package = $this->package;
+                return success("",compact('rule','totalAmount','totalDiscount','shop','cardPrice','package','card'));
+            }
+            return success("",compact('cart','rule','totalAmount','totalDiscount'));
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
+    /**
+     * 删除购物
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "del",methods: "post")]
+    public function delCart(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "shop.require"  => trans("empty.require"),
+                "id.require"    => trans("empty.require"),
+                "print.require" => trans("empty.require"),
+            ],"post");
+            if (!is_array($param)) return error($param);
+            $cart = (new SaasCart)->where("id",$param['id'])->findOrEmpty();
+            if ($cart->isEmpty()) return error("操作失败");
+            if ($cart['uuid'] <> $request->user['id']) return error("操作失败");
+            $state = $cart->delete();
+            if (!$state) return error("操作失败");
+            return success("操作成功");
+        } catch (\Throwable $exception) {
+            return error($exception->getMessage());
+        }
+    }
+
+    /**
+     * 更新购物
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "update",methods: "post")]
+    public function updateCart(Request $request): Response
+    {
+        try {
+            $param = $request->post();
+            $cart = (new SaasCart)->where("id",$param['id'])->where("uuid",$request->user['id'])->findOrEmpty();
+            if ($cart->isEmpty()) return error('数据格式错误');
+            if ($param['end_page'] > $cart['total_page']) return error('打印范围不能大于总页数');
+            // 查询默认打印机是否有额外收费规则
+            $printData = (new SaasPrintClient)->where("shop_id",$param['shop_id'])->where("code",$param['print'])->findOrEmpty();
+            $extraMoney = 0;
+            $moneyMode = (new SaasPrice)->where([
+                "shop_id"   => $param['shop_id'],
+                "paper_size" => $param['paper_size'],
+                "type"      => $param['source'],
+                "color"     => $param['color'],
+                "duplex"    => $param['duplex'],
+            ])->findOrEmpty();
+            if ($moneyMode->isEmpty()) return error("尚未设置收费规则");
+            if (!empty($printData['price']) && $printData['is_price'] == 1) {
+                $priceRule = isset($printData['price'][$moneyMode['id']]['price']) ? $printData['price'][$moneyMode['id']]['price'] : 0;
+                $extraMoney = $priceRule * 100;
+            }
+            if ($param['duplex'] == 2) {
+                $updateData['page'] = ceil(($param['end_page'] - $param['start_page'] + 1) / 2); // 双面
+            } else {
+                $updateData['page'] = $param['end_page'] - $param['start_page'] + 1;
+            }
+            $updateData['extra_money'] = $extraMoney;
+            $updateData['money'] = ($moneyMode['price']*100 + $extraMoney) * $updateData['page'] * $param['number'];
+            $updateData['single_money'] = $moneyMode['price']*100;
+            $updateData['single_id'] = $moneyMode['id'];
+            $updateData['paper_size'] = $param['paper_size'];
+            $updateData['number'] = $param['number'];
+            $updateData['duplex'] = $param['duplex'];
+            $updateData['direction'] = $param['direction']??1;
+            $updateData['color'] = $param['color'];
+            $updateData['start_page'] = $param['start_page'];
+            $updateData['end_page'] = $param['end_page'];
+            $state = $cart->save($updateData);
+            if (!$state) return error("数据操作失败");
+            return success("更新成功");
+        } catch (\Throwable $exception) {
+            return error($exception->getMessage());
+        }
+    }
+
+
+    /**
+     * 预览
+     * @return Response
+     */
+    #[Route(path: "preview",methods: "post")]
+    public function wordPreview(): Response
+    {
+        try {
+            return success("",[
+                "host"  => "https://".sConf("storage.cos_http_domain")."/",
+                "query" => "?ci-process=doc-preview&dstType=jpg&imageDpi=120&page="
+            ]);
         } catch (\Throwable $th) {
             return error($th->getMessage());
         }
@@ -49,13 +274,104 @@ class Cart extends Base
      * @return Response
      */
     #[Route(path: "word",methods: "post")]
-    public function uploadWord(): Response
+    public function uploadWord(Request $request): Response
     {
         try {
+            $param = $this->_valid([
+                "shop.require"      => trans("empty.require"),
+                "word.require"      => trans("empty.require"),
+                "print.require"     => trans("empty.require"),
+                "type.default"      => 1, // 1打印 2复印
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $wordData = json_decode($param["word"], true);
+            $printData = (new SaasPrintClient)->where(['shop_id' => $param['shop'],'code' => $param['print']])->findOrEmpty();
+            if ($printData->isEmpty()) return error('无可用打印机');
+            $paperRule = is_string($printData['rule'])?json_decode($printData['rule'],true):$printData['rule'];
+            $paperSize = count($paperRule['paper_size'])==1?$paperRule['paper_size'][0]:'A4';
+            $colorSize = count($paperRule['color'])==1?$paperRule['color'][0]:2;
+            $moneyMode = (new SaasPrice)->where(['shop_id' => $param['shop'],'paper_size' => $paperSize,'color' => $colorSize,'type' => $param['type']])->findOrEmpty();
+            if ($moneyMode->isEmpty()) return error("店铺未设置收费规则");
+            $extraMoney = 0;
+            // 计算额外收费
+            if (!empty($printData['price']) && $printData['is_price'] == 1) {
+                $priceRule = isset($printData['price'][$moneyMode['id']]['price']) ? $printData['price'][$moneyMode['id']]['price'] : 0;
+                $extraMoney = $priceRule * 100 ;
+            }
+            $cartData = [];
+            foreach ($wordData as $key=>$val) {
+                $cartData[$key] = [
+                    "money"         => ($val['total'] * $moneyMode['price'] * 100) + ($extraMoney * $val['total']),
+                    "extra_money"   => $extraMoney,
+                    "number"        => 1,
+                    "duplex"        => 1,
+                    "color"         => $colorSize,
+                    "page"          => $val['total'],
+                    "total_page"    => $val['total'],
+                    "end_page"      => $val['total'],
+                    "name"          => $val['name'],
+                    "uuid"          => $request->user['id'],
+                    "shop_id"       => $param['shop'],
+                    "paper_size"    => $paperSize,
+                    "extension"     => $val['ext'],
+                    "source"        => $param['type'],
+                    "icon"          => "https://inmei-print.oss-cn-guangzhou.aliyuncs.com/extension/{$val['ext']}.png", // 图标
+                    "single_money"  => $moneyMode['price'] * 100,
+                    "single_id"     => $moneyMode['id'],
+                    "path"          => $val['cosKey'],
+                    "print_id"      => $param['print'],
+                    "print_name"    => $printData['name'],
+                ];
+            }
+            if (empty($cartData)) return error('上传失败');
+            $state = (new SaasCart)->insertAll($cartData);
+            if (!$state) return error("解析文档失败,请重试");
             return success("ok");
         } catch (\Throwable $th) {
             return error($th->getMessage());
         }
     }
 
+    /**
+     * 读取页码
+     * ?ci-process=doc-preview&page=1&dstType=jpg&imageDpi=120
+     * ?ci-process=doc-preview&page=2&sheet=1&excelPaperDirection=0
+     */
+    #[Route(path: "total",methods: ['post','get'])]
+    public function checkTotal(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "cosKey.require"  => trans("empty.require"),
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $suffix = pathinfo($param['cosKey'], PATHINFO_EXTENSION);
+            if (empty($suffix)) return error("empty.data.suffix");
+            $cosClient = new Client([
+                'region' => sConf("storage.cos_region"),
+                'schema' => 'https', // 协议头部,默认为 http
+                'credentials' => array(
+                    'secretId' => sConf("storage.cos_access_key"),
+                    'secretKey' => sConf("storage.cos_secret_key"),
+                ),
+                "verify"    => false
+            ]);
+            $url = $cosClient->getObjectUrl(sConf("storage.cos_bucket"), $param['cosKey']);
+            $params = array(
+                'ci-process' => 'doc-preview',
+                'page' => 1,
+                'dstType' => 'jpg',
+                'imageDpi' => '120',
+            );
+            $query = http_build_query($params);
+            $path = $url.$query;
+            $resp = Http::get($path)->headers();
+            if (!isset($resp['X-Total-Page'])) return error("文档可能需要密码,请先删除后再确认");
+            $page = $resp['X-Total-Page']?$resp['X-Total-Page'][0]:1;
+            return success("ok",compact('page'));
+        } catch (\Throwable $th) {
+            return error($th->getMessage());
+        }
+    }
+
 }

+ 120 - 0
app/controller/api/Order.php

@@ -0,0 +1,120 @@
+<?php
+
+namespace app\controller\api;
+
+use app\extra\basic\Base;
+use app\extra\tools\CodeExtend;
+use app\middleware\WxMiddleware;
+use app\model\saas\SaasCart;
+use app\model\saas\SaasDiscount;
+use app\model\saas\SaasOrder;
+use app\model\saas\SaasPrintClient;
+use app\model\saas\SaasUser;
+use LinFly\Annotation\Route\Controller;
+use LinFly\Annotation\Route\Middleware;
+use LinFly\Annotation\Route\Route;
+use support\Request;
+use support\Response;
+
+
+#[Controller(prefix: "/wx_api/order"),Middleware(WxMiddleware::class)]
+class Order extends Base
+{
+    protected array $noNeedLogin = [];
+
+    protected array $types = [
+        '1_1_1' => ['name' => '彩色-单面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '1_2_1' => ['name' => '彩色-双面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '2_1_1' => ['name' => '黑白-单面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+        '2_2_1' => ['name' => '黑白-双面', 'amount' => 0, 'quantity' => 0,'discount' => 0],
+    ];
+
+    /**
+     * @param Request $request
+     * @return Response
+     */
+    #[Route(path: "create",methods: "post")]
+    public function createOrder(Request $request): Response
+    {
+        try {
+            $param = $this->_valid([
+                "shop.require"  => trans("empty.require"),
+                "print.require" => trans("empty.require"),
+                "pay.require"   => trans("empty.require"),
+                "printName.default" => "",
+                "express.require" => trans("empty.require"),
+                "card.default"      => [],
+                "gift.default"      => 0
+            ],$request->method());
+            if (!is_array($param)) return error($param);
+            $cart = (new SaasCart)->where("shop_id",$param['shop'])->order("create_at desc")->select();
+            if ($cart->isEmpty()) return success('ok',['cart' => []]);
+            $totalAmount = $totalDiscount = 0;
+            foreach ($cart as $k=>$v){
+                $key = $v['color'] . '_' . $v['duplex'] . '_' . $v['source'];
+                if (isset($this->types[$key])) {
+                    $this->types[$key]['quantity'] += $v['page'];
+                    $this->types[$key]['amount'] += $v['money'];
+                }
+                $cart[$k] = $v;
+                $cart[$k]['money'] = format_money($v['money'] / 100,2);
+                $cart[$k]['name'] = msubstr($v['name'],0,12);
+            }
+            $printData = (new SaasPrintClient)->where("shop_id",$param['shop'])->where("code",$param['print'])->select();
+            if ($printData->isEmpty()) return error('无可用打印机');
+            // 计算折扣
+            foreach ($this->types as $k=>$v) {
+                $discount = (new SaasDiscount)->where("shop_id",$param['shop'])->where("keys",$k)->where("number",'<',$v['quantity'])->findOrEmpty();
+                if (!$discount->isEmpty()) {
+                    $v['discount'] = round($v['amount'] * $discount['rate']);
+                    $this->types[$k]['discount'] = $v['discount'];
+                }
+                $totalAmount += $v['amount']; // 实际金额
+                $totalDiscount += $v['discount']; // 折扣后金额
+            }
+            $orderSn = CodeExtend::uniqidDate(16).date("is").rand(1,9);
+            $totalDay = (new SaasOrder)->where("shop_id",$param['shop'])->whereDay("create_at")->count();
+            $orderData = [
+                "shop_id"       => $param['shop'], // 所属店铺
+                "parent_id"     => $param['shop'], // 消费店铺
+                "order_sn"      => $orderSn,
+                "money"         => $totalAmount,
+                "discount"      => $totalDiscount,
+                "uuid"          => $request->user['id'],
+                "print_name"    => $param['printName'],
+                "package"       => $param['express'],
+                "package_sn"    => date('md')."-".sprintf("%02d",($totalDay+1)),
+                "extra_money"   => "",
+                "remark"        => $param['remark']??''
+            ];
+            if ($param['pay'] == 2) { // 会员卡支付或开通会员卡并充值
+                $card = (new SaasUser)->where("openid",$request->user['openid'])->where("shop_id",$param['shop'])->field("balance")->findOrEmpty();
+                if ($card->isEmpty()) // 创建会员并发起支付
+                {
+
+                }
+                if ($totalDiscount > 0 && $totalDiscount > $card['balance']) {
+                    return error("卡内余额不足~");
+                }
+                if ($totalDiscount == 0 && $totalAmount > $card['balance']) {
+                    return error("卡内余额不足");
+                }
+            }
+            $orderDetail = [];
+            foreach ($cart as $key=>$val)
+            {
+                unset($val['id']);
+                $orderDetail[$key] = $val;
+                $orderDetail[$key]['money'] = $val['money']*100;
+                $orderDetail[$key]['order_sn'] = $orderSn;
+                $orderDetail[$key]['print_name'] = $param['printName'];
+            }
+            print_r($orderDetail);
+
+        } catch (\Throwable $throwable) {
+            echo $throwable->getLine()."\n";
+            return error($throwable->getMessage());
+        }
+    }
+
+}

+ 11 - 1
app/controller/api/Uploads.php

@@ -12,11 +12,21 @@ use support\Request;
 use support\Response;
 use LinFly\Annotation\Route\Middleware;
 
-
 #[Controller(prefix: "/wx_api/upload"),Middleware(WxMiddleware::class)]
 class Uploads extends Base
 {
 
+
+    #[Route(path: "temp",methods: "post")]
+    public function getCosTemp()
+    {
+        try {
+
+        } catch (\Throwable $throwable) {
+            return error($throwable->getMessage());
+        }
+    }
+
     /**
      * 上传文件
      * @param Request $request

+ 2 - 4
app/controller/merchant/Discount.php

@@ -54,15 +54,13 @@ class Discount extends Base
                 "shop_id.default"   => $request->user['agent_id'],
             ],"post");
             if (!is_array($param)) return error($param);
+            $param['keys'] = $param['color']."_".$param['duplex']."_1";
             $price = $this->model->where("id",$param["id"])->findOrEmpty();
             if ($price->isEmpty())
             {
                 $priceType = $this->model->where([
                     "shop_id"   => $param["shop_id"],
-                    "color"     => $param["color"],
-                    "duplex"    => $param["duplex"],
-                    "number"    => $param["number"],
-                    "rate"      => $param["rate"],
+                    "keys"      => $param["keys"]
                 ])->findOrEmpty();
                 if (!$priceType->isEmpty()) return errorTrans("error.exist");
                 $state = $price->insertGetId($param);

+ 63 - 0
app/functions.php

@@ -6,6 +6,69 @@ use app\extra\tools\CodeExtend;
 use support\Response;
 use Webman\Event\Event;
 
+
+if (!function_exists('msubstr')) {
+    /**
+     * 字符串截取(同时去掉HTML与空白)
+     * @param string $str
+     * @param int $start
+     * @param int $length
+     * @param string $charset
+     * @param bool $suffix
+     * @return string
+     */
+    function msubstr(string $str, int $start = 0, int $length = 100,string $charset = "utf-8", bool $suffix = true): string
+    {
+
+        $str = preg_replace('/<[^>]+>/', '', preg_replace("/[\r\n\t ]{1,}/", ' ', delNt(strip_tags($str))));
+        $str = preg_replace('/&(\w{4});/i', '', $str);
+
+        // 直接返回
+        if ($start == -1) {
+            return $str;
+        }
+
+        if (function_exists("mb_substr")) {
+            $slice = mb_substr($str, $start, $length, $charset);
+        } elseif (function_exists('iconv_substr')) {
+            $slice = iconv_substr($str, $start, $length, $charset);
+
+        } else {
+            $re['utf-8'] = "/[x01-x7f]|[xc2-xdf][x80-xbf]|[xe0-xef][x80-xbf]{2}|[xf0-xff][x80-xbf]{3}/";
+            $re['gb2312'] = "/[x01-x7f]|[xb0-xf7][xa0-xfe]/";
+            $re['gbk'] = "/[x01-x7f]|[x81-xfe][x40-xfe]/";
+            $re['big5'] = "/[x01-x7f]|[x81-xfe]([x40-x7e]|xa1-xfe])/";
+            preg_match_all($re[$charset], $str, $match);
+            $slice = join("", array_slice($match[0], $start, $length));
+        }
+
+        $fix = '';
+        if (strlen($slice) < strlen($str)) {
+            $fix = '...';
+        }
+        return $suffix ? $slice . $fix : $slice;
+    }
+}
+
+if (!function_exists('delNt')) {
+    /**
+     * 去掉连续空白
+     * @param string $str 字符串
+     * @return string
+     */
+    function delNt(string $str): string
+    {
+        $str = trim($str); //清除字符串两边的空格
+        $str = strip_tags($str,""); //利用php自带的函数清除html格式
+        $str = preg_replace("/\t/","",$str); //使用正则表达式替换内容,如:空格,换行,并将替换为空。
+        $str = preg_replace("/\r\n/","",$str);
+        $str = preg_replace("/\r/","",$str);
+        $str = preg_replace("/\n/","",$str);
+        $str = preg_replace("/ /","",$str);
+        $str = preg_replace("/  /","",$str);  //匹配html中的空格
+        return trim($str); //返回字符串
+    }
+}
 if (!function_exists("between_time"))
 {
     /**

+ 68 - 0
app/model/saas/SaasCart.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property integer $uuid 
+ * @property integer $shop_id 
+ * @property string $name 文件名称
+ * @property integer $total_page 总页数
+ * @property integer $page 页数
+ * @property integer $end_page 结束页
+ * @property integer $start_page 起始页
+ * @property integer $color 颜色
+ * @property string $paper_size 纸张
+ * @property integer $duplex 单双面1单面2双面
+ * @property integer $direction 1
+ * @property integer $number 打印份数
+ * @property integer $money 金额
+ * @property string $path 文件
+ * @property string $old_path 原始路径
+ * @property string $extension 
+ * @property float $discount 折扣
+ * @property integer $source 1文档2复印
+ * @property integer $extra_money 额外加价
+ * @property integer $single_money 单价
+ * @property integer $single_id 单价ID
+ * @property string $icon 
+ * @property string $print_name 打印机名称
+ * @property string $view_key 预览id
+ * @property string $job 
+ * @property mixed $create_at
+ */
+class SaasCart 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_cart";
+    
+    /**
+     * 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;
+
+
+}

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

@@ -0,0 +1,69 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property integer $shop_id 所属店铺
+ * @property string $parent_id 消费店铺
+ * @property string $order_sn 
+ * @property integer $money 
+ * @property integer $status 0待付款1已支付
+ * @property integer $uuid 
+ * @property integer $pay_type 支付方式1微信2会员卡
+ * @property string $print_name 打印机名称
+ * @property integer $coupon_money 优惠券金额
+ * @property integer $coupon_id 
+ * @property integer $notify_status 通知状态1已通知
+ * @property mixed $pay_at 支付时间
+ * @property string $transaction_id 交易编号wx
+ * @property mixed $refund_at 
+ * @property integer $refund_status 
+ * @property integer $package 1店内打印2远程自取3商家配送
+ * @property string $package_sn 取件号
+ * @property integer $package_type 0无1店内打印2远程自取3商家配送
+ * @property string $package_local 装订位置
+ * @property integer $extra_money 额外加价
+ * @property integer $express_money 配送费
+ * @property integer $staple_money 装订费
+ * @property float $discount 折扣
+ * @property mixed $print_at 打印时间
+ * @property string $remark 备注
+ * @property string $reason 失败原因
+ * @property mixed $create_at
+ */
+class SaasOrder 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_order";
+    
+    /**
+     * 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;
+
+
+}

+ 73 - 0
app/model/saas/SaasOrderDetail.php

@@ -0,0 +1,73 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property string $order_sn 
+ * @property integer $uuid 
+ * @property integer $shop_id 
+ * @property string $name 文件名称
+ * @property integer $total_page 
+ * @property integer $page 页数
+ * @property integer $start_page 起始页
+ * @property integer $end_page 结束页面
+ * @property integer $color 颜色
+ * @property string $paper_size 纸张
+ * @property integer $duplex 单双面1单面2双面
+ * @property integer $direction 1
+ * @property integer $number 打印份数
+ * @property integer $money 金额
+ * @property string $path 文件
+ * @property string $old_path 
+ * @property string $extension 
+ * @property float $discount 折扣
+ * @property integer $source 1文档2复印
+ * @property integer $extra_money 额外加价
+ * @property integer $single_money 单价
+ * @property integer $single_id 单价ID
+ * @property string $icon 
+ * @property integer $status 
+ * @property integer $pay_status 支付状态
+ * @property integer $refund_status 退款状态
+ * @property mixed $refund_at 
+ * @property string $print_name 
+ * @property string $view_key 
+ * @property string $job 
+ * @property mixed $create_at
+ */
+class SaasOrderDetail 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_order_detail";
+    
+    /**
+     * 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;
+
+
+}

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

@@ -0,0 +1,47 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property integer $uuid 
+ * @property string $key 
+ * @property string $path 
+ * @property integer $type 
+ * @property mixed $create_at
+ */
+class SaasOrderPreview 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_order_preview";
+    
+    /**
+     * 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;
+
+
+}

+ 51 - 0
app/model/saas/SaasUserBuy.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace app\model\saas;
+
+use app\extra\basic\Model;
+
+
+/**
+ * @property integer $id (主键)
+ * @property integer $agent_id 
+ * @property integer $uid 
+ * @property integer $shop_id 
+ * @property mixed $order_sn 
+ * @property integer $money 金额
+ * @property integer $status 0待付款1已支付
+ * @property mixed $pay_at 支付时间
+ * @property string $transaction_id 交易编号wx
+ * @property mixed $create_at
+ */
+class SaasUserBuy 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_user_buy";
+    
+    /**
+     * 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;
+
+
+}