Selaa lähdekoodia

Merge branch 'feature/v4.7.55' of http://192.168.3.207:8080/qmx/jy into feature/v4.7.55

yangfeng 2 vuotta sitten
vanhempi
commit
3824090426
1 muutettua tiedostoa jossa 539 lisäystä ja 539 poistoa
  1. 539 539
      src/jfw/modules/subscribepay/src/entity/dataExportPackStruct.go

+ 539 - 539
src/jfw/modules/subscribepay/src/entity/dataExportPackStruct.go

@@ -1,26 +1,26 @@
 package entity
 
 import (
-    "encoding/json"
-    "fmt"
-    "jy/src/jfw/modules/subscribepay/src/config"
-    "jy/src/jfw/modules/subscribepay/src/pay"
-    "jy/src/jfw/modules/subscribepay/src/util"
-    "log"
-    "strings"
-    "sync"
-    "time"
-
-    "app.yhyue.com/moapp/jybase/api"
-    qutil "app.yhyue.com/moapp/jybase/common"
-    . "app.yhyue.com/moapp/jybase/date"
-    "app.yhyue.com/moapp/jybase/encrypt"
-    "app.yhyue.com/moapp/jybase/redis"
-    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
-    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
-    "app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
-
-    "app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	"encoding/json"
+	"fmt"
+	"jy/src/jfw/modules/subscribepay/src/config"
+	"jy/src/jfw/modules/subscribepay/src/pay"
+	"jy/src/jfw/modules/subscribepay/src/util"
+	"log"
+	"strings"
+	"sync"
+	"time"
+
+	"app.yhyue.com/moapp/jybase/api"
+	qutil "app.yhyue.com/moapp/jybase/common"
+	. "app.yhyue.com/moapp/jybase/date"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/redis"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
+	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/middleGround"
+
+	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
 )
 
 // 剑鱼数据流量包
