💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 导入商品信息生成唯一码 **位置:** Common\Lib\GoodsLib.class.php **参数:** * @param $style Array 品牌编号和中类的数组 * @return Array 生成系统款号的数组 **调用:** * $GoodsLib = new GoodsLib; * $GoodsLib->getSystemStyleNo($style) ; **完整代码:** ~~~ /** * 导入商品信息生成系统款号 * whz 2018-05-17 * @param $style array 生成系统款号的商品信息 * @return array 生成系统款号的数组 */ public function getSystemStyleNo($style) { // 生成规则是: 品牌+小类+四位国际款号(或者随机数) $style_no = $style['style_no']; $index_num = $style['index_num']; $brand_id = $style['brand']; $middle_class = $style['small_class']; $no = substr($style_no, $index_num, 4); // $system_style_no = $m.$brand_id.$y.$middle_class.$no; $system_style_no = $brand_id.$middle_class.$no; // 判断生成的系统款号是否存在 $res_no = M('goods_spu') ->where(['spu_no' => $system_style_no, 'is_delete' => 0]) ->find(); if (!empty($res_no)) { return ['type' => 1, 'system_style_no' => $res_no['spu_no'], 'num' => $res_no['num'], 'spu_id' => $res_no['id'], 'menu' => $res_no]; } else { // 系统代码如果在MAP里面存在,并且不和其供应商款号相等,就换另外一个索引值,再插入数据库,如果不存在直接插入,否则直接返回; $res = M('goods_spu')->where(['spu_no' => $system_style_no, 'is_affirm' => 1])->find(); if (count($res) >0 || !empty($res)) { // 递归判断生成随机数 $rand = $this->GetfourStr(4); // $system_style_no = $m.$brand_id.$y.$middle_class.$rand; $system_style_no = $brand_id.$middle_class.$rand; $res = M('goods_spu')->where(['spu_no' => $system_style_no])->find(); if (count($res) >0 || !empty($res)) { $arr = getSystemStyleNos($style); return $arr; } else { return ['type' => 2, 'system_style_no' => $system_style_no]; } } return ['type' => 2, 'system_style_no' => $system_style_no]; } } ~~~