浏览代码

更新

master
huangjiajun 5 个月前
父节点
当前提交
2b6a757270
共有 2 个文件被更改,包括 67 次插入5 次删除
  1. +66
    -4
      app/admin/svc/order/svc_order_list.go
  2. +1
    -1
      app/db/db_sku.go

+ 66
- 4
app/admin/svc/order/svc_order_list.go 查看文件

@@ -1196,20 +1196,63 @@ func OrderEditNum(c *gin.Context) {
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
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()
e.OutErr(c, 400, e.NewErr(400, "订单已经在制作,取消失败"))
e.OutErr(c, 400, e.NewErr(400, "数量不足,减少数量失败"))
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 {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "修改失败"))
return
}
orderGoodsSku := db.GetOrderGoodsBySkuIdSess(sess, args["oid"], args["sku_id"])
var goodsId int64 = 0
var skuId int64 = 0
code := ""
skuStr := ""
if orderGoodsSku != nil {
skuId = orderGoodsSku.SkuId
goodsId = orderGoodsSku.GoodsId
code = orderGoodsSku.SkuCode
skuStr = orderGoodsSku.Sku
isHasSku = 1
//先删掉修改的 ,然后改另外的sku
i, err := sess.Where("id=?", args["id"]).Delete(&model.OrderGoods{})
@@ -1258,7 +1301,26 @@ func OrderEditNum(c *gin.Context) {
if sku != nil {
orderGoods.SkuCode = sku.SkuCode
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 {


+ 1
- 1
app/db/db_sku.go 查看文件

@@ -24,7 +24,7 @@ func GetMallSkuBySkuCode(engine *xorm.Engine, skuCode, goodsId string) (isHas bo
func GetMallSkuBySkuId(engine *xorm.Engine, skuId, goodsId string) (isHas bool, mm *model.Sku, err error) {
isHas = false
var m model.Sku
isHas, err = engine.Where("sku_id=?", skuId).And("goods_id!=?", goodsId).Get(&m)
isHas, err = engine.Where("sku_id=?", skuId).And("goods_id=?", goodsId).Get(&m)
if err != nil {
return isHas, &m, err
}


正在加载...
取消
保存