瀏覽代碼

更新

master
huangjiajun 4 月之前
父節點
當前提交
653a09d124
共有 3 個檔案被更改,包括 100 行新增4 行删除
  1. +3
    -0
      app/ipad/hdl/hdl_order_make.go
  2. +92
    -0
      app/ipad/svc/svc_order_make.go
  3. +5
    -4
      app/router/ipad_router.go

+ 3
- 0
app/ipad/hdl/hdl_order_make.go 查看文件

@@ -14,3 +14,6 @@ func NewOrderBakingEnd(c *gin.Context) {
func NewOrderSortingEnd(c *gin.Context) {
svc.NewOrderSortingEnd(c)
}
func NewOrderSortingEndByOrder(c *gin.Context) {
svc.NewOrderSortingEndByOrder(c)
}

+ 92
- 0
app/ipad/svc/svc_order_make.go 查看文件

@@ -124,7 +124,99 @@ func NewOrderSortingEnd(c *gin.Context) {
e.OutSuc(c, "success", nil)
return
}
func NewOrderSortingEndByOrder(c *gin.Context) {
var args md.OrderSorting
if err := c.ShouldBindJSON(&args); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
eg := db.Db
sess := eg.NewSession()
defer sess.Close()
sess.Begin()
//修改制作记录
oids := make([]string, 0)
oids = append(oids, args.Oid)
for _, v := range args.GoodsInfo {
record := db.GetOrderGoods(sess, args.Oid, v["gid"], v["sku_id"])
if record.MakeDate > utils.StrToInt(time.Now().Format("20060102")) {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, v["oid"]+",未到制作时间,请勿提交"))
return
}
if utils.StrToInt(v["num"]) > record.Num-record.SuccessNum {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, record.GoodsTitle+",数量只能提交"+utils.IntToStr(record.Num-record.SuccessNum)+"个"))
return
}
record.SuccessNum += utils.StrToInt(v["num"])
if record.SuccessNum >= record.Num {
record.State = 4
}
record.AdminId = utils.StrToInt(args.AdminId)
record.Time = time.Now()
_, err := sess.Where("id=?", record.Id).Cols("success_num,state,time").Update(record)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试"))
return
}
makeRecord := db.GetOrderGoodsMakeStockByDate(sess, utils.StrToInt64(v["gid"]), utils.StrToInt64(v["sku_id"]), record.MakeDate)
if utils.StrToInt(v["num"]) > makeRecord.WaitSortingNum {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, record.GoodsTitle+",数量只能提交"+utils.IntToStr(makeRecord.WaitSortingNum)+"个"))
return
}
makeRecord.WaitSortingNum -= utils.StrToInt(v["num"])
makeRecord.SuccessNum += utils.StrToInt(v["num"])
_, err = sess.Where("id=?", makeRecord.Id).Cols("success_num,wait_sorting_num").Update(makeRecord)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试"))
return
}
//写入流程记录
var recordFlow = &model.OrderGoodsDoingFlow{
Num: record.Num,
State: 4,
Memo: "",
SuccessNum: utils.StrToInt(v["num"]),
Time: time.Now(),
Gid: record.GoodsId,
SkuId: record.SkuId,
SkuCode: record.SkuCode,
AdminId: utils.StrToInt(args.AdminId),
GoodsTitle: record.GoodsTitle,
Sku: record.Sku,
}
var admin model.Staff
sess.Where("id=?", recordFlow.AdminId).Get(&admin)
recordFlow.AdminName = admin.Name
one, err := sess.InsertOne(recordFlow)
if one == 0 || err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "提交失败,请重试"))
return
}
}
if len(oids) > 0 {
ord := db.GetOrderByIdsSess(sess, oids)
if ord != nil {
for _, v := range *ord {
err := order.JudgePackageOrdOrdStateSess(sess, &v)
if err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "请重新提交"))
return
}
}
}
}
sess.Commit()

e.OutSuc(c, "success", nil)
return
}
func commNewMake(c *gin.Context, args map[string]string) {
eg := db.Db
sess := eg.NewSession()


+ 5
- 4
app/router/ipad_router.go 查看文件

@@ -16,9 +16,10 @@ func IpadInit(r *gin.RouterGroup) {
r.POST("order/goods/list", hdl.OrderGoods) //订单商品
r.GET("responsible", hdl.Responsible) //负责人

r.POST("order/make/end", hdl.NewOrderMakeEnd) //订单制作完成
r.POST("order/baking/end", hdl.NewOrderBakingEnd) //订单烘焙完成
r.POST("order/sorting/end", hdl.NewOrderSortingEnd) //订单分拣完成
r.POST("order/goods/sorting_list", hdl.SortingOrderGoods) //订单商品
r.POST("order/make/end", hdl.NewOrderMakeEnd) //订单制作完成
r.POST("order/baking/end", hdl.NewOrderBakingEnd) //订单烘焙完成
r.POST("order/sorting/end", hdl.NewOrderSortingEnd) //订单分拣完成
r.POST("order/sorting/end/by_order", hdl.NewOrderSortingEndByOrder) //按主订单分拣完成
r.POST("order/goods/sorting_list", hdl.SortingOrderGoods) //订单商品

}

Loading…
取消
儲存