Просмотр исходного кода

Merge branch 'dwl'

# Conflicts:
#	api/v1/enter.go
#	config.yaml
#	initialize/router.go
#	router/enter.go
#	service/enter.go
倚楼听风雨 лет назад: 3
Родитель
Сommit
92f91cb94d
32 измененных файлов с 1548 добавлено и 29 удалено
  1. 6 6
      api/v1/enter.go
  2. 17 0
      api/v1/rentComputer/enter.go
  3. 138 0
      api/v1/rentComputer/rent_computer.go
  4. 109 0
      api/v1/rentComputer/rent_computer_shop.go
  5. 110 0
      api/v1/rentComputer/rent_set_meal.go
  6. 2 2
      api/v1/typeManage/gameList.go
  7. 8 10
      initialize/redis.go
  8. 4 0
      initialize/router.go
  9. 26 0
      model/rentComputer/rent_computer.go
  10. 14 0
      model/rentComputer/rent_computer_shop.go
  11. 19 0
      model/rentComputer/rent_set_meal.go
  12. 28 0
      model/rentComputer/request/common.go
  13. 33 0
      model/rentComputer/request/rent_computer.go
  14. 21 0
      model/rentComputer/request/rent_computer_shop.go
  15. 24 0
      model/rentComputer/request/rent_set_meal.go
  16. 8 0
      model/rentComputer/response/common.go
  17. 27 0
      model/rentComputer/response/rent_computer.go
  18. 10 0
      model/rentComputer/response/rent_computer_shop.go
  19. 14 0
      model/rentComputer/response/rent_set_meal.go
  20. 50 0
      model/typeManage/dataInsert_test.go
  21. BIN
      resource/excel/RentComputerTemplate.xlsx
  22. 8 6
      router/enter.go
  23. 9 0
      router/rentComputer/enter.go
  24. 24 0
      router/rentComputer/rent_computer.go
  25. 23 0
      router/rentComputer/rent_computer_shop.go
  26. 23 0
      router/rentComputer/rent_set_meal.go
  27. 7 5
      service/enter.go
  28. 9 0
      service/rentComputer/enter.go
  29. 381 0
      service/rentComputer/rent_computer.go
  30. 188 0
      service/rentComputer/rent_computer_shop.go
  31. 204 0
      service/rentComputer/rent_set_meal.go
  32. 4 0
      service/typeManage/tm_gameList.go

+ 6 - 6
api/v1/enter.go

@@ -3,17 +3,17 @@ package v1
 import (
 import (
 	"log-server/api/v1/example"
 	"log-server/api/v1/example"
 	"log-server/api/v1/log"
 	"log-server/api/v1/log"
+	"log-server/api/v1/rentComputer"
 	"log-server/api/v1/system"
 	"log-server/api/v1/system"
-	"log-server/api/v1/task"
 	"log-server/api/v1/typeManage"
 	"log-server/api/v1/typeManage"
 )
 )
 
 
 type ApiGroup struct {
 type ApiGroup struct {
-	SystemApiGroup  system.ApiGroup
-	ExampleApiGroup example.ApiGroup
-	LogApiGroup     log.GroupLog
-	TypeApiGroup    typeManage.ApiGroup
-	TaskApiGroup    task.GroupTask
+	SystemApiGroup       system.ApiGroup
+	ExampleApiGroup      example.ApiGroup
+	LogApiGroup          log.GroupLog
+	TypeApiGroup         typeManage.ApiGroup
+	RentComputerApiGroup rentComputer.ApiGroup
 }
 }
 
 
 var ApiGroupApp = new(ApiGroup)
 var ApiGroupApp = new(ApiGroup)

+ 17 - 0
api/v1/rentComputer/enter.go

@@ -0,0 +1,17 @@
+package rentComputer
+
+import "log-server/service"
+
+type ApiGroup struct {
+	// Code generated by log-server Begin; DO NOT EDIT.
+	ApiRentComputer
+	ApiRentComputerShop
+	ApiRentSetMeal
+	// Code generated by log-server End; DO NOT EDIT.
+}
+
+var (
+	ServiceRentComputer     = service.ServiceGroupApp.RentComputerServiceGroup.ServiceRentComputer
+	ServiceRentComputerShop = service.ServiceGroupApp.RentComputerServiceGroup.ServiceRentComputerShop
+	ServiceRentSetMeal      = service.ServiceGroupApp.RentComputerServiceGroup.ServiceRentSetMeal
+)

+ 138 - 0
api/v1/rentComputer/rent_computer.go

