rails_trade 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (616) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +37 -15
  4. data/Rakefile +9 -27
  5. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/cart_items/create.js +0 -0
  6. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/cart_items/index.js +0 -0
  7. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/cart_items/only.js +0 -0
  8. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/orders/new.js +0 -0
  9. data/app/assets/javascripts/controllers/trade/admin/payment_methods/edit.js +1 -0
  10. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/payment_methods/new.js +0 -0
  11. data/app/assets/javascripts/controllers/trade/admin/payments/edit.js +1 -0
  12. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/payments/new.js +0 -0
  13. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/promote_buyers/edit.js +0 -0
  14. data/app/assets/javascripts/controllers/{rails_trade_admin → trade/admin}/promote_buyers/new.js +3 -1
  15. data/app/assets/javascripts/controllers/trade/admin/promote_charges/edit.js +1 -0
  16. data/app/assets/javascripts/controllers/trade/admin/promote_charges/new.js +7 -0
  17. data/app/assets/javascripts/controllers/trade/admin/promote_goods/edit.js +1 -0
  18. data/app/assets/javascripts/controllers/trade/admin/promote_goods/new.js +17 -0
  19. data/app/assets/javascripts/controllers/trade/admin/promotes/edit.js +2 -0
  20. data/app/assets/javascripts/controllers/trade/admin/promotes/new.js +5 -0
  21. data/app/assets/javascripts/controllers/trade/admin/refunds/index.js +1 -0
  22. data/app/assets/javascripts/controllers/trade/admin/refunds/new.js +1 -0
  23. data/app/assets/javascripts/controllers/trade/my/carts/show-phone-ready.js +1 -0
  24. data/app/assets/javascripts/controllers/trade/my/carts/show-ready.js +28 -0
  25. data/app/assets/javascripts/controllers/trade/my/orders/wait-phone.js +8 -0
  26. data/app/{views/goods/show.html.erb → assets/javascripts/controllers/trade/my/trade_items/create.js} +0 -0
  27. data/app/assets/stylesheets/controllers/trade/admin/promote_charges/index.css +4 -0
  28. data/app/assets/stylesheets/controllers/trade/admin/promotes/index.css +4 -0
  29. data/app/{views/rails_trade_admin/orders/edit.html.erb → assets/stylesheets/controllers/trade/my/carts/show-phone.css} +0 -0
  30. data/app/assets/stylesheets/controllers/trade/payments/wxpay_result.css +57 -0
  31. data/app/channels/paid_channel.rb +7 -0
  32. data/app/controllers/concerns/controller_order_types.rb +3 -6
  33. data/app/controllers/rails_trade/my_cart.rb +16 -0
  34. data/app/controllers/trade/admin/base_controller.rb +5 -0
  35. data/app/controllers/{the_trade_admin → trade/admin}/buyers_controller.rb +3 -3
  36. data/app/controllers/{the_trade_admin/cart_item_serves_controller.rb → trade/admin/cart_serves_controller.rb} +8 -5
  37. data/app/controllers/{goods_controller.rb → trade/admin/goods_controller.rb} +7 -1
  38. data/app/controllers/{the_trade_admin → trade/admin}/order_payments_controller.rb +6 -3
  39. data/app/controllers/{the_trade_admin → trade/admin}/orders_controller.rb +23 -16
  40. data/app/controllers/{the_trade_admin → trade/admin}/payment_methods_controller.rb +8 -5
  41. data/app/controllers/{the_trade_admin → trade/admin}/payment_orders_controller.rb +10 -12
  42. data/app/controllers/{the_trade_admin → trade/admin}/payment_references_controller.rb +3 -3
  43. data/app/controllers/{the_trade_admin → trade/admin}/payment_strategies_controller.rb +9 -5
  44. data/app/controllers/trade/admin/payments_controller.rb +97 -0
  45. data/app/controllers/{the_trade_admin → trade/admin}/produces_controller.rb +4 -4
  46. data/app/controllers/trade/admin/promote_buyers_controller.rb +57 -0
  47. data/app/controllers/trade/admin/promote_charges_controller.rb +67 -0
  48. data/app/controllers/trade/admin/promote_goods_controller.rb +63 -0
  49. data/app/controllers/trade/admin/promotes_controller.rb +69 -0
  50. data/app/controllers/{the_trade_admin → trade/admin}/refunds_controller.rb +9 -12
  51. data/app/controllers/{the_trade_admin/cart_items_controller.rb → trade/admin/trade_items_controller.rb} +26 -28
  52. data/app/controllers/trade/admin/trade_promotes_controller.rb +71 -0
  53. data/app/controllers/trade/buyers_controller.rb +8 -0
  54. data/app/controllers/trade/my/base_controller.rb +4 -0
  55. data/app/controllers/trade/my/carts_controller.rb +32 -0
  56. data/app/controllers/{the_trade_my → trade/my}/order_items_controller.rb +4 -4
  57. data/app/controllers/trade/my/orders_controller.rb +106 -0
  58. data/app/controllers/{the_trade_my → trade/my}/payment_methods_controller.rb +1 -1
  59. data/app/controllers/trade/my/trade_items_controller.rb +47 -0
  60. data/app/controllers/trade/payments_controller.rb +71 -0
  61. data/app/models/cart.rb +4 -0
  62. data/app/models/order.rb +4 -0
  63. data/app/models/payment.rb +4 -0
  64. data/app/models/payment/alipay_payment.rb +3 -0
  65. data/app/models/payment/apple_payment.rb +3 -0
  66. data/app/models/payment/bank_payment.rb +3 -0
  67. data/app/models/payment/hand_payment.rb +3 -0
  68. data/app/models/payment/paypal_payment.rb +3 -0
  69. data/app/models/payment/stripe_payment.rb +3 -0
  70. data/app/models/payment/wxpay_payment.rb +3 -0
  71. data/app/models/payment_method.rb +3 -0
  72. data/app/models/{rails_trade/payment_methods → payment_method}/alipay_method.rb +1 -1
  73. data/app/models/{rails_trade/payment_methods → payment_method}/bank_method.rb +1 -1
  74. data/app/models/payment_method/stripe_method.rb +3 -0
  75. data/app/models/payment_order.rb +3 -0
  76. data/app/models/payment_reference.rb +3 -0
  77. data/app/models/payment_strategy.rb +3 -0
  78. data/app/models/payment_type.rb +3 -0
  79. data/app/models/promote.rb +3 -0
  80. data/app/models/promote_buyer.rb +3 -0
  81. data/app/models/promote_charge.rb +3 -0
  82. data/app/models/promote_charge/cash_promote_charge.rb +3 -0
  83. data/app/models/promote_charge/discount_promote_charge.rb +3 -0
  84. data/app/models/promote_charge/final_promote_charge.rb +3 -0
  85. data/app/models/promote_charge/minus_promote_charge.rb +3 -0
  86. data/app/models/promote_charge/plus_promote_charge.rb +3 -0
  87. data/app/models/promote_extra.rb +3 -0
  88. data/app/models/promote_good.rb +3 -0
  89. data/app/models/rails_trade/amount.rb +44 -0
  90. data/app/models/rails_trade/buyer.rb +35 -0
  91. data/app/models/rails_trade/cart.rb +64 -0
  92. data/app/models/rails_trade/good.rb +71 -0
  93. data/app/models/rails_trade/order.rb +78 -91
  94. data/app/models/rails_trade/ordering/payment.rb +113 -0
  95. data/app/models/rails_trade/{concerns/the_refund.rb → ordering/refund.rb} +3 -5
  96. data/app/models/rails_trade/payment.rb +72 -73
  97. data/app/models/rails_trade/payment/alipay_payment.rb +15 -0
  98. data/app/models/rails_trade/payment/apple_payment.rb +7 -0
  99. data/app/models/rails_trade/{payments → payment}/bank_payment.rb +2 -4
  100. data/app/models/rails_trade/payment/hand_payment.rb +8 -0
  101. data/app/models/rails_trade/payment/paypal_payment.rb +8 -0
  102. data/app/models/rails_trade/payment/stripe_payment.rb +9 -0
  103. data/app/models/rails_trade/{payments → payment}/wxpay_payment.rb +1 -2
  104. data/app/models/rails_trade/payment_method.rb +22 -12
  105. data/app/models/rails_trade/{payment_methods → payment_method}/stripe_method.rb +7 -4
  106. data/app/models/rails_trade/payment_order.rb +84 -51
  107. data/app/models/rails_trade/payment_reference.rb +12 -9
  108. data/app/models/rails_trade/payment_strategy.rb +15 -12
  109. data/app/models/rails_trade/payment_type/alipay.rb +28 -0
  110. data/app/models/rails_trade/payment_type/apple_pay.rb +18 -0
  111. data/app/models/rails_trade/{payment_interface/the_paypal.rb → payment_type/paypal.rb} +8 -29
  112. data/app/models/rails_trade/{payment_interface/the_stripe.rb → payment_type/stripe.rb} +8 -26
  113. data/app/models/rails_trade/payment_type/wxpay.rb +55 -0
  114. data/app/models/rails_trade/promote.rb +65 -27
  115. data/app/models/rails_trade/promote_buyer.rb +25 -7
  116. data/app/models/rails_trade/promote_charge.rb +78 -11
  117. data/app/models/rails_trade/promote_charge/cash_promote_charge.rb +12 -0
  118. data/app/models/rails_trade/promote_charge/discount_promote_charge.rb +17 -0
  119. data/app/models/rails_trade/promote_charge/final_promote_charge.rb +12 -0
  120. data/app/models/rails_trade/promote_charge/minus_promote_charge.rb +11 -0
  121. data/app/models/rails_trade/promote_charge/plus_promote_charge.rb +7 -0
  122. data/app/models/rails_trade/promote_extra.rb +13 -0
  123. data/app/models/rails_trade/promote_good.rb +20 -7
  124. data/app/models/rails_trade/refund.rb +30 -19
  125. data/app/models/rails_trade/{refunds → refund}/alipay_refund.rb +1 -1
  126. data/app/models/rails_trade/refund/bank_refund.rb +5 -0
  127. data/app/models/rails_trade/refund/hand_refund.rb +5 -0
  128. data/app/models/rails_trade/{refunds → refund}/paypal_refund.rb +1 -1
  129. data/app/models/rails_trade/{refunds → refund}/stripe_refund.rb +1 -1
  130. data/app/models/rails_trade/{refunds → refund}/wxpay_refund.rb +17 -9
  131. data/app/models/rails_trade/sell.rb +24 -0
  132. data/app/models/rails_trade/trade_item.rb +153 -0
  133. data/app/models/rails_trade/trade_promote.rb +92 -0
  134. data/app/models/rails_trade/user.rb +9 -0
  135. data/app/models/refund.rb +3 -0
  136. data/app/models/refund/alipay_refund.rb +3 -0
  137. data/app/models/refund/bank_refund.rb +3 -0
  138. data/app/models/refund/hand_refund.rb +3 -0
  139. data/app/models/refund/paypal_refund.rb +3 -0
  140. data/app/models/refund/stripe_refund.rb +3 -0
  141. data/app/models/refund/wxpay_refund.rb +3 -0
  142. data/app/models/trade_item.rb +3 -0
  143. data/app/models/trade_promote.rb +3 -0
  144. data/app/views/application/_trade_nav.html.erb +16 -0
  145. data/app/views/my/_trade_nav.html.erb +10 -0
  146. data/app/views/{rails_trade_admin → trade/admin}/buyers/_form.html.erb +0 -0
  147. data/app/views/{rails_trade_admin → trade/admin}/buyers/_menu.html.erb +0 -0
  148. data/app/views/{rails_trade_admin → trade/admin}/buyers/_search_form.html.erb +3 -3
  149. data/app/views/{rails_trade_admin → trade/admin}/buyers/edit.html.erb +0 -0
  150. data/app/views/{rails_trade_admin → trade/admin}/buyers/index.html.erb +1 -1
  151. data/app/views/{rails_trade_admin → trade/admin}/buyers/new.html.erb +0 -0
  152. data/app/views/{rails_trade_admin → trade/admin}/buyers/orders.html.erb +2 -2
  153. data/app/views/{rails_trade_admin → trade/admin}/buyers/overdue.html.erb +1 -1
  154. data/app/views/{rails_trade_admin → trade/admin}/buyers/show.html.erb +0 -0
  155. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_check.html.erb +0 -0
  156. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_index.html.erb +1 -1
  157. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_new.html.erb +0 -0
  158. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_serve.html.erb +0 -0
  159. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_single.html.erb +1 -1
  160. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_single_table.html.erb +0 -0
  161. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_total.html.erb +1 -1
  162. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/_total_table.html.erb +0 -0
  163. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/add.js.erb +0 -0
  164. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/create.js.erb +0 -0
  165. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/destroy.js.erb +0 -0
  166. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/index.js.erb +0 -0
  167. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/new.js.erb +0 -0
  168. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/single.js.erb +0 -0
  169. data/app/views/{rails_trade_admin → trade/admin}/cart_item_serves/total.js.erb +0 -0
  170. data/app/views/trade/admin/goods/_form.html.erb +7 -0
  171. data/app/views/{rails_trade_admin → trade/admin}/goods/_item.html.erb +0 -0
  172. data/app/views/{rails_trade_admin → trade/admin}/goods/_new.html.erb +2 -2
  173. data/app/views/{rails_trade_admin → trade/admin}/goods/_show.html.erb +0 -0
  174. data/app/views/{rails_trade_admin → trade/admin}/goods/_show_tr.html.erb +0 -0
  175. data/app/views/{rails_trade_admin → trade/admin}/goods/create.js.erb +0 -0
  176. data/app/views/{rails_trade_admin → trade/admin}/goods/destroy.js.erb +0 -0
  177. data/app/views/{rails_trade_admin → trade/admin}/goods/edit.html.erb +2 -2
  178. data/app/views/{rails_trade_admin → trade/admin}/goods/edit.js.erb +0 -0
  179. data/app/views/{rails_trade_admin → trade/admin}/goods/edit_items.html.erb +2 -2
  180. data/app/views/{rails_trade_admin → trade/admin}/goods/edit_pic.html.erb +2 -2
  181. data/app/views/{rails_trade_admin → trade/admin}/goods/edit_promote.html.erb +2 -2
  182. data/app/views/{rails_trade_admin → trade/admin}/goods/index.html.erb +1 -1
  183. data/app/views/{rails_trade_admin → trade/admin}/goods/new.html.erb +1 -1
  184. data/app/views/{rails_trade_admin → trade/admin}/goods/new.js.erb +0 -0
  185. data/app/views/{rails_trade_admin → trade/admin}/goods/show.js.erb +0 -0
  186. data/app/views/{rails_trade_admin → trade/admin}/goods/update.js.erb +0 -0
  187. data/app/views/{rails_trade_admin → trade/admin}/order_payments/_index.html.erb +0 -0
  188. data/app/views/{rails_trade_admin → trade/admin}/order_payments/_new.html.erb +0 -0
  189. data/app/views/{rails_trade_admin → trade/admin}/order_payments/_payment_orders.html.erb +1 -1
  190. data/app/views/{rails_trade_admin → trade/admin}/order_payments/_payments.html.erb +0 -0
  191. data/app/views/{rails_trade_admin → trade/admin}/order_payments/create.js.erb +0 -0
  192. data/app/views/{rails_trade_admin → trade/admin}/order_payments/create_fail.js.erb +0 -0
  193. data/app/views/{rails_trade_admin → trade/admin}/order_payments/destroy.js.erb +0 -0
  194. data/app/views/{rails_trade_admin → trade/admin}/order_payments/index.js.erb +0 -0
  195. data/app/views/{rails_trade_admin → trade/admin}/order_payments/new.js.erb +0 -0
  196. data/app/views/{rails_trade_admin → trade/admin}/orders/_addresses.html.erb +1 -1
  197. data/app/views/trade/admin/orders/_filter.html.erb +26 -0
  198. data/app/views/trade/admin/orders/_form.html.erb +4 -0
  199. data/app/views/{rails_trade_admin → trade/admin}/orders/_invoice_addresses.html.erb +1 -1
  200. data/app/views/{rails_trade_admin → trade/admin}/orders/_item.html.erb +0 -0
  201. data/app/views/{rails_trade_admin → trade/admin}/orders/_new_items.html.erb +1 -1
  202. data/app/{assets/javascripts/controllers/rails_trade_admin/payments/index.js → views/trade/admin/orders/_search_form.html.erb} +0 -0
  203. data/app/views/trade/admin/orders/index.html.erb +52 -0
  204. data/app/views/{rails_trade_admin → trade/admin}/orders/new.html.erb +0 -0
  205. data/app/views/{rails_trade_admin → trade/admin}/orders/payments.html.erb +1 -1
  206. data/app/views/{rails_trade_admin → trade/admin}/orders/refresh.js.erb +0 -0
  207. data/app/views/trade/admin/orders/show.html.erb +75 -0
  208. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/_edit.html.erb +0 -0
  209. data/app/views/{rails_trade_admin/payment_methods/_search_form.html.erb → trade/admin/payment_methods/_filter.html.erb} +5 -9
  210. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/_form.html.erb +0 -0
  211. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/_index_layout.html.erb +2 -5
  212. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/_new.html.erb +2 -2
  213. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/_payment_method.html.erb +2 -3
  214. data/app/views/trade/admin/payment_methods/create.js.erb +2 -0
  215. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/destroy.js.erb +0 -0
  216. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/edit.html.erb +1 -1
  217. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/edit.js.erb +0 -0
  218. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/index.html.erb +7 -4
  219. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/mine.html.erb +2 -2
  220. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/new.html.erb +1 -1
  221. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/new.js.erb +0 -0
  222. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/unverified.html.erb +4 -6
  223. data/app/views/{rails_trade_admin → trade/admin}/payment_methods/update.js.erb +0 -0
  224. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/_index.html.erb +2 -6
  225. data/app/views/trade/admin/payment_orders/_new.html.erb +23 -0
  226. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/_orders.html.erb +2 -9
  227. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/cancel.js.erb +0 -0
  228. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/create.js.erb +0 -0
  229. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/create_fail.js.erb +0 -0
  230. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/new.js.erb +0 -0
  231. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/raise_fail.js.erb +0 -0
  232. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/update.js.erb +1 -1
  233. data/app/views/{rails_trade_admin → trade/admin}/payment_orders/update_fail.js.erb +0 -0
  234. data/app/views/{rails_trade_admin → trade/admin}/payment_references/_form.html.erb +1 -1
  235. data/app/views/{rails_trade_admin → trade/admin}/payment_references/_new.html.erb +1 -1
  236. data/app/views/{rails_trade_admin → trade/admin}/payment_references/destroy.js.erb +0 -0
  237. data/app/views/{rails_trade_admin → trade/admin}/payment_references/edit.html.erb +0 -0
  238. data/app/views/{rails_trade_admin → trade/admin}/payment_references/index.html.erb +1 -1
  239. data/app/views/{rails_trade_admin → trade/admin}/payment_references/new.js.erb +0 -0
  240. data/app/views/{rails_trade_admin → trade/admin}/payment_references/show.html.erb +0 -0
  241. data/app/views/{rails_trade_admin → trade/admin}/payment_strategies/_form.html.erb +0 -0
  242. data/app/views/{rails_trade_admin → trade/admin}/payment_strategies/edit.html.erb +2 -2
  243. data/app/views/{rails_trade_admin → trade/admin}/payment_strategies/index.html.erb +2 -2
  244. data/app/views/{rails_trade_admin → trade/admin}/payment_strategies/new.html.erb +1 -1
  245. data/app/views/trade/admin/payments/_checked_amount.html.erb +6 -0
  246. data/app/views/trade/admin/payments/_edit.html.erb +12 -0
  247. data/app/views/trade/admin/payments/_filter.html.erb +40 -0
  248. data/app/views/{rails_trade_admin → trade/admin}/payments/_form.html.erb +6 -2
  249. data/app/views/trade/admin/payments/_item.html.erb +41 -0
  250. data/app/views/trade/admin/payments/_new.html.erb +12 -0
  251. data/app/views/{rails_trade_admin → trade/admin}/payments/analyze.js.erb +0 -0
  252. data/app/views/{rails_trade_admin → trade/admin}/payments/dashboard.html.erb +0 -0
  253. data/app/views/trade/admin/payments/edit.html.erb +13 -0
  254. data/app/views/trade/admin/payments/edit.js.erb +3 -0
  255. data/app/views/trade/admin/payments/index.html.erb +40 -0
  256. data/app/views/trade/admin/payments/new.html.erb +13 -0
  257. data/app/views/trade/admin/payments/new.js.erb +3 -0
  258. data/app/views/{rails_trade_admin → trade/admin}/payments/show.html.erb +0 -0
  259. data/app/views/trade/admin/promote_buyers/_filter.html.erb +7 -0
  260. data/app/views/trade/admin/promote_buyers/_form.html.erb +17 -0
  261. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/_promote_buyer.json.jbuilder +0 -0
  262. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/edit.html.erb +1 -1
  263. data/app/views/trade/admin/promote_buyers/edit.js.erb +3 -0
  264. data/app/views/trade/admin/promote_buyers/index.html.erb +52 -0
  265. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/index.json.jbuilder +0 -0
  266. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/new.html.erb +1 -1
  267. data/app/views/trade/admin/promote_buyers/new.js.erb +3 -0
  268. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/show.html.erb +0 -0
  269. data/app/views/{rails_trade_admin → trade/admin}/promote_buyers/show.json.jbuilder +0 -0
  270. data/app/views/trade/admin/promote_charges/_base_price_form.html.erb +1 -0
  271. data/app/views/trade/admin/promote_charges/_edit.html.erb +13 -0
  272. data/app/views/trade/admin/promote_charges/_filter.html.erb +11 -0
  273. data/app/views/trade/admin/promote_charges/_form.html.erb +11 -0
  274. data/app/views/trade/admin/promote_charges/_new.html.erb +13 -0
  275. data/app/views/trade/admin/promote_charges/index.html.erb +65 -0
  276. data/app/views/trade/admin/promote_charges/options.js.erb +4 -0
  277. data/app/views/trade/admin/promote_goods/_filter.html.erb +8 -0
  278. data/app/views/trade/admin/promote_goods/_form.html.erb +8 -0
  279. data/app/views/trade/admin/promote_goods/_goods_options.html.erb +1 -0
  280. data/app/views/trade/admin/promote_goods/goods.js.erb +2 -0
  281. data/app/views/trade/admin/promote_goods/index.html.erb +61 -0
  282. data/app/views/trade/admin/promotes/_edit.html.erb +12 -0
  283. data/app/views/trade/admin/promotes/_filter.html.erb +9 -0
  284. data/app/views/trade/admin/promotes/_form.html.erb +12 -0
  285. data/app/views/trade/admin/promotes/_new.html.erb +12 -0
  286. data/app/views/trade/admin/promotes/_new_promote_charge.html.erb +10 -0
  287. data/app/views/trade/admin/promotes/create.js.erb +2 -0
  288. data/app/views/trade/admin/promotes/index.html.erb +79 -0
  289. data/app/views/trade/admin/refunds/_filter.html.erb +11 -0
  290. data/app/views/{rails_trade_admin → trade/admin}/refunds/_form.html.erb +0 -0
  291. data/app/views/{rails_trade_admin → trade/admin}/refunds/_logs_table.html.erb +0 -0
  292. data/app/views/{rails_trade_admin → trade/admin}/refunds/_new.html.erb +0 -0
  293. data/app/views/{rails_trade_admin → trade/admin}/refunds/edit.html.erb +0 -0
  294. data/app/views/{rails_trade_admin → trade/admin}/refunds/index.html.erb +13 -17
  295. data/app/views/{rails_trade_admin → trade/admin}/refunds/logs.js.erb +0 -0
  296. data/app/views/{rails_trade_admin → trade/admin}/refunds/new.html.erb +0 -0
  297. data/app/views/{rails_trade_admin → trade/admin}/refunds/new.js.erb +0 -0
  298. data/app/views/{rails_trade_admin → trade/admin}/refunds/show.html.erb +0 -0
  299. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_additions.html.erb +0 -0
  300. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_filter.html.erb +0 -0
  301. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_good_price.html.erb +0 -0
  302. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_order_price.html.erb +0 -0
  303. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_retail_price.html.erb +0 -0
  304. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_single_price.html.erb +0 -0
  305. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/_total_price.html.erb +0 -0
  306. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/destroy.js.erb +0 -0
  307. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/error.html.erb +0 -0
  308. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/index.html.erb +3 -3
  309. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/only.html.erb +2 -2
  310. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/total.js.erb +0 -0
  311. data/app/views/{rails_trade_admin/cart_items → trade/admin/trade_items}/update.js.erb +0 -0
  312. data/app/views/trade/admin/trade_promotes/_filter.html.erb +7 -0
  313. data/app/views/trade/admin/trade_promotes/_form.html.erb +6 -0
  314. data/app/views/trade/admin/trade_promotes/_show_table.html.erb +20 -0
  315. data/app/views/trade/admin/trade_promotes/edit.html.erb +9 -0
  316. data/app/views/trade/admin/trade_promotes/edit.js.erb +3 -0
  317. data/app/views/trade/admin/trade_promotes/index.html.erb +38 -0
  318. data/app/views/trade/admin/trade_promotes/new.html.erb +9 -0
  319. data/app/views/trade/admin/trade_promotes/new.js.erb +3 -0
  320. data/app/views/trade/admin/trade_promotes/show.html.erb +7 -0
  321. data/app/views/trade/admin/trade_promotes/show.js.erb +3 -0
  322. data/app/views/trade/admin/trade_promotes/update.js.erb +1 -0
  323. data/app/views/{buyers → trade/buyers}/_show.html.erb +0 -0
  324. data/app/views/{buyers → trade/buyers}/show.js.erb +0 -0
  325. data/app/views/{goods → trade/goods}/_choose.html.erb +0 -0
  326. data/app/views/{goods → trade/goods}/_good.html.erb +0 -0
  327. data/app/views/{goods → trade/goods}/_good_item.html.erb +0 -0
  328. data/app/views/{goods → trade/goods}/_nav.html.erb +0 -0
  329. data/app/views/{goods → trade/goods}/_search.html.erb +0 -0
  330. data/app/views/{goods → trade/goods}/index.html.erb +0 -0
  331. data/app/views/{goods → trade/goods}/index/_product.html.erb +0 -0
  332. data/app/views/{goods → trade/goods}/item.html.erb +0 -0
  333. data/app/views/{goods → trade/goods}/produce.html.erb +0 -0
  334. data/app/views/trade/goods/show.html.erb +2 -0
  335. data/app/views/{goods → trade/goods}/show/_basic.html.erb +0 -0
  336. data/app/views/{goods → trade/goods}/show/_carousel.html.erb +0 -0
  337. data/app/views/{goods → trade/goods}/show/_items.html.erb +0 -0
  338. data/app/views/{goods → trade/goods}/show/_sales.html.erb +0 -0
  339. data/app/views/{goods → trade/goods}/show/_side.html.erb +0 -0
  340. data/app/views/{goods → trade/goods}/taxon/_breadcrumb.html.erb +0 -0
  341. data/app/views/{goods → trade/goods}/taxon/_nav.html.erb +0 -0
  342. data/app/views/{goods → trade/goods}/taxon/_nav_.html.erb +0 -0
  343. data/app/views/{goods → trade/goods}/taxon/_nav_last.html.erb +0 -0
  344. data/app/views/trade/my/carts/_filter.html.erb +7 -0
  345. data/app/views/trade/my/carts/_form.html.erb +8 -0
  346. data/app/views/trade/my/carts/_show_table.html.erb +28 -0
  347. data/app/views/trade/my/carts/edit.html.erb +9 -0
  348. data/app/views/trade/my/carts/edit.js.erb +3 -0
  349. data/app/views/trade/my/carts/index.html.erb +47 -0
  350. data/app/views/trade/my/carts/new.html.erb +9 -0
  351. data/app/views/trade/my/carts/new.js.erb +3 -0
  352. data/app/views/trade/my/carts/show.html+phone.erb +46 -0
  353. data/app/views/{rails_trade_admin/promote_goods → trade/my/carts}/show.html.erb +0 -0
  354. data/app/views/{rails_trade_my → trade/my}/order_items/_form.html.erb +0 -0
  355. data/app/views/{rails_trade_my → trade/my}/order_items/edit.html.erb +0 -0
  356. data/app/views/{rails_trade_my → trade/my}/order_items/index.html.erb +1 -1
  357. data/app/views/{rails_trade_my → trade/my}/order_items/new.html.erb +0 -0
  358. data/app/views/{rails_trade_my → trade/my}/order_items/show.html.erb +0 -0
  359. data/app/views/{rails_trade_my → trade/my}/orders/_date_form.html.erb +0 -0
  360. data/app/views/{rails_trade_my → trade/my}/orders/_edit.html.erb +2 -2
  361. data/app/views/trade/my/orders/_edit_payment_type.html.erb +12 -0
  362. data/app/views/{rails_trade_my → trade/my}/orders/_form.html.erb +0 -0
  363. data/app/views/{rails_trade_my → trade/my}/orders/destroy.js.erb +0 -0
  364. data/app/views/{rails_trade_my → trade/my}/orders/edit.js.erb +0 -0
  365. data/app/views/trade/my/orders/edit_payment_type.js.erb +4 -0
  366. data/app/views/{rails_trade_my → trade/my}/orders/fail.html.erb +0 -0
  367. data/app/views/trade/my/orders/index.html+phone.erb +37 -0
  368. data/app/views/trade/my/orders/index.html.erb +36 -0
  369. data/app/views/{rails_trade_my → trade/my}/orders/index.json.jbuilder +0 -0
  370. data/app/views/{rails_trade_my → trade/my}/orders/new.html.erb +0 -0
  371. data/app/views/{rails_trade_my → trade/my}/orders/refresh.js.erb +0 -0
  372. data/app/views/trade/my/orders/refund.json.jbuilder +12 -0
  373. data/app/views/trade/my/orders/show.html+phone.erb +3 -0
  374. data/app/views/{rails_trade_my → trade/my}/orders/show.html.erb +3 -3
  375. data/app/views/{rails_trade_my → trade/my}/orders/success.html.erb +0 -2
  376. data/app/views/{rails_trade_my → trade/my}/orders/update.js.erb +1 -1
  377. data/app/views/trade/my/orders/wait.html+wechat.erb +4 -0
  378. data/app/views/trade/my/orders/wxpay_pay.js.erb +16 -0
  379. data/app/views/trade/my/orders/wxpay_pay_err.js.erb +5 -0
  380. data/app/views/{rails_trade_my → trade/my}/payment_methods/_edit.html.erb +1 -1
  381. data/app/views/{rails_trade_my → trade/my}/payment_methods/_form.html.erb +0 -0
  382. data/app/views/{rails_trade_my → trade/my}/payment_methods/_index.html.erb +1 -1
  383. data/app/views/{rails_trade_my → trade/my}/payment_methods/_item.html.erb +1 -1
  384. data/app/views/{rails_trade_my → trade/my}/payment_methods/_new.html.erb +3 -3
  385. data/app/views/{rails_trade_my → trade/my}/payment_methods/create.js.erb +0 -0
  386. data/app/views/{rails_trade_my/addresses → trade/my/payment_methods}/destroy.js.erb +0 -0
  387. data/app/views/{rails_trade_my → trade/my}/payment_methods/edit.js.erb +0 -0
  388. data/app/views/{rails_trade_my → trade/my}/payment_methods/index.html.erb +0 -0
  389. data/app/views/{rails_trade_my → trade/my}/payment_methods/index.js.erb +0 -0
  390. data/app/views/{rails_trade_my → trade/my}/payment_methods/new.js.erb +0 -0
  391. data/app/views/{rails_trade_my → trade/my}/payment_methods/show.html.erb +0 -0
  392. data/app/views/{rails_trade_my/addresses → trade/my/payment_methods}/update.js.erb +0 -0
  393. data/app/views/trade/my/trade_items/_additions.html.erb +12 -0
  394. data/app/views/trade/my/trade_items/_cart_item.js.erb +2 -0
  395. data/app/views/trade/my/trade_items/_single_price.html.erb +6 -0
  396. data/app/views/trade/my/trade_items/_total_price.html.erb +8 -0
  397. data/app/views/trade/my/trade_items/_trade_items.html.erb +68 -0
  398. data/app/views/trade/my/trade_items/create.html.erb +1 -0
  399. data/app/views/{rails_trade_my/cart_items → trade/my/trade_items}/destroy.js.erb +0 -0
  400. data/app/views/trade/my/trade_items/index.json.jbuilder +0 -0
  401. data/app/views/trade/my/trade_items/update.js.erb +1 -0
  402. data/app/views/{rails_trade_my → trade/my}/users/_form.html.erb +0 -0
  403. data/app/views/{rails_trade_my → trade/my}/users/edit.html.erb +0 -0
  404. data/app/views/{rails_trade_my → trade/my}/users/show.html.erb +0 -0
  405. data/app/views/trade/payments/_wxpay_result.html.erb +3 -0
  406. data/app/views/trade/payments/wxpay_result.js.erb +1 -0
  407. data/config/locales/en.enum.yml +47 -0
  408. data/config/locales/en.yml +22 -60
  409. data/config/locales/zh.attributes.yml +75 -0
  410. data/config/locales/zh.controller.yml +51 -0
  411. data/config/locales/zh.enum.yml +58 -0
  412. data/config/locales/zh.help.yml +7 -0
  413. data/config/routes.rb +45 -59
  414. data/lib/rails_trade.rb +9 -19
  415. data/lib/rails_trade/apple_pay.rb +32 -0
  416. data/lib/rails_trade/config.rb +6 -3
  417. data/lib/rails_trade/engine.rb +15 -19
  418. data/lib/rails_trade/version.rb +1 -1
  419. metadata +475 -422
  420. data/app/assets/config/rails_trade_manifest.js +0 -1
  421. data/app/assets/javascripts/controllers/rails_trade_admin/buyers/index.js +0 -15
  422. data/app/assets/javascripts/controllers/rails_trade_admin/buyers/overdue.js +0 -15
  423. data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/edit.js +0 -1
  424. data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/index.js +0 -1
  425. data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/unverified.js +0 -1
  426. data/app/assets/javascripts/controllers/rails_trade_admin/promote_goods/index.js +0 -1
  427. data/app/assets/javascripts/controllers/rails_trade_admin/promotes/edit.js +0 -2
  428. data/app/assets/javascripts/controllers/rails_trade_admin/promotes/index.js +0 -1
  429. data/app/assets/javascripts/controllers/rails_trade_admin/promotes/new.js +0 -2
  430. data/app/assets/javascripts/controllers/rails_trade_admin/serves/edit.js +0 -2
  431. data/app/assets/javascripts/controllers/rails_trade_admin/serves/index.js +0 -1
  432. data/app/assets/javascripts/controllers/rails_trade_admin/serves/new.js +0 -4
  433. data/app/assets/javascripts/controllers/rails_trade_my/cart_items/create.js +0 -3
  434. data/app/assets/javascripts/controllers/rails_trade_my/cart_items/index.js +0 -65
  435. data/app/controllers/areas_controller.rb +0 -18
  436. data/app/controllers/buyers_controller.rb +0 -8
  437. data/app/controllers/payments_controller.rb +0 -50
  438. data/app/controllers/providers_controller.rb +0 -8
  439. data/app/controllers/the_trade_admin/addresses_controller.rb +0 -75
  440. data/app/controllers/the_trade_admin/areas_controller.rb +0 -50
  441. data/app/controllers/the_trade_admin/base_controller.rb +0 -5
  442. data/app/controllers/the_trade_admin/payments_controller.rb +0 -89
  443. data/app/controllers/the_trade_admin/promote_buyers_controller.rb +0 -39
  444. data/app/controllers/the_trade_admin/promote_charges_controller.rb +0 -62
  445. data/app/controllers/the_trade_admin/promote_goods_controller.rb +0 -50
  446. data/app/controllers/the_trade_admin/promotes_controller.rb +0 -105
  447. data/app/controllers/the_trade_admin/providers_controller.rb +0 -121
  448. data/app/controllers/the_trade_admin/serve_charges_controller.rb +0 -67
  449. data/app/controllers/the_trade_admin/serves_controller.rb +0 -107
  450. data/app/controllers/the_trade_my/addresses_controller.rb +0 -50
  451. data/app/controllers/the_trade_my/base_controller.rb +0 -13
  452. data/app/controllers/the_trade_my/buyers_controller.rb +0 -35
  453. data/app/controllers/the_trade_my/cart_items_controller.rb +0 -71
  454. data/app/controllers/the_trade_my/orders_controller.rb +0 -161
  455. data/app/controllers/the_trade_my/providers_controller.rb +0 -44
  456. data/app/models/rails_trade/address.rb +0 -14
  457. data/app/models/rails_trade/area.rb +0 -65
  458. data/app/models/rails_trade/cart_item.rb +0 -185
  459. data/app/models/rails_trade/cart_item_serve.rb +0 -16
  460. data/app/models/rails_trade/concerns/good_able.rb +0 -63
  461. data/app/models/rails_trade/concerns/order_able.rb +0 -48
  462. data/app/models/rails_trade/concerns/promote_fee.rb +0 -54
  463. data/app/models/rails_trade/concerns/serve_fee.rb +0 -41
  464. data/app/models/rails_trade/concerns/summary_service.rb +0 -67
  465. data/app/models/rails_trade/concerns/the_payment.rb +0 -88
  466. data/app/models/rails_trade/concerns/the_trade_buyer.rb +0 -50
  467. data/app/models/rails_trade/concerns/the_trade_user.rb +0 -23
  468. data/app/models/rails_trade/good_partner.rb +0 -8
  469. data/app/models/rails_trade/good_produce.rb +0 -14
  470. data/app/models/rails_trade/order_item.rb +0 -88
  471. data/app/models/rails_trade/order_promote.rb +0 -23
  472. data/app/models/rails_trade/order_serve.rb +0 -23
  473. data/app/models/rails_trade/order_shipment.rb +0 -10
  474. data/app/models/rails_trade/payment_interface/payment_interface_base.rb +0 -8
  475. data/app/models/rails_trade/payment_interface/the_alipay.rb +0 -49
  476. data/app/models/rails_trade/payment_interface/the_wxpay.rb +0 -56
  477. data/app/models/rails_trade/payments/alipay_payment.rb +0 -12
  478. data/app/models/rails_trade/payments/hand_payment.rb +0 -13
  479. data/app/models/rails_trade/payments/paypal_payment.rb +0 -8
  480. data/app/models/rails_trade/payments/stripe_payment.rb +0 -7
  481. data/app/models/rails_trade/produce.rb +0 -18
  482. data/app/models/rails_trade/promote_charges/single_promote_charge.rb +0 -7
  483. data/app/models/rails_trade/promote_charges/total_promote_charge.rb +0 -7
  484. data/app/models/rails_trade/promotes/amount_promote.rb +0 -4
  485. data/app/models/rails_trade/promotes/number_promote.rb +0 -4
  486. data/app/models/rails_trade/provider.rb +0 -25
  487. data/app/models/rails_trade/refunds/bank_refund.rb +0 -5
  488. data/app/models/rails_trade/refunds/hand_refund.rb +0 -5
  489. data/app/models/rails_trade/serve.rb +0 -44
  490. data/app/models/rails_trade/serve_charge.rb +0 -37
  491. data/app/models/rails_trade/serve_charges/single_serve_charge.rb +0 -7
  492. data/app/models/rails_trade/serve_charges/total_serve_charge.rb +0 -7
  493. data/app/models/rails_trade/serve_good.rb +0 -9
  494. data/app/models/rails_trade/serves/number_serve.rb +0 -4
  495. data/app/models/rails_trade/serves/quantity_serve.rb +0 -4
  496. data/app/models/rails_trade/shipment.rb +0 -8
  497. data/app/views/layouts/rails_trade_admin/base.html.erb +0 -25
  498. data/app/views/layouts/rails_trade_my/base.html.erb +0 -28
  499. data/app/views/rails_trade_admin/addresses/_address.html.erb +0 -24
  500. data/app/views/rails_trade_admin/addresses/_edit.html.erb +0 -13
  501. data/app/views/rails_trade_admin/addresses/_form.html.erb +0 -23
  502. data/app/views/rails_trade_admin/addresses/_new.html.erb +0 -13
  503. data/app/views/rails_trade_admin/addresses/create.js.erb +0 -2
  504. data/app/views/rails_trade_admin/addresses/destroy.js.erb +0 -1
  505. data/app/views/rails_trade_admin/addresses/edit.js.erb +0 -39
  506. data/app/views/rails_trade_admin/addresses/index.html.erb +0 -41
  507. data/app/views/rails_trade_admin/addresses/new.js.erb +0 -52
  508. data/app/views/rails_trade_admin/addresses/show.html.erb +0 -4
  509. data/app/views/rails_trade_admin/addresses/update.js.erb +0 -2
  510. data/app/views/rails_trade_admin/areas/_form.html.erb +0 -9
  511. data/app/views/rails_trade_admin/areas/edit.html.erb +0 -16
  512. data/app/views/rails_trade_admin/areas/index.html.erb +0 -43
  513. data/app/views/rails_trade_admin/areas/new.html.erb +0 -11
  514. data/app/views/rails_trade_admin/areas/show.html.erb +0 -1
  515. data/app/views/rails_trade_admin/base/_nav.html.erb +0 -24
  516. data/app/views/rails_trade_admin/base/_nav_bar.html.erb +0 -23
  517. data/app/views/rails_trade_admin/base/_nav_payment.html.erb +0 -25
  518. data/app/views/rails_trade_admin/goods/_form.html.erb +0 -7
  519. data/app/views/rails_trade_admin/orders/_filter.html.erb +0 -20
  520. data/app/views/rails_trade_admin/orders/_form.html.erb +0 -17
  521. data/app/views/rails_trade_admin/orders/_search_form.html.erb +0 -7
  522. data/app/views/rails_trade_admin/orders/index.html.erb +0 -61
  523. data/app/views/rails_trade_admin/orders/show.html.erb +0 -89
  524. data/app/views/rails_trade_admin/payment_methods/create.js.erb +0 -2
  525. data/app/views/rails_trade_admin/payment_orders/_new.html.erb +0 -24
  526. data/app/views/rails_trade_admin/payments/_item.html.erb +0 -49
  527. data/app/views/rails_trade_admin/payments/_search_form.html.erb +0 -15
  528. data/app/views/rails_trade_admin/payments/edit.html.erb +0 -15
  529. data/app/views/rails_trade_admin/payments/index.html.erb +0 -60
  530. data/app/views/rails_trade_admin/payments/new.html.erb +0 -17
  531. data/app/views/rails_trade_admin/promote_buyers/_form.html.erb +0 -6
  532. data/app/views/rails_trade_admin/promote_buyers/index.html.erb +0 -42
  533. data/app/views/rails_trade_admin/promote_charges/_edit.html.erb +0 -13
  534. data/app/views/rails_trade_admin/promote_charges/_form.html.erb +0 -6
  535. data/app/views/rails_trade_admin/promote_charges/_new.html.erb +0 -13
  536. data/app/views/rails_trade_admin/promote_charges/_search_form.html.erb +0 -9
  537. data/app/views/rails_trade_admin/promote_charges/edit.js.erb +0 -8
  538. data/app/views/rails_trade_admin/promote_charges/index.html.erb +0 -49
  539. data/app/views/rails_trade_admin/promote_charges/new.js.erb +0 -8
  540. data/app/views/rails_trade_admin/promote_goods/_form.html.erb +0 -4
  541. data/app/views/rails_trade_admin/promote_goods/_promote_good.json.jbuilder +0 -2
  542. data/app/views/rails_trade_admin/promote_goods/edit.html.erb +0 -14
  543. data/app/views/rails_trade_admin/promote_goods/index.html.erb +0 -37
  544. data/app/views/rails_trade_admin/promote_goods/index.json.jbuilder +0 -1
  545. data/app/views/rails_trade_admin/promote_goods/new.html.erb +0 -13
  546. data/app/views/rails_trade_admin/promote_goods/show.json.jbuilder +0 -1
  547. data/app/views/rails_trade_admin/promotes/_form.html.erb +0 -9
  548. data/app/views/rails_trade_admin/promotes/edit.html.erb +0 -9
  549. data/app/views/rails_trade_admin/promotes/index.html.erb +0 -65
  550. data/app/views/rails_trade_admin/promotes/new.html.erb +0 -9
  551. data/app/views/rails_trade_admin/promotes/show.html.erb +0 -4
  552. data/app/views/rails_trade_admin/providers/_form.html.erb +0 -6
  553. data/app/views/rails_trade_admin/providers/_product.html.erb +0 -12
  554. data/app/views/rails_trade_admin/providers/_side.html.erb +0 -8
  555. data/app/views/rails_trade_admin/providers/area.html.erb +0 -1
  556. data/app/views/rails_trade_admin/providers/channel.html.erb +0 -46
  557. data/app/views/rails_trade_admin/providers/edit.html.erb +0 -16
  558. data/app/views/rails_trade_admin/providers/index.html.erb +0 -27
  559. data/app/views/rails_trade_admin/providers/new.html.erb +0 -21
  560. data/app/views/rails_trade_admin/providers/posts.html.erb +0 -41
  561. data/app/views/rails_trade_admin/providers/products.html.erb +0 -23
  562. data/app/views/rails_trade_admin/providers/show.html.erb +0 -60
  563. data/app/views/rails_trade_admin/refunds/_search_form.html.erb +0 -13
  564. data/app/views/rails_trade_admin/serve_charges/_edit.html.erb +0 -13
  565. data/app/views/rails_trade_admin/serve_charges/_form.html.erb +0 -10
  566. data/app/views/rails_trade_admin/serve_charges/_new.html.erb +0 -13
  567. data/app/views/rails_trade_admin/serve_charges/_search_form.html.erb +0 -10
  568. data/app/views/rails_trade_admin/serve_charges/edit.js.erb +0 -7
  569. data/app/views/rails_trade_admin/serve_charges/index.html.erb +0 -56
  570. data/app/views/rails_trade_admin/serve_charges/new.js.erb +0 -8
  571. data/app/views/rails_trade_admin/serves/_form.html.erb +0 -9
  572. data/app/views/rails_trade_admin/serves/edit.html.erb +0 -9
  573. data/app/views/rails_trade_admin/serves/index.html.erb +0 -80
  574. data/app/views/rails_trade_admin/serves/new.html.erb +0 -9
  575. data/app/views/rails_trade_my/addresses/_edit.html.erb +0 -31
  576. data/app/views/rails_trade_my/addresses/_form.html.erb +0 -23
  577. data/app/views/rails_trade_my/addresses/_new.html.erb +0 -11
  578. data/app/views/rails_trade_my/addresses/create.js.erb +0 -2
  579. data/app/views/rails_trade_my/addresses/edit.js.erb +0 -39
  580. data/app/views/rails_trade_my/addresses/index.html.erb +0 -44
  581. data/app/views/rails_trade_my/addresses/new.js.erb +0 -39
  582. data/app/views/rails_trade_my/addresses/show.html.erb +0 -4
  583. data/app/views/rails_trade_my/base/_nav.html.erb +0 -22
  584. data/app/views/rails_trade_my/buyers/_form.html.erb +0 -5
  585. data/app/views/rails_trade_my/buyers/edit.html.erb +0 -2
  586. data/app/views/rails_trade_my/buyers/show.html.erb +0 -21
  587. data/app/views/rails_trade_my/cart_items/_additions.html.erb +0 -22
  588. data/app/views/rails_trade_my/cart_items/_single_price.html.erb +0 -6
  589. data/app/views/rails_trade_my/cart_items/_total_price.html.erb +0 -8
  590. data/app/views/rails_trade_my/cart_items/index.html.erb +0 -69
  591. data/app/views/rails_trade_my/cart_items/total.js.erb +0 -11
  592. data/app/views/rails_trade_my/cart_items/update.js.erb +0 -8
  593. data/app/views/rails_trade_my/my/index.html.erb +0 -17
  594. data/app/views/rails_trade_my/orders/_edit_payment_type.html.erb +0 -13
  595. data/app/views/rails_trade_my/orders/edit_payment_type.js.erb +0 -6
  596. data/app/views/rails_trade_my/orders/index.html.erb +0 -55
  597. data/app/views/rails_trade_my/orders/update_payment_type.js.erb +0 -3
  598. data/app/views/rails_trade_my/orders/wxpay_pay.js.erb +0 -16
  599. data/app/views/rails_trade_my/orders/wxpay_pay_err.js.erb +0 -5
  600. data/app/views/rails_trade_my/payment_methods/destroy.js.erb +0 -1
  601. data/app/views/rails_trade_my/payment_methods/update.js.erb +0 -2
  602. data/app/views/rails_trade_my/providers/_form.html.erb +0 -5
  603. data/app/views/rails_trade_my/providers/_provider.html.erb +0 -20
  604. data/app/views/rails_trade_my/providers/edit.html.erb +0 -2
  605. data/app/views/rails_trade_my/providers/index.html.erb +0 -12
  606. data/app/views/rails_trade_my/providers/new.html.erb +0 -10
  607. data/app/views/rails_trade_my/providers/show.html.erb +0 -13
  608. data/config/locales/zh.yml +0 -75
  609. data/db/migrate/20150514135720_create_providers.rb +0 -59
  610. data/db/migrate/20170601014520_create_payments.rb +0 -52
  611. data/db/migrate/20170602061859_create_payment_references.rb +0 -12
  612. data/db/migrate/20170702234123_create_orders.rb +0 -56
  613. data/db/migrate/20170714080032_create_payment_strategies.rb +0 -77
  614. data/db/migrate/20171115063702_create_promote_buyers.rb +0 -31
  615. data/db/schema.rb +0 -94
  616. data/lib/tasks/the_trade_tasks.rake +0 -4
