eric_weixin 0.3.1 → 0.3.2

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: ce48f9412945bf98b5c5bc68fda84793b8c03799
4
- data.tar.gz: 43ad31fb81824b2bf4ec7d7636bf6d262811de98
3
+ metadata.gz: 99d5d996dd245394e948403c861009e6935fc33b
4
+ data.tar.gz: b9ddafb0c72823ef812729909ba21ecb738abd6f
5
5
  SHA512:
6
- metadata.gz: e177ab14e806a22b877a35a4b82d5ddb1b53b506ca1aac64f248d911e73b72f7dd9fefc8cde2de7f7714032278c7ed7e33fe341a58066c247ba4dee25174041b
7
- data.tar.gz: 3863b957b56b3f9decf645827a32f8321e9f988ccc8ef59314d0ad4bf2829c69b00b53a007f14b7b65933987f66559403e8bdb8445c01c61592d12bf77d9233f
6
+ metadata.gz: bc4bf189c3f62645d944df24b04eed1f7ae05a2fd33edc0f8d7b3a772a902c560fed5bab120654fead28cb98ad6e01d2715bfede51d2919b639483b133596605
7
+ data.tar.gz: 7df2fd4d756065acdcd70e9b071e5e9eaab8cd5273e6c1db7b6c5f17b28960fcbee63130f36a16fb1ec9e121a8e8a528a850cb8f7c22b3e15d13bd5dad9e9122
data/README.rdoc CHANGED
@@ -28,22 +28,31 @@
28
28
  * 图文素材管理: /eric_weixin/cms/weixin/article_datas
29
29
  * 链接管理: /eric_weixin/cms/weixin/url_encodes
30
30
  * 微信小店订单设置 /eric_weixin/cms/weixin/xiaodian/orders
31
+ * 微信小店商品刷新 /eric_weixin/cms/weixin/xiaodian/products
32
+ * 微信用户展示 /eric_weixin/cms/weixin/weixin_users
31
33
 
32
34
 
33
35
  ===微信小店的初始化
34
36
  * 首先对所经营的分类进行归类,并且把腾讯分类同步至数据库。为了避免分类过多,一般只同步自己行业的大类,大类编号请自查,如儿童玩具大类,食品类两类更新如下:
35
-
36
37
  EricWeixin::Xiaodian::Category.import_all_categories '公众账号名称,参考 weixin_public_account表', ['538088633','538071212']
37
38
  * 更新SKU信息
38
-
39
39
  EricWeixin::Xiaodian::Category.update_sku_info '公众账号名称,参考 weixin_public_account表'
40
40
  * 更新商品信息
41
-
42
41
  EricWeixin::Xiaodian::Product.get_all_products '公众账号名称,参考 weixin_public_account表'
43
42
  * 同步已有订单信息
44
-
45
43
  EricWeixin::Xiaodian::Order.get_order_list_and_update nil, nil ,nil ,'公众账号名称,参考 weixin_public_account表'
46
44
 
47
- *如果有新商品上架,则需要更新商品与SKU信息。 更新过程见商品列表页面,点击刷新按钮即可。由于接口调用限制,一天之内不要操作超过3次。
48
-
49
-
45
+ * 如果有新商品上架,则需要更新商品与SKU信息。 更新过程见商品列表页面,点击刷新按钮即可。由于接口调用限制,一天之内不要操作超过3次。
46
+
47
+ ===红包的使用
48
+ * 先在项目根目录新建一个名字叫ca的目录,并设置权限,让应用程序可读。 ca目录用于存放微信官方密钥证书,主要用于发红包过程中的通信加密。
49
+ * 在weixin_public_account中设置:mch_id: 商户号, mch_key:在商户后台写的32位的那个密码,host_name_wich_schema: 当前域名,在回调时需要参考此参数。
50
+ * 调用方式:
51
+ EricWeixin::RedpackOrder.create_redpack_order wishing: 'xxx',
52
+ client_ip: '127.0.0.1', # 换成自己服务器ip
53
+ act_name: '过年送红包',
54
+ remark: '一起开心一下,祝新年快乐',
55
+ send_name: 'U果源',
56
+ re_openid: openid, # 收红包人的openid
57
+ total_amount: 100 # 金额: 单位(分)
58
+ * 定时获取红包信息:使用EricWeixin::RedpackOrder的实例调用 get_info 信息。
@@ -12,7 +12,7 @@ class EricWeixin::Cms::BaseController < EricWeixin::ApplicationController
12
12
  end
