|
|
@@ -15,14 +15,19 @@ class Order < ActiveRecord::Base
|
|
|
|
|
|
before_save :before_save
|
|
|
after_update :patch_send_product
|
|
|
- #after_create :patch_send_product
|
|
|
-
|
|
|
- scope :所有订单, -> {}
|
|
|
- scope :未支付, -> { where("status=?","unpay") }
|
|
|
- scope :已关闭, -> { where("status=?","closed") }
|
|
|
- scope :处理中, -> { where("status=?","processing") }
|
|
|
- scope :待收货, -> { where("status=?","dispatch") }
|
|
|
- scope :已完成, -> { where("status=?","complete") }
|
|
|
+ after_create :import_orders
|
|
|
+
|
|
|
+ def import_orders
|
|
|
+ # 更新order信息
|
|
|
+ od = Order.where("id = ?", self.id).first
|
|
|
+ if od.source=="sys"
|
|
|
+ od.order_type=0
|
|
|
+ od.pick_way=0
|
|
|
+ od.status="processing"
|
|
|
+ od.has_commission=false
|
|
|
+ od.save
|
|
|
+ end
|
|
|
+ end
|
|
|
|
|
|
def before_save
|
|
|
if self.express_company.length>0
|
|
|
@@ -31,10 +36,22 @@ class Order < ActiveRecord::Base
|
|
|
self.express_code = express.express_code
|
|
|
end
|
|
|
end
|
|
|
+ if !self.wx_user.blank?
|
|
|
+ self.errors.add("微信ID不存在")
|
|
|
+ end
|
|
|
self.depart=self.wx_user.depart
|
|
|
end
|
|
|
|
|
|
|
|
|
+ scope :所有订单, -> {}
|
|
|
+ scope :未支付, -> { where("status=?","unpay") }
|
|
|
+ scope :已关闭, -> { where("status=?","closed") }
|
|
|
+ scope :处理中, -> { where("status=?","processing") }
|
|
|
+ scope :待收货, -> { where("status=?","dispatch") }
|
|
|
+ scope :已完成, -> { where("status=?","complete") }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
def patch_send_product
|
|
|
if self.status=="processing"
|
|
|
#发放未发放赠品
|