@@ -0,0 +1,138 @@
+package rentComputer
+
+import (
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+	"log-server/global"
+	"log-server/model/log/response"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/utils"
+	"os"
+	"strconv"
+	"time"
+)
+
+type ApiRentComputer struct {
+}
+
+func (s *ApiRentComputer) GetRentComputerList(c *gin.Context) {
+	//global.GVA_LOG.Info("api----GetComputerList----strat")
+	var paramsInfo request.GetStatisticsComputerRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}*/
+	list, total, err := ServiceRentComputer.RentComputerList(c, paramsInfo.RentComputer, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+func (s *ApiRentComputer) GetRentComputerNum(c *gin.Context) {
+	num := ServiceRentComputer.GetRentComputerNum()
+	response.OkWithDetailed(num, "获取成功", c)
+}
+
+func (s *ApiRentComputer) GetRentComputerById(c *gin.Context) {
+	var idInfo request.GetById
+	_ = c.ShouldBindJSON(&idInfo)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	api, err := ServiceRentComputer.GetRentComputerById(idInfo.ID)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(api, "获取成功", c)
+	}
+}
+
+func (s *ApiRentComputer) AddRentComputer(c *gin.Context) {
+	var api request.ComputerRequest
+	_ = c.ShouldBindJSON(&api)
+	//if err := utils.Verify(api, utils.LogCodingVerify); err != nil {
+	//	response.FailWithMessage(err.Error(), c)
+	//	return
+	//}
+	//fmt.Printf("%#v\n", &api)
+	if err := ServiceRentComputer.AddRentComputer(api); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Error(err))
+		response.FailWithMessage("创建失败,"+err.Error(), c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+func (s *ApiRentComputer) EditRentComputer(c *gin.Context) {
+	var detail rentComputer.RentComputer
+	_ = c.ShouldBindJSON(&detail)
+	if err := ServiceRentComputer.EditRentComputer(detail); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Error(err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+func (s *ApiRentComputer) DeleteRentComputerByIds(c *gin.Context) {
+	var ids request.IdsReq
+	_ = c.ShouldBindJSON(&ids)
+	if err := ServiceRentComputer.DeleteRentComputerByIds(ids); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+func (s *ApiRentComputer) DeleteRentComputerById(c *gin.Context) {
+	var api rentComputer.RentComputer
+	_ = c.ShouldBindJSON(&api)
+
+	if err := ServiceRentComputer.DeleteRentComputerById(api); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+func (e *ApiRentComputer) ImportExcel(c *gin.Context) {
+	_, header, err := c.Request.FormFile("file")
+	if err != nil {
+		global.GVA_LOG.Error("接收文件失败!", zap.Error(err))
+		response.FailWithMessage("接收文件失败", c)
+		return
+	}
+	//创建目录
+
+	uploadDir := global.GVA_CONFIG.Excel.Dir + strconv.Itoa(int(time.Now().Year())) + "-" + strconv.Itoa(int(time.Now().Month())) + "-" + strconv.Itoa(int(time.Now().Day())) + "/"
+	err = os.MkdirAll(uploadDir, os.ModePerm)
+	if err != nil {
+		response.FailWithMessage("接收文件失败"+err.Error(), c)
+		return
+	}
+	filePath := uploadDir + strconv.Itoa(int(time.Now().Unix())) + ".xlsx"
+	err = c.SaveUploadedFile(header, filePath)
+	if err != nil {
+		response.FailWithMessage("接收文件失败"+err.Error(), c)
+		return
+	}
+	err = ServiceRentComputer.ParseExcel2InfoList(filePath)
+	if err != nil {
+		response.FailWithMessage("接收文件失败"+err.Error(), c)
+		return
+	}
+	response.OkWithMessage("导入成功,请刷新查看", c)
+}

+ 109 - 0
api/v1/rentComputer/rent_computer_shop.go

@@ -0,0 +1,109 @@
+package rentComputer
+
+import (
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+	"log-server/global"
+	"log-server/model/log/response"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/utils"
+)
+
+type ApiRentComputerShop struct {
+}
+
+func (s *ApiRentComputerShop) GetRentComputerShopList(c *gin.Context) {
+	global.GVA_LOG.Info("api----GetComputerShopList----strat")
+	var paramsInfo request.GetStatisticsComputerShopRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}*/
+	list, total, err := ServiceRentComputerShop.RentComputerShopList(c, paramsInfo.RentComputerShop, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+func (s *ApiRentComputerShop) GetRentComputerShopNum(c *gin.Context) {
+	//var paramsInfo request.GetStatisticsComputerShopRequest
+	//_ = c.ShouldBindJSON(&paramsInfo)
+	//num := ServiceComputerShop.GetComputerShopNum(paramsInfo.CreateTime)
+	num := ServiceRentComputerShop.GetRentComputerShopNum()
+	response.OkWithDetailed(num, "获取成功", c)
+}
+
+func (s *ApiRentComputerShop) GetRentComputerShopById(c *gin.Context) {
+	var idInfo request.GetById
+	_ = c.ShouldBindJSON(&idInfo)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	api, err := ServiceRentComputerShop.GetRentComputerShopById(idInfo.ID)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(api, "获取成功", c)
+	}
+}
+
+func (s *ApiRentComputerShop) AddRentComputerShop(c *gin.Context) {
+	var api request.ComputerShopRequest
+	_ = c.ShouldBindJSON(&api)
+	//if err := utils.Verify(api, utils.LogCodingVerify); err != nil {
+	//	response.FailWithMessage(err.Error(), c)
+	//	return
+	//}
+	if err := ServiceRentComputerShop.AddRentComputerShop(api); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Error(err))
+		response.FailWithMessage("创建失败", c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+func (s *ApiRentComputerShop) EditRentComputerShop(c *gin.Context) {
+	var detail rentComputer.RentComputerShop
+	_ = c.ShouldBindJSON(&detail)
+	if err := ServiceRentComputerShop.EditRentComputerShop(detail); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Error(err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+func (s *ApiRentComputerShop) DeleteRentComputerShopByIds(c *gin.Context) {
+	var ids request.IdsReq
+	_ = c.ShouldBindJSON(&ids)
+	if err := ServiceRentComputerShop.DeleteRentComputerShopByIds(ids); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+func (s *ApiRentComputerShop) DeleteRentComputerShopById(c *gin.Context) {
+	var api rentComputer.RentComputerShop
+	_ = c.ShouldBindJSON(&api)
+
+	if err := ServiceRentComputerShop.DeleteRentComputerShopById(api); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}

+ 110 - 0
api/v1/rentComputer/rent_set_meal.go

@@ -0,0 +1,110 @@
+package rentComputer
+
+import (
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
+	"log-server/global"
+	"log-server/model/log/response"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/utils"
+)
+
+type ApiRentSetMeal struct {
+}
+
+func (s *ApiRentSetMeal) GetRentSetMealList(c *gin.Context) {
+	var paramsInfo request.GetStatisticsSetMealRequest
+	_ = c.ShouldBindJSON(&paramsInfo)
+	/*if err := utils.Verify(paramsInfo.PageInfo, utils.PageInfoVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}*/
+	list, total, err := ServiceRentSetMeal.RentSetMealList(c, paramsInfo.RentSetMeal, paramsInfo.PageInfo, paramsInfo.OrderKey, paramsInfo.Desc)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(response.PageResult{
+			List:     list,
+			Total:    total,
+			Page:     paramsInfo.Page,
+			PageSize: paramsInfo.PageSize,
+		}, "获取成功", c)
+	}
+}
+
+func (s *ApiRentSetMeal) GetRentSetMealNum(c *gin.Context) {
+	//var paramsInfo request.GetStatisticsComputerShopRequest
+	//_ = c.ShouldBindJSON(&paramsInfo)
+	//num := ServiceComputerShop.GetComputerShopNum(paramsInfo.CreateTime)
+	num := ServiceRentSetMeal.GetRentSetMealNum()
+	response.OkWithDetailed(num, "获取成功", c)
+}
+
+func (s *ApiRentSetMeal) GetRentSetMealById(c *gin.Context) {
+	var idInfo request.GetById
+	_ = c.ShouldBindJSON(&idInfo)
+	if err := utils.Verify(idInfo, utils.IdVerify); err != nil {
+		response.FailWithMessage(err.Error(), c)
+		return
+	}
+	api, err := ServiceRentSetMeal.GetRentSetMealById(idInfo.ID)
+	if err != nil {
+		global.GVA_LOG.Error("获取失败!", zap.Error(err))
+		response.FailWithMessage("获取失败", c)
+	} else {
+		response.OkWithDetailed(api, "获取成功", c)
+	}
+}
+
+func (s *ApiRentSetMeal) AddRentSetMeal(c *gin.Context) {
+	var api request.SetMealRequest
+	_ = c.ShouldBindJSON(&api)
+	//if err := utils.Verify(api, utils.LogCodingVerify); err != nil {
+	//	response.FailWithMessage(err.Error(), c)
+	//	return
+	//}
+	fmt.Printf("%#v\n", &api)
+	if err := ServiceRentSetMeal.AddRentSetMeal(api); err != nil {
+		global.GVA_LOG.Error("创建失败!", zap.Error(err))
+		response.FailWithMessage("创建失败", c)
+	} else {
+		response.OkWithMessage("创建成功", c)
+	}
+}
+
+func (s *ApiRentSetMeal) EditRentSetMeal(c *gin.Context) {
+	var detail rentComputer.RentSetMeal
+	_ = c.ShouldBindJSON(&detail)
+	if err := ServiceRentSetMeal.EditRentSetMeal(detail); err != nil {
+		global.GVA_LOG.Error("更新失败!", zap.Error(err))
+		response.FailWithMessage("更新失败", c)
+	} else {
+		response.OkWithMessage("更新成功", c)
+	}
+}
+
+func (s *ApiRentSetMeal) DeleteRentSetMealByIds(c *gin.Context) {
+	var ids request.IdsReq
+	_ = c.ShouldBindJSON(&ids)
+	if err := ServiceRentSetMeal.DeleteRentSetMealByIds(ids); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}
+
+func (s *ApiRentSetMeal) DeleteRentSetMealById(c *gin.Context) {
+	var api rentComputer.RentSetMeal
+	_ = c.ShouldBindJSON(&api)
+
+	if err := ServiceRentSetMeal.DeleteRentSetMealById(api); err != nil {
+		global.GVA_LOG.Error("删除失败!", zap.Error(err))
+		response.FailWithMessage("删除失败", c)
+	} else {
+		response.OkWithMessage("删除成功", c)
+	}
+}

+ 2 - 2
api/v1/typeManage/gameList.go

@@ -1,14 +1,14 @@
 package typeManage
 package typeManage
 
 
 import (
 import (
+	"github.com/gin-gonic/gin"
+	"go.uber.org/zap"
 	"log-server/global"
 	"log-server/global"
 	"log-server/model/common/request"
 	"log-server/model/common/request"
 	"log-server/model/common/response"
 	"log-server/model/common/response"
 	"log-server/model/typeManage"
 	"log-server/model/typeManage"
 	typeManageRes "log-server/model/typeManage/response"
 	typeManageRes "log-server/model/typeManage/response"
 	"log-server/utils"
 	"log-server/utils"
-	"github.com/gin-gonic/gin"
-	"go.uber.org/zap"
 )
 )
 
 
 type GameListApi struct{}
 type GameListApi struct{}

+ 8 - 10
initialize/redis.go

@@ -1,12 +1,9 @@
 package initialize
 package initialize
 
 
 import (
 import (
-	"context"
-
 	"log-server/global"
 	"log-server/global"
 
 
 	"github.com/go-redis/redis/v8"
 	"github.com/go-redis/redis/v8"
-	"go.uber.org/zap"
 )
 )
 
 
 func Redis() {
 func Redis() {
@@ -16,11 +13,12 @@ func Redis() {
 		Password: redisCfg.Password, // no password set
 		Password: redisCfg.Password, // no password set
 		DB:       redisCfg.DB,       // use default DB
 		DB:       redisCfg.DB,       // use default DB
 	})
 	})
-	pong, err := client.Ping(context.Background()).Result()
-	if err != nil {
-		global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err))
-	} else {
-		global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
-		global.GVA_REDIS = client
-	}
+	global.GVA_LOG.Info(client.String())
+	//pong, err := client.Ping(context.Background()).Result()
+	//if err != nil {
+	//	global.GVA_LOG.Error("redis connect ping failed, err:", zap.Error(err))
+	//} else {
+	//	global.GVA_LOG.Info("redis connect ping response:", zap.String("pong", pong))
+	//	global.GVA_REDIS = client
+	//}
 }
 }

+ 4 - 0
initialize/router.go

@@ -23,6 +23,7 @@ func Routers() *gin.Engine {
 	taskRouter := router.RouterGroupApp.Task
 	taskRouter := router.RouterGroupApp.Task
 
 
 	typeManageRouter := router.RouterGroupApp.TypeManage
 	typeManageRouter := router.RouterGroupApp.TypeManage
+	rentComputerRouter := router.RouterGroupApp.RentComputer
 	// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
 	// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
 	// VUE_APP_BASE_API = /
 	// VUE_APP_BASE_API = /
 	// VUE_APP_BASE_PATH = http://localhost
 	// VUE_APP_BASE_PATH = http://localhost
@@ -62,6 +63,9 @@ func Routers() *gin.Engine {
 		typeManageRouter.InitResponsiblePersonRouter(PublicGroup) //负责人路由
 		typeManageRouter.InitResponsiblePersonRouter(PublicGroup) //负责人路由
 		typeManageRouter.InitAccountTypeRouter(PublicGroup)       //账号类型路由
 		typeManageRouter.InitAccountTypeRouter(PublicGroup)       //账号类型路由
 		taskRouter.InitGameTaskRouter(PublicGroup)
 		taskRouter.InitGameTaskRouter(PublicGroup)
+		rentComputerRouter.InitRentComputerRouter(PublicGroup)     //租机管理
+		rentComputerRouter.InitRentComputerShopRouter(PublicGroup) // 租机供应商管理
+		rentComputerRouter.InitRentSetMealRouter(PublicGroup)
 	}
 	}
 	PrivateGroup := Router.Group("")
 	PrivateGroup := Router.Group("")
 	PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
 	PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())

+ 26 - 0
model/rentComputer/rent_computer.go

@@ -0,0 +1,26 @@
+package rentComputer
+
+type RentComputer struct {
+	Id                uint    `json:"id"`
+	UpdateTime        string  `json:"update_time"`        // 更新时间
+	CreateTime        string  `json:"create_time"`        // 创建时间
+	PcNum             string  `json:"pc_num"`             //电脑编号
+	PcName            string  `json:"pc_name"`            //电脑名称
+	ShopId            uint    `json:"shop_id"`            //供应商ID
+	RentStart         string  `json:"rent_start"`         //起租时间
+	RentDuration      int     `json:"rent_duration"`      //租赁天数
+	RentEnd           string  `json:"rent_end"`           //到期时间
+	Remark            string  `json:"remark"`             //备注
+	TodeskId          string  `json:"todesk_id"`          //todesk账号密码
+	TodeskPassword    string  `json:"todesk_password"`    //todesk账号密码
+	SunflowerId       string  `json:"sunflower_id"`       //向日葵账号密码
+	SunflowerPassword string  `json:"sunflower_password"` //向日葵账号密码
+	RentPriceUsed     float64 `json:"rent_price_used"`    //当前租赁期内已产生租金
+	IsExpire          int     `json:"is_expire"`          //是否到期 0:否 1:是 2:明日到期
+	SetMealId         uint    `json:"set_meal_id"`        //套餐名id
+	IsOffShelf        int     `json:"is_off_shelf"`       //是否下架 0:否 1:是
+}
+
+func (RentComputer) TableName() string {
+	return "rent_computer"
+}

+ 14 - 0
model/rentComputer/rent_computer_shop.go

@@ -0,0 +1,14 @@
+package rentComputer
+
+type RentComputerShop struct {
+	Id          uint   `json:"id"`
+	UpdateTime  string `json:"update_time"` // 更新时间
+	CreateTime  string `json:"create_time"` // 创建时间
+	Name        string `json:"name"`        //供应商名
+	PayMethod   int    `json:"pay_method"`  //结算方式 0:先付后用 1:先用后付
+	Description string `json:"description"` //描述说明
+}
+
+func (RentComputerShop) TableName() string {
+	return "rent_computer_shop"
+}

+ 19 - 0
model/rentComputer/rent_set_meal.go

@@ -0,0 +1,19 @@
+package rentComputer
+
+// RentSetMeal 套餐表
+type RentSetMeal struct {
+	Id           uint    `json:"id"`             //ID
+	UpdateTime   string  `json:"update_time"`    // 更新时间
+	CreateTime   string  `json:"create_time"`    // 创建时间
+	Name         string  `json:"name"`           //套餐名称
+	Remark       string  `json:"remark"`         //备注
+	RentPrice    float64 `json:"rent_price"`     //价格标准
+	PriceType    int     `json:"price_type"`     //套餐类型 0:天卡 1:周卡 2:月卡
+	RentPriceDay float64 `json:"rent_price_day"` //折算天租金
+	ShopId       uint    `json:"shop_id"`        //供应商ID
+	//ShopName     string  `json:"shop_name"`      //供应商名
+}
+
+func (RentSetMeal) TableName() string {
+	return "rent_set_meal"
+}

+ 28 - 0
model/rentComputer/request/common.go

@@ -0,0 +1,28 @@
+package request
+
+// PageInfo Paging common input parameter structure
+type PageInfo struct {
+	Page     int    `json:"page" form:"page"`         // 页码
+	PageSize int    `json:"pageSize" form:"pageSize"` // 每页大小
+	Keyword  string `json:"keyword" form:"keyword"`   //关键字
+}
+
+// GetById Find by id structure
+type GetById struct {
+	ID int `json:"id" form:"id"` // 主键ID
+}
+
+func (r *GetById) Uint() uint {
+	return uint(r.ID)
+}
+
+type IdsReq struct {
+	Ids []int `json:"ids" form:"ids"`
+}
+
+// GetAuthorityId Get role by id structure
+type GetAuthorityId struct {
+	AuthorityId uint `json:"authorityId" form:"authorityId"` // 角色ID
+}
+
+type Empty struct{}

+ 33 - 0
model/rentComputer/request/rent_computer.go

@@ -0,0 +1,33 @@
+package request
+
+import (
+	"log-server/model/rentComputer"
+)
+
+type GetStatisticsComputerRequest struct {
+	rentComputer.RentComputer
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}
+
+type ComputerRequest struct {
+	Id                uint    `json:"id"`
+	UpdateTime        string  `json:"update_time"`        // 更新时间
+	CreateTime        string  `json:"create_time"`        // 创建时间
+	PcNum             string  `json:"pc_num"`             //电脑编号
+	PcName            string  `json:"pc_name"`            //电脑名称
+	ShopId            uint    `json:"shop_id"`            //供应商ID
+	RentStart         string  `json:"rent_start"`         //起租时间
+	RentDuration      int     `json:"rent_duration"`      //租赁天数
+	RentEnd           string  `json:"rent_end"`           //到期时间
+	Remark            string  `json:"remark"`             //备注
+	TodeskId          string  `json:"todesk_id"`          //todesk账号密码
+	TodeskPassword    string  `json:"todesk_password"`    //todesk账号密码
+	SunflowerId       string  `json:"sunflower_id"`       //向日葵账号密码
+	SunflowerPassword string  `json:"sunflower_password"` //向日葵账号密码
+	RentPriceUsed     float64 `json:"rent_price_used"`    //当前租赁期内已产生租金
+	IsExpire          int     `json:"is_expire"`          //是否到期 0:否 1:是 2:明日到期
+	SetMealId         uint    `json:"set_meal_id"`        //套餐名id
+	IsOffShelf        int     `json:"is_off_shelf"`       //是否下架 0:否 1:是
+}

+ 21 - 0
model/rentComputer/request/rent_computer_shop.go

@@ -0,0 +1,21 @@
+package request
+
+import (
+	"log-server/model/rentComputer"
+)
+
+type GetStatisticsComputerShopRequest struct {
+	rentComputer.RentComputerShop
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}
+
+type ComputerShopRequest struct {
+	Id          uint   `json:"id"`
+	UpdateTime  string `json:"update_time"` // 更新时间
+	CreateTime  string `json:"create_time"` // 创建时间
+	Name        string `json:"name"`        //供应商名
+	PayMethod   int    `json:"pay_method"`  //结算方式 0:先付后用 1:先用后付
+	Description string `json:"description"` //描述说明
+}

+ 24 - 0
model/rentComputer/request/rent_set_meal.go

@@ -0,0 +1,24 @@
+package request
+
+import (
+	"log-server/model/rentComputer"
+)
+
+type GetStatisticsSetMealRequest struct {
+	rentComputer.RentSetMeal
+	PageInfo
+	OrderKey string `json:"orderKey"` // 排序
+	Desc     bool   `json:"desc"`     // 排序方式:升序false(默认)|降序true
+}
+
+type SetMealRequest struct {
+	Id           uint    `json:"id"`             //ID
+	UpdateTime   string  `json:"update_time"`    // 更新时间
+	CreateTime   string  `json:"create_time"`    // 创建时间
+	Name         string  `json:"name"`           //套餐名称
+	Remark       string  `json:"remark"`         //备注
+	RentPrice    float64 `json:"rent_price"`     //价格标准
+	PriceType    int     `json:"price_type"`     //套餐类型 0:天卡 1:周卡 2:月卡
+	RentPriceDay float64 `json:"rent_price_day"` //折算天租金
+	ShopId       uint    `json:"shop_id"`        //供应商ID
+}

+ 8 - 0
model/rentComputer/response/common.go

@@ -0,0 +1,8 @@
+package response
+
+type PageResult struct {
+	List     interface{} `json:"list"`
+	Total    int64       `json:"total"`
+	Page     int         `json:"page"`
+	PageSize int         `json:"pageSize"`
+}

+ 27 - 0
model/rentComputer/response/rent_computer.go

@@ -0,0 +1,27 @@
+package response
+
+type ComputerStatisticsReply2 struct {
+	Id                uint    `json:"id"`
+	UpdateTime        string  `json:"update_time"`        // 更新时间
+	CreateTime        string  `json:"create_time"`        // 创建时间
+	PcNum             string  `json:"pc_num"`             //电脑编号
+	PcName            string  `json:"pc_name"`            //电脑名称
+	ShopId            uint    `json:"shop_id"`            //供应商ID
+	RentStart         string  `json:"rent_start"`         //起租时间
+	RentDuration      int     `json:"rent_duration"`      //租赁天数
+	RentEnd           string  `json:"rent_end"`           //到期时间
+	Remark            string  `json:"remark"`             //备注
+	TodeskId          string  `json:"todesk_id"`          //todesk账号密码
+	TodeskPassword    string  `json:"todesk_password"`    //todesk账号密码
+	SunflowerId       string  `json:"sunflower_id"`       //向日葵账号密码
+	SunflowerPassword string  `json:"sunflower_password"` //向日葵账号密码
+	RentPrice         float64 `json:"rent_price"`         //价格标准
+	PriceType         int     `json:"price_type"`         //套餐类型 0:天卡 1:周卡 2:月卡
+	RentPriceDay      float64 `json:"rent_price_day"`     //折算天租金
+	RentPriceUsed     float64 `json:"rent_price_used"`    //当前租赁期内已产生租金
+	IsExpire          int     `json:"is_expire"`          //是否到期 0:否 1:是 2:明日到期
+	SetMealId         uint    `json:"set_meal_id"`        //套餐名id
+	IsOffShelf        int     `json:"is_off_shelf"`       //是否下架 0:否 1:是
+	ShopName          string  `json:"shop_name"`          //供应商名
+	SetMealName       string  `json:"set_meal_name"`      //套餐名
+}

+ 10 - 0
model/rentComputer/response/rent_computer_shop.go

@@ -0,0 +1,10 @@
+package response
+
+type ComputerStatisticsReply1 struct {
+	Id          uint   `json:"id"`
+	UpdateTime  string `json:"update_time"` // 更新时间
+	CreateTime  string `json:"create_time"` // 创建时间
+	Name        string `json:"name"`        //供应商名
+	PayMethod   int    `json:"pay_method"`  //结算方式 0:先付后用 1:先用后付
+	Description string `json:"description"` //描述说明
+}

+ 14 - 0
model/rentComputer/response/rent_set_meal.go

@@ -0,0 +1,14 @@
+package response
+
+type SetMealStatisticsReply1 struct {
+	Id           uint    `json:"id"`             //ID
+	UpdateTime   string  `json:"update_time"`    // 更新时间
+	CreateTime   string  `json:"create_time"`    // 创建时间
+	Name         string  `json:"name"`           //套餐名称
+	Remark       string  `json:"remark"`         //备注
+	RentPrice    float64 `json:"rent_price"`     //价格标准
+	PriceType    int     `json:"price_type"`     //套餐类型 0:天卡 1:周卡 2:月卡
+	RentPriceDay float64 `json:"rent_price_day"` //折算天租金
+	ShopId       uint    `json:"shop_id"`        //供应商ID
+	ShopName     string  `json:"shop_name"`      //供应商名
+}

Разница между файлами не показана из-за своего большого размера
+ 50 - 0
model/typeManage/dataInsert_test.go


BIN
resource/excel/RentComputerTemplate.xlsx


+ 8 - 6
router/enter.go

@@ -3,18 +3,20 @@ package router
 import (
 import (
 	"log-server/router/example"
 	"log-server/router/example"
 	"log-server/router/log"
 	"log-server/router/log"
+	"log-server/router/rentComputer"
 	"log-server/router/system"
 	"log-server/router/system"
 	"log-server/router/task"
 	"log-server/router/task"
 	"log-server/router/typeManage"
 	"log-server/router/typeManage"
 )
 )
 
 
 type RouterGroup struct {
 type RouterGroup struct {
-	System     system.RouterGroup
-	Example    example.RouterGroup
-	Loging     log.RouterGroup
-	Computer   log.ComputerRouter
-	TypeManage typeManage.RouterGroup
-	Task       task.GameTaskRouter
+	System       system.RouterGroup
+	Example      example.RouterGroup
+	Loging       log.RouterGroup
+	Computer     log.ComputerRouter
+	TypeManage   typeManage.RouterGroup
+	Task         task.GameTaskRouter
+	RentComputer rentComputer.RouterGroup
 }
 }
 
 
 var RouterGroupApp = new(RouterGroup)
 var RouterGroupApp = new(RouterGroup)

+ 9 - 0
router/rentComputer/enter.go

@@ -0,0 +1,9 @@
+package rentComputer
+
+type RouterGroup struct {
+	// Code generated by log-server Begin; DO NOT EDIT.
+	RentComputerRouter
+	RentComputerShopRouter
+	RentSetMealRouter
+	// Code generated by log-server End; DO NOT EDIT.
+}

+ 24 - 0
router/rentComputer/rent_computer.go

@@ -0,0 +1,24 @@
+package rentComputer
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "log-server/api/v1"
+)
+
+type RentComputerRouter struct {
+}
+
+func (e *RentComputerRouter) InitRentComputerRouter(Router *gin.RouterGroup) {
+	excelRouter := Router.Group("rentComputer")
+	rentComputerApi := v1.ApiGroupApp.RentComputerApiGroup.ApiRentComputer
+	{
+		excelRouter.POST("getRentComputerList", rentComputerApi.GetRentComputerList) //查询记录
+		excelRouter.POST("getRentComputerNum", rentComputerApi.GetRentComputerNum)
+		excelRouter.POST("getRentComputerById", rentComputerApi.GetRentComputerById)           // 查询单条记录
+		excelRouter.POST("addRentComputer", rentComputerApi.AddRentComputer)                   //添加记录
+		excelRouter.PUT("editRentComputer", rentComputerApi.EditRentComputer)                  //修改记录
+		excelRouter.DELETE("deleteRentComputerByIds", rentComputerApi.DeleteRentComputerByIds) // 删除多条记录
+		excelRouter.DELETE("deleteRentComputerById", rentComputerApi.DeleteRentComputerById)   // 删除单个记录
+		excelRouter.POST("importExcel", rentComputerApi.ImportExcel)
+	}
+}

+ 23 - 0
router/rentComputer/rent_computer_shop.go

@@ -0,0 +1,23 @@
+package rentComputer
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "log-server/api/v1"
+)
+
+type RentComputerShopRouter struct {
+}
+
+func (e *RentComputerShopRouter) InitRentComputerShopRouter(Router *gin.RouterGroup) {
+	excelRouter := Router.Group("rentComputerShop")
+	rentComputerShopApi := v1.ApiGroupApp.RentComputerApiGroup.ApiRentComputerShop
+	{
+		excelRouter.POST("getRentComputerShopList", rentComputerShopApi.GetRentComputerShopList) //查询记录
+		excelRouter.POST("getRentComputerShopNum", rentComputerShopApi.GetRentComputerShopNum)
+		excelRouter.POST("getRentComputerShopById", rentComputerShopApi.GetRentComputerShopById)           // 查询单条记录
+		excelRouter.POST("addRentComputerShop", rentComputerShopApi.AddRentComputerShop)                   //添加记录
+		excelRouter.PUT("editRentComputerShop", rentComputerShopApi.EditRentComputerShop)                  //修改记录
+		excelRouter.DELETE("deleteRentComputerShopByIds", rentComputerShopApi.DeleteRentComputerShopByIds) // 删除多条记录
+		excelRouter.DELETE("deleteRentComputerShopById", rentComputerShopApi.DeleteRentComputerShopById)   // 删除单个记录
+	}
+}

