rails_trade 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +165 -0
- data/README.md +47 -0
- data/Rakefile +37 -0
- data/app/assets/config/rails_trade_manifest.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/buyers/index.js +15 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/buyers/overdue.js +15 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/cart_items/create.js +3 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/cart_items/index.js +80 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/cart_items/only.js +45 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/orders/new.js +29 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/edit.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/index.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/new.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payment_methods/unverified.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payments/index.js +0 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/payments/new.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promote_buyers/edit.js +31 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promote_buyers/new.js +31 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promote_goods/index.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promotes/edit.js +2 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promotes/index.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/promotes/new.js +2 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/serves/edit.js +2 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/serves/index.js +1 -0
- data/app/assets/javascripts/controllers/rails_trade_admin/serves/new.js +4 -0
- data/app/assets/javascripts/controllers/rails_trade_my/cart_items/create.js +3 -0
- data/app/assets/javascripts/controllers/rails_trade_my/cart_items/index.js +65 -0
- data/app/controllers/areas_controller.rb +18 -0
- data/app/controllers/buyers_controller.rb +8 -0
- data/app/controllers/concerns/controller_order_types.rb +92 -0
- data/app/controllers/goods_controller.rb +90 -0
- data/app/controllers/payments_controller.rb +50 -0
- data/app/controllers/providers_controller.rb +8 -0
- data/app/controllers/the_trade_admin/addresses_controller.rb +75 -0
- data/app/controllers/the_trade_admin/areas_controller.rb +50 -0
- data/app/controllers/the_trade_admin/base_controller.rb +5 -0
- data/app/controllers/the_trade_admin/buyers_controller.rb +37 -0
- data/app/controllers/the_trade_admin/cart_item_serves_controller.rb +63 -0
- data/app/controllers/the_trade_admin/cart_items_controller.rb +123 -0
- data/app/controllers/the_trade_admin/order_payments_controller.rb +52 -0
- data/app/controllers/the_trade_admin/orders_controller.rb +103 -0
- data/app/controllers/the_trade_admin/payment_methods_controller.rb +111 -0
- data/app/controllers/the_trade_admin/payment_orders_controller.rb +56 -0
- data/app/controllers/the_trade_admin/payment_references_controller.rb +54 -0
- data/app/controllers/the_trade_admin/payment_strategies_controller.rb +50 -0
- data/app/controllers/the_trade_admin/payments_controller.rb +89 -0
- data/app/controllers/the_trade_admin/produces_controller.rb +66 -0
- data/app/controllers/the_trade_admin/promote_buyers_controller.rb +39 -0
- data/app/controllers/the_trade_admin/promote_charges_controller.rb +62 -0
- data/app/controllers/the_trade_admin/promote_goods_controller.rb +50 -0
- data/app/controllers/the_trade_admin/promotes_controller.rb +105 -0
- data/app/controllers/the_trade_admin/providers_controller.rb +121 -0
- data/app/controllers/the_trade_admin/refunds_controller.rb +60 -0
- data/app/controllers/the_trade_admin/serve_charges_controller.rb +67 -0
- data/app/controllers/the_trade_admin/serves_controller.rb +107 -0
- data/app/controllers/the_trade_my/addresses_controller.rb +50 -0
- data/app/controllers/the_trade_my/base_controller.rb +13 -0
- data/app/controllers/the_trade_my/buyers_controller.rb +35 -0
- data/app/controllers/the_trade_my/cart_items_controller.rb +71 -0
- data/app/controllers/the_trade_my/order_items_controller.rb +49 -0
- data/app/controllers/the_trade_my/orders_controller.rb +161 -0
- data/app/controllers/the_trade_my/payment_methods_controller.rb +76 -0
- data/app/controllers/the_trade_my/providers_controller.rb +44 -0
- data/app/models/rails_trade/address.rb +14 -0
- data/app/models/rails_trade/area.rb +65 -0
- data/app/models/rails_trade/cart_item.rb +185 -0
- data/app/models/rails_trade/cart_item_serve.rb +16 -0
- data/app/models/rails_trade/concerns/good_able.rb +63 -0
- data/app/models/rails_trade/concerns/order_able.rb +48 -0
- data/app/models/rails_trade/concerns/promote_fee.rb +54 -0
- data/app/models/rails_trade/concerns/serve_fee.rb +41 -0
- data/app/models/rails_trade/concerns/summary_service.rb +67 -0
- data/app/models/rails_trade/concerns/the_payment.rb +88 -0
- data/app/models/rails_trade/concerns/the_refund.rb +36 -0
- data/app/models/rails_trade/concerns/the_trade_buyer.rb +50 -0
- data/app/models/rails_trade/concerns/the_trade_user.rb +23 -0
- data/app/models/rails_trade/good_partner.rb +8 -0
- data/app/models/rails_trade/good_produce.rb +14 -0
- data/app/models/rails_trade/order.rb +111 -0
- data/app/models/rails_trade/order_item.rb +88 -0
- data/app/models/rails_trade/order_promote.rb +23 -0
- data/app/models/rails_trade/order_serve.rb +23 -0
- data/app/models/rails_trade/order_shipment.rb +10 -0
- data/app/models/rails_trade/payment.rb +135 -0
- data/app/models/rails_trade/payment_interface/payment_interface_base.rb +8 -0
- data/app/models/rails_trade/payment_interface/the_alipay.rb +49 -0
- data/app/models/rails_trade/payment_interface/the_paypal.rb +103 -0
- data/app/models/rails_trade/payment_interface/the_stripe.rb +73 -0
- data/app/models/rails_trade/payment_interface/the_wxpay.rb +56 -0
- data/app/models/rails_trade/payment_method.rb +57 -0
- data/app/models/rails_trade/payment_methods/alipay_method.rb +7 -0
- data/app/models/rails_trade/payment_methods/bank_method.rb +7 -0
- data/app/models/rails_trade/payment_methods/stripe_method.rb +57 -0
- data/app/models/rails_trade/payment_order.rb +75 -0
- data/app/models/rails_trade/payment_reference.rb +15 -0
- data/app/models/rails_trade/payment_strategy.rb +16 -0
- data/app/models/rails_trade/payments/alipay_payment.rb +12 -0
- data/app/models/rails_trade/payments/bank_payment.rb +15 -0
- data/app/models/rails_trade/payments/hand_payment.rb +13 -0
- data/app/models/rails_trade/payments/paypal_payment.rb +8 -0
- data/app/models/rails_trade/payments/stripe_payment.rb +7 -0
- data/app/models/rails_trade/payments/wxpay_payment.rb +14 -0
- data/app/models/rails_trade/produce.rb +18 -0
- data/app/models/rails_trade/promote.rb +40 -0
- data/app/models/rails_trade/promote_buyer.rb +9 -0
- data/app/models/rails_trade/promote_charge.rb +17 -0
- data/app/models/rails_trade/promote_charges/single_promote_charge.rb +7 -0
- data/app/models/rails_trade/promote_charges/total_promote_charge.rb +7 -0
- data/app/models/rails_trade/promote_good.rb +9 -0
- data/app/models/rails_trade/promotes/amount_promote.rb +4 -0
- data/app/models/rails_trade/promotes/number_promote.rb +4 -0
- data/app/models/rails_trade/provider.rb +25 -0
- data/app/models/rails_trade/refund.rb +63 -0
- data/app/models/rails_trade/refunds/alipay_refund.rb +33 -0
- data/app/models/rails_trade/refunds/bank_refund.rb +5 -0
- data/app/models/rails_trade/refunds/hand_refund.rb +5 -0
- data/app/models/rails_trade/refunds/paypal_refund.rb +32 -0
- data/app/models/rails_trade/refunds/stripe_refund.rb +26 -0
- data/app/models/rails_trade/refunds/wxpay_refund.rb +40 -0
- data/app/models/rails_trade/serve.rb +44 -0
- data/app/models/rails_trade/serve_charge.rb +37 -0
- data/app/models/rails_trade/serve_charges/single_serve_charge.rb +7 -0
- data/app/models/rails_trade/serve_charges/total_serve_charge.rb +7 -0
- data/app/models/rails_trade/serve_good.rb +9 -0
- data/app/models/rails_trade/serves/number_serve.rb +4 -0
- data/app/models/rails_trade/serves/quantity_serve.rb +4 -0
- data/app/models/rails_trade/shipment.rb +8 -0
- data/app/views/buyers/_show.html.erb +7 -0
- data/app/views/buyers/show.js.erb +1 -0
- data/app/views/goods/_choose.html.erb +36 -0
- data/app/views/goods/_good.html.erb +17 -0
- data/app/views/goods/_good_item.html.erb +17 -0
- data/app/views/goods/_nav.html.erb +18 -0
- data/app/views/goods/_search.html.erb +6 -0
- data/app/views/goods/index.html.erb +34 -0
- data/app/views/goods/index/_product.html.erb +14 -0
- data/app/views/goods/item.html.erb +47 -0
- data/app/views/goods/produce.html.erb +48 -0
- data/app/views/goods/show.html.erb +2 -0
- data/app/views/goods/show/_basic.html.erb +23 -0
- data/app/views/goods/show/_carousel.html.erb +35 -0
- data/app/views/goods/show/_items.html.erb +32 -0
- data/app/views/goods/show/_sales.html.erb +17 -0
- data/app/views/goods/show/_side.html.erb +19 -0
- data/app/views/goods/taxon/_breadcrumb.html.erb +8 -0
- data/app/views/goods/taxon/_nav.html.erb +19 -0
- data/app/views/goods/taxon/_nav_.html.erb +18 -0
- data/app/views/goods/taxon/_nav_last.html.erb +19 -0
- data/app/views/layouts/rails_trade_admin/base.html.erb +25 -0
- data/app/views/layouts/rails_trade_my/base.html.erb +28 -0
- data/app/views/rails_trade_admin/addresses/_address.html.erb +24 -0
- data/app/views/rails_trade_admin/addresses/_edit.html.erb +13 -0
- data/app/views/rails_trade_admin/addresses/_form.html.erb +23 -0
- data/app/views/rails_trade_admin/addresses/_new.html.erb +13 -0
- data/app/views/rails_trade_admin/addresses/create.js.erb +2 -0
- data/app/views/rails_trade_admin/addresses/destroy.js.erb +1 -0
- data/app/views/rails_trade_admin/addresses/edit.js.erb +39 -0
- data/app/views/rails_trade_admin/addresses/index.html.erb +41 -0
- data/app/views/rails_trade_admin/addresses/new.js.erb +52 -0
- data/app/views/rails_trade_admin/addresses/show.html.erb +4 -0
- data/app/views/rails_trade_admin/addresses/update.js.erb +2 -0
- data/app/views/rails_trade_admin/areas/_form.html.erb +9 -0
- data/app/views/rails_trade_admin/areas/edit.html.erb +16 -0
- data/app/views/rails_trade_admin/areas/index.html.erb +43 -0
- data/app/views/rails_trade_admin/areas/new.html.erb +11 -0
- data/app/views/rails_trade_admin/areas/show.html.erb +1 -0
- data/app/views/rails_trade_admin/base/_nav.html.erb +24 -0
- data/app/views/rails_trade_admin/base/_nav_bar.html.erb +23 -0
- data/app/views/rails_trade_admin/base/_nav_payment.html.erb +25 -0
- data/app/views/rails_trade_admin/buyers/_form.html.erb +17 -0
- data/app/views/rails_trade_admin/buyers/_menu.html.erb +5 -0
- data/app/views/rails_trade_admin/buyers/_search_form.html.erb +11 -0
- data/app/views/rails_trade_admin/buyers/edit.html.erb +6 -0
- data/app/views/rails_trade_admin/buyers/index.html.erb +46 -0
- data/app/views/rails_trade_admin/buyers/new.html.erb +5 -0
- data/app/views/rails_trade_admin/buyers/orders.html.erb +134 -0
- data/app/views/rails_trade_admin/buyers/overdue.html.erb +49 -0
- data/app/views/rails_trade_admin/buyers/show.html.erb +4 -0
- data/app/views/rails_trade_admin/cart_item_serves/_check.html.erb +12 -0
- data/app/views/rails_trade_admin/cart_item_serves/_index.html.erb +37 -0
- data/app/views/rails_trade_admin/cart_item_serves/_new.html.erb +14 -0
- data/app/views/rails_trade_admin/cart_item_serves/_serve.html.erb +16 -0
- data/app/views/rails_trade_admin/cart_item_serves/_single.html.erb +10 -0
- data/app/views/rails_trade_admin/cart_item_serves/_single_table.html.erb +29 -0
- data/app/views/rails_trade_admin/cart_item_serves/_total.html.erb +10 -0
- data/app/views/rails_trade_admin/cart_item_serves/_total_table.html.erb +26 -0
- data/app/views/rails_trade_admin/cart_item_serves/add.js.erb +47 -0
- data/app/views/rails_trade_admin/cart_item_serves/create.js.erb +3 -0
- data/app/views/rails_trade_admin/cart_item_serves/destroy.js.erb +50 -0
- data/app/views/rails_trade_admin/cart_item_serves/index.js.erb +50 -0
- data/app/views/rails_trade_admin/cart_item_serves/new.js.erb +5 -0
- data/app/views/rails_trade_admin/cart_item_serves/single.js.erb +55 -0
- data/app/views/rails_trade_admin/cart_item_serves/total.js.erb +55 -0
- data/app/views/rails_trade_admin/cart_items/_additions.html.erb +20 -0
- data/app/views/rails_trade_admin/cart_items/_filter.html.erb +15 -0
- data/app/views/rails_trade_admin/cart_items/_good_price.html.erb +10 -0
- data/app/views/rails_trade_admin/cart_items/_order_price.html.erb +27 -0
- data/app/views/rails_trade_admin/cart_items/_retail_price.html.erb +4 -0
- data/app/views/rails_trade_admin/cart_items/_single_price.html.erb +28 -0
- data/app/views/rails_trade_admin/cart_items/_total_price.html.erb +9 -0
- data/app/views/rails_trade_admin/cart_items/destroy.js.erb +1 -0
- data/app/views/rails_trade_admin/cart_items/error.html.erb +3 -0
- data/app/views/rails_trade_admin/cart_items/index.html.erb +104 -0
- data/app/views/rails_trade_admin/cart_items/only.html.erb +72 -0
- data/app/views/rails_trade_admin/cart_items/total.js.erb +11 -0
- data/app/views/rails_trade_admin/cart_items/update.js.erb +11 -0
- data/app/views/rails_trade_admin/goods/_form.html.erb +7 -0
- data/app/views/rails_trade_admin/goods/_item.html.erb +6 -0
- data/app/views/rails_trade_admin/goods/_new.html.erb +11 -0
- data/app/views/rails_trade_admin/goods/_show.html.erb +24 -0
- data/app/views/rails_trade_admin/goods/_show_tr.html.erb +24 -0
- data/app/views/rails_trade_admin/goods/create.js.erb +2 -0
- data/app/views/rails_trade_admin/goods/destroy.js.erb +1 -0
- data/app/views/rails_trade_admin/goods/edit.html.erb +16 -0
- data/app/views/rails_trade_admin/goods/edit.js.erb +8 -0
- data/app/views/rails_trade_admin/goods/edit_items.html.erb +43 -0
- data/app/views/rails_trade_admin/goods/edit_pic.html.erb +32 -0
- data/app/views/rails_trade_admin/goods/edit_promote.html.erb +64 -0
- data/app/views/rails_trade_admin/goods/index.html.erb +32 -0
- data/app/views/rails_trade_admin/goods/new.html.erb +14 -0
- data/app/views/rails_trade_admin/goods/new.js.erb +8 -0
- data/app/views/rails_trade_admin/goods/show.js.erb +5 -0
- data/app/views/rails_trade_admin/goods/update.js.erb +2 -0
- data/app/views/rails_trade_admin/order_payments/_index.html.erb +44 -0
- data/app/views/rails_trade_admin/order_payments/_new.html.erb +44 -0
- data/app/views/rails_trade_admin/order_payments/_payment_orders.html.erb +17 -0
- data/app/views/rails_trade_admin/order_payments/_payments.html.erb +19 -0
- data/app/views/rails_trade_admin/order_payments/create.js.erb +2 -0
- data/app/views/rails_trade_admin/order_payments/create_fail.js.erb +1 -0
- data/app/views/rails_trade_admin/order_payments/destroy.js.erb +2 -0
- data/app/views/rails_trade_admin/order_payments/index.js.erb +8 -0
- data/app/views/rails_trade_admin/order_payments/new.js.erb +8 -0
- data/app/views/rails_trade_admin/orders/_addresses.html.erb +36 -0
- data/app/views/rails_trade_admin/orders/_filter.html.erb +20 -0
- data/app/views/rails_trade_admin/orders/_form.html.erb +17 -0
- data/app/views/rails_trade_admin/orders/_invoice_addresses.html.erb +36 -0
- data/app/views/rails_trade_admin/orders/_item.html.erb +10 -0
- data/app/views/rails_trade_admin/orders/_new_items.html.erb +70 -0
- data/app/views/rails_trade_admin/orders/_search_form.html.erb +7 -0
- data/app/views/rails_trade_admin/orders/edit.html.erb +1 -0
- data/app/views/rails_trade_admin/orders/index.html.erb +61 -0
- data/app/views/rails_trade_admin/orders/new.html.erb +23 -0
- data/app/views/rails_trade_admin/orders/payments.html.erb +50 -0
- data/app/views/rails_trade_admin/orders/refresh.js.erb +7 -0
- data/app/views/rails_trade_admin/orders/show.html.erb +89 -0
- data/app/views/rails_trade_admin/payment_methods/_edit.html.erb +6 -0
- data/app/views/rails_trade_admin/payment_methods/_form.html.erb +5 -0
- data/app/views/rails_trade_admin/payment_methods/_index_layout.html.erb +15 -0
- data/app/views/rails_trade_admin/payment_methods/_new.html.erb +13 -0
- data/app/views/rails_trade_admin/payment_methods/_payment_method.html.erb +25 -0
- data/app/views/rails_trade_admin/payment_methods/_search_form.html.erb +22 -0
- data/app/views/rails_trade_admin/payment_methods/create.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_methods/destroy.js.erb +1 -0
- data/app/views/rails_trade_admin/payment_methods/edit.html.erb +15 -0
- data/app/views/rails_trade_admin/payment_methods/edit.js.erb +8 -0
- data/app/views/rails_trade_admin/payment_methods/index.html.erb +23 -0
- data/app/views/rails_trade_admin/payment_methods/mine.html.erb +23 -0
- data/app/views/rails_trade_admin/payment_methods/new.html.erb +15 -0
- data/app/views/rails_trade_admin/payment_methods/new.js.erb +7 -0
- data/app/views/rails_trade_admin/payment_methods/unverified.html.erb +60 -0
- data/app/views/rails_trade_admin/payment_methods/update.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_orders/_index.html.erb +31 -0
- data/app/views/rails_trade_admin/payment_orders/_new.html.erb +24 -0
- data/app/views/rails_trade_admin/payment_orders/_orders.html.erb +27 -0
- data/app/views/rails_trade_admin/payment_orders/cancel.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_orders/create.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_orders/create_fail.js.erb +1 -0
- data/app/views/rails_trade_admin/payment_orders/new.js.erb +6 -0
- data/app/views/rails_trade_admin/payment_orders/raise_fail.js.erb +1 -0
- data/app/views/rails_trade_admin/payment_orders/update.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_orders/update_fail.js.erb +2 -0
- data/app/views/rails_trade_admin/payment_references/_form.html.erb +20 -0
- data/app/views/rails_trade_admin/payment_references/_new.html.erb +11 -0
- data/app/views/rails_trade_admin/payment_references/destroy.js.erb +1 -0
- data/app/views/rails_trade_admin/payment_references/edit.html.erb +6 -0
- data/app/views/rails_trade_admin/payment_references/index.html.erb +25 -0
- data/app/views/rails_trade_admin/payment_references/new.js.erb +8 -0
- data/app/views/rails_trade_admin/payment_references/show.html.erb +4 -0
- data/app/views/rails_trade_admin/payment_strategies/_form.html.erb +5 -0
- data/app/views/rails_trade_admin/payment_strategies/edit.html.erb +13 -0
- data/app/views/rails_trade_admin/payment_strategies/index.html.erb +37 -0
- data/app/views/rails_trade_admin/payment_strategies/new.html.erb +13 -0
- data/app/views/rails_trade_admin/payments/_form.html.erb +12 -0
- data/app/views/rails_trade_admin/payments/_item.html.erb +49 -0
- data/app/views/rails_trade_admin/payments/_search_form.html.erb +15 -0
- data/app/views/rails_trade_admin/payments/analyze.js.erb +12 -0
- data/app/views/rails_trade_admin/payments/dashboard.html.erb +4 -0
- data/app/views/rails_trade_admin/payments/edit.html.erb +15 -0
- data/app/views/rails_trade_admin/payments/index.html.erb +60 -0
- data/app/views/rails_trade_admin/payments/new.html.erb +17 -0
- data/app/views/rails_trade_admin/payments/show.html.erb +4 -0
- data/app/views/rails_trade_admin/promote_buyers/_form.html.erb +6 -0
- data/app/views/rails_trade_admin/promote_buyers/_promote_buyer.json.jbuilder +2 -0
- data/app/views/rails_trade_admin/promote_buyers/edit.html.erb +14 -0
- data/app/views/rails_trade_admin/promote_buyers/index.html.erb +42 -0
- data/app/views/rails_trade_admin/promote_buyers/index.json.jbuilder +1 -0
- data/app/views/rails_trade_admin/promote_buyers/new.html.erb +13 -0
- data/app/views/rails_trade_admin/promote_buyers/show.html.erb +0 -0
- data/app/views/rails_trade_admin/promote_buyers/show.json.jbuilder +1 -0
- data/app/views/rails_trade_admin/promote_charges/_edit.html.erb +13 -0
- data/app/views/rails_trade_admin/promote_charges/_form.html.erb +6 -0
- data/app/views/rails_trade_admin/promote_charges/_new.html.erb +13 -0
- data/app/views/rails_trade_admin/promote_charges/_search_form.html.erb +9 -0
- data/app/views/rails_trade_admin/promote_charges/edit.js.erb +8 -0
- data/app/views/rails_trade_admin/promote_charges/index.html.erb +49 -0
- data/app/views/rails_trade_admin/promote_charges/new.js.erb +8 -0
- data/app/views/rails_trade_admin/promote_goods/_form.html.erb +4 -0
- data/app/views/rails_trade_admin/promote_goods/_promote_good.json.jbuilder +2 -0
- data/app/views/rails_trade_admin/promote_goods/edit.html.erb +14 -0
- data/app/views/rails_trade_admin/promote_goods/index.html.erb +37 -0
- data/app/views/rails_trade_admin/promote_goods/index.json.jbuilder +1 -0
- data/app/views/rails_trade_admin/promote_goods/new.html.erb +13 -0
- data/app/views/rails_trade_admin/promote_goods/show.html.erb +0 -0
- data/app/views/rails_trade_admin/promote_goods/show.json.jbuilder +1 -0
- data/app/views/rails_trade_admin/promotes/_form.html.erb +9 -0
- data/app/views/rails_trade_admin/promotes/edit.html.erb +9 -0
- data/app/views/rails_trade_admin/promotes/index.html.erb +65 -0
- data/app/views/rails_trade_admin/promotes/new.html.erb +9 -0
- data/app/views/rails_trade_admin/promotes/show.html.erb +4 -0
- data/app/views/rails_trade_admin/providers/_form.html.erb +6 -0
- data/app/views/rails_trade_admin/providers/_product.html.erb +12 -0
- data/app/views/rails_trade_admin/providers/_side.html.erb +8 -0
- data/app/views/rails_trade_admin/providers/area.html.erb +1 -0
- data/app/views/rails_trade_admin/providers/channel.html.erb +46 -0
- data/app/views/rails_trade_admin/providers/edit.html.erb +16 -0
- data/app/views/rails_trade_admin/providers/index.html.erb +27 -0
- data/app/views/rails_trade_admin/providers/new.html.erb +21 -0
- data/app/views/rails_trade_admin/providers/posts.html.erb +41 -0
- data/app/views/rails_trade_admin/providers/products.html.erb +23 -0
- data/app/views/rails_trade_admin/providers/show.html.erb +60 -0
- data/app/views/rails_trade_admin/refunds/_form.html.erb +17 -0
- data/app/views/rails_trade_admin/refunds/_logs_table.html.erb +33 -0
- data/app/views/rails_trade_admin/refunds/_new.html.erb +18 -0
- data/app/views/rails_trade_admin/refunds/_search_form.html.erb +13 -0
- data/app/views/rails_trade_admin/refunds/edit.html.erb +6 -0
- data/app/views/rails_trade_admin/refunds/index.html.erb +57 -0
- data/app/views/rails_trade_admin/refunds/logs.js.erb +8 -0
- data/app/views/rails_trade_admin/refunds/new.html.erb +5 -0
- data/app/views/rails_trade_admin/refunds/new.js.erb +8 -0
- data/app/views/rails_trade_admin/refunds/show.html.erb +4 -0
- data/app/views/rails_trade_admin/serve_charges/_edit.html.erb +13 -0
- data/app/views/rails_trade_admin/serve_charges/_form.html.erb +10 -0
- data/app/views/rails_trade_admin/serve_charges/_new.html.erb +13 -0
- data/app/views/rails_trade_admin/serve_charges/_search_form.html.erb +10 -0
- data/app/views/rails_trade_admin/serve_charges/edit.js.erb +7 -0
- data/app/views/rails_trade_admin/serve_charges/index.html.erb +56 -0
- data/app/views/rails_trade_admin/serve_charges/new.js.erb +8 -0
- data/app/views/rails_trade_admin/serves/_form.html.erb +9 -0
- data/app/views/rails_trade_admin/serves/edit.html.erb +9 -0
- data/app/views/rails_trade_admin/serves/index.html.erb +80 -0
- data/app/views/rails_trade_admin/serves/new.html.erb +9 -0
- data/app/views/rails_trade_my/addresses/_edit.html.erb +31 -0
- data/app/views/rails_trade_my/addresses/_form.html.erb +23 -0
- data/app/views/rails_trade_my/addresses/_new.html.erb +11 -0
- data/app/views/rails_trade_my/addresses/create.js.erb +2 -0
- data/app/views/rails_trade_my/addresses/destroy.js.erb +1 -0
- data/app/views/rails_trade_my/addresses/edit.js.erb +39 -0
- data/app/views/rails_trade_my/addresses/index.html.erb +44 -0
- data/app/views/rails_trade_my/addresses/new.js.erb +39 -0
- data/app/views/rails_trade_my/addresses/show.html.erb +4 -0
- data/app/views/rails_trade_my/addresses/update.js.erb +2 -0
- data/app/views/rails_trade_my/base/_nav.html.erb +22 -0
- data/app/views/rails_trade_my/buyers/_form.html.erb +5 -0
- data/app/views/rails_trade_my/buyers/edit.html.erb +2 -0
- data/app/views/rails_trade_my/buyers/show.html.erb +21 -0
- data/app/views/rails_trade_my/cart_items/_additions.html.erb +22 -0
- data/app/views/rails_trade_my/cart_items/_single_price.html.erb +6 -0
- data/app/views/rails_trade_my/cart_items/_total_price.html.erb +8 -0
- data/app/views/rails_trade_my/cart_items/destroy.js.erb +1 -0
- data/app/views/rails_trade_my/cart_items/index.html.erb +69 -0
- data/app/views/rails_trade_my/cart_items/total.js.erb +11 -0
- data/app/views/rails_trade_my/cart_items/update.js.erb +8 -0
- data/app/views/rails_trade_my/my/index.html.erb +17 -0
- data/app/views/rails_trade_my/order_items/_form.html.erb +17 -0
- data/app/views/rails_trade_my/order_items/edit.html.erb +6 -0
- data/app/views/rails_trade_my/order_items/index.html.erb +25 -0
- data/app/views/rails_trade_my/order_items/new.html.erb +5 -0
- data/app/views/rails_trade_my/order_items/show.html.erb +8 -0
- data/app/views/rails_trade_my/orders/_date_form.html.erb +23 -0
- data/app/views/rails_trade_my/orders/_edit.html.erb +10 -0
- data/app/views/rails_trade_my/orders/_edit_payment_type.html.erb +13 -0
- data/app/views/rails_trade_my/orders/_form.html.erb +4 -0
- data/app/views/rails_trade_my/orders/destroy.js.erb +1 -0
- data/app/views/rails_trade_my/orders/edit.js.erb +4 -0
- data/app/views/rails_trade_my/orders/edit_payment_type.js.erb +6 -0
- data/app/views/rails_trade_my/orders/fail.html.erb +11 -0
- data/app/views/rails_trade_my/orders/index.html.erb +55 -0
- data/app/views/rails_trade_my/orders/index.json.jbuilder +9 -0
- data/app/views/rails_trade_my/orders/new.html.erb +41 -0
- data/app/views/rails_trade_my/orders/refresh.js.erb +7 -0
- data/app/views/rails_trade_my/orders/show.html.erb +103 -0
- data/app/views/rails_trade_my/orders/success.html.erb +12 -0
- data/app/views/rails_trade_my/orders/update.js.erb +3 -0
- data/app/views/rails_trade_my/orders/update_payment_type.js.erb +3 -0
- data/app/views/rails_trade_my/orders/wxpay_pay.js.erb +16 -0
- data/app/views/rails_trade_my/orders/wxpay_pay_err.js.erb +5 -0
- data/app/views/rails_trade_my/payment_methods/_edit.html.erb +13 -0
- data/app/views/rails_trade_my/payment_methods/_form.html.erb +5 -0
- data/app/views/rails_trade_my/payment_methods/_index.html.erb +25 -0
- data/app/views/rails_trade_my/payment_methods/_item.html.erb +10 -0
- data/app/views/rails_trade_my/payment_methods/_new.html.erb +13 -0
- data/app/views/rails_trade_my/payment_methods/create.js.erb +3 -0
- data/app/views/rails_trade_my/payment_methods/destroy.js.erb +1 -0
- data/app/views/rails_trade_my/payment_methods/edit.js.erb +8 -0
- data/app/views/rails_trade_my/payment_methods/index.html.erb +1 -0
- data/app/views/rails_trade_my/payment_methods/index.js.erb +1 -0
- data/app/views/rails_trade_my/payment_methods/new.js.erb +8 -0
- data/app/views/rails_trade_my/payment_methods/show.html.erb +4 -0
- data/app/views/rails_trade_my/payment_methods/update.js.erb +2 -0
- data/app/views/rails_trade_my/providers/_form.html.erb +5 -0
- data/app/views/rails_trade_my/providers/_provider.html.erb +20 -0
- data/app/views/rails_trade_my/providers/edit.html.erb +2 -0
- data/app/views/rails_trade_my/providers/index.html.erb +12 -0
- data/app/views/rails_trade_my/providers/new.html.erb +10 -0
- data/app/views/rails_trade_my/providers/show.html.erb +13 -0
- data/app/views/rails_trade_my/users/_form.html.erb +17 -0
- data/app/views/rails_trade_my/users/edit.html.erb +44 -0
- data/app/views/rails_trade_my/users/show.html.erb +18 -0
- data/config/locales/en.yml +85 -0
- data/config/locales/zh.yml +75 -0
- data/config/routes.rb +118 -0
- data/db/migrate/20150514135720_create_providers.rb +59 -0
- data/db/migrate/20170601014520_create_payments.rb +52 -0
- data/db/migrate/20170602061859_create_payment_references.rb +12 -0
- data/db/migrate/20170702234123_create_orders.rb +56 -0
- data/db/migrate/20170714080032_create_payment_strategies.rb +77 -0
- data/db/migrate/20171115063702_create_promote_buyers.rb +31 -0
- data/db/schema.rb +94 -0
- data/lib/rails_trade.rb +22 -0
- data/lib/rails_trade/config.rb +12 -0
- data/lib/rails_trade/engine.rb +30 -0
- data/lib/rails_trade/version.rb +3 -0
- data/lib/tasks/the_trade_tasks.rake +4 -0
- metadata +491 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
class RailsTradeAdmin::AddressesController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_addresses, only: [:index]
|
3
|
+
before_action :set_address, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
@address = Address.new(user_id: params[:user_id], kind: params[:kind], address_type: params[:address_type])
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
@address = Address.new(address_params)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
if @address.save
|
17
|
+
format.html {
|
18
|
+
redirect_to admin_addresses_url(user_id: @address.user_id), notice: 'Address was successfully created.'
|
19
|
+
}
|
20
|
+
format.js
|
21
|
+
format.json { render json: @order, status: :created, location: @order }
|
22
|
+
else
|
23
|
+
format.html { render action: 'new' }
|
24
|
+
format.js
|
25
|
+
format.json { render json: @order.errors, status: :unprocessable_entity }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def show
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
end
|
35
|
+
|
36
|
+
def update
|
37
|
+
respond_to do |format|
|
38
|
+
if @address.update(address_params)
|
39
|
+
format.html { redirect_to admin_addresses_url(user_id: @address.user_id), notice: 'Address was successfully updated.' }
|
40
|
+
format.js
|
41
|
+
else
|
42
|
+
format.html { render :edit }
|
43
|
+
format.js
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
@address.destroy
|
50
|
+
respond_to do |format|
|
51
|
+
format.html { redirect_to admin_addresses_url(user_id: @address.user_id), notice: 'Address was successfully destroyed.' }
|
52
|
+
format.js
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
def set_addresses
|
58
|
+
if params[:user_id]
|
59
|
+
@addresses = Address.includes(:area).where(user_id: params[:user_id])
|
60
|
+
elsif params[:buyer_id]
|
61
|
+
@addresses = Address.includes(:area).where(buyer_id: params[:buyer_id])
|
62
|
+
else
|
63
|
+
@addresses = Address.none
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def set_address
|
68
|
+
@address = Address.find(params[:id])
|
69
|
+
end
|
70
|
+
|
71
|
+
def address_params
|
72
|
+
params.fetch(:address, {}).permit! #(:user_id, :buyer_id, :area_id, :kind, :contact_person, :tel, :address)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class RailsTradeAdmin::AreasController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_area, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
def index
|
5
|
+
@areas = Area.unscoped.page(params[:page])
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
end
|
10
|
+
|
11
|
+
def new
|
12
|
+
@area = Area.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def edit
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@area = Area.new area_params
|
20
|
+
|
21
|
+
if @area.save
|
22
|
+
redirect_to admin_areas_url, notice: '地区添加成功'
|
23
|
+
else
|
24
|
+
render action: 'new'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
if @area.update area_params
|
30
|
+
redirect_to admin_areas_url, notice: 'Area was successfully updated.'
|
31
|
+
else
|
32
|
+
render action: 'edit'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@area.destroy
|
38
|
+
redirect_to admin_areas_url
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def set_area
|
43
|
+
@area = Area.unscoped.find params[:id]
|
44
|
+
end
|
45
|
+
|
46
|
+
def area_params
|
47
|
+
params[:area].permit(:nation, :province, :city, :popular, :published)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class RailsTradeAdmin::BuyersController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_buyer, only: [:orders]
|
3
|
+
|
4
|
+
def index
|
5
|
+
@managers = Manager.where(id: current_manager.allow_ids)
|
6
|
+
q_params = params.fetch(:q, {}).permit(:payment_strategy_id, :'crm_permits.manager_id', :'name-like').reverse_merge('orders.payment_status': ['unpaid', 'part_paid'], 'orders.state': 'active')
|
7
|
+
@overdue_date = params.fetch(:q, {})['overdue_date-lte'] || Date.today
|
8
|
+
|
9
|
+
@buyers = Buyer.unscoped.includes(:orders, :payment_strategy, :crm_permits).default_where(q_params).permit_with(the_role_user).page(params[:page])
|
10
|
+
end
|
11
|
+
|
12
|
+
def overdue
|
13
|
+
@managers = Manager.where(id: current_manager.allow_ids)
|
14
|
+
q_params = params.fetch(:q, {}).permit(:payment_strategy_id, :'crm_permits.manager_id', :'name-like').reverse_merge('orders.payment_status': ['unpaid', 'part_paid'], 'orders.state': 'active')
|
15
|
+
@overdue_date = params.fetch(:q, {})['overdue_date-lte'] || Date.today
|
16
|
+
|
17
|
+
@buyers = Buyer.unscoped.includes(:orders, :payment_strategy, :crm_permits).default_where(q_params).permit_with(the_role_user).page(params[:page])
|
18
|
+
end
|
19
|
+
|
20
|
+
def orders
|
21
|
+
@orders = @buyer.orders.includes(crm_performs: :manager).to_pay.order(overdue_date: :asc).page(params[:page])
|
22
|
+
payment_method_ids = @buyer.payment_references.pluck(:payment_method_id)
|
23
|
+
@payments = Payment.where(payment_method_id: payment_method_ids, state: ['init', 'part_checked'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def remind
|
27
|
+
Order.remind params[:order_ids].split(',')
|
28
|
+
|
29
|
+
redirect_back fallback_location: admin_buyers_url
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def set_buyer
|
34
|
+
@buyer = Buyer.find params[:id]
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class RailsTradeAdmin::CartItemServesController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_cart_item
|
3
|
+
|
4
|
+
def index
|
5
|
+
end
|
6
|
+
|
7
|
+
def single
|
8
|
+
end
|
9
|
+
|
10
|
+
def total
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
end
|
15
|
+
|
16
|
+
def new
|
17
|
+
@cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: params[:serve_id])
|
18
|
+
@serve_charge = @cart_item.get_charge(@cart_item_serve.serve)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: cart_item_serve_params[:serve_id])
|
23
|
+
@cart_item_serve.assign_attributes cart_item_serve_params
|
24
|
+
|
25
|
+
@serve_charge = @cart_item.get_charge(@cart_item_serve.serve)
|
26
|
+
@serve_charge.subtotal = @cart_item_serve.price
|
27
|
+
|
28
|
+
respond_to do |format|
|
29
|
+
if @cart_item_serve.save
|
30
|
+
@cart_item.cart_item_serves.reload
|
31
|
+
format.js
|
32
|
+
format.html { redirect_to @cart_item_serve, notice: 'Taxon item was successfully created.' }
|
33
|
+
else
|
34
|
+
format.js
|
35
|
+
format.html { render :new }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add
|
41
|
+
@cart_item_serve = @cart_item.cart_item_serves.find_or_initialize_by(serve_id: params[:serve_id])
|
42
|
+
|
43
|
+
@serve_charge = @cart_item.get_charge(@cart_item_serve.serve)
|
44
|
+
@cart_item_serve.price = @serve_charge.default_subtotal
|
45
|
+
@cart_item_serve.save
|
46
|
+
end
|
47
|
+
|
48
|
+
def destroy
|
49
|
+
@cart_item_serve = CartItemServe.find(params[:id])
|
50
|
+
@serve_charge = @cart_item.get_charge(@cart_item_serve.serve)
|
51
|
+
@cart_item_serve.destroy
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def set_cart_item
|
56
|
+
@cart_item = CartItem.find params[:cart_item_id]
|
57
|
+
end
|
58
|
+
|
59
|
+
def cart_item_serve_params
|
60
|
+
params.fetch(:cart_item_serve, {}).permit(:serve_id, :price)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
class TheTradeAdmin::CartItemsController < TheTradeAdmin::BaseController
|
2
|
+
before_action :current_cart, only: [:index, :create, :only, :total]
|
3
|
+
before_action :set_cart_item, only: [:update, :destroy]
|
4
|
+
skip_before_action :verify_authenticity_token, only: [:total]
|
5
|
+
|
6
|
+
def index
|
7
|
+
@cart_items = @cart_items.page(params[:page])
|
8
|
+
@checked_ids = @cart_items.checked.pluck(:id)
|
9
|
+
@additions = CartItem.checked_items(user_id: @user&.id, buyer_id: params[:buyer_id])
|
10
|
+
end
|
11
|
+
|
12
|
+
def only
|
13
|
+
unless params[:good_type] && params[:good_id]
|
14
|
+
redirect_back(fallback_location: admin_cart_items_url, notice: 'Need Good type and Good ID') and return
|
15
|
+
end
|
16
|
+
|
17
|
+
good = params[:good_type].safe_constantize&.find_by(id: params[:good_id])
|
18
|
+
if good.respond_to?(:user_id)
|
19
|
+
@user = good.user
|
20
|
+
@buyer = @user.buyer
|
21
|
+
@cart_items = CartItem.where(good_type: params[:good_type], good_id: params[:good_id], user_id: good.user_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
@cart_item = @cart_items.where(good_id: params[:good_id], good_type: params[:good_type]).first
|
25
|
+
if @cart_item.present?
|
26
|
+
params[:quantity] ||= 0
|
27
|
+
@cart_item.checked = true
|
28
|
+
@cart_item.quantity = @cart_item.quantity + params[:quantity].to_i
|
29
|
+
@cart_item.save
|
30
|
+
else
|
31
|
+
@cart_item = @cart_items.build(good_id: params[:good_id], good_type: params[:good_type], quantity: params[:quantity])
|
32
|
+
@cart_item.checked = true
|
33
|
+
@cart_item.save
|
34
|
+
end
|
35
|
+
|
36
|
+
@additions = @cart_item.total
|
37
|
+
|
38
|
+
render 'only'
|
39
|
+
end
|
40
|
+
|
41
|
+
def create
|
42
|
+
cart_item = @cart_items.unscope(where: :status).where(good_id: params[:good_id], good_type: params[:good_type]).first
|
43
|
+
if cart_item.present?
|
44
|
+
params[:quantity] ||= 0
|
45
|
+
cart_item.checked = true
|
46
|
+
cart_item.status = 'pending'
|
47
|
+
cart_item.quantity = cart_item.quantity + params[:quantity].to_i
|
48
|
+
cart_item.save
|
49
|
+
else
|
50
|
+
cart_item = @cart_items.build(good_id: params[:good_id], good_type: params[:good_type], quantity: params[:quantity], myself: false)
|
51
|
+
cart_item.checked = true
|
52
|
+
cart_item.save
|
53
|
+
end
|
54
|
+
|
55
|
+
@checked_ids = @cart_items.checked.pluck(:id)
|
56
|
+
@additions = CartItem.checked_items(user_id: @user_id, buyer_id: params[:buyer_id])
|
57
|
+
|
58
|
+
render 'index'
|
59
|
+
end
|
60
|
+
|
61
|
+
def total
|
62
|
+
if params[:add_id].present?
|
63
|
+
@add = @cart_items.find_by(id: params[:add_id])
|
64
|
+
@add.update(checked: true)
|
65
|
+
elsif params[:remove_id].present?
|
66
|
+
@remove = @cart_items.find_by(id: params[:remove_id])
|
67
|
+
@remove.update(checked: false)
|
68
|
+
end
|
69
|
+
|
70
|
+
@additions = CartItem.checked_items(user_id: @user&.id, buyer_id: params[:buyer_id])
|
71
|
+
|
72
|
+
response.headers['X-Request-URL'] = request.url
|
73
|
+
end
|
74
|
+
|
75
|
+
def doc
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def update
|
80
|
+
@cart_item.update(quantity: params[:quantity])
|
81
|
+
@additions = CartItem.checked_items(user_id: @cart_item.user_id, buyer_id: @cart_item.buyer_id)
|
82
|
+
end
|
83
|
+
|
84
|
+
def destroy
|
85
|
+
@cart_item = CartItem.find params[:id]
|
86
|
+
@cart_item.destroy
|
87
|
+
@additions = CartItem.checked_items(user_id: @cart_item.user_id, buyer_id: @cart_item.buyer_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def set_cart_item
|
92
|
+
@cart_item = CartItem.find(params[:id])
|
93
|
+
if @cart_item.user_id
|
94
|
+
@cart_items = CartItem.where(user_id: @cart_item.user_id)
|
95
|
+
else
|
96
|
+
@cart_items = CartItem.where(buyer_id: @cart_item.buyer_id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def cart_item_params
|
101
|
+
params.require(:cart_item).permit(id: [],
|
102
|
+
single_price: [],
|
103
|
+
amount: [],
|
104
|
+
total_price: [])
|
105
|
+
end
|
106
|
+
|
107
|
+
def current_cart
|
108
|
+
if params[:user_id].present?
|
109
|
+
@cart_items = CartItem.where(user_id: params[:user_id])
|
110
|
+
@user = User.find params[:user_id]
|
111
|
+
@buyer = @user.buyer
|
112
|
+
elsif params[:buyer_id].present?
|
113
|
+
@buyer = Buyer.find params[:buyer_id]
|
114
|
+
@cart_items = CartItem.where(buyer_id: params[:buyer_id])
|
115
|
+
elsif params[:id].present?
|
116
|
+
@cart_items = CartItem.where(id: params[:id])
|
117
|
+
else
|
118
|
+
@cart_items = CartItem.none
|
119
|
+
end
|
120
|
+
@cart_items = @cart_items.pending.default_where(params.permit(:good_type, :myself, :id))
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class RailsTradeAdmin::OrderPaymentsController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_order
|
3
|
+
before_action :set_payment_order, only: [:destroy]
|
4
|
+
after_action only: [:create] do
|
5
|
+
mark_audits(Order: [:payment_orders])
|
6
|
+
end
|
7
|
+
|
8
|
+
def index
|
9
|
+
@payment_orders = @order.payment_orders
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@payment_order = PaymentOrder.new
|
14
|
+
@payments = @order.pending_payments
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@payment_order = @order.payment_orders.build(payment_order_params)
|
19
|
+
@order = @payment_order.order
|
20
|
+
|
21
|
+
if @payment_order.save
|
22
|
+
respond_to do |format|
|
23
|
+
format.js
|
24
|
+
end
|
25
|
+
else
|
26
|
+
render 'create_fail'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
if @payment_order.init?
|
32
|
+
@payment_order.destroy
|
33
|
+
end
|
34
|
+
respond_to do |format|
|
35
|
+
format.js
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def set_payment_order
|
41
|
+
@payment_order = PaymentOrder.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_order
|
45
|
+
@order = Order.find(params[:order_id])
|
46
|
+
end
|
47
|
+
|
48
|
+
def payment_order_params
|
49
|
+
params.fetch(:payment_order, {}).permit(:payment_id, :check_amount)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class RailsTradeAdmin::OrdersController < RailsTradeAdmin::BaseController
|
2
|
+
before_action :set_order, only: [:show, :edit, :update, :refund, :destroy]
|
3
|
+
skip_before_action :verify_authenticity_token, only: [:refresh]
|
4
|
+
|
5
|
+
def index
|
6
|
+
query_params = params.permit(:id, :user_id, :payment_status, :payment_type)
|
7
|
+
q_params = params.fetch(:q, {}).permit(:uuid)
|
8
|
+
query_params.merge! q_params
|
9
|
+
|
10
|
+
@orders = Order.default_where(query_params).order(id: :desc).page(params[:page])
|
11
|
+
end
|
12
|
+
|
13
|
+
def payments
|
14
|
+
@orders = Order.default_where(params.permit(:id, :payment_status)).default_where(params.fetch(:q, {}).permit(:uuid)).page(params[:page])
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
@order = Order.new(user_id: params[:user_id])
|
19
|
+
if params[:cart_item_id]
|
20
|
+
@order.migrate_from_cart_item(params[:cart_item_id])
|
21
|
+
else
|
22
|
+
@order.migrate_from_cart_items
|
23
|
+
end
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html
|
27
|
+
format.json { render json: @order }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def refresh
|
32
|
+
@order = Order.new(user_id: params[:user_id])
|
33
|
+
@order.assign_attributes order_params
|
34
|
+
|
35
|
+
if params[:cart_item_id]
|
36
|
+
cart_item = CartItem.find(params[:cart_item_id])
|
37
|
+
cart_item.update extra: @order.extra
|
38
|
+
@order.migrate_from_cart_item(params[:cart_item_id])
|
39
|
+
else
|
40
|
+
@order.migrate_from_cart_items
|
41
|
+
end
|
42
|
+
|
43
|
+
respond_to do |format|
|
44
|
+
format.js
|
45
|
+
format.html
|
46
|
+
format.json { render json: @order }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
@order = Order.new(order_params)
|
52
|
+
|
53
|
+
respond_to do |format|
|
54
|
+
if @order.save
|
55
|
+
format.html { redirect_to admin_order_url(@order), notice: 'Order was successfully created.' }
|
56
|
+
format.json { render json: @order, status: :created, location: @order }
|
57
|
+
else
|
58
|
+
format.html { render action: 'new' }
|
59
|
+
format.json { render json: @order.errors, status: :unprocessable_entity }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def show
|
65
|
+
end
|
66
|
+
|
67
|
+
def update
|
68
|
+
if @order.update(order_params)
|
69
|
+
redirect_to @order, notice: 'Order was successfully updated.'
|
70
|
+
else
|
71
|
+
render :edit
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def refund
|
76
|
+
@order.apply_for_refund
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
format.html { redirect_to admin_orders_url(id: @order.id) }
|
80
|
+
format.json { render json: @order.as_json(include: [:refunds]) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def destroy
|
85
|
+
@order.destroy
|
86
|
+
redirect_to admin_orders_url(user_id: @order.user_id), notice: 'Order was successfully destroyed.'
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def set_order
|
91
|
+
@order = Order.find(params[:id])
|
92
|
+
end
|
93
|
+
|
94
|
+
def order_params
|
95
|
+
params.fetch(:order, {}).permit(:user_id, :quantity, :payment_id, :payment_type,
|
96
|
+
:address_id, :invoice_address_id,
|
97
|
+
:amount,
|
98
|
+
order_items_attributes: [:cart_item_id, :deliver_on, :advance_payment, :comment],
|
99
|
+
order_serves_attributes: [:serve_id, :serve_charge_id, :amount],
|
100
|
+
order_promotes_attributes: [:promote_id, :promote_charge_id, :amount])
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|