eric_weixin 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{LICENSE.txt → MIT-LICENSE} +1 -3
- data/README.rdoc +24 -0
- data/Rakefile +36 -1
- data/app/assets/javascripts/eric_weixin/application.js +25 -0
- data/app/assets/javascripts/eric_weixin/cms/base.js +22 -0
- data/app/assets/stylesheets/eric_weixin/application.css +15 -0
- data/app/assets/stylesheets/eric_weixin/cms/base.css.scss +14 -0
- data/app/assets/stylesheets/eric_weixin/cms/foundation_and_overrides.scss +1454 -0
- data/app/controllers/eric_weixin/application_controller.rb +5 -0
- data/app/controllers/eric_weixin/cms/base_controller.rb +19 -0
- data/app/controllers/eric_weixin/cms/weixin/article_datas_controller.rb +45 -0
- data/app/controllers/eric_weixin/cms/weixin/customs_service_records_controller.rb +8 -0
- data/app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb +52 -0
- data/app/controllers/eric_weixin/cms/weixin/public_accounts_controller.rb +36 -0
- data/app/controllers/eric_weixin/cms/weixin/reply_message_rules_controller.rb +49 -0
- data/app/controllers/eric_weixin/cms/weixin/two_dimension_codes_controller.rb +36 -0
- data/app/controllers/eric_weixin/cms/weixin/url_encodes_controller.rb +41 -0
- data/app/controllers/eric_weixin/cms/weixin/users_controller.rb +19 -0
- data/{lib/eric_weixin/app/controllers/weixin → app/controllers/eric_weixin/wz}/weixin_controller.rb +18 -7
- data/app/helpers/eric_weixin/application_helper.rb +4 -0
- data/app/helpers/eric_weixin/cms/weixin/public_accounts_helper.rb +28 -0
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/access_token.rb +23 -9
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/article.rb +0 -0
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/article_news.rb +0 -0
- data/app/models/eric_weixin/customs_service_record.rb +99 -0
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/message_log.rb +8 -2
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/news.rb +0 -0
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/public_account.rb +25 -14
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/reply_message_rule.rb +56 -12
- data/app/models/eric_weixin/report/interface_data.rb +120 -0
- data/app/models/eric_weixin/report/msg_data.rb +292 -0
- data/app/models/eric_weixin/report/news_data.rb +264 -0
- data/app/models/eric_weixin/report/user_data.rb +98 -0
- data/app/models/eric_weixin/template_message_log.rb +87 -0
- data/{lib/eric_weixin/app/model → app/models/eric_weixin}/two_dimension_code.rb +25 -17
- data/app/models/eric_weixin/weixin_user.rb +155 -0
- data/app/views/eric_weixin/cms/weixin/article_datas/_article_data.html.erb +8 -0
- data/app/views/eric_weixin/cms/weixin/article_datas/edit.html.erb +36 -0
- data/app/views/eric_weixin/cms/weixin/article_datas/index.html.erb +21 -0
- data/app/views/eric_weixin/cms/weixin/article_datas/new.html.erb +36 -0
- data/app/views/eric_weixin/cms/weixin/article_datas/show.html.erb +5 -0
- data/app/views/eric_weixin/cms/weixin/customs_service_records/index.html.erb +66 -0
- data/app/views/eric_weixin/cms/weixin/news_datas/_news_data.html.erb +7 -0
- data/app/views/eric_weixin/cms/weixin/news_datas/edit.html.erb +45 -0
- data/app/views/eric_weixin/cms/weixin/news_datas/index.html.erb +30 -0
- data/app/views/eric_weixin/cms/weixin/news_datas/new.html.erb +49 -0
- data/app/views/eric_weixin/cms/weixin/news_datas/show.html.erb +28 -0
- data/app/views/eric_weixin/cms/weixin/public_accounts/_menu.html.erb +5 -0
- data/app/views/eric_weixin/cms/weixin/public_accounts/_public_account.html.erb +19 -0
- data/app/views/eric_weixin/cms/weixin/public_accounts/_weixin_user.html.erb +7 -0
- data/app/views/eric_weixin/cms/weixin/public_accounts/index.html.erb +27 -0
- data/app/views/eric_weixin/cms/weixin/public_accounts/show.html.erb +8 -0
- data/app/views/eric_weixin/cms/weixin/reply_message_rules/destroy.js.erb +2 -0
- data/app/views/eric_weixin/cms/weixin/reply_message_rules/edit.html.erb +69 -0
- data/app/views/eric_weixin/cms/weixin/reply_message_rules/index.html.erb +38 -0
- data/app/views/eric_weixin/cms/weixin/reply_message_rules/new.html.erb +69 -0
- data/app/views/eric_weixin/cms/weixin/two_dimension_codes/_two_dimension_code_form.html.erb +11 -0
- data/app/views/eric_weixin/cms/weixin/two_dimension_codes/index.html.erb +30 -0
- data/app/views/eric_weixin/cms/weixin/two_dimension_codes/new.html.erb +41 -0
- data/app/views/eric_weixin/cms/weixin/two_dimension_codes/show.html.erb +12 -0
- data/app/views/eric_weixin/cms/weixin/url_encodes/_new.html.erb +25 -0
- data/app/views/eric_weixin/cms/weixin/url_encodes/create.js.erb +1 -0
- data/app/views/eric_weixin/cms/weixin/url_encodes/index.html.erb +43 -0
- data/app/views/eric_weixin/cms/weixin/users/index.html.erb +331 -0
- data/app/views/layouts/eric_weixin/application.html.erb +14 -0
- data/app/views/layouts/eric_weixin/cms/base.html.erb +66 -0
- data/{lib/eric_weixin/app/views → app/views/layouts}/eric_weixin/weixin/aa.erb +0 -0
- data/config/initializers/assets.rb +10 -0
- data/config/routes.rb +36 -0
- data/db/migrate/20150610031604_create_weixin_report_user_data.rb +14 -0
- data/db/migrate/20150610031935_create_weixin_report_news_data.rb +24 -0
- data/db/migrate/20150610032545_create_weixin_report_msg_data.rb +17 -0
- data/db/migrate/20150610032852_create_weixin_report_interface_data.rb +15 -0
- data/db/migrate/20150610035901_add_user_data_type_to_weixin_report_user_data.rb +5 -0
- data/db/migrate/20150610040008_add_news_data_type_to_weixin_report_news_data.rb +5 -0
- data/db/migrate/20150610040059_add_msg_data_type_to_weixin_report_msg_data.rb +5 -0
- data/db/migrate/20150610040145_add_interface_data_type_to_weixin_report_interface_data.rb +5 -0
- data/db/migrate/20150610072952_add_total_online_time_and_user_source_to_weixin_report_news_data.rb +6 -0
- data/db/migrate/20150610084545_add_user_source_to_weixin_report_msg_data.rb +5 -0
- data/db/migrate/20150610090206_create_weixin_user.rb +153 -0
- data/db/migrate/20150612104303_add_index_to_weixin_message_logs.rb +7 -0
- data/db/migrate/20150625065249_delete_clomn_weixin_token_from_public_account.rb +5 -0
- data/lib/eric_weixin/engine.rb +9 -0
- data/lib/eric_weixin/modules/analyze_data.rb +124 -0
- data/lib/eric_weixin/modules/ip.rb +33 -0
- data/lib/eric_weixin/modules/mult_customer.rb +113 -0
- data/lib/eric_weixin/{app/moudles → modules}/reply_message.rb +3 -3
- data/lib/eric_weixin/{app/moudles → modules}/snsapi.rb +3 -3
- data/lib/eric_weixin/version.rb +1 -1
- data/lib/eric_weixin.rb +6 -24
- data/lib/tasks/eric_weixin_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +78 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/eric_weixin_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +19 -0
- metadata +165 -196
- data/.gitignore +0 -23
- data/.idea/.name +0 -1
- data/.idea/.rakeTasks +0 -7
- data/.idea/encodings.xml +0 -5
- data/.idea/eric_weixin.iml +0 -22
- data/.idea/misc.xml +0 -5
- data/.idea/modules.xml +0 -9
- data/.idea/scopes/scope_settings.xml +0 -5
- data/.idea/vcs.xml +0 -7
- data/.rvmrc +0 -1
- data/Gemfile +0 -4
- data/README.md +0 -29
- data/eric_weixin.gemspec +0 -32
- data/lib/eric_weixin/app/model/template_message_log.rb +0 -75
- data/lib/eric_weixin/app/model/weixin_user.rb +0 -96
- data/lib/eric_weixin/app/moudles/mult_customer.rb +0 -57
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>EricWeixin</title>
|
5
|
+
<%= stylesheet_link_tag "eric_weixin/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "eric_weixin/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8"/>
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
6
|
+
|
7
|
+
<title><%= content_for?(:title) ? yield(:title) : "小神龙后台管理" %></title>
|
8
|
+
<%= javascript_include_tag "eric_weixin/cms/base" %>
|
9
|
+
<%= stylesheet_link_tag "eric_weixin/cms/base" %>
|
10
|
+
<%= javascript_include_tag "vendor/modernizr" %>
|
11
|
+
<%= csrf_meta_tags %>
|
12
|
+
</head>
|
13
|
+
|
14
|
+
|
15
|
+
<body>
|
16
|
+
|
17
|
+
<script>
|
18
|
+
<% if @is_popup.blank? || @is_popup == true %>
|
19
|
+
<% notice = get_notice_str %>
|
20
|
+
<% unless notice.blank? %>
|
21
|
+
$(document).ready(
|
22
|
+
function () {
|
23
|
+
$('#NoticeModal').foundation('reveal', 'open');
|
24
|
+
}
|
25
|
+
);
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
</script>
|
29
|
+
|
30
|
+
|
31
|
+
<div id="NoticeModal" class="reveal-modal" data-reveal>
|
32
|
+
<div class="row">
|
33
|
+
<%= notice %>
|
34
|
+
</div>
|
35
|
+
<a class="close-reveal-modal">×</a>
|
36
|
+
</div>
|
37
|
+
<section role="main">
|
38
|
+
<div class="row">
|
39
|
+
<div class="small-11 columns">
|
40
|
+
<br/>
|
41
|
+
<div class="row right">
|
42
|
+
<div class="small-12 columns">
|
43
|
+
<%= '你好! ' + begin current_employee.real_name rescue '' end%>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
<div class="row">
|
47
|
+
<div class="small-12 columns">
|
48
|
+
<% flash.each do |key, value| %>
|
49
|
+
<div data-alert class="alert-box <%= key %> radius" id="alert-box-div">
|
50
|
+
<%= value %>
|
51
|
+
<a href="javascript:alert_box_close()" class="close" id="alert-box-div-close">×</a>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
<%= yield %>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
</section>
|
60
|
+
</body>
|
61
|
+
</html>
|
62
|
+
<script language="javascript">
|
63
|
+
function alert_box_close(){
|
64
|
+
$("#alert-box-div").remove();
|
65
|
+
}
|
66
|
+
</script>
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Precompile additional assets.
|
7
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
8
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
9
|
+
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.js )
|
10
|
+
Rails.application.config.assets.precompile += %w( eric_weixin/cms/base.css )
|
data/config/routes.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
EricWeixin::Engine.routes.draw do
|
2
|
+
get "/weixin/service/:app_id" => "wz/weixin#index"
|
3
|
+
post "/weixin/service/:app_id" => "wz/weixin#reply"
|
4
|
+
get "/weixin/service1/ddd" => "wz/weixin#aa"
|
5
|
+
get "/weixin/snsapi" => "wz/weixin#snsapi_api"
|
6
|
+
get "/weixin/snsuserinfo" => "wz/weixin#snsapi_userinfo"
|
7
|
+
post "/weixin/snsapi" => "wz/weixin#snsapi_api"
|
8
|
+
post "/weixin/snsuserinfo" => "wz/weixin#snsapi_userinfo"
|
9
|
+
namespace :cms do
|
10
|
+
namespace :weixin do
|
11
|
+
resources :public_accounts do
|
12
|
+
member do
|
13
|
+
get :rebuild_weixin_users
|
14
|
+
get :export
|
15
|
+
post :create_menu
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
resources :article_datas
|
20
|
+
resources :news_datas
|
21
|
+
resources :users do
|
22
|
+
member do
|
23
|
+
post :modify_remark
|
24
|
+
end
|
25
|
+
end
|
26
|
+
resources :reply_message_rules
|
27
|
+
|
28
|
+
resources :two_dimension_codes
|
29
|
+
resources :url_encodes
|
30
|
+
|
31
|
+
|
32
|
+
resources :customs_service_records
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateWeixinReportUserData < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_report_user_data do |t|
|
4
|
+
t.date :ref_date
|
5
|
+
t.integer :user_source
|
6
|
+
t.integer :new_user
|
7
|
+
t.integer :cancel_user
|
8
|
+
t.integer :cumulate_user
|
9
|
+
t.integer :weixin_public_account_id
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateWeixinReportNewsData < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_report_news_data do |t|
|
4
|
+
t.date :ref_date
|
5
|
+
t.string :ref_hour
|
6
|
+
t.date :stat_date
|
7
|
+
t.string :msgid
|
8
|
+
t.string :title
|
9
|
+
t.integer :int_page_read_user
|
10
|
+
t.integer :int_page_read_count
|
11
|
+
t.integer :ori_page_read_user
|
12
|
+
t.integer :ori_page_read_count
|
13
|
+
t.integer :share_scene
|
14
|
+
t.integer :share_user
|
15
|
+
t.integer :share_count
|
16
|
+
t.integer :add_to_fav_user
|
17
|
+
t.integer :add_to_fav_count
|
18
|
+
t.integer :target_user
|
19
|
+
t.integer :weixin_public_account_id
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateWeixinReportMsgData < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_report_msg_data do |t|
|
4
|
+
t.date :ref_date
|
5
|
+
t.string :ref_hour
|
6
|
+
t.integer :msg_type
|
7
|
+
t.integer :msg_user
|
8
|
+
t.integer :msg_count
|
9
|
+
t.integer :count_interval
|
10
|
+
t.integer :int_page_read_count
|
11
|
+
t.integer :ori_page_read_user
|
12
|
+
t.integer :weixin_public_account_id
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateWeixinReportInterfaceData < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :weixin_report_interface_data do |t|
|
4
|
+
t.date :ref_date
|
5
|
+
t.integer :ref_hour
|
6
|
+
t.integer :callback_count
|
7
|
+
t.integer :fail_count
|
8
|
+
t.integer :total_time_cost
|
9
|
+
t.integer :max_time_cost
|
10
|
+
t.integer :weixin_public_account_id
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
class CreateWeixinUser < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
execute 'CREATE TABLE `weixin_users` (
|
4
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
5
|
+
`subscribe` int(11) DEFAULT NULL,
|
6
|
+
`openid` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
7
|
+
`nickname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
8
|
+
`sex` int(11) DEFAULT NULL,
|
9
|
+
`language` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
10
|
+
`city` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
11
|
+
`province` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
12
|
+
`country` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
13
|
+
`headimgurl` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
14
|
+
`subscribe_time` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
15
|
+
`remark` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
16
|
+
`member_info_id` int(11) DEFAULT NULL,
|
17
|
+
`created_at` datetime DEFAULT NULL,
|
18
|
+
`updated_at` datetime DEFAULT NULL,
|
19
|
+
`weixin_public_account_id` int(11) DEFAULT NULL,
|
20
|
+
`last_register_channel` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
21
|
+
`first_register_channel` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
|
22
|
+
PRIMARY KEY (`id`),
|
23
|
+
KEY `index_weixin_users_on_member_info_id` (`member_info_id`) USING BTREE,
|
24
|
+
KEY `index_weixin_users_on_nickname` (`nickname`) USING BTREE,
|
25
|
+
KEY `index_weixin_users_on_openid` (`openid`) USING BTREE,
|
26
|
+
KEY `index_weixin_users_on_subscribe` (`subscribe`) USING BTREE
|
27
|
+
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
28
|
+
|
29
|
+
execute 'CREATE TABLE `weixin_two_dimension_codes` (
|
30
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
31
|
+
`weixin_public_account_id` int(11) DEFAULT NULL,
|
32
|
+
`expire_seconds` int(11) DEFAULT NULL,
|
33
|
+
`action_name` varchar(30) DEFAULT NULL,
|
34
|
+
`action_info` varchar(200) DEFAULT NULL,
|
35
|
+
`scene_id` int(11) DEFAULT NULL,
|
36
|
+
`scene_str` varchar(64) DEFAULT NULL,
|
37
|
+
`ticket` varchar(100) DEFAULT NULL,
|
38
|
+
`url` varchar(500) DEFAULT NULL,
|
39
|
+
`expire_at` datetime DEFAULT NULL,
|
40
|
+
PRIMARY KEY (`id`)
|
41
|
+
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;'
|
42
|
+
|
43
|
+
|
44
|
+
execute 'CREATE TABLE `weixin_template_message_logs` (
|
45
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
46
|
+
`openid` varchar(100) DEFAULT NULL,
|
47
|
+
`url` varchar(255) DEFAULT NULL,
|
48
|
+
`topcolor` varchar(20) DEFAULT NULL,
|
49
|
+
`data` text,
|
50
|
+
`message_id` varchar(50) DEFAULT NULL,
|
51
|
+
`error_code` varchar(10) DEFAULT NULL,
|
52
|
+
`status` varchar(50) DEFAULT NULL,
|
53
|
+
`created_at` datetime DEFAULT NULL,
|
54
|
+
`updated_at` datetime DEFAULT NULL,
|
55
|
+
`template_id` varchar(50) DEFAULT NULL,
|
56
|
+
`weixin_public_account_id` int(11) DEFAULT NULL,
|
57
|
+
PRIMARY KEY (`id`)
|
58
|
+
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;'
|
59
|
+
|
60
|
+
|
61
|
+
execute 'CREATE TABLE `weixin_reply_message_rules` (
|
62
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
63
|
+
`key_word` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
64
|
+
`reply_message` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
65
|
+
`key_word_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
66
|
+
`is_valid` tinyint(1) DEFAULT NULL,
|
67
|
+
`created_at` datetime DEFAULT NULL,
|
68
|
+
`updated_at` datetime DEFAULT NULL,
|
69
|
+
`order` int(11) DEFAULT NULL,
|
70
|
+
`reply_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
71
|
+
`weixin_public_account_id` int(11) DEFAULT NULL,
|
72
|
+
PRIMARY KEY (`id`),
|
73
|
+
KEY `index_weixin_reply_message_rules_on_is_valid` (`is_valid`) USING BTREE,
|
74
|
+
KEY `index_weixin_reply_message_rules_on_key_word` (`key_word`) USING BTREE,
|
75
|
+
KEY `index_weixin_reply_message_rules_on_key_word_type` (`key_word_type`) USING BTREE,
|
76
|
+
KEY `index_weixin_reply_message_rules_on_order` (`order`) USING BTREE
|
77
|
+
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
78
|
+
|
79
|
+
|
80
|
+
execute 'CREATE TABLE `weixin_public_accounts` (
|
81
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
82
|
+
`weixin_secret_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
83
|
+
`weixin_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
84
|
+
`weixin_app_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
85
|
+
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
86
|
+
`menu_json` text COLLATE utf8_unicode_ci,
|
87
|
+
`weixin_number` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
|
88
|
+
PRIMARY KEY (`id`),
|
89
|
+
KEY `index_weixin_public_accounts_on_weixin_secret_key` (`weixin_secret_key`) USING BTREE,
|
90
|
+
KEY `index_weixin_public_accounts_on_weixin_token` (`weixin_token`) USING BTREE
|
91
|
+
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
92
|
+
|
93
|
+
execute 'CREATE TABLE `weixin_news` (
|
94
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
95
|
+
`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
96
|
+
`created_at` datetime DEFAULT NULL,
|
97
|
+
`updated_at` datetime DEFAULT NULL,
|
98
|
+
`match_key` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
99
|
+
PRIMARY KEY (`id`)
|
100
|
+
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
101
|
+
|
102
|
+
execute 'CREATE TABLE `weixin_message_logs` (
|
103
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
104
|
+
`openid` varchar(100) DEFAULT NULL,
|
105
|
+
`message_type` varchar(30) DEFAULT NULL,
|
106
|
+
`message_id` varchar(50) DEFAULT NULL,
|
107
|
+
`data` text,
|
108
|
+
`account_receive_flg` int(11) DEFAULT NULL,
|
109
|
+
`passive_reply_message` text,
|
110
|
+
`process_status` int(11) DEFAULT NULL,
|
111
|
+
`event_name` varchar(30) DEFAULT NULL,
|
112
|
+
`create_time` int(11) DEFAULT NULL,
|
113
|
+
`parent_id` int(11) DEFAULT NULL,
|
114
|
+
`created_at` datetime DEFAULT NULL,
|
115
|
+
`updated_at` datetime DEFAULT NULL,
|
116
|
+
`event_key` varchar(600) DEFAULT NULL,
|
117
|
+
`weixin_public_account_id` int(11) DEFAULT NULL,
|
118
|
+
PRIMARY KEY (`id`)
|
119
|
+
) ENGINE=InnoDB AUTO_INCREMENT=62 DEFAULT CHARSET=utf8;'
|
120
|
+
|
121
|
+
execute 'CREATE TABLE `weixin_articles` (
|
122
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
123
|
+
`title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
124
|
+
`desc` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
125
|
+
`pic_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
126
|
+
`link_url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
127
|
+
`created_at` datetime DEFAULT NULL,
|
128
|
+
`updated_at` datetime DEFAULT NULL,
|
129
|
+
PRIMARY KEY (`id`)
|
130
|
+
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
131
|
+
|
132
|
+
execute 'CREATE TABLE `weixin_article_news` (
|
133
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
134
|
+
`weixin_article_id` int(11) DEFAULT NULL,
|
135
|
+
`weixin_news_id` int(11) DEFAULT NULL,
|
136
|
+
`created_at` datetime DEFAULT NULL,
|
137
|
+
`updated_at` datetime DEFAULT NULL,
|
138
|
+
`sort` int(11) DEFAULT NULL,
|
139
|
+
PRIMARY KEY (`id`)
|
140
|
+
) ENGINE=InnoDB AUTO_INCREMENT=70 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
141
|
+
|
142
|
+
execute 'CREATE TABLE `weixin_access_tokens` (
|
143
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
144
|
+
`access_token` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
145
|
+
`expired_at` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
|
146
|
+
`created_at` datetime DEFAULT NULL,
|
147
|
+
`updated_at` datetime DEFAULT NULL,
|
148
|
+
`public_account_id` int(11) DEFAULT NULL,
|
149
|
+
PRIMARY KEY (`id`),
|
150
|
+
KEY `index_weixin_access_tokens_on_access_token` (`access_token`) USING BTREE
|
151
|
+
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EricWeixin
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace EricWeixin
|
4
|
+
initializer "eric_weixin.assets.precompile" do |app|
|
5
|
+
app.config.assets.precompile += %w( cms/base.js )
|
6
|
+
app.config.assets.precompile += %w( cms/base.css.scss )
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# 数据统计接口模块
|
2
|
+
module EricWeixin::AnalyzeData
|
3
|
+
|
4
|
+
# 自动去微信服务器拉取当日之前的统计模块的数据.
|
5
|
+
# ===参数说明
|
6
|
+
# * weixin_public_account_id # 微信公众号ID
|
7
|
+
# ===调用实例
|
8
|
+
# ::EricWeixin::AnalyzeData::InterfaceData.auto_get_and_save_data_from_weixin 1
|
9
|
+
def self.auto_get_and_save_data_from_weixin weixin_public_account_id
|
10
|
+
::EricWeixin::Report::UserData.auto_execute_get_and_save_data_from_weixin weixin_public_account_id
|
11
|
+
::EricWeixin::Report::NewsData.auto_execute_get_and_save_data_from_weixin weixin_public_account_id
|
12
|
+
::EricWeixin::Report::MsgData.auto_execute_get_and_save_data_from_weixin weixin_public_account_id
|
13
|
+
::EricWeixin::Report::InterfaceData.auto_execute_get_and_save_data_from_weixin weixin_public_account_id
|
14
|
+
end
|
15
|
+
|
16
|
+
# -------------------用户分析数据接口------------------------------------
|
17
|
+
|
18
|
+
def self.get_user_summary options
|
19
|
+
get_data_json "https://api.weixin.qq.com/datacube/getusersummary?access_token=", options
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.get_user_cumulate options
|
23
|
+
get_data_json "https://api.weixin.qq.com/datacube/getusercumulate?access_token=", options
|
24
|
+
end
|
25
|
+
|
26
|
+
# -------------------图文分析数据接口------------------------------------
|
27
|
+
|
28
|
+
# 获取图文群发每日数据(getarticlesummary)
|
29
|
+
def self.get_article_summary options
|
30
|
+
get_data_json "https://api.weixin.qq.com/datacube/getarticlesummary?access_token=", options
|
31
|
+
end
|
32
|
+
|
33
|
+
# 获取图文群发总数据(getarticletotal)
|
34
|
+
def self.get_article_total options
|
35
|
+
get_data_json "https://api.weixin.qq.com/datacube/getarticletotal?access_token=", options
|
36
|
+
end
|
37
|
+
|
38
|
+
# 获取图文统计数据(getuserread)
|
39
|
+
def self.get_user_read options
|
40
|
+
get_data_json "https://api.weixin.qq.com/datacube/getuserread?access_token=", options
|
41
|
+
end
|
42
|
+
|
43
|
+
# 获取图文统计分时数据(getuserreadhour)
|
44
|
+
def self.get_user_read_hour options
|
45
|
+
get_data_json "https://api.weixin.qq.com/datacube/getuserreadhour?access_token=", options
|
46
|
+
end
|
47
|
+
|
48
|
+
# 获取图文分享转发数据(getusershare)
|
49
|
+
def self.get_user_share options
|
50
|
+
get_data_json "https://api.weixin.qq.com/datacube/getusershare?access_token=", options
|
51
|
+
end
|
52
|
+
|
53
|
+
# 获取图文分享转发分时数据(getusersharehour)
|
54
|
+
def self.get_user_share_hour options
|
55
|
+
get_data_json "https://api.weixin.qq.com/datacube/getusersharehour?access_token=", options
|
56
|
+
end
|
57
|
+
|
58
|
+
# -------------------消息分析数据接口------------------------------------
|
59
|
+
|
60
|
+
# 获取消息发送概况数据(getupstreammsg)
|
61
|
+
def self.get_upstream_msg options
|
62
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsg?access_token=", options
|
63
|
+
end
|
64
|
+
|
65
|
+
# 获取消息分送分时数据(getupstreammsghour)
|
66
|
+
def self.get_upstream_msg_hour options
|
67
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsghour?access_token=", options
|
68
|
+
end
|
69
|
+
|
70
|
+
# 获取消息发送周数据(getupstreammsgweek)
|
71
|
+
def self.get_upstream_msg_week options
|
72
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsgweek?access_token=", options
|
73
|
+
end
|
74
|
+
|
75
|
+
# 获取消息发送月数据(getupstreammsgmonth)
|
76
|
+
def self.get_upstream_msg_month options
|
77
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsgmonth?access_token=", options
|
78
|
+
end
|
79
|
+
|
80
|
+
# 获取消息发送分布数据(getupstreammsgdist)
|
81
|
+
def self.get_upstream_msg_dist options
|
82
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsgdist?access_token=", options
|
83
|
+
end
|
84
|
+
|
85
|
+
# 获取消息发送分布周数据(getupstreammsgdistweek)
|
86
|
+
def self.get_upstream_msg_dist_week options
|
87
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsgdistweek?access_token=", options
|
88
|
+
end
|
89
|
+
|
90
|
+
# 获取消息发送分布月数据(getupstreammsgdistmonth)
|
91
|
+
def self.get_upstream_msg_dist_month options
|
92
|
+
get_data_json "https://api.weixin.qq.com/datacube/getupstreammsgdistmonth?access_token=", options
|
93
|
+
end
|
94
|
+
|
95
|
+
# -------------------接口分析数据接口------------------------------------
|
96
|
+
|
97
|
+
# 获取接口分析数据(getinterfacesummary)
|
98
|
+
def self.get_interface_summary options
|
99
|
+
get_data_json "https://api.weixin.qq.com/datacube/getinterfacesummary?access_token=", options
|
100
|
+
end
|
101
|
+
|
102
|
+
# 获取接口分析分时数据(getinterfacesummaryhour)
|
103
|
+
def self.get_interface_summary_hour options
|
104
|
+
get_data_json "https://api.weixin.qq.com/datacube/getinterfacesummaryhour?access_token=", options
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def self.get_data_json url, options
|
110
|
+
pa = ::EricWeixin::PublicAccount.find(options[:weixin_public_account_id])
|
111
|
+
BusinessException.raise '公众账号未查询到' if pa.blank?
|
112
|
+
token = ::EricWeixin::AccessToken.get_valid_access_token_by_app_id app_id: pa.weixin_app_id
|
113
|
+
url = url + token
|
114
|
+
post_data = {
|
115
|
+
:begin_date => options[:begin_date],
|
116
|
+
:end_date => options[:end_date]
|
117
|
+
}
|
118
|
+
response = RestClient.post url, post_data.to_json
|
119
|
+
response = JSON.parse response.body
|
120
|
+
response
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|