@@ -1,15 +1,18 @@
1
- class PaymentReference < ApplicationRecord
2
- belongs_to :payment_method, inverse_of: :payment_references
3
-
4
- before_save :prevent_duplicate
5
- after_initialize if: :new_record? do |t|
6
- self.buyer_id = self.user&.buyer_id if self.buyer_id.nil?
1
+ module RailsTrade::PaymentReference
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ attribute :state, :string
5
+
6
+ belongs_to :payment_method, inverse_of: :payment_references
7
+ belongs_to :buyer, polymorphic: true
8
+
9
+ before_save :prevent_duplicate
7
10
  end
8
-
11
+
9
12
  def prevent_duplicate
10
- if PaymentReference.exists?(payment_method_id: self.payment_method_id, buyer_id: self.buyer_id)
13
+ if PaymentReference.exists?(payment_method_id: self.payment_method_id, buyer_id: self.buyer_id, buyer_type: self.buyer_type)
11
14
  throw(:abort)
12
15
  end
13
16
  end
14
17
 
15
- end unless RailsTrade.config.disabled_models.include?('PaymentReference')
18
+ end
@@ -1,16 +1,19 @@
1
- class PaymentStrategy < ApplicationRecord
2
-
3
-
1
+ module RailsTrade::PaymentStrategy
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ attribute :name, :string
5
+ attribute :period, :integer, default: 0, comment: '可延期时间,单位天'
6
+ attribute :strategy, :string
7
+
8
+ enum strategy: {
9
+ # 预付全款
10
+ # 预付定金
11
+ # 后付
12
+ }
13
+ end
14
+
4
15
  def credit?
