소스 검색

update

master
dengbiao 3 달 전
부모
커밋
a6aba78ac6
7개의 변경된 파일907개의 추가작업 그리고 175개의 파일을 삭제
  1. +31
    -0
      app/customer/hdl/hdl_central_kitchen_for_school_package.go
  2. +9
    -0
      app/customer/md/md_enterprise.go
  3. +13
    -9
      app/customer/md/md_pay.go
  4. +298
    -133
      app/customer/svc/svc_central_kitchen_for_school_package.go
  5. +465
    -0
      app/customer/svc/svc_old_central_kitchen_for_school_package.go
  6. +80
    -24
      app/customer/svc/svc_pay.go
  7. +11
    -9
      app/db/model/central_kitchen_for_school_user_with_day.go

+ 31
- 0
app/customer/hdl/hdl_central_kitchen_for_school_package.go 파일 보기

@@ -2,6 +2,7 @@ package hdl

import (
"applet/app/customer/md"
"applet/app/customer/svc"
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
@@ -12,6 +13,7 @@ import (

func CentralKitchenForSchoolPackage(c *gin.Context) {
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", ""))

//1、查询出当前合适的package
var m []model.CentralKitchenForSchoolPackage
now := time.Now().Format("2006-01-02 15:04:05")
@@ -51,6 +53,35 @@ func CentralKitchenForSchoolPackage(c *gin.Context) {
}
resp = append(resp, tempResp)
}

//3、查询对应年级下餐标
userIdentityId := c.DefaultQuery("user_identity_id", "")
if userIdentityId != "" {
err1, mealLabelListForBreakfast := svc.GetUserIdentityForGradeWithMealLabel(userIdentityId, 1) //获取早餐
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}

err1, mealLabelListForLunch := svc.GetUserIdentityForGradeWithMealLabel(userIdentityId, 2) //获取wu餐
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
err1, mealLabelListForDinner := svc.GetUserIdentityForGradeWithMealLabel(userIdentityId, 3) //获取wu餐
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
e.OutSuc(c, map[string]interface{}{
"list": resp,
"meal_label_list_for_break_fast": mealLabelListForBreakfast,
"meal_label_list_for_break_lunch": mealLabelListForLunch,
"meal_label_list_for_break_dinner": mealLabelListForDinner,
}, nil)
return
}

e.OutSuc(c, map[string]interface{}{
"list": resp,
}, nil)


+ 9
- 0
app/customer/md/md_enterprise.go 파일 보기

@@ -59,6 +59,15 @@ type FindCentralKitchenForSchoolPackageReq struct {
IsOpenDinner int32 `json:"is_open_dinner"`
IsOpenReplenish int32 `json:"is_open_replenish"`
} `json:"date_list" binding:"required" label:"日期"`
//MealLabelListForBreakFast []MealLabelList `json:"meal_label_list_for_break_fast" label:"早餐-餐标集合"`
//MealLabelListForLunch []MealLabelList `json:"meal_label_list_for_break_lunch" label:"午餐-餐标集合"`
//MealLabelListForDinner []MealLabelList `json:"meal_label_list_for_break_dinner" label:"晚餐-餐标集合"`
}

type MealLabelList struct {
Id int `json:"id" label:"id"`
Name string `json:"name" binding:"required" label:"餐标名称"`
Price string `json:"price" binding:"required" label:"单价"`
}

