dengbiao 2 months ago
parent
commit
7df69c7a66
6 changed files with 64 additions and 24 deletions
  1. +8
    -1
      app/admin/hdl/hdl_audit_center.go
  2. +40
    -18
      app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go
  3. +8
    -2
      app/admin/svc/order/svc_central_kitchen_for_school_order.go
  4. +1
    -1
      app/admin/svc/order/svc_nursing_home_package_ord.go
  5. +1
    -1
      app/customer/hdl/hdl_demo.go
  6. +6
    -1
      app/customer/svc/order/svc_central_kitchen_for_school_order.go

+ 8
- 1
app/admin/hdl/hdl_audit_center.go View File

@@ -12,6 +12,7 @@ import (
"applet/app/utils" "applet/app/utils"
"applet/app/utils/cache" "applet/app/utils/cache"
"applet/app/utils/logx" "applet/app/utils/logx"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"errors" "errors"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"time" "time"
@@ -141,6 +142,12 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) {
return return
} }


rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

//TODO:: 加锁 Redis 锁,防并发 //TODO:: 加锁 Redis 锁,防并发
getString, _ := cache.GetString(md.AuditLockKeyForCentralKitchenLockKey) getString, _ := cache.GetString(md.AuditLockKeyForCentralKitchenLockKey)
if getString != "" { if getString != "" {
@@ -223,7 +230,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context) {
} }


