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

Merge remote-tracking branch 'origin/master'

wangbin лет назад: 3
Родитель
Сommit
761522a436

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

@@ -175,3 +175,15 @@ func (s *ApiRentComputer) ReplaceNumRentComputer(c *gin.Context) {
 		response.OkWithMessage(okMessage, c)
 		response.OkWithMessage(okMessage, c)
 	}
 	}
 }
 }
+
+// OffShelfRentComputer 租机下架
+func (s *ApiRentComputer) OffShelfRentComputer(c *gin.Context) {
+	var api request.ComputerRequest
+	_ = c.ShouldBindJSON(&api)
+	if err := ServiceRentComputer.OffShelfRentComputer(api); err != nil {
+		global.GVA_LOG.Error("租机下架失败!", zap.Error(err))
+		response.FailWithMessage("租机下架失败", c)
+	} else {
+		response.OkWithMessage(time.Now().Format("2006-01-02 15:04:05")+",租机编号"+api.PcNum+"下架成功", c)
+	}
+}

BIN
resource/excel/2023-3-13/1678675436.xlsx


BIN
resource/excel/2023-3-13/1678675558.xlsx


BIN
resource/excel/2023-3-13/1678675908.xlsx


BIN
resource/excel/2023-3-13/1678676210.xlsx


+ 1 - 0
router/rentComputer/rent_computer.go

@@ -23,6 +23,7 @@ func (e *RentComputerRouter) InitRentComputerRouter(Router *gin.RouterGroup) {
 		excelRouter.POST("renewRentComputer", rentComputerApi.RenewRentComputer)               //租机续费
 		excelRouter.POST("renewRentComputer", rentComputerApi.RenewRentComputer)               //租机续费
 		excelRouter.POST("replaceNumRentComputer", rentComputerApi.ReplaceNumRentComputer)     //租机更换编号
 		excelRouter.POST("replaceNumRentComputer", rentComputerApi.ReplaceNumRentComputer)     //租机更换编号
 		excelRouter.POST("rentingOutRentComputer", rentComputerApi.RentingOutRentComputer)     //租机提前退租
 		excelRouter.POST("rentingOutRentComputer", rentComputerApi.RentingOutRentComputer)     //租机提前退租
+		excelRouter.POST("offShelfRentComputer", rentComputerApi.OffShelfRentComputer)         //租机下架
 
 
 	}
 	}
 }
 }

+ 24 - 0
service/dataStatistics/data_abnormal_rate.go

@@ -203,10 +203,12 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 	}
 	}
 	xjfJson, err := simplejson.NewJson(dataXjf)
 	xjfJson, err := simplejson.NewJson(dataXjf)
 	if err != nil {
 	if err != nil {
+		global.GVA_LOG.Error("Error", zap.Error(err))
 		return
 		return
 	}
 	}
 	xjfArr, err := xjfJson.Array()
 	xjfArr, err := xjfJson.Array()
 	if err != nil {
 	if err != nil {
+		global.GVA_LOG.Error("Error", zap.Error(err))
 		return
 		return
 	}
 	}
 	//查询微信扫码订单数
 	//查询微信扫码订单数
