|
@@ -14,6 +14,7 @@ import (
|
|
|
"regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "sync"
|
|
|
"time"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
@@ -49,8 +50,14 @@ type DataExport struct {
|
|
|
integralDetail xweb.Mapper `xweb:"/front/integral/integralDetail"` //剑鱼币订单详情
|
|
|
|
|
|
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
|
|
|
+
|
|
|
type Filters struct {
|
|
|
FilterId string
|
|
|
}
|
|
@@ -60,8 +67,15 @@ func init() {
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
- layout_date = "2006.01.02"
|
|
|
- tableName_order = "dataexport_order" //订单表
|
|
|
+ layout_date = "2006.01.02"
|
|
|
+ orderStatus_unPaid = "0" //订单状态-待支付
|
|
|
+ orderStatus_paid = "1" //订单状态-已完成
|
|
|
+ orderStatus_deleted = "-1" //订单状态-已删除
|
|
|
+ orderStatus_cancel = "-2" //订单状态-已取消
|
|
|
+ tableName_order = "dataexport_order" //订单表
|
|
|
+ SE = util.SimpleEncrypt{Key: "topJYBX2019"}
|
|
|
+ exportLock = sync.Mutex{}
|
|
|
+ exportLockMap = map[int]sync.Mutex{}
|
|
|
)
|
|
|
|
|
|
func (d *DataExport) ToSieve() error {
|
|
@@ -92,38 +106,57 @@ func (d *DataExport) SieveData() error {
|
|
|
var cityArr []string
|
|
|
var regionArr []string
|
|
|
var industryArr []string
|
|
|
+ var subTypeArr []string
|
|
|
var buyerArr []string
|
|
|
var buyerclassArr []string
|
|
|
var winnerArr []string
|
|
|
var keywordList []dataexport.KeyWord
|
|
|
|
|
|
+ log.Println("price", minPrice, maxPrice)
|
|
|
+ if publishtime != "" {
|
|
|
+ log.Println("publishtime", publishtime)
|
|
|
+ }
|
|
|
if area != "" {
|
|
|
areaArr = strings.Split(area, ",")
|
|
|
+ log.Println("areaArr", areaArr)
|
|
|
}
|
|
|
if city != "" {
|
|
|
cityArr = strings.Split(city, ",")
|
|
|
+ log.Println("cityArr", cityArr)
|
|
|
}
|
|
|
if region != "" {
|
|
|
regionArr = strings.Split(region, ",")
|
|
|
+ log.Println("regionArr", regionArr)
|
|
|
}
|
|
|
if industry != "" {
|
|
|
industryArr = strings.Split(industry, ",")
|
|
|
log.Println("industryArr", industryArr)
|
|
|
}
|
|
|
+ if subType != "" {
|
|
|
+ subTypeArr = strings.Split(subType, ",")
|
|
|
+ log.Println("subTypeArr", subTypeArr)
|
|
|
+ }
|
|
|
+ log.Println("keywordParam", keyword)
|
|
|
if keyword != "" {
|
|
|
err := json.Unmarshal([]byte(keyword), &keywordList)
|
|
|
if err != nil {
|
|
|
log.Println("keyword param 反序列化异常,查看前后台字段是否对应")
|
|
|
+ } else {
|
|
|
+ log.Println("keywordList", len(keywordList), keywordList)
|
|
|
}
|
|
|
}
|
|
|
+ log.Println("selectType", selectType)
|
|
|
if buyer != "" {
|
|
|
buyerArr = strings.Split(buyer, ",")
|
|
|
+ log.Println("buyerArr", buyerArr)
|
|
|
}
|
|
|
if buyerclass != "" {
|
|
|
buyerclassArr = strings.Split(buyerclass, ",")
|
|
|
+ log.Println("buyerclassArr", buyerclassArr)
|
|
|
}
|
|
|
if winner != "" {
|
|
|
winnerArr = strings.Split(winner, ",")
|
|
|
+ log.Println("winnerArr", winnerArr)
|
|
|
}
|
|
|
sieveCondition := map[string]interface{}{
|
|
|
"publishtime": publishtime,
|
|
@@ -197,6 +230,7 @@ func (d *DataExport) ToOrderDetail(orderCode string) error {
|
|
|
if orderCode != "" {
|
|
|
orderDetail = *public.Mysql.FindOne(tableName_order, queryMap, "", "")
|
|
|
}
|
|
|
+ // log.Println("ToOrderDetail", orderCode, orderDetail)
|
|
|
if orderDetail["pay_money"] != nil {
|
|
|
orderDetail["pay_money"] = float64(orderDetail["pay_money"].(int64))
|
|
|
}
|
|
@@ -687,6 +721,15 @@ 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) InvoicetimeOut() {
|
|
|
d.Render("/pc/invoice_error.html")
|
|
|
}
|
|
@@ -700,6 +743,86 @@ 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
|
|
|
+//}
|
|
|
+
|
|
|
//剑鱼pc判断登录用户是否有我的企业、商机管理菜单
|
|
|
func (this *DataExport) GetPcEntAuth() {
|
|
|
userId, _ := this.GetSession("userId").(string)
|
|
@@ -780,7 +903,7 @@ func (this *DataExport) GetPcEntAuth() {
|
|
|
}
|
|
|
|
|
|
data := map[string]interface{}{
|
|
|
- "myEntMenu": myEntMenu,
|
|
|
+ "myEntMenu": true,
|
|
|
"entnicheMenu": entnicheMenu,
|
|
|
"isNew": isNew,
|
|
|
"privatedata": privatedata,
|
|
@@ -788,6 +911,176 @@ 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 GetPhone(userId string) (string, string) {
|
|
|
u, ok := mongodb.FindById("user", userId, `{"s_phone":1,"s_m_phone":1}`)
|