|
|
@@ -4,7 +4,9 @@ import (
|
|
|
"fohow.com/apps"
|
|
|
"fohow.com/apps/helpers"
|
|
|
"fohow.com/apps/models/order_model"
|
|
|
+ "fohow.com/apps/models/product_model"
|
|
|
"github.com/astaxie/beego"
|
|
|
+ "github.com/astaxie/beego/orm"
|
|
|
"strconv"
|
|
|
"sync"
|
|
|
"time"
|
|
|
@@ -51,6 +53,28 @@ func (self *RailsadminController) OrderDispatch() {
|
|
|
beego.BeeLogger.Error("user[%d]", id)
|
|
|
}
|
|
|
go helpers.DispathSendSms([]string{o.Tel}, o.ExpressOrderNo)
|
|
|
-
|
|
|
+ go updateSoldCount(o.Id)
|
|
|
self.ServeJSON()
|
|
|
}
|
|
|
+
|
|
|
+//更新商品出库数量
|
|
|
+func updateSoldCount(Id int64) {
|
|
|
+ var list []*order_model.OrderDtItem
|
|
|
+ sql := `
|
|
|
+ select *
|
|
|
+ from base_details where order_id=?;
|
|
|
+ `
|
|
|
+ _, err := orm.NewOrm().Raw(sql, Id).QueryRows(&list)
|
|
|
+ if err != nil {
|
|
|
+ beego.Debug("updateOutCount err=[%s]", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ beego.BeeLogger.Warn("updateSoldCount.len(list):%d", len(list))
|
|
|
+ for _, item := range list {
|
|
|
+ product := product_model.GetProductById(item.ProductId, true)
|
|
|
+ if product != nil {
|
|
|
+ product.OutNums += item.Nums
|
|
|
+ product.Save()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|