|
|
@@ -153,18 +153,26 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
var recordsId = map[int]bool{} |
|
|
|
for _, v := range req.Ids { |
|
|
|
returnDay, err1 := centralKitchenForSchoolUserRefundDayDb.GetCentralKitchenForSchoolUserRefundDay(utils.StrToInt(v)) |
|
|
|
if returnDay == nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, "记录id:【"+v+"】不存在") |
|
|
|
return |
|
|
|
} |
|
|
|
if err1 != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if returnDay.State != enum.CentralKitchenForSchoolUserRefundDayStateForAuditing { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR, "请勿重复审核申请单!") |
|
|
|
return |
|
|
|
} |
|
|
|
if recordsId[returnDay.RecordsId] { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR, "当前含有重复退订餐记录!") |
|
|
|
e.OutErr(c, e.ERR, "当前含有重复退订餐记录【身份id:"+utils.IntToStr(returnDay.IdentityId)+"】;"+"记录id:【"+v+"】!") |
|
|
|
return |
|
|
|
} |
|
|
|
recordsId[returnDay.RecordsId] = true |
|
|
@@ -175,6 +183,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
} else { |
|
|
|
userWithDay, err3 := centralKitchenForSchoolUserWithDayDb.GetCentralKitchenForSchoolUserWithDay(returnDay.RecordsId) |
|
|
|
if err3 != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err3.Error()) |
|
|
|
return |
|
|
@@ -183,13 +192,15 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
returnDay.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditReject |
|
|
|
userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForWait |
|
|
|
|
|
|
|
updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdate(userWithDay.Id, userWithDay, "state") |
|
|
|
updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdateBySess(session, userWithDay.Id, userWithDay, "state") |
|
|
|
if err4 != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err4.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if updateAck1 <= 0 { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, errors.New("更新退款就餐记录状态失败2")) |
|
|
|
return |
|
|
@@ -198,6 +209,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
//2、处理订单状态 |
|
|
|
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo) |
|
|
|
if err5 != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR, err5.Error()) |
|
|
|
return |
|
|
@@ -205,13 +217,15 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
returnDay.Memo = req.Memo |
|
|
|
updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo") |
|
|
|
updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdateBySess(session, returnDay.Id, returnDay, "state", "memo") |
|
|
|
if err2 != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if updateAck <= 0 { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
_ = session.Rollback() |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, errors.New("更新退款订单记录状态失败1")) |
|
|
|
return |
|
|
@@ -220,6 +234,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { |
|
|
|
|
|
|
|
err = session.Commit() |
|
|
|
if err != nil { |
|
|
|
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|