+ 23 - 0
router/rentComputer/rent_set_meal.go

@@ -0,0 +1,23 @@
+package rentComputer
+
+import (
+	"github.com/gin-gonic/gin"
+	v1 "log-server/api/v1"
+)
+
+type RentSetMealRouter struct {
+}
+
+func (e *RentSetMealRouter) InitRentSetMealRouter(Router *gin.RouterGroup) {
+	excelRouter := Router.Group("rentSetMeal")
+	rentSetMealApi := v1.ApiGroupApp.RentComputerApiGroup.ApiRentSetMeal
+	{
+		excelRouter.POST("getRentSetMealList", rentSetMealApi.GetRentSetMealList) //查询记录
+		excelRouter.POST("getRentSetMealNum", rentSetMealApi.GetRentSetMealNum)
+		excelRouter.POST("getRentSetMealById", rentSetMealApi.GetRentSetMealById)           // 查询单条记录
+		excelRouter.POST("addRentSetMeal", rentSetMealApi.AddRentSetMeal)                   //添加记录
+		excelRouter.PUT("editRentSetMeal", rentSetMealApi.EditRentSetMeal)                  //修改记录
+		excelRouter.DELETE("deleteRentSetMealByIds", rentSetMealApi.DeleteRentSetMealByIds) // 删除多条记录
+		excelRouter.DELETE("deleteRentSetMealById", rentSetMealApi.DeleteRentSetMealById)   // 删除单个记录
+	}
+}

