Browse Source

feat : 附件下载包次数

zhangxinlei1996 3 years ago
parent
commit
edbf7e0ffb

+ 6 - 2
src/jfw/modules/bigmember/src/service/use/use.go

@@ -624,8 +624,12 @@ func (u *Use) IsAdd() {
 		var notBigFileBool = bigPower.Status <= 0 || !bigPower.PowerMap[3]
 		var notBigFileBool = bigPower.Status <= 0 || !bigPower.PowerMap[3]
 		//超级订阅非大会员用户附件下载本月可用次数
 		//超级订阅非大会员用户附件下载本月可用次数
 		uk := qu.If(notBigFileBool && bigPower.VipStatus > 0 && bigPower.Vip_BuySet.Upgrade == 1, "v", "f").(string)
 		uk := qu.If(notBigFileBool && bigPower.VipStatus > 0 && bigPower.Vip_BuySet.Upgrade == 1, "v", "f").(string)
-		// log.Println(uk, "-----", config.Config.FileUploadNum[uk])
-		d["fileNum"] = config.Config.FileUploadNum[uk] - redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.VipFileUploadNumKey, userid, fmt.Sprint(time.Now().Month())))
+
+		//附件下载包的剩余次数
+		filePackKey := fmt.Sprintf(jy.FilePackNumKey, userid, fmt.Sprint(time.Now().Month()))
+		filePackNum := redis.GetInt(jy.PowerCacheDb, filePackKey)
+		d["fileNum"] = config.Config.FileUploadNum[uk] - redis.GetInt(jy.PowerCacheDb, fmt.Sprintf(jy.VipFileUploadNumKey, userid, fmt.Sprint(time.Now().Month()))) + filePackNum
+		//
 		//新用户->新订阅设置页面
 		//新用户->新订阅设置页面
 		if config.Config.NewFreeUser < bigPower.Registedate {
 		if config.Config.NewFreeUser < bigPower.Registedate {
 			d["isUpgrade"] = true
 			d["isUpgrade"] = true

+ 1 - 1
src/jfw/modules/common/src/qfw/util/jy/bigVipPower.go

@@ -50,7 +50,7 @@ const (
 	UserUpdateAreaKey   = "free_area_num_%s_%s"
 	UserUpdateAreaKey   = "free_area_num_%s_%s"
 	BaseAreaNum         = 1
 	BaseAreaNum         = 1
 	VipFileUploadNumKey = "vip_file_num_%s_%s"  //超级订阅附件本月一下载次数 %s:userid ; %s:当前月份-fmt.Sprint(time.Now().Month())
 	VipFileUploadNumKey = "vip_file_num_%s_%s"  //超级订阅附件本月一下载次数 %s:userid ; %s:当前月份-fmt.Sprint(time.Now().Month())
-	FilePackNumKey      = "file_pack_num_%s_%s" //附件下载包本月  下载次数  %s:userid   %s 当前月份-fmt.Sprint(time.Now().Month())
+	FilePackNumKey      = "file_pack_num_%s_%s" //附件下载包本月  剩余次数  %s:userid   %s 当前月份-fmt.Sprint(time.Now().Month())
 )
 )
 
 
 //初始化大会员权益
 //初始化大会员权益

+ 11 - 1
src/jfw/modules/subscribepay/src/entity/resourcePackStruct.go

@@ -8,6 +8,7 @@ import (
 	"math"
 	"math"
 	qu "qfw/util"
 	qu "qfw/util"
 	"qfw/util/jy"
 	"qfw/util/jy"
+	"qfw/util/redis"
 	"strconv"
 	"strconv"
 	"time"
 	"time"
 	"util"
 	"util"
@@ -61,13 +62,22 @@ func (this *resoucePackStruct) PayCallBack(param *CallBackParam) bool {
 				log.Printf("用户%sPurchaseUserBalance出错:%v", userId, (*orderData)["order_code"], err)
 				log.Printf("用户%sPurchaseUserBalance出错:%v", userId, (*orderData)["order_code"], err)
 				return false
 				return false
 			}
 			}
+			//附件下载包剩余次数
+			filePackKey := fmt.Sprintf(jy.FilePackNumKey, userId, fmt.Sprint(time.Now().Month()))
+			filePackNum := redis.GetInt(jy.PowerCacheDb, filePackKey)
+			if filePackNum == 0 {
+				redis.Put(jy.PowerCacheDb, filePackKey, qu.IntAll(filterM["num"]), int(this.LastDate(now).Unix()-now.Unix()))
+			} else {
+				filePackNum += qu.IntAll(filterM["num"])
+				redis.Put(jy.PowerCacheDb, filePackKey, filePackNum, int(this.LastDate(now).Unix()-now.Unix()))
+			}
 			//卡卷使用
 			//卡卷使用
 			userLotteryId := qu.ObjToString((*orderData)["d_relation_id"])
 			userLotteryId := qu.ObjToString((*orderData)["d_relation_id"])
 			order_code := qu.ObjToString((*orderData)["order_code"])
 			order_code := qu.ObjToString((*orderData)["order_code"])
 			if userLotteryId != "" {
 			if userLotteryId != "" {
 				go func(userId, userLotteryId, order_code string) {
 				go func(userId, userLotteryId, order_code string) {
 					phone, name := util.GetMyPhoneAndName(userId)
 					phone, name := util.GetMyPhoneAndName(userId)
-					if !util.UpdateCouponState(userId, userLotteryId, name, phone, order_code, "省份订阅包", "0", 1, 0) {
+					if !util.UpdateCouponState(userId, userLotteryId, name, phone, order_code, ATTACHMENT, "0", 1, 0) {
 						log.Println(fmt.Sprintf("单号%s-消费失败-卡卷%s", order_code, userLotteryId))
 						log.Println(fmt.Sprintf("单号%s-消费失败-卡卷%s", order_code, userLotteryId))
 					}
 					}
 				}(userId, userLotteryId, order_code)
 				}(userId, userLotteryId, order_code)

+ 2 - 0
src/jfw/modules/subscribepay/src/timetask/timetask.go

@@ -314,6 +314,8 @@ func checkIsExpire() {
 				go jy.ClearBigVipUserPower(_id)
 				go jy.ClearBigVipUserPower(_id)
 				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
 				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
 				redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
 				redis.Del("other", "p1_indexMessage_"+_id) //清除redis中vip状态
+				filePackKey := fmt.Sprintf(jy.FilePackNumKey, _id, fmt.Sprint(time.Now().Month()))
+				redis.Del(jy.PowerCacheDb, filePackKey) //清除redis中附件下载包次数
 			} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 {
 			} else if l_vip_endtime-now_unix <= threeday && i_vip_expire_tip != 1 {
 				updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
 				updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
 					"$set": map[string]interface{}{
 					"$set": map[string]interface{}{