order_base_detail.rb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 :id
  91. field :order_no
  92. field :product_id
  93. field :title
  94. field :nums
  95. field :order_dt_id
  96. field :send
  97. end
  98. export do
  99. include_all_fields
  100. field :wx_user_id do
  101. formatted_value do
  102. bindings[:object].order.wx_user_id
  103. end
  104. end
  105. field :paid_time do
  106. filterable true
  107. formatted_value do
  108. #bindings[:object].order.paied_time
  109. if !bindings[:object].order.blank?
  110. (bindings[:object].order.paied_at == 0 || bindings[:object].order.paied_at == nil) ? Time.at(0) : Time.at(bindings[:object].order.paied_at)
  111. end
  112. end
  113. end
  114. field :order_dt_state do
  115. filterable true
  116. formatted_value do
  117. if !bindings[:object].order.blank?
  118. bindings[:object].get_order_state(bindings[:object].order.status)
  119. end
  120. end
  121. end
  122. field :pay_way do
  123. filterable true
  124. formatted_value do
  125. if !bindings[:object].order.blank?
  126. bindings[:object].get_order_pay_way(bindings[:object].order.pay_way)
  127. end
  128. end
  129. end
  130. end
  131. end
  132. end