13
13
 
14
14
  def need_login
15
- redirect_to '/' if current_user.blank?
15
+ redirect_to '/cms' if current_user.blank?
16
16
  return
17
17
  end
18
18
 
@@ -0,0 +1,18 @@
1
+ class EricWeixin::Cms::Weixin::Xiaodian::ProductsController < EricWeixin::Cms::BaseController
2
+ def index
3
+ @products = EricWeixin::Xiaodian::Product.all
4
+ @products = @products.where("id >= ?", params[:start_id]) unless params[:start_id].blank?
5
+ @products = @products.where("id <= ?", params[:end_id]) unless params[:end_id].blank?
6
+ @products = @products.order(id: :desc).paginate(per_page: params[:per_page]||6, page: params[:page]||1)
7
+ end
8
+
9
+ def get_all_products
10
+ EricWeixin::PublicAccount.all.each do |pb|
11
+ EricWeixin::Xiaodian::Product.get_all_products pb.name
12
+ EricWeixin::Xiaodian::Category.update_sku_info pb.name
13
+ end
14
+ redirect_to 'EricWeixin::Cms::Weixin::Xiaodian::Products#index'
15
+ end
16
+
17
+
18
+ end
@@ -143,7 +143,7 @@ class EricWeixin::PublicAccount < ActiveRecord::Base
143
143
  end
144
144
  end
145
145
  tmp_next_openid = response["next_openid"]
146
- self.rebuild_users tmp_next_openid unless tmp_next_openid.blank?
146
+ self.rebuild_users_simple tmp_next_openid unless tmp_next_openid.blank?
147
147
  end
148
148
  end
149
149
 
@@ -49,6 +49,7 @@ class EricWeixin::RedpackOrder < ActiveRecord::Base
49
49
  end
50
50
  end
51
51
 
52
+ # 定时使用 redpack_order 实例变量来完善补充红包信息。
52
53
  def get_info
53
54
  return unless self.redpacks.blank?
54
55
  EricWeixin::RedpackOrder.transaction do
@@ -18,6 +18,7 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
18
18
  }
19
19
 
20
20
  def product_info
21
+ return '' if self.sku_info.blank?
21
22
  info = ""
22
23
  list = self.sku_info.split(";")
23
24
  list.each do |sku|
@@ -90,6 +91,11 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
90
91
  end
91
92
 
92
93
 
94
+ def buyer_nick
95
+ CGI::unescape(self.attributes["buyer_nick"]) rescue '无法正常显示'
96
+ end
97
+
98
+
93
99
  # 根据订单ID获取订单详情
94
100
  def get_info
95
101
  token = ::EricWeixin::AccessToken.get_valid_access_token public_account_id: self.weixin_public_account_id
@@ -102,6 +108,8 @@ class EricWeixin::Xiaodian::Order < ActiveRecord::Base
102
108
  order_params.delete a
103
109
  end
104
110
 
111
+ order_params["buyer_nick"] = CGI::escape(order_params["buyer_nick"]) if not order_params["buyer_nick"].blank?
112
+
105
113
 
106
114
 
107
115
  # 获取订单详情前,weixin_product_id、sku_info、weixin_user_id应该已经有了值