//2、处理订单状态 //2、处理订单状态
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo)
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo, rabbitMqCh)
if err5 != nil { if err5 != nil {
cache.Del(md.AuditLockKeyForCentralKitchenLockKey) cache.Del(md.AuditLockKeyForCentralKitchenLockKey)
_ = session.Rollback() _ = session.Rollback()


+ 40
- 18
app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go View File

@@ -4,6 +4,7 @@ import (
"applet/app/admin/enum" "applet/app/admin/enum"
"applet/app/admin/md" "applet/app/admin/md"
"applet/app/admin/svc" "applet/app/admin/svc"
"applet/app/cfg"
"applet/app/db" "applet/app/db"
"applet/app/db/model" "applet/app/db/model"
"applet/app/e" "applet/app/e"
@@ -1549,6 +1550,11 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq
if err != nil { if err != nil {
return err return err
} }
rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
return
}

if len(m) > 0 { if len(m) > 0 {
//2、更改 `central_kitchen_for_school_user_with_day` 的 state 为 退款中 //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)" 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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态(ord_state)
for _, v := range dealOutTradeNo { for _, v := range dealOutTradeNo {
err1 := JudgePackageOrdOrdState(v)
err1 := JudgePackageOrdOrdState(v, rabbitMqCh)
if err1 != nil { if err1 != nil {
return err1 return err1
} }
@@ -1601,6 +1607,11 @@ func CentralKitchenForSchoolOrdRefund(req md.CentralKitchenForSchoolOrdRefundReq
func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSchoolBatchAskForLeaveReqBySchool) (err error) { func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSchoolBatchAskForLeaveReqBySchool) (err error) {
enterpriseDb := db.EnterpriseDb{} enterpriseDb := db.EnterpriseDb{}
enterpriseDb.Set() enterpriseDb.Set()
rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
return
}

for _, v := range req.EnterpriseIds { for _, v := range req.EnterpriseIds {
//1、查询学校 //1、查询学校
enterprise, err1 := enterpriseDb.GetEnterprise(v) enterprise, err1 := enterpriseDb.GetEnterprise(v)
@@ -1675,7 +1686,7 @@ func CentralKitchenForSchoolBatchAskForLeaveBySchool(req md.CentralKitchenForSch
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error())
@@ -1877,6 +1888,10 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho
if enterprise == nil { if enterprise == nil {
return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录") return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录")
} }
rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
return
}


classDb := db.ClassDb{} classDb := db.ClassDb{}
var classWithUser *[]model.ClassWithUser var classWithUser *[]model.ClassWithUser
@@ -1968,7 +1983,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByGrade(req md.CentralKitchenForScho
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error())
@@ -2170,6 +2185,10 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
if enterprise == nil { if enterprise == nil {
return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录") return errors.New("未查询到id:【" + utils.IntToStr(req.EnterpriseId) + "】公司对应记录")
} }
rabbitMqCh, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
return
}


var classWithUser *[]model.ClassWithUser var classWithUser *[]model.ClassWithUser
for _, v := range req.ClassIds { for _, v := range req.ClassIds {
@@ -2250,7 +2269,7 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
//4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("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) //4、处理 `central_kitchen_for_school_package_ord` 的 订单状态 (ord_state)
go func() { go func() {
for _, vv := range dealOutTradeNo { for _, vv := range dealOutTradeNo {
err11 := JudgePackageOrdOrdState(vv)
err11 := JudgePackageOrdOrdState(vv, rabbitMqCh)
if err11 != nil { if err11 != nil {
fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error()) fmt.Println("batchAskForLeaveJudgePackageOrdOrdStateErr>>>>>>>>>>>>>>>>>>>>>", err11.Error())
utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error()) utils.FilePutContents("batchAskForLeaveJudgePackageOrdOrdStateErr", err11.Error())
@@ -2440,15 +2459,18 @@ func CentralKitchenForSchoolBatchAskForLeaveByClass(req md.CentralKitchenForScho
} }


// JudgePackageOrdOrdState 判断订单状态 // 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 return
} }




+ 8
- 2
app/admin/svc/order/svc_central_kitchen_for_school_order.go View File

@@ -14,6 +14,7 @@ import (
"applet/app/enum" "applet/app/enum"
svc3 "applet/app/svc" svc3 "applet/app/svc"
"applet/app/utils" "applet/app/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"errors" "errors"
"fmt" "fmt"
"github.com/gin-gonic/gin" "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 { for k, v := range dealReturnOrdMap {
err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{ err6, _ := svc2.OldCurlAlipayTradeRefund(md2.OldCurlAlipayTradeRefundReq{
@@ -386,7 +392,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch
})) }))
} else { } else {
//TODO::处理订单状态 //TODO::处理订单状态
err = svc.JudgePackageOrdOrdState(k)
err = svc.JudgePackageOrdOrdState(k, rabbitMqCh)
if err != nil { if err != nil {
utils.FilePutContents("dealReturnOrdMap_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{ utils.FilePutContents("dealReturnOrdMap_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{
"err": err.Error(), "err": err.Error(),
@@ -451,7 +457,7 @@ func CentralKitchenForSchoolOrderRefundAudit(c *gin.Context, req md.CentralKitch
})) }))
} else { } else {
//TODO::处理订单状态 //TODO::处理订单状态
err = svc.JudgePackageOrdOrdState(k)
err = svc.JudgePackageOrdOrdState(k, rabbitMqCh)
if err != nil { if err != nil {
utils.FilePutContents("dealReturnOrdMapForWx_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{ utils.FilePutContents("dealReturnOrdMapForWx_judge_packageOrdState_ERR", utils.SerializeStr(map[string]interface{}{
"err": err.Error(), "err": err.Error(),


+ 1
- 1
app/admin/svc/order/svc_nursing_home_package_ord.go View File

@@ -180,7 +180,7 @@ func NursingHomeOrderRefundAudit(req md.NursingHomeOrderRefundAuditReq) (err err
} }


//2、处理订单状态 //2、处理订单状态
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo)
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo, nil)
if err5 != nil { if err5 != nil {
_ = session.Rollback() _ = session.Rollback()
return err5 return err5


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

@@ -269,7 +269,7 @@ func Demo(c *gin.Context) {
e.OutSuc(c, info, nil) e.OutSuc(c, info, nil)
return return
ordNo := c.DefaultQuery("ord_no", "") ordNo := c.DefaultQuery("ord_no", "")
svc2.JudgePackageOrdOrdState(ordNo)
svc2.JudgePackageOrdOrdState(ordNo, nil)
e.OutSuc(c, nil, nil) e.OutSuc(c, nil, nil)
return return
} }


+ 6
- 1
app/customer/svc/order/svc_central_kitchen_for_school_order.go View File

@@ -8,6 +8,7 @@ import (
"applet/app/db/model" "applet/app/db/model"
"applet/app/enum" "applet/app/enum"
"applet/app/utils" "applet/app/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"errors" "errors"
"fmt" "fmt"
"time" "time"
@@ -147,7 +148,11 @@ func CentralKitchenForSchoolOrderRefund(req md.CentralKitchenForSchoolOrderRefun
} }


//4、处理订单状态 //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 { if err != nil {
return err return err
} }


Loading…
Cancel
Save