+ 7 - 5
service/enter.go

@@ -3,17 +3,19 @@ package service
 import (
 import (
 	"log-server/service/example"
 	"log-server/service/example"
 	"log-server/service/log"
 	"log-server/service/log"
+	"log-server/service/rentComputer"
 	"log-server/service/system"
 	"log-server/service/system"
 	"log-server/service/task"
 	"log-server/service/task"
 	"log-server/service/typeManage"
 	"log-server/service/typeManage"
 )
 )
 
 
 type ServiceGroup struct {
 type ServiceGroup struct {
-	SystemServiceGroup  system.ServiceGroup
-	ExampleServiceGroup example.ServiceGroup
-	LogServiceGroup     log.ServiceGroup
-	TypeServiceGroup    typeManage.ServiceGroup
-	TaskServiceGroup    task.ServiceGroup
+	SystemServiceGroup       system.ServiceGroup
+	ExampleServiceGroup      example.ServiceGroup
+	LogServiceGroup          log.ServiceGroup
+	TypeServiceGroup         typeManage.ServiceGroup
+	TaskServiceGroup         task.ServiceGroup
+	RentComputerServiceGroup rentComputer.ServiceGroup
 }
 }
 
 
 var ServiceGroupApp = new(ServiceGroup)
 var ServiceGroupApp = new(ServiceGroup)

