From ec2cedd5dcdd6060ce3eafed4dc5b58a7517945b Mon Sep 17 00:00:00 2001 From: dengbiao <“1239118001@qq.com”> Date: Sat, 31 Aug 2024 17:22:18 +0800 Subject: [PATCH 1/5] update --- app/customer/svc/svc_pay.go | 104 +++++++++--------------------------- 1 file changed, 24 insertions(+), 80 deletions(-) diff --git a/app/customer/svc/svc_pay.go b/app/customer/svc/svc_pay.go index a3a9e1e..e3be7df 100644 --- a/app/customer/svc/svc_pay.go +++ b/app/customer/svc/svc_pay.go @@ -54,55 +54,27 @@ func BuyPackageForAli(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo var totalPrice float64 var data []*model.CentralKitchenForSchoolUserWithDay if req.Kind == 1 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcBySchoolTerm(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 2 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcByMonth(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 3 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcByDay(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcByDay(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcByDay(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 4 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcSupplementaryByDay(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req) + if err != nil { + return } } total = utils.Float64ToStr(totalPrice) @@ -197,55 +169,27 @@ func BuyPackageForWx(c *gin.Context, req md.BuyPackageReq) (outTradeNo, total st var totalPrice float64 var data []*model.CentralKitchenForSchoolUserWithDay if req.Kind == 1 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcBySchoolTerm(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 2 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcByMonth(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 3 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcByDay(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcByDay(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcByDay(user.Id, isTeacher, req) + if err != nil { + return } } if req.Kind == 4 { - if req.IsBuyByMealLabel { - totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req) - if err != nil { - return - } - } else { - totalPrice, data, err = OldCalcSupplementaryByDay(user.Id, isTeacher, req) - if err != nil { - return - } + totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req) + if err != nil { + return } } total = utils.Float64ToStr(totalPrice) From f8b78508ed652d9c1028651dc550c9de69503b09 Mon Sep 17 00:00:00 2001 From: dengbiao <“1239118001@qq.com”> Date: Sat, 31 Aug 2024 18:35:04 +0800 Subject: [PATCH 2/5] 1 --- .../svc_central_kitchen_for_school_package.go | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/customer/svc/svc_central_kitchen_for_school_package.go b/app/customer/svc/svc_central_kitchen_for_school_package.go index c1258ac..376d7a3 100644 --- a/app/customer/svc/svc_central_kitchen_for_school_package.go +++ b/app/customer/svc/svc_central_kitchen_for_school_package.go @@ -37,7 +37,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel - if buyPackageReq.IsBuyBreakfast == 1 { + if !isTeacher && buyPackageReq.IsBuyBreakfast == 1{ mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { return @@ -47,7 +47,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) return } } - if buyPackageReq.IsBuyLunch == 1 { + if !isTeacher && buyPackageReq.IsBuyLunch == 1 { mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForLunch) if err != nil { return @@ -57,7 +57,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) return } } - if buyPackageReq.IsBuyDinner == 1 { + if !isTeacher && buyPackageReq.IsBuyDinner == 1 { mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForDinner) if err != nil { return @@ -198,7 +198,7 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel - if buyPackageReq.IsBuyBreakfast == 1 { + if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { return @@ -208,7 +208,7 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota return } } - if buyPackageReq.IsBuyLunch == 1 { + if !isTeacher && buyPackageReq.IsBuyLunch == 1 { mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForLunch) if err != nil { return @@ -218,7 +218,7 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota return } } - if buyPackageReq.IsBuyDinner == 1 { + if !isTeacher && buyPackageReq.IsBuyDinner == 1 { mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForDinner) if err != nil { return @@ -358,7 +358,7 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel - if buyPackageReq.IsBuyBreakfast == 1 { + if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { return @@ -368,7 +368,7 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP return } } - if buyPackageReq.IsBuyLunch == 1 { + if !isTeacher && buyPackageReq.IsBuyLunch == 1 { mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForLunch) if err != nil { return @@ -378,7 +378,7 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP return } } - if buyPackageReq.IsBuyDinner == 1 { + if !isTeacher && buyPackageReq.IsBuyDinner == 1 { mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForDinner) if err != nil { return @@ -498,7 +498,7 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel - if buyPackageReq.IsBuyBreakfast == 1 { + if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { return @@ -508,7 +508,7 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag return } } - if buyPackageReq.IsBuyLunch == 1 { + if !isTeacher && buyPackageReq.IsBuyLunch == 1 { mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForLunch) if err != nil { return @@ -518,7 +518,7 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag return } } - if buyPackageReq.IsBuyDinner == 1 { + if !isTeacher && buyPackageReq.IsBuyDinner == 1 { mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForDinner) if err != nil { return From b38d1b4973bc4416a47b4df6f8a6e5b234e9b888 Mon Sep 17 00:00:00 2001 From: dengbiao <“1239118001@qq.com”> Date: Sat, 31 Aug 2024 19:13:58 +0800 Subject: [PATCH 3/5] 1 --- .../svc/svc_central_kitchen_for_school_package.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/customer/svc/svc_central_kitchen_for_school_package.go b/app/customer/svc/svc_central_kitchen_for_school_package.go index 376d7a3..78aeffa 100644 --- a/app/customer/svc/svc_central_kitchen_for_school_package.go +++ b/app/customer/svc/svc_central_kitchen_for_school_package.go @@ -36,7 +36,7 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} if !isTeacher && buyPackageReq.IsBuyBreakfast == 1{ mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -197,7 +197,7 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -357,7 +357,7 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -497,7 +497,7 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { From 6540dda2ff7db6f2e8d97f6d2eb602a94a311788 Mon Sep 17 00:00:00 2001 From: dengbiao <“1239118001@qq.com”> Date: Sat, 31 Aug 2024 19:37:03 +0800 Subject: [PATCH 4/5] 1 --- .../svc_central_kitchen_for_school_package.go | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/customer/svc/svc_central_kitchen_for_school_package.go b/app/customer/svc/svc_central_kitchen_for_school_package.go index 78aeffa..7d9de4f 100644 --- a/app/customer/svc/svc_central_kitchen_for_school_package.go +++ b/app/customer/svc/svc_central_kitchen_for_school_package.go @@ -36,7 +36,10 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + if isTeacher { + mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} + } if !isTeacher && buyPackageReq.IsBuyBreakfast == 1{ mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -197,7 +200,10 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + if isTeacher { + mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} + } if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -357,7 +363,10 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + if isTeacher { + mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} + } if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { @@ -497,7 +506,10 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag //} mealLabelDb := db.MealLabelDb{} mealLabelDb.Set(buyPackageReq.EnterpriseId) - var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = model.MealLabel{}, model.MealLabel{}, model.MealLabel{} + var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel + if isTeacher { + mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} + } if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) if err != nil { From 02f56ffdce29600f2b672ddeb8f64459ebe912f4 Mon Sep 17 00:00:00 2001 From: dengbiao <“1239118001@qq.com”> Date: Sat, 31 Aug 2024 23:49:47 +0800 Subject: [PATCH 5/5] 1 --- app/admin/svc/svc_data_statisstics.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index bed0a31..79aa3b5 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -1441,6 +1441,8 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD sDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) eDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) nativeSql = fmt.Sprintf(nativeSql, strings.Join(ordNoArr, ","), enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling, sDate.Format("2006-01-02"), eDate.Format("2006-01-02"), strings.Join(mealKindListArr, ",")) + + fmt.Println(nativeSql) nativeResults, err := db.QueryNativeString(db.Db, nativeSql) var nativeResultsMap = map[string]map[int]map[string]int64{} var mealLabelMap = map[int]map[int]map[string]string{} @@ -1485,23 +1487,22 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD centralKitchenForSchoolUserWithDayDb := db.CentralKitchenForSchoolUserWithDayDb{} centralKitchenForSchoolUserWithDayDb.Set(0) for _, v := range m { - if list[v.Enterprise.Name] == nil { - list[v.Enterprise.Name] = make(map[string]map[string]map[string]map[string]int64) - } - if list[v.Enterprise.Name][v.Grade.Name] == nil { - list[v.Enterprise.Name][v.Grade.Name] = make(map[string]map[string]map[string]int64) - } - if list[v.Enterprise.Name][v.Grade.Name][v.Class.Name] == nil { - list[v.Enterprise.Name][v.Grade.Name][v.Class.Name] = make(map[string]map[string]int64) - } - if list[v.Enterprise.Name][v.Grade.Name][v.Class.Name][v.UserIdentity.Name] == nil { - list[v.Enterprise.Name][v.Grade.Name][v.Class.Name][v.UserIdentity.Name] = make(map[string]int64) - } - for kk, vv := range nativeResultsMap[v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo] { if v.CentralKitchenForSchoolPackageOrdForReserve.Kind != kk { continue } + if list[v.Enterprise.Name] == nil { + list[v.Enterprise.Name] = make(map[string]map[string]map[string]map[string]int64) + } + if list[v.Enterprise.Name][v.Grade.Name] == nil { + list[v.Enterprise.Name][v.Grade.Name] = make(map[string]map[string]map[string]int64) + } + if list[v.Enterprise.Name][v.Grade.Name][v.Class.Name] == nil { + list[v.Enterprise.Name][v.Grade.Name][v.Class.Name] = make(map[string]map[string]int64) + } + if list[v.Enterprise.Name][v.Grade.Name][v.Class.Name][v.UserIdentity.Name] == nil { + list[v.Enterprise.Name][v.Grade.Name][v.Class.Name][v.UserIdentity.Name] = make(map[string]int64) + } for kkk, vvv := range vv { list[v.Enterprise.Name][v.Grade.Name][v.Class.Name][v.UserIdentity.Name][kkk] += vvv }