5
16
  self.period.to_i > 0
6
17
  end
7
18
 
8
- end unless RailsTrade.config.disabled_models.include?('PaymentStrategy')
9
-
10
-
11
- # :name, comment: '名称'
12
- # :period, comment: '可延期时间,单位天'
13
-
14
- # 预付全款
15
- # 预付定金
16
- # 后付
19
+ end
@@ -0,0 +1,28 @@
1
+ module RailsTrade::PaymentType::Alipay
2
+
3
+ def alipay_prepay
4
+ self.update payment_type: 'alipay'
5
+ Alipay2::Service.trade_app_pay_params(subject: self.subject, out_trade_no: self.uuid, total_amount: self.amount.to_s)
6
+ end
7
+
8
+ def alipay_prepay_url
9
+ self.update payment_type: 'alipay'
10
+ Alipay2::Service.trade_page_pay subject: self.subject, out_trade_no: self.uuid, total_amount: self.amount.to_s
11
+ end
12
+
13
+ def alipay_result
14
+ return self if self.payment_status == 'all_paid'
15
+
16
+ result = Alipay2::Service.trade_query out_trade_no: self.uuid
17
+ result = JSON.parse(result)
18
+ result = result['alipay_trade_query_response']
19
+
20
+ if result['trade_status'] == 'TRADE_SUCCESS'
21
+ self.change_to_paid! type: 'AlipayPayment', payment_uuid: result['trade_no'], params: result
22
+ else
23
+ errors.add :base, result['msg']
24
+ logger.error "Alipay: #{self.errors.full_messages.join(', ')}"
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,18 @@
1
+ module RailsTrade::PaymentType::ApplePay
2
+
3
+ def apple_pay_result(receipt_data)
4
+ return self if self.payment_status == 'all_paid'
5
+
6
+ result = ApplePay.query receipt_data
7
+
8
+ result['product_id'] == self.uuid
9
+ result['amount'] = self.amount
10
+
11
+ if result['trade_status'] == 'TRADE_SUCCESS'
12
+ self.change_to_paid! type: 'ApplePayment', payment_uuid: result['transaction_id'], params: result
13
+ else
14
+ errors.add :base, result['msg']
15
+ end
16
+ end
17
+
18
+ end
@@ -1,9 +1,4 @@
1
- module ThePaypal
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- delegate :url_helpers, to: 'Rails.application.routes'
6
- end
1
+ module RailsTrade::PaymentType::Paypal
7
2
 
