|
@@ -7,7 +7,6 @@ import (
|
|
|
"jfw/config"
|
|
|
"jfw/public"
|
|
|
"log"
|
|
|
- "os"
|
|
|
"qfw/util"
|
|
|
"qfw/util/dataexport"
|
|
|
"qfw/util/jy"
|
|
@@ -19,7 +18,6 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
|
- "github.com/tealeg/xlsx"
|
|
|
)
|
|
|
|
|
|
type DataExport struct {
|
|
@@ -51,10 +49,11 @@ type DataExport struct {
|
|
|
bidfileDetail xweb.Mapper `xweb:"/front/bidfile/bidfileDetail"` //招标文件解读详情
|
|
|
integralDetail xweb.Mapper `xweb:"/front/integral/integralDetail"` //剑鱼币订单详情
|
|
|
|
|
|
- gettest xweb.Mapper `xweb:"/front/order/gettest"` //模拟
|
|
|
- entDataExport xweb.Mapper `xweb:"/front/entDataExport/(.*)"` //企业数据导出
|
|
|
- getPcEntAuth xweb.Mapper `xweb:"/front/entExportAuth/getAuth"` //获取企业权限
|
|
|
- isEntExportSuccess xweb.Mapper `xweb:"/front/entExportAuth/isEntExportSuccess"` //企业导出是否成功
|
|
|
+ getPcEntAuth xweb.Mapper `xweb:"/front/entExportAuth/getAuth"` //获取企业权限
|
|
|
+
|
|
|
+ //gettest xweb.Mapper `xweb:"/front/order/gettest"` //模拟
|
|
|
+ //entDataExport xweb.Mapper `xweb:"/front/entDataExport/(.*)"` //企业数据导出
|
|
|
+ //isEntExportSuccess xweb.Mapper `xweb:"/front/entExportAuth/isEntExportSuccess"` //企业导出是否成功
|
|
|
}
|
|
|
|
|
|
var order_pageSize = 10
|
|
@@ -723,14 +722,14 @@ func (d *DataExport) Check_invoice(order_code string) error {
|
|
|
return d.Render("/_error.html")
|
|
|
}
|
|
|
|
|
|
-func (d *DataExport) Gettest() {
|
|
|
- order_code := d.GetString("order_code")
|
|
|
- info := public.Mysql.FindOne("invoice", map[string]interface{}{"order_code": order_code}, "", "")
|
|
|
- d.ServeJson(map[string]interface{}{
|
|
|
- "data": info,
|
|
|
- })
|
|
|
- return
|
|
|
-}
|
|
|
+//func (d *DataExport) Gettest() {
|
|
|
+// order_code := d.GetString("order_code")
|
|
|
+// info := public.Mysql.FindOne("invoice", map[string]interface{}{"order_code": order_code}, "", "")
|
|
|
+// d.ServeJson(map[string]interface{}{
|
|
|
+// "data": info,
|
|
|
+// })
|
|
|
+// return
|
|
|
+//}
|
|
|
|
|
|
func (d *DataExport) InvoicetimeOut() {
|
|
|
d.Render("/pc/invoice_error.html")
|
|
@@ -745,84 +744,85 @@ func (d *DataExport) ValuationList(order_code string) error {
|
|
|
return d.Render("/_error.html")
|
|
|
}
|
|
|
|
|
|
-func (d *DataExport) EntDataExport(_id string) error {
|
|
|
- id := util.SE.Decode4Hex(_id)
|
|
|
- userId := util.ObjToString(d.GetSession("userId"))
|
|
|
- entId := util.IntAll(d.GetSession("entId"))
|
|
|
- entUserId := util.IntAll(d.GetSession("entUserId"))
|
|
|
- isFirst, err := d.GetBool("isFirst")
|
|
|
- if err != nil {
|
|
|
- isFirst = true
|
|
|
- }
|
|
|
- if userId == "" {
|
|
|
- return errors.New("未登录")
|
|
|
- }
|
|
|
- exportLock.Lock()
|
|
|
- exportLockMap[entId] = sync.Mutex{}
|
|
|
- entLock := exportLockMap[entId]
|
|
|
- exportLock.Unlock()
|
|
|
- entLock.Lock()
|
|
|
- query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
|
|
|
- data_limit, remain_nums, export_nums := 0, 0, 0
|
|
|
- limit := public.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
|
|
|
- if limit != nil {
|
|
|
- data_limit = util.IntAll((*limit)["data_limit"])
|
|
|
- remain_nums = util.IntAll((*limit)["remain_nums"])
|
|
|
- export_nums = util.IntAll((*limit)["export_nums"])
|
|
|
- }
|
|
|
- count := 0
|
|
|
- newCount := 0
|
|
|
- data := &[]map[string]interface{}{}
|
|
|
- current := GetCurrentCount(entId)
|
|
|
- log.Println("企业总条数", current)
|
|
|
- url := config.Sysconfig["dedupUrl"].(string)
|
|
|
- count, newCount, data = public.GetEntDataExportCount(id, entId, entUserId, remain_nums, current, isFirst, util.ObjToString(config.Sysconfig["webdomain"]), url)
|
|
|
- isExport := true
|
|
|
- isEntExport := true
|
|
|
- if newCount > current {
|
|
|
- isEntExport = false
|
|
|
- }
|
|
|
- if newCount > remain_nums {
|
|
|
- isExport = false
|
|
|
- }
|
|
|
- //current 企业总条数 count 筛选条数 newCount 去重后条数 exportNum 今日已导出 limit 今日剩余 limitDay 今日限额
|
|
|
- result := map[string]interface{}{
|
|
|
- "newCount": newCount,
|
|
|
- "count": count,
|
|
|
- "limit": remain_nums,
|
|
|
- "limitDay": data_limit,
|
|
|
- "exportNum": export_nums,
|
|
|
- "current": current,
|
|
|
- "isExport": isExport,
|
|
|
- "isEntExport": isEntExport,
|
|
|
- }
|
|
|
- if isFirst || !isExport || !isEntExport {
|
|
|
- entLock.Unlock()
|
|
|
- d.ServeJson(result)
|
|
|
- } else {
|
|
|
- go func() {
|
|
|
- data = public.FormatExportDatas(data, config.Sysconfig["webdomain"].(string), "2", entId)
|
|
|
- xlsxUrl := GetXlsx(*data, entId, entUserId)
|
|
|
- if xlsxUrl != "" {
|
|
|
- filter := Filters{
|
|
|
- FilterId: id,
|
|
|
- }
|
|
|
- filterStr, _ := json.Marshal(filter)
|
|
|
- SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums, xlsxUrl, "2", string(filterStr))
|
|
|
- DeductNum(entId, newCount)
|
|
|
- go func() {
|
|
|
- for _, v := range *data {
|
|
|
- mongodb.Save("entdataexport", v)
|
|
|
- }
|
|
|
- }()
|
|
|
- redis.Put("other", "entexportdata_"+fmt.Sprintln(entId), xlsxUrl, 60)
|
|
|
- entLock.Unlock()
|
|
|
- }
|
|
|
- }()
|
|
|
- d.ServeJson(result)
|
|
|
- }
|
|
|
- return nil
|
|
|
-}
|
|
|
+//
|
|
|
+//func (d *DataExport) EntDataExport(_id string) error {
|
|
|
+// id := util.SE.Decode4Hex(_id)
|
|
|
+// userId := util.ObjToString(d.GetSession("userId"))
|
|
|
+// entId := util.IntAll(d.GetSession("entId"))
|
|
|
+// entUserId := util.IntAll(d.GetSession("entUserId"))
|
|
|
+// isFirst, err := d.GetBool("isFirst")
|
|
|
+// if err != nil {
|
|
|
+// isFirst = true
|
|
|
+// }
|
|
|
+// if userId == "" {
|
|
|
+// return errors.New("未登录")
|
|
|
+// }
|
|
|
+// exportLock.Lock()
|
|
|
+// exportLockMap[entId] = sync.Mutex{}
|
|
|
+// entLock := exportLockMap[entId]
|
|
|
+// exportLock.Unlock()
|
|
|
+// entLock.Lock()
|
|
|
+// query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
|
|
|
+// data_limit, remain_nums, export_nums := 0, 0, 0
|
|
|
+// limit := public.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
|
|
|
+// if limit != nil {
|
|
|
+// data_limit = util.IntAll((*limit)["data_limit"])
|
|
|
+// remain_nums = util.IntAll((*limit)["remain_nums"])
|
|
|
+// export_nums = util.IntAll((*limit)["export_nums"])
|
|
|
+// }
|
|
|
+// count := 0
|
|
|
+// newCount := 0
|
|
|
+// data := &[]map[string]interface{}{}
|
|
|
+// current := GetCurrentCount(entId)
|
|
|
+// log.Println("企业总条数", current)
|
|
|
+// url := config.Sysconfig["dedupUrl"].(string)
|
|
|
+// count, newCount, data = public.GetEntDataExportCount(id, entId, entUserId, remain_nums, current, isFirst, util.ObjToString(config.Sysconfig["webdomain"]), url)
|
|
|
+// isExport := true
|
|
|
+// isEntExport := true
|
|
|
+// if newCount > current {
|
|
|
+// isEntExport = false
|
|
|
+// }
|
|
|
+// if newCount > remain_nums {
|
|
|
+// isExport = false
|
|
|
+// }
|
|
|
+// //current 企业总条数 count 筛选条数 newCount 去重后条数 exportNum 今日已导出 limit 今日剩余 limitDay 今日限额
|
|
|
+// result := map[string]interface{}{
|
|
|
+// "newCount": newCount,
|
|
|
+// "count": count,
|
|
|
+// "limit": remain_nums,
|
|
|
+// "limitDay": data_limit,
|
|
|
+// "exportNum": export_nums,
|
|
|
+// "current": current,
|
|
|
+// "isExport": isExport,
|
|
|
+// "isEntExport": isEntExport,
|
|
|
+// }
|
|
|
+// if isFirst || !isExport || !isEntExport {
|
|
|
+// entLock.Unlock()
|
|
|
+// d.ServeJson(result)
|
|
|
+// } else {
|
|
|
+// go func() {
|
|
|
+// data = public.FormatExportDatas(data, config.Sysconfig["webdomain"].(string), "2", entId)
|
|
|
+// xlsxUrl := GetXlsx(*data, entId, entUserId)
|
|
|
+// if xlsxUrl != "" {
|
|
|
+// filter := Filters{
|
|
|
+// FilterId: id,
|
|
|
+// }
|
|
|
+// filterStr, _ := json.Marshal(filter)
|
|
|
+// SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums, xlsxUrl, "2", string(filterStr))
|
|
|
+// DeductNum(entId, newCount)
|
|
|
+// go func() {
|
|
|
+// for _, v := range *data {
|
|
|
+// mongodb.Save("entdataexport", v)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+// redis.Put("other", "entexportdata_"+fmt.Sprintln(entId), xlsxUrl, 60)
|
|
|
+// entLock.Unlock()
|
|
|
+// }
|
|
|
+// }()
|
|
|
+// d.ServeJson(result)
|
|
|
+// }
|
|
|
+// return nil
|
|
|
+//}
|
|
|
|
|
|
//剑鱼pc判断登录用户是否有我的企业、商机管理菜单
|
|
|
func (this *DataExport) GetPcEntAuth() {
|
|
@@ -896,174 +896,175 @@ func (this *DataExport) GetPcEntAuth() {
|
|
|
this.ServeJson(data)
|
|
|
}
|
|
|
|
|
|
-//判断是否导出成功
|
|
|
-func (this *DataExport) IsEntExportSuccess() {
|
|
|
- entId := util.IntAll(this.GetSession("entId"))
|
|
|
- res := map[string]interface{}{
|
|
|
- "state": false,
|
|
|
- }
|
|
|
- if entId != 0 {
|
|
|
- key := "entexportdata_" + fmt.Sprintln(entId)
|
|
|
- log.Println(key)
|
|
|
- xlsxUrl := redis.Get("other", key)
|
|
|
- log.Println(xlsxUrl)
|
|
|
- if xlsxUrl != nil {
|
|
|
- res["state"] = true
|
|
|
- res["xlsxUrl"] = xlsxUrl
|
|
|
- redis.Del("other", key)
|
|
|
- }
|
|
|
- }
|
|
|
- this.ServeJson(res)
|
|
|
-}
|
|
|
-
|
|
|
-//生成xlsx
|
|
|
-func GetXlsx(mMap []map[string]interface{}, entId, entUserId int) string {
|
|
|
- xf, err := xlsx.OpenFile("./web/staticres/fields.xlsx")
|
|
|
- if err != nil {
|
|
|
- log.Println("fields file not foud", err.Error())
|
|
|
- }
|
|
|
- sh := xf.Sheets[1]
|
|
|
- for _, v := range mMap {
|
|
|
- row := sh.AddRow()
|
|
|
- row.AddCell().SetValue(v["area"])
|
|
|
- row.AddCell().SetValue(v["city"])
|
|
|
- row.AddCell().SetValue(v["title"])
|
|
|
- row.AddCell().SetValue(v["subtype"])
|
|
|
- row.AddCell().SetValue(v["detail"])
|
|
|
- if v["publishtime"] != nil {
|
|
|
- row.AddCell().SetValue(v["publishtime"])
|
|
|
- } else {
|
|
|
- row.AddCell()
|
|
|
- }
|
|
|
- row.AddCell().SetValue(v["href"])
|
|
|
- row.AddCell().SetValue(v["url"])
|
|
|
- row.AddCell().SetValue(v["projectname"])
|
|
|
- row.AddCell().SetValue(v["projectcode"])
|
|
|
- row.AddCell().SetValue(v["projectscope"])
|
|
|
- if v["budget"] != nil {
|
|
|
- row.AddCell().SetFloat(util.Float64All(v["budget"]))
|
|
|
- } else {
|
|
|
- row.AddCell()
|
|
|
- }
|
|
|
- if v["bidamount"] != nil {
|
|
|
- row.AddCell().SetFloat(util.Float64All(v["bidamount"]))
|
|
|
- } else {
|
|
|
- row.AddCell()
|
|
|
- }
|
|
|
- if v["bidopentime"] != nil {
|
|
|
- row.AddCell().SetValue(v["bidopentime"])
|
|
|
- } else {
|
|
|
- row.AddCell()
|
|
|
- }
|
|
|
- row.AddCell().SetValue(v["buyer"])
|
|
|
- row.AddCell().SetValue(v["buyerperson"])
|
|
|
- row.AddCell().SetValue(v["buyertel"])
|
|
|
- row.AddCell().SetValue(v["agency"])
|
|
|
- row.AddCell().SetValue(v["s_winner"])
|
|
|
- row.AddCell().SetValue(v["winnerperson"])
|
|
|
- row.AddCell().SetValue(v["winnertel"])
|
|
|
- row.AddCell().SetValue(v["legal_person"])
|
|
|
- row.AddCell().SetValue(v["company_phone"])
|
|
|
- row.AddCell().SetValue(v["company_email"])
|
|
|
- }
|
|
|
- xf.Sheets = xf.Sheets[1:2]
|
|
|
- xf.Sheets[0].Name = "数据导出"
|
|
|
- //生文件
|
|
|
- t := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
- entIds := strconv.Itoa(entId)
|
|
|
- entUserIds := strconv.Itoa(entUserId)
|
|
|
- dir := "./web/staticres/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/"
|
|
|
- if b, _ := PathExists(dir); !b {
|
|
|
- err1 := os.MkdirAll(dir, os.ModePerm)
|
|
|
- if err1 != nil {
|
|
|
- log.Println("mkdir err", dir)
|
|
|
- }
|
|
|
- }
|
|
|
- fname := entIds + "_" + entUserIds + "_" + "entdataexport.xlsx"
|
|
|
- xlsxUrl := dir + fname
|
|
|
- xlsxUrls := "/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/" + fname
|
|
|
- err = xf.Save(xlsxUrl)
|
|
|
- if err != nil {
|
|
|
- log.Println("xls error", fname)
|
|
|
- xlsxUrls = ""
|
|
|
- }
|
|
|
- return xlsxUrls
|
|
|
-}
|
|
|
-
|
|
|
-func PathExists(path string) (bool, error) {
|
|
|
- _, err := os.Stat(path)
|
|
|
- if err == nil {
|
|
|
- return true, nil
|
|
|
- }
|
|
|
- if os.IsNotExist(err) {
|
|
|
- return false, nil
|
|
|
- }
|
|
|
- return false, err
|
|
|
-}
|
|
|
-
|
|
|
-func SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums int, xlsxUrl, types, filterStr string) {
|
|
|
- query := map[string]interface{}{
|
|
|
- "id": entUserId,
|
|
|
- "ent_id": entId,
|
|
|
- }
|
|
|
- set := map[string]interface{}{
|
|
|
- "remain_nums": remain_nums - newCount,
|
|
|
- "export_nums": export_nums + newCount,
|
|
|
- }
|
|
|
- ok := public.Mysql.Update("entniche_export_limit", map[string]interface{}{"ent_id": entId, "user_id": entUserId}, set)
|
|
|
- if !ok {
|
|
|
- log.Println("修改导出条数失败", query, remain_nums, newCount)
|
|
|
- }
|
|
|
- userData := public.Mysql.FindOne("entniche_user", query, "name,phone", "")
|
|
|
- if userData != nil {
|
|
|
- name := util.ObjToString((*userData)["name"])
|
|
|
- phone := util.ObjToString((*userData)["phone"])
|
|
|
- now := time.Now()
|
|
|
- public.Mysql.Insert("entniche_export_log", map[string]interface{}{
|
|
|
- "user_name": name,
|
|
|
- "export_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
- "data_source": "2",
|
|
|
- "export_num": count,
|
|
|
- "deduct_num": newCount,
|
|
|
- "download_url": xlsxUrl,
|
|
|
- "ent_id": entId,
|
|
|
- "phone": phone,
|
|
|
- "user_id": entUserId,
|
|
|
- "filter": filterStr,
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func DeductNum(entId, newCount int) {
|
|
|
- query := map[string]interface{}{
|
|
|
- "id": entId,
|
|
|
- }
|
|
|
- userData := public.Mysql.FindOne("entniche_info", query, "name,phone", "")
|
|
|
- if userData != nil {
|
|
|
- name := util.ObjToString((*userData)["name"])
|
|
|
- phone := util.ObjToString((*userData)["phone"])
|
|
|
- public.Mgo_Qyfw.Update("user", map[string]interface{}{"phone": phone, "username": name}, map[string]interface{}{
|
|
|
- "$inc": map[string]interface{}{
|
|
|
- "plan.current": -newCount,
|
|
|
- },
|
|
|
- }, false, false)
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func GetCurrentCount(entId int) int {
|
|
|
- count := 0
|
|
|
- userData := public.Mysql.FindOne("entniche_info", map[string]interface{}{"id": entId}, "name,phone", "")
|
|
|
- if userData == nil {
|
|
|
- return count
|
|
|
- }
|
|
|
- current, ok := public.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": util.ObjToString((*userData)["phone"]), "username": util.ObjToString((*userData)["name"])})
|
|
|
- if current == nil || !ok {
|
|
|
- return count
|
|
|
- }
|
|
|
- plan, _ := (*current)["plan"].(map[string]interface{})
|
|
|
- count = util.IntAll(plan["current"])
|
|
|
- return count
|
|
|
-}
|
|
|
+//
|
|
|
+////判断是否导出成功
|
|
|
+//func (this *DataExport) IsEntExportSuccess() {
|
|
|
+// entId := util.IntAll(this.GetSession("entId"))
|
|
|
+// res := map[string]interface{}{
|
|
|
+// "state": false,
|
|
|
+// }
|
|
|
+// if entId != 0 {
|
|
|
+// key := "entexportdata_" + fmt.Sprintln(entId)
|
|
|
+// log.Println(key)
|
|
|
+// xlsxUrl := redis.Get("other", key)
|
|
|
+// log.Println(xlsxUrl)
|
|
|
+// if xlsxUrl != nil {
|
|
|
+// res["state"] = true
|
|
|
+// res["xlsxUrl"] = xlsxUrl
|
|
|
+// redis.Del("other", key)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// this.ServeJson(res)
|
|
|
+//}
|
|
|
+//
|
|
|
+////生成xlsx
|
|
|
+//func GetXlsx(mMap []map[string]interface{}, entId, entUserId int) string {
|
|
|
+// xf, err := xlsx.OpenFile("./web/staticres/fields.xlsx")
|
|
|
+// if err != nil {
|
|
|
+// log.Println("fields file not foud", err.Error())
|
|
|
+// }
|
|
|
+// sh := xf.Sheets[1]
|
|
|
+// for _, v := range mMap {
|
|
|
+// row := sh.AddRow()
|
|
|
+// row.AddCell().SetValue(v["area"])
|
|
|
+// row.AddCell().SetValue(v["city"])
|
|
|
+// row.AddCell().SetValue(v["title"])
|
|
|
+// row.AddCell().SetValue(v["subtype"])
|
|
|
+// row.AddCell().SetValue(v["detail"])
|
|
|
+// if v["publishtime"] != nil {
|
|
|
+// row.AddCell().SetValue(v["publishtime"])
|
|
|
+// } else {
|
|
|
+// row.AddCell()
|
|
|
+// }
|
|
|
+// row.AddCell().SetValue(v["href"])
|
|
|
+// row.AddCell().SetValue(v["url"])
|
|
|
+// row.AddCell().SetValue(v["projectname"])
|
|
|
+// row.AddCell().SetValue(v["projectcode"])
|
|
|
+// row.AddCell().SetValue(v["projectscope"])
|
|
|
+// if v["budget"] != nil {
|
|
|
+// row.AddCell().SetFloat(util.Float64All(v["budget"]))
|
|
|
+// } else {
|
|
|
+// row.AddCell()
|
|
|
+// }
|
|
|
+// if v["bidamount"] != nil {
|
|
|
+// row.AddCell().SetFloat(util.Float64All(v["bidamount"]))
|
|
|
+// } else {
|
|
|
+// row.AddCell()
|
|
|
+// }
|
|
|
+// if v["bidopentime"] != nil {
|
|
|
+// row.AddCell().SetValue(v["bidopentime"])
|
|
|
+// } else {
|
|
|
+// row.AddCell()
|
|
|
+// }
|
|
|
+// row.AddCell().SetValue(v["buyer"])
|
|
|
+// row.AddCell().SetValue(v["buyerperson"])
|
|
|
+// row.AddCell().SetValue(v["buyertel"])
|
|
|
+// row.AddCell().SetValue(v["agency"])
|
|
|
+// row.AddCell().SetValue(v["s_winner"])
|
|
|
+// row.AddCell().SetValue(v["winnerperson"])
|
|
|
+// row.AddCell().SetValue(v["winnertel"])
|
|
|
+// row.AddCell().SetValue(v["legal_person"])
|
|
|
+// row.AddCell().SetValue(v["company_phone"])
|
|
|
+// row.AddCell().SetValue(v["company_email"])
|
|
|
+// }
|
|
|
+// xf.Sheets = xf.Sheets[1:2]
|
|
|
+// xf.Sheets[0].Name = "数据导出"
|
|
|
+// //生文件
|
|
|
+// t := strconv.FormatInt(time.Now().Unix(), 10)
|
|
|
+// entIds := strconv.Itoa(entId)
|
|
|
+// entUserIds := strconv.Itoa(entUserId)
|
|
|
+// dir := "./web/staticres/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/"
|
|
|
+// if b, _ := PathExists(dir); !b {
|
|
|
+// err1 := os.MkdirAll(dir, os.ModePerm)
|
|
|
+// if err1 != nil {
|
|
|
+// log.Println("mkdir err", dir)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// fname := entIds + "_" + entUserIds + "_" + "entdataexport.xlsx"
|
|
|
+// xlsxUrl := dir + fname
|
|
|
+// xlsxUrls := "/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/" + fname
|
|
|
+// err = xf.Save(xlsxUrl)
|
|
|
+// if err != nil {
|
|
|
+// log.Println("xls error", fname)
|
|
|
+// xlsxUrls = ""
|
|
|
+// }
|
|
|
+// return xlsxUrls
|
|
|
+//}
|
|
|
+//
|
|
|
+//func PathExists(path string) (bool, error) {
|
|
|
+// _, err := os.Stat(path)
|
|
|
+// if err == nil {
|
|
|
+// return true, nil
|
|
|
+// }
|
|
|
+// if os.IsNotExist(err) {
|
|
|
+// return false, nil
|
|
|
+// }
|
|
|
+// return false, err
|
|
|
+//}
|
|
|
+//
|
|
|
+//func SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums int, xlsxUrl, types, filterStr string) {
|
|
|
+// query := map[string]interface{}{
|
|
|
+// "id": entUserId,
|
|
|
+// "ent_id": entId,
|
|
|
+// }
|
|
|
+// set := map[string]interface{}{
|
|
|
+// "remain_nums": remain_nums - newCount,
|
|
|
+// "export_nums": export_nums + newCount,
|
|
|
+// }
|
|
|
+// ok := public.Mysql.Update("entniche_export_limit", map[string]interface{}{"ent_id": entId, "user_id": entUserId}, set)
|
|
|
+// if !ok {
|
|
|
+// log.Println("修改导出条数失败", query, remain_nums, newCount)
|
|
|
+// }
|
|
|
+// userData := public.Mysql.FindOne("entniche_user", query, "name,phone", "")
|
|
|
+// if userData != nil {
|
|
|
+// name := util.ObjToString((*userData)["name"])
|
|
|
+// phone := util.ObjToString((*userData)["phone"])
|
|
|
+// now := time.Now()
|
|
|
+// public.Mysql.Insert("entniche_export_log", map[string]interface{}{
|
|
|
+// "user_name": name,
|
|
|
+// "export_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
+// "data_source": "2",
|
|
|
+// "export_num": count,
|
|
|
+// "deduct_num": newCount,
|
|
|
+// "download_url": xlsxUrl,
|
|
|
+// "ent_id": entId,
|
|
|
+// "phone": phone,
|
|
|
+// "user_id": entUserId,
|
|
|
+// "filter": filterStr,
|
|
|
+// })
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//func DeductNum(entId, newCount int) {
|
|
|
+// query := map[string]interface{}{
|
|
|
+// "id": entId,
|
|
|
+// }
|
|
|
+// userData := public.Mysql.FindOne("entniche_info", query, "name,phone", "")
|
|
|
+// if userData != nil {
|
|
|
+// name := util.ObjToString((*userData)["name"])
|
|
|
+// phone := util.ObjToString((*userData)["phone"])
|
|
|
+// public.Mgo_Qyfw.Update("user", map[string]interface{}{"phone": phone, "username": name}, map[string]interface{}{
|
|
|
+// "$inc": map[string]interface{}{
|
|
|
+// "plan.current": -newCount,
|
|
|
+// },
|
|
|
+// }, false, false)
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//func GetCurrentCount(entId int) int {
|
|
|
+// count := 0
|
|
|
+// userData := public.Mysql.FindOne("entniche_info", map[string]interface{}{"id": entId}, "name,phone", "")
|
|
|
+// if userData == nil {
|
|
|
+// return count
|
|
|
+// }
|
|
|
+// current, ok := public.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": util.ObjToString((*userData)["phone"]), "username": util.ObjToString((*userData)["name"])})
|
|
|
+// if current == nil || !ok {
|
|
|
+// return count
|
|
|
+// }
|
|
|
+// plan, _ := (*current)["plan"].(map[string]interface{})
|
|
|
+// count = util.IntAll(plan["current"])
|
|
|
+// return count
|
|
|
+//}
|
|
|
|
|
|
//获取当前登录用户的手机号
|
|
|
func GetPhone(userId string) (string, string) {
|