|
@@ -1196,20 +1196,63 @@ func OrderEditNum(c *gin.Context) { |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
if all.WaitMakeNum < orderGoods.Num { |
|
|
|
|
|
|
|
|
newNum := orderGoods.Num |
|
|
|
|
|
num := orderGoods.Num |
|
|
|
|
|
WaitMakeNum := 0 |
|
|
|
|
|
if all.WaitMakeNum > 0 { |
|
|
|
|
|
leave := all.WaitMakeNum - num |
|
|
|
|
|
deNum := num |
|
|
|
|
|
if leave < 0 { |
|
|
|
|
|
deNum = all.WaitMakeNum |
|
|
|
|
|
} |
|
|
|
|
|
all.WaitMakeNum -= deNum |
|
|
|
|
|
newNum -= deNum |
|
|
|
|
|
WaitMakeNum = deNum |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
if newNum > 0 && all.WaitSortingNum > 0 { |
|
|
|
|
|
leave := all.WaitSortingNum - num |
|
|
|
|
|
deNum := num |
|
|
|
|
|
if leave < 0 { |
|
|
|
|
|
deNum = all.WaitSortingNum |
|
|
|
|
|
} |
|
|
|
|
|
newNum -= deNum |
|
|
|
|
|
all.WaitSortingNum -= deNum |
|
|
|
|
|
} |
|
|
|
|
|
WaitBakingNum := 0 |
|
|
|
|
|
if newNum > 0 && all.WaitBakingNum > 0 { |
|
|
|
|
|
leave := all.WaitBakingNum - num |
|
|
|
|
|
deNum := num |
|
|
|
|
|
if leave < 0 { |
|
|
|
|
|
deNum = all.WaitBakingNum |
|
|
|
|
|
} |
|
|
|
|
|
newNum -= deNum |
|
|
|
|
|
all.WaitBakingNum -= deNum |
|
|
|
|
|
WaitBakingNum = deNum |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Println(WaitMakeNum) |
|
|
|
|
|
fmt.Println(WaitBakingNum) |
|
|
|
|
|
if newNum > 0 { |
|
|
sess.Rollback() |
|
|
sess.Rollback() |
|
|
e.OutErr(c, 400, e.NewErr(400, "订单已经在制作,取消失败")) |
|
|
|
|
|
|
|
|
e.OutErr(c, 400, e.NewErr(400, "数量不足,减少数量失败")) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
all.WaitMakeNum -= orderGoods.Num |
|
|
|
|
|
_, err := sess.Where("id=?", all.Id).Cols("wait_make_num").Update(all) |
|
|
|
|
|
|
|
|
_, err := sess.Where("id=?", all.Id).Cols("wait_make_num,wait_sorting_num,wait_baking_num").Update(all) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
sess.Rollback() |
|
|
sess.Rollback() |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
e.OutErr(c, 400, e.NewErr(400, "修改失败")) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
orderGoodsSku := db.GetOrderGoodsBySkuIdSess(sess, args["oid"], args["sku_id"]) |
|
|
orderGoodsSku := db.GetOrderGoodsBySkuIdSess(sess, args["oid"], args["sku_id"]) |
|
|
|
|
|
var goodsId int64 = 0 |
|
|
|
|
|
var skuId int64 = 0 |
|
|
|
|
|
code := "" |
|
|
|
|
|
skuStr := "" |
|
|
if orderGoodsSku != nil { |
|
|
if orderGoodsSku != nil { |
|
|
|
|
|
skuId = orderGoodsSku.SkuId |
|
|
|
|
|
goodsId = orderGoodsSku.GoodsId |
|
|
|
|
|
code = orderGoodsSku.SkuCode |
|
|
|
|
|
skuStr = orderGoodsSku.Sku |
|
|
isHasSku = 1 |
|
|
isHasSku = 1 |
|
|
//先删掉修改的 ,然后改另外的sku |
|
|
//先删掉修改的 ,然后改另外的sku |
|
|
i, err := sess.Where("id=?", args["id"]).Delete(&model.OrderGoods{}) |
|
|
i, err := sess.Where("id=?", args["id"]).Delete(&model.OrderGoods{}) |
|
@@ -1258,7 +1301,26 @@ func OrderEditNum(c *gin.Context) { |
|
|
if sku != nil { |
|
|
if sku != nil { |
|
|
orderGoods.SkuCode = sku.SkuCode |
|
|
orderGoods.SkuCode = sku.SkuCode |
|
|
orderGoods.Sku = sku.Sku |
|
|
orderGoods.Sku = sku.Sku |
|
|
|
|
|
orderGoods.SkuCode = sku.SkuCode |
|
|
|
|
|
code = sku.SkuCode |
|
|
|
|
|
skuStr = sku.Sku |
|
|
|
|
|
} |
|
|
|
|
|
skuId = orderGoods.SkuId |
|
|
|
|
|
goodsId = sku.GoodsId |
|
|
|
|
|
} |
|
|
|
|
|
all1 := db.GetOrderGoodsMakeStockAllByDate(sess, goodsId, skuId, 0, orderGoods.MakeDate) |
|
|
|
|
|
if all1 == nil { |
|
|
|
|
|
var tmp = &model.OrderGoodsMakeStock{ |
|
|
|
|
|
Gid: goodsId, |
|
|
|
|
|
SkuId: skuId, |
|
|
|
|
|
SkuCode: code, |
|
|
|
|
|
GoodsTitle: orderGoods.GoodsTitle, |
|
|
|
|
|
Sku: skuStr, |
|
|
|
|
|
WaitMakeNum: utils.StrToInt(args["num"]), |
|
|
|
|
|
GoodsType: 0, |
|
|
|
|
|
MakeDate: orderGoods.MakeDate, |
|
|
} |
|
|
} |
|
|
|
|
|
sess.Insert(tmp) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if isHasSku == 0 { |
|
|
if isHasSku == 0 { |
|
|