From 1f5b78c836f7e2fb840a9b7782135e54121b321f Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Mon, 9 Oct 2023 17:05:46 +0800 Subject: [PATCH] update --- app/admin/md/md_enterprise_manage.go | 2 + .../svc_central_kitchen_for_school.go | 45 +++++++++++++++++++ ...entral_kitchen_for_school_user_with_day.go | 24 +++------- 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 8662314..d26515b 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -280,6 +280,8 @@ type CentralKitchenForSchoolReserveListResp struct { ReserveMonth string `json:"reserve_month"` TotalPrice string `json:"total_price"` CreateAt string `json:"create_at"` + State int `json:"state"` + StateZh string `json:"state_zh"` Phone string `json:"phone" label:"家长联系电话"` Grade string `json:"grade" label:"年级"` GradeId int `json:"grade_id" label:"年级id"` 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 dab3e02..05f82c0 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 @@ -829,6 +829,49 @@ func CentralKitchenForSchoolReserveList(req md.CentralKitchenForSchoolReserveLis // continue //} + //获取当前预定记录下有多少退款记录 + var state = 1 + var stateZh = "已支付" + + centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} + centralKitchenForSchoolUserWithDayDb.Set(0) + count1, err1 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoV2(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum2.CentralKitchenForSchoolUserWithDayStateForCanceling, + v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeStart, v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeEnd, v.CentralKitchenForSchoolPackageOrdForReserve.Kind) + if err1 != nil { + return nil, 0, err1 + } + if count1 > 0 { + state = 2 + stateZh = "退款中" + } else { + count2, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoV2(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum2.CentralKitchenForSchoolUserWithDayStateForCancel, + v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeStart, v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeEnd, v.CentralKitchenForSchoolPackageOrdForReserve.Kind) + if err1 != nil { + return nil, 0, err2 + } + if count2 > 0 { + state = 3 + stateZh = "部分退款" + + count3, err3 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoV2(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum2.CentralKitchenForSchoolUserWithDayStateForWait, + v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeStart, v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeEnd, v.CentralKitchenForSchoolPackageOrdForReserve.Kind) + if err1 != nil { + return nil, 0, err3 + } + if count3 == 0 { + count4, err4 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoV2(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum2.CentralKitchenForSchoolUserWithDayStateForAlready, + v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeStart, v.CentralKitchenForSchoolPackageOrdForReserve.MealTimeEnd, v.CentralKitchenForSchoolPackageOrdForReserve.Kind) + if err1 != nil { + return nil, 0, err4 + } + if count4 == 0 { + state = 4 + stateZh = "已退款" + } + } + } + } + resp = append(resp, md.CentralKitchenForSchoolReserveListResp{ Id: v.CentralKitchenForSchoolPackageOrdForReserve.Id, EnterpriseId: v.UserIdentity.EnterpriseId, @@ -846,6 +889,8 @@ func CentralKitchenForSchoolReserveList(req md.CentralKitchenForSchoolReserveLis GradeId: v.Grade.Id, Class: v.Class.Name, ClassId: v.Class.Id, + State: state, + StateZh: stateZh, }) } return 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 10acadd..4da5dc3 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 @@ -77,26 +77,12 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb return count, nil } -func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNoV2(ordNo string, state int, startDate, endDate string, kindList []int) (count int64, err error) { +func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNoV2(ordNo string, state int, startDate, endDate string, kind int) (count int64, err error) { var m model.CentralKitchenForSchoolUserWithDay - - sess := centralKitchenForSchoolUserWithDayDb.Db.NewSession() - sess = sess.Where("1=1") - if ordNo != "" { - sess.And("ord_no =?", ordNo) - } - if state != 0 { - sess.And("state !=?", state) - } - if startDate != "" { - sDate, _ := time.ParseInLocation("2006-01-02", startDate, time.Local) - eDate, _ := time.ParseInLocation("2006-01-02", endDate, time.Local) - sess.And("date >= ?", sDate.Format("2006-01-02")).And("date <= ?", eDate.Format("2006-01-02")) - } - if len(kindList) > 0 { - sess.In("kind", kindList) - } - count, err = sess.Count(&m) + count, err = centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("state =?", state). + And("date >= ?", startDate).And("date <= ?", endDate). + And("kind = ?", kind). + Count(&m) return count, nil }