@@ -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 | |||
} | |||
@@ -37,7 +37,10 @@ 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 { | |||
mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} | |||
} | |||
if !isTeacher && buyPackageReq.IsBuyBreakfast == 1{ | |||
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) | |||
if err != nil { | |||
return | |||
@@ -47,7 +50,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 +60,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 +201,10 @@ 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 { | |||
mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} | |||
} | |||
if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { | |||
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) | |||
if err != nil { | |||
return | |||
@@ -208,7 +214,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 +224,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 +364,10 @@ 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 { | |||
mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} | |||
} | |||
if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { | |||
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) | |||
if err != nil { | |||
return | |||
@@ -368,7 +377,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 +387,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 +507,10 @@ 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 { | |||
mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner = &model.MealLabel{}, &model.MealLabel{}, &model.MealLabel{} | |||
} | |||
if !isTeacher && buyPackageReq.IsBuyBreakfast == 1 { | |||
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast) | |||
if err != nil { | |||
return | |||
@@ -508,7 +520,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 +530,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 | |||
@@ -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) | |||