Browse Source

update

tmp
DengBiao 10 months ago
parent
commit
3b3fb6b697
5 changed files with 71 additions and 6 deletions
  1. +18
    -3
      app/admin/hdl/hdl_audit_center.go
  2. +40
    -0
      app/admin/hdl/hdl_demo.go
  3. +9
    -0
      app/admin/svc/order/svc_central_kitchen_for_school_order.go
  4. +3
    -3
      app/customer/hdl/hdl_demo.go
  5. +1
    -0
      app/router/admin_router.go

+ 18
- 3
app/admin/hdl/hdl_audit_center.go View File

@@ -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
}


+ 40
- 0
app/admin/hdl/hdl_demo.go View File

@@ -1,9 +1,13 @@
package hdl

import (
"applet/app/admin/lib/validate"
"applet/app/admin/md"
svc "applet/app/admin/svc/order"
md2 "applet/app/customer/md"
svc2 "applet/app/customer/svc"
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/enum"
"fmt"
@@ -13,6 +17,22 @@ import (

// Demo 测试
func Demo(c *gin.Context) {
var req md.CentralKitchenForSchoolOrderRefundAuditReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
err1 := svc.CentralKitchenForSchoolOrderRefundAudit(c, req)
if err1 != nil {
fmt.Println(err1.Error())
e.OutErr(c, e.ERR, err1.Error())
return
}
e.OutSuc(c, "success", nil)
return
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAlipayAppid, enum.OpenAlipayAppPrivateKey, enum.OpenAlipayPublicKey)
@@ -50,6 +70,26 @@ func Demo(c *gin.Context) {
return
}

func DemoV1(c *gin.Context) {
centralKitchenForSchoolUserRefundDayDb := db.CentralKitchenForSchoolUserRefundDayDb{}
centralKitchenForSchoolUserRefundDayDb.Set(0)
var m []model.CentralKitchenForSchoolUserRefundDay
if err := centralKitchenForSchoolUserRefundDayDb.Db.Where("state =1").Desc("id").Find(&m); err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
var recordsId = map[int]bool{}
var repeatIds []int
for _, v := range m {
if recordsId[v.RecordsId] {
repeatIds = append(repeatIds, v.Id)
}
recordsId[v.RecordsId] = true
}
e.OutSuc(c, repeatIds, nil)

}

func GoOnExecuting() {
for i := 0; i < 20; i++ {
time.Sleep(1 * time.Second)


+ 9
- 0
app/admin/svc/order/svc_central_kitchen_for_school_order.go View File

@@ -221,6 +221,13 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch
return err3
}

if userWithDay.State == enum.CentralKitchenForSchoolUserWithDayStateForCancel {
//TODO::当前订餐记录,已退款了
returnDay.Memo = "当前退款申请记录,已有其他退款申请完成退款!"
centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "memo")
continue
}

userWithDay.State = enum.CentralKitchenForSchoolUserWithDayStateForCancel
outRequestNo := "r_" + returnDay.OutTradeNo + outRequestNoSuffix
centralKitchenForSchoolPackageOrd.Set(returnDay.OutTradeNo)
@@ -282,6 +289,8 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch
return
}

time.Sleep(20 * time.Millisecond) //TODO::避免频繁操作sql

updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdateBySess(session, userWithDay.Id, userWithDay, "state")
if err4 != nil {
_ = session.Rollback()


+ 3
- 3
app/customer/hdl/hdl_demo.go View File

@@ -163,9 +163,9 @@ func Demo(c *gin.Context) {
AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
},
CertType: "1",
CertNo: "42122420101212373X",
StudentName: "陈柏中",
OutUserId: "6010",
CertNo: "411381201103013932",
StudentName: "黄永康",
OutUserId: "6088",
SchoolStdCode: "3144003844",
}, &model.UserIdentity{}, "", "")
if err != nil {


+ 1
- 0
app/router/admin_router.go View File

@@ -282,6 +282,7 @@ func rRole(r *gin.RouterGroup) {

func AdminRoute(r *gin.RouterGroup) {
r.GET("/demo", hdl2.Demo)
r.GET("/test", hdl2.DemoV1)

r.POST("/login", hdl2.Login)



Loading…
Cancel
Save