type FindNursingHomePackageReq struct {


+ 13
- 9
app/customer/md/md_pay.go 파일 보기

@@ -1,15 +1,19 @@
package md

type BuyPackageReq struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
UserIdentityId int `json:"user_identity_id" binding:"required" label:"用户身份id"`
PackageId int `json:"package_id" label:"套餐ID"`
PackageIds []int `json:"package_ids" label:"套餐ID"`
Kind int `json:"kind" binding:"required" label:"购买类型(1:按学期购买 2:按月购买 3:按天购买 4:补餐)"`
IsBuyBreakfast int `json:"is_buy_breakfast" label:"是否购买早餐(1:是 2:否)"`
IsBuyLunch int `json:"is_buy_lunch" label:"是否购买午餐(1:是 2:否)"`
IsBuyDinner int `json:"is_buy_dinner" label:"是否购买晚餐(1:是 2:否)"`
WithDays []struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
UserIdentityId int `json:"user_identity_id" binding:"required" label:"用户身份id"`
PackageId int `json:"package_id" label:"套餐ID"`
PackageIds []int `json:"package_ids" label:"套餐ID"`
Kind int `json:"kind" binding:"required" label:"购买类型(1:按学期购买 2:按月购买 3:按天购买 4:补餐)"`
IsBuyByMealLabel bool `json:"is_buy_by_meal_label" label:"是否通过餐标购买"`
IsBuyBreakfast int `json:"is_buy_breakfast" label:"是否购买早餐(1:是 2:否)"`
MealLabelIdForBreakfast int `json:"meal_label_id_for_breakfast" label:"早餐餐标id"`
IsBuyLunch int `json:"is_buy_lunch" label:"是否购买午餐(1:是 2:否)"`
MealLabelIdForLunch int `json:"meal_label_id_for_lunch" label:"午餐餐标id"`
IsBuyDinner int `json:"is_buy_dinner" label:"是否购买晚餐(1:是 2:否)"`
MealLabelIdForDinner int `json:"meal_label_id_for_dinner" label:"晚餐餐标id"`
WithDays []struct {
Date string `json:"date" label:"日期"`
IsBuyBreakfast int `json:"is_buy_breakfast" label:"是否购买早餐(1:是 2:否)"`
IsBuyLunch int `json:"is_buy_lunch" label:"是否购买午餐(1:是 2:否)"`


+ 298
- 133
app/customer/svc/svc_central_kitchen_for_school_package.go 파일 보기

@@ -7,6 +7,8 @@ import (
"applet/app/db/model"
"applet/app/enum"
"applet/app/utils"
"errors"
"fmt"
"time"
)

@@ -25,11 +27,45 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return

//classWithUserDb := db.ClassWithUserDb{}
//classWithUserDb.Set()
//classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
//if err != nil {
// return
//}
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(buyPackageReq.EnterpriseId)
var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel
if buyPackageReq.IsBuyBreakfast == 1 {
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForBreakfast == nil {
err = errors.New("未查询到早餐餐标记录")
return
}
}
if buyPackageReq.IsBuyLunch == 1 {
mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForLunch == nil {
err = errors.New("未查询到午餐餐标记录")
return
}
}
if buyPackageReq.IsBuyDinner == 1 {
mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForDinner == nil {
err = errors.New("未查询到晚餐餐标记录")
return
}
}

//2、查询出当前合适的package
@@ -73,17 +109,19 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
amount = mealLabelForBreakfast.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForBreakfast.Id,
MealLabelName: mealLabelForBreakfast.Name,
})
}

@@ -92,18 +130,20 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
amount = mealLabelForLunch.Price
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForLunch.Id,
MealLabelName: mealLabelForLunch.Name,
})
}

@@ -112,17 +152,19 @@ func CalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq)
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
amount = mealLabelForDinner.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForDinner.Id,
MealLabelName: mealLabelForDinner.Name,
})
}
}
@@ -146,11 +188,45 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return

//classWithUserDb := db.ClassWithUserDb{}
//classWithUserDb.Set()
//classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
//if err != nil {
// return
//}
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(buyPackageReq.EnterpriseId)
var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel
if buyPackageReq.IsBuyBreakfast == 1 {
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForBreakfast == nil {
err = errors.New("未查询到早餐餐标记录")
return
}
}
if buyPackageReq.IsBuyLunch == 1 {
mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForLunch == nil {
err = errors.New("未查询到午餐餐标记录")
return
}
}
if buyPackageReq.IsBuyDinner == 1 {
mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForDinner == nil {
err = errors.New("未查询到晚餐餐标记录")
return
}
}

