Procházet zdrojové kódy

修改风险等级展示

kobe6258 před 5 měsíci
rodič
revize
7c83c5f5c0

+ 1 - 1
domian/order/product_order.go

@@ -179,7 +179,7 @@ func BatchCloseOrder() (err error) {
 	//		go func() {
 	//			defer wg.Done()
 	//			var ids []int
-	//			ids, minId = orderDao.GetPendingOrderIds(minId, 500)
+	//			ids, minId = orderDao.GetExpiredPendingOrderIds(minId, 500)
 	//			err = orderDao.batchCloseOrder(ids)
 	//		}()
 	//	}

+ 4 - 5
models/order/product_order.go

@@ -110,22 +110,21 @@ func GetOrderDetail(orderId int, userId int) (order ProductOrder, err error) {
 
 func GetUnPendingOrderCount() (count int, minId int) {
 	db := models.Main()
-	_ = db.Model(&ProductOrder{}).Select("count(*)").Where("is_deleted=0 and status=?", OrderStatusPending).Scan(&count).Error
+	_ = db.Model(&ProductOrder{}).Select("count(*)").Where("is_deleted=0 and status=? and expired_time <= ?", OrderStatusPending, time.Now()).Scan(&count).Error
 	_ = db.Model(&ProductOrder{}).Select("MIN(id)").Where("is_deleted=0 and status =?", OrderStatusPending).Scan(&minId).Error
 	return
 }
 
-func GetPendingOrderIds(minId int, limit int) (ids []int, latestId int) {
+func GetExpiredPendingOrderIds(minId int, limit int) (ids []int) {
 	db := models.Main()
-	_ = db.Model(&ProductOrder{}).Select("id").Where("id> ? and status=? and  is_deleted=0 order by id asc", minId, OrderStatusPending).Limit(limit).Scan(&ids).Error
-	latestId = ids[0]
+	_ = db.Model(&ProductOrder{}).Select("id").Where("id> ? and status=? and  is_deleted=0 and expired_time < ? order by id asc", minId, OrderStatusPending, time.Now()).Where("", time.Now()).Limit(limit).Scan(&ids).Error
 	return
 }
 
 func batchCloseOrder(ids []int) error {
 	//db := models.Main()
 	//_ = db.Model(&ProductOrder{}).Select("id").Where("id> ? and status=? and  is_deleted=0 order by id asc", minId, OrderStatusPending).Limit(limit).Scan(&ids).Error
-	//err = db.Model(&VerificationRecord{}).Where("expired_time < ?", time.Now()).Where("status =?", StatusPending).Update("status", StatusExpired).Error
+	//err = db.Model(&ProductOrder{}).Where("expired_time < ?", time.Now()).Where("status =?", StatusPending).Update("status", StatusExpired).Error
 	//if err != nil {
 	//	logger.Error("批量过期验证码失败:%v", err)
 	//}

+ 6 - 3
service/media/media_service.go

@@ -290,7 +290,8 @@ func GetMediaById(mediaType string, mediaId int, isLogin bool, userId int) (medi
 		return
 	}
 	var status string
-	status, err = matchRiskLevel(userId, media)
+
+	status, media.RiskLevel, err = matchRiskLevel(userId, media)
 	if err != nil {
 		logger.Error("匹配风险等级失败:%v", err)
 		err = exception.New(exception.ReportRiskLevelUnSet)
@@ -316,9 +317,10 @@ func GetMediaById(mediaType string, mediaId int, isLogin bool, userId int) (medi
 		media.RiskLevelStatus = RiskLevelUnMatch
 		media.Login = false
 	}
+
 	return
 }
-func matchRiskLevel(userId int, media mediaService.MediaDTO) (riskLevelMatch string, err error) {
+func matchRiskLevel(userId int, media mediaService.MediaDTO) (riskLevelMatch string, productRiskLevel string, err error) {
 	userProfile, userErr := user.GetUserProfile(userId)
 	if userErr != nil {
 		if errors.Is(userErr, gorm.ErrRecordNotFound) {
@@ -370,7 +372,8 @@ func matchRiskLevel(userId int, media mediaService.MediaDTO) (riskLevelMatch str
 		return
 	}
 	//能够查看需要的最小等级
-	num := getLowestRiskLevel(permissionDTOs)
+	num := getHighestRiskLevel(permissionDTOs)
+	productRiskLevel = fmt.Sprintf("R%d", num)
 	if num > matchNum {
 		riskLevelMatch = RiskLevelUnMatch
 		return

+ 2 - 2
service/report/report_service.go

@@ -86,7 +86,7 @@ type RecordCount struct {
 	Additional string
 }
 
-func matchRiskLevel(userId int, report reportService.ReportDTO) (riskLevelMatch string, err error) {
+func matchRiskLevel(userId int, report reportService.ReportDTO) (riskLevelMatch string, riskLevel string, err error) {
 	userProfile, userErr := user.GetUserProfile(userId)
 	if userErr != nil {
 		if errors.Is(userErr, gorm.ErrRecordNotFound) {
@@ -193,7 +193,7 @@ func GetReportById(reportId int, login bool, userId int) (report reportService.R
 		return
 	}
 	var status string
-	status, err = matchRiskLevel(userId, report)
+	status, report.RiskLevel, err = matchRiskLevel(userId, report)
 	if err != nil {
 		logger.Error("匹配风险等级失败:%v", err)
 		err = exception.New(exception.ReportRiskLevelUnSet)