# 批发市场
批发市场 : 建立分销商、供应商关系
建立关系流程:批发市场申请成为分销商 -> 供应商同意 -> 成为分销商
一、申请成为分销商(供应商不能是分销商)
文件路径:shop/controllers/Supplier/GoodsCtl.php
视图:shop/views/default/Supplier/GoodsCtl/goodslist.php
```
<pre class="calibre14">```
<span class="token"><</span>a class<span class="token">=</span><span class="token4">"apply_dist"</span> data<span class="token">-</span>id <span class="token">=</span> <span class="token"><</span><span class="token">?</span><span class="token">=</span>$val<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token">?</span><span class="token">></span> style<span class="token">=</span><span class="token4">"padding: 3.5px 50px;background-color: #e45050;color: white;"</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="token"><</span><span class="token">/</span>a<span class="token">></span>
$<span class="token1">(</span><span class="token4">".apply_dist"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var self_shop_type <span class="token">=</span> <span class="token"><</span><span class="token">?</span><span class="token">=</span>$shop_info<span class="token1">[</span><span class="token4">'shop_type'</span><span class="token1">]</span><span class="token">?</span><span class="token">></span><span class="token1">;</span>
var shop_id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">"data-id"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>self_shop_type <span class="token">==</span> <span class="token6">2</span><span class="token1">)</span><span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">"<?=__('供货商不能参与分销')?>!"</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
location<span class="token1">.</span>href <span class="token">=</span> SITE_URL<span class="token">+</span><span class="token4">"?ctl=Seller_Supplier_Supplier&met=apply&typ=e&shop_id="</span><span class="token">+</span>shop_id<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span>
```
```
申请路径:shop/controllers/Seller/Supplier/SupplierCtl.php
申请视图:shop/views/default/Seller/Supplier/SupplierCtl/apply.php
参数:shop\_id
方法:apply()
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span>$shop_id<span class="token1">)</span>
<span class="token1">{</span>
$shop_info <span class="token">=</span> $shopBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOneByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></span>$shop_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
$cat_row<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_id<span class="token1">;</span>
$shop_cat <span class="token">=</span> $shopGoodCatModel<span class="token">-</span><span class="token">></span><span class="token3">getGoodCatList</span><span class="token1">(</span>$cat_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
二、供应商审核分销商
文件路径:shop/controllers/Seller/Supplier/DistributorCtl.php
视图:shop/views/default/Seller/Supplier/DistributorCtl/index.php
- 审核通过:方法:edit\_statu()
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'act'</span><span class="token1">)</span> <span class="token">&&</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'act'</span><span class="token1">)</span> <span class="token">==</span> <span class="token4">'agree'</span><span class="token1">)</span>
<span class="token1">{</span>
$field_row<span class="token1">[</span><span class="token4">'distributor_enable'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span>
$field_row<span class="token1">[</span><span class="token4">'distributor_cat_ids'</span><span class="token1">]</span> <span class="token">=</span> $shop_dist_base<span class="token1">[</span><span class="token4">'distributor_new_cat_ids'</span><span class="token1">]</span><span class="token1">;</span>
$field_row<span class="token1">[</span><span class="token4">'distributor_new_cat_ids'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">''</span><span class="token1">;</span>
$flag<span class="token">=</span>$this<span class="token">-</span><span class="token">></span>shopDistributorModel<span class="token">-</span><span class="token">></span><span class="token3">editShopDistributor</span><span class="token1">(</span>$shop_distributor_id<span class="token1">,</span>$field_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//发送消息</span>
$MessageModel<span class="token">-</span><span class="token">></span><span class="token3">sendMessage</span><span class="token1">(</span><span class="token4">'dist apply statu'</span><span class="token1">,</span>$dist_shop_base<span class="token1">[</span><span class="token4">'user_id'</span><span class="token1">]</span><span class="token1">,</span> $dist_shop_base<span class="token1">[</span><span class="token4">'user_name'</span><span class="token1">]</span><span class="token1">,</span> $order_id <span class="token">=</span> NULL<span class="token1">,</span> $shop_name<span class="token">=</span><span class="token2">null</span><span class="token1">,</span> <span class="token6">1</span><span class="token1">,</span> <span class="token6">1</span><span class="token1">,</span> $end_time <span class="token">=</span> Null<span class="token1">,</span>$common_id<span class="token">=</span><span class="token2">null</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token3">elseif</span><span class="token1">(</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'act'</span><span class="token1">)</span> <span class="token">&&</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'act'</span><span class="token1">)</span> <span class="token">==</span> <span class="token4">'del'</span><span class="token1">)</span>
<span class="token1">{</span>
$flag<span class="token">=</span>$this<span class="token">-</span><span class="token">></span>shopDistributorModel<span class="token">-</span><span class="token">></span><span class="token3">removeShopDistributor</span><span class="token1">(</span>$shop_distributor_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//删除分销商品</span>
$goodsCommonModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Goods_CommonModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$commons <span class="token">=</span>$goodsCommonModel <span class="token">-</span><span class="token">></span> <span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></span>$dist_shop_base<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">,</span><span class="token4">'supply_shop_id'</span><span class="token">=</span><span class="token">></span>Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$commons<span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
foreach <span class="token1">(</span>$commons as $key <span class="token">=</span><span class="token">></span> $value<span class="token1">)</span> <span class="token1">{</span>
$goodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">removeCommon</span><span class="token1">(</span>$value<span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//发送消息</span>
$des <span class="token">=</span> <span class="token4">'供货商删除你的分销权限'</span><span class="token1">;</span>
$MessageModel<span class="token">-</span><span class="token">></span><span class="token3">sendMessage</span><span class="token1">(</span><span class="token4">'del goods'</span><span class="token1">,</span>$dist_shop_base<span class="token1">[</span><span class="token4">'user_id'</span><span class="token1">]</span><span class="token1">,</span> $dist_shop_base<span class="token1">[</span><span class="token4">'user_name'</span><span class="token1">]</span><span class="token1">,</span> $order_id <span class="token">=</span> NULL<span class="token1">,</span> $shop_name<span class="token">=</span><span class="token2">null</span><span class="token1">,</span> <span class="token6">1</span><span class="token1">,</span> <span class="token6">1</span><span class="token1">,</span> $end_time <span class="token">=</span> Null<span class="token1">,</span>$value<span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">,</span>$goods_id<span class="token">=</span><span class="token2">null</span><span class="token1">,</span>$des<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
- 分销商审核不通过:
视图:shop/views/default/Seller/Supplier/DistributorCtl/index.php
```
<pre class="calibre14">```
<span class="token"><</span>div id<span class="token">=</span><span class="token4">"apply-disagree"</span> class<span class="token">=</span><span class="token4">"eject_con"</span> <span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">"hidden"</span> name<span class="token">=</span><span class="token4">"shop_grade_id"</span> id<span class="token">=</span><span class="token4">"shop_grade_id"</span> value<span class="token">=</span><span class="token4">""</span> <span class="token">/</span><span class="token">></span>
<span class="token"><</span>textarea id<span class="token">=</span><span class="token4">"reason"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>textarea<span class="token">></span>
<span class="token"><</span>div class<span class="token">=</span><span class="token4">"eject_con mb10"</span><span class="token">></span>
<span class="token"><</span>div class<span class="token">=</span><span class="token4">"bottom"</span><span class="token">></span><span class="token"><</span>a id<span class="token">=</span><span class="token4">"btn_apply_submit"</span> class<span class="token">=</span><span class="token4">"button bbc_seller_submit_btns"</span> href<span class="token">=</span><span class="token4">"javascript:void(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="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>div<span class="token">></span>
<span class="token"><</span><span class="token">/</span>div<span class="token">></span>
<span class="token"><</span><span class="token">/</span>div<span class="token">></span>
$<span class="token1">(</span><span class="token4">"#btn_apply_submit"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var shop_distributor_id <span class="token">=</span> $<span class="token1">(</span><span class="token4">"#shop_distributor_id"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
var reason <span class="token">=</span> $<span class="token1">(</span><span class="token4">"#reason"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>reason<span class="token1">.</span>length <span class="token">==</span> <span class="token6">0</span><span class="token1">)</span><span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">'<?=__('</span>请填写原因<span class="token">!</span><span class="token4">')?>'</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 ajax_url <span class="token">=</span> <span class="token4">'./index.php?ctl=Seller_Supplier_Distributor&met=apply_disagree&typ=json'</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span>
url<span class="token1">:</span>ajax_url<span class="token1">,</span>
data<span class="token1">:</span><span class="token1">{</span>shop_distributor_id<span class="token1">:</span>shop_distributor_id<span class="token1">,</span>reason<span class="token1">:</span>reason<span class="token1">}</span><span class="token1">,</span>
success<span class="token1">:</span><span class="token2">function</span><span class="token1">(</span>a<span class="token1">)</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><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span>
```
```
方法:apply\_disagree()
```
<pre class="calibre15">```
<span class="token5">//不通过分销商申请,添加原因</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopDistributorModel<span class="token">-</span><span class="token">></span><span class="token3">editShopDistributor</span><span class="token1">(</span>$shop_distributor_id<span class="token1">,</span>$field_row<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
- 配置
- 平台帐号
- 活动数据表说明