//2、查询出当前合适的package
@@ -194,18 +270,19 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
amount = mealLabelForBreakfast.Price
}

totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForBreakfast.Id,
MealLabelName: mealLabelForBreakfast.Name,
})
}

@@ -214,18 +291,20 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
amount = mealLabelForLunch.Price
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForLunch.Id,
MealLabelName: mealLabelForLunch.Name,
})
}

@@ -234,17 +313,19 @@ func CalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (tota
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
amount = mealLabelForDinner.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForDinner.Id,
MealLabelName: mealLabelForDinner.Name,
})
}
}
@@ -267,11 +348,45 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return

//classWithUserDb := db.ClassWithUserDb{}
//classWithUserDb.Set()
//classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
//if err != nil {
// return
//}
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(buyPackageReq.EnterpriseId)
var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel
if buyPackageReq.IsBuyBreakfast == 1 {
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForBreakfast == nil {
err = errors.New("未查询到早餐餐标记录")
return
}
}
if buyPackageReq.IsBuyLunch == 1 {
mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForLunch == nil {
err = errors.New("未查询到午餐餐标记录")
return
}
}
if buyPackageReq.IsBuyDinner == 1 {
mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForDinner == nil {
err = errors.New("未查询到晚餐餐标记录")
return
}
}

now := time.Now()
@@ -301,19 +416,20 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
amount = mealLabelForBreakfast.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForBreakfast.Id,
MealLabelName: mealLabelForBreakfast.Name,
})
totalPrice += utils.StrToFloat64(amount)
}

if v1.IsBuyLunch == 1 && buyPackageReq.IsBuyLunch == 1 {
@@ -321,17 +437,20 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
amount = mealLabelForLunch.Price
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Amount: amount,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForLunch.Id,
MealLabelName: mealLabelForLunch.Name,
})
}

@@ -340,17 +459,19 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
amount = mealLabelForDinner.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForDinner.Id,
MealLabelName: mealLabelForDinner.Name,
})
}
}
@@ -359,12 +480,6 @@ func CalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalP
}

func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
//sysCfgDb := db.SysCfgDb{}
//sysCfgDb.Set()
//cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
//if err != nil {
// return
//}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
@@ -373,18 +488,46 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

//now := time.Now()
//today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
//tomorrowDay := today.AddDate(0, 0, 1)

//centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)
//classWithUserDb := db.ClassWithUserDb{}
//classWithUserDb.Set()
//classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
//if err != nil {
// return
//}
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(buyPackageReq.EnterpriseId)
var mealLabelForBreakfast, mealLabelForLunch, mealLabelForDinner *model.MealLabel
if buyPackageReq.IsBuyBreakfast == 1 {
mealLabelForBreakfast, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForBreakfast == nil {
err = errors.New("未查询到早餐餐标记录")
return
}
}
if buyPackageReq.IsBuyLunch == 1 {
mealLabelForLunch, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForLunch == nil {
err = errors.New("未查询到午餐餐标记录")
return
}
}
if buyPackageReq.IsBuyDinner == 1 {
mealLabelForDinner, err = mealLabelDb.GetMealLabel(buyPackageReq.MealLabelIdForBreakfast)
if err != nil {
return
}
if mealLabelForDinner == nil {
err = errors.New("未查询到晚餐餐标记录")
return
}
}

//2、循环拼接数据
for _, v1 := range buyPackageReq.WithDays {
@@ -407,19 +550,20 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
amount = mealLabelForBreakfast.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForBreakfast.Id,
MealLabelName: mealLabelForBreakfast.Name,
})
totalPrice += utils.StrToFloat64(amount)
}

if v1.IsBuyLunch == 1 && buyPackageReq.IsBuyLunch == 1 {
@@ -427,17 +571,20 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
amount = mealLabelForLunch.Price
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Amount: amount,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForLunch.Id,
MealLabelName: mealLabelForLunch.Name,
})
}

