瀏覽代碼

增加系统配置接口

kobe6258 4 月之前
父節點
當前提交
a4894f1739
共有 3 個文件被更改,包括 16 次插入25 次删除
  1. 14 24
      controllers/order.go
  2. 1 0
      models/product_order.go
  3. 1 1
      models/user_subscription_access_list.go

+ 14 - 24
controllers/order.go

@@ -232,6 +232,7 @@ func (this *OrderController) ProductOrderList() {
 			Status:        ProductOrderStatus[orderItem.Status],
 			RefundStatus:  RefundStatusMap[orderItem.RefundStatus],
 			Remark:        orderItem.Remark,
+			ValidDuration: orderItem.ValidDuration,
 			CreatedTime:   orderItem.CreatedTime.Format(time.DateTime),
 		}
 		if orderItem.TradeNo != "" {
@@ -243,18 +244,6 @@ func (this *OrderController) ProductOrderList() {
 				view.PaymentAmount = fmt.Sprintf("¥%s", tradeOrder.Amount)
 			}
 		}
-		if orderItem.Status == models.OrderStatusPaid {
-			access, accessErr := models.GetAccess(orderItem.ProductId, orderItem.TemplateUserId)
-			if accessErr != nil {
-				utils.FileLog.Error("获取用户订阅记录失败,templateUserId:" + string(rune(orderItem.TemplateUserId)) + "productId:" + string(rune(orderItem.ProductId)) + ",err:" + accessErr.Error())
-			} else {
-				if access.ProductType == models.ProductPackage {
-					view.ValidDuration = fmt.Sprintf("%s~%s", access.BeginDate.Format(time.DateOnly), access.EndDate.Format(time.DateOnly))
-				} else {
-					view.ValidDuration = "永久有效"
-				}
-			}
-		}
 		if orderItem.Status == models.OrderStatusRefund && orderItem.RefundStatus == models.RefundStatusSuccess {
 			view.RefundFinishTime = orderItem.RefundFinishTime.Format(time.DateTime)
 		}
@@ -509,6 +498,7 @@ func (this *OrderController) ExportProductOrder() {
 			RefundStatus:  RefundStatusMap[orderItem.RefundStatus],
 			Remark:        orderItem.Remark,
 			CreatedTime:   orderItem.CreatedTime.Format(time.DateTime),
+			ValidDuration: orderItem.ValidDuration,
 		}
 		if orderItem.TradeNo != "" {
 			view.PaymentTime = orderItem.PaymentTime.Format(time.DateTime)
@@ -519,18 +509,18 @@ func (this *OrderController) ExportProductOrder() {
 				view.PaymentAmount = fmt.Sprintf("¥%s", tradeOrder.Amount)
 			}
 		}
-		if orderItem.Status == models.OrderStatusPaid {
-			access, accessErr := models.GetAccess(orderItem.ProductId, orderItem.TemplateUserId)
-			if accessErr != nil {
-				utils.FileLog.Error("获取用户订阅记录失败,templateUserId:" + string(rune(orderItem.TemplateUserId)) + "productId:" + string(rune(orderItem.ProductId)) + ",err:" + accessErr.Error())
-			} else {
-				if access.ProductType == models.ProductPackage {
-					view.ValidDuration = fmt.Sprintf("%s~%s", access.BeginDate.Format(time.DateOnly), access.EndDate.Format(time.DateOnly))
-				} else {
-					view.ValidDuration = "永久有效"
-				}
-			}
-		}
+		//if orderItem.Status == models.OrderStatusPaid {
+		//	access, accessErr := models.GetAccess(orderItem.ProductId, orderItem.TemplateUserId)
+		//	if accessErr != nil {
+		//		utils.FileLog.Error("获取用户订阅记录失败,templateUserId:" + string(rune(orderItem.TemplateUserId)) + "productId:" + string(rune(orderItem.ProductId)) + ",err:" + accessErr.Error())
+		//	} else {
+		//		if access.ProductType == models.ProductPackage {
+		//			view.ValidDuration = fmt.Sprintf("%s~%s", access.BeginDate.Format(time.DateOnly), access.EndDate.Format(time.DateOnly))
+		//		} else {
+		//			view.ValidDuration = "永久有效"
+		//		}
+		//	}
+		//}
 		if orderItem.Status == models.OrderStatusRefund && orderItem.RefundStatus == models.RefundStatusSuccess {
 			view.RefundFinishTime = orderItem.RefundFinishTime.Format(time.DateTime)
 		}

+ 1 - 0
models/product_order.go

@@ -71,6 +71,7 @@ type ProductOrder struct {
 	Status           OrderStatus         `gorm:"column:status;type:enum('pending','processing','paid','closed','refund');default:'pending';comment:'订单状态'" json:"status"`
 	RefundStatus     RefundStatus        `gorm:"column:refund_status;type:enum('pending','processing','failed','success');default:null;comment:'退款状态'" json:"refund_status"`
 	RefundFinishTime time.Time           `gorm:"column:refund_finish_time;default:null;comment:'退款完成时间'" json:"refund_finish_time"`
+	ValidDuration    string              `gorm:"column:valid_duration;default:null;comment:'订单有效期'" json:"valid_duration"`
 	Remark           string              `gorm:"column:remark;size:255;default:null;comment:'备注'" json:"remark"`
 	IsDeleted        int                 `gorm:"column:is_deleted;size:1;default:0;comment:'是否删除'" json:"is_deleted"`
 	CreatedTime      time.Time           `gorm:"column:created_time;default:null;comment:'创建时间'" json:"created_time"`

+ 1 - 1
models/user_subscription_access_list.go

@@ -30,6 +30,6 @@ const (
 
 func GetAccess(productId int, templateUserId int) (access *UserSubscriptionAccessList, err error) {
 	o := orm.NewOrm()
-	err = o.Raw("select * from UserSubscriptionAccessList where template_user_id=? and  product_id =? ", templateUserId, productId).QueryRow(&access)
+	err = o.Raw("select * from user_subscription_access_list where template_user_id=? and  product_id =? ", templateUserId, productId).QueryRow(&access)
 	return
 }