8
3
  def paypal_prepay
9
4
  paypal_payment = PayPal::SDK::REST::DataTypes::Payment.new(paypal_params)
@@ -26,32 +21,16 @@ module ThePaypal
26
21
  end
27
22
 
28
23
  def paypal_result
29
- return unless self.payment_id
30
- self.paypal_payment ||= PayPal::SDK::REST::DataTypes::Payment.find(self.payment_id)
31
-
32
- paypal_record(paypal_payment)
33
- end
34
-
35
- def paypal_record(record)
36
- trans = record.transactions[0]
37
-
38
- if record.state == 'approved'
39
- paypal = PaypalPayment.find_by(payment_uuid: trans.related_resources[0].sale.id)
40
- return paypal if paypal
24
+ return self if self.payment_status == 'all_paid'
41
25
 
42
- paypal = PaypalPayment.new
43
- paypal.payment_uuid = trans.related_resources[0].sale.id
44
- paypal.total_amount = trans.amount.total
45
-
46
- payment_order = paypal.payment_orders.build(order_id: self.id, check_amount: paypal.total_amount)
26
+ return unless self.payment_id
27
+ paypal_payment ||= PayPal::SDK::REST::DataTypes::Payment.find(self.payment_id)
28
+ trans = paypal_payment.transactions[0]
47
29
 
