|
@@ -733,32 +733,36 @@ func GetPaiedOrderByWxUIdAndPayWayLimitOne(wxUserId int64, payWay string, useCac
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新商品已售数量
|
|
// 更新商品已售数量
|
|
|
-func UpdateSaleNums(saleProducts map[int64]int64) bool {
|
|
|
|
|
-
|
|
|
|
|
|
|
+func UpdateSaleNums(saleProducts map[int64]int64, direction int) bool {
|
|
|
for pId, nums := range saleProducts {
|
|
for pId, nums := range saleProducts {
|
|
|
-
|
|
|
|
|
- //beego.BeeLogger.Error("pId,Nums %d--%d", pId, nums)
|
|
|
|
|
-
|
|
|
|
|
product := product_model.GetProductById(pId, true)
|
|
product := product_model.GetProductById(pId, true)
|
|
|
if product == nil {
|
|
if product == nil {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
- product.SaleNums += nums
|
|
|
|
|
- product.Save()
|
|
|
|
|
- //套装商品拆分更新销量
|
|
|
|
|
|
|
+ // 套装商品拆分更新销量
|
|
|
if product.Package {
|
|
if product.Package {
|
|
|
package_list := product_model.GetPackageList(product.Id, true)
|
|
package_list := product_model.GetPackageList(product.Id, true)
|
|
|
for _, item := range package_list {
|
|
for _, item := range package_list {
|
|
|
item_pd := product_model.GetProductById(item.ItemId, true)
|
|
item_pd := product_model.GetProductById(item.ItemId, true)
|
|
|
count := item.Nums * nums
|
|
count := item.Nums * nums
|
|
|
- item_pd.SaleNums += count
|
|
|
|
|
|
|
+ if direction == 0 {
|
|
|
|
|
+ item_pd.SaleNums += count
|
|
|
|
|
+ } else if direction == 1 {
|
|
|
|
|
+ item_pd.SaleNums -= count
|
|
|
|
|
+ }
|
|
|
item_pd.Save()
|
|
item_pd.Save()
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if direction == 0 {
|
|
|
|
|
+ product.SaleNums += nums
|
|
|
|
|
+ } else if direction == 1 {
|
|
|
|
|
+ product.SaleNums -= nums
|
|
|
|
|
+ }
|
|
|
|
|
+ product.Save()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
func GetDistrictOrders(tcBl, page, perPage int64, tcArea string) (orders []*Order) {
|
|
func GetDistrictOrders(tcBl, page, perPage int64, tcArea string) (orders []*Order) {
|
|
|
|
|
|
|
|
beginSql := "select order_id,contact,paied_at, "
|
|
beginSql := "select order_id,contact,paied_at, "
|