@@ -0,0 +1,82 @@
1
+
2
+ <h3>产品列表</h3>
3
+
4
+
5
+ <%= button_to "刷新产品", 'products/get_all_products', method: :get, class: "button tiny" %>
6
+
7
+
8
+ <div class="row">
9
+ <%= form_tag "/eric_weixin/cms/weixin/xiaodian/products/", method: :get do %>
10
+ <div class="columns small-2">
11
+ <label class="inline text-right">起始ID</label>
12
+ </div>
13
+ <div class="columns small-3">
14
+ <%= number_field_tag 'start_id', params[:start_id], placeholder: '输入起始数字ID' %>
15
+ </div>
16
+ <div class="columns small-1 text-center">
17
+ <label class="inline center">终止ID</label>
18
+ </div>
19
+ <div class="columns small-3">
20
+ <%= number_field_tag 'end_id', params[:end_id], placeholder: '输入终止数字ID' %>
21
+ </div>
22
+ <div class="columns small-3 text-left">
23
+ <%= submit_tag "搜索", class: "button tiny" %>
24
+ </div>
25
+
26
+ <% end %>
27
+ </div>
28
+
29
+ <table>
30
+ <thead>
31
+ <tr>
32
+ <th>商品ID</th>
33
+ <th>商品名称</th>
34
+ <th>商品特点</th>
35
+ <th>SKU信息</th>
36
+ <th>商品状态</th>
37
+ <th>公众号</th>
38
+ </tr>
39
+ </thead>
40
+ <tbody>
41
+ <% @products.each do |product| %>
42
+ <tr>
43
+ <td><%= product.id %></td>
44
+ <td><%= product.name %></td>
45
+ <td>
46
+ <% str = product.properties %>
47
+ <% a = str.gsub("=>", ":") %>
48
+ <% properties = JSON.parse(a) %>
49
+
50
+ <% properties.each do |property| %>
51
+ <%= property['id'] + ':' %>
52
+ <%= property['vid'] %>
53
+ <br>
54
+ <% end %>
55
+ </td>
56
+ <td>
57
+ <% b = product.sku_info.gsub("=>", ":") %>
58
+ <% sku_infos = JSON.parse b %>
59
+ <% sku_infos.each do |info| %>
60
+ <%= info['id'][1, info['id'].length-1] + ':' %>
61
+ <% info['vid'].each do |vid| %>
62
+ <%= vid[1, vid.length-1] %>
63
+ <% end %>
64
+ <br>
65
+ <% end %>
66
+ </td>
67
+ <td>
68
+ <% if product.status == 1 %>
69
+ <span>上架</span>
70
+ <% elsif product.status == 2 %>
71
+ <span>下架</span>
72
+ <% else %>
73
+ <span>error</span>
74
+ <% end %>
75
+ </td>
76
+ <td><%= product.weixin_public_account_id %></td>
77
+ </tr>
78
+ <% end %>
79
+ </tbody>
80
+ </table>
81
+ <%= will_paginate @collection, renderer: FoundationPagination::Rails %>
82
+
data/config/routes.rb CHANGED
@@ -16,6 +16,11 @@ EricWeixin::Engine.routes.draw do
16
16
  get :download_orders
17
17
  end
18
18
  end
19
+ resources :products do
20
+ collection do
21
+ get :get_all_products
22
+ end
23
+ end
19
24
  end
20
25
  resources :public_accounts do
21
26
  member do
@@ -61,6 +61,7 @@ module EricWeixin::MultCustomer
61
61
  # 发送多客服信息.
62
62
  # ====参数说明
63
63
  # app_id: 微信公众账号app_id
64
+ # weixin_number: 微信原始账号,和app_id 二选一必填
64
65
  # openid: 接收消息用户的openid
65
66
  # message_type: 消息类型:包含以下:text image voice video music news#
66
67
  # data: 值为一个hash, 对应着公众账号里要发送的内容,它的key为msgtype
@@ -1,3 +1,3 @@
1
1
  module EricWeixin
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 刘晓琦
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -54,6 +54,7 @@ files:
54
54
  - app/controllers/eric_weixin/cms/weixin/users_controller.rb
55
55
  - app/controllers/eric_weixin/cms/weixin/weixin_users_controller.rb
56
56
  - app/controllers/eric_weixin/cms/weixin/xiaodian/orders_controller.rb
57
+ - app/controllers/eric_weixin/cms/weixin/xiaodian/products_controller.rb
57
58
  - app/controllers/eric_weixin/wz/pays_controller.rb
58
59
  - app/controllers/eric_weixin/wz/weixin_controller.rb
59
60
  - app/helpers/eric_weixin/application_helper.rb
@@ -130,6 +131,7 @@ files:
130
131
  - app/views/eric_weixin/cms/weixin/users/index.html.erb
131
132
  - app/views/eric_weixin/cms/weixin/weixin_users/index.html.erb
132
133
  - app/views/eric_weixin/cms/weixin/xiaodian/orders/index.html.erb
134
+ - app/views/eric_weixin/cms/weixin/xiaodian/products/index.html.erb
133
135
  - app/views/eric_weixin/wz/pays/pay_fail.html.erb
134
136
  - app/views/eric_weixin/wz/pays/pay_ok.html.erb
135
137
  - app/views/eric_weixin/wz/pays/prepay.html.erb