|
|
@@ -0,0 +1,42 @@
|
|
|
+package railsadmin_controller
|
|
|
+
|
|
|
+import (
|
|
|
+ "fohow.com/apps"
|
|
|
+ "fohow.com/apps/helpers"
|
|
|
+ "fohow.com/apps/models/order_model"
|
|
|
+ "fohow.com/apps/models/user_model"
|
|
|
+ "github.com/astaxie/beego"
|
|
|
+ "strconv"
|
|
|
+ "sync"
|
|
|
+)
|
|
|
+
|
|
|
+var orderAwardLock sync.Mutex
|
|
|
+
|
|
|
+//订单发货
|
|
|
+func (self *RailsadminController) OrderAward() {
|
|
|
+
|
|
|
+ _id := self.Ctx.Input.Param(":id")
|
|
|
+ id, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
+
|
|
|
+ beego.BeeLogger.Warn("OrderAward id:(%d)", id)
|
|
|
+
|
|
|
+ defer orderAwardLock.Unlock()
|
|
|
+ orderAwardLock.Lock()
|
|
|
+ o := order_model.GetOrderByIntId(id)
|
|
|
+ if o == nil {
|
|
|
+ self.ReturnError(404, apps.OrderNotExist, "", nil)
|
|
|
+ }
|
|
|
+ //只能处理待发货订单
|
|
|
+ if o.Status != order_model.STATUS_PROCESSING && !o.HasCommission {
|
|
|
+ self.ReturnError(403, apps.OrderStatusNotSuit, "", nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ o.HasCommission = true
|
|
|
+ if !o.Save() {
|
|
|
+ beego.BeeLogger.Error("user[%d]", id)
|
|
|
+ }
|
|
|
+ wxUser := user_model.GetWxUserById(o.WxUserId, true)
|
|
|
+ go helpers.NewSendInviterBenefit(wxUser, o.OrderId, user_model.SOURCE_PRODUCT_BENEFIT)
|
|
|
+
|
|
|
+ self.ServeJSON()
|
|
|
+}
|