Browse Source

update

add_mode
DengBiao 1 year ago
parent
commit
ce3a684fb7
2 changed files with 40 additions and 25 deletions
  1. +39
    -25
      app/customer/hdl/hdl_pay.go
  2. +1
    -0
      app/db/model/nursing_home_package_ord_for_reserve.go

+ 39
- 25
app/customer/hdl/hdl_pay.go View File

@@ -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"),
})


+ 1
- 0
app/db/model/nursing_home_package_ord_for_reserve.go View File

@@ -11,6 +11,7 @@ type NursingHomePackageOrdForReserve struct {
ReserveMonth string `json:"reserve_month" xorm:"not null default '' comment('预定月份') CHAR(50)"`
MealTimeStart string `json:"meal_time_start" xorm:"not null default '0000-00-00' comment('就餐时间-开始') CHAR(50)"`
MealTimeEnd string `json:"meal_time_end" xorm:"not null default '0000-00-00' comment('就餐时间-截止') CHAR(50)"`
TotalPrice string `json:"total_price" xorm:"not null default 0.00 comment('总金额') DECIMAL(8,2)"`
CreateAt string `json:"create_at" xorm:"not null pk default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

Loading…
Cancel
Save