48
- Payment.transaction do
49
- payment_order.confirm!
50
- paypal.save!
51
- end
52
- paypal
30
+ if paypal_payment.state == 'approved'
31
+ self.change_to_paid! type: 'PaypalPayment', payment_uuid: trans.related_resources[0].sale.id, params: trans
53
32
  else
54
- errors.add :uuid, record.error.inspect
33
+ errors.add :base, paypal_payment.error.inspect
55
34
  end
56
35
  end
57
36
 
@@ -1,8 +1,4 @@
1
- module TheStripe
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- end
1
+ module RailsTrade::PaymentType::Stripe
6
2
 
7
3
  def stripe_charge(params = {})
8
4
  if params[:token]
@@ -32,31 +28,17 @@ module TheStripe
32
28
  end
33
29
 
34
30
  def stripe_result
31
+ return self if self.payment_status == 'all_paid'
32
+
35
33
  if self.payment_id.present?
36
34
  charge = Stripe::Charge.retrieve(self.payment_id)
37
- self.stripe_record(charge)
38
- end
39
- end
40
35
 
41
- def stripe_record(charge)
42
- if charge.paid && !charge.refunded
43
- existing = StripePayment.find_by(payment_uuid: charge.id)
44
- return existing if existing
45
-
46
- stripe = StripePayment.new
47
- stripe.payment_uuid = charge.id
48
- stripe.total_amount = Money.new(charge.amount, self.currency).to_d
49
- stripe.currency = charge.currency.upcase
50
-
51
- payment_order = stripe.payment_orders.build(order_id: self.id, check_amount: stripe.total_amount)
52
-
53
- Payment.transaction do
54
- payment_order.confirm!
55
- stripe.save!
36
+ if charge.paid && !charge.refunded
37
+ self.change_to_paid! type: 'StripePayment', payment_uuid: charge.id, params: charge
38
+ else
39
+ errors.add :uuid, 'error'
56
40
  end
