Browse Source

增加订单导入功能

abiao 4 years ago
parent
commit
b6b19742e3
1 changed files with 7 additions and 6 deletions
  1. 7 6
      app/models/order.rb

+ 7 - 6
app/models/order.rb

@@ -21,9 +21,11 @@ class Order < ActiveRecord::Base
         # 更新order信息
         od = Order.where("id = ?", self.id).first
         if od.source=="sys"
+            od.depart=od.wx_user.depart
+            od.user_id=od.wx_user.user_id
+            od.status="processing"
             od.order_type=0
             od.pick_way=0
-            od.status="processing"
             od.has_commission=false
             od.save
         end
@@ -42,13 +44,12 @@ class Order < ActiveRecord::Base
 
         wxUser = WxUser.where("id = ?", self.wx_user_id).first
 
-        if wxUser.blank?
-            self.errors.add(:wx_user_id,"微信ID不存在")
+        if !wxUser.blank?
+            self.depart=wxUser.depart
+            self.user_id=wxUser.user_id
         end
 
-        self.depart=wxUser.depart
-        self.user_id=wxUser.user_id
-        self.status="processing"
+
     end