需求以下: html
開發一個管理員,叫作業務員有特別的權限,就是後臺能夠給業務員一個帳號,而後業務員每次出去拉到團購回來,上傳商戶,以後,運營後能在業務員本身的帳號權限內看到本身所拉業務下面的詳細統計,包括多少個商戶,成交了多少團購,,等,,可是看不到別的業務員的。node
思路以下:sql
商戶添加的時候填寫推薦人,而後關聯管理員數據表,只查詢登陸用戶的推薦商戶數據。數據庫
大致步驟以下:session
①修改表,添加操做者字段;spa
alter table fanwe_supplier
add column operator_id varchar(55);code
② 後臺添加商戶的時候,加當前登陸管理員的ID,htm
經過session數據或者手動填表單的形式,將操做者寫入商戶列表的數據表。blog
③統計報表選項添加, 查看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";