57
- stripe
58
- else
59
- errors.add :uuid, 'error'
41
+
60
42
  end
61
43
  end
62
44
 
@@ -0,0 +1,55 @@
1
+ module RailsTrade::PaymentType::Wxpay
2
+
3
+ def wxpay_prepay(trade_type: 'JSAPI', spbill_create_ip: '127.0.0.0', notify_url: url_helpers.wxpay_notify_payments_url, **options)
4
+ appid = options[:appid] || ::WxPay.appid
5
+ params = {
6
+ body: "订单编号: #{self.uuid}",
7
+ out_trade_no: self.uuid,
8
+ total_fee: (self.amount * 100).to_i,
9
+ spbill_create_ip: spbill_create_ip,
10
+ notify_url: notify_url,
11
+ trade_type: trade_type,
12
+ openid: user.oauth_users.find_by(app_id: appid)&.uid
13
+ }
14
+
15
+ ::WxPay::Service.invoke_unifiedorder params, options
16
+ end
17
+
18
+ def wxpay_order(trade_type: 'JSAPI', **options)
19
+ prepay = wxpay_prepay(trade_type: trade_type, **options)
20
+
21
+ if prepay.success?
22
+ params = {
23
+ noncestr: prepay['nonce_str'],
24
+ prepayid: prepay['prepay_id']
25
+ }
26
+ if trade_type == 'JSAPI'
27
+ ::WxPay::Service.generate_js_pay_req params, options
28
+ else
29
+ ::WxPay::Service.generate_app_pay_req params, options
30
+ end
31
+ else
32
+ prepay.except(:raw)
33
+ end
34
+ end
35
+
36
+ def wxpay_result(options = {})
37
+ return self if self.payment_status == 'all_paid'
38
+
39
+ params = {
40
+ out_trade_no: self.uuid,
41
+ }
42
+ begin
43
+ result = WxPay::Service.order_query params, options
44
+ rescue
45
+ result = { 'err_code_des' => 'network error' }
46
+ end
47
+
48
+ if result['trade_state'] == 'SUCCESS'
49
+ self.change_to_paid! type: 'WxpayPayment', payment_uuid: result['transaction_id'], params: result
50
+ else
51
+ self.errors.add :base, result['err_code_des']
52
+ end
53
+ end
54
+
55
+ end
@@ -1,30 +1,63 @@
1
- class Promote < ApplicationRecord
2
- attr_accessor :price
1
+ module RailsTrade::Promote
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ attribute :name, :string
5
+ attribute :short_name, :string
6
+ attribute :code, :string
7
+ attribute :description, :string
8
+ attribute :scope, :string
9
+ attribute :metering, :string
10
+ attribute :effect_at, :datetime
11
+ attribute :expire_at, :datetime
12
+ attribute :sequence, :integer, default: 1
13
+ attribute :editable, :boolean, default: false, comment: '是否可更改价格'
14
+ attribute :verified, :boolean, default: false
15
+ attribute :extra, :json
16
+
17
+ belongs_to :organ, optional: true
18
+ belongs_to :deal, polymorphic: true, optional: true
19
+ has_many :promote_charges, dependent: :delete_all
20
+ has_many :promote_extras, dependent: :delete_all
21
+ has_many :promote_goods, dependent: :destroy
22
+ has_many :promote_buyers, dependent: :destroy
23
+
24
+ scope :verified, -> { where(verified: true) }
25
+ scope :default, -> { verified.where(default: true) }
26
+ scope :for_sale, -> { verified.where(default: false) }
27
+ scope :valid, -> { t = Time.current; verified.default_where('effect_at-lte': t, 'expire_at-gte': t) }
3
28
 