+ 9 - 0
service/rentComputer/enter.go

@@ -0,0 +1,9 @@
+package rentComputer
+
+type ServiceGroup struct {
+	// Code generated by log-server Begin; DO NOT EDIT.
+	ServiceRentComputer
+	ServiceRentComputerShop
+	ServiceRentSetMeal
+	// Code generated by log-server End; DO NOT EDIT.
+}

+ 381 - 0
service/rentComputer/rent_computer.go

@@ -0,0 +1,381 @@
+package rentComputer
+
+import (
+	"context"
+	"errors"
+	"github.com/xuri/excelize/v2"
+	"go.uber.org/zap"
+	"gorm.io/gorm"
+	"log-server/global"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/model/rentComputer/response"
+	"math"
+	"os"
+	"strconv"
+	"time"
+)
+
+type ServiceRentComputer struct {
+}
+
+func (s *ServiceRentComputer) RentComputerList(ctx context.Context, api rentComputer.RentComputer, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
+
+	db := global.GVA_DB.Model(&rentComputer.RentComputer{})
+	db = db.Select("rent_computer.id,rent_computer.update_time,rent_computer.create_time,rent_computer.pc_num,rent_computer.set_meal_id," +
+		"rent_computer.pc_name,rent_computer.shop_id,rent_computer.rent_start,rent_computer.rent_duration,rent_computer.is_off_shelf,rent_computer.rent_end," +
+		"rent_computer.remark,rent_computer.todesk_id,rent_computer.todesk_password,rent_computer.sunflower_id,rent_computer.sunflower_password,rent_computer.rent_price_used,rent_computer.is_expire," +
+		"s.name as shop_name, r.name as set_meal_name,r.rent_price,r.price_type,r.rent_price_day")
+	db = db.Joins("left join rent_computer_shop s on s.id = rent_computer.shop_id")
+	db = db.Joins("left join rent_set_meal r on r.id = rent_computer.set_meal_id")
+
+	if api.PcNum != "" {
+		db = db.Where("rent_computer.pc_num = ?", api.PcNum)
+	}
+	if api.ShopId != 0 {
+		db = db.Where("rent_computer.shop_id = ?", api.ShopId)
+	}
+	if api.SetMealId != 0 {
+		db = db.Where("rent_computer.set_meal_id = ?", api.SetMealId)
+	}
+	global.GVA_LOG.Info(strconv.Itoa(int(api.IsOffShelf)))
+	global.GVA_LOG.Info(strconv.Itoa(int(api.IsExpire)))
+	if api.IsOffShelf != -1 {
+		db = db.Where("rent_computer.is_off_shelf = ?", api.IsOffShelf)
+	}
+	if api.IsExpire != -1 {
+		db = db.Where("rent_computer.is_expire = ?", api.IsExpire)
+	}
+
+	var total int64
+	err := db.Count(&total).Error
+	//if err != nil {
+	//	return nil, 0, err
+	//}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	//var statisticsLogs []*log.LogComputer
+	var statisticscomputers []*response.ComputerStatisticsReply2
+	db = db.Limit(limit).Offset(offset)
+	if order != "" {
+		var OrderStr string
+		// 设置有效排序key 防止sql注入
+		// 感谢 Tom4t0 提交漏洞信息
+		orderMap := make(map[string]bool, 3)
+		orderMap["pc_num"] = true
+		//orderMap["game_id"] = true
+		//orderMap["operator"] = true
+		if orderMap[order] {
+			if desc {
+				OrderStr = order + " desc"
+			} else {
+				OrderStr = order
+			}
+		} else { // didn't matched any order key in `orderMap`
+			global.GVA_LOG.Error("获取失败!", zap.Error(err))
+			return statisticscomputers, total, err
+		}
+		err = db.Order(OrderStr).Find(&statisticscomputers).Error
+	} else {
+		err = db.Order("id").Find(&statisticscomputers).Error
+	}
+	if err != nil {
+		return nil, 0, err
+	}
+	var statisticsLogsComputer []*response.ComputerStatisticsReply2
+
+	for _, statisticsLog := range statisticscomputers {
+
+		statisticscomputer := new(response.ComputerStatisticsReply2)
+		statisticscomputer.Id = statisticsLog.Id
+		statisticscomputer.UpdateTime = statisticsLog.UpdateTime
+		statisticscomputer.CreateTime = statisticsLog.CreateTime
+		statisticscomputer.PcNum = statisticsLog.PcNum
+		statisticscomputer.PcName = statisticsLog.PcName
+		statisticscomputer.ShopId = statisticsLog.ShopId
+		statisticscomputer.RentStart = statisticsLog.RentStart
+		statisticscomputer.RentDuration = statisticsLog.RentDuration
+		statisticscomputer.RentEnd = statisticsLog.RentEnd
+		statisticscomputer.Remark = statisticsLog.Remark
+		statisticscomputer.TodeskId = statisticsLog.TodeskId
+		statisticscomputer.TodeskPassword = statisticsLog.TodeskPassword
+		statisticscomputer.SunflowerId = statisticsLog.SunflowerId
+		statisticscomputer.SunflowerPassword = statisticsLog.SunflowerPassword
+		statisticscomputer.RentPrice = statisticsLog.RentPrice
+		statisticscomputer.RentPriceDay = statisticsLog.RentPriceDay
+		statisticscomputer.RentPriceUsed = statisticsLog.RentPriceUsed
+		statisticscomputer.IsExpire = statisticsLog.IsExpire
+		statisticscomputer.SetMealId = statisticsLog.SetMealId
+		statisticscomputer.PriceType = statisticsLog.PriceType
+		statisticscomputer.IsOffShelf = statisticsLog.IsOffShelf
+		statisticscomputer.ShopName = statisticsLog.ShopName
+		statisticscomputer.SetMealName = statisticsLog.SetMealName
+		statisticsLogsComputer = append(statisticsLogsComputer, statisticscomputer)
+	}
+	return statisticsLogsComputer, total, err
+}
+
+func (s *ServiceRentComputer) GetRentComputerNum() int64 {
+	var total int64
+
+	db := global.GVA_DB.Model(&rentComputer.RentComputer{})
+	db = db.Distinct("id")
+	db = db.Where("is_off_shelf = 0 and is_expire != 1")
+	_ = db.Count(&total).Error
+	return total
+}
+
+func (s *ServiceRentComputer) AddRentComputer(requestCoding request.ComputerRequest) (err error) {
+	if !errors.Is(global.GVA_DB.Where("pc_num = ? and shop_id = ?", requestCoding.PcNum, requestCoding.ShopId).First(&rentComputer.RentComputer{}).Error, gorm.ErrRecordNotFound) {
+		return errors.New("租机编号已存在")
+	}
+	computer := new(rentComputer.RentComputer)
+	//computer.Id = requestCoding.Id
+	computer.PcNum = requestCoding.PcNum
+	computer.PcName = requestCoding.PcName
+	computer.ShopId = requestCoding.ShopId
+	computer.RentStart = requestCoding.RentStart
+	computer.RentDuration = requestCoding.RentDuration
+	computer.RentEnd = requestCoding.RentEnd
+	computer.Remark = requestCoding.Remark
+	computer.TodeskId = requestCoding.TodeskId
+	computer.TodeskPassword = requestCoding.TodeskPassword
+	computer.SunflowerId = requestCoding.SunflowerId
+	computer.SunflowerPassword = requestCoding.SunflowerPassword
+	computer.RentPriceUsed = requestCoding.RentPriceUsed
+	computer.IsExpire = requestCoding.IsExpire
+	computer.SetMealId = requestCoding.SetMealId
+	computer.IsOffShelf = requestCoding.IsOffShelf
+	computer.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+	computer.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
+	//key := codeListCacheKey
+	//_ = s.cache.DelBatheHsCache(context.Background(), key)
+	return global.GVA_DB.Create(&computer).Error
+}
+
+func (s *ServiceRentComputer) GetRentComputerById(id int) (computerShop response.ComputerStatisticsReply2, err error) {
+	db := global.GVA_DB.Model(&rentComputer.RentComputer{})
+	var api response.ComputerStatisticsReply2
+	db = db.Select("rent_computer.id,rent_computer.update_time,rent_computer.create_time,rent_computer.pc_num,rent_computer.set_meal_id," +
+		"rent_computer.pc_name,rent_computer.shop_id,rent_computer.rent_start,rent_computer.rent_duration,rent_computer.is_off_shelf,rent_computer.rent_end," +
+		"rent_computer.remark,rent_computer.todesk_id,rent_computer.todesk_password,rent_computer.sunflower_id,rent_computer.sunflower_password,rent_computer.rent_price_used,rent_computer.is_expire," +
+		"s.name as shop_name, r.name as set_meal_name,r.rent_price,r.price_type,r.rent_price_day")
+	db = db.Joins("left join rent_computer_shop s on s.id = rent_computer.shop_id")
+	db = db.Joins("left join rent_set_meal r on r.id = rent_computer.set_meal_id")
+	err = db.Where("rent_computer.id = ?", id).Order(id).Limit(1).Find(&api).Error
+	if err != nil {
+		return
+	}
+	computerShop.Id = api.Id
+	computerShop.PcNum = api.PcNum
+	computerShop.PcName = api.PcName
+	computerShop.RentStart = api.RentStart
+	computerShop.RentDuration = api.RentDuration
+	computerShop.RentEnd = api.RentEnd
+	computerShop.TodeskId = api.TodeskId
+	computerShop.TodeskPassword = api.TodeskPassword
+	computerShop.SunflowerId = api.SunflowerId
+	computerShop.SunflowerPassword = api.SunflowerPassword
+	computerShop.RentPrice = api.RentPrice
+	computerShop.RentPriceDay = api.RentPriceDay
+	computerShop.RentPriceUsed = api.RentPriceUsed
+	computerShop.IsExpire = api.IsExpire
+	computerShop.SetMealId = api.SetMealId
+	computerShop.PriceType = api.PriceType
+	computerShop.IsOffShelf = api.IsOffShelf
+	global.GVA_LOG.Info(strconv.Itoa(api.IsOffShelf))
+	global.GVA_LOG.Info(strconv.Itoa(computerShop.IsOffShelf))
+	computerShop.ShopName = api.ShopName
+	computerShop.SetMealName = api.SetMealName
+	computerShop.Remark = api.Remark
+	computerShop.ShopId = api.ShopId
+	computerShop.UpdateTime = api.UpdateTime
+	computerShop.CreateTime = api.CreateTime
+	return
+}
+
+func (s *ServiceRentComputer) EditRentComputer(computer rentComputer.RentComputer) (err error) {
+
+	err = global.GVA_DB.Save(computer).Error
+	return err
+}
+
+func (s *ServiceRentComputer) DeleteRentComputerByIds(ids request.IdsReq) (err error) {
+	err = global.GVA_DB.Delete(&[]rentComputer.RentComputer{}, "id in ?", ids.Ids).Error
+	return err
+}
+
+func (s *ServiceRentComputer) DeleteRentComputerById(api rentComputer.RentComputer) (err error) {
+	var entity rentComputer.RentComputer
+	//global.GVA_LOG.Info(strconv.Itoa(int(api.Id)))
+	err = global.GVA_DB.Where("id = ?", api.Id).First(&entity).Error // 根据id查询api记录
+	if errors.Is(err, gorm.ErrRecordNotFound) {                      // api记录不存在
+		return err
+	}
+	return global.GVA_DB.Delete(&entity).Error
+}
+
+func (exa *ServiceRentComputer) ParseExcel2InfoList(filePath string) (err error) {
+	skipHeader := true
+	fixedHeader := []string{"租机编码", "供应商", "所属套餐", "套餐类型", "起租日", "到期日", "todesk号", "todesk密码", "向日葵号", "向日葵密码"}
+	file, err := excelize.OpenFile(filePath)
+	if err != nil {
+		return err
+	}
+	var insertComputers []*rentComputer.RentComputer
+	//var updateComputers []*rentComputer.RentComputer
+	rows, err := file.Rows("Sheet1")
+	if err != nil {
+		return err
+	}
+	//查询数据库里的套餐与供应商=====================================
+	var setMeals []*response.SetMealStatisticsReply1
+	db := global.GVA_DB.Model(&rentComputer.RentSetMeal{})
+	db = db.Select("rent_set_meal.id, rent_set_meal.name," +
+		"rent_set_meal.price_type,rent_set_meal.shop_id,s.name as shop_name")
+	db = db.Joins("left join rent_computer_shop s on s.id = rent_set_meal.shop_id")
+	err = db.Order("id").Find(&setMeals).Error
+	if err != nil {
+		return err
+	}
+	// =========================================================
+	index := 0
+	for rows.Next() {
+		index++
+		row, err := rows.Columns()
+		if err != nil {
+			return err
+		}
+		if skipHeader {
+			if exa.compareStrSlice(row, fixedHeader) {
+				skipHeader = false
+				continue
+			} else {
+				return errors.New("Excel格式错误")
+			}
+		}
+
+		c := new(rentComputer.RentComputer)
+		c.PcNum = row[0]
+		c.PcName = row[0]
+		flagShopId := false
+		flagSetMealName := false
+		for _, setMeal := range setMeals {
+			if row[1] == setMeal.ShopName {
+				flagShopId = true
+				c.ShopId = setMeal.ShopId
+				//break
+			}
+			priceType := 0
+			if row[3] == "天卡" {
+				priceType = 0
+			} else if row[3] == "周卡" {
+				priceType = 1
+			} else {
+				priceType = 2
+			}
+			if row[2] == setMeal.Name && priceType == setMeal.PriceType {
+				flagSetMealName = true
+				c.SetMealId = setMeal.Id
+				break
+			}
+		}
+		if flagShopId == false || flagSetMealName == false {
+			return errors.New("供应商错误")
+		}
+
+		rentStart, _ := time.ParseInLocation("2006-01-02 15:04:05", row[4]+" 00:00:00", time.Local)
+		rentEnd, _ := time.ParseInLocation("2006-01-02 15:04:05", row[5]+" 00:00:00", time.Local)
+		//global.GVA_LOG.Info(strconv.FormatInt(rentStart.Unix(), 10))
+		//global.GVA_LOG.Info(strconv.FormatInt(rentEnd.Unix(), 10))
+		c.RentStart = row[4] + " 00:00:00"
+		c.RentEnd = row[5] + " 00:00:00"
+		c.RentDuration = int(math.Abs(float64(SubDays(rentStart, rentEnd)))) + 1
+		c.IsExpire = 0
+		c.IsOffShelf = 0
+		// 获取工作表中指定单元格的值
+		todeskId, _ := file.GetCellValue("Sheet1", "G"+strconv.Itoa(index))
+		todeskPassword, _ := file.GetCellValue("Sheet1", "H"+strconv.Itoa(index))
+		sunflowerId, _ := file.GetCellValue("Sheet1", "I"+strconv.Itoa(index))
+		sunflowerPassword, _ := file.GetCellValue("Sheet1", "J"+strconv.Itoa(index))
+		c.TodeskId = todeskId                   //todesk账号密码
+		c.TodeskPassword = todeskPassword       //todesk账号密码
+		c.SunflowerId = sunflowerId             //向日葵账号密码
+		c.SunflowerPassword = sunflowerPassword //向日葵账号密码
+
+		c.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+		c.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
+		// 租机编号已存在,存入更新数组中
+		if !errors.Is(global.GVA_DB.Where("pc_num = ? and shop_id = ?", c.PcNum, c.ShopId).First(&rentComputer.RentComputer{}).Error, gorm.ErrRecordNotFound) {
+			// 租机编号已存在,存入更新数组中
+			//updateComputers = append(updateComputers, c)
+			continue
+		} else {
+			insertComputers = append(insertComputers, c)
+		}
+
+	}
+	defer func() {
+		global.GVA_LOG.Info("defer 删除文件")
+		err = os.RemoveAll(filePath)
+		if err != nil {
+			return
+		}
+	}()
+
+	//if updateComputers != nil {
+	//	err = global.GVA_DB.Updates(updateComputers).Error
+	//	if err != nil {
+	//		return
+	//	}
+	//}
+	if insertComputers != nil {
+		err = global.GVA_DB.Create(insertComputers).Error
+		if err != nil {
+			return
+		}
+	}
+
+	//var cp log.Computer
+	//err = cp.DelAllOnlinePcCodeCache()
+	return
+}
+
+func (exa *ServiceRentComputer) compareStrSlice(a, b []string) bool {
+	if len(a) != len(b) {
+		return false
+	}
+	if (b == nil) != (a == nil) {
+		return false
+	}
+	for key, value := range a {
+		if value != b[key] {
+			return false
+		}
+	}
+	return true
+}
+
+// 计算日期相差多少天
+// 返回值day>0, t1晚于t2; day<0, t1早于t2
+func SubDays(t1, t2 time.Time) (day int) {
+	swap := false
+	if t1.Unix() < t2.Unix() {
+		t_ := t1
+		t1 = t2
+		t2 = t_
+		swap = true
+	}
+	//global.GVA_LOG.Info(strconv.Itoa(int(t1.Unix())))
+	//global.GVA_LOG.Info(strconv.Itoa(int(t2.Unix())))
+	day = int(t1.Sub(t2).Hours() / 24)
+	// 计算在被24整除外的时间是否存在跨自然日
+	if int(t1.Sub(t2).Milliseconds())%86400000 > int(86400000-t2.Unix()%86400000) {
+		day += 1
+	}
+	if swap {
+		day = -day
+	}
+	//global.GVA_LOG.Info(strconv.Itoa(day))
+	return
+}

