From 09e856bac17e42a738f57291c8eef97bf2f72d5e Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 18 Jan 2024 12:25:04 +0800 Subject: [PATCH] update --- app/admin/hdl/hdl_audit_center.go | 26 ++++++++++++------- app/admin/hdl/hdl_demo.go | 11 ++++---- .../svc_central_kitchen_for_school_order.go | 4 +-- ...tral_kitchen_for_school_user_refund_day.go | 16 ++++++++++++ ...entral_kitchen_for_school_user_with_day.go | 16 ++++++++++++ 5 files changed, 55 insertions(+), 18 deletions(-) diff --git a/app/admin/hdl/hdl_audit_center.go b/app/admin/hdl/hdl_audit_center.go index 9b78dfd..366f6ad 100644 --- a/app/admin/hdl/hdl_audit_center.go +++ b/app/admin/hdl/hdl_audit_center.go @@ -6,6 +6,7 @@ import ( svc "applet/app/admin/svc/enterprise_manage" svc2 "applet/app/admin/svc/order" "applet/app/db" + "applet/app/db/model" "applet/app/e" "applet/app/enum" "applet/app/utils" @@ -105,8 +106,6 @@ func CentralKitchenForSchoolOrderRefundList(c *gin.Context) { } func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { - e.OutSuc(c, "success", nil) - return var req md.CentralKitchenForSchoolOrderRefundAuditReq err := c.ShouldBindJSON(&req) if err != nil { @@ -213,14 +212,21 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { return } - go func() { - err1 := svc2.CentralKitchenForSchoolOrderRefundAudit(c, req) - if err1 != nil { - logx.Error(err1) - println("<<<>>>>Error:::", err1.Error()) - } - cache.Del(md.AuditLockKeyForCentralKitchenLockKey) - }() + if req.State == 1 { + //TODO::审核通过,进行退款处理 + go func() { + err1 := svc2.CentralKitchenForSchoolOrderRefundAudit(c, req) + if err1 != nil { + logx.Error(err1) + println("<<<>>>>Error:::", err1.Error()) + var m model.CentralKitchenForSchoolUserRefundDay + m.Memo = "退款处理失败:(" + err1.Error() + ")" + m.State = enum.CentralKitchenForSchoolUserRefundDayStateForAuditing + db.Db.In("id", req.Ids).Cols("memo", "state").Update(&m) + } + cache.Del(md.AuditLockKeyForCentralKitchenLockKey) + }() + } e.OutSuc(c, "success", nil) return diff --git a/app/admin/hdl/hdl_demo.go b/app/admin/hdl/hdl_demo.go index d014e25..ba7a871 100644 --- a/app/admin/hdl/hdl_demo.go +++ b/app/admin/hdl/hdl_demo.go @@ -6,7 +6,6 @@ import ( "applet/app/db" "applet/app/e" "applet/app/enum" - "applet/app/utils" "fmt" "github.com/gin-gonic/gin" "time" @@ -29,11 +28,11 @@ func Demo(c *gin.Context) { PayAliPrivateKey: sysCfg[enum.OpenAlipayAppPrivateKey], PayAliPublicKey: sysCfg[enum.OpenAlipayPublicKey], }, - OutTradeNo: "SMIT1D20238140046521695702623232", - RefundAmount: "2.00", - RefundReason: "测试刷脸支付退款", - OutRequestNo: utils.OrderUUID(1997), - AppAuthToken: "202309BB893c46c0d6214c16913fb2268e5bdE03", + OutTradeNo: "800169659125681442", + RefundAmount: "180.00", + RefundReason: "央厨订餐退款", + OutRequestNo: "r_800169659125681442_1705546121", + AppAuthToken: "202308BB8ef30019cd8d4a40a3853192c397dX35", }) if err6 != nil { fmt.Println(err6.Error()) diff --git a/app/admin/svc/order/svc_central_kitchen_for_school_order.go b/app/admin/svc/order/svc_central_kitchen_for_school_order.go index c63981b..941bb7d 100644 --- a/app/admin/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/admin/svc/order/svc_central_kitchen_for_school_order.go @@ -259,7 +259,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch returnDay.RefundDate = time.Now().Format("2006-01-02 15:04:05") returnDay.Memo = req.Memo - updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdate(returnDay.Id, returnDay, "state", "memo", "refund_date", "out_request_no") + updateAck, err2 := centralKitchenForSchoolUserRefundDayDb.CentralKitchenForSchoolUserRefundDayUpdateBySess(session, returnDay.Id, returnDay, "state", "memo", "refund_date", "out_request_no") if err2 != nil { _ = session.Rollback() return err2 @@ -270,7 +270,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch return } - updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdate(userWithDay.Id, userWithDay, "state") + updateAck1, err4 := centralKitchenForSchoolUserWithDayDb.CentralKitchenForSchoolUserWithDayUpdateBySess(session, userWithDay.Id, userWithDay, "state") if err4 != nil { _ = session.Rollback() return err4 diff --git a/app/db/db_central_kitchen_for_school_user_refund_day.go b/app/db/db_central_kitchen_for_school_user_refund_day.go index 241067d..5412ce0 100644 --- a/app/db/db_central_kitchen_for_school_user_refund_day.go +++ b/app/db/db_central_kitchen_for_school_user_refund_day.go @@ -85,6 +85,22 @@ func (centralKitchenForSchoolUserRefundDayDb *CentralKitchenForSchoolUserRefundD return affected, nil } +func (centralKitchenForSchoolUserRefundDayDb *CentralKitchenForSchoolUserRefundDayDb) CentralKitchenForSchoolUserRefundDayUpdateBySess(sess *xorm.Session, id interface{}, m *model.CentralKitchenForSchoolUserRefundDay, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = sess.Where("id=?", id).Cols(forceColums...).Update(m) + } else { + affected, err = sess.Where("id=?", id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + type CentralKitchenForSchoolUserRefundDayWithCentralKitchenForSchoolUserWithDay struct { model.CentralKitchenForSchoolUserRefundDay `xorm:"extends"` model.CentralKitchenForSchoolUserWithDay `xorm:"extends"` diff --git a/app/db/db_central_kitchen_for_school_user_with_day.go b/app/db/db_central_kitchen_for_school_user_with_day.go index 7533465..8e054e1 100644 --- a/app/db/db_central_kitchen_for_school_user_with_day.go +++ b/app/db/db_central_kitchen_for_school_user_with_day.go @@ -205,6 +205,22 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb return affected, nil } +func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CentralKitchenForSchoolUserWithDayUpdateBySess(sess *xorm.Session, id interface{}, m *model.CentralKitchenForSchoolUserWithDay, forceColums ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColums != nil { + affected, err = sess.Where("id=?", id).Cols(forceColums...).Update(m) + } else { + affected, err = sess.Where("id=?", id).Update(m) + } + if err != nil { + return 0, err + } + return affected, nil +} + func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CentralKitchenForSchoolUserWithDayBatchUpdate(ids interface{}, m []*model.CentralKitchenForSchoolUserWithDay) (int64, error) { var ( affected int64