@@ -446,20 +593,38 @@ func CalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackag
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
amount = mealLabelForDinner.Price
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
MealLabelId: mealLabelForDinner.Id,
MealLabelName: mealLabelForDinner.Name,
})
}
}

return
}

func GetUserIdentityForGradeWithMealLabel(userIdentityId string, kind int32) (err error, resp []md2.MealLabelList) {
sql := fmt.Sprintf("SELECT ml.* FROM class_with_user cwu INNER JOIN class c ON cwu.class_id = c.id INNER JOIN grade g ON c.grade_id = g.id LEFT JOIN meal_label ml ON g.id = ml.grade_id WHERE cwu.`user_identity_id`= %s AND ml.kind = %d;", userIdentityId, kind)
nativeString, err := db.QueryNativeString(db.Db, sql)
if err != nil {
return err, nil
}
for _, v := range nativeString {
resp = append(resp, md2.MealLabelList{
Id: utils.StrToInt(v["id"]),
Name: v["name"],
Price: v["price"],
})
}
return
}

+ 465
- 0
app/customer/svc/svc_old_central_kitchen_for_school_package.go 파일 보기

@@ -0,0 +1,465 @@
package svc

import (
"applet/app/admin/md"
md2 "applet/app/customer/md"
"applet/app/db"
"applet/app/db/model"
"applet/app/enum"
"applet/app/utils"
"time"
)

func OldCalcBySchoolTerm(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
if err != nil {
return
}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(buyPackageReq.EnterpriseId)
centralKitchenForSchoolWithSpecData, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

//2、查询出当前合适的package
var m []model.CentralKitchenForSchoolPackage
now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)

err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).In("id", buyPackageReq.PackageIds).And("is_delete = 0").And("state = 1").Desc("end_date").Find(&m)
if err != nil {
return
}
centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)

//3、循环拼接数据
for _, v := range m {
centralKitchenForSchoolPackageWithDayDb := db.CentralKitchenForSchoolPackageWithDayDb{}
centralKitchenForSchoolPackageWithDayDb.Set(v.Id)
centralKitchenForSchoolPackageWithDay, err1 := centralKitchenForSchoolPackageWithDayDb.FindCentralKitchenForSchoolPackageWithDay()
if err1 != nil {
return
}
for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) || today.Equal(date) {
continue
}

if tomorrowDay.Equal(date) {
//2.2、判断是否过了明日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) {
continue
}
}

//3.3、计算价格 && 组装数据
if v1.IsOpenBreakfast == md.OpenBreakfast && buyPackageReq.IsBuyBreakfast == 1 {
//早餐
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}

if v1.IsOpenLunch == md.OpenLunch && buyPackageReq.IsBuyLunch == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}

if v1.IsOpenDinner == md.OpenDinner && buyPackageReq.IsBuyDinner == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}
}

}
return
}

func OldCalcByMonth(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
if err != nil {
return
}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(buyPackageReq.EnterpriseId)
centralKitchenForSchoolWithSpecData, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

//2、查询出当前合适的package
var m []model.CentralKitchenForSchoolPackage
now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)

err = db.Db.Where("enterprise_id =?", buyPackageReq.EnterpriseId).And("id =?", buyPackageReq.PackageId).And("is_delete = 0").And("state = 1").Find(&m)
if err != nil {
return
}
centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)

//3、循环拼接数据
for _, v := range m {
centralKitchenForSchoolPackageWithDayDb := db.CentralKitchenForSchoolPackageWithDayDb{}
centralKitchenForSchoolPackageWithDayDb.Set(v.Id)
centralKitchenForSchoolPackageWithDay, err1 := centralKitchenForSchoolPackageWithDayDb.FindCentralKitchenForSchoolPackageWithDay()
if err1 != nil {
return
}
for _, v1 := range *centralKitchenForSchoolPackageWithDay {
//3.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) || today.Equal(date) {
continue
}

if tomorrowDay.Equal(date) {
//2.2、判断是否过了今日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) {
continue
}
}