+ 188 - 0
service/rentComputer/rent_computer_shop.go

@@ -0,0 +1,188 @@
+package rentComputer
+
+import (
+	"context"
+	"errors"
+	"go.uber.org/zap"
+	"gorm.io/gorm"
+	"log-server/global"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/model/rentComputer/response"
+	"time"
+)
+
+type ServiceRentComputerShop struct {
+}
+
+func (s *ServiceRentComputerShop) RentComputerShopList(ctx context.Context, api rentComputer.RentComputerShop, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
+	//global.GVA_LOG.Info("service----GetComputerShopList----strat")
+	//date := api.CreateTime
+	//isCurrentDate := false
+	//if date == "" {
+	//	date = s.CurrentDate()
+	//	isCurrentDate = true
+	//}
+	db := global.GVA_DB.Model(&rentComputer.RentComputerShop{})
+	var total int64
+	//db = db.Distinct("pc_code", "id", "operator", "create_date", "GROUP_CONCAT(game_id) AS game_ids")
+	//db = db.Where("create_date = ?", date)
+	//if api.Operator != "" {
+	//	db = db.Where("operator like ?", "%"+api.Operator+"%")
+	//}
+	//if api.PcCode != "" {
+	//	db = db.Where("pc_code = ?", api.PcCode)
+	//}
+	//if api.GameId != 0 {
+	//	db = db.Where("game_id = ?", api.GameId)
+	//}
+	//.Select("count(distinct(name))").Count(&count)
+	//err := db.Count(&total).Error
+	//err := db.Select("count(distinct(pc_code))").Count(&total).Error
+	//db = db.Group("pc_code")
+	//db2 := global.GVA_DB.Model(&log.LogComputer{})
+	//db2 = db2.Select("count(distinct(pc_code))")
+	//db2 = db2.Where("create_date = ?", date)
+	//if api.Operator != "" {
+	//	db2 = db2.Where("operator like ?", "%"+api.Operator+"%")
+	//}
+	//if api.PcCode != "" {
+	//	db2 = db2.Where("pc_code = ?", api.PcCode)
+	//}
+	err := db.Count(&total).Error
+	//if err != nil {
+	//	return nil, 0, err
+	//}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	//var statisticsLogs []*log.LogComputer
+	var statisticsLogs []*rentComputer.RentComputerShop
+	db = db.Limit(limit).Offset(offset)
+	if order != "" {
+		var OrderStr string
+		// 设置有效排序key 防止sql注入
+		// 感谢 Tom4t0 提交漏洞信息
+		orderMap := make(map[string]bool, 3)
+		orderMap["pc_code"] = true
+		orderMap["game_id"] = true
+		orderMap["operator"] = true
+		if orderMap[order] {
+			if desc {
+				OrderStr = order + " desc"
+			} else {
+				OrderStr = order
+			}
+		} else { // didn't matched any order key in `orderMap`
+			global.GVA_LOG.Error("获取失败!", zap.Error(err))
+			return statisticsLogs, total, err
+		}
+		err = db.Order(OrderStr).Find(&statisticsLogs).Error
+	} else {
+		err = db.Order("id").Find(&statisticsLogs).Error
+	}
+	if err != nil {
+		return nil, 0, err
+	}
+	var statisticsLogsComputer []*response.ComputerStatisticsReply1
+
+	for _, statisticsLog := range statisticsLogs {
+		/*var gameInfo []*response.GameInfo
+		err = json.Unmarshal([]byte(statisticsLog.GameInfo), &gameInfo)
+		for i, _ := range gameInfo {
+			statisticsLogComputer := new(response.ComputerStatisticsReply1)
+			statisticsLogComputer.GameInfo = gameInfo
+			statisticsLogComputer.PcCode = statisticsLog.PcCode
+			statisticsLogComputer.Operator = statisticsLog.Operator
+			statisticsLogComputer.CreateDate = statisticsLog.CreateDate[:10]
+			statisticsLogComputer.GameId = gameInfo[i].GameId
+			statisticsLogComputer.PullAccountNum = gameInfo[i].PullAccountNum
+			statisticsLogComputer.TaskSuccessNum = gameInfo[i].TaskSuccessNum
+			statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
+		}*/
+		//gameIdStr:=strconv.Itoa(statisticsLog.GameId)
+		//taskStatistics := s.GameTargetInfo(ctx,s.LogicalLog.CurrentDate(),gameIdStr)
+		statisticsLogComputer := new(response.ComputerStatisticsReply1)
+		statisticsLogComputer.Id = statisticsLog.Id
+		//updateTime, _ := time.ParseInLocation("2006-01-02 15:04:05", statisticsLog.UpdateTime, time.Local)
+		statisticsLogComputer.UpdateTime = statisticsLog.UpdateTime
+		//global.GVA_LOG.Info(statisticsLog.CreateTime.String())
+		//createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", statisticsLog.CreateTime, time.Local)
+		//global.GVA_LOG.Info(createTime.String())
+		statisticsLogComputer.PayMethod = statisticsLog.PayMethod
+		statisticsLogComputer.CreateTime = statisticsLog.CreateTime
+
+		statisticsLogComputer.Name = statisticsLog.Name
+		statisticsLogComputer.Description = statisticsLog.Description
+
+		//if isCurrentDate {
+		//	statisticsLogComputer.ComputerFeeRate = s.GetStatisticsPcFeeRate(ctx, statisticsLog.PcCode, statisticsLog.GameId)
+		//}
+		//statisticsLogComputer.ComputerHourAverageRate = statisticsLog.ComputerHourAverageRate
+		statisticsLogsComputer = append(statisticsLogsComputer, statisticsLogComputer)
+	}
+	return statisticsLogsComputer, total, err
+}
+
+func (s *ServiceRentComputerShop) GetRentComputerShopNum() int64 {
+	var total int64
+
+	db := global.GVA_DB.Model(&rentComputer.RentComputerShop{})
+	db = db.Distinct("name")
+	_ = db.Count(&total).Error
+	return total
+}
+
+func (s *ServiceRentComputerShop) GetRentComputerShopById(id int) (computerShop response.ComputerStatisticsReply1, err error) {
+	var api rentComputer.RentComputerShop
+	err = global.GVA_DB.Where("id = ?", id).First(&api).Error
+	if err != nil {
+		return
+	}
+	computerShop.Id = api.Id
+	computerShop.Name = api.Name
+	computerShop.PayMethod = api.PayMethod
+	computerShop.Description = api.Description
+	computerShop.UpdateTime = api.UpdateTime
+	computerShop.CreateTime = api.CreateTime
+	return
+}
+
+func (s *ServiceRentComputerShop) CurrentDate() (current string) {
+	current = time.Now().Format("2006-01-02")
+	return
+}
+
+func (s *ServiceRentComputerShop) AddRentComputerShop(requestCoding request.ComputerShopRequest) (err error) {
+	if !errors.Is(global.GVA_DB.Where("name = ?", requestCoding.Name).First(&rentComputer.RentComputerShop{}).Error, gorm.ErrRecordNotFound) {
+		return errors.New("存在相同供应商名")
+	}
+	computerShop := new(rentComputer.RentComputerShop)
+
+	computerShop.Name = requestCoding.Name
+	computerShop.PayMethod = requestCoding.PayMethod
+	computerShop.Description = requestCoding.Description
+	computerShop.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+	computerShop.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
+	//key := codeListCacheKey
+	//_ = s.cache.DelBatheHsCache(context.Background(), key)
+	return global.GVA_DB.Create(&computerShop).Error
+}
+
+func (s *ServiceRentComputerShop) EditRentComputerShop(computerShop rentComputer.RentComputerShop) (err error) {
+	err = global.GVA_DB.Save(computerShop).Error
+	return err
+}
+
+func (s *ServiceRentComputerShop) DeleteRentComputerShopByIds(ids request.IdsReq) (err error) {
+	err = global.GVA_DB.Delete(&[]rentComputer.RentComputerShop{}, "id in ?", ids.Ids).Error
+	return err
+}
+
+func (s *ServiceRentComputerShop) DeleteRentComputerShopById(api rentComputer.RentComputerShop) (err error) {
+	var entity rentComputer.RentComputerShop
+	err = global.GVA_DB.Where("id = ?", api.Id).First(&entity).Error // 根据id查询api记录
+	if errors.Is(err, gorm.ErrRecordNotFound) {                      // api记录不存在
+		return err
+	}
+	return global.GVA_DB.Delete(&entity).Error
+}

