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/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()


+ 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/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
}



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

@@ -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(),


+ 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、处理订单状态
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo)
err5 := svc.JudgePackageOrdOrdState(returnDay.OutTradeNo, nil)
if err5 != nil {
_ = session.Rollback()
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)
return
ordNo := c.DefaultQuery("ord_no", "")
svc2.JudgePackageOrdOrdState(ordNo)
svc2.JudgePackageOrdOrdState(ordNo, nil)
e.OutSuc(c, nil, nil)
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/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
}


Loading…
Cancel
Save