kobe6258 преди 3 месеца
родител
ревизия
bf925f5948

+ 1 - 0
controllers/payment/payment_controller.go

@@ -70,6 +70,7 @@ func (pc *PaymentController) PayOrder() {
 				}
 				return
 			}
+			//1、未发起支付,2、支付到一半退出了,3、支付中
 			if productOrder.TradeNo != "" {
 				tradeOrder, tradeErr := order.GetTradeOrderByNo(productOrder.TradeNo)
 				if tradeErr != nil {

+ 12 - 0
domian/merchant/merchant_product.go

@@ -174,3 +174,15 @@ func ProductListBySort(isSignal bool, list []reportDomain.ProductSearchDTO, weig
 	}
 	return
 }
+
+func GetOffSaleProducts(productTypeList []string) (dtoList []MerchantProductDTO, err error) {
+	var productTypeQuery []merchantDao.MerchantProductType
+	for _, productType := range productTypeList {
+		productTypeQuery = append(productTypeQuery, typeKindTransfer[productType])
+	}
+	list, err := merchantDao.GetOffSaleProducts(productTypeQuery)
+	for _, product := range list {
+		dtoList = append(dtoList, convertToDTO(product))
+	}
+	return
+}

+ 5 - 0
domian/order/product_order.go

@@ -1,6 +1,7 @@
 package order
 
 import (
+	"errors"
 	logger "eta/eta_mini_ht_api/common/component/log"
 	"eta/eta_mini_ht_api/common/exception"
 	"eta/eta_mini_ht_api/common/utils/page"
@@ -8,6 +9,7 @@ import (
 	productDao "eta/eta_mini_ht_api/models/merchant"
 	orderDao "eta/eta_mini_ht_api/models/order"
 	"fmt"
+	"gorm.io/gorm"
 	"math/rand"
 	"sync"
 	"time"
@@ -332,6 +334,9 @@ func GetOrderByUser(templateUserId int, orderNo string) (orderDTO ProductOrderDT
 	order, err = orderDao.GetOrderByUser(templateUserId, orderNo)
 	product, err := productDao.GetMerchantProductById(order.ProductID)
 	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			//产品被删除了
+		}
 		logger.Error("获取产品信息失败:%v", err)
 		return
 	}

+ 29 - 2
domian/report/report_service.go

@@ -10,6 +10,7 @@ import (
 	stringUtils "eta/eta_mini_ht_api/common/utils/string"
 	configService "eta/eta_mini_ht_api/domian/config"
 	analystService "eta/eta_mini_ht_api/domian/financial_analyst"
+	merchantService "eta/eta_mini_ht_api/domian/merchant"
 	messageDomian "eta/eta_mini_ht_api/domian/message"
 	userService "eta/eta_mini_ht_api/domian/user"
 	"eta/eta_mini_ht_api/models"
@@ -845,7 +846,6 @@ func GetReportByIdListByOrgIds(orgIds map[string][]int) (ids []int, err error) {
 }
 
 func GetTotalPageCountByPermissionIds(permissionIds []int, riskLevel string) (total int64, latestId int64, ids map[string][]int) {
-
 	htOrgIds, err := GetHTReportIdsByPermissionIdsWithRiskLevel(permissionIds, riskLevel)
 	if err != nil {
 		logger.Error("品种筛选ht报告id失败:%v", err)
@@ -872,8 +872,35 @@ func GetTotalPageCountByPermissionIds(permissionIds []int, riskLevel string) (to
 	} else {
 		ids["HT"] = htOrgIds
 	}
+	//获取一下下架的报告产品
+	var offSaleProducts []merchantService.MerchantProductDTO
+	var disCardReportIds []int
+	offSaleProducts, err = merchantService.GetOffSaleProducts([]string{"report", "package"})
+	if err != nil {
+		logger.Error("获取下架的报告产品失败:%v", err)
+	}
+	for _, product := range offSaleProducts {
+		if product.Type == "package" {
+			permission, permissionErr := permissionDao.PermissionsByPermissionId(product.SourceId)
+			if permissionErr != nil {
+				logger.Error("获取权限信息失败[permissionId:%d]", product.SourceId)
+				continue
+			}
+			classifyIds, classifyErr := permissionDao.GetClassifyIdsByPermissionIds([]int{permission.PermissionId})
+			if classifyErr != nil {
+				logger.Error("获取ETA报告分类id失败:%v", err)
+			}
+			disCardIds, _ := reportDao.GetHiddenReportIds(classifyIds, permission.Name)
+			if len(disCardIds) > 0 {
+				disCardReportIds = append(disCardReportIds, disCardIds...)
+			}
 
-	total, latestId, err = reportDao.GetMaxIdByPermissionIds(ids)
+		}
+		if product.Type == "report" {
+			disCardReportIds = append(disCardReportIds, product.SourceId)
+		}
+	}
+	total, latestId, err = reportDao.GetMaxIdByPermissionIds(ids, disCardReportIds)
 	if err != nil {
 		logger.Error("获取筛选报告的最大记录和记录数失败:%v", err)
 		return

+ 6 - 0
models/merchant/merchant_product.go

@@ -230,3 +230,9 @@ func PackageListBySort(weightMap map[int]*atomic.Int32, id int64, offset int, si
 	err = db.Select(detailColumns).Where("id <= ?  and type =? and deleted =? and source_id in ? order by Field(id,?) desc limit ?,? ", id, Package, false, idSort, strings.Join(stringUtils.IntToStringSlice(idSort), ","), offset, size).Find(&productList).Error
 	return
 }
+
+func GetOffSaleProducts(query []MerchantProductType) (list []MerchantProduct, err error) {
+	db := models.Main()
+	err = db.Select(detailColumns).Where(" deleted =? and  type  in ?  and sale_status = ? ", query, false, OffSale).Find(&list).Error
+	return
+}

+ 20 - 7
models/report/report.go

@@ -226,7 +226,7 @@ func GetReportIdListByOrgIds(orgIds map[string][]int) (ids []int, err error) {
 	}
 	return
 }
-func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64, err error) {
+func GetMaxIdByPermissionIds(orgIds map[string][]int, disCardIds []int) (total int64, maxId int64, err error) {
 	db := models.Main()
 	if len(orgIds["ETA"]) == 0 && len(orgIds["HT"]) == 0 {
 		//err := db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Scan(&maxId).Error
@@ -239,12 +239,12 @@ func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64,
 		return
 	}
 	if len(orgIds["ETA"]) == 0 {
-		err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&total).Error
+		err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ? and id not in ?", orgIds["HT"], disCardIds).Scan(&total).Error
 		if err != nil {
 			logger.Error("获取记录条数失败:%v", err)
 			return
 		}
-		err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
+		err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='HT' and org_id in ? and id not in ?", orgIds["HT"], disCardIds).Scan(&maxId).Error
 		if err != nil {
 			logger.Error("获取报告最大ID失败:%v", err)
 			return
@@ -252,24 +252,24 @@ func GetMaxIdByPermissionIds(orgIds map[string][]int) (total int64, maxId int64,
 		return
 	}
 	if len(orgIds["HT"]) == 0 {
-		err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&total).Error
+		err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"], disCardIds).Scan(&total).Error
 		if err != nil {
 			logger.Error("获取报告最大ID失败:%v", err)
 			return
 		}
-		err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Scan(&maxId).Error
+		err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"], disCardIds).Scan(&maxId).Error
 		if err != nil {
 			logger.Error("获取报告最大ID失败:%v", err)
 			return
 		}
 		return
 	}
-	err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&total).Error
+	err = db.Model(&Report{}).Select("count(*)").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"], disCardIds).Scan(&total).Error
 	if err != nil {
 		logger.Error("获取报告最大ID失败:%v", err)
 		return
 	}
-	err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"]).Scan(&maxId).Error
+	err = db.Model(&Report{}).Select("MAX(id) id").Where("status = ?", StatusPublish).Where(" source='ETA' and org_id in ? and id not in ?", orgIds["ETA"]).Or("source='HT' and org_id in ?", orgIds["HT"], disCardIds).Scan(&maxId).Error
 	if err != nil {
 		logger.Error("获取报告最大ID失败:%v", err)
 		return
@@ -407,3 +407,16 @@ select cpm.permission_id from reports  r LEFT JOIN (SELECT classify_id,permissio
 	err = db.Raw(sql, ids, ids).Find(&list).Error
 	return
 }
+
+func GetHiddenReportIds(classifyIds []int, plateName string) (reportIds []int, err error) {
+	db := models.Main()
+	exc := db.Model(&Report{}).Select("id")
+	if len(classifyIds) == 0 {
+		exc.Where("(source='ETA' and classify_id in ?)", classifyIds)
+	}
+	if plateName != "" {
+		exc.Or("(source='HT' and plate_name = ?)", plateName)
+	}
+	err = exc.Scan(&reportIds).Error
+	return
+}