//3.3、计算价格 && 组装数据
if v1.IsOpenBreakfast == md.OpenBreakfast && buyPackageReq.IsBuyBreakfast == 1 {
//早餐
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
}

totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}

if v1.IsOpenLunch == md.OpenLunch && buyPackageReq.IsBuyLunch == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
}
totalPrice += utils.StrToFloat64(amount)

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Amount: amount,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}

if v1.IsOpenDinner == md.OpenDinner && buyPackageReq.IsBuyDinner == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}
}
}
return
}

func OldCalcByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
sysCfgDb := db.SysCfgDb{}
sysCfgDb.Set()
cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
if err != nil {
return
}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(buyPackageReq.EnterpriseId)
centralKitchenForSchoolWithSpecData, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

now := time.Now()
today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
tomorrowDay := today.AddDate(0, 0, 1)

centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)

//2、循环拼接数据
for _, v1 := range buyPackageReq.WithDays {
//2.1、判断是否小于今天
date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
if today.After(date) || today.Equal(date) {
continue
}
if tomorrowDay.Equal(date) {
//2.2、判断是否过了今日可订餐时间
if now.After(centralKitchenForSchoolReserveMealTime) {
continue
}
}

//2.3、计算价格 && 组装数据
if v1.IsBuyBreakfast == 1 && buyPackageReq.IsBuyBreakfast == 1 {
//早餐
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
}

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
totalPrice += utils.StrToFloat64(amount)
}

if v1.IsBuyLunch == 1 && buyPackageReq.IsBuyLunch == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Amount: amount,
})
}

if v1.IsBuyDinner == 1 && buyPackageReq.IsBuyDinner == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}
}

return
}

func OldCalcSupplementaryByDay(uid int, isTeacher bool, buyPackageReq md2.BuyPackageReq) (totalPrice float64, data []*model.CentralKitchenForSchoolUserWithDay, err error) {
//sysCfgDb := db.SysCfgDb{}
//sysCfgDb.Set()
//cfg, err := sysCfgDb.SysCfgGetOne(enum.CentralKitchenForSchoolReserveMealTime)
//if err != nil {
// return
//}

//1、查询出套餐基础设置
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(buyPackageReq.EnterpriseId)
centralKitchenForSchoolWithSpecData, err := centralKitchenForSchoolWithSpec.GetCentralKitchenForSchoolWithSpec()
if err != nil {
return
}
classWithUserDb := db.ClassWithUserDb{}
classWithUserDb.Set()
classWithUserInfo, err := classWithUserDb.GetInfoByUserIdentityId(buyPackageReq.UserIdentityId)
if err != nil {
return
}

//now := time.Now()
//today, _ := time.ParseInLocation("2006-01-02", time.Now().Format("2006-01-02"), time.Local)
//tomorrowDay := today.AddDate(0, 0, 1)

//centralKitchenForSchoolReserveMealTime, _ := time.ParseInLocation("2006-01-02 15:04:05", now.Format("2006-01-02")+" "+cfg.Val+":00", time.Local)

//2、循环拼接数据
for _, v1 := range buyPackageReq.WithDays {
//2.1、判断是否小于今天
//date, _ := time.ParseInLocation("2006-01-02", v1.Date, time.Local)
//if today.After(date) || today.Equal(date) {
// continue
//}
//if tomorrowDay.Equal(date) {
// //2.2、判断是否过了今日可订餐时间
// if now.After(centralKitchenForSchoolReserveMealTime) {
// continue
// }
//}

//2.3、计算价格 && 组装数据
if v1.IsBuyBreakfast == 1 && buyPackageReq.IsBuyBreakfast == 1 {
//早餐
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.BreakfastUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.BreakfastUnitPrice
}

data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
Date: v1.Date,
Amount: amount,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
totalPrice += utils.StrToFloat64(amount)
}

if v1.IsBuyLunch == 1 && buyPackageReq.IsBuyLunch == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.LunchUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.LunchUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForLunch,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
Amount: amount,
})
}