@@ -229,15 +231,20 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 				if string(result) != "null" {
 				if string(result) != "null" {
 					dataJson, err := simplejson.NewJson(result)
 					dataJson, err := simplejson.NewJson(result)
 					if err != nil {
 					if err != nil {
+						global.GVA_LOG.Error("Error", zap.Error(err))
 						return
 						return
 					}
 					}
 					dataArr, err := dataJson.Array()
 					dataArr, err := dataJson.Array()
 					if err != nil {
 					if err != nil {
+						global.GVA_LOG.Error("Error", zap.Error(err))
 						return
 						return
 					}
 					}
 					for iii, _ := range dataArr {
 					for iii, _ := range dataArr {
 						info := dataJson.GetIndex(iii)
 						info := dataJson.GetIndex(iii)
 						gameId, _ := info.Get("game_id").Int()
 						gameId, _ := info.Get("game_id").Int()
+						if gameId == 0 {
+							continue
+						}
 						total, _ := info.Get("total").Int()
 						total, _ := info.Get("total").Int()
 						//var arr = XjfTotal{GameId: gameId, Total: total}
 						//var arr = XjfTotal{GameId: gameId, Total: total}
 						//arrTemp = append(arrTemp, arr)
 						//arrTemp = append(arrTemp, arr)
@@ -262,21 +269,33 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 			}
 			}
 			dataJson, err := simplejson.NewJson(result)
 			dataJson, err := simplejson.NewJson(result)
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 			dataArr, err := dataJson.Array()
 			dataArr, err := dataJson.Array()
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 			arrTemp := make(map[int]int)
 			arrTemp := make(map[int]int)
 			for iii, _ := range dataArr {
 			for iii, _ := range dataArr {
 				info := dataJson.GetIndex(iii)
 				info := dataJson.GetIndex(iii)
 				gameId, err := info.Get("game_id").Int()
 				gameId, err := info.Get("game_id").Int()
+				global.GVA_LOG.Info(strconv.Itoa(gameId))
+				if gameId == 0 {
+					continue
+				}
 				if err != nil {
 				if err != nil {
+					global.GVA_LOG.Error(err.Error())
 					return
 					return
 				}
 				}
 				total, err := info.Get("total").Int()
 				total, err := info.Get("total").Int()
+				global.GVA_LOG.Info(strconv.Itoa(total))
+				if total == 0 && err != nil {
+					continue
+				}
 				if err != nil {
 				if err != nil {
+					global.GVA_LOG.Error(err.Error())
 					return
 					return
 				}
 				}
 				//global.GVA_LOG.Info(strconv.Itoa(gameId))
 				//global.GVA_LOG.Info(strconv.Itoa(gameId))
@@ -364,11 +383,13 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 			info := xjfJson.GetIndex(iii)
 			info := xjfJson.GetIndex(iii)
 			gameId, err := info.Get("game_id").Int()
 			gameId, err := info.Get("game_id").Int()
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 			if gameId == task.TaskId {
 			if gameId == task.TaskId {
 				orderSuccessRate, err = info.Get("order_success_rate").String()
 				orderSuccessRate, err = info.Get("order_success_rate").String()
 				if err != nil {
 				if err != nil {
+					global.GVA_LOG.Error("Error", zap.Error(err))
 					return
 					return
 				}
 				}
 				break
 				break
@@ -379,6 +400,7 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 			numOrderPay, err = strconv.Atoi(orderSuccessRateArr[0]) // 付费订单数
 			numOrderPay, err = strconv.Atoi(orderSuccessRateArr[0]) // 付费订单数
 			numPay, err = strconv.Atoi(orderSuccessRateArr[1])      // 付费成功数
 			numPay, err = strconv.Atoi(orderSuccessRateArr[1])      // 付费成功数
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 			ratePaySuccess = orderSuccessRateArr[2] //付费成功率
 			ratePaySuccess = orderSuccessRateArr[2] //付费成功率
@@ -418,6 +440,7 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 			//global.GVA_LOG.Info("已存在,更新")
 			//global.GVA_LOG.Info("已存在,更新")
 			err = global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).Updates(data).Error
 			err = global.GVA_DB.Model(&dataStatistics.DataAbnormalRate{}).Where("new_date = ? and task_id = ? and hour = ?", newDate, taskId, hour).Updates(data).Error
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 		} else {
 		} else {
@@ -425,6 +448,7 @@ func (s *ServiceDataAbnormalRate) SyncAbnormalRateByBatch() {
 			//global.GVA_LOG.Info("不存在,新建")
 			//global.GVA_LOG.Info("不存在,新建")
 			err = global.GVA_DB.Create(&data).Error
 			err = global.GVA_DB.Create(&data).Error
 			if err != nil {
 			if err != nil {
+				global.GVA_LOG.Error("Error", zap.Error(err))
 				return
 				return
 			}
 			}
 		}
 		}

+ 26 - 5
service/rentComputer/rent_computer.go

@@ -40,7 +40,7 @@ func (s *ServiceRentComputer) RentComputerList(ctx context.Context, api rentComp
 	}
 	}
 	if api.DirectorName != "ALL" {
 	if api.DirectorName != "ALL" {
 		if api.DirectorName == "" {
 		if api.DirectorName == "" {
-			db = db.Where("rent_computer.director_name IS NULL")
+			db = db.Where("rent_computer.director_name IS NULL or rent_computer.director_name = ''")
 		} else {
 		} else {
 			db = db.Where("rent_computer.director_name = ?", api.DirectorName)
 			db = db.Where("rent_computer.director_name = ?", api.DirectorName)
 		}
 		}
@@ -48,9 +48,9 @@ func (s *ServiceRentComputer) RentComputerList(ctx context.Context, api rentComp
 	//
 	//
 	//global.GVA_LOG.Info(strconv.Itoa(int(api.IsOffShelf)))
 	//global.GVA_LOG.Info(strconv.Itoa(int(api.IsOffShelf)))
 	//global.GVA_LOG.Info(strconv.Itoa(int(api.IsExpire)))
 	//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.IsOffShelf != -1 {
+		db = db.Where("rent_computer.is_off_shelf = ?", api.IsOffShelf)
+	}
 	if api.IsExpire != -1 {
 	if api.IsExpire != -1 {
 		db = db.Where("rent_computer.is_expire = ?", api.IsExpire)
 		db = db.Where("rent_computer.is_expire = ?", api.IsExpire)
 	}
 	}
@@ -141,7 +141,7 @@ func (s *ServiceRentComputer) GetRentComputerNum(ctx context.Context, api rentCo
 	}
 	}
 	if api.DirectorName != "ALL" {
 	if api.DirectorName != "ALL" {
 		if api.DirectorName == "" {
 		if api.DirectorName == "" {
-			db = db.Where("rent_computer.director_name IS NULL")
+			db = db.Where("rent_computer.director_name IS NULL or rent_computer.director_name = ''")
 		} else {
 		} else {
 			db = db.Where("rent_computer.director_name = ?", api.DirectorName)
 			db = db.Where("rent_computer.director_name = ?", api.DirectorName)
 		}
 		}
@@ -149,6 +149,9 @@ func (s *ServiceRentComputer) GetRentComputerNum(ctx context.Context, api rentCo
 	if api.IsExpire != -1 {
 	if api.IsExpire != -1 {
 		db = db.Where("rent_computer.is_expire = ?", api.IsExpire)
 		db = db.Where("rent_computer.is_expire = ?", api.IsExpire)
 	}
 	}
+	if api.IsOffShelf != -1 {
+		db = db.Where("rent_computer.is_off_shelf = ?", api.IsOffShelf)
+	}
 	_ = db.Count(&total).Error
 	_ = db.Count(&total).Error
 	return total
 	return total
 }
 }
@@ -330,6 +333,24 @@ func (s *ServiceRentComputer) RentingOutRentComputer(api request.RentingOutRentC
 	return "", err, remark
 	return "", err, remark
 }
 }
 
 
+// OffShelfRentComputer 租机下架
+func (s *ServiceRentComputer) OffShelfRentComputer(api request.ComputerRequest) (err error) {
+	var info rentComputer.RentComputer
+	if errors.Is(global.GVA_DB.Model(&rentComputer.RentComputer{}).Where("id = ?", api.Id).First(&info).Error, gorm.ErrRecordNotFound) {
+		return err
+	}
+	//global.GVA_LOG.Info(info.PcNum)
+	remark := time.Now().Format("2006-01-02 15:04:05") + ",租机编号" + api.PcNum + "下架;\n"
+	global.GVA_LOG.Info(remark)
+	var updateInfo rentComputer.RentComputer
+	updateInfo.UpdateTime = time.Now().Format("2006-01-02 15:04:05")
+	updateInfo.IsOffShelf = 1
+	updateInfo.PcNum = "offShelf_" + api.PcNum + "_" + strconv.Itoa(int(time.Now().Unix()))
+	updateInfo.Remark = info.Remark + remark
+	err = global.GVA_DB.Model(&rentComputer.RentComputer{}).Where("id = ?", api.Id).Updates(updateInfo).Error
+	return err
+}
+
 // ReplaceNumRentComputer 租机换编号
 // ReplaceNumRentComputer 租机换编号
 func (s *ServiceRentComputer) ReplaceNumRentComputer(api request.ReplaceNumRentComputerRequest) (errMessage string, err error, okMessage string) {
 func (s *ServiceRentComputer) ReplaceNumRentComputer(api request.ReplaceNumRentComputerRequest) (errMessage string, err error, okMessage string) {
 	var infoOld rentComputer.RentComputer
 	var infoOld rentComputer.RentComputer