fix:
This commit is contained in:
parent
d134f5742a
commit
582c388a84
|
@ -71,7 +71,7 @@ func ErpOrderCreate(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
//uc = &auth.UserClaims{Uid: 8588420}
|
||||
//uc := &auth.UserClaims{Uid: 8588420}
|
||||
assistant := model.GetUserByUid(uc.Uid)
|
||||
if assistant.UserType != 2 {
|
||||
logger.Error("not assistant")
|
||||
|
@ -90,7 +90,7 @@ func ErpOrderCreate(c *gin.Context) {
|
|||
Tel: req.Tel,
|
||||
StoreId: uint32(assistant.StoreId),
|
||||
StoreName: store.Name,
|
||||
MakerId: uint32(assistant.Uid),
|
||||
MakerId: assistant.Uid,
|
||||
MakerName: assistant.ShopAssistantName,
|
||||
AuditTime: time.Now(),
|
||||
AuditorId: assistant.Uid,
|
||||
|
@ -155,6 +155,7 @@ func ErpOrderCreate(c *gin.Context) {
|
|||
v.RejectedCount = req.ErpOrderCommodities[i].RejectedCount
|
||||
v.RejectedAmount = v.RejectedCount * v.RejectedPrice
|
||||
} else {
|
||||
begin.Rollback()
|
||||
logger.Error("rejected order commodity id is null")
|
||||
return
|
||||
}
|
||||
|
@ -162,11 +163,13 @@ func ErpOrderCreate(c *gin.Context) {
|
|||
req.ErpOrderCommodities[i] = v
|
||||
// 添加库存 TODO
|
||||
if req.ErpOrderCommodities[i].RejectedPrice > req.ErpOrderCommodities[i].RetailPrice {
|
||||
begin.Rollback()
|
||||
logger.Error("rejected price gt retail price ")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
if req.ErpOrderCommodities[i].RejectedCount > req.ErpOrderCommodities[i].Count {
|
||||
begin.Rollback()
|
||||
logger.Error("rejected count gt retail count ")
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
|
@ -198,13 +201,22 @@ func ErpOrderCreate(c *gin.Context) {
|
|||
erpOrder.TotalCount += req.ErpOrderCommodities[i].Count
|
||||
}
|
||||
|
||||
err = begin.Create(&req.ErpOrderCommodities).Error
|
||||
for _, commodity := range req.ErpOrderCommodities {
|
||||
err = begin.Create(&commodity).Error
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("Create")
|
||||
logger.Error("create err:", err)
|
||||
RespJson(c, status.InternalServerError, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
//err = begin.Create(orderCommodities).Error
|
||||
//if err != nil {
|
||||
// begin.Rollback()
|
||||
// logger.Error("Create")
|
||||
// RespJson(c, status.InternalServerError, nil)
|
||||
// return
|
||||
//}
|
||||
err = begin.Commit().Error
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
|
|
|
@ -285,7 +285,7 @@ func ConfigAppRouter(r gin.IRouter) {
|
|||
{
|
||||
retail.POST("order_commodity_list", controller.ErpOrderCommodityList)
|
||||
|
||||
recycleConsole.Use(auth.UserAccessAuth)
|
||||
retail.Use(auth.UserAccessAuth)
|
||||
retail.POST("order/list", controller.ErpOrderList)
|
||||
retail.POST("order/create", controller.ErpOrderCreate)
|
||||
retail.POST("order_detail", controller.ErpOrderDetail)
|
||||
|
|
Loading…
Reference in New Issue
Block a user