+ 204 - 0
service/rentComputer/rent_set_meal.go

@@ -0,0 +1,204 @@
+package rentComputer
+
+import (
+	"context"
+	"errors"
+	"go.uber.org/zap"
+	"gorm.io/gorm"
+	"log-server/global"
+	"log-server/model/rentComputer"
+	"log-server/model/rentComputer/request"
+	"log-server/model/rentComputer/response"
+	"time"
+)
+
+type ServiceRentSetMeal struct {
+}
+
+func (s *ServiceRentSetMeal) RentSetMealList(ctx context.Context, api rentComputer.RentSetMeal, info request.PageInfo, order string, desc bool) (interface{}, int64, error) {
+	//global.GVA_LOG.Info("service----GetComputerShopList----strat")
+	//date := api.CreateTime
+	//isCurrentDate := false
+	//if date == "" {
+	//	date = s.CurrentDate()
+	//	isCurrentDate = true
+	//}
+	db := global.GVA_DB.Model(&rentComputer.RentSetMeal{})
+	var total int64
+	db = db.Select("rent_set_meal.id, rent_set_meal.update_time,rent_set_meal.create_time,rent_set_meal.name," +
+		"rent_set_meal.remark,rent_set_meal.rent_price,rent_set_meal.price_type,rent_set_meal.rent_price_day,rent_set_meal.shop_id,s.name as shop_name")
+	db = db.Joins("left join rent_computer_shop s on s.id = rent_set_meal.shop_id")
+	//db = db.Distinct("pc_code", "id", "operator", "create_date", "GROUP_CONCAT(game_id) AS game_ids")
+	//db = db.Where("create_date = ?", date)
+	//if api.Operator != "" {
+	//	db = db.Where("operator like ?", "%"+api.Operator+"%")
+	//}
+	//if api.PcCode != "" {
+	//	db = db.Where("pc_code = ?", api.PcCode)
+	//}
+	//if api.GameId != 0 {
+	//	db = db.Where("game_id = ?", api.GameId)
+	//}
+	//.Select("count(distinct(name))").Count(&count)
+	//err := db.Count(&total).Error
+	//err := db.Select("count(distinct(pc_code))").Count(&total).Error
+	//db = db.Group("pc_code")
+	//db2 := global.GVA_DB.Model(&log.LogComputer{})
+	//db2 = db2.Select("count(distinct(pc_code))")
+	//db2 = db2.Where("create_date = ?", date)
+	//if api.Operator != "" {
+	//	db2 = db2.Where("operator like ?", "%"+api.Operator+"%")
+	//}
+	//if api.PcCode != "" {
+	//	db2 = db2.Where("pc_code = ?", api.PcCode)
+	//}
+	err := db.Count(&total).Error
+	//if err != nil {
+	//	return nil, 0, err
+	//}
+	limit := info.PageSize
+	offset := info.PageSize * (info.Page - 1)
+	//var statisticsLogs []*log.LogComputer
+	//var statisticsLogs []*rentComputer.RentSetMeal
+	var statisticsLogs []*response.SetMealStatisticsReply1
+	db = db.Limit(limit).Offset(offset)
+	if order != "" {
+		var OrderStr string
+		// 设置有效排序key 防止sql注入
+		// 感谢 Tom4t0 提交漏洞信息
+		orderMap := make(map[string]bool, 3)
+		orderMap["id"] = true
+		if orderMap[order] {
+			if desc {
+				OrderStr = order + " desc"
+			} else {
+				OrderStr = order
+			}
+		} else { // didn't matched any order key in `orderMap`
+			global.GVA_LOG.Error("获取失败!", zap.Error(err))
+			return statisticsLogs, total, err
+		}
+		err = db.Order(OrderStr).Find(&statisticsLogs).Error
+	} else {
+		err = db.Order("id").Find(&statisticsLogs).Error
+	}
+	if err != nil {
+		return nil, 0, err
+	}
+	var statisticsSetMeals []*response.SetMealStatisticsReply1
+
+	for _, statisticsLog := range statisticsLogs {
+
+		//gameIdStr:=strconv.Itoa(statisticsLog.GameId)
+		//taskStatistics := s.GameTargetInfo(ctx,s.LogicalLog.CurrentDate(),gameIdStr)
+		statisticsSetMeal := new(response.SetMealStatisticsReply1)
+		statisticsSetMeal.Id = statisticsLog.Id
+		//updateTime, _ := time.ParseInLocation("2006-01-02 15:04:05", statisticsLog.UpdateTime, time.Local)
+		statisticsSetMeal.UpdateTime = statisticsLog.UpdateTime
+		//global.GVA_LOG.Info(statisticsLog.CreateTime.String())
+		//createTime, _ := time.ParseInLocation("2006-01-02 15:04:05", statisticsLog.CreateTime, time.Local)
+		//global.GVA_LOG.Info(createTime.String())
+		statisticsSetMeal.CreateTime = statisticsLog.CreateTime
+		statisticsSetMeal.Name = statisticsLog.Name
+		statisticsSetMeal.Remark = statisticsLog.Remark
+		statisticsSetMeal.PriceType = statisticsLog.PriceType
+		statisticsSetMeal.RentPriceDay = statisticsLog.RentPriceDay
+		statisticsSetMeal.RentPrice = statisticsLog.RentPrice
+		statisticsSetMeal.ShopId = statisticsLog.ShopId
+		statisticsSetMeal.ShopName = statisticsLog.ShopName
+		//if isCurrentDate {
+		//	statisticsLogComputer.ComputerFeeRate = s.GetStatisticsPcFeeRate(ctx, statisticsLog.PcCode, statisticsLog.GameId)
+		//}
+		//statisticsLogComputer.ComputerHourAverageRate = statisticsLog.ComputerHourAverageRate
+		statisticsSetMeals = append(statisticsSetMeals, statisticsSetMeal)
+	}
+	return statisticsSetMeals, total, err
+}
+
+func (s *ServiceRentSetMeal) GetRentSetMealNum() int64 {
+	var total int64
+
+	db := global.GVA_DB.Model(&rentComputer.RentSetMeal{})
+	db = db.Distinct("id")
+	_ = db.Count(&total).Error
+	return total
+}
+
+func (s *ServiceRentSetMeal) GetRentSetMealById(id int) (computerShop response.SetMealStatisticsReply1, err error) {
+	var api rentComputer.RentSetMeal
+	err = global.GVA_DB.Where("id = ?", id).First(&api).Error
+	if err != nil {
+		return
+	}
+	computerShop.Id = api.Id
+	computerShop.Name = api.Name
+	computerShop.Remark = api.Remark
+	computerShop.RentPrice = api.RentPrice
+	computerShop.PriceType = api.PriceType
+	computerShop.RentPriceDay = api.RentPriceDay
+	computerShop.ShopId = api.ShopId
+	computerShop.UpdateTime = api.UpdateTime
+	computerShop.CreateTime = api.CreateTime
+	return
+}
+
+func (s *ServiceRentSetMeal) AddRentSetMeal(requestCoding request.SetMealRequest) (err error) {
+	//fmt.Printf("%#v\n", &requestCoding)
+	if !errors.Is(global.GVA_DB.Where("name = ? and price_type = ? and shop_id = ?", requestCoding.Name, requestCoding.PriceType, requestCoding.ShopId).First(&rentComputer.RentSetMeal{}).Error, gorm.ErrRecordNotFound) {
+		return errors.New("存在相同套餐")
+	}
+	computerShop := new(rentComputer.RentSetMeal)
+
+	priceType := requestCoding.PriceType
+	rentPrice := requestCoding.RentPrice
+	rentPriceDay := float64(0)
+	computerShop.Name = requestCoding.Name
+	computerShop.Remark = requestCoding.Remark
+
+	if priceType == 0 {
+		rentPriceDay = float64(int(rentPrice))
+	} else if priceType == 1 {
+		rentPriceDay = rentPrice / 7
+	} else if priceType == 2 {
+		rentPriceDay = rentPrice / 30
+	}
+	computerShop.PriceType = priceType
+	computerShop.RentPrice = rentPrice
+	computerShop.RentPriceDay = rentPriceDay
+	computerShop.ShopId = requestCoding.ShopId
+	computerShop.CreateTime = time.Now().Format("2006-01-02 15:04:05")
+	computerShop.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
+	//key := codeListCacheKey
+	//_ = s.cache.DelBatheHsCache(context.Background(), key)
+	return global.GVA_DB.Create(&computerShop).Error
+}
+
+func (s *ServiceRentSetMeal) EditRentSetMeal(setMeal rentComputer.RentSetMeal) (err error) {
+	priceType := setMeal.PriceType
+	rentPrice := setMeal.RentPrice
+	rentPriceDay := float64(0)
+	if priceType == 0 {
+		rentPriceDay = float64(int(rentPrice))
+	} else if priceType == 1 {
+		rentPriceDay = rentPrice / 7
+	} else if priceType == 2 {
+		rentPriceDay = rentPrice / 30
+	}
+	setMeal.RentPriceDay = rentPriceDay
+	err = global.GVA_DB.Save(setMeal).Error
+	return err
+}
+
+func (s *ServiceRentSetMeal) DeleteRentSetMealByIds(ids request.IdsReq) (err error) {
+	err = global.GVA_DB.Delete(&[]rentComputer.RentSetMeal{}, "id in ?", ids.Ids).Error
+	return err
+}
+
+func (s *ServiceRentSetMeal) DeleteRentSetMealById(api rentComputer.RentSetMeal) (err error) {
+	var entity rentComputer.RentSetMeal
+	err = global.GVA_DB.Where("id = ?", api.Id).First(&entity).Error // 根据id查询api记录
+	if errors.Is(err, gorm.ErrRecordNotFound) {                      // api记录不存在
+		return err
+	}
+	return global.GVA_DB.Delete(&entity).Error
+}

Разница между файлами не показана из-за своего большого размера
+ 4 - 0
service/typeManage/tm_gameList.go