浏览代码

Merge branch 'dev4.6.2.17' of http://192.168.3.207:8080/qmx/jy into dev4.6.2.17

zhangyuhan 3 年之前
父节点
当前提交
4a9868a1e0

+ 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]
 		//超级订阅非大会员用户附件下载本月可用次数
 		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 {
 			d["isUpgrade"] = true

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

@@ -49,7 +49,8 @@ const (
 	OneDay              = 60 * 60 * 24
 	UserUpdateAreaKey   = "free_area_num_%s_%s"
 	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())
 )
 
 //初始化大会员权益

+ 11 - 5
src/jfw/modules/subscribepay/src/entity/basePack.go

@@ -54,8 +54,8 @@ func (this *UseBalanceStruct) fileConsume() (r map[string]interface{}, m string)
 			isCanConsume_f := false
 			isCanConsume_p := false
 			//免费赠送已使用次数
-			mon := fmt.Sprintf(jy.VipFileUploadNumKey, this.UserId, fmt.Sprint(time.Now().Month()))
-			fui := redis.GetInt(jy.PowerCacheDb, mon)
+			mon_free := fmt.Sprintf(jy.VipFileUploadNumKey, this.UserId, fmt.Sprint(time.Now().Month()))
+			fui := redis.GetInt(jy.PowerCacheDb, mon_free)
 			if fui < config.BidfileConfig.File_number {
 				isCanConsume_f = true
 			} else if payCount := this.accountPack(); payCount > 0 { //付费未使用次数
@@ -71,12 +71,18 @@ func (this *UseBalanceStruct) fileConsume() (r map[string]interface{}, m string)
 						rb, err := this.UseBalance()
 						if err != nil || (rb != nil && qutil.IntAll(rb["code"]) == 0) {
 							m = fmt.Sprintf("消费记录保存异常:%s", qutil.ObjToString(rb["message"]))
+						} else {
+							//更新redis 购买附件下载包数量
+							mon_pay := fmt.Sprintf(jy.FilePackNumKey, this.UserId, fmt.Sprint(time.Now().Month()))
+							if redis.GetInt(jy.PowerCacheDb, mon_pay) <= 0 || redis.Decrby(jy.PowerCacheDb, mon_pay, 1) < 0 {
+								log.Println(fmt.Sprintf("附件下载包 消费异常:%s,附件名称:%s", this.UserId, this.Remarks["fileName"].(string)))
+							}
 						}
 					} else if isCanConsume_f { //下载后自增一次 免费权限默认存储31d
 						if fui == 0 {
-							redis.Put(jy.PowerCacheDb, mon, 1, 60*60*24*31)
+							redis.Put(jy.PowerCacheDb, mon_free, 1, 60*60*24*31)
 						} else {
-							redis.Incr(jy.PowerCacheDb, mon)
+							redis.Incr(jy.PowerCacheDb, mon_free)
 						}
 					}
 					go this.saveJyConsumePackList(qutil.If(isCanConsume_p, true, false).(bool))
@@ -230,7 +236,7 @@ func (this *FindRecordStruct) FindJyConsumePackAllRecord() ([]map[string]interfa
 
 //数据处理-default
 func (this *FindRecordStruct) DefaultData() ([]map[string]interface{}, int) {
-	returnList, total, err := this.FindBalance()
+	returnList, total, err := this.FindRecord()
 	if err != nil {
 		log.Println("默认资源包流水异常:", err)
 		return nil, 0

+ 1 - 1
src/jfw/modules/subscribepay/src/entity/commonApi.go

@@ -183,7 +183,7 @@ func InitFindRecord(userId, resourceType, queryTime, platform string, pageSize,
 // @Summary 流水接口【数据流量包、附件下载包。。】
 // @Param  &FindRecordStruct
 // @return list列表 , int数量 , error
-func (this *FindRecordStruct) FindBalance() ([]interface{}, int, error) {
+func (this *FindRecordStruct) FindRecord() ([]interface{}, int, error) {
 	log.Println("----", this.UserId, this.PageSize, this.Page, this.State, this.ResourceType, this.QueryTime)
 	resMap, err := commonPost(config.JyApiConfig.ApiList.FindRecord, url.Values{
 		"accountId":    []string{this.UserId},                      //账户标识

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

@@ -8,6 +8,7 @@ import (
 	"math"
 	qu "qfw/util"
 	"qfw/util/jy"
+	"qfw/util/redis"
 	"strconv"
 	"time"
 	"util"
@@ -61,13 +62,22 @@ func (this *resoucePackStruct) PayCallBack(param *CallBackParam) bool {
 				log.Printf("用户%sPurchaseUserBalance出错:%v", userId, (*orderData)["order_code"], err)
 				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"])
 			order_code := qu.ObjToString((*orderData)["order_code"])
 			if userLotteryId != "" {
 				go func(userId, userLotteryId, order_code string) {
 					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))
 					}
 				}(userId, userLotteryId, order_code)

+ 1 - 1
src/jfw/modules/subscribepay/src/service/resourcePack.go

@@ -42,7 +42,7 @@ func (this *ResourcePack) Tes() {
 	}
 	updateT.UpdateVipEndTime()
 	return
-	a, b, c := entity.InitFindRecord(userId, entity.ATTACHMENT, "2022-01", "PC", 10, 1, 0).FindBalance()
+	a, b, c := entity.InitFindRecord(userId, entity.ATTACHMENT, "2022-01", "PC", 10, 1, 0).FindRecord()
 	this.ServeJson(map[string]interface{}{
 		"a": a,
 		"b": b,

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

@@ -314,6 +314,8 @@ func checkIsExpire() {
 				go jy.ClearBigVipUserPower(_id)
 				log.Println("用户", _id, i_vip_status, l_vip_endtime, "修改已到期状态")
 				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 {
 				updateOk := util.MQFW.UpdateById("user", _id, map[string]interface{}{
 					"$set": map[string]interface{}{