Browse Source

update

tmp
DengBiao 10 months ago
parent
commit
efaec745d2
10 changed files with 371 additions and 0 deletions
  1. +1
    -0
      app/admin/hdl/hdl_suggested_feedback.go
  2. +1
    -0
      app/admin/md/md_suggested_feedback.go
  3. +19
    -0
      app/customer/hdl/hdl_notice.go
  4. +109
    -0
      app/customer/hdl/hdl_suggested_feed_back.go
  5. +12
    -0
      app/customer/md/md_suggested_feddback.go
  6. +8
    -0
      app/router/customer_router.go
  7. +1
    -0
      go.mod
  8. +69
    -0
      main.go
  9. +76
    -0
      main_back.go
  10. +75
    -0
      main_copy.go

+ 1
- 0
app/admin/hdl/hdl_suggested_feedback.go View File

@@ -57,6 +57,7 @@ func SuggestedFeedbackList(c *gin.Context) {
kind = 1 kind = 1
} }
resp = append(resp, md.SuggestedFeedbackListResp{ resp = append(resp, md.SuggestedFeedbackListResp{
Id: v.SuggestedFeedback.Id,
EnterpriseId: v.Enterprise.Id, EnterpriseId: v.Enterprise.Id,
EnterpriseName: v.Enterprise.Name, EnterpriseName: v.Enterprise.Name,
Uid: v.User.Id, Uid: v.User.Id,


+ 1
- 0
app/admin/md/md_suggested_feedback.go View File

@@ -11,6 +11,7 @@ type SuggestedFeedbackListReq struct {
} }


type SuggestedFeedbackListResp struct { type SuggestedFeedbackListResp struct {
Id int `json:"id" `
EnterpriseId int `json:"enterprise_id" ` EnterpriseId int `json:"enterprise_id" `
EnterpriseName string `json:"enterprise_name" ` EnterpriseName string `json:"enterprise_name" `
Uid int `json:"uid" ` Uid int `json:"uid" `


+ 19
- 0
app/customer/hdl/hdl_notice.go View File

@@ -19,3 +19,22 @@ func NoticeList(c *gin.Context) {
}, nil) }, nil)
return return
} }

func PopCentralKitchen(c *gin.Context) {
noticeDb := db.NoticeDb{}
noticeDb.Set()
notices, err := noticeDb.GetPopToCentralKitchen()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var isPop bool
if notices == nil {
isPop = true
}
e.OutSuc(c, map[string]interface{}{
"data": notices,
"is_pop": isPop,
}, nil)
return
}

+ 109
- 0
app/customer/hdl/hdl_suggested_feed_back.go View File

@@ -0,0 +1,109 @@
package hdl

import (
"applet/app/customer/lib/validate"
"applet/app/customer/md"
"applet/app/customer/svc"
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"time"
)

