order_base_detail.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # encoding:utf-8
  2. class OrderBaseDetail < ActiveRecord::Base
  3. has_paper_trail
  4. self.table_name = "order_base_details"
  5. validates :order_no,:order_dt_id,:product_id, presence: true
  6. belongs_to :order, :foreign_key => :order_id
  7. attr_accessor :get_order_state
  8. def get_order_state(x)
  9. case x
  10. when "unpay"
  11. return "未支付"
  12. when "closed"
  13. return "已关闭"
  14. when "unconfirmed"
  15. return "待确认"
  16. when "processing"
  17. return "处理中"
  18. when "complete"
  19. return "已完成"
  20. when "dispatch"
  21. return "待收货"
  22. when "refunded"
  23. return "已退款"
  24. else
  25. return "--"
  26. end
  27. end
  28. def get_order_pay_way(x)
  29. case x
  30. when "weixinpay"
  31. return "微信支付"
  32. when "balance"
  33. return "提货券支付"
  34. when "cent"
  35. return "积分支付"
  36. else
  37. return "--"
  38. end
  39. end
  40. rails_admin do
  41. navigation_label '订单基本明细'
  42. weight -300
  43. parent Order
  44. list do
  45. filters [:order_no,:product_id,:order_dt_id]
  46. # include_all_fields
  47. field :id
  48. field :order_no
  49. field :product_id
  50. field :title
  51. field :nums
  52. field :order_dt_id
  53. field :paid_time do
  54. filterable true
  55. formatted_value do
  56. #bindings[:object].order.paied_time
  57. if !bindings[:object].order.blank?
  58. (bindings[:object].order.paied_at == 0 || bindings[:object].order.paied_at == nil) ? Time.at(0) : Time.at(bindings[:object].order.paied_at)
  59. end
  60. end
  61. end
  62. field :order_dt_state do
  63. filterable true
  64. formatted_value do
  65. if !bindings[:object].order.blank?
  66. bindings[:object].get_order_state(bindings[:object].order.status)
  67. end
  68. end
  69. end
  70. field :pay_way do
  71. filterable true
  72. formatted_value do
  73. if !bindings[:object].order.blank?
  74. bindings[:object].get_order_pay_way(bindings[:object].order.pay_way)
  75. end
  76. end
  77. end
  78. field :send
  79. end
  80. show do
  81. field :id
  82. field :order_no
  83. field :product_id
  84. field :title
  85. field :nums
  86. field :order_dt_id
  87. field :send
  88. end
  89. edit do
  90. field :order_no
  91. field :product_id
  92. field :title
  93. field :nums
  94. field :order_dt_id
  95. field :send
  96. end
  97. export do
  98. include_all_fields
  99. field :wx_user_id do
  100. formatted_value do
  101. bindings[:object].order.wx_user_id
  102. end
  103. end
  104. field :paid_time do
  105. filterable true
  106. formatted_value do
  107. #bindings[:object].order.paied_time
  108. if !bindings[:object].order.blank?
  109. (bindings[:object].order.paied_at == 0 || bindings[:object].order.paied_at == nil) ? Time.at(0) : Time.at(bindings[:object].order.paied_at)
  110. end
  111. end
  112. end
  113. field :order_dt_state do
  114. filterable true
  115. formatted_value do
  116. if !bindings[:object].order.blank?
  117. bindings[:object].get_order_state(bindings[:object].order.status)
  118. end
  119. end
  120. end
  121. field :pay_way do
  122. filterable true
  123. formatted_value do
  124. if !bindings[:object].order.blank?
  125. bindings[:object].get_order_pay_way(bindings[:object].order.pay_way)
  126. end
  127. end
  128. end
  129. end
  130. end
  131. end