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