func SuggestedFeedbackList(c *gin.Context) {
var req md.SuggestedFeedbackListReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
if req.Limit == 0 {
req.Limit = 10
}
if req.Page == 0 {
req.Page = 1
}
var m []*model.SuggestedFeedback
total, err := db.Db.Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
type respStruct struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null comment('用户id') INT(11)"`
UserIdentityId int `json:"user_identity_id" xorm:"not null comment('身份id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null comment('单位id') INT(11)"`
Kind int `json:"kind" `
Content string `json:"content" xorm:"not null default '' comment('反馈内容') VARCHAR(255)"`
ReplyContent string `json:"reply_content" xorm:"not null default '' comment('回复内容') VARCHAR(255)"`
ReplyDate string `json:"reply_date" xorm:"not null default '' comment('回复时间') CHAR(50)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}
var list []respStruct
for _, v := range m {
var tmp respStruct
err = copier.Copy(&tmp, v)
fmt.Println(err)
kind := 2
if v.ReplyDate != "" {
kind = 1
}
tmp.Kind = kind
list = append(list, tmp)
}
e.OutSuc(c, map[string]interface{}{
"list": list,
"total": total,
"kind_list": []map[string]interface{}{
{
"name": "已回复",
"value": 1,
},
{
"name": "未回复",
"value": 2,
},
},
}, nil)
return
}

func SuggestedFeedbackAdd(c *gin.Context) {
var req md.SuggestedFeedbackAddReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

suggestedFeedbackDb := db.SuggestedFeedbackDb{}
suggestedFeedbackDb.Set()
user := svc.GetUser(c)
now := time.Now()
insertAffected, err := suggestedFeedbackDb.SuggestedFeedbackInsert(&model.SuggestedFeedback{
Uid: user.Id,
UserIdentityId: req.UserIdentityId,
EnterpriseId: req.EnterpriseId,
Content: req.Content,
ReplyContent: "",
ReplyDate: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
if insertAffected <= 0 {
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败")
return
}

e.OutSuc(c, "success", nil)
return
}

+ 12
- 0
app/customer/md/md_suggested_feddback.go View File

@@ -0,0 +1,12 @@
package md

type SuggestedFeedbackListReq struct {
Limit int `json:"limit"`
Page int `json:"page" `
UserIdentityId int `json:"user_identity_id" `
}
type SuggestedFeedbackAddReq struct {
UserIdentityId int `json:"user_identity_id" `
EnterpriseId int `json:"enterprise_id" `
Content string `json:"content" `
}

+ 8
- 0
app/router/customer_router.go View File

@@ -15,6 +15,7 @@ func CustomerInit(r *gin.RouterGroup) {
rSelfSupportForSchoolOrder(r.Group("/order/selfSupportForSchool")) rSelfSupportForSchoolOrder(r.Group("/order/selfSupportForSchool"))
rSelfSupportForSchool(r.Group("/selfSupportForSchool")) rSelfSupportForSchool(r.Group("/selfSupportForSchool"))
rUserIdentity(r.Group("/userIdentity")) rUserIdentity(r.Group("/userIdentity"))
rApiSuggestedFeedback(r.Group("/suggestedFeedback"))
rTest(r.Group("/test")) rTest(r.Group("/test"))


r.GET("/sanHu", hdl.SanHu) r.GET("/sanHu", hdl.SanHu)
@@ -61,6 +62,7 @@ func CustomerInit(r *gin.RouterGroup) {
r.Group("/notice") r.Group("/notice")
{ {
r.GET("notice/list", hdl.NoticeList) r.GET("notice/list", hdl.NoticeList)
r.GET("notice/popCentralKitchen", hdl.PopCentralKitchen)
} }


r.Group("/banner") r.Group("/banner")
@@ -125,3 +127,9 @@ func rUserIdentity(r *gin.RouterGroup) { //用户身份
r.POST("/updateSelfSupportForSchoolUserIdentity", hdl.UpdateSelfSupportForSchoolUserIdentity) // 修改"自营-学校"学生身份信息 r.POST("/updateSelfSupportForSchoolUserIdentity", hdl.UpdateSelfSupportForSchoolUserIdentity) // 修改"自营-学校"学生身份信息
r.POST("/updateNursingHomeUserIdentity", hdl.UpdateNursingHomeUserIdentity) // 修改"养老院"身份信息 r.POST("/updateNursingHomeUserIdentity", hdl.UpdateNursingHomeUserIdentity) // 修改"养老院"身份信息
} }

func rApiSuggestedFeedback(r *gin.RouterGroup) { //反馈建议
r.Use(mw.Auth) //检测登录状态
r.POST("/list", hdl.SuggestedFeedbackList) // 列表
r.POST("/add", hdl.SuggestedFeedbackAdd) // 新增
}

+ 1
- 0
go.mod View File

@@ -40,6 +40,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/gookit/color v1.3.6 // indirect github.com/gookit/color v1.3.6 // indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect github.com/kr/text v0.2.0 // indirect


+ 69
- 0
main.go View File

@@ -30,6 +30,75 @@ func init() {
} }


func main() { func main() {
//svc.CentralKitchenForSchoolAlipayTradeFastpayRefundQuery(db.Db)
//var list []model.CentralKitchenForSchoolUserRefundDay
//if err := db.Db.Where("create_at >= '2024-01-15 18:00:00' AND state = 4 and uid < 0").Desc("id").Find(&list); err != nil {
// fmt.Println(err)
//}
//
//var notCanUserIds []int
//for _, v := range list {
// 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)
// }
//}
r := router.Init() //创建路由 r := router.Init() //创建路由


srv := &http.Server{ //设置http服务参数 srv := &http.Server{ //设置http服务参数


+ 76
- 0
main_back.go View File

@@ -0,0 +1,76 @@
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 main1() {
var m []model.CentralKitchenForSchoolUserRefundDay
if err := db.Db.Where("1=1").Desc("id").Find(&m); err != nil {
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{})
}
}

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

}

+ 75
- 0
main_copy.go View File

@@ -0,0 +1,75 @@
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")

}

Loading…
Cancel
Save