eric_weixin 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67b696e374ee5f2be50ca3e7790b18c22e6e13f3
4
- data.tar.gz: bc6d5445b2073a4e50982b5182c2490088373154
3
+ metadata.gz: 642edff6b9961fd9d985894da46515fe75d5aeda
4
+ data.tar.gz: 43103ab6656f7a14693bb62eccec56b70dcf7a3f
5
5
  SHA512:
6
- metadata.gz: 16c55ef32a6a7f31d286b5e1e2fe37a510428debddc4afd19c505d23de275263c40234a78afea002be5b02efec9baa24a67c1278980f54bf46d046ec5ba7905e
7
- data.tar.gz: 9a8dfb581b4a7d28d496465c560288a58a04e2b2b1660ac96e334d59a10d9fca0b71f03c0e5b2081aaab1e43eed9757aaf672e3fe38d9c2e1677ab08f9e74e76
6
+ metadata.gz: e96d4c0d4d55ce60178902daf6254134bf5150451f2f0a6aab6937590fbaec591b2a3c226cfd75b3f4145382a6efb62303249201075e00177d4106c06d0ab729
7
+ data.tar.gz: c39688341c2d05d8c7312d8b415d8e9466d17b6939eb0ee0a0aadb08e9c8e4b28f7361f16172ce8e27a21ee5e4ef4c805901aba15a009b6902a1e01cfa7dd4f1
@@ -0,0 +1,23 @@
1
+ class EricWeixin::Cms::Weixin::WeixinUsersController < EricWeixin::Cms::BaseController
2
+ def index
3
+ @public_accounts = ::EricWeixin::PublicAccount.all
4
+ public_account = ::EricWeixin::PublicAccount.find_by_id(params[:public_account_id])
5
+ @weixin_users = public_account.weixin_users.custom_query(params.permit(:subscribe,
6
+ :nickname,
7
+ :sex,
8
+ :city,
9
+ :province,
10
+ :weixin_public_account_id,
11
+ :start_date,
12
+ :end_date)).
13
+ order(id: :desc).
14
+ paginate(page: params[:page]||1, per_page: params[:per_page]||10) unless public_account.blank?
15
+ end
16
+
17
+ def modify_remark
18
+ user = ::EricWeixin::WeixinUser.find(params[:id])
19
+ user.set_remark params[:new_remark]
20
+ user.reload
21
+ render text: user.remark
22
+ end
23
+ end
@@ -3,7 +3,8 @@ class EricWeixin::ReplyMessageRule < ActiveRecord::Base
3
3
  scope :valid, -> { where(:is_valid => true) }
4
4
  belongs_to :weixin_public_account, :class_name => '::EricWeixin::PublicAccount', foreign_key: "weixin_public_account_id"
5
5
  delegate :name, to: :weixin_public_account, prefix: true, allow_nil: true
6
- KEY_WORD_TYPE_LABEL = {"keyword" => '字符', 'regularexpr' => '正则表达式'}
6
+ KEY_WORD_TYPE_LABEL = {"text" => '字符', 'regularexpr' => '正则表达式', 'event' => '事件'}
7
+
7
8
  REPLY_TYPE_LABEL = {"text" => '静态字符串', 'wx_function' => '动态运行', 'news' => '多图文'}
8
9
 
9
10
  validates_presence_of :key_word, message: "关键词不能为空。"
@@ -187,8 +188,10 @@ class EricWeixin::ReplyMessageRule < ActiveRecord::Base
187
188
 
188
189
  def match_key_words wx_key_word, public_account_id, receive_message,need_to_mult_service=true
189
190
  matched_rule = ::EricWeixin::ReplyMessageRule.order(order: :desc).
190
- where(:key_word => wx_key_word, :weixin_public_account_id => public_account_id, :key_word_type=>(receive_message[:MsgType]||"keyword")).first
191
+ where(:key_word => wx_key_word, :weixin_public_account_id => public_account_id, :key_word_type=>(receive_message[:MsgType]||"text")).first
191
192
  if matched_rule.nil?
193
+ # todo 处理正则表达式
194
+
192
195
  if need_to_mult_service
193
196
  return ::EricWeixin::ReplyMessage::transfer_mult_customer_service ToUserName: receive_message[:FromUserName],
194
197
  FromUserName: receive_message[:ToUserName]
@@ -151,5 +151,18 @@ class EricWeixin::WeixinUser < ActiveRecord::Base
151
151
  member_info
152
152
  end
153
153
  end
