|
@@ -1,22 +1,18 @@
|
|
package entity
|
|
package entity
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ qu "app.yhyue.com/moapp/jybase/common"
|
|
"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
|
|
|
|
+ "app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"jy/src/jfw/modules/subscribepay/src/config"
|
|
"jy/src/jfw/modules/subscribepay/src/config"
|
|
"log"
|
|
"log"
|
|
"net/url"
|
|
"net/url"
|
|
"strings"
|
|
"strings"
|
|
- "time"
|
|
|
|
-
|
|
|
|
- qu "app.yhyue.com/moapp/jybase/common"
|
|
|
|
- "app.yhyue.com/moapp/jybase/redis"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
|
|
|
|
- "app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
-//充值
|
|
|
|
|
|
+// 充值
|
|
type PayStruct struct {
|
|
type PayStruct struct {
|
|
AccountId string //用户身份
|
|
AccountId string //用户身份
|
|
Name string //资源名称
|
|
Name string //资源名称
|
|
@@ -27,9 +23,10 @@ type PayStruct struct {
|
|
Remarks map[string]interface{} //备注
|
|
Remarks map[string]interface{} //备注
|
|
AppId string //appId默认10000
|
|
AppId string //appId默认10000
|
|
VipTime int64 //超级订阅截止日期
|
|
VipTime int64 //超级订阅截止日期
|
|
|
|
+ VipState int64 //超级订阅状态
|
|
}
|
|
}
|
|
|
|
|
|
-func InitPurchase(userId, product, resourceType, num, spec, endTime string, remarks map[string]interface{}, vipEndTime int64) *PayStruct {
|
|
|
|
|
|
+func InitPurchase(userId, product, resourceType, num, spec, endTime string, remarks map[string]interface{}, vipEndTime int64, vipState int) *PayStruct {
|
|
return &PayStruct{
|
|
return &PayStruct{
|
|
AccountId: userId,
|
|
AccountId: userId,
|
|
Name: product, //资源名称
|
|
Name: product, //资源名称
|
|
@@ -40,6 +37,7 @@ func InitPurchase(userId, product, resourceType, num, spec, endTime string, rema
|
|
Remarks: remarks, //备注
|
|
Remarks: remarks, //备注
|
|
AppId: config.CouponConfig.AppId,
|
|
AppId: config.CouponConfig.AppId,
|
|
VipTime: vipEndTime,
|
|
VipTime: vipEndTime,
|
|
|
|
+ VipState: int64(vipState),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,6 +70,7 @@ func (this *PayStruct) PurchaseUserBalance() (bool, error) {
|
|
type FindBalanceStruct struct {
|
|
type FindBalanceStruct struct {
|
|
AccountId string //账户标识
|
|
AccountId string //账户标识
|
|
ResourceType string //产品类型
|
|
ResourceType string //产品类型
|
|
|
|
+ VipState int
|
|
}
|
|
}
|
|
|
|
|
|
// @Summary 余额接口【数据流量包、附件下载包。。】
|
|
// @Summary 余额接口【数据流量包、附件下载包。。】
|
|
@@ -90,24 +89,28 @@ func (this *FindBalanceStruct) FindBalance() (map[string]interface{}, error) {
|
|
if rmap != nil && len(rmap) > 0 && this.ResourceType == "附件下载包" {
|
|
if rmap != nil && len(rmap) > 0 && this.ResourceType == "附件下载包" {
|
|
rdata, _ := rmap["data"].([]interface{})
|
|
rdata, _ := rmap["data"].([]interface{})
|
|
rdataArr := qu.ObjArrToMapArr(rdata)
|
|
rdataArr := qu.ObjArrToMapArr(rdata)
|
|
- vipFileKey := fmt.Sprintf(jy.VipFileUploadNumKey, this.AccountId, fmt.Sprint(time.Now().Month()))
|
|
|
|
- vipFileKeyNum := redis.GetInt(jy.PowerCacheDb, vipFileKey)
|
|
|
|
- free_num := config.BidfileConfig.File_number - vipFileKeyNum //free
|
|
|
|
|
|
+ //vipFileKey := fmt.Sprintf(jy.VipFileUploadNumKey, this.AccountId, fmt.Sprint(time.Now().Month()))
|
|
|
|
+ //vipFileKeyNum := redis.GetInt(jy.PowerCacheDb, vipFileKey)
|
|
|
|
+ //free_num := config.BidfileConfig.File_number - vipFileKeyNum //free
|
|
if len(rdata) > 0 {
|
|
if len(rdata) > 0 {
|
|
for k, v := range rdataArr {
|
|
for k, v := range rdataArr {
|
|
num := qu.IntAll(v["number"]) //buy
|
|
num := qu.IntAll(v["number"]) //buy
|
|
- v["number"] = num + free_num
|
|
|
|
|
|
+ v["number"] = num
|
|
|
|
+ v["purchaseNum"] = qu.IntAll(v["number1"]) //充值数量
|
|
|
|
+ v["exchangeNum"] = qu.IntAll(v["number2"]) //兑换数量
|
|
|
|
+ v["grantNum"] = qu.IntAll(v["number3"]) //超级订阅定期发放数量
|
|
|
|
+ v["freeNum"] = qu.IntAll(v["number4"]) //免费数量
|
|
rdataArr[k] = v
|
|
rdataArr[k] = v
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- rdataArr = append(rdataArr, map[string]interface{}{"name": this.ResourceType, "number": free_num, "resourceType": this.ResourceType, "thirtyNum": 0})
|
|
|
|
|
|
+ rdataArr = append(rdataArr, map[string]interface{}{"name": this.ResourceType, "number": 0, "purchaseNum": 0, "exchangeNum": 0, "grantNum": 0, "freeNum": 0, "resourceType": this.ResourceType, "thirtyNum": 0})
|
|
}
|
|
}
|
|
rmap["data"] = rdataArr
|
|
rmap["data"] = rdataArr
|
|
}
|
|
}
|
|
return rmap, err
|
|
return rmap, err
|
|
}
|
|
}
|
|
|
|
|
|
-//使用
|
|
|
|
|
|
+// 使用
|
|
type UseBalanceStruct struct {
|
|
type UseBalanceStruct struct {
|
|
AccountId string //账户标识
|
|
AccountId string //账户标识
|
|
Name string //资源名称
|
|
Name string //资源名称
|
|
@@ -123,7 +126,6 @@ type UseBalanceStruct struct {
|
|
Session *httpsession.Session
|
|
Session *httpsession.Session
|
|
}
|
|
}
|
|
|
|
|
|
-//
|
|
|
|
func InitUseBalance(userId, product, resourceType, ruleId, duplicateRemoval string, infoId []string, remarks map[string]interface{}, num int, platform string, session *httpsession.Session) *UseBalanceStruct {
|
|
func InitUseBalance(userId, product, resourceType, ruleId, duplicateRemoval string, infoId []string, remarks map[string]interface{}, num int, platform string, session *httpsession.Session) *UseBalanceStruct {
|
|
return &UseBalanceStruct{
|
|
return &UseBalanceStruct{
|
|
AccountId: userId,
|
|
AccountId: userId,
|
|
@@ -167,7 +169,7 @@ func (this *UseBalanceStruct) UseBalance() (map[string]interface{}, error) {
|
|
return resMap, err
|
|
return resMap, err
|
|
}
|
|
}
|
|
|
|
|
|
-//流水
|
|
|
|
|
|
+// 流水
|
|
type FindRecordStruct struct {
|
|
type FindRecordStruct struct {
|
|
AccountId string //账户标识
|
|
AccountId string //账户标识
|
|
UserId string //用户标识
|
|
UserId string //用户标识
|
|
@@ -181,7 +183,7 @@ type FindRecordStruct struct {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-//定义结构体
|
|
|
|
|
|
+// 定义结构体
|
|
func InitFindRecord(userId, resourceType, queryTime, platform string, pageSize, pageNum, state int) *FindRecordStruct {
|
|
func InitFindRecord(userId, resourceType, queryTime, platform string, pageSize, pageNum, state int) *FindRecordStruct {
|
|
if pageSize == 0 {
|
|
if pageSize == 0 {
|
|
pageSize = 10
|
|
pageSize = 10
|
|
@@ -249,7 +251,7 @@ func (this *UpdateVipTimeStruct) UpdateVipEndTime() (bool, error) {
|
|
return ok, nil
|
|
return ok, nil
|
|
}
|
|
}
|
|
|
|
|
|
-//账户信息
|
|
|
|
|
|
+// 账户信息
|
|
func (this *UseBalanceStruct) accountPack() (payCount int) {
|
|
func (this *UseBalanceStruct) accountPack() (payCount int) {
|
|
resMap, err := middleGround.CommonPost(middleGround.JyApiConfig.ApiList.FindBalance, url.Values{
|
|
resMap, err := middleGround.CommonPost(middleGround.JyApiConfig.ApiList.FindBalance, url.Values{
|
|
"accountId": []string{this.UserId}, //账户标识*
|
|
"accountId": []string{this.UserId}, //账户标识*
|