rails_trade 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -165
- data/README.md +8 -1
- data/app/apis/trade/apple_pay_api.rb +33 -0
- data/app/controllers/trade/admin/advances_controller.rb +58 -0
- data/app/controllers/trade/admin/base_controller.rb +3 -4
- data/app/controllers/trade/admin/card_advances_controller.rb +60 -0
- data/app/controllers/trade/admin/card_logs_controller.rb +44 -0
- data/app/controllers/trade/admin/card_payments_controller.rb +60 -0
- data/app/controllers/trade/admin/card_prepayments_controller.rb +58 -0
- data/app/controllers/trade/admin/card_promotes_controller.rb +63 -0
- data/app/controllers/trade/admin/card_templates_controller.rb +69 -0
- data/app/controllers/trade/admin/cards_controller.rb +66 -0
- data/app/controllers/trade/admin/carts_controller.rb +74 -0
- data/app/controllers/trade/admin/cash_givens_controller.rb +55 -0
- data/app/controllers/trade/admin/cash_logs_controller.rb +45 -0
- data/app/controllers/trade/admin/cashes_controller.rb +41 -0
- data/app/controllers/trade/admin/order_payments_controller.rb +42 -40
- data/app/controllers/trade/admin/orders_controller.rb +73 -83
- data/app/controllers/trade/admin/payment_methods_controller.rb +71 -84
- data/app/controllers/trade/admin/payment_orders_controller.rb +45 -42
- data/app/controllers/trade/admin/payment_references_controller.rb +45 -39
- data/app/controllers/trade/admin/payment_strategies_controller.rb +43 -40
- data/app/controllers/trade/admin/payments_controller.rb +68 -74
- data/app/controllers/trade/admin/payouts_controller.rb +67 -0
- data/app/controllers/trade/admin/promote_carts_controller.rb +54 -0
- data/app/controllers/trade/admin/promote_charges_controller.rb +55 -53
- data/app/controllers/trade/admin/promote_goods_controller.rb +51 -46
- data/app/controllers/trade/admin/promotes_controller.rb +3 -67
- data/app/controllers/trade/admin/refunds_controller.rb +51 -40
- data/app/controllers/trade/admin/trade_items_controller.rb +103 -98
- data/app/controllers/trade/admin/trade_promotes_controller.rb +36 -54
- data/app/controllers/trade/admin/users_controller.rb +30 -0
- data/app/controllers/trade/advances_controller.rb +50 -0
- data/app/controllers/trade/base_controller.rb +4 -0
- data/app/controllers/trade/card_templates_controller.rb +61 -0
- data/app/controllers/trade/controller/application.rb +35 -0
- data/app/controllers/trade/controller/promote.rb +68 -0
- data/app/controllers/trade/my/advances_controller.rb +66 -0
- data/app/controllers/trade/my/base_controller.rb +3 -3
- data/app/controllers/trade/my/card_logs_controller.rb +15 -0
- data/app/controllers/trade/my/cards_controller.rb +78 -0
- data/app/controllers/trade/my/carts_controller.rb +50 -29
- data/app/controllers/trade/my/cash_logs_controller.rb +10 -0
- data/app/controllers/trade/my/orders_controller.rb +145 -81
- data/app/controllers/trade/my/payment_methods_controller.rb +40 -57
- data/app/controllers/trade/my/payments_controller.rb +56 -0
- data/app/controllers/trade/my/payouts_controller.rb +33 -0
- data/app/controllers/trade/my/trade_items_controller.rb +54 -44
- data/app/controllers/trade/panel/base_controller.rb +4 -0
- data/app/controllers/trade/panel/exchange_rates_controller.rb +53 -0
- data/app/controllers/trade/payments_controller.rb +53 -51
- data/app/models/payment/trade/alipay_payment.rb +5 -0
- data/app/models/payment/trade/apple_payment.rb +5 -0
- data/app/models/payment/trade/bank_payment.rb +5 -0
- data/app/models/payment/trade/card_payment.rb +5 -0
- data/app/models/payment/trade/hand_payment.rb +5 -0
- data/app/models/payment/trade/paypal_payment.rb +5 -0
- data/app/models/payment/trade/stripe_payment.rb +5 -0
- data/app/models/payment/trade/wxpay_payment.rb +5 -0
- data/app/models/payment_method/trade/alipay_method.rb +4 -0
- data/app/models/payment_method/trade/bank_method.rb +4 -0
- data/app/models/payment_method/trade/stripe_method.rb +5 -0
- data/app/models/payout/trade/wxpay_payout.rb +5 -0
- data/app/models/promote_charge/trade/discount_promote_charge.rb +5 -0
- data/app/models/promote_charge/trade/final_promote_charge.rb +5 -0
- data/app/models/promote_charge/trade/minus_promote_charge.rb +5 -0
- data/app/models/promote_charge/trade/plus_promote_charge.rb +5 -0
- data/app/models/refund/trade/alipay_refund.rb +5 -0
- data/app/models/refund/trade/bank_refund.rb +5 -0
- data/app/models/refund/trade/card_refund.rb +5 -0
- data/app/models/refund/trade/hand_refund.rb +5 -0
- data/app/models/refund/trade/paypal_refund.rb +5 -0
- data/app/models/refund/trade/stripe_refund.rb +5 -0
- data/app/models/refund/trade/wxpay_refund.rb +5 -0
- data/app/models/trade/advance.rb +6 -0
- data/app/models/trade/application_record.rb +5 -0
- data/app/models/trade/card.rb +6 -0
- data/app/models/trade/card_advance.rb +5 -0
- data/app/models/trade/card_log.rb +5 -0
- data/app/models/trade/card_prepayment.rb +5 -0
- data/app/models/trade/card_promote.rb +5 -0
- data/app/models/trade/card_template.rb +5 -0
- data/app/models/trade/cart.rb +7 -0
- data/app/models/trade/cash.rb +6 -0
- data/app/models/trade/cash_given.rb +5 -0
- data/app/models/trade/cash_log.rb +5 -0
- data/app/models/trade/exchange_rate.rb +5 -0
- data/app/models/trade/ext/payable.rb +50 -0
- data/app/models/trade/ext/user.rb +38 -0
- data/app/models/trade/model/advance.rb +43 -0
- data/app/models/trade/model/agency.rb +10 -0
- data/app/models/trade/model/amount.rb +41 -0
- data/app/models/trade/model/card.rb +64 -0
- data/app/models/trade/model/card_advance.rb +52 -0
- data/app/models/trade/model/card_log.rb +17 -0
- data/app/models/trade/model/card_prepayment.rb +31 -0
- data/app/models/trade/model/card_promote.rb +14 -0
- data/app/models/trade/model/card_template.rb +31 -0
- data/app/models/trade/model/cart.rb +60 -0
- data/app/models/trade/model/cash.rb +32 -0
- data/app/models/trade/model/cash_given.rb +40 -0
- data/app/models/trade/model/cash_log.rb +26 -0
- data/app/models/trade/model/compute.rb +33 -0
- data/app/models/trade/model/exchange_rate.rb +44 -0
- data/app/models/trade/model/good.rb +66 -0
- data/app/models/trade/model/member.rb +25 -0
- data/app/models/trade/model/order.rb +127 -0
- data/app/models/trade/model/payment/alipay_payment.rb +17 -0
- data/app/models/trade/model/payment/apple_payment.rb +9 -0
- data/app/models/trade/model/payment/bank_payment.rb +19 -0
- data/app/models/trade/model/payment/card_payment.rb +72 -0
- data/app/models/trade/model/payment/hand_payment.rb +10 -0
- data/app/models/trade/model/payment/paypal_payment.rb +10 -0
- data/app/models/trade/model/payment/stripe_payment.rb +11 -0
- data/app/models/trade/model/payment/wxpay_payment.rb +15 -0
- data/app/models/trade/model/payment.rb +131 -0
- data/app/models/trade/model/payment_method/stripe_method.rb +59 -0
- data/app/models/trade/model/payment_method.rb +67 -0
- data/app/models/trade/model/payment_order.rb +108 -0
- data/app/models/trade/model/payment_reference.rb +21 -0
- data/app/models/trade/model/payment_strategy.rb +22 -0
- data/app/models/trade/model/payout/wxpay_payout.rb +31 -0
- data/app/models/trade/model/payout.rb +71 -0
- data/app/models/trade/model/plan_attender.rb +33 -0
- data/app/models/trade/model/profile.rb +10 -0
- data/app/models/trade/model/promote.rb +59 -0
- data/app/models/trade/model/promote_cart.rb +30 -0
- data/app/models/trade/model/promote_charge/discount_promote_charge.rb +19 -0
- data/app/models/trade/model/promote_charge/final_promote_charge.rb +11 -0
- data/app/models/trade/model/promote_charge/minus_promote_charge.rb +20 -0
- data/app/models/trade/model/promote_charge/plus_promote_charge.rb +9 -0
- data/app/models/trade/model/promote_charge.rb +86 -0
- data/app/models/trade/model/promote_extra.rb +16 -0
- data/app/models/trade/model/promote_good.rb +28 -0
- data/app/models/trade/model/refund/alipay_refund.rb +29 -0
- data/app/models/trade/model/refund/bank_refund.rb +4 -0
- data/app/models/trade/model/refund/card_refund.rb +45 -0
- data/app/models/trade/model/refund/hand_refund.rb +9 -0
- data/app/models/trade/model/refund/paypal_refund.rb +27 -0
- data/app/models/trade/model/refund/stripe_refund.rb +20 -0
- data/app/models/trade/model/refund/wxpay_refund.rb +74 -0
- data/app/models/trade/model/refund.rb +70 -0
- data/app/models/trade/model/sell.rb +24 -0
- data/app/models/trade/model/trade_item.rb +214 -0
- data/app/models/trade/model/trade_promote.rb +69 -0
- data/app/models/trade/order.rb +8 -0
- data/app/models/trade/ordering/payment.rb +112 -0
- data/app/models/trade/ordering/refund.rb +36 -0
- data/app/models/trade/payment.rb +6 -0
- data/app/models/trade/payment_method.rb +5 -0
- data/app/models/trade/payment_order.rb +5 -0
- data/app/models/trade/payment_reference.rb +5 -0
- data/app/models/trade/payment_strategy.rb +5 -0
- data/app/models/trade/payment_type/alipay.rb +35 -0
- data/app/models/trade/payment_type/apple_pay.rb +20 -0
- data/app/models/trade/payment_type/paypal.rb +84 -0
- data/app/models/trade/payment_type/stripe.rb +57 -0
- data/app/models/trade/payment_type/svf_card.rb +24 -0
- data/app/models/trade/payment_type/wxpay.rb +104 -0
- data/app/models/trade/payout.rb +5 -0
- data/app/models/trade/promote.rb +6 -0
- data/app/models/trade/promote_cart.rb +5 -0
- data/app/models/trade/promote_charge.rb +5 -0
- data/app/models/trade/promote_extra.rb +5 -0
- data/app/models/trade/promote_good.rb +5 -0
- data/app/models/trade/refund.rb +5 -0
- data/app/models/trade/trade_item.rb +5 -0
- data/app/models/trade/trade_promote.rb +5 -0
- data/app/models/trade.rb +11 -0
- data/app/views/admin/_trade_nav.html.erb +35 -0
- data/app/views/my/_trade_nav.html.erb +4 -9
- data/app/views/panel/_trade_nav.html.erb +10 -0
- data/app/views/trade/admin/advances/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/advances/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/advances/_form.html.erb +4 -0
- data/app/views/trade/admin/advances/_index_tbody.html.erb +3 -0
- data/app/views/trade/admin/advances/_index_thead.html.erb +4 -0
- data/app/views/trade/admin/advances/_new_form.html.erb +4 -0
- data/app/views/trade/admin/advances/index.html.erb +5 -0
- data/app/views/trade/admin/advances/show.html.erb +30 -0
- data/app/views/trade/admin/base/_nav.html.erb +4 -0
- data/app/views/trade/admin/card_advances/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/card_advances/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_advances/_form.html.erb +3 -0
- data/app/views/trade/admin/card_advances/_index_tbody.html.erb +5 -0
- data/app/views/trade/admin/card_advances/_index_thead.html.erb +6 -0
- data/app/views/trade/admin/card_advances/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_advances/_show_table.html.erb +20 -0
- data/app/views/trade/admin/card_advances/index.html.erb +5 -0
- data/app/views/trade/admin/card_logs/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/card_logs/_card_log.json.jbuilder +11 -0
- data/app/views/trade/admin/card_logs/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_logs/_filter_form.html.erb +8 -0
- data/app/views/trade/admin/card_logs/_form.html.erb +3 -0
- data/app/views/trade/admin/card_logs/_index_tbody.html.erb +8 -0
- data/app/views/trade/admin/card_logs/_index_thead.html.erb +9 -0
- data/app/views/trade/admin/card_logs/_index_tr.html.erb +10 -0
- data/app/views/trade/admin/card_logs/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_logs/_show.json.jbuilder +1 -0
- data/app/views/trade/admin/card_logs/_show_table.html.erb +24 -0
- data/app/views/trade/admin/card_logs/index.html.erb +5 -0
- data/app/views/trade/admin/card_logs/index.json.jbuilder +1 -0
- data/app/views/trade/admin/card_payments/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/{orders/_search_form.html.erb → card_payments/_button.html.erb} +0 -0
- data/app/views/trade/admin/card_payments/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_payments/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/card_payments/_form.html.erb +2 -0
- data/app/views/trade/admin/card_payments/_index_tbody.html.erb +3 -0
- data/app/views/trade/admin/card_payments/_index_thead.html.erb +4 -0
- data/app/views/trade/admin/card_payments/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_payments/_show_table.html.erb +12 -0
- data/app/views/trade/admin/card_payments/index.html.erb +5 -0
- data/app/views/trade/admin/card_prepayments/_breadcrumb.html.erb +6 -0
- data/app/views/trade/admin/card_prepayments/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_prepayments/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/card_prepayments/_form.html.erb +3 -0
- data/app/views/trade/admin/card_prepayments/_index_tbody.html.erb +3 -0
- data/app/views/trade/admin/card_prepayments/_index_thead.html.erb +4 -0
- data/app/views/trade/admin/card_prepayments/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_prepayments/_show_table.html.erb +16 -0
- data/app/views/trade/admin/card_prepayments/index.html.erb +5 -0
- data/app/views/trade/admin/card_promotes/_breadcrumb.html.erb +6 -0
- data/app/views/trade/admin/card_promotes/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_promotes/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/card_promotes/_form.html.erb +4 -0
- data/app/views/trade/admin/card_promotes/_index_tbody.html.erb +5 -0
- data/app/views/trade/admin/card_promotes/_index_thead.html.erb +6 -0
- data/app/views/trade/admin/card_promotes/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_promotes/_show_table.html.erb +12 -0
- data/app/views/trade/admin/card_promotes/index.html.erb +5 -0
- data/app/views/trade/admin/card_templates/_advance_options.html.erb +1 -0
- data/app/views/trade/admin/card_templates/_card_template.json.jbuilder +7 -0
- data/app/views/trade/admin/card_templates/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/card_templates/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/card_templates/_form.html.erb +11 -0
- data/app/views/trade/admin/card_templates/_index_tbody.html.erb +14 -0
- data/app/views/trade/admin/card_templates/_index_thead.html.erb +10 -0
- data/app/views/trade/admin/card_templates/_index_tr.html.erb +25 -0
- data/app/views/trade/admin/card_templates/_item_form.html.erb +15 -0
- data/app/views/trade/admin/card_templates/_new_form.html.erb +4 -0
- data/app/views/trade/admin/card_templates/_show.json.jbuilder +1 -0
- data/app/views/trade/admin/card_templates/_show_table.html.erb +12 -0
- data/app/views/trade/admin/card_templates/advance_options.js.erb +3 -0
- data/app/views/trade/admin/card_templates/index.html.erb +5 -0
- data/app/views/trade/admin/card_templates/index.json.jbuilder +1 -0
- data/app/views/trade/admin/cards/_breadcrumb.html.erb +6 -0
- data/app/views/trade/admin/cards/_button.html.erb +3 -0
- data/app/views/trade/admin/cards/_card.json.jbuilder +10 -0
- data/app/views/trade/admin/cards/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/cards/_filter_form.html.erb +10 -0
- data/app/views/trade/admin/cards/_filter_table.html.erb +11 -0
- data/app/views/trade/admin/cards/_form.html.erb +4 -0
- data/app/views/trade/admin/cards/_index_tbody.html.erb +25 -0
- data/app/views/trade/admin/cards/_index_thead.html.erb +14 -0
- data/app/views/trade/admin/cards/_index_tr.html.erb +19 -0
- data/app/views/trade/admin/cards/_new_form.html.erb +5 -0
- data/app/views/trade/admin/cards/_show.json.jbuilder +1 -0
- data/app/views/trade/admin/cards/_show_table.html.erb +20 -0
- data/app/views/trade/admin/cards/index.html.erb +5 -0
- data/app/views/trade/admin/cards/index.json.jbuilder +1 -0
- data/app/views/trade/admin/{promote_buyers/show.html.erb → carts/_button.html.erb} +0 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_check.html.erb +0 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_index.html.erb +1 -3
- data/app/views/trade/admin/carts/_index_tbody.html.erb +6 -0
- data/app/views/trade/admin/carts/_index_thead.html.erb +7 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_new.html.erb +1 -1
- data/app/views/trade/admin/{cart_item_serves → carts}/_serve.html.erb +2 -2
- data/app/views/trade/admin/{cart_item_serves → carts}/_single.html.erb +0 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_single_table.html.erb +0 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_total.html.erb +0 -0
- data/app/views/trade/admin/{cart_item_serves → carts}/_total_table.html.erb +0 -0
- data/app/views/trade/admin/carts/index.html.erb +5 -0
- data/app/views/trade/admin/cash_givens/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/cash_givens/_filter_form.html.erb +5 -0
- data/app/views/trade/admin/cash_givens/_form.html.erb +4 -0
- data/app/views/trade/admin/cash_givens/_index_tbody.html.erb +17 -0
- data/app/views/trade/admin/cash_givens/_index_thead.html.erb +4 -0
- data/app/views/trade/admin/cash_givens/_new_form.html.erb +4 -0
- data/app/views/trade/admin/cash_givens/_show_table.html.erb +12 -0
- data/app/views/trade/admin/cash_givens/index.html.erb +5 -0
- data/app/views/trade/admin/cash_logs/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/cash_logs/_filter_form.html.erb +8 -0
- data/app/views/trade/admin/cash_logs/_form.html.erb +2 -0
- data/app/views/trade/admin/cash_logs/_index_tbody.html.erb +25 -0
- data/app/views/trade/admin/cash_logs/_index_thead.html.erb +11 -0
- data/app/views/trade/admin/cash_logs/_new_form.html.erb +4 -0
- data/app/views/trade/admin/cash_logs/_show_table.html.erb +20 -0
- data/app/views/trade/admin/cash_logs/index.html.erb +5 -0
- data/app/views/trade/admin/cashes/_button.html.erb +0 -0
- data/app/views/trade/admin/cashes/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/cashes/_filter_form.html.erb +5 -0
- data/app/views/trade/admin/cashes/_form.html.erb +3 -0
- data/app/views/trade/admin/cashes/_index_tbody.html.erb +18 -0
- data/app/views/trade/admin/cashes/_index_thead.html.erb +12 -0
- data/app/views/trade/admin/cashes/_new_form.html.erb +4 -0
- data/app/views/trade/admin/cashes/_show_tbody.html.erb +20 -0
- data/app/views/trade/admin/cashes/index.html.erb +5 -0
- data/app/views/trade/admin/goods/_form.html.erb +1 -1
- data/app/views/trade/admin/goods/_item.html.erb +1 -1
- data/app/views/trade/admin/goods/_new.html.erb +1 -1
- data/app/views/trade/admin/order_payments/_index_tbody.html.erb +6 -0
- data/app/views/trade/admin/order_payments/_index_thead.html.erb +6 -0
- data/app/views/trade/admin/order_payments/_index_tr.html.erb +4 -0
- data/app/views/trade/admin/order_payments/_new_form.html.erb +30 -0
- data/app/views/trade/admin/order_payments/_payment_orders.html.erb +2 -2
- data/app/views/trade/admin/order_payments/index.html.erb +12 -0
- data/app/views/trade/admin/orders/_addresses.html.erb +3 -3
- data/app/views/trade/admin/orders/_breadcrumb.html.erb +5 -0
- data/app/views/trade/admin/orders/_button.html.erb +0 -0
- data/app/views/trade/admin/orders/_edit_form.html.erb +3 -0
- data/app/views/trade/admin/orders/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/orders/_filter_table.html.erb +20 -0
- data/app/views/trade/admin/orders/_index_tbody.html.erb +16 -0
- data/app/views/trade/admin/orders/_index_thead.html.erb +8 -0
- data/app/views/trade/admin/orders/_index_tr.html.erb +10 -0
- data/app/views/trade/admin/orders/_invoice_addresses.html.erb +3 -3
- data/app/views/trade/admin/orders/_show/_breadcrumb.html.erb +6 -0
- data/app/views/trade/admin/orders/index.html.erb +2 -49
- data/app/views/trade/admin/orders/new.html.erb +1 -1
- data/app/{assets/javascripts/controllers → views}/trade/admin/orders/new.js +0 -0
- data/app/views/trade/admin/orders/payments.html.erb +6 -6
- data/app/views/trade/admin/orders/refund.turbo_stream.erb +3 -0
- data/app/views/trade/admin/orders/show.html.erb +12 -20
- data/app/views/trade/admin/payment_methods/_breadcrumb.html.erb +10 -0
- data/app/views/trade/admin/payment_methods/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/payment_methods/_filter_form.html.erb +12 -0
- data/app/views/trade/admin/payment_methods/_filter_table.html.erb +9 -0
- data/app/views/trade/admin/payment_methods/_form.html.erb +1 -2
- data/app/views/trade/admin/payment_methods/_index_tbody.html.erb +17 -0
- data/app/views/trade/admin/payment_methods/_index_thead.html.erb +7 -0
- data/app/views/trade/admin/payment_methods/_index_tr.html.erb +10 -0
- data/app/views/trade/admin/payment_methods/_new_form.html.erb +4 -0
- data/app/views/trade/admin/payment_methods/_unverified/_index_tbody.html.erb +37 -0
- data/app/views/trade/admin/payment_methods/index.html.erb +4 -25
- data/app/views/trade/admin/payment_methods/mine.html.erb +3 -3
- data/app/views/trade/admin/payment_methods/unverified.html.erb +4 -57
- data/app/views/trade/admin/payment_orders/_index.html.erb +5 -7
- data/app/views/trade/admin/payment_orders/_new.html.erb +5 -8
- data/app/views/trade/admin/payment_orders/_orders.html.erb +1 -3
- data/app/views/trade/admin/payment_orders/cancel.js.erb +2 -2
- data/app/views/trade/admin/payment_orders/create.js.erb +2 -2
- data/app/views/trade/admin/payment_orders/new.turbo_stream.erb +2 -0
- data/app/views/trade/admin/payment_orders/update.js.erb +2 -2
- data/app/views/trade/admin/payment_orders/update_fail.js.erb +2 -2
- data/app/views/trade/admin/payment_strategies/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/payment_strategies/_form.html.erb +2 -5
- data/app/views/trade/admin/payment_strategies/_index_tbody.html.erb +12 -0
- data/app/views/trade/admin/payment_strategies/_index_thead.html.erb +3 -0
- data/app/views/trade/admin/payment_strategies/_new_form.html.erb +4 -0
- data/app/views/trade/admin/payment_strategies/index.html.erb +4 -36
- data/app/views/trade/admin/payments/_breadcrumb.html.erb +5 -0
- data/app/views/trade/admin/payments/_button.html.erb +2 -0
- data/app/views/trade/admin/payments/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/payments/_filter_form.html.erb +13 -0
- data/app/views/trade/admin/payments/_filter_table.html.erb +29 -0
- data/app/views/trade/admin/payments/_form.html.erb +2 -3
- data/app/views/trade/admin/payments/_index_tbody.html.erb +24 -0
- data/app/views/trade/admin/payments/_index_thead.html.erb +15 -0
- data/app/views/trade/admin/payments/_index_tr.html.erb +17 -0
- data/app/views/trade/admin/payments/_new_form.html.erb +4 -0
- data/app/views/trade/admin/payments/dashboard.html.erb +0 -3
- data/app/views/trade/admin/payments/index.html.erb +2 -37
- data/app/views/trade/admin/payouts/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/payouts/_filter_form.html.erb +10 -0
- data/app/views/trade/admin/payouts/_form.html.erb +4 -0
- data/app/views/trade/admin/payouts/_index_tbody.html.erb +12 -0
- data/app/views/trade/admin/payouts/_index_thead.html.erb +11 -0
- data/app/views/trade/admin/payouts/_index_tr.html.erb +9 -0
- data/app/views/trade/admin/payouts/_new_form.html.erb +4 -0
- data/app/views/trade/admin/payouts/_show_table.html.erb +32 -0
- data/app/views/trade/admin/payouts/index.html.erb +5 -0
- data/app/views/trade/admin/promote_carts/_breadcrumb.html.erb +10 -0
- data/app/views/trade/admin/promote_carts/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/promote_carts/_filter_form.html.erb +9 -0
- data/app/views/trade/admin/promote_carts/_form.html.erb +9 -0
- data/app/views/trade/admin/promote_carts/_index_tbody.html.erb +3 -0
- data/app/views/trade/admin/promote_carts/_index_thead.html.erb +4 -0
- data/app/views/trade/admin/promote_carts/_index_tr.html.erb +10 -0
- data/app/views/trade/admin/promote_carts/_new_form.html.erb +4 -0
- data/app/views/trade/admin/{promote_buyers → promote_carts}/_promote_buyer.json.jbuilder +0 -0
- data/app/{assets/javascripts/controllers/trade/admin/promote_buyers → views/trade/admin/promote_carts}/edit.js +0 -0
- data/app/views/trade/admin/promote_carts/index.html.erb +5 -0
- data/app/views/trade/admin/{promote_buyers → promote_carts}/index.json.jbuilder +0 -0
- data/app/{assets/javascripts/controllers/trade/admin/promote_buyers → views/trade/admin/promote_carts}/new.js +0 -0
- data/app/views/trade/admin/promote_carts/show.json.jbuilder +1 -0
- data/app/views/trade/admin/promote_charges/_base_price_form.html.erb +1 -1
- data/app/views/trade/admin/promote_charges/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/promote_charges/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/promote_charges/_filter_form.html.erb +13 -0
- data/app/views/trade/admin/promote_charges/_form.html.erb +5 -7
- data/app/views/trade/admin/promote_charges/_index_tbody.html.erb +17 -0
- data/app/views/trade/admin/promote_charges/_index_thead.html.erb +12 -0
- data/app/views/trade/admin/promote_charges/_index_tr.html.erb +13 -0
- data/app/views/trade/admin/promote_charges/_new_form.html.erb +4 -0
- data/app/views/trade/admin/promote_charges/index.html.erb +2 -62
- data/app/views/trade/admin/promote_goods/_breadcrumb.html.erb +9 -0
- data/app/views/trade/admin/promote_goods/_button.html.erb +3 -0
- data/app/views/trade/admin/promote_goods/_filter_form.html.erb +10 -0
- data/app/views/trade/admin/promote_goods/_form.html.erb +7 -8
- data/app/views/trade/admin/promote_goods/_index_tbody.html.erb +10 -0
- data/app/views/trade/admin/promote_goods/_index_thead.html.erb +5 -0
- data/app/views/trade/admin/promote_goods/_index_tr.html.erb +16 -0
- data/app/views/trade/admin/promote_goods/_new_form.html.erb +4 -0
- data/app/views/trade/admin/promote_goods/goods.js.erb +1 -1
- data/app/views/trade/admin/promote_goods/index.html.erb +2 -58
- data/app/views/trade/admin/promotes/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/promotes/_filter_table.html.erb +11 -0
- data/app/views/trade/admin/promotes/_form.html.erb +3 -8
- data/app/views/trade/admin/promotes/_index_tbody.html.erb +18 -0
- data/app/views/trade/admin/promotes/_index_thead.html.erb +12 -0
- data/app/views/trade/admin/promotes/_index_tr.html.erb +22 -0
- data/app/views/trade/admin/promotes/_new_form.html.erb +4 -0
- data/app/views/trade/admin/promotes/_new_promote_charge.html.erb +1 -1
- data/app/views/trade/admin/promotes/_show_table.html.erb +4 -0
- data/app/views/trade/admin/promotes/index.html.erb +4 -78
- data/app/views/trade/admin/refunds/_breadcrumb.html.erb +6 -0
- data/app/views/trade/admin/refunds/_filter_form.html.erb +13 -0
- data/app/views/trade/admin/refunds/_index_tbody.html.erb +25 -0
- data/app/views/trade/admin/refunds/_index_thead.html.erb +12 -0
- data/app/views/trade/admin/refunds/_index_tr.html.erb +3 -0
- data/app/views/trade/admin/refunds/_logs_form.html.erb +33 -0
- data/app/views/trade/admin/refunds/_new.html.erb +8 -18
- data/app/views/trade/admin/refunds/confirm.turbo_stream.erb +3 -0
- data/app/views/trade/admin/refunds/deny.turbo_stream.erb +3 -0
- data/app/views/trade/admin/refunds/index.html.erb +4 -52
- data/app/views/trade/admin/refunds/logs.turbo_stream.erb +1 -0
- data/app/views/trade/admin/trade_items/_filter.html.erb +5 -5
- data/app/views/trade/admin/trade_items/_good_price.html.erb +5 -5
- data/app/views/trade/admin/trade_items/_order_price.html.erb +8 -8
- data/app/views/trade/admin/trade_items/_retail_price.html.erb +3 -3
- data/app/views/trade/admin/trade_items/_show/_breadcrumb.html.erb +7 -0
- data/app/views/trade/admin/trade_items/_single_price.html.erb +10 -10
- data/app/{assets/javascripts/controllers/trade/admin/cart_items → views/trade/admin/trade_items}/create.js +0 -0
- data/app/views/trade/admin/trade_items/index.html.erb +31 -42
- data/app/{assets/javascripts/controllers/trade/admin/cart_items → views/trade/admin/trade_items}/index.js +0 -0
- data/app/views/trade/admin/trade_items/only.html.erb +2 -2
- data/app/{assets/javascripts/controllers/trade/admin/cart_items → views/trade/admin/trade_items}/only.js +0 -0
- data/app/views/trade/admin/trade_items/show.html.erb +0 -0
- data/app/views/trade/admin/trade_promotes/_edit_form.html.erb +4 -0
- data/app/views/trade/admin/trade_promotes/{_filter.html.erb → _filter_form.html.erb} +2 -2
- data/app/views/trade/admin/trade_promotes/_form.html.erb +3 -6
- data/app/views/trade/admin/trade_promotes/_index_tbody.html.erb +2 -0
- data/app/views/trade/admin/trade_promotes/_index_thead.html.erb +3 -0
- data/app/views/trade/admin/trade_promotes/_new_form.html.erb +4 -0
- data/app/views/trade/admin/trade_promotes/_show_table.html.erb +8 -20
- data/app/views/trade/admin/trade_promotes/index.html.erb +3 -36
- data/app/views/trade/admin/{buyers → users}/index.html.erb +4 -4
- data/app/views/trade/admin/{buyers → users}/orders.html.erb +6 -6
- data/app/views/trade/admin/{buyers → users}/overdue.html.erb +2 -2
- data/app/views/trade/advances/index.html.erb +15 -0
- data/app/views/trade/card_templates/_card_template.json.jbuilder +9 -0
- data/app/views/trade/card_templates/_filter_form.html.erb +8 -0
- data/app/views/trade/card_templates/_show_table.html.erb +16 -0
- data/app/views/trade/card_templates/index.html.erb +16 -0
- data/app/views/trade/card_templates/index.json.jbuilder +1 -0
- data/app/views/trade/card_templates/show.json.jbuilder +1 -0
- data/app/views/trade/goods/_search.html.erb +3 -3
- data/app/views/trade/goods/taxon/_breadcrumb.html.erb +2 -2
- data/app/views/trade/my/advances/index.json.jbuilder +11 -0
- data/app/views/trade/my/advances/order.json.jbuilder +14 -0
- data/app/views/trade/my/card_logs/_wallet_log.json.jbuilder +1 -0
- data/app/views/trade/my/card_logs/index.html.erb +15 -0
- data/app/views/trade/my/card_logs/index.json.jbuilder +5 -0
- data/app/views/trade/my/cards/index.html.erb +45 -0
- data/app/views/trade/my/cards/new.html.erb +0 -0
- data/app/views/trade/my/cards/token.html.erb +11 -0
- data/app/views/trade/my/{trade_items → carts}/_additions.html.erb +0 -2
- data/app/views/trade/my/carts/_addresses/_index_table.html.erb +14 -0
- data/app/views/trade/my/carts/_addresses/_index_tbody.html.erb +5 -0
- data/app/views/trade/my/carts/_addresses/_index_tr.html.erb +13 -0
- data/app/views/trade/my/carts/_filter_form.html.erb +9 -0
- data/app/views/trade/my/carts/_form.html.erb +1 -1
- data/app/views/trade/my/carts/_show/_address.html.erb +18 -0
- data/app/views/trade/my/carts/_show/_tab_bar.html.erb +22 -0
- data/app/views/trade/my/carts/_show_table.html.erb +16 -28
- data/app/views/trade/my/carts/_show_thead.html.erb +6 -0
- data/app/views/trade/my/carts/_total_price.html.erb +44 -0
- data/app/views/trade/my/carts/_trade_item.html.erb +52 -0
- data/app/views/trade/my/carts/add.html.erb +23 -0
- data/app/views/trade/my/carts/add.turbo_stream.erb +3 -0
- data/app/views/trade/my/carts/addresses.html.erb +5 -0
- data/app/views/trade/my/carts/destroy.turbo_stream.erb +3 -0
- data/app/views/trade/my/carts/show.html+phone.erb +45 -25
- data/app/views/trade/my/carts/show.html.erb +25 -0
- data/app/views/trade/my/carts/update.turbo_stream.erb +9 -0
- data/app/views/trade/my/cash_logs/_cash_log.json.jbuilder +1 -0
- data/app/views/trade/my/cash_logs/index.json.jbuilder +4 -0
- data/app/views/trade/my/orders/_date_form.html.erb +2 -2
- data/app/views/trade/my/orders/_edit_form.html.erb +4 -0
- data/app/views/trade/my/orders/_edit_payment_type.html.erb +3 -12
- data/app/views/trade/my/orders/_form.html.erb +1 -4
- data/app/views/trade/my/orders/_payment_types/_show_table.html.erb +35 -0
- data/app/views/trade/my/orders/_show/_breadcrumb.html.erb +6 -0
- data/app/views/trade/my/orders/_success.html.erb +9 -0
- data/app/views/trade/my/orders/alipay_pay.json.jbuilder +1 -0
- data/app/views/trade/my/orders/create.turbo_stream.erb +3 -0
- data/app/views/trade/my/orders/edit_payment_type.html.erb +3 -0
- data/app/views/trade/my/orders/index.html+phone.erb +14 -11
- data/app/views/trade/my/orders/index.html.erb +15 -15
- data/app/views/trade/my/orders/new.html.erb +25 -36
- data/app/views/trade/my/orders/payment_types.html+phone.erb +51 -0
- data/app/views/trade/my/orders/payment_types.html.erb +5 -0
- data/app/views/trade/my/orders/refresh.turbo_stream.erb +3 -0
- data/app/views/trade/my/orders/show.html+phone.erb +2 -2
- data/app/views/trade/my/orders/show.html.erb +54 -97
- data/app/views/trade/my/orders/success.html.erb +2 -9
- data/app/views/trade/my/orders/wxpay_pay.html.erb +13 -0
- data/app/views/trade/my/orders/wxpay_pay_err.html.erb +5 -0
- data/app/views/trade/my/orders/wxpay_pc_pay.html.erb +24 -0
- data/app/views/trade/my/payment_methods/_button.html.erb +3 -0
- data/app/views/trade/my/payment_methods/_edit_form.html.erb +4 -0
- data/app/views/trade/my/payment_methods/{_item.html.erb → _index_tbody.html.erb} +3 -4
- data/app/views/trade/my/payment_methods/_index_thead.html.erb +4 -0
- data/app/views/trade/my/payment_methods/_new_form.html.erb +4 -0
- data/app/views/trade/my/payment_methods/index.html.erb +5 -1
- data/app/views/trade/my/payments/_edit_form.html.erb +4 -0
- data/app/views/trade/my/payments/_filter_form.html.erb +9 -0
- data/app/views/trade/my/payments/_form.html.erb +2 -0
- data/app/views/trade/my/payments/_index_tbody.html.erb +1 -0
- data/app/views/trade/my/payments/_index_thead.html.erb +2 -0
- data/app/views/trade/my/payments/_new_form.html.erb +4 -0
- data/app/views/trade/my/payments/_show_table.html.erb +4 -0
- data/app/views/trade/my/payments/create.turbo_stream.erb +3 -0
- data/app/views/trade/my/payments/destroy.turbo_stream.erb +3 -0
- data/app/views/trade/my/payments/index.html.erb +5 -0
- data/app/views/trade/my/payouts/_payout.json.jbuilder +11 -0
- data/app/views/trade/my/payouts/index.json.jbuilder +3 -0
- data/app/views/trade/my/payouts/list.json.jbuilder +2 -0
- data/app/views/trade/my/payouts/show.json.jbuilder +1 -0
- data/app/views/trade/my/shared/_cash.json.jbuilder +6 -0
- data/app/views/trade/my/trade_items/_show/_breadcrumb.html.erb +7 -0
- data/app/views/trade/my/trade_items/promote.html.erb +12 -0
- data/app/views/trade/my/trade_items/show.html.erb +0 -0
- data/app/views/trade/my/trade_items/toggle.turbo_stream.erb +3 -0
- data/app/views/trade/panel/exchange_rates/_edit_form.html.erb +4 -0
- data/app/views/trade/panel/exchange_rates/_filter_form.html.erb +9 -0
- data/app/views/trade/panel/exchange_rates/_form.html.erb +4 -0
- data/app/views/trade/panel/exchange_rates/_index_tbody.html.erb +3 -0
- data/app/views/trade/panel/exchange_rates/_index_thead.html.erb +4 -0
- data/app/views/trade/panel/exchange_rates/_new_form.html.erb +4 -0
- data/app/views/trade/panel/exchange_rates/_show_table.html.erb +12 -0
- data/app/views/trade/panel/exchange_rates/index.html.erb +5 -0
- data/config/locales/en.attributes.yml +35 -0
- data/config/locales/en.controller.yml +73 -0
- data/config/locales/en.yml +28 -44
- data/config/locales/zh.attributes.yml +78 -16
- data/config/locales/zh.controller.yml +53 -1
- data/config/locales/zh.enum.yml +44 -18
- data/config/locales/zh.help.yml +7 -7
- data/config/locales/zh.yml +24 -0
- data/config/routes.rb +164 -89
- data/lib/rails_trade/config.rb +0 -2
- data/lib/rails_trade/engine.rb +2 -1
- data/lib/rails_trade.rb +2 -10
- metadata +465 -322
- data/app/assets/javascripts/controllers/trade/admin/payment_methods/edit.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/payment_methods/new.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/payments/edit.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/payments/new.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/promote_charges/edit.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/promote_charges/new.js +0 -7
- data/app/assets/javascripts/controllers/trade/admin/promote_goods/edit.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/promote_goods/new.js +0 -17
- data/app/assets/javascripts/controllers/trade/admin/promotes/edit.js +0 -2
- data/app/assets/javascripts/controllers/trade/admin/promotes/new.js +0 -5
- data/app/assets/javascripts/controllers/trade/admin/refunds/index.js +0 -1
- data/app/assets/javascripts/controllers/trade/admin/refunds/new.js +0 -1
- data/app/assets/javascripts/controllers/trade/my/carts/show-phone-ready.js +0 -1
- data/app/assets/javascripts/controllers/trade/my/carts/show-ready.js +0 -28
- data/app/assets/javascripts/controllers/trade/my/orders/wait-phone.js +0 -8
- data/app/assets/javascripts/controllers/trade/my/trade_items/create.js +0 -2
- data/app/assets/stylesheets/controllers/trade/admin/promote_charges/index.css +0 -4
- data/app/assets/stylesheets/controllers/trade/admin/promotes/index.css +0 -4
- data/app/assets/stylesheets/controllers/trade/my/carts/show-phone.css +0 -1
- data/app/assets/stylesheets/controllers/trade/payments/wxpay_result.css +0 -57
- data/app/channels/paid_channel.rb +0 -7
- data/app/controllers/concerns/controller_order_types.rb +0 -89
- data/app/controllers/rails_trade/my_cart.rb +0 -16
- data/app/controllers/trade/admin/buyers_controller.rb +0 -37
- data/app/controllers/trade/admin/cart_serves_controller.rb +0 -66
- data/app/controllers/trade/admin/goods_controller.rb +0 -96
- data/app/controllers/trade/admin/produces_controller.rb +0 -66
- data/app/controllers/trade/admin/promote_buyers_controller.rb +0 -57
- data/app/controllers/trade/buyers_controller.rb +0 -8
- data/app/controllers/trade/my/order_items_controller.rb +0 -49
- data/app/models/cart.rb +0 -4
- data/app/models/order.rb +0 -4
- data/app/models/payment/alipay_payment.rb +0 -3
- data/app/models/payment/apple_payment.rb +0 -3
- data/app/models/payment/bank_payment.rb +0 -3
- data/app/models/payment/hand_payment.rb +0 -3
- data/app/models/payment/paypal_payment.rb +0 -3
- data/app/models/payment/stripe_payment.rb +0 -3
- data/app/models/payment/wxpay_payment.rb +0 -3
- data/app/models/payment.rb +0 -4
- data/app/models/payment_method/alipay_method.rb +0 -7
- data/app/models/payment_method/bank_method.rb +0 -7
- data/app/models/payment_method/stripe_method.rb +0 -3
- data/app/models/payment_method.rb +0 -3
- data/app/models/payment_order.rb +0 -3
- data/app/models/payment_reference.rb +0 -3
- data/app/models/payment_strategy.rb +0 -3
- data/app/models/payment_type.rb +0 -3
- data/app/models/promote.rb +0 -3
- data/app/models/promote_buyer.rb +0 -3
- data/app/models/promote_charge/cash_promote_charge.rb +0 -3
- data/app/models/promote_charge/discount_promote_charge.rb +0 -3
- data/app/models/promote_charge/final_promote_charge.rb +0 -3
- data/app/models/promote_charge/minus_promote_charge.rb +0 -3
- data/app/models/promote_charge/plus_promote_charge.rb +0 -3
- data/app/models/promote_charge.rb +0 -3
- data/app/models/promote_extra.rb +0 -3
- data/app/models/promote_good.rb +0 -3
- data/app/models/rails_trade/amount.rb +0 -44
- data/app/models/rails_trade/buyer.rb +0 -35
- data/app/models/rails_trade/cart.rb +0 -64
- data/app/models/rails_trade/good.rb +0 -71
- data/app/models/rails_trade/order.rb +0 -98
- data/app/models/rails_trade/ordering/payment.rb +0 -113
- data/app/models/rails_trade/ordering/refund.rb +0 -34
- data/app/models/rails_trade/payment/alipay_payment.rb +0 -15
- data/app/models/rails_trade/payment/apple_payment.rb +0 -7
- data/app/models/rails_trade/payment/bank_payment.rb +0 -13
- data/app/models/rails_trade/payment/hand_payment.rb +0 -8
- data/app/models/rails_trade/payment/paypal_payment.rb +0 -8
- data/app/models/rails_trade/payment/stripe_payment.rb +0 -9
- data/app/models/rails_trade/payment/wxpay_payment.rb +0 -13
- data/app/models/rails_trade/payment.rb +0 -134
- data/app/models/rails_trade/payment_method/stripe_method.rb +0 -60
- data/app/models/rails_trade/payment_method.rb +0 -67
- data/app/models/rails_trade/payment_order.rb +0 -108
- data/app/models/rails_trade/payment_reference.rb +0 -18
- data/app/models/rails_trade/payment_strategy.rb +0 -19
- data/app/models/rails_trade/payment_type/alipay.rb +0 -28
- data/app/models/rails_trade/payment_type/apple_pay.rb +0 -18
- data/app/models/rails_trade/payment_type/paypal.rb +0 -82
- data/app/models/rails_trade/payment_type/stripe.rb +0 -55
- data/app/models/rails_trade/payment_type/wxpay.rb +0 -55
- data/app/models/rails_trade/promote.rb +0 -78
- data/app/models/rails_trade/promote_buyer.rb +0 -27
- data/app/models/rails_trade/promote_charge/cash_promote_charge.rb +0 -12
- data/app/models/rails_trade/promote_charge/discount_promote_charge.rb +0 -17
- data/app/models/rails_trade/promote_charge/final_promote_charge.rb +0 -12
- data/app/models/rails_trade/promote_charge/minus_promote_charge.rb +0 -11
- data/app/models/rails_trade/promote_charge/plus_promote_charge.rb +0 -7
- data/app/models/rails_trade/promote_charge.rb +0 -84
- data/app/models/rails_trade/promote_extra.rb +0 -13
- data/app/models/rails_trade/promote_good.rb +0 -22
- data/app/models/rails_trade/refund/alipay_refund.rb +0 -33
- data/app/models/rails_trade/refund/bank_refund.rb +0 -5
- data/app/models/rails_trade/refund/hand_refund.rb +0 -5
- data/app/models/rails_trade/refund/paypal_refund.rb +0 -32
- data/app/models/rails_trade/refund/stripe_refund.rb +0 -26
- data/app/models/rails_trade/refund/wxpay_refund.rb +0 -48
- data/app/models/rails_trade/refund.rb +0 -74
- data/app/models/rails_trade/sell.rb +0 -24
- data/app/models/rails_trade/trade_item.rb +0 -153
- data/app/models/rails_trade/trade_promote.rb +0 -92
- data/app/models/rails_trade/user.rb +0 -9
- data/app/models/refund/alipay_refund.rb +0 -3
- data/app/models/refund/bank_refund.rb +0 -3
- data/app/models/refund/hand_refund.rb +0 -3
- data/app/models/refund/paypal_refund.rb +0 -3
- data/app/models/refund/stripe_refund.rb +0 -3
- data/app/models/refund/wxpay_refund.rb +0 -3
- data/app/models/refund.rb +0 -3
- data/app/models/trade_item.rb +0 -3
- data/app/models/trade_promote.rb +0 -3
- data/app/views/application/_trade_nav.html.erb +0 -16
- data/app/views/trade/admin/buyers/_form.html.erb +0 -17
- data/app/views/trade/admin/buyers/_menu.html.erb +0 -5
- data/app/views/trade/admin/buyers/_search_form.html.erb +0 -11
- data/app/views/trade/admin/buyers/edit.html.erb +0 -6
- data/app/views/trade/admin/buyers/new.html.erb +0 -5
- data/app/views/trade/admin/buyers/show.html.erb +0 -4
- data/app/views/trade/admin/cart_item_serves/add.js.erb +0 -47
- data/app/views/trade/admin/cart_item_serves/create.js.erb +0 -3
- data/app/views/trade/admin/cart_item_serves/destroy.js.erb +0 -50
- data/app/views/trade/admin/cart_item_serves/index.js.erb +0 -50
- data/app/views/trade/admin/cart_item_serves/new.js.erb +0 -5
- data/app/views/trade/admin/cart_item_serves/single.js.erb +0 -55
- data/app/views/trade/admin/cart_item_serves/total.js.erb +0 -55
- data/app/views/trade/admin/order_payments/_index.html.erb +0 -44
- data/app/views/trade/admin/order_payments/_new.html.erb +0 -44
- data/app/views/trade/admin/order_payments/create.js.erb +0 -2
- data/app/views/trade/admin/order_payments/destroy.js.erb +0 -2
- data/app/views/trade/admin/order_payments/index.js.erb +0 -8
- data/app/views/trade/admin/order_payments/new.js.erb +0 -8
- data/app/views/trade/admin/orders/_filter.html.erb +0 -26
- data/app/views/trade/admin/orders/_form.html.erb +0 -4
- data/app/views/trade/admin/orders/refresh.js.erb +0 -7
- data/app/views/trade/admin/payment_methods/_edit.html.erb +0 -6
- data/app/views/trade/admin/payment_methods/_filter.html.erb +0 -18
- data/app/views/trade/admin/payment_methods/_index_layout.html.erb +0 -12
- data/app/views/trade/admin/payment_methods/_new.html.erb +0 -13
- data/app/views/trade/admin/payment_methods/_payment_method.html.erb +0 -24
- data/app/views/trade/admin/payment_methods/create.js.erb +0 -2
- data/app/views/trade/admin/payment_methods/destroy.js.erb +0 -1
- data/app/views/trade/admin/payment_methods/edit.html.erb +0 -15
- data/app/views/trade/admin/payment_methods/edit.js.erb +0 -8
- data/app/views/trade/admin/payment_methods/new.html.erb +0 -15
- data/app/views/trade/admin/payment_methods/new.js.erb +0 -7
- data/app/views/trade/admin/payment_methods/update.js.erb +0 -2
- data/app/views/trade/admin/payment_orders/new.js.erb +0 -6
- data/app/views/trade/admin/payment_strategies/edit.html.erb +0 -13
- data/app/views/trade/admin/payment_strategies/new.html.erb +0 -13
- data/app/views/trade/admin/payments/_edit.html.erb +0 -12
- data/app/views/trade/admin/payments/_filter.html.erb +0 -40
- data/app/views/trade/admin/payments/_item.html.erb +0 -41
- data/app/views/trade/admin/payments/_new.html.erb +0 -12
- data/app/views/trade/admin/payments/edit.html.erb +0 -13
- data/app/views/trade/admin/payments/edit.js.erb +0 -3
- data/app/views/trade/admin/payments/new.html.erb +0 -13
- data/app/views/trade/admin/payments/new.js.erb +0 -3
- data/app/views/trade/admin/payments/show.html.erb +0 -4
- data/app/views/trade/admin/promote_buyers/_filter.html.erb +0 -7
- data/app/views/trade/admin/promote_buyers/_form.html.erb +0 -17
- data/app/views/trade/admin/promote_buyers/edit.html.erb +0 -14
- data/app/views/trade/admin/promote_buyers/edit.js.erb +0 -3
- data/app/views/trade/admin/promote_buyers/index.html.erb +0 -52
- data/app/views/trade/admin/promote_buyers/new.html.erb +0 -13
- data/app/views/trade/admin/promote_buyers/new.js.erb +0 -3
- data/app/views/trade/admin/promote_buyers/show.json.jbuilder +0 -1
- data/app/views/trade/admin/promote_charges/_edit.html.erb +0 -13
- data/app/views/trade/admin/promote_charges/_filter.html.erb +0 -11
- data/app/views/trade/admin/promote_charges/_new.html.erb +0 -13
- data/app/views/trade/admin/promote_goods/_filter.html.erb +0 -8
- data/app/views/trade/admin/promotes/_edit.html.erb +0 -12
- data/app/views/trade/admin/promotes/_filter.html.erb +0 -9
- data/app/views/trade/admin/promotes/_new.html.erb +0 -12
- data/app/views/trade/admin/promotes/create.js.erb +0 -2
- data/app/views/trade/admin/refunds/_filter.html.erb +0 -11
- data/app/views/trade/admin/refunds/_form.html.erb +0 -17
- data/app/views/trade/admin/refunds/_logs_table.html.erb +0 -33
- data/app/views/trade/admin/refunds/edit.html.erb +0 -6
- data/app/views/trade/admin/refunds/logs.js.erb +0 -8
- data/app/views/trade/admin/refunds/new.html.erb +0 -5
- data/app/views/trade/admin/refunds/new.js.erb +0 -8
- data/app/views/trade/admin/refunds/show.html.erb +0 -4
- data/app/views/trade/admin/trade_items/destroy.js.erb +0 -1
- data/app/views/trade/admin/trade_items/update.js.erb +0 -11
- data/app/views/trade/admin/trade_promotes/edit.html.erb +0 -9
- data/app/views/trade/admin/trade_promotes/edit.js.erb +0 -3
- data/app/views/trade/admin/trade_promotes/new.html.erb +0 -9
- data/app/views/trade/admin/trade_promotes/new.js.erb +0 -3
- data/app/views/trade/admin/trade_promotes/show.html.erb +0 -7
- data/app/views/trade/admin/trade_promotes/show.js.erb +0 -3
- data/app/views/trade/admin/trade_promotes/update.js.erb +0 -1
- data/app/views/trade/buyers/_show.html.erb +0 -7
- data/app/views/trade/buyers/show.js.erb +0 -1
- data/app/views/trade/my/carts/_filter.html.erb +0 -7
- data/app/views/trade/my/carts/edit.html.erb +0 -9
- data/app/views/trade/my/carts/edit.js.erb +0 -3
- data/app/views/trade/my/carts/index.html.erb +0 -47
- data/app/views/trade/my/carts/new.html.erb +0 -9
- data/app/views/trade/my/carts/new.js.erb +0 -3
- data/app/views/trade/my/order_items/_form.html.erb +0 -17
- data/app/views/trade/my/order_items/edit.html.erb +0 -6
- data/app/views/trade/my/order_items/index.html.erb +0 -25
- data/app/views/trade/my/order_items/new.html.erb +0 -5
- data/app/views/trade/my/order_items/show.html.erb +0 -8
- data/app/views/trade/my/orders/_edit.html.erb +0 -10
- data/app/views/trade/my/orders/destroy.js.erb +0 -1
- data/app/views/trade/my/orders/edit.js.erb +0 -4
- data/app/views/trade/my/orders/edit_payment_type.js.erb +0 -4
- data/app/views/trade/my/orders/refresh.js.erb +0 -7
- data/app/views/trade/my/orders/update.js.erb +0 -3
- data/app/views/trade/my/orders/wxpay_pay.js.erb +0 -16
- data/app/views/trade/my/orders/wxpay_pay_err.js.erb +0 -5
- data/app/views/trade/my/payment_methods/_edit.html.erb +0 -13
- data/app/views/trade/my/payment_methods/_index.html.erb +0 -25
- data/app/views/trade/my/payment_methods/_new.html.erb +0 -13
- data/app/views/trade/my/payment_methods/create.js.erb +0 -3
- data/app/views/trade/my/payment_methods/destroy.js.erb +0 -1
- data/app/views/trade/my/payment_methods/edit.js.erb +0 -8
- data/app/views/trade/my/payment_methods/index.js.erb +0 -1
- data/app/views/trade/my/payment_methods/new.js.erb +0 -8
- data/app/views/trade/my/payment_methods/show.html.erb +0 -4
- data/app/views/trade/my/payment_methods/update.js.erb +0 -2
- data/app/views/trade/my/trade_items/_cart_item.js.erb +0 -2
- data/app/views/trade/my/trade_items/_single_price.html.erb +0 -6
- data/app/views/trade/my/trade_items/_total_price.html.erb +0 -8
- data/app/views/trade/my/trade_items/_trade_items.html.erb +0 -68
- data/app/views/trade/my/trade_items/create.html.erb +0 -1
- data/app/views/trade/my/trade_items/destroy.js.erb +0 -1
- data/app/views/trade/my/trade_items/update.js.erb +0 -1
- data/app/views/trade/my/users/_form.html.erb +0 -17
- data/app/views/trade/my/users/edit.html.erb +0 -44
- data/app/views/trade/my/users/show.html.erb +0 -18
- data/lib/rails_trade/apple_pay.rb +0 -32
- data/lib/rails_trade/version.rb +0 -3
@@ -0,0 +1,70 @@
|
|
1
|
+
module Trade
|
2
|
+
module Model::Refund
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :type, :string
|
7
|
+
attribute :currency, :string, default: RailsTrade.config.default_currency
|
8
|
+
attribute :total_amount, :decimal
|
9
|
+
attribute :buyer_identifier, :string
|
10
|
+
attribute :comment, :string
|
11
|
+
attribute :refunded_at, :datetime
|
12
|
+
attribute :reason, :string
|
13
|
+
attribute :refund_uuid, :string
|
14
|
+
attribute :response, :json
|
15
|
+
|
16
|
+
enum state: {
|
17
|
+
init: 'init',
|
18
|
+
completed: 'completed',
|
19
|
+
failed: 'failed',
|
20
|
+
denied: 'denied'
|
21
|
+
}, _default: 'init'
|
22
|
+
|
23
|
+
belongs_to :organ, class_name: 'Org::Organ', optional: true
|
24
|
+
belongs_to :operator, class_name: 'Org::Member', optional: true
|
25
|
+
belongs_to :order, inverse_of: :refunds, optional: true
|
26
|
+
belongs_to :payment
|
27
|
+
|
28
|
+
validates :payment_id, uniqueness: { scope: :order_id }
|
29
|
+
#validate :valid_total_amount
|
30
|
+
|
31
|
+
before_validation do
|
32
|
+
self.refund_uuid ||= UidHelper.nsec_uuid('RD') if new_record?
|
33
|
+
self.organ_id = payment.organ_id
|
34
|
+
end
|
35
|
+
after_save :sync_refund, if: -> { completed? && state_before_last_save == 'init' }
|
36
|
+
after_save :deny_refund, if: -> { denied? && state_before_last_save == 'init' }
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_total_amount
|
40
|
+
if self.new_record? && total_amount > payment.total_amount
|
41
|
+
self.errors.add :total_amount, 'more then order received amount!'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def currency_symbol
|
46
|
+
Money::Currency.new(self.currency).symbol
|
47
|
+
end
|
48
|
+
|
49
|
+
def sync_refund
|
50
|
+
payment.total_amount -= total_amount
|
51
|
+
payment.refunded_amount = total_amount
|
52
|
+
payment.save
|
53
|
+
|
54
|
+
if order
|
55
|
+
order.payment_status = 'refunded'
|
56
|
+
order.save
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def deny_refund
|
61
|
+
order.payment_status = 'denied'
|
62
|
+
order.save
|
63
|
+
end
|
64
|
+
|
65
|
+
def can_refund?
|
66
|
+
self.init? && ['all_paid', 'part_paid', 'refunding'].include?(order.payment_status)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Trade
|
2
|
+
module Model::Sell
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include Model::Good
|
7
|
+
|
8
|
+
belongs_to :buyer, optional: true
|
9
|
+
|
10
|
+
has_one :trade_item, as: :good, dependent: :nullify
|
11
|
+
has_one :order, ->(o){ where(buyer_type: o.buyer.class.name, buyer_id: o.buyer.id) }, through: :order_item
|
12
|
+
end
|
13
|
+
|
14
|
+
def update_order
|
15
|
+
order_item.update amount: self.price
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_order
|
19
|
+
return @get_order if defined?(@get_order)
|
20
|
+
@get_order = self.order || generate_order!(buyer: self.buyer, number: 1)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
module Trade
|
2
|
+
module Model::TradeItem
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :status, :string
|
7
|
+
attribute :myself, :boolean, default: true, comment: '是否后台协助添加'
|
8
|
+
attribute :starred, :boolean, default: false, comment: '收藏'
|
9
|
+
attribute :good_name, :string
|
10
|
+
attribute :number, :integer, default: 1
|
11
|
+
attribute :weight, :decimal, default: 0, comment: '重量'
|
12
|
+
attribute :unit, :string, comment: '单位'
|
13
|
+
attribute :single_price, :decimal, default: 0, comment: '一份产品的价格'
|
14
|
+
attribute :retail_price, :decimal, default: 0, comment: '单个商品零售价(商品原价 + 服务价)'
|
15
|
+
attribute :original_amount, :decimal, default: 0, comment: '合计份数之后的价格,商品原价'
|
16
|
+
attribute :additional_amount, :decimal, default: 0, comment: '附加服务价格汇总'
|
17
|
+
attribute :reduced_amount, :decimal, default: 0, comment: '已优惠的价格'
|
18
|
+
attribute :wholesale_price, :decimal, default: 0, comment: '多个商品批发价'
|
19
|
+
attribute :amount, :decimal, default: 0
|
20
|
+
attribute :note, :string
|
21
|
+
attribute :advance_amount, :decimal, default: 0
|
22
|
+
attribute :extra, :json, default: {}
|
23
|
+
|
24
|
+
belongs_to :user, class_name: 'Auth::User'
|
25
|
+
belongs_to :good, polymorphic: true
|
26
|
+
belongs_to :cart, counter_cache: true
|
27
|
+
belongs_to :order, inverse_of: :trade_items, counter_cache: true, optional: true
|
28
|
+
belongs_to :address, optional: true
|
29
|
+
belongs_to :produce_plan, optional: true # 产品对应批次号
|
30
|
+
has_many :trade_promotes, inverse_of: :trade_item, autosave: true, dependent: :destroy
|
31
|
+
#has_many :organs 用于对接供应商
|
32
|
+
|
33
|
+
scope :valid, -> { where(status: 'init', myself: true) }
|
34
|
+
scope :starred, -> { where(status: 'init', starred: true) }
|
35
|
+
default_scope -> { order(id: :asc) }
|
36
|
+
|
37
|
+
enum status: {
|
38
|
+
init: 'init',
|
39
|
+
checked: 'checked',
|
40
|
+
ordered: 'ordered',
|
41
|
+
paid: 'paid',
|
42
|
+
packaged: 'packaged',
|
43
|
+
done: 'done',
|
44
|
+
canceled: 'canceled'
|
45
|
+
}, _default: 'init'
|
46
|
+
|
47
|
+
after_initialize if: :new_record? do
|
48
|
+
if good
|
49
|
+
self.good_name = good.name
|
50
|
+
self.single_price = good.price
|
51
|
+
self.advance_amount = good.advance_price
|
52
|
+
self.produce_plan_id = good.product_plan&.produce_plan_id if good.respond_to? :product_plan_id
|
53
|
+
end
|
54
|
+
if cart
|
55
|
+
self.user_id = cart.user_id
|
56
|
+
self.member_id = cart.member_id if cart.respond_to?(:member_id) && respond_to?(:member_id)
|
57
|
+
end
|
58
|
+
self.original_amount = single_price * number
|
59
|
+
self.amount = original_amount
|
60
|
+
end
|
61
|
+
before_save :recompute_amount, if: -> { (changes.keys & ['number']).present? }
|
62
|
+
before_save :compute_promote, if: -> { original_amount_changed? }
|
63
|
+
after_save :sync_changed_amount, if: -> {
|
64
|
+
(saved_changes.keys & ['original_amount', 'additional_amount', 'reduced_amount', 'status']).present? && ['init', 'checked'].include?(status)
|
65
|
+
}
|
66
|
+
after_destroy_commit :sync_changed_amount
|
67
|
+
after_commit :sync_cart_charges, if: -> { number_changed? }, on: [:create, :update]
|
68
|
+
end
|
69
|
+
|
70
|
+
def weight_str
|
71
|
+
if weight > 0
|
72
|
+
"#{weight} #{unit}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def original_quantity
|
77
|
+
good.unified_quantity * self.number
|
78
|
+
end
|
79
|
+
|
80
|
+
# 批发价和零售价之间的差价,即批发折扣
|
81
|
+
def discount_price
|
82
|
+
wholesale_price - (retail_price * number)
|
83
|
+
end
|
84
|
+
|
85
|
+
def recompute_amount
|
86
|
+
self.original_amount = single_price * number
|
87
|
+
self.amount = original_amount + additional_amount + reduced_amount
|
88
|
+
end
|
89
|
+
|
90
|
+
def check
|
91
|
+
self.status = 'checked'
|
92
|
+
self.save
|
93
|
+
self
|
94
|
+
end
|
95
|
+
|
96
|
+
def uncheck
|
97
|
+
self.status = 'init'
|
98
|
+
self.save
|
99
|
+
self
|
100
|
+
end
|
101
|
+
|
102
|
+
# todo remove
|
103
|
+
def sync_from_cart
|
104
|
+
cart.trade_items.checked.default_where(myself: myself).update_all(trade_type: self.class.name, trade_id: self.id, address_id: self.address_id)
|
105
|
+
cart.trade_promotes.update_all(trade_type: self.class.name, trade_id: self.id)
|
106
|
+
|
107
|
+
self.compute_amount
|
108
|
+
self.save
|
109
|
+
end
|
110
|
+
|
111
|
+
def compute_promote
|
112
|
+
good.valid_promote_goods.map do |promote_good|
|
113
|
+
value = metering_attributes.fetch(promote_good.promote.metering)
|
114
|
+
promote_charge = promote_good.promote.compute_charge(value, **extra)
|
115
|
+
next unless promote_charge
|
116
|
+
if promote_good.promote.single?
|
117
|
+
tp = self.trade_promotes.find(&->(i){ i.promote_good_id == promote_good.id }) || trade_promotes.build(promote_good_id: promote_good.id)
|
118
|
+
else
|
119
|
+
tp = order.trade_promotes.find(&->(i){ i.promote_good_id == promote_good.id }) || order.trade_promotes.build(promote_good_id: promote_good.id)
|
120
|
+
end
|
121
|
+
tp.promote_charge_id = promote_charge.id
|
122
|
+
tp.compute_amount
|
123
|
+
end
|
124
|
+
|
125
|
+
cart.promote_carts.each do |promote_cart|
|
126
|
+
value = metering_attributes.fetch(promote_cart.promote.metering)
|
127
|
+
promote_charge = promote_cart.promote.compute_charge(value, **extra)
|
128
|
+
next unless promote_charge
|
129
|
+
if promote_good.promote.single?
|
130
|
+
tp = self.trade_promotes.find_or_initialize_by(promote_cart_id: promote_cart.id, promote_good_id: promote_cart.promote_good_id)
|
131
|
+
else
|
132
|
+
tp = trade.trade_promotes.find_or_initialize_by(promote_cart_id: promote_cart.id, promote_good_id: promote_cart.promote_good_id)
|
133
|
+
end
|
134
|
+
tp.promote_charge_id = promote_charge.id
|
135
|
+
tp.compute_amount
|
136
|
+
end
|
137
|
+
|
138
|
+
sum_amount
|
139
|
+
end
|
140
|
+
|
141
|
+
def sum_amount
|
142
|
+
self.additional_amount = trade_promotes.select(&->(o){ o.amount >= 0 }).sum(&:amount)
|
143
|
+
self.reduced_amount = trade_promotes.select(&->(o){ o.amount < 0 }).sum(&:amount) # 促销价格
|
144
|
+
|
145
|
+
self.retail_price = single_price + additional_amount
|
146
|
+
self.wholesale_price = original_amount + additional_amount
|
147
|
+
|
148
|
+
self.amount = original_amount + additional_amount + reduced_amount # 最终价格
|
149
|
+
self.changes
|
150
|
+
end
|
151
|
+
|
152
|
+
def sync_changed_amount
|
153
|
+
if destroyed? || (init? && status_before_last_save == 'checked')
|
154
|
+
changed_amount = -amount
|
155
|
+
elsif checked? && ['init', nil].include?(status_before_last_save)
|
156
|
+
changed_amount = amount
|
157
|
+
elsif checked? && saved_change_to_amount
|
158
|
+
changed_amount = amount - amount_before_last_save.to_d
|
159
|
+
else
|
160
|
+
return
|
161
|
+
end
|
162
|
+
|
163
|
+
if ['init', 'checked'].include?(status)
|
164
|
+
cart.reload
|
165
|
+
cart.item_amount += changed_amount
|
166
|
+
cart.valid_item_amount
|
167
|
+
cart.save!
|
168
|
+
else
|
169
|
+
order.reload
|
170
|
+
order.item_amount += changed_amount
|
171
|
+
order.valid_item_amount
|
172
|
+
order.save!
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def reset_amount
|
177
|
+
self.additional_amount = trade_promotes.default_where('amount-gte': 0).sum(:amount)
|
178
|
+
self.reduced_amount = trade_promotes.default_where('amount-lt': 0).sum(:amount)
|
179
|
+
self.amount = original_amount + additional_amount + reduced_amount
|
180
|
+
self.valid?
|
181
|
+
self.changes
|
182
|
+
end
|
183
|
+
|
184
|
+
def reset_amount!(*args)
|
185
|
+
self.reset_amount
|
186
|
+
self.save(*args)
|
187
|
+
end
|
188
|
+
|
189
|
+
def valid_promote_buyers(buyer)
|
190
|
+
ids = (available_promote_ids & buyer.all_promote_ids) - buyer.promote_buyers.pluck(:promote_id)
|
191
|
+
Promote.where(id: ids)
|
192
|
+
end
|
193
|
+
|
194
|
+
def metering_attributes
|
195
|
+
attributes.slice 'quantity', 'original_amount', 'number'
|
196
|
+
end
|
197
|
+
|
198
|
+
def confirm_ordered!
|
199
|
+
self.good.order_done
|
200
|
+
end
|
201
|
+
|
202
|
+
def confirm_paid!
|
203
|
+
self.update status: 'paid'
|
204
|
+
self.good.order_paid(self)
|
205
|
+
end
|
206
|
+
|
207
|
+
def confirm_part_paid!
|
208
|
+
end
|
209
|
+
|
210
|
+
def confirm_refund!
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Trade
|
2
|
+
module Model::TradePromote
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
attribute :sequence, :integer
|
7
|
+
attribute :original_amount, :decimal, comment: '初始价格'
|
8
|
+
attribute :based_amount, :decimal, default: 0, comment: '基于此价格计算,默认为 trade_item 的 amount,与sequence有关'
|
9
|
+
attribute :computed_amount, :decimal, default: 0, comment: '计算出的价格'
|
10
|
+
attribute :amount, :decimal, default: 0, comment: '默认等于 computed_amount,如果客服人员修改过价格后,则 amount 会发生变化'
|
11
|
+
attribute :note, :string, comment: '备注'
|
12
|
+
attribute :edited, :boolean, default: false, comment: '是否被客服改过价'
|
13
|
+
attribute :promote_name, :string
|
14
|
+
|
15
|
+
belongs_to :cart
|
16
|
+
belongs_to :order, inverse_of: :trade_promotes, optional: true
|
17
|
+
belongs_to :trade_item, optional: true
|
18
|
+
belongs_to :promote
|
19
|
+
belongs_to :promote_charge
|
20
|
+
belongs_to :promote_good
|
21
|
+
belongs_to :promote_cart, counter_cache: true, optional: true
|
22
|
+
|
23
|
+
enum status: {
|
24
|
+
init: 'init',
|
25
|
+
checked: 'checked',
|
26
|
+
ordered: 'ordered'
|
27
|
+
}, _default: 'init'
|
28
|
+
|
29
|
+
validates :promote_id, uniqueness: { scope: [:cart_id, :trade_item_id] }
|
30
|
+
validates :amount, presence: true
|
31
|
+
|
32
|
+
after_initialize if: :new_record? do
|
33
|
+
if trade_item
|
34
|
+
self.cart = trade_item.cart
|
35
|
+
self.order = trade_item.order
|
36
|
+
end
|
37
|
+
if self.promote_good
|
38
|
+
self.promote_id = self.promote_good.promote_id
|
39
|
+
end
|
40
|
+
self.sequence = self.promote.sequence
|
41
|
+
end
|
42
|
+
after_create_commit :check_promote_cart
|
43
|
+
end
|
44
|
+
|
45
|
+
def compute_amount
|
46
|
+
if trade_item
|
47
|
+
value = trade_item.metering_attributes.fetch(promote.metering, 0)
|
48
|
+
added_amount = trade_item.trade_promotes.select { |cp| cp.promote.sequence < self.promote.sequence }.sum(&->(o){ o.send(promote.metering) })
|
49
|
+
|
50
|
+
self.based_amount = value + added_amount
|
51
|
+
else
|
52
|
+
value = trade.metering_attributes.fetch(promote.metering, 0)
|
53
|
+
added_amount = trade.trade_promotes.select { |cp| cp.promote.sequence < self.promote.sequence }.sum(&->(o){ o.send(promote.metering) })
|
54
|
+
|
55
|
+
self.based_amount = value + added_amount
|
56
|
+
end
|
57
|
+
|
58
|
+
self.computed_amount = self.promote_charge.final_price(based_amount)
|
59
|
+
self.amount = computed_amount unless edited?
|
60
|
+
self
|
61
|
+
end
|
62
|
+
|
63
|
+
def check_promote_cart
|
64
|
+
return unless promote_cart
|
65
|
+
self.promote_cart.update state: 'used'
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# payment_id
|
2
|
+
# payment_type
|
3
|
+
# amount
|
4
|
+
# received_amount
|
5
|
+
module Trade
|
6
|
+
module Ordering::Payment
|
7
|
+
|
8
|
+
def can_pay?
|
9
|
+
self.payment_status != 'all_paid'
|
10
|
+
end
|
11
|
+
|
12
|
+
def unreceived_amount
|
13
|
+
self.amount.to_d - self.received_amount.to_d
|
14
|
+
end
|
15
|
+
|
16
|
+
def init_received_amount
|
17
|
+
self.payment_orders.confirmed.sum(:check_amount)
|
18
|
+
end
|
19
|
+
|
20
|
+
def pending_payments
|
21
|
+
Payment.where.not(id: self.payment_orders.pluck(:payment_id)).where(payment_method_id: self.cart.payment_method_ids, state: ['init', 'part_checked'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def exists_payments
|
25
|
+
Payment.where.not(id: self.payment_orders.pluck(:payment_id)).exists?(payment_method_id: self.cart.payment_method_ids, state: ['init', 'part_checked'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def confirm_paid!
|
29
|
+
self.expire_at = nil
|
30
|
+
self.trade_items.each(&:confirm_paid!)
|
31
|
+
send_notice
|
32
|
+
end
|
33
|
+
|
34
|
+
def confirm_part_paid!
|
35
|
+
self.expire_at = nil
|
36
|
+
self.trade_items.each(&:confirm_part_paid!)
|
37
|
+
end
|
38
|
+
|
39
|
+
def change_to_paid!(type:, payment_uuid:, params: {})
|
40
|
+
payment = self.payments.find_by(type: type, payment_uuid: payment_uuid)
|
41
|
+
|
42
|
+
if payment
|
43
|
+
self.check_state!
|
44
|
+
payment
|
45
|
+
else
|
46
|
+
payment = self.payments.build(type: type, payment_uuid: payment_uuid)
|
47
|
+
payment.organ_id = organ_id
|
48
|
+
payment.assign_detail params
|
49
|
+
|
50
|
+
payment_order = self.payment_orders.find { |i| i.id.nil? }
|
51
|
+
payment_order.check_amount = payment.total_amount
|
52
|
+
|
53
|
+
begin
|
54
|
+
self.class.transaction do
|
55
|
+
payment_order.confirm!
|
56
|
+
payment.save!
|
57
|
+
self.save!
|
58
|
+
end
|
59
|
+
rescue ActiveRecord::RecordInvalid => e
|
60
|
+
payment.errors.add :base, 'can not save'
|
61
|
+
logger.error "#{payment.errors.full_messages.join(', ')}"
|
62
|
+
raise e
|
63
|
+
end
|
64
|
+
payment
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def send_notice
|
69
|
+
broadcast_action_to self, action: :update, target: 'order_result', partial: 'trade/my/orders/success'
|
70
|
+
end
|
71
|
+
|
72
|
+
def payment_result(payment_kind: payment_type)
|
73
|
+
if self.payment_status == 'all_paid'
|
74
|
+
return self
|
75
|
+
end
|
76
|
+
|
77
|
+
if self.amount == 0
|
78
|
+
self.received_amount = self.amount
|
79
|
+
self.check_state!
|
80
|
+
end
|
81
|
+
|
82
|
+
if payment_kind.present?
|
83
|
+
begin
|
84
|
+
self.send payment_kind.to_s + '_result'
|
85
|
+
rescue NoMethodError
|
86
|
+
self
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
self
|
91
|
+
end
|
92
|
+
|
93
|
+
def check_state
|
94
|
+
if self.received_amount.to_d >= self.amount
|
95
|
+
self.payment_status = 'all_paid'
|
96
|
+
self.confirm_paid!
|
97
|
+
elsif self.received_amount.to_d > 0 && self.received_amount.to_d < self.amount
|
98
|
+
self.payment_status = 'part_paid'
|
99
|
+
self.confirm_part_paid!
|
100
|
+
elsif self.received_amount.to_d <= 0
|
101
|
+
self.payment_status = 'unpaid'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def check_state!
|
106
|
+
self.received_amount = init_received_amount
|
107
|
+
self.check_state
|
108
|
+
self.save!
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|