154
+
155
+ def custom_query options
156
+ users = self.all
157
+ users = users.where(subscribe: options[:subscribe]) unless options[:subscribe].blank?
158
+ users = users.where("nickname like ?", "%#{CGI::escape(options[:nickname])}%") unless options[:nickname].blank?
159
+ users = users.where(sex: options[:sex]) unless options[:sex].blank?
160
+ users = users.where(city: options[:city]) unless options[:city].blank?
161
+ users = users.where(province: options[:province]) unless options[:province].blank?
162
+ users = users.where(weixin_public_account_id: options[:weixin_public_account_id]) unless options[:weixin_public_account_id].blank?
163
+ users = users.where("subscribe_time >= ?", options[:start_date].to_date.to_time.to_i) unless options[:start_date].blank?
164
+ users = users.where("subscribe_time <= ?", (options[:end_date].to_date+1.day).to_time.to_i) unless options[:end_date].blank?
165
+ users
166
+ end
154
167
  end
155
168
  end
@@ -29,7 +29,7 @@
29
29
  <div class="large-8 columns">
30
30
  <select name="two[app_id]">
31
31
  <% @public_accounts.each do |public_account| %>
32
- <option value="<%= public_account.weixin_app_id %>"><%= public_account.weixin_number %></option>
32
+ <option value="<%= public_account.weixin_app_id %>"><%= public_account.name %></option>
33
33
  <% end %>
34
34
  </select>
35
35
  </div>
@@ -0,0 +1,128 @@
1
+ <h3>用户表</h3>
2
+ <%= form_tag '/eric_weixin/cms/weixin/weixin_users', method: :get do %>
3
+ <div class="row">
4
+ <div class="columns small-2 text-right">
5
+ <label class="inline">订阅状态</label>
6
+ </div>
7
+ <div class="columns small-2">
8
+ <%= select_tag :subscribe, options_from_collection_for_select({1=>'订阅',0=>'取消订阅'},'first','second',params[:subscribe]),prompt:"ALL" %>
9
+ </div>
10
+ <div class="columns small-2 text-right">
11
+ <label class="inline">昵称</label>
12
+ </div>
13
+ <div class="columns small-2">
14
+ <%= text_field_tag :nickname, params[:nickname] ,placeholder:"ALL" %>
15
+ </div>
16
+ <div class="columns small-2 text-right">
17
+ <label class="inline">性别</label>
18
+ </div>
19
+ <div class="columns small-2 end">
20
+ <%= select_tag :sex, options_from_collection_for_select(::EricWeixin::WeixinUser::SEX,'first','second',params[:sex]), prompt:"ALL" %>
21
+ </div>
22
+ </div>
23
+ <div class="row">
24
+ <div class="columns small-2 text-right">
25
+ <label class="inline">城市</label>
26
+ </div>
27
+ <div class="columns small-2">
28
+ <%= text_field_tag :city, params[:city] ,placeholder:"ALL" %>
29
+ </div>
30
+ <div class="columns small-2 text-right">
31
+ <label class="inline">省份</label>
32
+ </div>
33
+ <div class="columns small-2 end">
34
+ <%= text_field_tag :province, params[:province] ,placeholder:"ALL" %>
35
+ </div>
36
+
37
+
38
+ </div>
39
+ <div class="row">
40
+ <div class="columns small-2 text-right">
41
+ <label class="inline">关注日期起始</label>
42
+ </div>
43
+ <div class="columns small-2">
44
+ <%= date_field_tag :start_date, params[:start_date] %>
45
+ </div>
46
+ <div class="columns small-2 text-right">
47
+ <label class="inline">关注日期结束</label>
48
+ </div>
49
+ <div class="columns small-2">
50
+ <%= date_field_tag :end_date, params[:end_date] %>
51
+ </div>
52
+
53
+ <div class="columns small-2">
54
+ <%= select_tag :public_account_id, options_from_collection_for_select(@public_accounts, 'id', 'name', (params[:public_account_id].blank? ? '' : params[:public_account_id])), prompt: '请选择公众账号' %>
55
+ </div>
56
+
57
+ <div class="columns small-2 end">
58
+ <%= submit_tag '加载用户', class: 'button tiny' %>
59
+ </div>
60
+ </div>
61
+ <% end %>
62
+ <% unless @weixin_users.blank? %>
63
+ <%= will_paginate @collection, renderer: FoundationPagination::Rails %>
64
+ <table>
65
+ <thead>
66
+ <th width="150px">openid</th> <th>是否订阅</th> <th>昵称</th> <th>性别</th> <th>语言</th> <th>城市</th> <th>省份</th> <th>国家</th> <th>头像</th> <th>关注时间</th> <th>备注</th> <th>最后一次注册渠道</th> <th>第一次注册渠道</th><th>操作</th>
67
+ </thead>
68
+ <tbody>
69
+ <% @weixin_users.each do |user| %>
70
+ <tr>
71
+ <td style="word-wrap:break-word;word-break:break-all;"><%= user.openid %></td>
72
+ <td><%= case user.subscribe when 1 then '是' when 0 then '否' end %></td>
73
+ <td><%= user.nickname %></td>
74
+ <td><%= case user.sex when 1 then '男' when 2 then '女' else '未知' end %></td>
75
+ <td><%= case user.language when 'zh_CN' then '简体中文' when 'zh_TW' then '繁体中文' when 'en' then '英文' else '其它' end %></td>
76
+ <td><%= user.city %></td>
77
+ <td><%= user.province %></td>
78
+ <td><%= user.country %></td>
79
+ <td><%= image_tag(user.headimgurl, height: '32', width: '32') %></td>
80
+ <td><%= Time.at(user.subscribe_time.to_i).chinese_format %></td>
81
+ <td id="user_remark_<%= user.id %>"><%= user.remark %></td>
82
+ <td><%= user.last_register_channel %></td>
83
+ <td><%= user.first_register_channel %></td>
84
+ <td>
85
+ <%= link_to '备注', "javascript:open_modal(#{user.id})" %>
86
+ </td>
87
+ </tr>
88
+ <% end %>
89
+ </tbody>
90
+ </table>
91
+ <%= will_paginate @collection, renderer: FoundationPagination::Rails %>
92
+ <% end %>
93
+
94
+ <%= hidden_field_tag :hidden_user_id %>
95
+ <script language="javascript">
96
+ function open_modal(user_id){
97
+ $("#hidden_user_id").val(user_id);
98
+ $('#myModal').foundation('reveal', 'open');
99
+
100
+ }
101
+ function modify_remark(){
102
+ user_id = $("#hidden_user_id").val();
103
+ new_remark = $("#new_remark").val();
104
+ $.ajax({
105
+ url: "/eric_weixin/cms/weixin/users/"+user_id+"/modify_remark",
106
+ type: "post",
107
+ async: false,
108
+ data: {new_remark: new_remark}
109
+ }).done(
110
+ function(result){
111
+ $("#user_remark_"+user_id).html(result);
112
+ $('#myModal').foundation('reveal', 'close');
113
+ }
114
+ );
115
+ }
116
+ </script>
117
+
118
+
119
+
120
+ <div id="myModal" class="reveal-modal" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
121
+
122
+ <label class="inline left">新备注</label>
123
+ <%= text_field_tag :new_remark %>
124
+ <%= link_to "提交", "javascript:modify_remark()" %>
125
+
126
+
127
+ <a class="close-reveal-modal" aria-label="Close">&#215;</a>
128
+ </div>
data/config/routes.rb CHANGED
@@ -16,6 +16,12 @@ EricWeixin::Engine.routes.draw do
16
16
  end