4
- has_many :charges, class_name: 'PromoteCharge', dependent: :delete_all
5
-
6
- scope :special, -> { where(verified: true, overall: false) }
7
- scope :overall, -> { where(verified: true, overall: true) }
8
-
9
- after_commit :delete_cache, on: [:create, :destroy]
10
- #after_update_commit :delete_cache, if: -> { sequence_changed? }
11
-
12
- enum scope: {
13
- 'total': 'total',
14
- 'single': 'single'
15
- }
16
-
17
- def compute_price(amount, extra = {})
18
- query = { 'min-lte': amount.to_d, 'max-gt': amount.to_d }.merge(extra)
19
- charge = self.charges.default_where(query).first
20
- charge.subtotal = charge.final_price(amount) if charge
21
- charge
29
+ validates :code, uniqueness: true, allow_blank: true
30
+
31
+ after_commit :delete_cache, on: [:create, :destroy]
32
+ after_update_commit :delete_cache, if: -> { saved_change_to_sequence? }
33
+
34
+ enum scope: {
35
+ single: 'single', # 适用于单独计算商品
36
+ overall: 'overall' # 适用于多个商品一起计算
37
+ }
38
+ enum metering: {
39
+ number: 'number', # 商品购买件数
40
+ weight: 'weight', # 商品总重量,support sequence
41
+ volume: 'volume', # 商品总体积, support sequence
42
+ amount: 'amount' # 商品总金额, support sequence
43
+ }
44
+ end
45
+
46
+ def extra_mappings
47
+ promote_extras.pluck(:extra_name, :column_name).to_h
22
48
  end