if v1.IsBuyDinner == 1 && buyPackageReq.IsBuyDinner == 1 {
var amount string
if isTeacher {
amount = centralKitchenForSchoolWithSpecData.DinnerUnitPriceForTeacher
} else {
amount = classWithUserInfo.Period.DinnerUnitPrice
}
totalPrice += utils.StrToFloat64(amount)
data = append(data, &model.CentralKitchenForSchoolUserWithDay{
Uid: uid,
EnterpriseId: buyPackageReq.EnterpriseId,
IdentityId: buyPackageReq.UserIdentityId,
Kind: enum.CentralKitchenForSchoolUserWithDayKindForDinner,
Amount: amount,
Date: v1.Date,
State: enum.CentralKitchenForSchoolUserWithDayStateForWait,
})
}
}

return
}

+ 80
- 24
app/customer/svc/svc_pay.go 파일 보기

@@ -54,27 +54,55 @@ func BuyPackageForAli(c *gin.Context, req md.BuyPackageReq) (outTradeNo, tradeNo
var totalPrice float64
var data []*model.CentralKitchenForSchoolUserWithDay
if req.Kind == 1 {
totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 2 {
totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 3 {
totalPrice, data, err = CalcByDay(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 4 {
totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
total = utils.Float64ToStr(totalPrice)
@@ -169,27 +197,55 @@ func BuyPackageForWx(c *gin.Context, req md.BuyPackageReq) (outTradeNo, total st
var totalPrice float64
var data []*model.CentralKitchenForSchoolUserWithDay
if req.Kind == 1 {
totalPrice, data, err = CalcBySchoolTerm(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 2 {
totalPrice, data, err = CalcByMonth(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 3 {
totalPrice, data, err = CalcByDay(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
if req.Kind == 4 {
totalPrice, data, err = CalcSupplementaryByDay(user.Id, isTeacher, req)
if err != nil {
return
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
}
}
}
total = utils.Float64ToStr(totalPrice)


+ 11
- 9
app/db/model/central_kitchen_for_school_user_with_day.go 파일 보기

@@ -1,13 +1,15 @@
package model

type CentralKitchenForSchoolUserWithDay struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
OrdNo string `json:"ord_no" xorm:"not null default '' comment('订单号') VARCHAR(50)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('校企id') INT(11)"`
IdentityId int `json:"identity_id" xorm:"not null default 0 comment('身份id') INT(11)"`
Kind int `json:"kind" xorm:"not null default 1 comment('就餐类型(1:早餐 2:午餐 3:晚餐)') TINYINT(1)"`
Amount string `json:"amount" xorm:"not null default '' comment('金额') CHAR(50)"`
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"`
State int `json:"state" xorm:"not null default 1 comment('状态(1:待就餐 2:已就餐 3:退款中 4:已退款)') TINYINT(1)"`
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
OrdNo string `json:"ord_no" xorm:"not null default '' comment('订单号') VARCHAR(50)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('校企id') INT(11)"`
IdentityId int `json:"identity_id" xorm:"not null default 0 comment('身份id') INT(11)"`
Kind int `json:"kind" xorm:"not null default 1 comment('就餐类型(1:早餐 2:午餐 3:晚餐)') TINYINT(1)"`
Amount string `json:"amount" xorm:"not null default '' comment('金额') CHAR(50)"`
MealLabelId int `json:"meal_label_id" xorm:"not null default '' comment('餐标id') INT(11)"`
MealLabelName string `json:"meal_label_name" xorm:"not null default '' comment('餐标名称') CHAR(50)"`
Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"`
State int `json:"state" xorm:"not null default 1 comment('状态(1:待就餐 2:已就餐 3:退款中 4:已退款)') TINYINT(1)"`
}

불러오는 중...
취소
저장