💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 三级分销推广链接发展推广员 #### 1.分销员推广链接 会员在店铺中的消费金额满足分销员申请条件后发起申请,当店铺审核通过后,会员才能成为分销员有推广链接。 ![](https://box.kancloud.cn/28079b8fc8f256984b0f27df0e9d6112_1234x595.png) ![](https://box.kancloud.cn/dbb22fafbeb6aa84e9f592ec02e019ea_1303x770.jpg) ![](https://box.kancloud.cn/f320ccf63182e60dfea965f8377e39b9_1268x653.jpg) 分销推广链接:index.php?ctl=Goods\_Goods&met=goods&type=goods&gid=153&rec=u10081s2c106 rec:推广分销员的信息 #### 2.打开分销推广链接 文件地址:shop/controllers/Goods/GoodsCtl.php 方法:goods() ``` <pre class="calibre14">``` <span class="token5">//判断是否开启分销插件</span> <span class="token2">if</span> <span class="token1">(</span>Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">'Plugin_Directseller'</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $goods_detail<span class="token1">[</span><span class="token4">'recImages'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">''</span><span class="token1">;</span> <span class="token5">//推荐者上传的图片</span> $PluginManager <span class="token">=</span> Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $data <span class="token">=</span> $PluginManager<span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'rec_goods'</span><span class="token1">)</span><span class="token1">;</span> $goods_detail<span class="token1">[</span><span class="token4">'recImages'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">isset</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'Plugin_Directseller_recGoods'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">?</span> $data<span class="token1">[</span><span class="token4">'Plugin_Directseller_recGoods'</span><span class="token1">]</span> <span class="token1">:</span> <span class="token4">''</span><span class="token1">;</span> <span class="token5">//--END</span> <span class="token1">}</span> ``` ``` #### 4.新用户通过分销推广链接注册 文件地址:shop/controllers/LoginCtl.php 方法:check() sass中规定只有新注册的用户才能发展为推广员,所以此处sass与shop的check()方法中可能有一点区别。sass中已注册会员发展推广员的代码注释了。 ``` <pre class="calibre14">``` <span class="token2">if</span> <span class="token1">(</span>Web_ConfigModel<span class="token1">:</span><span class="token1">:</span><span class="token3">value</span><span class="token1">(</span><span class="token4">'Plugin_Directseller'</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>$_COOKIE<span class="token1">[</span><span class="token4">'yf_recserialize'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> <span class="token5">//regDone</span> $PluginManager <span class="token">=</span> Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $PluginManager<span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'regDone'</span><span class="token1">,</span> $user_id<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` #### 5.$PluginManager = Yf\_Plugin\_Manager::getInstance(); 文件地址:shop/controllers/Plugin/Directseller.php ``` <pre class="calibre14">``` public <span class="token2">function</span> <span class="token3">recGoods</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $rec <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'rec'</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$rec<span class="token1">)</span> <span class="token1">{</span> $cond_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $cond_row<span class="token1">[</span><span class="token4">'shop_directseller_goods_common_code'</span><span class="token1">]</span> <span class="token">=</span> $rec<span class="token1">;</span> $Distribution_ShopDirectsellerGoodsCommonModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Distribution_ShopDirectsellerGoodsCommonModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $recImages <span class="token">=</span> $Distribution_ShopDirectsellerGoodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span> <span class="token3">setcookie</span><span class="token1">(</span><span class="token4">'yf_recserialize'</span><span class="token1">,</span>$rec<span class="token1">,</span><span class="token3">time</span><span class="token1">(</span><span class="token1">)</span><span class="token">+</span><span class="token6">60</span><span class="token">*</span><span class="token6">60</span><span class="token">*</span><span class="token6">24</span><span class="token">*</span><span class="token6">3</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>$recImages<span class="token1">[</span><span class="token4">'directseller_images_image'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> <span class="token3">explode</span><span class="token1">(</span><span class="token4">','</span><span class="token1">,</span>$recImages<span class="token1">[</span><span class="token4">'directseller_images_image'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> <span class="token2">return</span> $data<span class="token1">;</span> <span class="token1">}</span> ``` ``` ``` <pre class="calibre15">``` <span class="token5">/** * 注册完成后,判断是否需要建立分佣关系 * * @return mixed */</span> public <span class="token2">function</span> <span class="token3">regDone</span><span class="token1">(</span>$user_id<span class="token1">)</span> <span class="token1">{</span> $rec <span class="token">=</span> $_COOKIE<span class="token1">[</span><span class="token4">'yf_recserialize'</span><span class="token1">]</span><span class="token1">;</span> $b<span class="token">=</span> <span class="token1">(</span><span class="token3">strpos</span><span class="token1">(</span>$rec<span class="token1">,</span><span class="token4">"u"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $e<span class="token">=</span> <span class="token1">(</span><span class="token3">strpos</span><span class="token1">(</span>$rec<span class="token1">,</span><span class="token4">"s"</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'user_parent_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">substr</span><span class="token1">(</span>$rec<span class="token1">,</span>$b<span class="token">+</span><span class="token6">1</span><span class="token1">,</span>$e<span class="token">-</span><span class="token6">1</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">/* $User_BaseModel = new User_BaseModel(); $User_BaseModel->editBase($userid,$data); */</span> $User_InfoModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_InfoModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $User_InfoModel<span class="token">-</span><span class="token">></span><span class="token3">editInfo</span><span class="token1">(</span>$user_id<span class="token1">,</span>$data<span class="token1">)</span><span class="token1">;</span> <span class="token2">return</span> <span class="token6">true</span><span class="token1">;</span> <span class="token1">}</span> ``` ```