diff --git a/app/admin/hdl/hdl_audit_center.go b/app/admin/hdl/hdl_audit_center.go index 29adfa4..24bea00 100644 --- a/app/admin/hdl/hdl_audit_center.go +++ b/app/admin/hdl/hdl_audit_center.go @@ -12,6 +12,7 @@ import ( "applet/app/utils" "applet/app/utils/cache" "applet/app/utils/logx" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "errors" "github.com/gin-gonic/gin" "time" @@ -141,6 +142,12 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { return } + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + e.OutErr(c, e.ERR, err.Error()) + return + } + //TODO:: 加锁 Redis 锁,防并发 getString, _ := cache.GetString(md.AuditLockKeyForCentralKitchenLockKey) if getString != "" { @@ -223,7 +230,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) { } //2、处理订单状态 - err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo) + err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo, rabbitMqCh) if err5 != nil { cache.Del(md.AuditLockKeyForCentralKitchenLockKey) _ = session.Rollback() diff --git a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go index 1f50098..7ce2865 100644 --- a/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go +++ b/app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go @@ -4,6 +4,7 @@ import ( "applet/app/admin/enum" "applet/app/admin/md" "applet/app/admin/svc" + "applet/app/cfg" "applet/app/db" "applet/app/db/model" "applet/app/e" @@ -1549,6 +1550,11 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq if err != nil { return err } + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } + if len(m) > 0 { //2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 sql := "update central_kitchen_for_school_user_with_day set state = %d where id In (%s)" @@ -1584,7 +1590,7 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state) for _, v := range dealOutTradeNo { - err1 := JudgePackageOrdOrdState(v) + err1 := JudgePackageOrdOrdState(v, rabbitMqCh) if err1 != nil { return err1 } @@ -1601,6 +1607,11 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSchoolBatchAskForLeaveReqBySchool) (err error) { enterpriseDb := db.EnterpriseDb{} enterpriseDb.Set() + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } + for _, v := range req.EnterpriseIds { //1、查询学校 enterprise, err1 := enterpriseDb.GetEnterprise(v) @@ -1675,7 +1686,7 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -1758,7 +1769,7 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -1841,7 +1852,7 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -1877,6 +1888,10 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho if enterprise == nil { return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录") } + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } classDb := db.ClassDb{} var classWithUser *[]model.ClassWithUser @@ -1968,7 +1983,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2051,7 +2066,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2134,7 +2149,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2170,6 +2185,10 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho if enterprise == nil { return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录") } + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } var classWithUser *[]model.ClassWithUser for _, v := range req.ClassIds { @@ -2250,7 +2269,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2333,7 +2352,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2416,7 +2435,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) go func() { for _, vv := range dealOutTradeNo { - err11 := JudgePackageOrdOrdState(vv) + err11 := JudgePackageOrdOrdState(vv, rabbitMqCh) if err11 != nil { fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) @@ -2440,15 +2459,18 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho } // JudgePackageOrdOrdState 判断订单状态 -func JudgePackageOrdOrdState(outTradeNo string) (err error) { - rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() - if err != nil { - fmt.Println("err:::::11111:::::HoneyCollectContribution", err.Error()) - return +func JudgePackageOrdOrdState(outTradeNo string, ch *rabbit.Channel) (err error) { + if cfg.Prd { + if err != nil { + fmt.Println("err:::::11111:::::JudgePackageOrdOrdState", err.Error()) + return + } + ch.Publish(md2.OrdExchange, md2.JudgePackageOrdOrdState{ + OrdNo: outTradeNo, + }, md2.OrdRoutKeyForJudgePackageOrdOrdState) + } else { + DealJudgePackageOrdOrdState(outTradeNo) } - rabbitMqCh.Publish(md2.OrdExchange, md2.JudgePackageOrdOrdState{ - OrdNo: outTradeNo, - }, md2.OrdRoutKeyForJudgePackageOrdOrdState) return } 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 5175e29..85013c7 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 @@ -14,6 +14,7 @@ import ( "applet/app/enum" svc3 "applet/app/svc" "applet/app/utils" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "errors" "fmt" "github.com/gin-gonic/gin" @@ -348,6 +349,11 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch } } + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } + //调用支付宝进行退款 for k, v := range dealReturnOrdMap { err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ @@ -386,7 +392,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch })) } else { //TODO::处理订单状态 - err = svc.JudgePackageOrdOrdState(k) + err = svc.JudgePackageOrdOrdState(k, rabbitMqCh) if err != nil { utils.FilePutContents("dealReturnOrdMap_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{ "err": err.Error(), @@ -451,7 +457,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch })) } else { //TODO::处理订单状态 - err = svc.JudgePackageOrdOrdState(k) + err = svc.JudgePackageOrdOrdState(k, rabbitMqCh) if err != nil { utils.FilePutContents("dealReturnOrdMapForWx_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{ "err": err.Error(), diff --git a/app/admin/svc/order/svc_nursing_home_package_ord.go b/app/admin/svc/order/svc_nursing_home_package_ord.go index f10bbc4..5f40691 100644 --- a/app/admin/svc/order/svc_nursing_home_package_ord.go +++ b/app/admin/svc/order/svc_nursing_home_package_ord.go @@ -180,7 +180,7 @@ func NursingHomeOrderRefundAudit(req md.NursingHomeOrderRefundAuditReq) (err err } //2、处理订单状态 - err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo) + err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo, nil) if err5 != nil { _ = session.Rollback() return err5 diff --git a/app/customer/hdl/hdl_demo.go b/app/customer/hdl/hdl_demo.go index 44d650c..4afa695 100644 --- a/app/customer/hdl/hdl_demo.go +++ b/app/customer/hdl/hdl_demo.go @@ -269,7 +269,7 @@ func Demo(c *gin.Context) { e.OutSuc(c, info, nil) return ordNo := c.DefaultQuery("ord_no", "") - svc2.JudgePackageOrdOrdState(ordNo) + svc2.JudgePackageOrdOrdState(ordNo, nil) e.OutSuc(c, nil, nil) return } diff --git a/app/customer/svc/order/svc_central_kitchen_for_school_order.go b/app/customer/svc/order/svc_central_kitchen_for_school_order.go index 9a28c16..d0372d0 100644 --- a/app/customer/svc/order/svc_central_kitchen_for_school_order.go +++ b/app/customer/svc/order/svc_central_kitchen_for_school_order.go @@ -8,6 +8,7 @@ import ( "applet/app/db/model" "applet/app/enum" "applet/app/utils" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" "errors" "fmt" "time" @@ -147,7 +148,11 @@ func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefun } //4、处理订单状态 - err = svc.JudgePackageOrdOrdState(req.OutTradeNo) + rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + return + } + err = svc.JudgePackageOrdOrdState(req.OutTradeNo, rabbitMqCh) if err != nil { return err }