🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 分销 **分销员(非供应商用户)** 分销前提:在相应店铺购买过商品,且满足对应店铺申请成为分销员的条件 分销流程:分销中心申请分销 -> 店铺审核 -> 分销 一、申请分销 文件路径:shop/controllers/Distribution/Buyer/DirectsellerCtl.php 视图:shop/views/default/Distribution/Buyer/DirectsellerCtl/index.php ``` <pre class="calibre14">``` <span class="token"><</span><span class="token">!</span><span class="token">--</span><span class="token">-</span>满足申请条件<span class="token">--</span><span class="token">></span> <span class="token"><</span>a onclick<span class="token">=</span><span class="token4">"apply('<?=$val['shop_id']?>')"</span> class<span class="token">=</span><span class="token4">"to_views bbc_btns "</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-duigou1"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>script<span class="token">></span> <span class="token2">function</span> <span class="token3">apply</span><span class="token1">(</span>id<span class="token1">)</span> <span class="token1">{</span> var e <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">;</span> $<span class="token1">.</span>dialog<span class="token1">.</span><span class="token3">confirm</span><span class="token1">(</span><span class="token4">"<?=__('您确定要申请吗?')?>"</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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Distribution_Buyer_Directseller&met=addDirectseller&typ=json'</span><span class="token1">,</span><span class="token1">{</span>shop_id<span class="token1">:</span>id<span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>d<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>d<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span> var data <span class="token">=</span> d<span class="token1">.</span>data<span class="token1">;</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">success</span><span class="token1">(</span><span class="token4">"<?=__('申请成功!')?>"</span><span class="token1">)</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=Distribution_Buyer_Directseller&met=index'</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><span class="token4">"<?=__('申请失败!')?>"</span><span class="token1">)</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=Distribution_Buyer_Directseller&met=index'</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><span class="token1">;</span> <span class="token"><</span><span class="token">/</span>script<span class="token">></span> ``` ``` 方法:addDirectseller() ``` <pre class="calibre14">``` <span class="token5">// 添加店铺分销员</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>directseller_model<span class="token">-</span><span class="token">></span><span class="token3">addDirectseller</span><span class="token1">(</span>$data<span class="token1">)</span><span class="token1">;</span> ``` ``` 二、供应商发布商品 文件路径:shop/controllers/Distribution/Seller/SettingCtl.php 视图:shop/views/default/Distribution/Seller/SettingCtl/addDirectsellerGoods.php 提交商品表单验证:`$('#form').validator({})` 方法:addGoods() ``` <pre class="calibre14">``` <span class="token5">//新增分销商品</span> <span class="token2">if</span><span class="token1">(</span>$common_id_rows<span class="token1">)</span> <span class="token1">{</span> $Goods_CommonModel <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> <span class="token3">foreach</span><span class="token1">(</span>$common_id_rows as $k <span class="token">=</span><span class="token">></span> $v<span class="token1">)</span> <span class="token1">{</span> <span class="token5">//三级分佣</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//一级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_second_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_second_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//二级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_third_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_third_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//三级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_is_directseller'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> $common <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$v<span class="token1">)</span><span class="token1">;</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_commission'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">number_format</span><span class="token1">(</span><span class="token1">(</span><span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token">*</span>$common<span class="token1">[</span><span class="token4">'common_price'</span><span class="token1">]</span><span class="token">/</span><span class="token6">100</span><span class="token1">)</span><span class="token1">,</span> <span class="token6">2</span><span class="token1">,</span> <span class="token4">'.'</span><span class="token1">,</span> <span class="token4">''</span><span class="token1">)</span><span class="token1">;</span> $flag <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommon</span><span class="token1">(</span>$v<span class="token1">,</span> $common_data<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` 三、分销商品 文件路径:shop/controllers/Distribution/Buyer/GoodsCtl.php 视图:shop/views/default/Distribution/Buyer/GoodsCtl/index.php 分享推广: ``` <pre class="calibre14">``` <span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">'<?php echo urlencode(Yf_Registry::get('</span>base_url<span class="token4">').'</span><span class="token">/</span>shop<span class="token">/</span>api<span class="token">/</span>share<span class="token1">.</span>php<span class="token">?</span>type<span class="token">=</span>goods<span class="token">&</span>gid<span class="token">=</span><span class="token4">'.$goods_id.'</span><span class="token">&</span>rec<span class="token">=</span><span class="token4">'.$rec); ?>'</span> data<span class="token">-</span>url<span class="token">=</span><span class="token4">'<?php echo Yf_Registry::get('</span>base_url<span class="token4">').'</span><span class="token">/</span>shop<span class="token">/</span>api<span class="token">/</span>share<span class="token1">.</span>php<span class="token">?</span>type<span class="token">=</span>goods<span class="token">&</span>gid<span class="token">=</span><span class="token4">'.$goods_id.'</span><span class="token">&</span>rec<span class="token">=</span><span class="token4">'.$rec; ?>'</span> onclick<span class="token">=</span><span class="token4">"showLink(this);"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-chakan"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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="token5">//分享链接</span> <span class="token2">function</span> <span class="token3">showLink</span><span class="token1">(</span>ele<span class="token1">)</span> <span class="token1">{</span> $<span class="token1">(</span><span class="token4">'#dialog_link'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">yf_show_dialog</span><span class="token1">(</span><span class="token1">{</span>width<span class="token1">:</span> <span class="token6">550</span><span class="token1">,</span> title<span class="token1">:</span> <span class="token4">"<?=__('分享链接')?>"</span><span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> var val <span class="token">=</span> ele<span class="token1">.</span><span class="token3">getAttribute</span><span class="token1">(</span><span class="token4">'data-url'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#share-link'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>val<span class="token1">)</span><span class="token1">;</span> var param <span class="token">=</span> ele<span class="token1">.</span><span class="token3">getAttribute</span><span class="token1">(</span><span class="token4">"data-param"</span><span class="token1">)</span><span class="token1">;</span> var img <span class="token">=</span> <span class="token4">'<?=Yf_Registry::get('</span>base_url<span class="token4">')?>'</span><span class="token">+</span><span class="token4">'/shop/api/qrcode.php?data='</span><span class="token">+</span>param<span class="token">+</span><span class="token4">''</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#share_code'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'src'</span><span class="token1">,</span>img<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 四、店铺分销管理 文件路径:shop/controllers/Distribution/Seller/SettingCtl.php - 分销设置 视图:shop/views/default/Distribution/Seller/SettingCtl/index.php 设置消费金额限制表单提交:`$('#form').validator({})` 方法:edit() ``` <pre class="calibre14">``` $temp <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>Distribution_ShopDirectsellerConfigModel<span class="token">-</span><span class="token">></span><span class="token3">getConfigList</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> <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$temp<span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>Distribution_ShopDirectsellerConfigModel<span class="token">-</span><span class="token">></span><span class="token3">updateConfig</span><span class="token1">(</span>$shop_id<span class="token1">,</span>$edit_directseller_row<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token2">else</span><span class="token1">{</span> $edit_directseller_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> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>Distribution_ShopDirectsellerConfigModel<span class="token">-</span><span class="token">></span><span class="token3">addConfig</span><span class="token1">(</span>$edit_directseller_row<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` - 我的分销员 (1)分销员列表: 视图:shop/views/default/Distribution/Seller/SettingCtl/directseller.php 方法:directseller() ``` <pre class="calibre14">``` <span class="token5">//获取店铺分销员</span> $Yf_Page <span class="token">=</span> <span class="token2">new</span> <span class="token3">Yf_Page</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $Yf_Page<span class="token">-</span><span class="token">></span>listRows <span class="token">=</span> <span class="token6">15</span><span class="token1">;</span> $rows <span class="token">=</span> $Yf_Page<span class="token">-</span><span class="token">></span>listRows<span class="token1">;</span> $offset <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'firstRow'</span><span class="token1">,</span> <span class="token6">0</span><span class="token1">)</span><span class="token1">;</span> $page <span class="token">=</span> <span class="token3">ceil_r</span><span class="token1">(</span>$offset <span class="token">/</span> $rows<span class="token1">)</span><span class="token1">;</span> $data <span class="token">=</span> $Distribution_ShopDirectsellerModel<span class="token">-</span><span class="token">></span><span class="token3">getDirectseller</span><span class="token1">(</span>$cond_row<span class="token1">,</span>$order_row<span class="token1">,</span>$page<span class="token1">,</span>$rows<span class="token1">)</span><span class="token1">;</span> ``` ``` (2)分销员审核通过 方法:directseller() ``` <pre class="calibre14">``` <span class="token"><</span>span <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'directseller_enable'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">{</span><span class="token">?</span><span class="token">></span>class<span class="token">=</span><span class="token4">"unclick"</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>a href<span class="token">=</span><span class="token4">"javascript:void(0);"</span> data<span class="token">-</span>id<span class="token">=</span><span class="token4">'<?=$val['</span>shop_directseller_id<span class="token4">']?>'</span> <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token">!</span>$val<span class="token1">[</span><span class="token4">'directseller_enable'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">{</span> echo <span class="token4">'class="audit"'</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>i class<span class="token">=</span><span class="token4">"iconfont icon-success"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>span<span class="token">></span> $<span class="token1">(</span><span class="token4">".audit"</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 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="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>id<span class="token1">:</span>id<span class="token1">,</span>op<span class="token1">:</span><span class="token4">'audit'</span><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="token2">if</span><span class="token1">(</span>a<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">success</span><span class="token1">(</span><span class="token4">"<?=__('操作成功!')?>"</span><span class="token1">)</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=Distribution_Seller_Setting&met=directseller&typ=e'</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><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="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` ``` <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">'op'</span><span class="token1">)</span><span class="token">==</span><span class="token4">'audit'</span><span class="token1">)</span> <span class="token1">{</span> $id <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'id'</span><span class="token1">)</span><span class="token1">;</span> $field_row<span class="token1">[</span><span class="token4">'directseller_enable'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> $flag <span class="token">=</span> $Distribution_ShopDirectsellerModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$id<span class="token1">,</span>$field_row<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$flag <span class="token">===</span> FALSE<span class="token1">)</span> <span class="token1">{</span> $status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span> $msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'failure'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $status <span class="token">=</span> <span class="token6">200</span><span class="token1">;</span> $msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'success'</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> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> $data<span class="token1">,</span> $msg<span class="token1">,</span> $status<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` (3)删除分销员 方法:delDirectseller() ``` <pre class="calibre14">``` <span class="token"><</span>span class<span class="token">=</span><span class="token4">"del"</span><span class="token">></span> <span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">"{'ctl':'Distribution_Seller_Setting','met':'delDirectseller','id':'<?=$val['shop_directseller_id']?>'}"</span> href<span class="token">=</span><span class="token4">"javascript:void(0)"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-lajitong"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>span<span class="token">></span> ``` ``` ``` <pre class="calibre14">``` <span class="token5">//判断删除操作是不是当前店铺</span> <span class="token2">if</span> <span class="token1">(</span>$directseller<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span> <span class="token">==</span> $shop_id<span class="token1">)</span> <span class="token1">{</span> $flag <span class="token">=</span> $Distribution_ShopDirectsellerModel<span class="token">-</span><span class="token">></span><span class="token3">removeShopDirectseller</span><span class="token1">(</span>$shop_directseller_id<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$flag<span class="token1">)</span> <span class="token1">{</span> $status <span class="token">=</span> <span class="token6">200</span><span class="token1">;</span> $msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'success'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span> $msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'failure'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` - 分销商品 (1)分销商品列表 文件路径:shop/controllers/Distribution/Seller/SettingCtl.php 视图:shop/views/default/Distribution/Seller/SettingCtl/directsellerGoods.php `$data = $Goods_CommonModel->getGoodsList($cond_row,array('common_id' => 'DESC'), $page, $rows);` (2)删除分销商品 文件路径:shop/controllers/Seller/GoodsCtl.php 方法:deleteGoodsCommon() ``` <pre class="calibre14">``` <span class="token"><</span>span class<span class="token">=</span><span class="token4">"del"</span><span class="token">></span> <span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">"{'id':'<?= $item['common_id'] ?>','ctl':'Seller_Goods','met':'deleteGoodsCommon'}"</span> href<span class="token">=</span><span class="token4">"javascript:void(0)"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-lajitong"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>span<span class="token">></span> ``` ``` ``` <pre class="calibre14">``` <span class="token5">//删除分销商的商品</span> $dist_common <span class="token">=</span> $this<span class="token">-</span><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">'common_parent_id'</span> <span class="token">=</span><span class="token">></span> $id<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>$dist_common<span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> foreach <span class="token1">(</span>$dist_common as $key <span class="token">=</span><span class="token">></span> $value<span class="token1">)</span> <span class="token1">{</span> $common_base <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</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> $shop_base <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$common_base<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $this<span class="token">-</span><span class="token">></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>$shop_base<span class="token1">[</span><span class="token4">'user_id'</span><span class="token1">]</span><span class="token1">,</span> $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_base<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> ``` ``` (3)设置分佣比例 视图:shop/views/default/Distribution/Seller/SettingCtl/directsellerGoods.php 方法:editDirectsellerGoods() ``` <pre class="calibre14">``` <span class="token"><</span>span class<span class="token">=</span><span class="token4">"edit"</span><span class="token">></span> <span class="token"><</span>a href<span class="token">=</span><span class="token4">"javascript:void(0)"</span> common<span class="token">-</span>id<span class="token">=</span><span class="token4">'<?=$item['</span>common_id<span class="token4">']?>'</span> first_rate<span class="token">=</span><span class="token4">'<?=$item['</span>common_cps_rate<span class="token4">']?>'</span> second_rate<span class="token">=</span><span class="token4">'<?=$item['</span>common_second_cps_rate<span class="token4">']?>'</span> third_rate<span class="token">=</span><span class="token4">'<?=$item['</span>common_third_cps_rate<span class="token4">']?>'</span> id<span class="token">=</span><span class="token4">"set_commission"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-setting"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>span<span class="token">></span> <span class="token5">//设置分佣比例</span> $<span class="token1">(</span><span class="token4">'.table-list-style'</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="token4">'#set_commission'</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> var common_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">'common-id'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#common_id'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>common_id<span class="token1">)</span><span class="token1">;</span> var first_rate <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">'first_rate'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#common_cps_rate'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>first_rate<span class="token1">)</span><span class="token1">;</span> var second_rate <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">'second_rate'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#common_second_cps_rate'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>second_rate<span class="token1">)</span><span class="token1">;</span> var third_rate <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">'third_rate'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#common_third_cps_rate'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>third_rate<span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#dialog_directseller'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">yf_show_dialog</span><span class="token1">(</span><span class="token1">{</span>width<span class="token1">:</span> <span class="token6">450</span><span class="token1">,</span> title<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="token1">;</span> ``` ``` ``` <pre class="calibre14">``` <span class="token5">//三级分佣</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//一级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_second_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_second_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//二级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_third_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_third_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//三级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_is_directseller'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> $common <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$common_id<span class="token1">)</span><span class="token1">;</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_commission'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">number_format</span><span class="token1">(</span><span class="token1">(</span><span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token">*</span>$common<span class="token1">[</span><span class="token4">'common_price'</span><span class="token1">]</span><span class="token">/</span><span class="token6">100</span><span class="token1">)</span><span class="token1">,</span> <span class="token6">2</span><span class="token1">,</span> <span class="token4">'.'</span><span class="token1">,</span> <span class="token4">''</span><span class="token1">)</span><span class="token1">;</span> $flag <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommon</span><span class="token1">(</span>$common_id<span class="token1">,</span> $common_data<span class="token1">)</span><span class="token1">;</span> ``` ``` - 添加分销商品 文件路径:shop/controllers/Distribution/Seller/SettingCtl.php 视图:shop/views/default/Distribution/Seller/SettingCtl/addDirectsellerGoods.php 提交商品表单验证:`$('#form').validator({})` 方法:addGoods() ``` <pre class="calibre14">``` <span class="token5">//新增分销商品</span> <span class="token2">if</span><span class="token1">(</span>$common_id_rows<span class="token1">)</span> <span class="token1">{</span> $Goods_CommonModel <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> <span class="token3">foreach</span><span class="token1">(</span>$common_id_rows as $k <span class="token">=</span><span class="token">></span> $v<span class="token1">)</span> <span class="token1">{</span> <span class="token5">//三级分佣</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//一级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_second_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_second_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//二级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_third_cps_rate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_third_cps_rate'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//三级分佣比例</span> $common_data<span class="token1">[</span><span class="token4">'common_is_directseller'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> $common <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$v<span class="token1">)</span><span class="token1">;</span> $common_data<span class="token1">[</span><span class="token4">'common_cps_commission'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">number_format</span><span class="token1">(</span><span class="token1">(</span><span class="token3">request_float</span><span class="token1">(</span><span class="token4">'common_cps_rate'</span><span class="token1">)</span><span class="token">*</span>$common<span class="token1">[</span><span class="token4">'common_price'</span><span class="token1">]</span><span class="token">/</span><span class="token6">100</span><span class="token1">)</span><span class="token1">,</span> <span class="token6">2</span><span class="token1">,</span> <span class="token4">'.'</span><span class="token1">,</span> <span class="token4">''</span><span class="token1">)</span><span class="token1">;</span> $flag <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommon</span><span class="token1">(</span>$v<span class="token1">,</span> $common_data<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` - 分销业绩列表 视图:shop/views/default/Distribution/Seller/SettingCtl/directsellerDetail.php 方法:directsellerDetail() 模型:shop/models/Order/StateModel.php 分销交易状态: ``` <pre class="calibre14">``` <span class="token3">foreach</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span> as $k<span class="token">=</span><span class="token">></span>$v<span class="token1">)</span> <span class="token1">{</span> switch <span class="token1">(</span>$v<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> case Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY <span class="token1">:</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_status_text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'订单已经提交,等待买家付款'</span><span class="token1">;</span> <span class="token2">break</span><span class="token1">;</span> case Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_PAYED <span class="token1">:</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_status_text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'已经付款'</span><span class="token1">;</span> <span class="token2">break</span><span class="token1">;</span> case Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_CONFIRM_GOODS <span class="token1">:</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_status_text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'已经发货'</span><span class="token1">;</span> <span class="token2">break</span><span class="token1">;</span> case Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_RECEIVED <span class="token">||</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH <span class="token1">:</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_status_text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'已经收货'</span><span class="token1">;</span> <span class="token2">break</span><span class="token1">;</span> case Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">:</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_status_text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'交易关闭'</span><span class="token1">;</span> <span class="token2">break</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">if</span> <span class="token1">(</span>$v<span class="token1">[</span><span class="token4">'order_shipping_fee'</span><span class="token1">]</span> <span class="token">==</span> <span class="token6">0</span><span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'shipping_info'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">"(免运费)"</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $shipping_fee <span class="token">=</span> @<span class="token3">format_money</span><span class="token1">(</span>$v<span class="token1">[</span><span class="token4">'order_shipping_fee'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$k<span class="token1">]</span><span class="token1">[</span><span class="token4">'shipping_info'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">"(含运费$shipping_fee)"</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` 五、分销员分销中心 1.分销申请: 文件路径:shop/controllers/Distribution/Buyer/DirectsellerCtl.php 视图:shop/views/default/Distribution/Buyer/DirectsellerCtl/index.php ``` <pre class="calibre14">``` <span class="token"><</span><span class="token">!</span><span class="token">--</span><span class="token">-</span>满足申请条件<span class="token">--</span><span class="token">></span> <span class="token"><</span>a onclick<span class="token">=</span><span class="token4">"apply('<?=$val['shop_id']?>')"</span> class<span class="token">=</span><span class="token4">"to_views bbc_btns "</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-duigou1"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<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>script<span class="token">></span> <span class="token2">function</span> <span class="token3">apply</span><span class="token1">(</span>id<span class="token1">)</span> <span class="token1">{</span> var e <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">;</span> $<span class="token1">.</span>dialog<span class="token1">.</span><span class="token3">confirm</span><span class="token1">(</span><span class="token4">"<?=__('您确定要申请吗?')?>"</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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Distribution_Buyer_Directseller&met=addDirectseller&typ=json'</span><span class="token1">,</span><span class="token1">{</span>shop_id<span class="token1">:</span>id<span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>d<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span><span class="token1">(</span>d<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span> <span class="token1">{</span> var data <span class="token">=</span> d<span class="token1">.</span>data<span class="token1">;</span> Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">success</span><span class="token1">(</span><span class="token4">"<?=__('申请成功!')?>"</span><span class="token1">)</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=Distribution_Buyer_Directseller&met=index'</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><span class="token4">"<?=__('申请失败!')?>"</span><span class="token1">)</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=Distribution_Buyer_Directseller&met=index'</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><span class="token1">;</span> <span class="token"><</span><span class="token">/</span>script<span class="token">></span> ``` ``` 方法:addDirectseller() ``` <pre class="calibre14">``` <span class="token5">// 添加店铺分销员</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>directseller_model<span class="token">-</span><span class="token">></span><span class="token3">addDirectseller</span><span class="token1">(</span>$data<span class="token1">)</span><span class="token1">;</span> ``` ``` 2.商品列表 文件路径:shop/controllers/Distribution/Buyer/GoodsCtl.php 方法:index() ``` <pre class="calibre14">``` <span class="token5">//获取推广商品</span> $data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $Goods_CommonModel <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> $data <span class="token">=</span> $Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">getCommonList</span><span class="token1">(</span>$cond_good_row<span class="token1">,</span>$order_row<span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'user_id'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span> ``` ``` 3.我的推广 文件路径:shop/controllers/Distribution/Buyer/DirectsellerCtl.php 方法:directsellerList() ``` <pre class="calibre14">``` <span class="token5">//分销用户下级列表</span> <span class="token2">if</span><span class="token1">(</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'userName'</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'user_name:LIKE'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'%'</span><span class="token1">.</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'userName'</span><span class="token1">)</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><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">'month'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'user_regtime:<='</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">get_date_time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $beginDate <span class="token">=</span> <span class="token3">date</span><span class="token1">(</span><span class="token4">'Y-m-d H:i:s'</span><span class="token1">,</span><span class="token3">mktime</span><span class="token1">(</span><span class="token6">0</span><span class="token1">,</span><span class="token6">0</span><span class="token1">,</span><span class="token6">0</span><span class="token1">,</span><span class="token3">date</span><span class="token1">(</span><span class="token4">'m'</span><span class="token1">)</span><span class="token1">,</span><span class="token6">1</span><span class="token1">,</span><span class="token3">date</span><span class="token1">(</span><span class="token4">'Y'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $cond_row<span class="token1">[</span><span class="token4">'user_regtime:>='</span><span class="token1">]</span> <span class="token">=</span> $beginDate<span class="token1">;</span> <span class="token1">}</span> $order_row<span class="token1">[</span><span class="token4">'user_regtime'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'DESC'</span><span class="token1">;</span> $Yf_Page <span class="token">=</span> <span class="token2">new</span> <span class="token3">Yf_Page</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $Yf_Page<span class="token">-</span><span class="token">></span>listRows <span class="token">=</span> <span class="token6">15</span><span class="token1">;</span> $rows <span class="token">=</span> $Yf_Page<span class="token">-</span><span class="token">></span>listRows<span class="token1">;</span> $offset <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'firstRow'</span><span class="token1">,</span> <span class="token6">0</span><span class="token1">)</span><span class="token1">;</span> $page <span class="token">=</span> <span class="token3">ceil_r</span><span class="token1">(</span>$offset <span class="token">/</span> $rows<span class="token1">)</span><span class="token1">;</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>directseller_model<span class="token">-</span><span class="token">></span><span class="token3">getInvitors</span><span class="token1">(</span>$cond_row<span class="token1">,</span>$order_row<span class="token1">,</span>$page<span class="token1">,</span>$rows<span class="token1">)</span><span class="token1">;</span> ``` ``` 4.我的业绩 文件路径:shop/controllers/Distribution/Buyer/DirectsellerCtl.php 方法:directsellerOrder() 模型:shop/models/Order/StateModel.php ``` <pre class="calibre14">``` <span class="token5">//用户推广订单</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span> $cond_row<span class="token1">[</span><span class="token4">'directseller_id'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span> $Order_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $data <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getBaseList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'order_create_time'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'DESC'</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> ``` ``` 订单交易状态: ``` <pre class="calibre14">``` <span class="token5">//待付款</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'wait_pay'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token1">;</span> <span class="token1">}</span> <span class="token5">//待发货 -> 只可退款</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'wait_perpare_goods'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PREPARE_GOODS<span class="token1">;</span> <span class="token1">}</span> <span class="token5">//已付款</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'order_payed'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_PAYED<span class="token1">;</span> <span class="token1">}</span> <span class="token5">//待收货、已发货 -> 退款退货</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'wait_confirm_goods'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_CONFIRM_GOODS<span class="token1">;</span> <span class="token1">}</span> <span class="token5">//已完成 -> 订单评价</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'finish'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span> <span class="token1">}</span> <span class="token5">//已取消</span> <span class="token2">if</span> <span class="token1">(</span>$status <span class="token">==</span> <span class="token4">'cancel'</span><span class="token1">)</span> <span class="token1">{</span> $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">;</span> <span class="token1">}</span> ``` ``` 5.佣金记录 文件路径:shop/controllers/Distribution/Buyer/DirectsellerCtl.php 方法:directsellerCommission() ``` <pre class="calibre15">``` $cond_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span> $Order_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $data <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getBaseList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'order_create_time'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'DESC'</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> ``` ```