@@ -25,6 +25,7 @@ func SetCenter(c *gin.Context) { | |||||
sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, req.CentralKitchenForSchoolCancelMealTimeForBreakfast) | sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, req.CentralKitchenForSchoolCancelMealTimeForBreakfast) | ||||
sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForLunch, req.CentralKitchenForSchoolCancelMealTimeForLunch) | sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForLunch, req.CentralKitchenForSchoolCancelMealTimeForLunch) | ||||
sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForDinner, req.CentralKitchenForSchoolCancelMealTimeForDinner) | sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolCancelMealTimeForDinner, req.CentralKitchenForSchoolCancelMealTimeForDinner) | ||||
sysCfgDb.SysCfgUpdate(enum.CentralKitchenForSchoolTeacherMealNotice, req.CentralKitchenForSchoolTeacherMealNotice) | |||||
e.OutSuc(c, "success", nil) | e.OutSuc(c, "success", nil) | ||||
return | return | ||||
} | } | ||||
@@ -35,6 +36,7 @@ func GetCenter(c *gin.Context) { | |||||
res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, | res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, | ||||
enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, | enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, | ||||
enum.CentralKitchenForSchoolCancelMealTimeForLunch, | enum.CentralKitchenForSchoolCancelMealTimeForLunch, | ||||
enum.CentralKitchenForSchoolTeacherMealNotice, | |||||
enum.CentralKitchenForSchoolCancelMealTimeForDinner) | enum.CentralKitchenForSchoolCancelMealTimeForDinner) | ||||
e.OutSuc(c, res, nil) | e.OutSuc(c, res, nil) | ||||
return | return | ||||
@@ -6,6 +6,7 @@ type SetCenterReq struct { | |||||
CentralKitchenForSchoolCancelMealTimeForBreakfast string `json:"central_kitchen_for_school_cancel_meal_time_for_breakfast" binding:"required" label:"央厨取消用餐时间-早餐"` | CentralKitchenForSchoolCancelMealTimeForBreakfast string `json:"central_kitchen_for_school_cancel_meal_time_for_breakfast" binding:"required" label:"央厨取消用餐时间-早餐"` | ||||
CentralKitchenForSchoolCancelMealTimeForLunch string `json:"central_kitchen_for_school_cancel_meal_time_for_lunch" binding:"required" label:"央厨取消用餐时间-午餐"` | CentralKitchenForSchoolCancelMealTimeForLunch string `json:"central_kitchen_for_school_cancel_meal_time_for_lunch" binding:"required" label:"央厨取消用餐时间-午餐"` | ||||
CentralKitchenForSchoolCancelMealTimeForDinner string `json:"central_kitchen_for_school_cancel_meal_time_for_dinner" binding:"required" label:"央厨取消用餐时间-晚餐"` | CentralKitchenForSchoolCancelMealTimeForDinner string `json:"central_kitchen_for_school_cancel_meal_time_for_dinner" binding:"required" label:"央厨取消用餐时间-晚餐"` | ||||
CentralKitchenForSchoolTeacherMealNotice string `json:"central_kitchen_for_school_teacher_meal_notice" binding:"required" label:"教师餐说明"` | |||||
} | } | ||||
type SetCenterReqForNursingHome struct { | type SetCenterReqForNursingHome struct { | ||||
@@ -94,7 +94,7 @@ func EnterpriseInfo(c *gin.Context) { | |||||
sysCfgDb := db.SysCfgDb{} | sysCfgDb := db.SysCfgDb{} | ||||
sysCfgDb.Set() | sysCfgDb.Set() | ||||
res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, | res := sysCfgDb.SysCfgFindWithDb(enum.AdministratorContactInfo, enum.CentralKitchenForSchoolReserveMealTime, enum.CentralKitchenForSchoolCancelMealTime, | ||||
enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, enum.CentralKitchenForSchoolCancelMealTimeForLunch, enum.CentralKitchenForSchoolCancelMealTimeForDinner) | |||||
enum.CentralKitchenForSchoolCancelMealTimeForBreakfast, enum.CentralKitchenForSchoolCancelMealTimeForLunch, enum.CentralKitchenForSchoolCancelMealTimeForDinner, enum.CentralKitchenForSchoolTeacherMealNotice) | |||||
e.OutSuc(c, map[string]interface{}{ | e.OutSuc(c, map[string]interface{}{ | ||||
"info": resp, | "info": resp, | ||||
"set_center": res, | "set_center": res, | ||||
@@ -31,6 +31,7 @@ const ( | |||||
CentralKitchenForSchoolCancelMealTimeForBreakfast = "central_kitchen_for_school_cancel_meal_time_for_breakfast" | CentralKitchenForSchoolCancelMealTimeForBreakfast = "central_kitchen_for_school_cancel_meal_time_for_breakfast" | ||||
CentralKitchenForSchoolCancelMealTimeForDinner = "central_kitchen_for_school_cancel_meal_time_for_dinner" | CentralKitchenForSchoolCancelMealTimeForDinner = "central_kitchen_for_school_cancel_meal_time_for_dinner" | ||||
CentralKitchenForSchoolCancelMealTimeForLunch = "central_kitchen_for_school_cancel_meal_time_for_lunch" | CentralKitchenForSchoolCancelMealTimeForLunch = "central_kitchen_for_school_cancel_meal_time_for_lunch" | ||||
CentralKitchenForSchoolTeacherMealNotice = "central_kitchen_for_school_teacher_meal_notice" | |||||
NursingHomeReserveMealTime = "nursing_home_reserve_meal_time" | NursingHomeReserveMealTime = "nursing_home_reserve_meal_time" | ||||
NursingHomeCancelMealTime = "nursing_home_cancel_meal_time" | NursingHomeCancelMealTime = "nursing_home_cancel_meal_time" | ||||
JsapiPayAppAutToken = "jsapi_pay_app_auth_token" | JsapiPayAppAutToken = "jsapi_pay_app_auth_token" | ||||
@@ -96,6 +97,8 @@ func (gt SysCfg) String() string { | |||||
return "央厨取消用餐时间-早餐" | return "央厨取消用餐时间-早餐" | ||||
case CentralKitchenForSchoolCancelMealTimeForLunch: | case CentralKitchenForSchoolCancelMealTimeForLunch: | ||||
return "央厨取消用餐时间-午餐" | return "央厨取消用餐时间-午餐" | ||||
case CentralKitchenForSchoolTeacherMealNotice: | |||||
return "教师餐说明" | |||||
case CentralKitchenForSchoolCancelMealTimeForDinner: | case CentralKitchenForSchoolCancelMealTimeForDinner: | ||||
return "央厨取消用餐时间-晚餐" | return "央厨取消用餐时间-晚餐" | ||||
case NursingHomeReserveMealTime: | case NursingHomeReserveMealTime: | ||||
@@ -3,6 +3,7 @@ package main | |||||
import ( | import ( | ||||
"applet/app/db" | "applet/app/db" | ||||
"applet/app/db/model" | "applet/app/db/model" | ||||
"applet/app/utils" | |||||
"context" | "context" | ||||
"fmt" | "fmt" | ||||
"log" | "log" | ||||
@@ -17,36 +18,89 @@ import ( | |||||
) | ) | ||||
func main1() { | func main1() { | ||||
var m []model.CentralKitchenForSchoolUserRefundDay | |||||
if err := db.Db.Where("1=1").Desc("id").Find(&m); err != nil { | |||||
//svc.CentralKitchenForSchoolAlipayTradeFastpayRefundQuery(db.Db) | |||||
var list []model.CentralKitchenForSchoolPackageOrdForReserve | |||||
if err := db.Db.Where("create_at >= '2024-09-01 15:00:00'").Desc("id").Find(&list); err != nil { | |||||
fmt.Println(err) | fmt.Println(err) | ||||
} | } | ||||
var alreadyIds = map[int]bool{} | |||||
for _, v := range m { | |||||
if v.State != 3 && !alreadyIds[v.Id] { | |||||
var mm []model.CentralKitchenForSchoolUserRefundDay | |||||
if err := db.Db.Where("records_id = ?", v.RecordsId).And("state != 3").And("id != ?", v.Id).Find(&mm); err != nil { | |||||
fmt.Println(err) | |||||
} | |||||
var ids []int | |||||
for _, vv := range mm { | |||||
if vv.State == 4 { | |||||
if v.State == 4 { | |||||
fmt.Println(v, vv) | |||||
} | |||||
ids = append(ids, v.Id) | |||||
alreadyIds[v.Id] = true | |||||
} else { | |||||
ids = append(ids, vv.Id) | |||||
alreadyIds[vv.Id] = true | |||||
} | |||||
} | |||||
if len(ids) > 0 { | |||||
db.Db.In("id", ids).Delete(model.CentralKitchenForSchoolUserRefundDay{}) | |||||
} | |||||
// | |||||
var ordIds = map[string]string{} | |||||
for _, v := range list { | |||||
if ordIds[v.OutTradeNo+"_"+utils.AnyToString(v.Kind)+"_"+v.ReserveMonth] != "" { | |||||
continue | |||||
} | } | ||||
var tmpList []model.CentralKitchenForSchoolPackageOrdForReserve | |||||
if err := db.Db.Where("out_trade_no = ?", v.OutTradeNo).And("kind =?", v.Kind).And("reserve_month =?", v.ReserveMonth). | |||||
And("total_price =?", v.TotalPrice).Find(&tmpList); err != nil { | |||||
fmt.Println(err) | |||||
} | |||||
fmt.Println(v.OutTradeNo) | |||||
if len(tmpList) > 1 { | |||||
ordIds[v.OutTradeNo+"_"+utils.AnyToString(v.Kind)+"_"+v.ReserveMonth] = v.OutTradeNo | |||||
utils.FilePutContents("test_test_test", v.OutTradeNo) | |||||
} | |||||
// v.RecordsId = -v.RecordsId | |||||
// v.OutTradeNo = "-" + v.OutTradeNo | |||||
// affected1, err := db.Db.Where("id=?", v.Id).Cols("records_id", "out_trade_no").Update(&v) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// fmt.Println(">>>>>>>>>>>>>>>>>affected1<<<<<<<<<<<<<<<<<<<", affected1) | |||||
// continue | |||||
// var mm []model.CentralKitchenForSchoolUserRefundDay | |||||
// if err := db.Db.Where("uid = ?", v.Uid).And("state = 1").Desc("records_id").Find(&mm); err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// | |||||
// if len(mm) > 0 { | |||||
// mmm := new(model.CentralKitchenForSchoolUserWithDay) | |||||
// _, err := db.Db.Where("id =?", mm[0].RecordsId).Get(mmm) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// //if mmm.Date == "2024-01-31" { | |||||
// //1、更改当前记录 | |||||
// v.Uid = -v.Uid | |||||
// affected1, err := db.Db.Where("id=?", v.Id).Cols("uid").Update(&v) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// fmt.Println(">>>>>>>>>>>>>>>>>affected1<<<<<<<<<<<<<<<<<<<", affected1) | |||||
// vv := new(model.CentralKitchenForSchoolUserWithDay) | |||||
// _, err = db.Db.Where("id =?", v.RecordsId).Get(vv) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// vv.State = 2 | |||||
// affected11, err := db.Db.Where("id=?", vv.Id).Cols("state").Update(vv) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// fmt.Println(">>>>>>>>>>>>>>>>>affected11<<<<<<<<<<<<<<<<<<<", affected11) | |||||
// | |||||
// //2、更改兑换记录 | |||||
// mm[0].OutRequestNo = v.OutRequestNo | |||||
// mm[0].State = v.State | |||||
// mm[0].RefundDate = v.RefundDate | |||||
// mm[0].Memo = "exchange" | |||||
// affected2, err := db.Db.Where("id=?", mm[0].Id).Cols("out_request_no", "state", "refund_date", "memo").Update(mm[0]) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// fmt.Println(">>>>>>>>>>>>>>>>>affected2<<<<<<<<<<<<<<<<<<<", affected2) | |||||
// mmm.State = 4 | |||||
// affected22, err := db.Db.Where("id=?", mmm.Id).Cols("state").Update(mmm) | |||||
// if err != nil { | |||||
// fmt.Println(err) | |||||
// } | |||||
// fmt.Println(">>>>>>>>>>>>>>>>>affected22<<<<<<<<<<<<<<<<<<<", affected22) | |||||
// | |||||
// //} | |||||
// } else { | |||||
// notCanUserIds = append(notCanUserIds, v.Uid) | |||||
// } | |||||
} | } | ||||
return | |||||
r := router.Init() //创建路由 | r := router.Init() //创建路由 | ||||
srv := &http.Server{ //设置http服务参数 | srv := &http.Server{ //设置http服务参数 | ||||
@@ -1,75 +0,0 @@ | |||||
package main | |||||
import ( | |||||
"applet/app/db" | |||||
"applet/app/db/model" | |||||
"context" | |||||
"fmt" | |||||
"log" | |||||
"net/http" | |||||
"os" | |||||
"os/signal" | |||||
"syscall" | |||||
"time" | |||||
"applet/app/cfg" | |||||
"applet/app/router" | |||||
) | |||||
func main2() { | |||||
var m []model.CentralKitchenForSchoolUserRefundDay | |||||
if err := db.Db.Where("create_at >= '2024-01-15 18:00:00' AND state = 4").Desc("id").Find(&m); err != nil { | |||||
fmt.Println(err) | |||||
} | |||||
var canUserIds []int | |||||
var onlyCanUserIds []int | |||||
var notCanUserIds []int | |||||
for _, v := range m { | |||||
var mm []model.CentralKitchenForSchoolUserRefundDay | |||||
if err := db.Db.Where("uid = ?", v.Uid).And("state = 1").Desc("records_id").Find(&mm); err != nil { | |||||
fmt.Println(err) | |||||
} | |||||
if len(mm) > 0 { | |||||
canUserIds = append(canUserIds, v.Uid) | |||||
for _, vv := range mm { | |||||
mmm := new(model.CentralKitchenForSchoolUserWithDay) | |||||
_, err := db.Db.Where("id =?", vv.RecordsId).Get(mmm) | |||||
if err != nil { | |||||
fmt.Println(err) | |||||
} | |||||
if mmm.Date == "2024-01-30" { | |||||
onlyCanUserIds = append(onlyCanUserIds, v.Uid) | |||||
} | |||||
} | |||||
} else { | |||||
notCanUserIds = append(notCanUserIds, v.Uid) | |||||
} | |||||
} | |||||
r := router.Init() //创建路由 | |||||
srv := &http.Server{ //设置http服务参数 | |||||
Addr: cfg.SrvAddr, //指定ip和端口 | |||||
Handler: r, //指定路由 | |||||
} | |||||
go func() { //协程启动监听http服务 | |||||
fmt.Println("Listening and serving HTTP on " + cfg.SrvAddr) | |||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { | |||||
log.Fatalf("listen: %s\n", err) | |||||
} | |||||
}() | |||||
//退出go守护进程 | |||||
quit := make(chan os.Signal) | |||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) | |||||
<-quit | |||||
log.Println("Shutting down server...") | |||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | |||||
defer cancel() | |||||
if err := srv.Shutdown(ctx); err != nil { | |||||
log.Fatal("Server forced to shutdown:", err) | |||||
} | |||||
log.Println("Server exiting") | |||||
} |