# 淘宝导入
淘宝导入
文件路径:shop/controllers/Seller/Goods/TBImportCtl.php;
###### 导入csv文件
商品分类:
```
<pre class="calibre14">```
<span class="token"><</span>select name<span class="token">=</span><span class="token4">"sgcate_id[]"</span> class<span class="token">=</span><span class="token4">"sgcategory"</span><span class="token">></span>
<span class="token"><</span>option value<span class="token">=</span><span class="token4">"0"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'请选择'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$shop_goods_cat_rows<span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span>$shop_goods_cat_rows as $shop_goods_cat_id <span class="token">=</span><span class="token">></span> $shop_goods_cat_data<span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>option data<span class="token">-</span>parent_id<span class="token">=</span><span class="token4">"<?= $shop_goods_cat_data['parent_id'] ?>"</span> value<span class="token">=</span><span class="token4">"<?= $shop_goods_cat_id ?>"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span> $shop_goods_cat_data<span class="token1">[</span><span class="token4">'shop_goods_cat_name'</span><span class="token1">]</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>option value<span class="token">=</span><span class="token4">"-1"</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'暂无分类'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>select<span class="token">></span>
$<span class="token1">.</span><span class="token3">get</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Goods_Cat&met=cat&typ=json'</span><span class="token1">,</span> <span class="token1">{</span>cat_id<span class="token1">:</span> cat_id<span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span>
<span class="token5">//没有数据</span>
<span class="token2">if</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>length <span class="token">===</span> <span class="token6">0</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">return</span> <span class="token6">false</span><span class="token1">;</span>
<span class="token1">}</span>
var option_rows <span class="token">=</span> <span class="token1">[</span><span class="token1">]</span><span class="token1">,</span> cat_data <span class="token">=</span> data<span class="token1">.</span>data<span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>change<span class="token1">)</span> <span class="token1">{</span>
option_rows<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token4">"<option value='0'>请选择</option>"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">for</span> <span class="token1">(</span>var i <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> i <span class="token"><</span> cat_data<span class="token1">.</span>length<span class="token1">;</span> i<span class="token">++</span><span class="token1">)</span> <span class="token1">{</span>
option_rows<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token4">"<option value="</span> <span class="token">+</span> cat_data<span class="token1">[</span>i<span class="token1">]</span><span class="token1">.</span>cat_id <span class="token">+</span> <span class="token4">">"</span> <span class="token">+</span> cat_data<span class="token1">[</span>i<span class="token1">]</span><span class="token1">.</span>cat_name <span class="token">+</span> <span class="token4">"</option>"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">if</span> <span class="token1">(</span>change<span class="token1">)</span><span class="token1">{</span>
<span class="token5">//first create select</span>
<span class="token2">if</span> <span class="token1">(</span>option_rows<span class="token1">.</span>length <span class="token">></span> <span class="token6">0</span><span class="token1">)</span> <span class="token1">{</span>
<span class="token5">//default first goods_cat</span>
$<span class="token1">(</span><span class="token4">"#gc_id"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>cat_data<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span>cat_id<span class="token1">)</span><span class="token1">,</span> $<span class="token1">(</span><span class="token4">"#cat_name"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>cat_data<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span>cat_name<span class="token1">)</span><span class="token1">;</span>
var next_deep <span class="token">=</span> deep <span class="token">+</span> <span class="token6">1</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">"span[nctype=gc"</span> <span class="token">+</span> next_deep <span class="token">+</span> <span class="token4">"]"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">append</span><span class="token1">(</span><span class="token4">"<select data-deep="</span> <span class="token">+</span> next_deep <span class="token">+</span> <span class="token4">">"</span> <span class="token">+</span> option_rows<span class="token1">.</span><span class="token3">join</span><span class="token1">(</span><span class="token4">""</span><span class="token1">)</span> <span class="token">+</span> <span class="token4">"</select>"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
$select<span class="token1">.</span><span class="token3">append</span><span class="token1">(</span>option_rows<span class="token1">.</span><span class="token3">join</span><span class="token1">(</span><span class="token4">""</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>data<span class="token1">.</span>msg<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span>
```
```
所在地:
```
<pre class="calibre14">```
<span class="token2">function</span> <span class="token3">getDistrictList</span><span class="token1">(</span>province_id<span class="token1">,</span> change<span class="token1">)</span> <span class="token1">{</span>
change <span class="token">&&</span> $<span class="token1">(</span><span class="token4">"#city_id"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">remove</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>$<span class="token1">.</span><span class="token3">inArray</span><span class="token1">(</span>province_id<span class="token1">,</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">,</span> <span class="token6">2</span><span class="token1">,</span> <span class="token6">9</span><span class="token1">,</span> <span class="token6">22</span><span class="token1">]</span><span class="token1">)</span> <span class="token">!=</span> <span class="token">-</span><span class="token6">1</span><span class="token1">)</span> <span class="token2">return</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">get</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Base_District&met=district&pid=0&typ=json'</span><span class="token1">,</span> <span class="token1">{</span>pid<span class="token1">:</span> province_id<span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span>
var district_data <span class="token">=</span> data<span class="token1">.</span>data<span class="token1">.</span>items<span class="token1">,</span> district_row <span class="token">=</span> <span class="token1">[</span><span class="token1">]</span><span class="token1">;</span>
<span class="token2">for</span> <span class="token1">(</span> var i<span class="token">=</span><span class="token6">0</span><span class="token1">;</span> i<span class="token"><</span>district_data<span class="token1">.</span>length<span class="token1">;</span> i<span class="token">++</span> <span class="token1">)</span> <span class="token1">{</span>
district_row<span class="token1">.</span><span class="token3">push</span><span class="token1">(</span><span class="token4">"<option value="</span> <span class="token">+</span> district_data<span class="token1">[</span>i<span class="token1">]</span><span class="token1">.</span>district_id <span class="token">+</span> <span class="token4">">"</span> <span class="token">+</span> district_data<span class="token1">[</span>i<span class="token1">]</span><span class="token1">.</span>district_name <span class="token">+</span> <span class="token4">"</option>"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
district_row <span class="token">=</span> district_row<span class="token1">.</span><span class="token3">join</span><span class="token1">(</span><span class="token4">""</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>change<span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'#province_id'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">after</span><span class="token1">(</span><span class="token4">"<select id='city_id'>"</span> <span class="token">+</span> district_row <span class="token">+</span> <span class="token4">"</select>"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'#province_id'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">append</span><span class="token1">(</span>district_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span>data<span class="token1">.</span>msg<span class="token1">)</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
新增分类:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#add_sgcategory'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">".sgcategory:last"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">after</span><span class="token1">(</span>$<span class="token1">(</span><span class="token4">".sgcategory:last"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">clone</span><span class="token1">(</span><span class="token6">true</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token6">0</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
文件上传:
上传路径:shop/controllers/UploadCtl.php;
方法名:uploadGoodsExcel();
##### 上传商品图片
实例化
```
<pre class="calibre14">```
uploader <span class="token">=</span> WebUploader<span class="token1">.</span><span class="token3">create</span><span class="token1">(</span><span class="token1">{</span>
pick<span class="token1">:</span> <span class="token1">{</span>
id<span class="token1">:</span> <span class="token4">'#filePicker'</span><span class="token1">,</span>
label<span class="token1">:</span> <span class="token4">'点击选择图片'</span>
<span class="token1">}</span><span class="token1">,</span>
formData<span class="token1">:</span> <span class="token1">{</span>
uid<span class="token1">:</span> <span class="token6">123</span>
<span class="token1">}</span><span class="token1">,</span>
dnd<span class="token1">:</span> <span class="token4">'#dndArea'</span><span class="token1">,</span>
paste<span class="token1">:</span> <span class="token4">'#uploader'</span><span class="token1">,</span>
chunked<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
chunkSize<span class="token1">:</span> <span class="token6">512</span> <span class="token">*</span> <span class="token6">1024</span><span class="token1">,</span>
accept<span class="token1">:</span> <span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'taobaoImage'</span><span class="token1">,</span>
extensions<span class="token1">:</span> <span class="token4">"tbi,jpg"</span>
<span class="token1">}</span><span class="token1">,</span>
swf<span class="token1">:</span> BASE_URL <span class="token">+</span> <span class="token4">'/shop/static/common/js/Uploader.swf'</span><span class="token1">,</span>
server<span class="token1">:</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Upload&action=uploadTaoBaoImage&typ=json"</span><span class="token1">,</span>
fileVal<span class="token1">:</span> <span class="token4">'upfile'</span><span class="token1">,</span>
<span class="token5">// 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。</span>
disableGlobalDnd<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
fileNumLimit<span class="token1">:</span> <span class="token6">300</span><span class="token1">,</span>
fileSizeLimit<span class="token1">:</span> <span class="token6">200</span> <span class="token">*</span> <span class="token6">1024</span> <span class="token">*</span> <span class="token6">1024</span><span class="token1">,</span> <span class="token5">// 200 M</span>
fileSingleSizeLimit<span class="token1">:</span> <span class="token6">50</span> <span class="token">*</span> <span class="token6">1024</span> <span class="token">*</span> <span class="token6">1024</span> <span class="token5">// 50 M</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
上传路径:shop/controllers/UploadCtl.php;
方法名:uploadTaoBaoImage()
```
<pre class="calibre15">```
<span class="token5">// 生成上传实例对象并完成上传 </span>
$up <span class="token">=</span> <span class="token2">new</span> <span class="token3">Yf_Uploader</span><span class="token1">(</span>$field_name<span class="token1">,</span> $config<span class="token1">,</span> <span class="token4">"upload"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改goods_common表</span>
$goodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommon</span><span class="token1">(</span>$common_id<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">"common_image"</span> <span class="token">=</span><span class="token">></span> $image_url<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改goods_image</span>
$goodsImagesModel<span class="token">-</span><span class="token">></span><span class="token3">editImages</span><span class="token1">(</span> $images_id<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">"images_image"</span> <span class="token">=</span><span class="token">></span> $image_url<span class="token1">)</span> <span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改goods_base</span>
$goodsBaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$goods_id<span class="token1">,</span> $update_goods_data<span class="token1">,</span> <span class="token6">false</span><span class="token1">)</span><span class="token1">;</span>
```
```
- 序言
- 系统要求
- 版本更新日志
- 远丰商城技术对接说明
- 开发指导
- 框架内容
- 基础
- 开发规范
- 目录结构
- 架构
- 架构总览
- 数据库
- 数据库连接
- 基本使用
- 缓存
- 配置
- 路由
- 数据字典
- ucenter
- shop
- paycenter
- ucenter_admin
- shop_admin
- paycenter_admin
- 通讯内容
- 商家中心
- 顶部导航栏
- 店铺信息栏
- 店铺及商品提示栏
- 交易提示栏
- 销售情况统计栏
- 单品销量排行栏
- 店铺运营推广栏
- 平台联系方式栏
- 订单物流
- 商品
- 商品列表
- 商品详情
- 商品发布与编辑
- 分销商品
- 关联版式
- 商品规格
- 图片空间
- 淘宝导入
- 订单流程
- 交易订单
- 订单退款/退货
- 促销
- 团购管理
- 加价购
- 限时折扣
- 满即送
- 代金券管理
- 分销
- 店铺
- 店铺设置
- 自销产品供应商
- 实体店铺
- 品牌申请
- 店铺信息
- 消费者保障服务
- 门店账号
- 分销商--产品供应商
- 分销明细
- 批发市场
- 售后服务
- 咨询管理
- 投诉管理
- 退款管理
- 退货管理
- 云方案架构
- 负载集群
- 云存储
- 接口
- Api接口说明
- 品牌
- 商品规格
- 商品类型
- 商品分类
- 商品
- 订单
- 商品/店铺收藏
- 足迹
- 退款及退货
- 商家店铺
- 会员
- 入驻协议
- 订单接口
- 商品接口
- 订单物流接口
- 商家中心接口
- 促销接口
- 快递鸟物流接口
- 代金券接口
- 首页版块
- 团购
- 平台红包
- 限时折扣接口
- 拼团接口
- wap首页模板
- 杂项
- 远程上传图片
- JS
- 银联支付
- 多语言
- 商品评分
- 图片加载
- 买家申请退款退货
- 商家退款退货
- 平台退款退货
- 添加发票
- 提交订单
- 确认订单
- 运费销售区域
- 获取会员地址
- 充值
- 导出XLS
- 商城系统集成
- 多语言实现
- 三级分销推广链接发展推广员
- app.ini.php
- 去分销
- 版本更新
- 物流支持
- 运营人员建议
- 业务逻辑
- 统计结算
- 客服消息
- 账号
- 三级分销
- IM
- 配置
- 平台帐号
- 活动数据表说明