INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('202', '获取服务工单列表', '/admin/web/bookServes', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('203', '服务品类列表', '/admin/web/categories', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('204', '服务品类新增', '/admin/web/categories', 'POST', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('205', '预约调度列表', '/admin/web/bookDetails', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('206', '获取订单列表', '/admin/web/orders', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('207', '服务品类排序', '/admin/web/categories/sort', 'PUT', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('208', '导出商户结算列表', '/admin/web/merchants/settlement/export', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('209', '服务品类下架', '(/admin/web/categories/).*(/off)', 'PUT', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('210', '获取服务品类', '(/admin/web/categories/).*', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('211', '服务品类编辑', '(/admin/web/categories/).*', 'POST', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('212', '获取商户结算列表', '/admin/web/merchants/settlement', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('214', '统计商户结算数据', '/admin/web/merchants/settlement/count', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('215', '服务工单异常', '(/admin/web/bookServes/).*(/status)', 'PUT', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('216', '商户推荐配置', '(/admin/web/merchant/).*(/recommend/config)', 'POST', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('217', '服务品类上架', '(/admin/web/categories/).*(/on)', 'PUT', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('218', '服务品类页', '/admin/web/serviceCategory', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('219', '商户结算页', '/admin/web/merchantSettlement', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('220', '新增编辑服务品类页', '/admin/web/addCategory', 'GET', '0', '0');
INSERT INTO `1hjz`.`function_permission` (`id`, `name`, `url`, `method`, `create_time`, `del_flag`) VALUES ('221', '新增订单v2.5.0', '/admin/web/orders', 'POST', '0', '0');





-- 导出商户结算视图查询

CREATE VIEW v_consumer_book_detail_simple AS
SELECT
	b.merchant_no,
	b.book_no,
	b.linkman,
	b.address_telephone,
	u.mobile register_mobile,
	b.book_time,
	b.time_type,
	b.`status`,
	b.card_no,
	b.card_type,
	s.serve_no,
	c.id cleaner_id,
	c.nick_name cleaner_name,
	c.mobile cleaner_mobile
FROM
	book_detail b
LEFT JOIN `user` u ON b.user_id = u.user_id
LEFT JOIN cleaner_info c ON b.cleaner_id = c.user_id
LEFT JOIN book_serve s ON b.book_no = s.book_no
WHERE
	b.`status` IN ('30', '91')
AND b.del_flag = '0';


CREATE VIEW v_consuner_order_and_card AS
SELECT
	o.order_no,
	o.created_at,
	o.origin_total_price,
	o.pay_price,
	s.card_no AS service_card_no,
	s.card_type AS service_card_type,
	s.total_service_cnt,
	s.serviced_cnt,
	s.booked_cnt,
	IFNULL(r.commission, '0') commission
FROM
	vorder o
LEFT JOIN service_card s ON o.order_no = s.order_no
LEFT JOIN (
	SELECT
		order_no,
		commission
	FROM
		user_recommend
	WHERE
		status = '1'
) r ON o.order_no = r.order_no
WHERE
	1 = 1
AND o.`status` IN ('10', '11')
AND s.`status` < 40
AND o.del_flag = '0'
AND s.del_flag = '0';	
