rabin 3 napja
szülő
commit
733a7b9a80

+ 2 - 0
config/env/localhost.php

@@ -1,5 +1,7 @@
 <?php
 return [
+    # 定义资源导入接口 默认是import
+    'import' => 'importJiu',
     'db' => [
         'type' => 'Pdo',
         'host' => 'web-mysql',

+ 3 - 0
config/setting.php

@@ -26,6 +26,9 @@ return [
         'v' => 'Pinterface/Lib/Core.getVersion',
     ],
 
+    # 定义资源导入接口 默认是import
+    'import' => $env['import'],
+
     # 路由解析设置
     'route' => [
         'api/notify/(.*?)' => 'notify.common?s=$1',

+ 4 - 0
package/querylist/index.php

@@ -0,0 +1,4 @@
+<?php
+define('DEVER_PACKAGE',  'querylist');
+define('DEVER_APP_SETUP', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../boot.php');

+ 11 - 13
src/place/interface/app/Api/Source.php

@@ -206,20 +206,18 @@ class Source extends Core
             $data['tab'][] = $view;
         }
         # 是否展示内容
-        if ($info['show_content'] == 1) {
-            # 获取内容类别
-            $content_channel = Dever::db('psource/content_channel')->select(['info_id' => $info['id'], 'status' => 1]);
-            if ($content_channel) {
-                foreach ($content_channel as $v) {
-                    $num = Dever::db('psource/content')->count(['info_id' => $info['id'], 'channel_id' => $v['id'], 'status' => 1]);
-                    if ($num > 0) {
-                        if ($num > 10) {
-                            $more = 1;
-                        } else {
-                            $more = 2;
-                        }
-                        $data['tab'][] = ['id' => $v['id'], 'name' => $v['name'], 'more' => $more];
+        # 获取内容类别
+        $content_channel = Dever::db('psource/content_channel')->select(['info_id' => $info['id'], 'status' => 1]);
+        if ($content_channel) {
+            foreach ($content_channel as $v) {
+                $num = Dever::db('psource/content')->count(['info_id' => $info['id'], 'channel_id' => $v['id'], 'status' => 1]);
+                if ($num > 0) {
+                    if ($num > 10) {
+                        $more = 1;
+                    } else {
+                        $more = 2;
                     }
+                    $data['tab'][] = ['id' => $v['id'], 'name' => $v['name'], 'more' => $more];
                 }
             }
         }

+ 1 - 0
src/place/set/table/info.php

@@ -2,6 +2,7 @@
 return [
     'name' => '品牌表',
     'partition' => 'Dever::call("Manage/Lib/Util.system", [false, false])',
+    'order' => 'id asc',
     'struct' => [
         'uid' => [
             'name'      => '用户ID',//对应sector.user表

+ 97 - 0
src/place/source/app/Lib/Info.php

@@ -199,4 +199,101 @@ class Info
         $where['main.state'] = 1;
         return Dever::db('psource/sku')->select($where, $set);
     }
+
+    # 建立规格
+    public function createSku($i, $id, $name, $code, $price, $pic, $type = 1)
+    {
+        if ($name) {
+            $createCode = false;
+            if (!$code) {
+                $createCode = true;
+            }
+            if (!$type) {
+                $type = 1;
+            }
+            foreach ($name as $v) {
+                if ($createCode) {
+                    $code = $this->createCode($i);
+                }
+                $temp = explode('&', $v);
+                $spec_value_id = [];
+                foreach ($temp as $k => $t) {
+                    # 颜色:白色 & 尺寸:35
+                    $t = trim($t);
+                    list($spec_name, $spec_value) = explode(':', $t);
+
+                    $spec_data = ['info_id' => $id, 'name' => $spec_name];
+                    $spec = Dever::db('psource/spec')->find($spec_data);
+                    if ($spec) {
+                        $spec_id = $spec['id'];
+                    } else {
+                        $spec_data['sort'] = $i;
+                        $spec_id = Dever::db('psource/spec')->insert($spec_data);
+                    }
+                    if ($spec_id) {
+                        $spec_data = ['info_id' => $id, 'spec_id' => $spec_id, 'value' => $spec_value];
+                        $spec_value = Dever::db('psource/spec_value')->find($spec_data);
+                        if ($spec_value) {
+                            $spec_value_id[] = $spec_value['id'];
+                        } else {
+                            $spec_data['sort'] = $i;
+                            if ($type == 1) {
+                                $spec_data['pic'] = $pic;
+                            }
+                            $spec_value_id[] = Dever::db('psource/spec_value')->insert($spec_data);
+                        }
+                    }
+                }
+                $update = [];
+                if ($spec_value_id) {
+                    $spec_value_id = implode(',', $spec_value_id);
+                    $update['spec_type'] = 3;
+                } else {
+                    $spec_value_id = -1;
+                    $update['spec_type'] = 2;
+                }
+                $sku_data = ['info_id' => $id, 'key' => $spec_value_id];
+                $sku = Dever::db('psource/sku')->find($sku_data);
+                $sku_data['price'] = $price;
+                $sku_data['code'] = $code;
+                if ($type == 2) {
+                    $sku_data['pic'] = $pic;
+                }
+                if ($sku) {
+                    Dever::db('psource/sku')->update($sku['id'], $sku_data);
+                } else {
+                    Dever::db('psource/sku')->insert($sku_data);
+                }
+
+                $sku = Dever::load(\Api\Lib\Sku::class)->getPrice(['info_id' => $id], $update['spec_type'], 'psource');
+                $update['price'] = $sku['price'];
+                $update['sku_id'] = $sku['id'];
+                Dever::db('psource/info')->update($id, $update);
+                $i++;
+            }
+        }
+        return $i;
+    }
+
+    public function createPic($pic, $info_pic = '')
+    {
+        if ($pic) {
+            $temp = explode('?', $pic);
+            if (!strstr($info_pic, $temp[0])) {
+                $info_pic = explode(',', $info_pic);
+                $info_pic[] = $pic;
+                return implode(',', $info_pic);
+            }
+        }
+        return '';
+    }
+
+    private function createCode($i)
+    {
+        // 流水号,补足4位,不足左边补0
+        $line = str_pad((string)($i + 1), 4, '0', STR_PAD_LEFT);
+        // 当前时间 (年月日时分)
+        $dateStr = date("YmdHi");  // Y=年, m=月, d=日, H=时, i=分
+        return $dateStr . $line;
+    }
 }

+ 20 - 136
src/place/source/manage/Lib/Excel.php

@@ -54,15 +54,15 @@ class Excel
         $result = [];
         if ($import) {
             # 导入时的字段,一定要和下面的else里的对应
-            $result['head'][0] = ['source_name', 'channel_name', 'cate_parent_name', 'cate_child_name', 'source_type', 'sku_code', 'sku_name', 'sku_price', 'sku_pic'];
+            $result['head'][0] = ['source_name', 'channel_name', 'cate_parent_name', 'cate_child_name', 'source_type', 'sku_code', 'sku_name', 'sku_price', 'sku_pic', 'sku_pic_type'];
         } else {
             # 这是导入时的模板
-            $result['head'][0] = ['资源名称', '资源频道', '资源主分类', '资源子分类', '资源类型', '规格编码', '规格名称', '规格售价', '规格图片(插入-图片-本地图片-裁剪-锁定纵横比-宽度设置2厘米,不要内嵌到单元格中)'];
+            $result['head'][0] = ['资源名称', '资源频道', '资源主分类', '资源子分类', '资源类型', '规格编码', '规格名称', '规格售价', '规格图片(插入-图片-本地图片-裁剪-锁定纵横比-宽度设置2厘米,不要内嵌到单元格中)', '图片类型(1是主规格图片,2是所有规格图片)'];
         }
         $result['body'] = [];
         if ($out) {
             $k = 0;
-            $result['body'][$k] = ['资源名称', '频道名称', '主分类名称', '子分类名称', '实物/虚拟/服务/不发货', '规格编码,不填将自动生成,填写请勿重复', '颜色:白色 & 尺寸:35(注:请用这个格式填写规格)', '规格售价,这里直接添加售价的数字,无需填写任何单位', '规格图片,仅支持一张图片,直接复制粘贴到本单元格即可,请勿嵌入图片,同时该图片将成为资源主图'];
+            $result['body'][$k] = ['资源名称', '频道名称', '主分类名称', '子分类名称', '实物/虚拟/服务/不发货', '规格编码,不填将自动生成,填写请勿重复', '颜色:白色 & 尺寸:35(注:请用这个格式填写规格,第一个规格为主规格)', '规格售价,这里直接添加售价的数字,无需填写任何单位', '规格图片,仅支持一张图片,直接复制粘贴到本单元格即可,请勿嵌入图片,同时该图片将成为资源主图', '1'];
             return Dever::load(\Excel\Lib\Export::class)->act($result['body'], $result['head'], '资源导入模板');
         }
         return $result;
@@ -138,95 +138,23 @@ class Excel
             $source['cate'] = implode(',', $source['cate']);
             
             if ($info) {
-                if ($row['sku_pic']) {
-                    $pic = explode(',', $info['pic']);
-                    $pic[] = $row['sku_pic'];
-                    $source['pic'] = implode(',', $pic);
-                }
-                if ($info['price'] > $row['sku_price']) {
-                    $source['price'] = $row['sku_price'];
-                }
+                $source['pic'] = Dever::load(\Psource\Lib\Info::class)->createPic($row['sku_pic'], $info['pic']);
                 Dever::db('psource/info')->update($info['id'], $source);
                 $id = $info['id'];
             } else {
                 $source['pic'] = $row['sku_pic'];
-                $source['price'] = $row['sku_price'];
                 $id = Dever::db('psource/info')->insert($source);
             }
             
             if ($id) {
                 # 建立规格
-                if (isset($row['sku_name']) && $row['sku_name']) {
-                    $temp = explode('&', $row['sku_name']);
-                    $spec_value_id = [];
-                    foreach ($temp as $v) {
-                        # 颜色:白色 & 尺寸:35
-                        $v = trim($v);
-                        list($spec_name, $spec_value) = explode(':', $v);
-
-                        $spec_data = ['info_id' => $id, 'name' => $spec_name];
-                        $spec = Dever::db('psource/spec')->find($spec_data);
-                        if ($spec) {
-                            $spec_id = $spec['id'];
-                        } else {
-                            $spec_data['sort'] = $i;
-                            $spec_id = Dever::db('psource/spec')->insert($spec_data);
-                        }
-                        if ($spec_id) {
-                            $spec_data = ['info_id' => $id, 'spec_id' => $spec_id, 'value' => $spec_value];
-                            $spec_value = Dever::db('psource/spec_value')->find($spec_data);
-                            if ($spec_value) {
-                                $spec_value_id[] = $spec_value['id'];
-                            } else {
-                                $spec_data['sort'] = $i;
-                                $spec_value_id[] = Dever::db('psource/spec_value')->insert($spec_data);
-                            }
-                        }
-                    }
-                    $update = [];
-                    if ($spec_value_id) {
-                        $spec_value_id = implode(',', $spec_value_id);
-                        $update['spec_type'] = 3;
-                    } else {
-                        $spec_value_id = -1;
-                        $update['spec_type'] = 2;
-                    }
-                    if (!$row['sku_code']) {
-                        $row['sku_code'] = $this->createCode($i);
-                    }
-                    $sku_data = ['info_id' => $id, 'key' => $spec_value_id];
-                    $sku = Dever::db('psource/sku')->find($sku_data);
-                    $sku_data += ['pic' => $row['sku_pic'], 'price' => $row['sku_price'], 'code' => $row['sku_code']];
-                    if ($sku) {
-                        Dever::db('psource/sku')->update($sku['id'], $sku_data);
-                    } else {
-                        Dever::db('psource/sku')->insert($sku_data);
-                    }
-
-                    $sku = Dever::load(\Api\Lib\Sku::class)->getPrice(['info_id' => $id], $update['spec_type'], 'psource');
-                    $update['price'] = $sku['price'];
-                    $update['sku_id'] = $sku['id'];
-                    Dever::db('psource/info')->update($id, $update);
-
-                    $i++;
-                }
+                $i = Dever::load(\Psource\Lib\Info::class)->createSku($i, $id, [$row['sku_name']], $row['sku_code'], $row['sku_price'], $row['sku_pic'], $row['sku_pic_type']);
             }
         }
 
         @unlink($file);
     }
 
-    public function createCode($i)
-    {
-        // 流水号,补足4位,不足左边补0
-        $line = str_pad((string)($i + 1), 4, '0', STR_PAD_LEFT);
-
-        // 当前时间 (年月日时分)
-        $dateStr = date("YmdHi");  // Y=年, m=月, d=日, H=时, i=分
-
-        return $dateStr . $line;
-    }
-
 
     # 导出一个模板出来
     public function getJiuTemplate($out = false, $import = false)
@@ -308,77 +236,33 @@ class Excel
             $source['cate'] = implode(',', $source['cate']);
             
             if ($info) {
-                if ($row['sku_pic']) {
-                    $pic = explode(',', $info['pic']);
-                    $pic[] = $row['sku_pic'];
-                    $source['pic'] = implode(',', $pic);
-                }
-                if ($info['price'] > $row['sku_price']) {
-                    $source['price'] = $row['sku_price'];
-                }
+                $source['pic'] = Dever::load(\Psource\Lib\Info::class)->createPic($row['sku_pic'], $info['pic']);
                 Dever::db('psource/info')->update($info['id'], $source);
                 $id = $info['id'];
             } else {
                 $source['pic'] = $row['sku_pic'];
-                $source['price'] = $row['sku_price'];
                 $id = Dever::db('psource/info')->insert($source);
             }
             
             if ($id) {
                 # 建立规格
-                $row['sku_name'] = '颜色:' . $row['color'] . ' & 尺寸:' . $row['size'];
-                if (isset($row['sku_name']) && $row['sku_name']) {
-                    $temp = explode('&', $row['sku_name']);
-                    $spec_value_id = [];
-                    foreach ($temp as $v) {
-                        # 颜色:白色 & 尺寸:35
-                        $v = trim($v);
-                        list($spec_name, $spec_value) = explode(':', $v);
-
-                        $spec_data = ['info_id' => $id, 'name' => $spec_name];
-                        $spec = Dever::db('psource/spec')->find($spec_data);
-                        if ($spec) {
-                            $spec_id = $spec['id'];
-                        } else {
-                            $spec_data['sort'] = $i;
-                            $spec_id = Dever::db('psource/spec')->insert($spec_data);
-                        }
-                        if ($spec_id) {
-                            $spec_data = ['info_id' => $id, 'spec_id' => $spec_id, 'value' => $spec_value];
-                            $spec_value = Dever::db('psource/spec_value')->find($spec_data);
-                            if ($spec_value) {
-                                $spec_value_id[] = $spec_value['id'];
-                            } else {
-                                $spec_data['sort'] = $i;
-                                $spec_value_id[] = Dever::db('psource/spec_value')->insert($spec_data);
-                            }
-                        }
+                $color = $row['color'];
+                $sku_name = [];
+                if (strstr($row['size'], '-')) {
+                    $temp = explode('-', $row['size']);
+                    for ($j = $temp[0]; $j <= $temp[1]; $j++) {
+                        $sku_name[] = '颜色:' . $color . ' & 尺寸:' . $j;
                     }
-                    $update = [];
-                    if ($spec_value_id) {
-                        $spec_value_id = implode(',', $spec_value_id);
-                        $update['spec_type'] = 3;
-                    } else {
-                        $spec_value_id = -1;
-                        $update['spec_type'] = 2;
+                } elseif (strstr($row['size'], '、')) {
+                    $row['size'] = explode('、', $row['size']);
+                    foreach ($row['size'] as $v) {
+                        $sku_name[] = '颜色:' . $color . ' & 尺寸:' . $v;
                     }
-                    $row['sku_code'] = $this->createCode($i);
-                    $sku_data = ['info_id' => $id, 'key' => $spec_value_id];
-                    $sku = Dever::db('psource/sku')->find($sku_data);
-                    $sku_data += ['pic' => $row['sku_pic'], 'price' => $row['sku_price'], 'code' => $row['sku_code']];
-                    if ($sku) {
-                        Dever::db('psource/sku')->update($sku['id'], $sku_data);
-                    } else {
-                        Dever::db('psource/sku')->insert($sku_data);
-                    }
-
-                    $sku = Dever::load(\Api\Lib\Sku::class)->getPrice(['info_id' => $id], $update['spec_type'], 'psource');
-                    $update['price'] = $sku['price'];
-                    $update['sku_id'] = $sku['id'];
-                    Dever::db('psource/info')->update($id, $update);
-
-                    $i++;
+                } else {
+                    $sku_name[] = '颜色:' . $color . ' & 尺寸:' . $row['size'];
                 }
+
+                $i = Dever::load(\Psource\Lib\Info::class)->createSku($i, $id, $sku_name, '', $row['sku_price'], $row['sku_pic'], 1);
             }
         }
         @unlink($file);

+ 2 - 3
src/place/source/manage/Lib/Info.php

@@ -9,7 +9,8 @@ class Info
             if (!$data['import']) {
                 Dever::error('请选择导入文件');
             }
-            Dever::load(\Psource\Manage\Lib\Excel::class)->importJiu($data['import']);
+            $method = Dever::config('setting')['import'];
+            Dever::load(\Psource\Manage\Lib\Excel::class)->$method($data['import']);
             return 'end';
         }
         if ($data['cate']) {
@@ -61,9 +62,7 @@ class Info
                 $name = Dever::db('psource/info')->value('show_page', $info['show_page']);
                 $sell = Dever::db('psource/info')->value('show_sell', $info['show_sell']);
                 $submit = Dever::db('psource/info')->value('show_submit', $info['show_submit']);
-                $show_content = Dever::db('psource/info')->value('show_content', $info['show_content']);
                 $content = [
-                    ['name' => '内容展示', 'content' => $show_content],
                     ['name' => '下单按钮', 'content' => $submit],
                     ['name' => '销量展示', 'content' => $sell],
                     ['name' => '实际销量', 'content' => $info['num_sell'] ?: 0],

+ 2 - 7
src/place/source/manage/info.php

@@ -67,7 +67,7 @@ $config = [
                     # 打开新页面
                     //'open' => true,
                 ],
-            ],'', 'show_content=1'],
+            ]],
         ],
         # 更多按钮
         /*
@@ -118,7 +118,7 @@ $config = [
                 ['content' => 24],
             ],
             '价格设置' => 'spec_type,psource/sku,psource/sku#',
-            '展示设置' => 'show_page,show_content,show_submit,show_sell,num_sell_add',
+            '展示设置' => 'show_page,show_submit,show_sell,num_sell_add',
             '限制设置' => 'have_vip',
             //'奖励设置' => 'psource/info_benefit',
         ],
@@ -234,11 +234,6 @@ $config = [
                 <br />内容详情页:按照排序进入,最新内容类别下最新的内容详情页',
             ],
 
-            'show_content' => [
-                'type' => 'radio',
-                'desc' => '设置之后,可以在资源介绍页查看内容',
-            ],
-
             'show_submit' => [
                 'type' => 'radio',
                 'desc' => '是否展示下单按钮',

+ 2 - 12
src/place/source/table/info.php

@@ -149,17 +149,7 @@ return [
         'show_sell' => [
             'name'      => '销量展示',
             'type'      => 'tinyint(1)',
-            'default'   => 2,
-            'value'     => [
-                1 => '显示',
-                2 => '不显示',
-            ],
-        ],
-
-        'show_content'       => [
-            'name'      => '内容展示',
-            'type'      => 'tinyint(1)',
-            'default'   => 2,
+            'default'   => 1,
             'value'     => [
                 1 => '显示',
                 2 => '不显示',
@@ -175,7 +165,7 @@ return [
         'status' => [
             'name'      => '状态',
             'type'      => 'tinyint(1)',
-            'default'   => 2,
+            'default'   => 1,
             'value'     => [
                 1 => '上架',
                 2 => '下架',

+ 119 - 5
src/sector/app/Api/Cron.php

@@ -11,7 +11,8 @@ class Cron
     # 处理待收货订单 7天未确认收货将自动收货 一个小时执行一次吧
     public function finishOrder()
     {
-        $this->exe(function($place, $time) {
+        $time = time();
+        $this->exe(function($place) use($time) {
             # 订单过期,超过1个小时没支付的
             $date = $time - 3600;
             $order = Dever::db('porder/source')->load(['status' => 1, 'cdate' => ['<', $date]]);
@@ -29,17 +30,17 @@ class Cron
     }
 
     # 执行所有身份里的方法
-    public function exe($call)
+    public function exe($call, $where = [])
     {
         # 仅获取活跃的
-        $time = time();
-        $code = Dever::db('place/code')->select(['status' => 1]);
+        $where['status'] = 1;
+        $code = Dever::db('place/code')->select($where);
         foreach ($code as $k => $v) {
             $place = Dever::load(\Place\Lib\Info::class)->encode($v['sector_id'], $v['user_id'], $v['place_id']);
 
             Dever::load(\Manage\Lib\Util::class)->setAuth('sector', 'sector_place', $v['sector_id'], $v['place_id']);
 
-            $call($place, $time);
+            $call($place);
         }
     }
 
@@ -54,4 +55,117 @@ class Cron
             return $data;
         }
     }
+
+    # 采集又拍云 临时功能,后续加到万接里
+    # http://127.0.0.1/ydb/src/sector/?l=cron.youpai&link=https://3087659634.x.yupoo.com/categories/4932135
+    public function youpai()
+    {
+        Dever::apply('querylist/vendor/autoload');
+        $link = 'https://3087659634.x.yupoo.com/categories/4932135';
+        $link = Dever::input('link');
+
+        $this->exe(function($place) use($link) {
+            $header = [
+                'Referer' => 'https://3087659634.x.yupoo.com/',
+            ];
+            $ql = \QL\QueryList::get($link);
+            $name = $ql->find('.yupoo-crumbs-span')->eq(1)->title;
+            if (strstr($name, '】')) {
+                $temp = explode('】', $temp);
+                $name = $temp[1];
+            }
+            $price = 488;
+
+            $source = [];
+            $source['name'] = $name;
+            $info = Dever::db('psource/info')->find($source);
+            if (!$info) {
+                $source['type'] = 1;
+                $source['channel_id'] = 1;
+                $source['cate_parent_id'] = 1;
+                $source['cate_child_id'] = 4;
+                $source['cate_id'] = $source['cate_child_id'];
+                $source['cate'] = $source['channel_id'] . ',' . $source['cate_parent_id'] . ',' . $source['cate_child_id'];
+                $source['price'] = $price;
+                $source['status'] = 1;
+                $id = Dever::db('psource/info')->insert($source);
+            } else {
+                $id = $info['id'];
+            }
+            $data = $ql->rules([
+                'title' => ['.album__title','text'],
+                'pic' => ['img','data-src']
+            ])->range('.album__categories-box .categories__children')->query()->getData()->all();
+            $i = 0;
+            $sizes = [];
+            $up = [];
+            $up['pic'] = [];
+            foreach ($data as $v) {
+                $attr = $this->parseProductInfo($v['title']);
+                if ($attr['color']) {
+                    if ($attr['sizes']) {
+                        $sizes = $attr['sizes'];
+                    } else {
+                        $attr['sizes'] = $sizes;
+                    }
+                    if (!$attr['sizes']) {
+                        continue;
+                    }
+                    
+                    $v['pic'] = 'http:' . str_replace('medium', 'big', $v['pic']);
+                    $pic = Dever::curl($v['pic'], [], 'get', false, $header)->result();
+                    $pic = Dever::load(\Upload\Lib\Save::class)->init(1)->act($pic, $default_ext = 'jpg', false, md5($v['pic']), true)['url'];
+                    $up['pic'][] = $pic;
+
+                    # 建立规格
+                    $color = $attr['color'];
+                    $sku_name = [];
+                    foreach ($attr['sizes'] as $size) {
+                        $sku_name[] = '颜色:' . $color . ' & 尺寸:' . $size;
+                    }
+                    $i = Dever::load(\Psource\Lib\Info::class)->createSku($i, $id, $sku_name, '', $price, $pic, 1);
+                }
+            }
+            $up['pic'] = implode(',', $up['pic']);
+            Dever::db('psource/info')->update($id, $up);
+        }, ['code' => 'jiujiu']);
+    }
+
+    function parseProductInfo(string $text): array {
+        $result = [
+            'color' => null,
+            'size_range' => null,
+            'sizes' => [],
+        ];
+
+        // 预清理:去掉括号及其中内容(例如 “(情侣款)”)
+        $clean = preg_replace('/(.*?)/u', '', $text);
+        $clean = preg_replace('/\(.*?\)/u', '', $clean); // 英文括号
+
+        // 提取尺寸区间或单个尺寸
+        if (preg_match('/(\d{1,3})\s*[-–—]\s*(\d{1,3})/u', $clean, $m)) {
+            $a = (int)$m[1];
+            $b = (int)$m[2];
+            if ($a > $b) { [$a, $b] = [$b, $a]; }
+            $result['size_range'] = "{$a}-{$b}";
+            $result['sizes'] = range($a, $b);
+        } elseif (preg_match('/\b(\d{1,3})\b/u', $clean, $m)) {
+            $n = (int)$m[1];
+            $result['size_range'] = (string)$n;
+            $result['sizes'] = [$n];
+        }
+
+        // 提取颜色
+        // 匹配常见颜色后缀(色、银、金、灰、白、黑、蓝、绿、红、粉、棕、紫等)
+        if (preg_match('/([一-龥]{1,6}(色|银|金|灰|白|黑|蓝|绿|红|粉|棕|紫))/u', $clean, $m)) {
+            $result['color'] = $m[1];
+        } else {
+            // fallback:取数字前最后一段汉字
+            if (preg_match('/([一-龥]{1,6})\d/u', $clean, $m)) {
+                $result['color'] = $m[1];
+            }
+        }
+
+        return $result;
+    }
 }