23
49
 
24
- def self.sequence
25
- Rails.cache.fetch('promotes/sequence') do
26
- self.select(:sequence).distinct.pluck(:sequence).sort
27
- end
50
+ def compute_charge(value, **extra)
51
+ extra.transform_keys! { |key| extra_mappings[key.to_s] }
52
+ extra.delete nil
53
+
54
+ q_params = {
55
+ 'min-lte': value,
56
+ 'max-gte': value,
57
+ **extra
58
+ }
59
+
60
+ promote_charges.default_where(q_params).take
28
61
  end
29
62
 
30
63
  private
@@ -34,7 +67,12 @@ class Promote < ApplicationRecord
34
67
  end
35
68
  end
36
69
 
37
- end unless RailsTrade.config.disabled_models.include?('Promote')
70
+ class_methods do
71
+ def sequence
72
+ Rails.cache.fetch('promotes/sequence') do
73
+ self.select(:sequence).distinct.pluck(:sequence).sort
74
+ end
75
+ end
76
+ end
38
77
 
39
- # :start_at, :datetime
40
- # :finish_at, :datetime
78
+ end
@@ -1,9 +1,27 @@
1
- class PromoteBuyer < ApplicationRecord
2
- belongs_to :promote
1
+ module RailsTrade::PromoteBuyer
2
+ extend ActiveSupport::Concern
3
+ included do
4
+ attribute :state, :string, default: 'unused'
5
+ attribute :status, :string, default: 'available'
6
+ attribute :effect_at, :datetime
7
+ attribute :expire_at, :datetime
8
+ attribute :trade_promotes_count, :integer, default: 0
9
+
10
+ belongs_to :promote
11
+ belongs_to :promote_good, optional: true
12
+ belongs_to :buyer, polymorphic: true
13
+ has_many :trade_promotes, dependent: :nullify
14
+
15
+ enum state: {
16
+ unused: 'unused',
17
+ used: 'used'
18
+ }
3
19
 
20
+ scope :valid, -> { t = Time.current; unused.default_where('expire_at-gte': t, 'effect_at-lte': t) }
21
+
22
+ before_validation do
23
+ self.promote = self.promote_good.promote
24
+ end
25
+ end
4
26
 
5
- end unless RailsTrade.config.disabled_models.include?('PromoteBuyer')
6
-
7
- # :order_id, :integer
8
- # :order_item_id :integer
9
-
27
+ end
@@ -1,17 +1,84 @@
1
- class PromoteCharge < ApplicationRecord
2
- attr_accessor :subtotal
3
- belongs_to :item, class_name: 'Promote', foreign_key: :promote_id
4
-
5
- validates :max, numericality: { greater_than: -> (o) { o.min } }
6
- validates :min, numericality: { less_than: -> (o) { o.max } }
1
+ module RailsTrade::PromoteCharge
2
+ COLUMN_NAMES = [
3
+ 'id',
4
+ 'promote_id',
5
+ 'min',
6
+ 'max',
7
+ 'filter_min',
8
+ 'filter_max',
9
+ 'contain_min',
10
+ 'contain_max',
11
+ 'parameter',
12
+ 'base_price',
13
+ 'type',
14
+ 'metering',
15
+ 'unit',
16
+ 'created_at',
17
+ 'updated_at'
18
+ ].freeze
19
+ extend ActiveSupport::Concern
20
+
21
+ included do
22
+ attribute :type, :string
23
+ attribute :unit, :string
24
+ attribute :min, :decimal, precision: 10, scale: 2, default: 0
25
+ attribute :max, :decimal, precision: 10, scale: 2, default: 99999999.99
26
+ attribute :filter_min, :decimal, precision: 10, scale: 2, default: 0
27
+ attribute :filter_max, :decimal, precision: 10, scale: 2, default: 99999999.99
28
+ attribute :contain_min, :boolean, default: true
29
+ attribute :contain_max, :boolean, default: false
30
+ attribute :parameter, :decimal, precision: 10, scale: 2, default: 0
31
+ attribute :base_price, :decimal, precision: 10, scale: 2, default: 0
32
+
33
+ belongs_to :promote
34
+
35
+ scope :filter_with, ->(amount){ default_where('filter_min-lte': amount, 'filter_max-gte': amount) }
7
36
 
37
+ validates :max, numericality: { greater_than_or_equal_to: -> (o) { o.min } }
38
+ validates :min, numericality: { less_than_or_equal_to: -> (o) { o.max } }
39
+ #validates :min, uniqueness: { scope: [:contain_min, :contain_max] } # todo
40
+ before_validation :compute_filter_value
41
+ end
42
+
43
+ # amount: 商品价格
44
+ # return 计算后的价格
8
45
  def final_price(amount = 1)
9
46
  raise 'Should Implement in Subclass'
10
47
  end
48
+
49
+ def compute_filter_value
50
+ if contain_min
51
+ self.filter_min = min
52
+ else
53
+ self.filter_min = min + self.class.min_step
54
+ end
55
+ if contain_max
56
+ self.filter_max = max
57
+ else
58
+ self.filter_max = max - self.class.max_step
59
+ end
60
+ end
61
+
62
+ def extra
63
+ self.attributes.slice(*PromoteCharge.extra_columns)
64
+ end
65
+
66
+ class_methods do
67
+ def min_step
68
+ 0.1.to_d.power(self.columns_hash['min'].scale)
69
+ end
11
70
 
12
- end unless RailsTrade.config.disabled_models.include?('PromoteCharge')
71
+ def max_step
72
+ 0.1.to_d.power(self.columns_hash['max'].scale)
73
+ end
13
74
 
14
- # :min, :integer
15
- # :max, :integer
16
- # :price, :decimal
17
- # :type, :string # SingleCharge / TotalCharge
75
+ def extra_columns
76
+ self.column_names - COLUMN_NAMES
77
+ end
78
+
79
+ def extra_options
80
+ extra_columns.map { |extra_column| [self.human_attribute_name(extra_column), extra_column] }.to_h
81
+ end
82
+ end
83
+
84
+ end