需求如下:
开发一个管理员,叫做业务员有特别的权限,就是后台可以给业务员一个账号,然后业务员每次出去拉到团购回来,上传商户,之后,运营后能在业务员自己的账号权限内看到自己所拉业务下面的详细统计,包括多少个商户,成交了多少团购,,等,,但是看不到别的业务员的。
思路如下:
商户添加的时候填写推荐人,然后关联管理员数据表,只查询登录用户的推荐商户数据。
大体步骤如下:
①修改表,添加操作者字段;
alter table fanwe_supplier
add column operator_id varchar(55);
② 后台添加商户的时候,加当前登录管理员的ID,
通过session数据或者手动填表单的形式,将操作者写入商户列表的数据表。
③统计报表选项添加, 查看left.html 得知是数据库出来的:
show tables like '%group%';
Tables_in_hdm1430549_db (%group%) |
fanwe_filter_group |
fanwe_images_group |
fanwe_images_group_link |
fanwe_link_group |
fanwe_point_group |
fanwe_point_group_link |
fanwe_role_group |
fanwe_supplier_tag_group_preset |
fanwe_tag_group |
fanwe_tag_group_link |
fanwe_topic_group |
fanwe_topic_group_cate |
fanwe_user_group |
fanwe_user_topic_group |
select * from fanwe_role_group where name like '%报表%';
id | name | nav_id | is_delete | is_effect | sort |
68 | 报表与结算 | 8 | 0 | 1 | 14 |
select * from fanwe_role_group where nav_id=8;
id | name | nav_id | is_delete | is_effect | sort |
16 | 支付接口 | 8 | 0 | 1 | 14 |
17 | 配送方式 | 8 | 0 | 1 | 15 |
23 | 订单管理 | 8 | 0 | 1 | 13 |
24 | 充值订单 | 8 | 0 | 1 | 13 |
68 | 报表与结算 | 8 | 0 | 1 | 14 |
查看action文件:
$nav_group = M("RoleGroup")->where("nav_id=".$nav_id." and is_effect = 1 and is_delete = 0")->order("sort asc")->findAll(); foreach($nav_group as $k=>$v) { $sql = "select role_node.`action` as a,role_module.`module` as m,role_node.id as nid,role_node.name as name from ".conf("DB_PREFIX")."role_node as role_node left join ". conf("DB_PREFIX")."role_module as role_module on role_module.id = role_node.module_id ". "where role_node.is_effect = 1 and role_node.is_delete = 0 and role_module.is_effect = 1 and role_module.is_delete = 0 and role_node.group_id = ".$v['id']." order by role_node.id asc"; $nav_group[$k]['nodes'] = M()->query($sql); }
select * from fanwe_role_node where name like '%报表%' limit 3;
id | action | name | is_effect | is_delete | group_id | module_id |
604 | index | 报表列表 | 1 | 0 | 68 | 112 |
select * from fanwe_role_module where name like '%报表%' limit 3;
id | module | name | is_effect | is_delete |
112 | Statistic | 报表 | 1 | 0 |
insert into fanwe_role_node values(null,'tongji','业务员列表',1,0,68,112);
新建tpl与action;
action:
$sql = "SELECT c.id, c.name,count(*) as num, sum(a.pay_amount) as money FROM `fanwe_deal_order` as a left join fanwe_deal as b on a.deal_ids = b.id left join fanwe_supplier as c on c.id = b.supplier_id WHERE a.is_delete = 0 and a.type = 0 and a.pay_status = 2 and c.operator_id is null group by c.id limit 33";