|
@@ -4,6 +4,10 @@ import (
|
|
|
"app.yhyue.com/moapp/jy_docs/rpc/partnerlib/entity"
|
|
|
"app.yhyue.com/moapp/jy_docs/services/model"
|
|
|
jyDocRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
|
|
|
+ "app.yhyue.com/moapp/jybase/common"
|
|
|
+ "app.yhyue.com/moapp/jybase/date"
|
|
|
+ "encoding/json"
|
|
|
+ "log"
|
|
|
)
|
|
|
|
|
|
// 保存和合作商订单相关的信息
|
|
@@ -27,16 +31,37 @@ func GetDocOrderInfo(positionId int64, mgoUserId string, state int) (orderInfo *
|
|
|
|
|
|
// 剑鱼文库会员订单信息
|
|
|
type OrderInfo struct {
|
|
|
+ Filter Filter
|
|
|
+ OrderCode string
|
|
|
+ StartDate string
|
|
|
+ EndDate string
|
|
|
+}
|
|
|
+
|
|
|
+type Filter struct {
|
|
|
CycleCount int
|
|
|
CycleUnit int
|
|
|
- OrderCode string
|
|
|
- StartDate string
|
|
|
- EndDate string
|
|
|
}
|
|
|
|
|
|
// 获取剑鱼文库会员购买信息
|
|
|
func GetJYDocsOrderInfo(positionId int64, mgoUserId string) (orderInfo *OrderInfo) {
|
|
|
var orders = []map[string]interface{}{}
|
|
|
- jyDocRpcUtil.GetJyDocsDB().Table(entity.OrderTable).Where("order_status = 1 AND product_type = ? AND (user_id = ? OR user_id = ?)", entity.ProductType, positionId, mgoUserId).Select("filter,vip_starttime,vip_endtime").Find(&orders)
|
|
|
+ err := jyDocRpcUtil.GetJyDocsDB().Table(entity.OrderTable).
|
|
|
+ Where("order_status = 1 AND product_type = ? AND (user_id = ? OR user_id = ?) AND vip_endtime > ?", entity.ProductType, positionId, mgoUserId, date.NowFormat(date.Date_Full_Layout)).
|
|
|
+ Select("order_code,filter,vip_starttime,vip_endtime").
|
|
|
+ Find(&orders).Error
|
|
|
+ if err == nil && len(orders) > 0 {
|
|
|
+ filter := &Filter{}
|
|
|
+ err := json.Unmarshal([]byte(orders[0]["filter"].(string)), &filter)
|
|
|
+ if err == nil {
|
|
|
+ orderInfo = &OrderInfo{
|
|
|
+ Filter: *filter,
|
|
|
+ OrderCode: common.InterfaceToStr(orders[0]["order_code"]),
|
|
|
+ StartDate: common.InterfaceToStr(orders[0]["vip_starttime"]),
|
|
|
+ EndDate: common.InterfaceToStr(orders[0]["vip_endtime"]),
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.Println("文库会员订单-filter-结构体反序列化-错误", err)
|
|
|
+ }
|
|
|
+ }
|
|
|
return
|
|
|
}
|