@@ -29,614 +29,614 @@ type dataExportPackStruct struct{}
 var JyDataExportPack dataExportPackStruct
 
 type PackDetail struct {
-    PackType      int    `json:"pType"`                    //数据包类型 1标准,2高级
-    PackNum       int    `json:"pNum"`                     //数据包数量
-    ValidYear     int    `json:"validYear"`                //有效年份 「账户合并过来的资源为-1」
-    Price         int    `json:"price"`                    //数据包价格 「账户合并过来的资源为-1」
-    GiveCycle     int    `json:"give_cycle,omitempty"`     //赠送条数
-    OriginalPrice int    `json:"original_price,omitempty"` //双十一活动原价价格
-    DisCountId    int    `json:"discountId,omitempty"`     //赠送的id
-    Badge         string `json:"badge,omitempty"`          //活动标识
-    Source        string `json:"source,omitempty"`         //来源
+	PackType      int    `json:"pType"`                    //数据包类型 1标准,2高级
+	PackNum       int    `json:"pNum"`                     //数据包数量
+	ValidYear     int    `json:"validYear"`                //有效年份 「账户合并过来的资源为-1」
+	Price         int    `json:"price"`                    //数据包价格 「账户合并过来的资源为-1」
+	GiveCycle     int    `json:"give_cycle,omitempty"`     //赠送条数
+	OriginalPrice int    `json:"original_price,omitempty"` //双十一活动原价价格
+	DisCountId    int    `json:"discountId,omitempty"`     //赠送的id
+	Badge         string `json:"badge,omitempty"`          //活动标识
+	Source        string `json:"source,omitempty"`         //来源
 }
 type PackDetailReturn struct { //因账户合并,中台返回的字段会有差异
-    *PackDetail
-    EndTime int64 `json:"endTime"` //仅通过账户合并后的有此字段
+	*PackDetail
+	EndTime int64 `json:"endTime"` //仅通过账户合并后的有此字段
 }
 
 var packPriceMap map[string]*PackDetail
 
 func init() {
-    packPriceMap = make(map[string]*PackDetail)
-    for _, pack := range config.ExConf.Packs_showList {
-        packPriceMap[fmt.Sprintf("%s_%d", "normal", pack.PackNum)] = &PackDetail{
-            PackType:  1,
-            PackNum:   pack.PackNum,
-            ValidYear: 2, //默认全为两年
-            Price:     int(config.ExConf.UnitPrice_normal*config.ExConf.Discount*pack.Normal_discount*100) * pack.PackNum,
-        }
-        packPriceMap[fmt.Sprintf("%s_%d", "senior", pack.PackNum)] = &PackDetail{
-            PackType:  2,
-            PackNum:   pack.PackNum,
-            ValidYear: 2, //默认全为两年
-            Price:     int(config.ExConf.UnitPrice_senior*config.ExConf.Discount*pack.Senior_discount*100) * pack.PackNum,
-        }
-    }
+	packPriceMap = make(map[string]*PackDetail)
+	for _, pack := range config.ExConf.Packs_showList {
+		packPriceMap[fmt.Sprintf("%s_%d", "normal", pack.PackNum)] = &PackDetail{
+			PackType:  1,
+			PackNum:   pack.PackNum,
+			ValidYear: 2, //默认全为两年
+			Price:     int(config.ExConf.UnitPrice_normal*config.ExConf.Discount*pack.Normal_discount*100) * pack.PackNum,
+		}
+		packPriceMap[fmt.Sprintf("%s_%d", "senior", pack.PackNum)] = &PackDetail{
+			PackType:  2,
+			PackNum:   pack.PackNum,
+			ValidYear: 2, //默认全为两年
+			Price:     int(config.ExConf.UnitPrice_senior*config.ExConf.Discount*pack.Senior_discount*100) * pack.PackNum,
+		}
+	}
 }
 
 // PayCallBack 支付完成回调
 func (this *dataExportPackStruct) PayCallBack(param *CallBackParam) bool {
-    orderData := util.Mysql.FindOne("dataexport_order", param.GetPaySuccessOrderQuery(map[string]interface{}{"product_type": "数据流量包"}),
-        "id,order_status,order_code,filter,user_id,d_relation_id,dis_word,order_money", "")
-    if orderData != nil {
-        now := time.Now()
-        if order_status := qutil.IntAll((*orderData)["order_status"]); order_status == 0 {
-            payTime := FormatDate(&now, Date_Full_Layout)
-            update := util.Mysql.Update("dataexport_order", map[string]interface{}{
-                "id": (*orderData)["id"],
-            }, map[string]interface{}{
-                "pay_money":    param.CashFee,
-                "pay_time":     payTime,
-                "order_status": 1,
-                //支付成功后更新成支付成功的out_trade_no 避免多人支付重复刷新字段
-                "out_trade_no": param.OutTradeno,
-            })
-            if update {
-                filter := qutil.ObjToString((*orderData)["filter"])
-                orderCode := qutil.ObjToString((*orderData)["order_code"])
-                userId := qutil.ObjToString((*orderData)["user_id"])
-                packDetail := new(PackDetail)
-                if err := json.Unmarshal([]byte(filter), &packDetail); err != nil {
-                    log.Printf("获取用户%s已购买数据包内容异常:%v", userId, err)
-                    return false
-                }
-                if packDetail.GiveCycle > 0 { //赠品
-                    packDetail.PackNum += packDetail.GiveCycle
-                }
-                //卡卷使用
-                userLotteryId := qutil.ObjToString((*orderData)["d_relation_id"])
-                if userLotteryId != "" {
-                    go func(userId, userLotteryId, order_code string) {
-                        phone, name := util.GetMyPhoneAndName(userId)
-                        if !util.UpdateCouponState(userId, userLotteryId, name, phone, order_code, "数据流量包", "", 1, 0) {
-                            log.Println(fmt.Sprintf("单号 %s-消费失败-卡卷%s", order_code, userLotteryId))
-                        }
-                    }(userId, userLotteryId, orderCode)
-                }
-                //调用中台 增加数据包
-                entTime := time.Now().AddDate(2, 0, 0) //有效期
-
-                if _, err := perRechargePack(userId, entTime.Format(Date_Short_Layout), packDetail); err != nil {
-                    log.Println(fmt.Sprintf("%s 资源账户更改异常 %v", userId, err))
-                    return false
-                }
-                dis_word := qutil.ObjToString((*orderData)["dis_word"])
-                //userId := qutil.ObjToString((*orderData)["user_id"])
-                if dis_word != "" {
-                    /*	//分销系统 分销记录
-                    	go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)*/
-                    //分销系统 分销记录
-                    suffix := dis_word[len(dis_word)-3:]
-                    if suffix == suffix_msgt {
-                        //go OtherDisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word, qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["create_time"]))
-                    } else if suffix == "_GX" {
-                        go DisWordRecode(qutil.IntAll((*orderData)["id"]), qutil.IntAll((*orderData)["order_money"]), "数据流量包", dis_word, userId)
-                    } else {
-                        //go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)
-                    }
-                }
-                return true
-            }
-        } else {
-            return true
-        }
-    }
-    return false
+	orderData := util.Mysql.FindOne("dataexport_order", param.GetPaySuccessOrderQuery(map[string]interface{}{"product_type": "数据流量包"}),
+		"id,order_status,order_code,filter,user_id,d_relation_id,dis_word,order_money", "")
+	if orderData != nil {
+		now := time.Now()
+		if order_status := qutil.IntAll((*orderData)["order_status"]); order_status == 0 {
+			payTime := FormatDate(&now, Date_Full_Layout)
+			update := util.Mysql.Update("dataexport_order", map[string]interface{}{
+				"id": (*orderData)["id"],
+			}, map[string]interface{}{
+				"pay_money":    param.CashFee,
+				"pay_time":     payTime,
+				"order_status": 1,
+				//支付成功后更新成支付成功的out_trade_no 避免多人支付重复刷新字段
+				"out_trade_no": param.OutTradeno,
+			})
+			if update {
+				filter := qutil.ObjToString((*orderData)["filter"])
+				orderCode := qutil.ObjToString((*orderData)["order_code"])
+				userId := qutil.ObjToString((*orderData)["user_id"])
+				packDetail := new(PackDetail)
+				if err := json.Unmarshal([]byte(filter), &packDetail); err != nil {
+					log.Printf("获取用户%s已购买数据包内容异常:%v", userId, err)
+					return false
+				}
+				if packDetail.GiveCycle > 0 { //赠品
+					packDetail.PackNum += packDetail.GiveCycle
+				}
+				//卡卷使用
+				userLotteryId := qutil.ObjToString((*orderData)["d_relation_id"])
+				if userLotteryId != "" {
+					go func(userId, userLotteryId, order_code string) {
+						phone, name := util.GetMyPhoneAndName(userId)
+						if !util.UpdateCouponState(userId, userLotteryId, name, phone, order_code, "数据流量包", "", 1, 0) {
+							log.Println(fmt.Sprintf("单号 %s-消费失败-卡卷%s", order_code, userLotteryId))
+						}
+					}(userId, userLotteryId, orderCode)
+				}
+				//调用中台 增加数据包
+				entTime := time.Now().AddDate(2, 0, 0) //有效期
+
+				if _, err := perRechargePack(userId, entTime.Format(Date_Short_Layout), packDetail); err != nil {
+					log.Println(fmt.Sprintf("%s 资源账户更改异常 %v", userId, err))
+					return false
+				}
+				dis_word := qutil.ObjToString((*orderData)["dis_word"])
+				//userId := qutil.ObjToString((*orderData)["user_id"])
+				if dis_word != "" {
+					/*	//分销系统 分销记录
+						go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)*/
+					//分销系统 分销记录
+					suffix := dis_word[len(dis_word)-3:]
+					if suffix == suffix_msgt {
+						//go OtherDisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word, qutil.ObjToString((*orderdata)["user_id"]), qutil.ObjToString((*orderdata)["create_time"]))
+					} else if suffix == "_GX" {
+						go DisWordRecode(qutil.IntAll((*orderData)["id"]), qutil.IntAll((*orderData)["order_money"]), "数据流量包", dis_word, userId)
+					} else {
+						//go DisWordRecode(qutil.IntAll((*orderdata)["id"]), qutil.IntAll((*orderdata)["order_money"]), "超级订阅", dis_word)
+					}
+				}
+				return true
+			}
+		} else {
+			return true
+		}
+	}
+	return false
 }
 
 // GetPackPriceList 获取数据流量包价格
 func (this *dataExportPackStruct) GetPackPriceList() (interface{}, error) {
-    return map[string]interface{}{
-        "unitPrice_normal":   config.ExConf.UnitPrice_normal,
-        "unitPrice_senior":   config.ExConf.UnitPrice_senior,
-        "discount":           config.ExConf.Discount,
-        "packs_validityYear": config.ExConf.Packs_validityYear,
-        "packs_showList":     config.ExConf.Packs_showList,
-    }, nil
+	return map[string]interface{}{
+		"unitPrice_normal":   config.ExConf.UnitPrice_normal,
+		"unitPrice_senior":   config.ExConf.UnitPrice_senior,
+		"discount":           config.ExConf.Discount,
+		"packs_validityYear": config.ExConf.Packs_validityYear,
+		"packs_showList":     config.ExConf.Packs_showList,
+	}, nil
 }
 
 // GetPackDetailById 中台交互-获取单个数据流量包价格
 func (this *dataExportPackStruct) GetPackDetailById(packId string) (*PackDetail, error) {
-    packDetail, ok := packPriceMap[packId]
-    log.Println(packPriceMap)
-    if !ok {
-        return nil, fmt.Errorf("未知规格数据包")
-    }
-    return packDetail, nil
+	packDetail, ok := packPriceMap[packId]
+	log.Println(packPriceMap)
+	if !ok {
+		return nil, fmt.Errorf("未知规格数据包")
+	}
+	return packDetail, nil
 }
 
 // GetAccountMsg 查询账户和企业数据包情况
 func (this *dataExportPackStruct) GetAccountMsg(sess *httpsession.Session, userId string) (map[string]interface{}, error) {
-    //每日限量包
-    packDetail := map[string]interface{}{}
-    vipStatus := jy.GetBigVipUserBaseMsg(sess, *config.Middleground)
-    if vipStatus.Status > 0 && vipStatus.DailyNum > 0 {
-        packetMsg := dataexport.GetDataPacketMsg(vipStatus.GetUseId(), vipStatus.DailyNum)
-        packDetail["dailyPack"] = map[string]interface{}{
-            "limitToday": vipStatus.DailyNum,      //每日限量
-            "usedToday":  packetMsg.GetUsed(true), //已使用
-        }
-    }
-    //个人线上数据包
-    if senior, normal, seniorThirty, normalThirty, err := JyDataExportPack.GetPersonalAccount(userId); err == nil {
-        packDetail["personalPack"] = map[string]interface{}{
-            "seniorTotal":  senior,
-            "normalTotal":  normal,
-            "seniorThirty": seniorThirty,
-            "normalThirty": normalThirty,
-        }
-    }
-
-    //企业数据导出
-    if phone := getAndCacheUserPhone(sess, userId); phone != "" {
-        if entId := qutil.IntAll(sess.Get("entId")); entId != 0 {
-            var entPack []map[string]interface{}
-            var entAllCount int
-            res := util.Mysql.FindOne("entniche_info", map[string]interface{}{"id": entId}, "id,phone,name", "")
-            if res != nil && len(*res) != 0 {
-                entUserId := qutil.IntAll(sess.Get("entUserId"))
-                entName, _ := (*res)["name"].(string)
-                entPhone, _ := (*res)["phone"].(string)
-                if entUserId > 0 && entName != "" && entPhone != "" {
-                    entAllCount = getCurrEntCount(entName, entPhone) //查询所属企业及账户余额
-                    limit := util.Mysql.FindOne("entniche_export_limit", map[string]interface{}{"ent_id": entId, "user_id": entUserId}, "data_limit,remain_nums,export_nums", "")
-                    if limit != nil && len(*limit) > 0 {
-                        entPack = append(entPack, map[string]interface{}{
-                            "entId":        entId,                                 //企业id
-                            "entName":      entName,                               //企业名字
-                            "entAllCount":  entAllCount,                           //企业总条数
-                            "limitToday":   qutil.IntAll((*limit)["data_limit"]),  //个人今日限额
-                            "surplusToday": qutil.IntAll((*limit)["remain_nums"]), //今日剩余
-                            "usedToday":    qutil.IntAll((*limit)["export_nums"]), //今日使用
-                        })
-                    }
-                }
-            }
-            if entPack != nil {
-                packDetail["entPack"] = entPack
-            }
-        }
-    }
-    return packDetail, nil
+	//每日限量包
+	packDetail := map[string]interface{}{}
+	vipStatus := jy.GetBigVipUserBaseMsg(sess, *config.Middleground)
+	if vipStatus.Status > 0 && vipStatus.DailyNum > 0 {
+		packetMsg := dataexport.GetDataPacketMsg(qutil.InterfaceToStr(qutil.If(vipStatus.Pid == "", userId, vipStatus.Pid)), vipStatus.DailyNum)
+		packDetail["dailyPack"] = map[string]interface{}{
+			"limitToday": vipStatus.DailyNum,      //每日限量
+			"usedToday":  packetMsg.GetUsed(true), //已使用
+		}
+	}
+	//个人线上数据包
+	if senior, normal, seniorThirty, normalThirty, err := JyDataExportPack.GetPersonalAccount(userId); err == nil {
+		packDetail["personalPack"] = map[string]interface{}{
+			"seniorTotal":  senior,
+			"normalTotal":  normal,
+			"seniorThirty": seniorThirty,
+			"normalThirty": normalThirty,
+		}
+	}
+
+	//企业数据导出
+	if phone := getAndCacheUserPhone(sess, userId); phone != "" {
+		if entId := qutil.IntAll(sess.Get("entId")); entId != 0 {
+			var entPack []map[string]interface{}
+			var entAllCount int
+			res := util.Mysql.FindOne("entniche_info", map[string]interface{}{"id": entId}, "id,phone,name", "")
+			if res != nil && len(*res) != 0 {
+				entUserId := qutil.IntAll(sess.Get("entUserId"))
+				entName, _ := (*res)["name"].(string)
+				entPhone, _ := (*res)["phone"].(string)
+				if entUserId > 0 && entName != "" && entPhone != "" {
+					entAllCount = getCurrEntCount(entName, entPhone) //查询所属企业及账户余额
+					limit := util.Mysql.FindOne("entniche_export_limit", map[string]interface{}{"ent_id": entId, "user_id": entUserId}, "data_limit,remain_nums,export_nums", "")
+					if limit != nil && len(*limit) > 0 {
+						entPack = append(entPack, map[string]interface{}{
+							"entId":        entId,                                 //企业id
+							"entName":      entName,                               //企业名字
+							"entAllCount":  entAllCount,                           //企业总条数
+							"limitToday":   qutil.IntAll((*limit)["data_limit"]),  //个人今日限额
+							"surplusToday": qutil.IntAll((*limit)["remain_nums"]), //今日剩余
+							"usedToday":    qutil.IntAll((*limit)["export_nums"]), //今日使用
+						})
+					}
+				}
+			}
+			if entPack != nil {
+				packDetail["entPack"] = entPack
+			}
+		}
+	}
+	return packDetail, nil
 }
 
 // GetPersonalAccount 中台交互-查询个人数据包账户信息
 func (this *dataExportPackStruct) GetPersonalAccount(userId string) (senior, normal, seniorThirty, normalThirty int, err error) {
-    //调用中台 查询
-    var account *AccountPack
-    account, err = packAccountQuery(userId)
-    if err != nil {
-        return
-    }
-    return account.SeniorTotal, account.NormalTotal, account.SeniorThirty, account.NormalThirty, nil
+	//调用中台 查询
+	var account *AccountPack
+	account, err = packAccountQuery(userId)
+	if err != nil {
+		return
+	}
+	return account.SeniorTotal, account.NormalTotal, account.SeniorThirty, account.NormalThirty, nil
 }
 
 // GetDataExportRecordList 数据导出记录(包含商机管理导出、每日流量包导出、数据包导出及用户付费直接导出)
 func (this *dataExportPackStruct) GetDataExportRecordList(userId, memberPid string, entId, entUserId, pageNum, pageSize int) (list []map[string]interface{}, total int, err error) {
-    if pageSize == 0 {
-        pageSize = 10
-    }
+	if pageSize == 0 {
+		pageSize = 10
+	}
 
-    var searchSql []string
-    var searchValue []interface{}
+	var searchSql []string
+	var searchValue []interface{}
 
-    //个人直接支付数据导出
-    if userId != "" {
-        searchSql = append(searchSql, `(SELECT '' AS queryObj,filter_id AS queryId,user_id AS user_id,'' AS user_name,UNIX_TIMESTAMP( create_time ) AS exportDate,
+	//个人直接支付数据导出
+	if userId != "" {
+		searchSql = append(searchSql, `(SELECT '' AS queryObj,filter_id AS queryId,user_id AS user_id,'' AS user_name,UNIX_TIMESTAMP( create_time ) AS exportDate,
 		2 AS data_from,data_count AS export_num,-1 AS deduct_num,download_url AS down_url FROM dataexport_order WHERE user_id =? AND order_status =1 AND product_type ='历史数据')`)
-        searchValue = append(searchValue, userId)
-    }
+		searchValue = append(searchValue, userId)
+	}
 
-    //数据包导出及每日限量包导出
-    if userId != "" || memberPid != "" {
-        if memberPid == "" { //主账号查询
-            searchSql = append(searchSql, `(SELECT '' AS queryObj,query_id AS queryId,useid AS user_id,'' AS user_name,date AS exportDate,2 AS data_from,export_num AS
+	//数据包导出及每日限量包导出
+	if userId != "" || memberPid != "" {
+		if memberPid == "" { //主账号查询
+			searchSql = append(searchSql, `(SELECT '' AS queryObj,query_id AS queryId,useid AS user_id,'' AS user_name,date AS exportDate,2 AS data_from,export_num AS
 			export_num,deduct_num AS deduct_num,path AS down_url FROM datapacket_record WHERE master_id = ? )`)
-            searchValue = append(searchValue, userId)
-        } else { //子账号查询
-            searchSql = append(searchSql, `(SELECT '' AS queryObj,query_id AS queryId,useid AS user_id,'' AS user_name,date AS exportDate,2 AS data_from,export_num AS
+			searchValue = append(searchValue, userId)
+		} else { //子账号查询
+			searchSql = append(searchSql, `(SELECT '' AS queryObj,query_id AS queryId,useid AS user_id,'' AS user_name,date AS exportDate,2 AS data_from,export_num AS
 			export_num,deduct_num AS deduct_num,path AS down_url FROM datapacket_record WHERE useid = ? )`)
-            searchValue = append(searchValue, userId)
-        }
-    }
-
-    //企业数据导出
-    if entId > 0 && entUserId != 0 {
-        if util.Mysql.Count("entniche_user_role", map[string]interface{}{"user_id": entUserId, "role_id": 1}) > 0 {
-            //管理员查询
-            searchSql = append(searchSql, `(SELECT filter AS queryObj,'' AS queryId,'' AS user_id,user_name AS user_name,UNIX_TIMESTAMP( export_time ) AS exportDate,
+			searchValue = append(searchValue, userId)
+		}
+	}
+
+	//企业数据导出
+	if entId > 0 && entUserId != 0 {
+		if util.Mysql.Count("entniche_user_role", map[string]interface{}{"user_id": entUserId, "role_id": 1}) > 0 {
+			//管理员查询
+			searchSql = append(searchSql, `(SELECT filter AS queryObj,'' AS queryId,'' AS user_id,user_name AS user_name,UNIX_TIMESTAMP( export_time ) AS exportDate,
 			data_source AS data_from,export_num AS export_num,deduct_num AS deduct_num,download_url AS down_url FROM entniche_export_log WHERE ent_id = ? )`)
-            searchValue = append(searchValue, entId)
-        } else {
-            //子账号查询
-            searchSql = append(searchSql, `(SELECT filter AS queryObj,'' AS queryId,'' AS user_id,user_name AS user_name,UNIX_TIMESTAMP( export_time ) AS exportDate,
+			searchValue = append(searchValue, entId)
+		} else {
+			//子账号查询
+			searchSql = append(searchSql, `(SELECT filter AS queryObj,'' AS queryId,'' AS user_id,user_name AS user_name,UNIX_TIMESTAMP( export_time ) AS exportDate,
 			data_source AS data_from,export_num AS export_num,deduct_num AS deduct_num,download_url AS down_url FROM entniche_export_log WHERE user_id = ? )`)
-            searchValue = append(searchValue, entUserId)
-        }
-    }
-
-    finalSearch := strings.Join(searchSql, ` UNION ALL `)
-
-    //log.Printf("sql xxx %s\n", fmt.Sprintf(`SELECT * FROM ( %s ) AS allData ORDER BY exportDate DESC limit ?,? `, finalSearch))
-    //log.Printf("values xxx :")
-    //for k, v := range append(searchValue, pageNum*pageSize, pageSize) {
-    //	log.Printf(" [%d]=%v ", k, v)
-    //}
-    //log.Println()
-
-    //第一页返回总条数
-    if pageNum == 0 {
-        //log.Printf(`SELECT COUNT(*) FROM ( %s ) AS allData`, finalSearch)
-        if total = util.Mysql.QueryCount(fmt.Sprintf(`SELECT COUNT(*) FROM ( %s ) AS allData`, finalSearch), searchValue...); total == 0 {
-            return
-        }
-    } else {
-        total = -1
-    }
-
-    //查询列表
-    searchList := util.Mysql.Query(fmt.Sprintf(`SELECT * FROM ( %s ) AS allData ORDER BY exportDate DESC limit ?,? `, finalSearch), append(searchValue, pageNum*pageSize, pageSize)...)
-    if searchList == nil || len(*searchList) == 0 {
-        return
-    }
-
-    //格式化返回内容
-    list = make([]map[string]interface{}, 0, pageSize)
-    cacheName := map[string]string{}
-    for _, row := range *searchList {
-        //筛选内容
-        returnRow := make(map[string]interface{})
-        if queryId, _ := row["queryId"].(string); queryId != "" {
-            returnRow["search"] = getSearchValueById(queryId)
-        } else if queryStr, _ := row["queryObj"].(string); queryStr != "" {
-            filterMap := map[string]interface{}{}
-            if err := json.Unmarshal([]byte(queryStr), &filterMap); err == nil {
-                if filterId, _ := filterMap["FilterId"].(string); filterId != "" {
-                    returnRow["search"] = getSearchValueById(filterId)
-                } else {
-                    filterMap["area"] = filterMap["Area"]
-                    t, _ := filterMap["Time"].(string)
-                    if strings.Contains(t, "_") {
-                        t1 := strings.Split(t, "_")[0]
-                        t2 := strings.Split(t, "_")[1]
-                        if len([]rune(t1)) > 10 {
-                            t1 = string([]rune(t)[:10])
-                        }
-                        if len([]rune(t2)) > 10 {
-                            t2 = string([]rune(t2)[:10])
-                        }
-                        t = t1 + "_" + t2
-                    } else {
-                        if len([]rune(t)) > 10 {
-                            t = string([]rune(t)[:10])
-                        }
-                    }
-                    filterMap["publishtime"] = t
-                    filterMap["buyerclass"] = filterMap["Buyerclass"]
-                    delete(filterMap, "Area")
-                    delete(filterMap, "Time")
-                    delete(filterMap, "Buyerclass")
-                    returnRow["search"] = filterMap
-                }
-            }
-        }
-        //查询用户
-        if personalName, _ := row["user_name"].(string); personalName != "" {
-            returnRow["personal_name"] = personalName
-        } else if searchUserId, _ := row["user_id"].(string); searchUserId != "" {
-            if _, exists := cacheName[searchUserId]; !exists {
-                cacheName[searchUserId] = getUserName(searchUserId)
-            }
-            returnRow["personal_name"] = cacheName[searchUserId]
-        }
-        //导出时间
-        returnRow["export_timestamp"] = row["exportDate"]
-        //数据来源
-        if qutil.IntAll(row["data_from"]) == 1 {
-            returnRow["data_from"] = "统一订阅"
-        } else {
-            returnRow["data_from"] = "用户搜索"
-        }
-        //导出条数
-        returnRow["export_num"] = qutil.Int64All(row["export_num"])
-        returnRow["deduct_num"] = qutil.Int64All(row["deduct_num"])
-        //下载地址
-        returnRow["down_url"] = config.Config.WebDomain + qutil.ObjToString(row["down_url"])
-
-        list = append(list, returnRow)
-    }
-    return
+			searchValue = append(searchValue, entUserId)
+		}
+	}
+
+	finalSearch := strings.Join(searchSql, ` UNION ALL `)
+
+	//log.Printf("sql xxx %s\n", fmt.Sprintf(`SELECT * FROM ( %s ) AS allData ORDER BY exportDate DESC limit ?,? `, finalSearch))
+	//log.Printf("values xxx :")
+	//for k, v := range append(searchValue, pageNum*pageSize, pageSize) {
+	//	log.Printf(" [%d]=%v ", k, v)
+	//}
+	//log.Println()
+
+	//第一页返回总条数
+	if pageNum == 0 {
+		//log.Printf(`SELECT COUNT(*) FROM ( %s ) AS allData`, finalSearch)
+		if total = util.Mysql.QueryCount(fmt.Sprintf(`SELECT COUNT(*) FROM ( %s ) AS allData`, finalSearch), searchValue...); total == 0 {
+			return
+		}
+	} else {
+		total = -1
+	}
+
+	//查询列表
+	searchList := util.Mysql.Query(fmt.Sprintf(`SELECT * FROM ( %s ) AS allData ORDER BY exportDate DESC limit ?,? `, finalSearch), append(searchValue, pageNum*pageSize, pageSize)...)
+	if searchList == nil || len(*searchList) == 0 {
+		return
+	}
+
+	//格式化返回内容
+	list = make([]map[string]interface{}, 0, pageSize)
+	cacheName := map[string]string{}
+	for _, row := range *searchList {
+		//筛选内容
+		returnRow := make(map[string]interface{})
+		if queryId, _ := row["queryId"].(string); queryId != "" {
+			returnRow["search"] = getSearchValueById(queryId)
+		} else if queryStr, _ := row["queryObj"].(string); queryStr != "" {
+			filterMap := map[string]interface{}{}
+			if err := json.Unmarshal([]byte(queryStr), &filterMap); err == nil {
+				if filterId, _ := filterMap["FilterId"].(string); filterId != "" {
+					returnRow["search"] = getSearchValueById(filterId)
+				} else {
+					filterMap["area"] = filterMap["Area"]
+					t, _ := filterMap["Time"].(string)
+					if strings.Contains(t, "_") {
+						t1 := strings.Split(t, "_")[0]
+						t2 := strings.Split(t, "_")[1]
+						if len([]rune(t1)) > 10 {
+							t1 = string([]rune(t)[:10])
+						}
+						if len([]rune(t2)) > 10 {
+							t2 = string([]rune(t2)[:10])
+						}
+						t = t1 + "_" + t2
+					} else {
+						if len([]rune(t)) > 10 {
+							t = string([]rune(t)[:10])
+						}
+					}
+					filterMap["publishtime"] = t
+					filterMap["buyerclass"] = filterMap["Buyerclass"]
+					delete(filterMap, "Area")
+					delete(filterMap, "Time")
+					delete(filterMap, "Buyerclass")
+					returnRow["search"] = filterMap
+				}
+			}
+		}
+		//查询用户
+		if personalName, _ := row["user_name"].(string); personalName != "" {
+			returnRow["personal_name"] = personalName
+		} else if searchUserId, _ := row["user_id"].(string); searchUserId != "" {
+			if _, exists := cacheName[searchUserId]; !exists {
+				cacheName[searchUserId] = getUserName(searchUserId)
+			}
+			returnRow["personal_name"] = cacheName[searchUserId]
+		}
+		//导出时间
+		returnRow["export_timestamp"] = row["exportDate"]
+		//数据来源
+		if qutil.IntAll(row["data_from"]) == 1 {
+			returnRow["data_from"] = "统一订阅"
+		} else {
+			returnRow["data_from"] = "用户搜索"
+		}
+		//导出条数
+		returnRow["export_num"] = qutil.Int64All(row["export_num"])
+		returnRow["deduct_num"] = qutil.Int64All(row["deduct_num"])
+		//下载地址
+		returnRow["down_url"] = config.Config.WebDomain + qutil.ObjToString(row["down_url"])
+
+		list = append(list, returnRow)
+	}
+	return
 }
 
 // DoEntPackRepeatCheck 查询企业去重(旧企业导出逻辑)
 func (this *dataExportPackStruct) DoEntPackRepeatCheck(sess *httpsession.Session, userId, entId, selectId string, selectCount int) (deduct int, err error) {
-    //校验当前用户是否所属此企业
-    if phone := getAndCacheUserPhone(sess, userId); phone != "" {
-        res := util.Mysql.FindOne("entniche_user", map[string]interface{}{"phone": phone, "ent_id": entId}, "id,ent_id", "")
-        if res == nil || len(*res) == 0 {
-            return -1, fmt.Errorf("企业校验异常")
-        }
-
-        entUserId := qutil.IntAll((*res)["id"])
-        entIdInt := qutil.IntAll((*res)["ent_id"])
-
-        exportLock.Lock()
-        exportLockMap[entIdInt] = &sync.Mutex{}
-        entLock := exportLockMap[entIdInt]
-        exportLock.Unlock()
-        entLock.Lock()
-        //开始去重
-        _, newCount, _ := dataexport.GetEntDataExportCount(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch,
-            selectId, entIdInt, entUserId, true, middleGround.JyApiConfig.ApiList.EntDedupUrl, config.ExConf.MsgMaxCount)
-        entLock.Unlock()
-        return newCount, err
-    }
-    return -1, fmt.Errorf("未查询所属企业")
+	//校验当前用户是否所属此企业
+	if phone := getAndCacheUserPhone(sess, userId); phone != "" {
+		res := util.Mysql.FindOne("entniche_user", map[string]interface{}{"phone": phone, "ent_id": entId}, "id,ent_id", "")
+		if res == nil || len(*res) == 0 {
+			return -1, fmt.Errorf("企业校验异常")
+		}
+
+		entUserId := qutil.IntAll((*res)["id"])
+		entIdInt := qutil.IntAll((*res)["ent_id"])
+
+		exportLock.Lock()
+		exportLockMap[entIdInt] = &sync.Mutex{}
+		entLock := exportLockMap[entIdInt]
+		exportLock.Unlock()
+		entLock.Lock()
+		//开始去重
+		_, newCount, _ := dataexport.GetEntDataExportCount(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch,
+			selectId, entIdInt, entUserId, true, middleGround.JyApiConfig.ApiList.EntDedupUrl, config.ExConf.MsgMaxCount)
+		entLock.Unlock()
+		return newCount, err
+	}
+	return -1, fmt.Errorf("未查询所属企业")
 }
 
 // DoPerPackRepeatCheck 查询个人数据包去重
 func (this *dataExportPackStruct) DoPerPackRepeatCheck(userId string, isSenior bool, ids []string) (repeat, deduct int, err error) {
-    return doRepeatCheck(userId, isSenior, ids)
+	return doRepeatCheck(userId, isSenior, ids)
 }
 
 // GetExcelFile 数据包生成excel文件
 func GetExcelFile(selectId string, checkCount int, isSenior bool, success func(excelPath string, exportIds []string), fail func(error)) {
-    list, err := dataexport.GetDataExportSearchResultByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, selectId, qutil.If(isSenior, "2", "1").(string), checkCount)
-    url := util.GetExcelFilePath(pay.GetOrderCode(selectId))
-    if err == nil && list != nil && len(*list) > 0 {
-        list = dataexport.FormatExportData(util.MQFWENT, list, config.Config.WebDomain, "2")
-        err = util.CreateDataExportExcelFile(list, isSenior, config.ExConf.ExcelPayedPath+url) //创建excel文件
-    }
-    if err == nil {
-        ids := make([]string, 0, checkCount)
-        for _, item := range *list {
-            ids = append(ids, item["_id"].(string))
-        }
-        success(url, ids)
-    } else {
-        fail(err)
-    }
+	list, err := dataexport.GetDataExportSearchResultByScdId(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch, selectId, qutil.If(isSenior, "2", "1").(string), checkCount)
+	url := util.GetExcelFilePath(pay.GetOrderCode(selectId))
+	if err == nil && list != nil && len(*list) > 0 {
+		list = dataexport.FormatExportData(util.MQFWENT, list, config.Config.WebDomain, "2")
+		err = util.CreateDataExportExcelFile(list, isSenior, config.ExConf.ExcelPayedPath+url) //创建excel文件
+	}
+	if err == nil {
+		ids := make([]string, 0, checkCount)
+		for _, item := range *list {
+			ids = append(ids, item["_id"].(string))
+		}
+		success(url, ids)
+	} else {
+		fail(err)
+	}
 }
 
 var (
-    exportLock    = sync.Mutex{}
-    exportLockMap = map[int]*sync.Mutex{}
+	exportLock    = sync.Mutex{}
+	exportLockMap = map[int]*sync.Mutex{}
 )
 
 // UseEntPack 企业数据包扣除
 func (this *dataExportPackStruct) UseEntPack(sess *httpsession.Session, userId, entId string, selectId string, exportPhone, exportEmail string) error {
-    if phone := getAndCacheUserPhone(sess, userId); phone != "" {
-        res := util.Mysql.FindOne("entniche_user", map[string]interface{}{"phone": phone, "ent_id": entId}, "id,ent_id", "")
-        if res == nil || len(*res) == 0 {
-            return fmt.Errorf("企业校验异常")
-        }
-        entUserId := qutil.IntAll((*res)["id"])
-        entIdInt := qutil.IntAll((*res)["ent_id"])
-
-        exportLock.Lock()
-        exportLockMap[entIdInt] = &sync.Mutex{}
-        entLock := exportLockMap[entIdInt]
-        exportLock.Unlock()
-        entLock.Lock()
-
-        query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
-        remain_nums, export_nums := 0, 0
-        limit := util.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
-        if limit != nil {
-            remain_nums = qutil.IntAll((*limit)["remain_nums"])
-            export_nums = qutil.IntAll((*limit)["export_nums"])
-        }
-
-        count := 0
-        newCount := 0
-        data := &[]map[string]interface{}{}
-
-        current := dataexport.GetCurrentCount(util.Mysql, util.Mgo_Qyfw, entIdInt)
-        log.Println("企业总条数", current)
-        //开始去重
-        count, newCount, data = dataexport.GetEntDataExportCount(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch,
-            selectId, entIdInt, entUserId, false, middleGround.JyApiConfig.ApiList.EntDedupUrl, config.ExConf.MsgMaxCount)
-
-        if newCount > current {
-            return fmt.Errorf("企业账户余额不足")
-        }
-        if newCount > remain_nums {
-            return fmt.Errorf("已超出进入导出上限")
-        }
-        go func() {
-            data = dataexport.FormatExportDatas(util.MQFWENT, data, config.Config.WebDomain, "2", entIdInt)
-            xlsxUrl := dataexport.GetXlsx(*data, entIdInt, entUserId, config.ExConf.ExcelEntPath)
-            if xlsxUrl != "" {
-                filter := dataexport.Filters{
-                    FilterId: selectId,
-                }
-                filterStr, _ := json.Marshal(filter)
-                dataexport.SaveExportLog(util.Mysql, entIdInt, entUserId, count, newCount, remain_nums, export_nums, xlsxUrl, "2", string(filterStr), exportPhone, exportEmail)
-                dataexport.DeductNum(util.Mysql, util.Mgo_Qyfw, entIdInt, newCount)
-                cacheResult(nil, xlsxUrl, fmt.Sprintf("entPackResult_%s_%s", userId, selectId))
-                sendPackExportMail(userId, selectId, exportEmail, xlsxUrl)
-                for _, v := range *data {
-                    util.MQFW.Save("entdataexport", v)
-                }
-            }
-        }()
-        entLock.Unlock()
-    }
-    return nil
+	if phone := getAndCacheUserPhone(sess, userId); phone != "" {
+		res := util.Mysql.FindOne("entniche_user", map[string]interface{}{"phone": phone, "ent_id": entId}, "id,ent_id", "")
+		if res == nil || len(*res) == 0 {
+			return fmt.Errorf("企业校验异常")
+		}
+		entUserId := qutil.IntAll((*res)["id"])
+		entIdInt := qutil.IntAll((*res)["ent_id"])
+
+		exportLock.Lock()
+		exportLockMap[entIdInt] = &sync.Mutex{}
+		entLock := exportLockMap[entIdInt]
+		exportLock.Unlock()
+		entLock.Lock()
+
+		query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
+		remain_nums, export_nums := 0, 0
+		limit := util.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
+		if limit != nil {
+			remain_nums = qutil.IntAll((*limit)["remain_nums"])
+			export_nums = qutil.IntAll((*limit)["export_nums"])
+		}
+
+		count := 0
+		newCount := 0
+		data := &[]map[string]interface{}{}
+
+		current := dataexport.GetCurrentCount(util.Mysql, util.Mgo_Qyfw, entIdInt)
+		log.Println("企业总条数", current)
+		//开始去重
+		count, newCount, data = dataexport.GetEntDataExportCount(util.MQFW, util.Mgo_bidding, config.Config.Mongobidding.DbName, config.Config.Elasticsearch,
+			selectId, entIdInt, entUserId, false, middleGround.JyApiConfig.ApiList.EntDedupUrl, config.ExConf.MsgMaxCount)
+
+		if newCount > current {
+			return fmt.Errorf("企业账户余额不足")
+		}
+		if newCount > remain_nums {
+			return fmt.Errorf("已超出进入导出上限")
+		}
+		go func() {
+			data = dataexport.FormatExportDatas(util.MQFWENT, data, config.Config.WebDomain, "2", entIdInt)
+			xlsxUrl := dataexport.GetXlsx(*data, entIdInt, entUserId, config.ExConf.ExcelEntPath)
+			if xlsxUrl != "" {
+				filter := dataexport.Filters{
+					FilterId: selectId,
+				}
+				filterStr, _ := json.Marshal(filter)
+				dataexport.SaveExportLog(util.Mysql, entIdInt, entUserId, count, newCount, remain_nums, export_nums, xlsxUrl, "2", string(filterStr), exportPhone, exportEmail)
+				dataexport.DeductNum(util.Mysql, util.Mgo_Qyfw, entIdInt, newCount)
+				cacheResult(nil, xlsxUrl, fmt.Sprintf("entPackResult_%s_%s", userId, selectId))
+				sendPackExportMail(userId, selectId, exportEmail, xlsxUrl)
+				for _, v := range *data {
+					util.MQFW.Save("entdataexport", v)
+				}
+			}
+		}()
+		entLock.Unlock()
+	}
+	return nil
 }
 
 // UsePersonalPack 个人数据包扣除
 func (this *dataExportPackStruct) UsePersonalPack(userId, selectId, phone, email string, isSenior bool, checkCount int) error {
-    go GetExcelFile(selectId, checkCount, isSenior, func(excelPath string, exportIds []string) {
-        deduct, err := usePerPack(userId, checkCount, isSenior, &PersonalUsePackRemark{
-            QueryId:         selectId,
-            ExcelUrl:        excelPath,
-            ExportNum:       checkCount,
-            ExportTimeStamp: time.Now().Unix(),
-            Phone:           phone,
-            Email:           email,
-        }, exportIds)
-        if err == nil {
-            go util.Mysql.Insert("datapacket_record", map[string]interface{}{
-                "infoids":    strings.Join(exportIds, ","),
-                "type":       2,
-                "master_id":  userId,
-                "useid":      userId,
-                "query_id":   selectId,
-                "date":       time.Now().Unix(),
-                "path":       excelPath,
-                "deduct_num": deduct,
-                "export_num": checkCount,
-                "phone":      phone,
-                "mail":       email,
-                "isSenior":   qutil.If(isSenior, 2, 1),
-            })
-            //发送邮件
-            go sendPackExportMail(userId, selectId, email, excelPath)
-        }
-        cacheResult(err, excelPath, fmt.Sprintf("personalPackResult_%s_%s_%v", userId, selectId, isSenior))
-    }, func(err error) {
-        cacheResult(err, "", fmt.Sprintf("personalPackResult_%s_%s_%v", userId, selectId, isSenior))
-        errMeg := fmt.Sprintf("数据包导出异常\n用户id:%s\n数据导出筛选id:%s\n异常信息:%v:", userId, selectId, err)
-        util.SendErrNoteToMail(errMeg)
-    })
-    return nil
+	go GetExcelFile(selectId, checkCount, isSenior, func(excelPath string, exportIds []string) {
+		deduct, err := usePerPack(userId, checkCount, isSenior, &PersonalUsePackRemark{
+			QueryId:         selectId,
+			ExcelUrl:        excelPath,
+			ExportNum:       checkCount,
+			ExportTimeStamp: time.Now().Unix(),
+			Phone:           phone,
+			Email:           email,
+		}, exportIds)
+		if err == nil {
+			go util.Mysql.Insert("datapacket_record", map[string]interface{}{
+				"infoids":    strings.Join(exportIds, ","),
+				"type":       2,
+				"master_id":  userId,
+				"useid":      userId,
+				"query_id":   selectId,
+				"date":       time.Now().Unix(),
+				"path":       excelPath,
+				"deduct_num": deduct,
+				"export_num": checkCount,
+				"phone":      phone,
+				"mail":       email,
+				"isSenior":   qutil.If(isSenior, 2, 1),
+			})
+			//发送邮件
+			go sendPackExportMail(userId, selectId, email, excelPath)
+		}
+		cacheResult(err, excelPath, fmt.Sprintf("personalPackResult_%s_%s_%v", userId, selectId, isSenior))
+	}, func(err error) {
+		cacheResult(err, "", fmt.Sprintf("personalPackResult_%s_%s_%v", userId, selectId, isSenior))
+		errMeg := fmt.Sprintf("数据包导出异常\n用户id:%s\n数据导出筛选id:%s\n异常信息:%v:", userId, selectId, err)
+		util.SendErrNoteToMail(errMeg)
+	})
+	return nil
 }
 
 func cacheResult(err error, filePath, key string) {
-    var returnData api.Result
-    if err != nil {
-        returnData = api.NewResult(nil, err)
-    } else {
-        returnData = api.NewResult(filePath, nil)
-    }
-    bytes, _ := json.Marshal(returnData)
-    redis.Put("other", key, string(bytes), 60*5)
+	var returnData api.Result
+	if err != nil {
+		returnData = api.NewResult(nil, err)
+	} else {
+		returnData = api.NewResult(filePath, nil)
+	}
+	bytes, _ := json.Marshal(returnData)
+	redis.Put("other", key, string(bytes), 60*5)
 }
 
 // UseDailyPack 每日限量包
 func (this *dataExportPackStruct) UseDailyPack(userId, selectId, phone, email string, selectCount int, session *httpsession.Session) error {
-    vipStatus := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
-    if vipStatus.Status <= 0 || vipStatus.DailyNum == 0 {
-        return fmt.Errorf("非法请求")
-    }
-    go GetExcelFile(selectId, selectCount, true, func(excelPath string, exportIds []string) {
-        packetMsg := dataexport.GetDataPacketMsg(vipStatus.GetUseId(), vipStatus.DailyNum)
-        //余额扣除
-        err := func() error {
-            if err := packetMsg.AddNum(selectCount); err != nil {
-                return err
-            }
-            //保存导出记录
-            packetMsg.SaveRecord(util.Mysql, userId, selectId, dataexport.BigMemberDaily, exportIds, excelPath, phone, email)
-            //发送邮件
-            go sendPackExportMail(userId, selectId, email, excelPath)
-            return nil
-        }()
-        cacheResult(err, excelPath, fmt.Sprintf("dailyPackResult_%s_%s", userId, selectId))
-    }, func(err error) {
-        cacheResult(err, "", fmt.Sprintf("dailyPackResult_%s_%s", userId, selectId))
-        errMeg := fmt.Sprintf("数据包导出异常\n用户id:%s\n数据导出筛选id:%s\n异常信息:%v:", userId, selectId, err)
-        util.SendErrNoteToMail(errMeg)
-    })
-    return nil
+	vipStatus := jy.GetBigVipUserBaseMsg(session, *config.Middleground)
+	if vipStatus.Status <= 0 || vipStatus.DailyNum == 0 {
+		return fmt.Errorf("非法请求")
+	}
+	go GetExcelFile(selectId, selectCount, true, func(excelPath string, exportIds []string) {
+		packetMsg := dataexport.GetDataPacketMsg(qutil.InterfaceToStr(qutil.If(vipStatus.Pid == "", userId, vipStatus.Pid)), vipStatus.DailyNum)
+		//余额扣除
+		err := func() error {
+			if err := packetMsg.AddNum(selectCount); err != nil {
+				return err
+			}
+			//保存导出记录
+			packetMsg.SaveRecord(util.Mysql, userId, selectId, dataexport.BigMemberDaily, exportIds, excelPath, phone, email)
+			//发送邮件
+			go sendPackExportMail(userId, selectId, email, excelPath)
+			return nil
+		}()
+		cacheResult(err, excelPath, fmt.Sprintf("dailyPackResult_%s_%s", userId, selectId))
+	}, func(err error) {
+		cacheResult(err, "", fmt.Sprintf("dailyPackResult_%s_%s", userId, selectId))
+		errMeg := fmt.Sprintf("数据包导出异常\n用户id:%s\n数据导出筛选id:%s\n异常信息:%v:", userId, selectId, err)
+		util.SendErrNoteToMail(errMeg)
+	})
+	return nil
 }
 
 // PerRechargeList 个人数据包充值记录
 func (this *dataExportPackStruct) PerRechargeList(userId string, pageNum, pageSize int) (int, []map[string]interface{}, error) {
-    if pageSize == 0 {
-        pageSize = 10
-    }
-    pageNum += 1
-    return perPackRecharge(userId, pageNum, pageSize)
+	if pageSize == 0 {
+		pageSize = 10
+	}
+	pageNum += 1
+	return perPackRecharge(userId, pageNum, pageSize)
 }
 
 // 查询企业账户余额
 func getCurrEntCount(entName, entPhone string) int {
-    current, ok := util.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": entPhone, "username": entName})
-    if current == nil || !ok {
-        return 0
-    }
-    plan, planOk := (*current)["plan"].(map[string]interface{})
-    if !planOk {
-        return 0
-    }
-    return qutil.IntAll(plan["current"])
+	current, ok := util.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": entPhone, "username": entName})
+	if current == nil || !ok {
+		return 0
+	}
+	plan, planOk := (*current)["plan"].(map[string]interface{})
+	if !planOk {
+		return 0
+	}
+	return qutil.IntAll(plan["current"])
 }
 
 // 根据筛选id获取筛选条件
 func getSearchValueById(filterId string) (searchMap map[string]interface{}) {
-    filter, _ := util.MQFW.FindById("export_search", filterId, `{"buyerclass":1,"publishtime":1,"area":1,"comeinfrom":1}`)
-    if filter != nil && len(*filter) > 0 {
-        searchMap = make(map[string]interface{})
-        searchMap["buyerclass"] = (*filter)["buyerclass"]
-        searchMap["publishtime"] = (*filter)["publishtime"]
-        searchMap["area"] = (*filter)["area"]
-        searchMap["id"] = encrypt.SE.Encode2Hex(filterId)
-        searchMap["comeinfrom"] = (*filter)["comeinfrom"]
-    }
-    return
+	filter, _ := util.MQFW.FindById("export_search", filterId, `{"buyerclass":1,"publishtime":1,"area":1,"comeinfrom":1}`)
+	if filter != nil && len(*filter) > 0 {
+		searchMap = make(map[string]interface{})
+		searchMap["buyerclass"] = (*filter)["buyerclass"]
+		searchMap["publishtime"] = (*filter)["publishtime"]
+		searchMap["area"] = (*filter)["area"]
+		searchMap["id"] = encrypt.SE.Encode2Hex(filterId)
+		searchMap["comeinfrom"] = (*filter)["comeinfrom"]
+	}
+	return
 }
 
 // 根据用户id查询用户名
 func getUserName(userId string) string {
-    userRow := util.Compatible.Select(userId, `{"s_nickname":1,"s_phone":1,"s_jyname":1}`)
-    if userRow != nil && len(*userRow) > 0 {
-        if name, ok := (*userRow)["s_nickname"].(string); ok && name != "" {
-            return name
-        } else if s_phone, ok := (*userRow)["s_phone"].(string); ok && len(s_phone) == 11 {
-            return fmt.Sprintf("%s***%s", s_phone[:3], s_phone[7:])
-        } else if jyName, ok := (*userRow)["s_jyname"].(string); ok && jyName != "" {
-            return jyName
-        }
-    }
-    return ""
+	userRow := util.Compatible.Select(userId, `{"s_nickname":1,"s_phone":1,"s_jyname":1}`)
+	if userRow != nil && len(*userRow) > 0 {
+		if name, ok := (*userRow)["s_nickname"].(string); ok && name != "" {
+			return name
+		} else if s_phone, ok := (*userRow)["s_phone"].(string); ok && len(s_phone) == 11 {
+			return fmt.Sprintf("%s***%s", s_phone[:3], s_phone[7:])
+		} else if jyName, ok := (*userRow)["s_jyname"].(string); ok && jyName != "" {
+			return jyName
+		}
+	}
+	return ""
 }
 
 func getAndCacheUserPhone(sess *httpsession.Session, userId string) string {
-    phone, _ := sess.Get("phone").(string)
-    if phone == "" {
-        user := util.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1}`)
-        if user != nil && len(*user) > 0 {
-            if phone1, ok := (*user)["s_m_phone"]; ok && phone1 != "" {
-                phone, _ = phone1.(string)
-            } else if phone2, ok := (*user)["s_phone"]; ok && phone2 != "" {
-                phone, _ = phone2.(string)
-            }
-        }
-        if phone != "" {
-            sess.Set("phone", phone)
-        }
-    }
-    return phone
+	phone, _ := sess.Get("phone").(string)
+	if phone == "" {
+		user := util.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1}`)
+		if user != nil && len(*user) > 0 {
+			if phone1, ok := (*user)["s_m_phone"]; ok && phone1 != "" {
+				phone, _ = phone1.(string)
+			} else if phone2, ok := (*user)["s_phone"]; ok && phone2 != "" {
+				phone, _ = phone2.(string)
+			}
+		}
+		if phone != "" {
+			sess.Set("phone", phone)
+		}
+	}
+	return phone
 }
 
 func sendPackExportMail(userId, selectId, userMail, excelPath string) {
-    if userId == "" || selectId == "" || userMail == "" || excelPath == "" {
-        return
-    }
-    mailContent, err := GetPackDataExportMailContent(selectId, config.Config.WebDomain+excelPath)
-    if err != nil {
-        log.Printf("SendDataExportMailForPayed SendMailToPayUser 订单号%s获取邮件内容异常%v\n", selectId, err)
-    }
-    //用户发送邮件
-    if userMail != "" {
-        if util.SendRetryMail(config.ExConf.Mail_retry, userMail, "历史数据", mailContent, "", nil, config.GmailAuth) {
-            log.Printf("SendDataExportMailForPayed SendMailToPayUser 订单号%s:邮箱%s数据导出邮件发送成功!", selectId, userMail)
-        } else {
-            sendErr := fmt.Sprintf("SendDataExportMailForPayed SendMailToPayUser 订单号%s:邮箱%s数据导出邮件发送失败", selectId, userMail)
-            log.Printf("%s sendPackExportMail 发送邮件失败 %v\n", userId, sendErr)
-            return
-        }
-    }
+	if userId == "" || selectId == "" || userMail == "" || excelPath == "" {
+		return
+	}
+	mailContent, err := GetPackDataExportMailContent(selectId, config.Config.WebDomain+excelPath)
+	if err != nil {
+		log.Printf("SendDataExportMailForPayed SendMailToPayUser 订单号%s获取邮件内容异常%v\n", selectId, err)
+	}
+	//用户发送邮件
+	if userMail != "" {
+		if util.SendRetryMail(config.ExConf.Mail_retry, userMail, "历史数据", mailContent, "", nil, config.GmailAuth) {
+			log.Printf("SendDataExportMailForPayed SendMailToPayUser 订单号%s:邮箱%s数据导出邮件发送成功!", selectId, userMail)
+		} else {
+			sendErr := fmt.Sprintf("SendDataExportMailForPayed SendMailToPayUser 订单号%s:邮箱%s数据导出邮件发送失败", selectId, userMail)
+			log.Printf("%s sendPackExportMail 发送邮件失败 %v\n", userId, sendErr)
+			return
+		}
+	}
 }