17
17
  end
18
18
 
19
+ resources :weixin_users do
20
+ member do
21
+ post :modify_remark
22
+ end
23
+ end
24
+
19
25
  resources :article_datas
20
26
  resources :news_datas
21
27
  resources :users do
@@ -10,7 +10,7 @@ module EricWeixin::Snsapi
10
10
  # * schema_host 当前项目的域名(包含http://):如http://www.baidu.com
11
11
  # * state 这个参数可以直接带到业务页面。
12
12
  # ===调用示例
13
- # EricWeixin::Snsapi.get_snsapi_base_url url:'http://lxq.mdcc.club/weixin/member/login', app_id: 'wx51729870d9012531', schema_host: "http://lxq.mdcc.club"
13
+ #
14
14
  def self.get_snsapi_base_url options
15
15
  require 'base64'
16
16
  p_zhongzhuan = []
@@ -1,3 +1,3 @@
1
1
  module EricWeixin
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eric_weixin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - 刘晓琦
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -49,6 +49,7 @@ files:
49
49
  - app/controllers/eric_weixin/cms/weixin/two_dimension_codes_controller.rb
50
50
  - app/controllers/eric_weixin/cms/weixin/url_encodes_controller.rb
51
51
  - app/controllers/eric_weixin/cms/weixin/users_controller.rb
52
+ - app/controllers/eric_weixin/cms/weixin/weixin_users_controller.rb
52
53
  - app/controllers/eric_weixin/wz/weixin_controller.rb
53
54
  - app/helpers/eric_weixin/application_helper.rb
54
55
  - app/helpers/eric_weixin/cms/weixin/public_accounts_helper.rb
@@ -95,6 +96,7 @@ files:
95
96
  - app/views/eric_weixin/cms/weixin/url_encodes/create.js.erb
96
97
  - app/views/eric_weixin/cms/weixin/url_encodes/index.html.erb
97
98
  - app/views/eric_weixin/cms/weixin/users/index.html.erb
99
+ - app/views/eric_weixin/cms/weixin/weixin_users/index.html.erb
98
100
  - app/views/layouts/eric_weixin/application.html.erb
99
101
  - app/views/layouts/eric_weixin/cms/base.html.erb
100
102
  - app/views/layouts/eric_weixin/weixin/aa.erb