|
|
@@ -88,7 +88,8 @@ func OrdState(c *gin.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
var hasMonths = map[string]map[string]interface{}{} |
|
|
|
var hasKinds = map[string][]string{} |
|
|
|
var hasKinds = map[string]map[string]string{} |
|
|
|
var hasTotalPrice = map[string]map[string]float64{} |
|
|
|
for _, v := range data { |
|
|
|
date, _ := time.ParseInLocation("2006-01-02", v.Date, time.Local) |
|
|
|
if hasMonths[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
@@ -106,9 +107,16 @@ func OrdState(c *gin.Context) { |
|
|
|
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_end"] = date.Format("2006-01-02") |
|
|
|
} |
|
|
|
} |
|
|
|
if hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
|
hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()] = make(map[string]float64) |
|
|
|
} |
|
|
|
if hasKinds[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()] = make(map[string]string) |
|
|
|
} |
|
|
|
|
|
|
|
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["month"] = int(utils.TimeParseStd(v.Date).Month()) |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()] = append(hasKinds[utils.TimeParseStd(v.Date).Month().String()], utils.IntToStr(v.Kind)) |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()][utils.IntToStr(v.Kind)] = utils.IntToStr(v.Kind) |
|
|
|
hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()][utils.IntToStr(v.Kind)] += utils.StrToFloat64(v.Amount) |
|
|
|
v.OrdNo = outTradeNo |
|
|
|
} |
|
|
|
|
|
|
@@ -123,28 +131,25 @@ func OrdState(c *gin.Context) { |
|
|
|
//TODO::插入数据至 `central_kitchen_for_school_package_ord_for_reserve` |
|
|
|
centralKitchenForSchoolPackageOrdForReserve := db.CentralKitchenForSchoolPackageOrdForReserve{} |
|
|
|
centralKitchenForSchoolPackageOrdForReserve.Set(outTradeNo) |
|
|
|
var isHasKind []string |
|
|
|
for k, v := range hasMonths { |
|
|
|
for _, v1 := range hasKinds[k] { |
|
|
|
if !utils.InArr(v1, isHasKind) { |
|
|
|
_, err3 := centralKitchenForSchoolPackageOrdForReserve.CentralKitchenForSchoolPackageOrdForReserveInsert(&model.CentralKitchenForSchoolPackageOrdForReserve{ |
|
|
|
EnterpriseId: ord.EnterpriseId, |
|
|
|
Uid: ord.Uid, |
|
|
|
UserIdentityName: ord.UserIdentityName, |
|
|
|
UserIdentityId: ord.UserIdentityId, |
|
|
|
Kind: utils.StrToInt(v1), |
|
|
|
OutTradeNo: ord.OutTradeNo, |
|
|
|
ReserveMonth: utils.AnyToString(v["month"]), |
|
|
|
MealTimeStart: utils.AnyToString(v["meal_time_start"]), |
|
|
|
MealTimeEnd: utils.AnyToString(v["meal_time_end"]), |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err3 != nil { |
|
|
|
e.OutErr(c, e.ERR, err3.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
isHasKind = append(isHasKind, v1) |
|
|
|
_, err3 := centralKitchenForSchoolPackageOrdForReserve.CentralKitchenForSchoolPackageOrdForReserveInsert(&model.CentralKitchenForSchoolPackageOrdForReserve{ |
|
|
|
EnterpriseId: ord.EnterpriseId, |
|
|
|
Uid: ord.Uid, |
|
|
|
UserIdentityName: ord.UserIdentityName, |
|
|
|
UserIdentityId: ord.UserIdentityId, |
|
|
|
Kind: utils.StrToInt(v1), |
|
|
|
OutTradeNo: ord.OutTradeNo, |
|
|
|
ReserveMonth: utils.AnyToString(v["month"]), |
|
|
|
MealTimeStart: utils.AnyToString(v["meal_time_start"]), |
|
|
|
MealTimeEnd: utils.AnyToString(v["meal_time_end"]), |
|
|
|
TotalPrice: utils.Float64ToStr(hasTotalPrice[k][v1]), |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|
if err3 != nil { |
|
|
|
e.OutErr(c, e.ERR, err3.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -237,7 +242,8 @@ func NursingHomeOrdState(c *gin.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
var hasMonths = map[string]map[string]interface{}{} |
|
|
|
var hasKinds = map[string][]string{} |
|
|
|
var hasKinds = map[string]map[string]string{} |
|
|
|
var hasTotalPrice = map[string]map[string]float64{} |
|
|
|
for _, v := range data { |
|
|
|
date, _ := time.ParseInLocation("2006-01-02", v.Date, time.Local) |
|
|
|
if hasMonths[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
@@ -255,9 +261,16 @@ func NursingHomeOrdState(c *gin.Context) { |
|
|
|
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["meal_time_end"] = date.Format("2006-01-02") |
|
|
|
} |
|
|
|
} |
|
|
|
if hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
|
hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()] = make(map[string]float64) |
|
|
|
} |
|
|
|
if hasKinds[utils.TimeParseStd(v.Date).Month().String()] == nil { |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()] = make(map[string]string) |
|
|
|
} |
|
|
|
|
|
|
|
hasMonths[utils.TimeParseStd(v.Date).Month().String()]["month"] = int(utils.TimeParseStd(v.Date).Month()) |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()] = append(hasKinds[utils.TimeParseStd(v.Date).Month().String()], utils.IntToStr(v.Kind)) |
|
|
|
hasKinds[utils.TimeParseStd(v.Date).Month().String()][utils.IntToStr(v.Kind)] = utils.IntToStr(v.Kind) |
|
|
|
hasTotalPrice[utils.TimeParseStd(v.Date).Month().String()][utils.IntToStr(v.Kind)] += utils.StrToFloat64(v.Amount) |
|
|
|
v.OrdNo = outTradeNo |
|
|
|
} |
|
|
|
|
|
|
@@ -269,7 +282,7 @@ func NursingHomeOrdState(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//TODO::插入数据至 `central_kitchen_for_school_package_ord_for_reserve` |
|
|
|
//TODO::插入数据至 `nursing_home_package_ord_for_reserve` |
|
|
|
centralKitchenForSchoolPackageOrdForReserve := db.NursingHomePackageOrdForReserve{} |
|
|
|
centralKitchenForSchoolPackageOrdForReserve.Set(outTradeNo) |
|
|
|
var isHasKind []string |
|
|
@@ -286,6 +299,7 @@ func NursingHomeOrdState(c *gin.Context) { |
|
|
|
ReserveMonth: utils.AnyToString(v["month"]), |
|
|
|
MealTimeStart: utils.AnyToString(v["meal_time_start"]), |
|
|
|
MealTimeEnd: utils.AnyToString(v["meal_time_end"]), |
|
|
|
TotalPrice: utils.Float64ToStr(hasTotalPrice[k][v1]), |
|
|
|
CreateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), |
|
|
|
}) |
|
|
|