wangshan 3 years ago
parent
commit
aac9b19150

+ 14 - 5
src/jfw/modules/subscribepay/src/entity/commonApi.go

@@ -85,17 +85,26 @@ func (this *FindBalanceStruct) FindBalance() (map[string]interface{}, error) {
 		return rmap, err
 	}
 	if rmap != nil && len(rmap) > 0 && this.ResourceType == "附件下载包" {
-		if rdata, _ := rmap["data"].([]interface{}); len(rdata) > 0 {
-			rdataArr := qu.ObjArrToMapArr(rdata)
+		rdata, _ := rmap["data"].([]interface{})
+		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
+		if len(rdata) > 0 {
 			for k, v := range rdataArr {
 				num := qu.IntAll(v["number"]) //buy
-				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
 				v["number"] = num + free_num
 				rdataArr[k] = v
 			}
+		} else {
+			rdataArr = append(rdataArr, map[string]interface{}{
+				"name":         "附件下载包",
+				"number":       free_num,
+				"resourceType": "附件下载包",
+				"thirtyNum":    0,
+			})
 		}
+		rmap["data"] = rdataArr
 	}
 	return rmap, err
 }

+ 27 - 27
src/web/staticres/common-module/file-pack/js/index.js

@@ -191,33 +191,33 @@ var vm = new Vue({
     },
     downFile (item) {
       //location.href = item.s_downUrl
-    $.ajax({
-        type: 'post',
-        url: '/jypay/resourcePack/consumePack',
-        data: {
-            productName: '附件下载包',
-            platform: 'APP',
-            fileName: item.s_fileName,
-            id: item.s_id,
-            title: item.s_title
-        },
-        success: function (r) {
-			if (r && r.m === '' && r.r) {
-     				location.href = r.r.downUrl
-					setTimeout(function(){
-						location.reload();
-					},2000)
-               }else{
-               	vant.Dialog.alert({
-                       message: '附件下载异常,请联系管理员,谢谢!',
-                       className: 'custom-dialog',
-                       confirmButtonText: '我知道了',
-                       confirmButtonColor: '#2ABDD1',
-                       width: 303,
-                     }).then(() => {})
-               }
-		}
-	})
+		   $.ajax({
+		       type: 'post',
+		       url: '/jypay/resourcePack/consumePack',
+		       data: {
+		           productName: '附件下载包',
+		           platform: 'APP',
+		           fileName: item.s_fileName,
+		           id: item.s_id,
+		           title: item.s_title
+		       },
+		       success: function (r) {
+				if (r && r.m === '' && r.r) {
+		    				location.href = r.r.downUrl
+						setTimeout(function(){
+							location.reload();
+						},2000)
+		              }else{
+		              	vant.Dialog.alert({
+		                      message: '附件下载异常,请联系管理员,谢谢!',
+		                      className: 'custom-dialog',
+		                      confirmButtonText: '我知道了',
+		                      confirmButtonColor: '#2ABDD1',
+		                      width: 303,
+		                    }).then(() => {})
+		              }
+			}
+		})
     },
     commonDialogFn (message, confirmText, callBack) {
       if (this.ptype == "1") {