1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327 |
- package front
- import (
- "encoding/json"
- "errors"
- "fmt"
- "jy/src/jfw/config"
- "jy/src/jfw/jyutil"
- "log"
- "regexp"
- "strconv"
- "strings"
- "sync"
- "time"
- . "app.yhyue.com/moapp/jybase/date"
- "app.yhyue.com/moapp/jybase/encrypt"
- "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/public"
- util "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- )
- type DataExport struct {
- *xweb.Action
- toSieve xweb.Mapper `xweb:"/front/dataExport/toSieve"` //数据导出-条件筛选
- sieveData xweb.Mapper `xweb:"/front/dataExport/sieveData"` //筛选数据
- toOrderDetail xweb.Mapper `xweb:"/front/dataExport/toOrderDetail/(.*)"` //订单详情
- getOrderCode xweb.Mapper `xweb:"/front/dataExport/getOrderCode/(\\w+)"` //申请发票获取订单编号
- superSearchExport xweb.Mapper `xweb:"/front/dataExport/superSearchExport"` //数据导出-超级搜索
- toCreateOrderPage xweb.Mapper `xweb:"/front/dataExport/toCreateOrderPage/(.*)"` //数据导出-订单页面
- previewData xweb.Mapper `xweb:"/front/(.*)/previewData/(.*)"` //数据导出-数据预览
- sendMailVerify xweb.Mapper `xweb:"/front/dataExport/sendMailVerify"` //发送邮箱验证码
- checkMailVerify xweb.Mapper `xweb:"/front/dataExport/checkMailVerify"` //验证邮箱验证码
- paysuccess xweb.Mapper `xweb:"/front/dataExport/paysuccess"` //支付成功页面
- checkPhoneVerify xweb.Mapper `xweb:"/front/dataExport/checkPhoneVerify"` //验证手机号
- fontSet xweb.Mapper `xweb:"/front/dataExport/fontSet/(.*)"`
- setDontPromptAgain xweb.Mapper `xweb:"/front/dataExport/setDontPromptAgain"` //数据导出-超出2w条,不再提示
- getDontPromptAgain xweb.Mapper `xweb:"/front/dataExport/getDontPromptAgain"` //数据导出-超出2w条,不再提示
- cancelOrder xweb.Mapper `xweb:"/front/dataExport/cancelOrder"` //取消订单
- vipOrderDetail xweb.Mapper `xweb:"/front/vipOrder/vipOrderDetail"` //vip订单详情
- entOrderDetail xweb.Mapper `xweb:"/front/entniche/entnicheOrderDetail"` //商机管理订单详情
- invoice xweb.Mapper `xweb:"/front/order/invoice/(\\w+)"` //电子发票-开发票
- check_invoice xweb.Mapper `xweb:"/front/order/check_invoice/(\\w+)"` //电子发票-开发票-流程
- invoicetimeOut xweb.Mapper `xweb:"/front/order/invoicetimeOut"` //申请超时
- valuationList xweb.Mapper `xweb:"/front/order/valuationList/(\\w+)"` //计费清单
- memberDetail xweb.Mapper `xweb:"/front/member/memberDetail"` //大会员订单详情
- aiForecastPackDetail xweb.Mapper `xweb:"/front/aiForecastPack/aiForecastPackDetail"` //AI中标预测包订单详情
- subAccountDetail xweb.Mapper `xweb:"/front/subAccount/subAccountDetail"` //子账号订单详情
- bidfileDetail xweb.Mapper `xweb:"/front/bidfile/bidfileDetail"` //招标文件解读详情
- 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
- }
- func init() {
- xweb.AddAction(&DataExport{})
- }
- var (
- layout_date = "2006.01.02"
- orderStatus_unPaid = "0" //订单状态-待支付
- orderStatus_paid = "1" //订单状态-已完成
- orderStatus_deleted = "-1" //订单状态-已删除
- orderStatus_cancel = "-2" //订单状态-已取消
- tableName_order = "dataexport_order" //订单表
- SEX = encrypt.SimpleEncrypt{Key: "topJYBX2019"}
- exportLock = sync.Mutex{}
- exportLockMap = map[int]sync.Mutex{}
- )
- func (d *DataExport) ToSieve() error {
- industrylist, sortArray = jy.Getindustrys(util.ObjToString(config.Sysconfig["industry"]), public.MQFW)
- d.T["industrylist"] = industrylist
- d.T["sortArray"] = sortArray
- d.T["logid"] = config.Seoconfig["dataexport"].(string)
- d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
- d.Render("/pc/dataExport_sieve.html", &d.T)
- return nil
- }
- func (d *DataExport) SieveData() {
- dataType := d.GetString("dataType")
- publishtime := d.GetString("publishtime")
- area := d.GetString("area")
- city := d.GetString("city")
- region := d.GetString("region")
- industry := d.GetString("industry")
- keyword := d.GetString("keyword")
- minPrice := d.GetString("minprice")
- maxPrice := d.GetString("maxprice")
- subType := d.GetString("subtype")
- buyer := d.GetString("buyer")
- buyerclass := d.GetString("buyerclass")
- winner := d.GetString("winner")
- selectType := d.GetString("selectType")
- var areaArr []string
- 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)
- }
- 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)
- }
- var isTitle int
- if selectType != "" {
- if strings.Count(selectType, "title") > 1 {
- isTitle = 3 //包含标题及正文
- } else if strings.Contains(selectType, "detail") {
- isTitle = 2 //只包含正文
- } else if strings.Contains(selectType, "title") {
- isTitle = 1 //只包含标题
- }
- //去重 如果选取了标题及正文 引起的有2个title问题
- if strings.Count(selectType, "title") > 1 {
- var detail []string
- for _, v := range strings.Split(selectType, ",") {
- if v == "title" {
- continue
- }
- detail = append(detail, v)
- }
- //维持原逻辑 正文表示标题及正文
- selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
- }
- }
- exportLimit := util.StructToMapMore(config.ExportConfig["exportLimit"])
- wordsLimit := util.IntAllDef(exportLimit["wordsLimit"], 100)
- countLimit := util.IntAllDef(exportLimit["countLimit"], 300)
- buyerLimit := util.IntAllDef(exportLimit["buyerLimit"], 100)
- winnerLimit := util.IntAllDef(exportLimit["winnerLimit"], 100)
- var count int
- for k, kw := range keywordList {
- if kw.Keyword != "" {
- count++
- }
- count += len(kw.Appended)
- count += len(kw.Exclude)
- if len([]rune(kw.Keyword)) > wordsLimit {
- keywordList[k].Keyword = util.SubString(kw.Keyword, 0, wordsLimit)
- }
- for k1, ad := range kw.Appended {
- if len([]rune(ad)) > wordsLimit {
- keywordList[k].Appended[k1] = util.SubString(ad, 0, wordsLimit)
- }
- }
- for k1, el := range kw.Exclude {
- if len([]rune(el)) > wordsLimit {
- keywordList[k].Exclude[k1] = util.SubString(el, 0, wordsLimit)
- }
- }
- }
- if count > countLimit {
- d.ServeJson(map[string]interface{}{
- "error_code": -1,
- "error_msg": fmt.Sprintf("关键词信息超过上限%d", countLimit),
- })
- return
- }
- if len(buyerArr) > buyerLimit {
- d.ServeJson(map[string]interface{}{
- "error_code": -1,
- "error_msg": fmt.Sprintf("采购单位超过上限%d", buyerLimit),
- })
- return
- }
- if len(winnerArr) > winnerLimit {
- d.ServeJson(map[string]interface{}{
- "error_code": -1,
- "error_msg": fmt.Sprintf("中标单位超过上限%d", winnerLimit),
- })
- return
- }
- sieveCondition := map[string]interface{}{
- "publishtime": publishtime,
- "area": areaArr,
- "city": cityArr,
- "region": regionArr,
- "industry": industryArr,
- "keywords": keywordList,
- "selectType": selectType,
- "minprice": minPrice,
- "maxprice": maxPrice,
- "subtype": subType,
- "buyer": buyerArr,
- "buyerclass": buyerclassArr,
- "isTitle": isTitle,
- "winner": winnerArr,
- "comeintime": time.Now().Unix(),
- "comeinfrom": "exportPage",
- }
- sessVal := d.Session().GetMultiple()
- if sessVal["s_m_openid"] != nil {
- sieveCondition["s_openid"] = util.ObjToString(sessVal["s_m_openid"])
- }
- if sessVal["userId"] != nil {
- sieveCondition["s_userid"] = util.ObjToString(sessVal["userId"])
- }
- _id := mongodb.Save(dataexport.ExportTable, sieveCondition)
- _res := map[string]interface{}{
- "error_code": 0,
- "error_msg": "",
- }
- if _id != "" {
- msgCount := dataexport.GetDataExportSearchCountByScdId(public.MQFW, public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, _id)
- //从500条数据中筛选字段最全五条
- scd := dataexport.GetSqlObjFromId(public.MQFW, _id)
- kws := scd.Keyword
- res, err := dataexport.GetDataExportSearchResult(public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, scd, dataType, -1)
- if res == nil || err != nil {
- _res["error_msg"] = "无数据"
- d.ServeJson(_res)
- return
- }
- //格式化字段
- res_screen := dataexport.ScreenData(res, dataType, 20, kws)
- var EntArr = []string{}
- if dataType == "2" {
- for _, v := range res_screen {
- //高级字段查询且winner不为空
- if v["s_winner"] != nil && v["s_winner"] != "" {
- EntArr = append(EntArr, v["s_winner"].(string))
- }
- }
- }
- list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
- /*if msgCount > 20000 {
- msgCount = 20000
- }*/
- _res["data"] = map[string]interface{}{
- "list": subUrl(list, dataType),
- "_id": encrypt.SE.Encode2Hex(_id),
- "total": msgCount,
- }
- d.ServeJson(_res)
- //_res["dataType"] = dataType
- //d.T["success"] = true
- //d.T["redirectUrl"] = "/front/dataExport/toCreateOrderPage/" + util.se.Encode2Hex(_id)
- } else {
- _res["error_code"] = -1
- _res["error_msg"] = "保存筛选条件失败"
- d.ServeJson(_res)
- }
- }
- /*
- *
- 根据 id+openid 取消订单
- */
- func (d *DataExport) CancelOrder() error {
- if userId := d.GetSession("userId"); userId != nil {
- // if openid := d.GetSession("s_m_openid"); openid != nil {
- queryMap := map[string]interface{}{
- "id": d.GetString("id"),
- "user_id": userId.(string),
- }
- boo := public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
- //取消订单
- d.ServeJson(map[string]interface{}{"success": boo})
- }
- return nil
- }
- /*
- *
- 根据 订单编号+userId 查询
- */
- func (d *DataExport) ToOrderDetail(orderCode string) error {
- myUserId := ""
- if userId := d.GetSession("userId"); userId != nil {
- // if openid := d.GetSession("s_m_openid"); openid != nil {
- myUserId = userId.(string)
- } else {
- return nil
- }
- orderDetail := map[string]interface{}{}
- filter := dataexport.SieveCondition{}
- queryMap := map[string]interface{}{
- "order_code": orderCode,
- "user_id": myUserId,
- }
- if orderCode != "" {
- orderDetail = *public.Mysql.FindOne(tableName_order, queryMap, "", "")
- //最后一次开票查询
- orderDetail["source"] = LastInvoiceSource(orderCode)
- }
- // log.Println("ToOrderDetail", orderCode, orderDetail)
- if orderDetail["pay_money"] != nil {
- orderDetail["pay_money"] = float64(orderDetail["pay_money"].(int64))
- }
- if orderDetail["order_money"] != nil {
- orderDetail["order_money"] = float64(orderDetail["order_money"].(int64))
- }
- if orderDetail["discount_price"] != nil {
- orderDetail["discount_price"] = float64(orderDetail["discount_price"].(int64))
- }
- //卡卷id加密
- if orderDetail["d_relation_id"] != "" {
- orderDetail["userLotteryId"] = encrypt.SE.Encode2Hex(util.ObjToString(orderDetail["d_relation_id"]))
- }
- delete(orderDetail, "d_relation_id")
- if orderDetail["filter"] != nil {
- err := json.Unmarshal([]byte(orderDetail["filter"].(string)), &filter)
- if err == nil {
- publishtime := filter.PublishTime
- if publishtime != "" {
- timeArr := strings.Split(publishtime, "_")
- if len(timeArr) == 2 {
- start, err := strconv.ParseInt(timeArr[0], 10, 64)
- end, erro := strconv.ParseInt(timeArr[1], 10, 64)
- if err == nil && erro == nil {
- filter.PublishTime = FormatDateByInt64(&start, layout_date) + "-" + FormatDateByInt64(&end, layout_date)
- } else if err == nil && erro != nil {
- filter.PublishTime = FormatDateByInt64(&start, layout_date) + "-"
- } else if err != nil && erro == nil {
- filter.PublishTime = "-" + FormatDateByInt64(&end, layout_date)
- }
- }
- }
- filter.MinPrice = public.GetPriceDes_SieveCondition(filter.MinPrice, filter.MaxPrice)
- orderDetail["filter"] = filter
- } else {
- log.Println("筛选条件-关键词-结构体反序列化-错误", err)
- }
- }
- if orderDetail["applybill_type"] != nil && orderDetail["applybill_type"].(int64) == 0 {
- orderDetail["applybill_type"] = "个人"
- } else if orderDetail["applybill_type"] != nil && orderDetail["applybill_type"].(int64) == 1 {
- orderDetail["applybill_type"] = "单位"
- } else {
- orderDetail["applybill_type"] = "-"
- }
- orderStatus := util.IntAll((orderDetail)["order_status"])
- if orderStatus == 1 {
- orderDetail["transaction_id"] = func() string {
- table := ""
- payway := util.ObjToString(orderDetail["pay_way"])
- if strings.Contains(payway, "wx") {
- payway = "微信"
- table = "weixin_pay"
- } else if strings.Contains(payway, "ali") {
- payway = "支付宝"
- table = "ali_pay"
- } else {
- return ""
- }
- orderDetail["pay_way"] = payway
- wxPayMap := map[string]interface{}{}
- wxPayMap["out_trade_no"] = orderDetail["out_trade_no"]
- payDetail := public.Mysql.FindOne(table, wxPayMap, "", "")
- if payDetail == nil || len(*payDetail) == 0 {
- return ""
- }
- return util.ObjToString((*payDetail)["transaction_id"])
- }()
- }
- d.T["o"] = orderDetail
- d.T["logid"] = config.Seoconfig["dataexport"].(string)
- return d.Render("/pc/orderDetail.html", &d.T)
- }
- // 查询订单最后开票状态
- func LastInvoiceSource(orderCode string) int64 {
- orderData := public.Mysql.SelectBySql("select source from invoice where order_code =? ORDER BY create_time desc ", orderCode)
- if orderData != nil && len(*orderData) > 0 {
- return util.Int64All((*orderData)[0]["source"])
- }
- return 0
- }
- // ------------------------------申请发票跳转页面-----------------------------
- func (d *DataExport) GetOrderCode(order_code string) error {
- var status, order_status int64
- queryMap := map[string]interface{}{
- "order_code": order_code,
- }
- oDate := public.Mysql.FindOne(tableName_order, queryMap, "", "")
- status = (*oDate)["applybill_status"].(int64)
- order_status = (*oDate)["order_status"].(int64)
- d.T["order_code"] = order_code
- d.T["logid"] = config.Seoconfig["dataexport"].(string)
- //是否申请发票 支付状态
- if status == 1 || order_status == 0 {
- d.Redirect("/front/dataExport/toOrderDetail/" + order_code)
- } else {
- d.Render("/pc/dataExport_invoice.html", &d.T)
- }
- return nil
- }
- // ---------------------------生成订单预览----------------------------------
- func (d *DataExport) SuperSearchExport() error {
- sessVal := d.Session().GetMultiple()
- openid := util.ObjToString(sessVal["s_m_openid"])
- userId := util.ObjToString(sessVal["userId"])
- searchGroup, _ := d.GetInteger("searchGroup")
- searchMode, _ := d.GetInteger("searchMode")
- wordsMode, _ := d.GetInteger("wordsMode")
- if userId == "" {
- return errors.New("未登录")
- }
- //接收超级搜索页面参数
- reqData := public.BidSearchExport{
- Keywords: d.GetString("keywords"), //搜索词
- Publishtime: d.GetString("publishtime"), //发布时间
- Area: d.GetString("area"), //地区
- Subtype: d.GetString("subtype"), //信息类型
- Minprice: d.GetString("minprice"), //最低价格
- Maxprice: d.GetString("maxprice"), //最高价格
- Industry: strings.TrimSpace(d.GetString("industry")), //选中的行业
- SelectType: d.GetString("selectType"), //标题 or 全文
- Buyerclass: d.GetString("buyerclass"), //采购单位行业
- Hasbuyertel: d.GetString("buyertel"), //是否有采购电话
- Haswinnertel: d.GetString("winnertel"), //是否有中标电话
- SelectIds: strings.TrimSpace(d.GetString("selectIds")), //选择信息id
- Notkey: d.GetString("notkey"), //排除词
- FileExists: d.GetString("fileExists"), //是否有附件
- City: d.GetString("city"), //城市
- BidField: d.GetString("bid_field"), // 领域数据类型 0101- 医疗行业
- SearchGroup: searchGroup, //搜索分组:默认0:全部;1:招标采购公告;2:超前项目
- SearchMode: searchMode, //搜索模式:0:精准搜索;1:模糊搜索
- WordsMode: wordsMode, //搜索关键词模式;默认0:包含所有,1:包含任意
- AdditionalWords: d.GetString("additionalWords"), //关键词:附加关键词(副:五组,每组最多15个字符)
- }
- selectType := strings.Join(jy.GetVipState(d.Session(), *config.Middleground, userId).GetQueryItems(d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
- //数据回显
- d.SetSession("Echo_timeslot", d.GetString("timeslot"))
- d.SetSession("Echo_keywords", reqData.Keywords)
- d.SetSession("Echo_publishtime", reqData.Publishtime)
- d.SetSession("Echo_area", reqData.Area)
- d.SetSession("Echo_subtype", reqData.Subtype)
- d.SetSession("Echo_minprice", reqData.Minprice)
- d.SetSession("Echo_maxprice", reqData.Maxprice)
- d.SetSession("Echo_industry", reqData.Industry)
- d.SetSession("Echo_selectType", reqData.SelectType)
- d.SetSession("Echo_buyerclass", reqData.Buyerclass)
- d.SetSession("Echo_hasBuyertel", reqData.Hasbuyertel)
- d.SetSession("Echo_hasWinnertel", reqData.Haswinnertel)
- d.SetSession("Echo_notkey", reqData.Notkey)
- d.SetSession("Echo_fileExists", reqData.FileExists)
- d.SetSession("Echo_city", reqData.City)
- d.SetSession("Echo_bid_field", reqData.BidField) // 领域类型 0101-医疗行业
- d.SetSession("Echo_searchGroup", reqData.SearchGroup)
- d.SetSession("Echo_searchMode", reqData.SearchMode)
- d.SetSession("Echo_wordsMode", reqData.WordsMode)
- d.SetSession("Echo_additionalWords", reqData.AdditionalWords)
- saveData := reqData.PassBidSearchExport(config.Sysconfig)
- saveData["selectType"] = selectType
- saveData["s_openid"] = openid
- saveData["s_userid"] = userId
- saveData["comeinfrom"] = "supersearchPage"
- //是否开启 正文 标题同时搜索只搜正文的开关
- saveData["searchTypeSwitch"], _ = config.Sysconfig["searchTypeSwitch"].(bool)
- region := util.If(reqData.Area == "全国", "", reqData.Area).(string)
- if region != "" && reqData.City != "" {
- region += "," + reqData.City
- } else {
- region = reqData.City
- }
- saveData["region"] = util.If(region != "", strings.Split(region, ","), []string{}).([]string)
- //存入数据库
- _id := mongodb.Save(dataexport.ExportTable, saveData)
- log.Println(_id, "saveData:", saveData)
- return d.Redirect("/front/dataExport/toCreateOrderPage/" + encrypt.SE.Encode2Hex(_id))
- }
- func (d *DataExport) ToCreateOrderPage(_id string) error {
- id := encrypt.SE.Decode4Hex(_id)
- sessVal := d.Session().GetMultiple()
- openid := util.ObjToString(sessVal["s_m_openid"])
- userId := util.ObjToString(sessVal["userId"])
- if userId == "" {
- return errors.New("未登录")
- }
- // }
- // 企业数据导出结束
- //是否是从结构化数据推广页过来的
- if d.GetString("from") == "structed" {
- d.SetSession("Structed", true)
- } else {
- d.DelSession("Structed")
- }
- msgCount := dataexport.GetDataExportSearchCountByScdId(public.MQFW, public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, id)
- if msgCount > public.ExConf.MsgMaxCount || msgCount == -1 {
- msgCount = public.ExConf.MsgMaxCount
- }
- d.T["logid"] = config.Seoconfig["dataexport"].(string)
- if msgCount < 1 {
- d.Render("/pc/dataExport_noDataErr.html", &d.T)
- return nil
- }
- //订单数据存入session中
- d.SetSession("dataexport_waitcreateorder", map[string]interface{}{
- "id": id, //用户的筛选条件mongodb中的id string
- "data_count": msgCount, //匹配到的数据总数 int
- })
- resEmail := util.ObjToString(sessVal["DataExportVerifyEmail_val"])
- resPhone := util.ObjToString(sessVal["DataExportVerifyPhone_val"])
- if resEmail != "" {
- lastSendDEVerify := util.Int64All(sessVal["CreatEVerifyTime"])
- timeSpaceing := lastSendDEVerify - time.Now().Unix() + 60*5
- d.T["email"] = resEmail
- d.T["timeSpaceing"] = timeSpaceing
- }
- if resPhone != "" {
- d.T["phone"] = resPhone
- }
- if resEmail == "" || resPhone == "" {
- lastEmail, lastPhone := "", ""
- if lastPhone, lastEmail = dataexport.GetLastExportPhoneAndMail(public.Mysql, userId, util.ObjToString(sessVal["entUserId"])); lastPhone == "" || lastEmail == "" {
- userData := jyutil.Compatible.Select(userId, `{"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
- if userData != nil && len(*userData) > 0 {
- if lastEmail == "" {
- lastEmail, _ = (*userData)["s_myemail"].(string)
- }
- if lastPhone == "" {
- lastPhone, _ = util.If((*userData)["s_phone"] != nil, (*userData)["s_phone"], (*userData)["s_m_phone"]).(string)
- }
- }
- }
- if resEmail == "" && lastEmail != "" {
- d.T["email"] = lastEmail
- d.SetSession("EMVerifySucess", true)
- d.SetSession("DataExportVerifyEmail_val", lastEmail)
- }
- if resPhone == "" {
- setPhone := lastPhone
- if isPhone(openid) { //剑鱼助手手机号登录
- setPhone = openid
- }
- if setPhone != "" {
- d.SetSession("DataExportVerifyPhone_val", lastPhone)
- }
- d.T["phone"] = lastPhone
- }
- }
- d.T["_id"] = _id
- d.T["msgCount"] = msgCount
- incurKey := fmt.Sprintf("PreviewData_%s_%d", util.ObjToString(sessVal["userId"]), time.Now().Day())
- d.T["PreviewData"] = util.IntAll(redis.Get("other", incurKey))
- d.Render("/pc/createOrderPage.html", &d.T)
- return nil
- }
- func (d *DataExport) PreviewData(source, _id string) error {
- if !strings.Contains(source, "app") {
- sessVal := d.Session().GetMultiple()
- userId := util.ObjToString(sessVal["userId"])
- // openid := util.ObjToString(d.GetSession("s_m_openid"))
- if userId == "" {
- return errors.New("未登录")
- }
- //数据预览每天限制50次
- incurKey := fmt.Sprintf("PreviewData_%s_%d", util.ObjToString(sessVal["userId"]), time.Now().Day())
- times := util.IntAll(redis.Get("other", incurKey))
- if times >= 50 {
- return errors.New("超出预览次数")
- }
- if times == 0 {
- redis.Put("other", incurKey, 1, 24*60*60)
- } else {
- redis.Incr("other", incurKey)
- }
- }
- _id = encrypt.SE.Decode4Hex(_id)
- dataType := d.GetString("dataType")
- //从500条数据中筛选字段最全五条
- scd := dataexport.GetSqlObjFromId(public.MQFW, _id)
- kws := scd.Keyword
- res, err := dataexport.GetDataExportSearchResult(public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, scd, dataType, -1)
- if res == nil || err != nil {
- log.Println("PreviewData查询出错", res)
- return d.Render("/pc/dataExport_noDataErr.html", &d.T)
- }
- //格式化字段
- res_screen := dataexport.ScreenData(res, dataType, 20, kws)
- list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
- d.T["data"] = subUrl(list, dataType)
- d.T["dataType"] = dataType
- d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
- d.Render("/pc/previewData.html", &d.T)
- return nil
- }
- /*
- *
- 设置ttf版本号
- */
- func (d *DataExport) FontSet(version string) {
- if public.ExConf.Font.Enabled {
- if version == "" {
- version = public.ExConf.Font.ConvertVersionDefault
- }
- b := redis.Put(public.ExConf.Font.RedisPool, public.ExConf.Font.RedisKey, version, -1)
- if b {
- d.RenderString("Congratulations , the font (version " + version + ") set successfully !")
- } else {
- d.RenderString("Sorry , there is an error , please view the logs !")
- }
- } else {
- d.RenderString("Sorry , permission denied , please contact the administrator !")
- }
- }
- func subUrl(list *[]map[string]interface{}, dataType string) *[]map[string]interface{} {
- for _, v := range *list {
- //加密截取url
- href := util.ObjToString(v["href"])
- url := util.ObjToString(v["url"])
- if len(url) > 40 { //截取剑鱼标讯地址
- v["url"] = url[:40] + "*****" + url[len(url)-10:]
- }
- re := regexp.MustCompile(`\/\/([^\/]+)`)
- // 使用正则表达式查找匹配的结果
- match := re.FindStringSubmatch(href)
- if len(match) > 1 {
- data := match[1]
- ds := strings.Split(data, ".")
- if len(ds) > 2 {
- href = strings.Replace(href, ds[1], "****", 1)
- }
- }
- if len(href) > 40 { //截取原文地址
- v["href"] = href[:40] + "*****" + href[len(href)-10:]
- } else if len(href) > 0 {
- v["href"] = href[:len(href)*8/10] + "*****"
- }
- }
- var result []map[string]interface{}
- bytes, marshalErr := json.Marshal(list)
- if marshalErr != nil {
- log.Println("数据导出字体混淆errMarshal", marshalErr)
- return list
- }
- //字体混淆
- hxb := public.GetFontConvertStr(public.ExConf.Font.ConvertVersionDefault, string(bytes), "pc")
- unmarshalErr := json.Unmarshal([]byte(hxb), &result)
- if unmarshalErr != nil {
- log.Println("数据导出字体混淆unmarshalErr", unmarshalErr)
- return list
- }
- return &result
- }
- // 发送邮件
- func (d *DataExport) SendMailVerify() {
- email := d.GetString("email")
- if isEmail(email) {
- var email_used = true
- sessVal := d.Session().GetMultiple()
- if email != util.ObjToString(sessVal["DataExportVerifyEmail"]) {
- d.DelSession("CreatEVerifyTime")
- // openid := util.ObjToString(d.GetSession("s_m_openid"))
- userId := util.ObjToString(sessVal["userId"])
- emails := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
- "user_mail": email,
- "user_id": userId,
- }, "user_mail", "")
- if emails != nil && util.ObjToString((*emails)["user_mail"]) != "" {
- email_used = false
- d.T["success"] = true
- d.T["errCode"] = 4
- d.T["errMsg"] = "此邮箱已被验证"
- d.SetSession("DataExportVerifyEmail_val", email)
- d.SetSession("EMVerifySucess", true)
- }
- }
- if email_used {
- lastSendDEVerify := util.Int64All(sessVal["CreatEVerifyTime"])
- timeSpaceing := lastSendDEVerify - time.Now().Unix() + 60*5
- incurKey := fmt.Sprintf("SendEmail_%s_%d", util.ObjToString(sessVal["userId"]), time.Now().Day())
- //log.Println(incurKey)
- if lastSendDEVerify == 0 || timeSpaceing < 0 {
- //每日限制10次
- times := util.IntAll(redis.Get("other", incurKey))
- if times < 10 {
- if times == 0 {
- redis.Put("other", incurKey, 1, 24*60*60)
- } else {
- redis.Incr("other", incurKey)
- }
- //生成随机数
- verifyStr := strings.ToUpper(util.GetComplexRandom(6, 3, 3))
- d.SetSession("EMVerifySucess", false)
- d.SetSession("DataExportVerifyEmail", email)
- d.SetSession("DataExportVerify", verifyStr)
- d.SetSession("CreatEVerifyTime", time.Now().Unix())
- log.Println("====================", verifyStr, "====================", sessVal["CreatEVerifyTime"], "====================")
- //发送邮箱验证码
- go public.SendMailIdentCode(email, verifyStr, config.GmailAuth)
- d.T["success"] = true
- } else {
- d.T["success"] = false
- d.T["errCode"] = 3
- d.T["time"] = timeSpaceing
- d.T["errMsg"] = "验证码发送次数已达到今日上限"
- }
- } else {
- d.T["success"] = false
- d.T["errCode"] = 2
- d.T["time"] = timeSpaceing
- d.T["errMsg"] = "已发送,5分钟后再尝试"
- }
- }
- } else {
- d.T["success"] = false
- d.T["errCode"] = 1
- d.T["errMsg"] = "邮箱格式不正确"
- }
- d.ServeJson(&d.T)
- }
- func isPhone(value string) bool {
- var phonePattern = regexp.MustCompile("^[1][3-9][0-9]{9}$")
- return phonePattern.MatchString(value)
- }
- // 验证手机号
- func (d *DataExport) CheckPhoneVerify() {
- phone := d.GetString("phone")
- verityResult := false
- if isPhone(phone) {
- verityResult = true
- d.SetSession("DataExportVerifyPhone", phone)
- }
- d.T["success"] = verityResult
- d.ServeJson(&d.T)
- }
- // 验证邮箱
- func (d *DataExport) CheckMailVerify() {
- email := d.GetString("email")
- emailVerity := d.GetString("emailVerity")
- DataExportEmail := d.GetSession("DataExportVerifyEmail")
- DataExportVerify := d.GetSession("DataExportVerify")
- verityResult := false
- if emailVerity != "" && emailVerity == DataExportVerify && email != "" && email == DataExportEmail {
- verityResult = true
- d.DelSession("DataExportVerify")
- d.DelSession("CreatEVerifyTime")
- d.SetSession("EMVerifySucess", true)
- d.SetSession("DataExportVerifyEmail_val", DataExportEmail)
- }
- d.T["success"] = verityResult
- d.ServeJson(&d.T)
- }
- func isEmail(value string) bool {
- var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
- return emailPattern.MatchString(value)
- }
- func (d *DataExport) Paysuccess() error {
- code := d.GetString("code")
- // openid, _ := d.GetSession("s_m_openid").(string)
- userId, _ := d.GetSession("userId").(string)
- data := map[string]interface{}{}
- if code != "" && userId != "" {
- data_ := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
- "order_code": code,
- "user_id": userId,
- "order_status": 1,
- }, "pay_way,user_mail,pay_time,pay_money,order_money", "")
- if data_ != nil {
- data = *data_
- if data["pay_money"] != nil {
- data["pay_money"] = util.Float64All(data["pay_money"]) / 100
- } else {
- data["pay_money"] = util.Float64All(data["order_money"]) / 100
- }
- if data["pay_way"] != nil {
- pay_way := util.ObjToString(data["pay_way"])
- if strings.Contains(pay_way, "wx") {
- pay_way = "微信"
- } else if strings.Contains(pay_way, "ali") {
- pay_way = "支付宝"
- }
- data["pay_way"] = pay_way
- }
- }
- }
- d.T["data"] = data
- d.T["order_code"] = code
- return d.Render("/pc/paysuccess.html")
- }
- func (d *DataExport) VipOrderDetail() {
- d.Render("/pc/vip_orderDetail.html")
- }
- func (d *DataExport) EntOrderDetail() {
- d.Render("/pc/entniche_orderDetail.html")
- }
- func (d *DataExport) Invoice(order_code string) error {
- userid := d.GetSession("userId").(string)
- d.T["order_code"] = order_code
- res := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
- "user_id": userid,
- "order_code": order_code,
- }, "user_mail,user_phone", "create_time desc")
- if *res != nil {
- d.T["mail"] = (*res)["user_mail"]
- d.T["phone"] = (*res)["user_phone"]
- }
- if public.Mysql.CountBySql("select count(1) as count from dataexport_order where user_id = ? and order_code = ? and order_status = ?", userid, order_code, 1) > 0 {
- return d.Render("/pc/invoice.html", &d.T)
- }
- return d.Render("/_error.html")
- }
- func (d *DataExport) Check_invoice(order_code string) error {
- userid := d.GetSession("userId").(string)
- d.T["order_code"] = order_code
- if public.Mysql.CountBySql("select count(1) as count from dataexport_order where user_id = ? and order_code = ? and order_status = ?", userid, order_code, 1) > 0 {
- return d.Render("/pc/check_invoice.html", &d.T)
- }
- 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")
- }
- func (d *DataExport) ValuationList(order_code string) error {
- userid := d.GetSession("userId").(string)
- d.T["order_code"] = order_code
- if public.Mysql.CountBySql("select count(1) as count from dataexport_order where user_id = ? and order_code = ?", userid, order_code) > 0 {
- return d.Render("/pc/billing_list.html")
- }
- return d.Render("/_error.html")
- }
- func (d *DataExport) SetDontPromptAgain() {
- status := d.GetString("status") //0 提示 1 不再提示
- userId := d.GetSession("mgoUserId").(string)
- boo := public.MQFW.UpdateById("user", userId, map[string]interface{}{
- "$set": map[string]interface{}{
- "i_export_promptAgain": status,
- },
- })
- d.ServeJson(map[string]interface{}{
- "error_code": 0,
- "error_msg": "",
- "success": boo,
- })
- return
- }
- func (d *DataExport) GetDontPromptAgain() {
- isPrompt := true
- userId := d.GetSession("mgoUserId").(string)
- user, ok := public.MQFW.FindById("user", userId, `{"i_export_promptAgain":1}`)
- if ok && user != nil && len(*user) > 0 {
- if util.IntAll((*user)["i_export_promptAgain"]) == 1 {
- isPrompt = false
- }
- }
- d.ServeJson(map[string]interface{}{
- "error_code": 0,
- "error_msg": "",
- "isPrompt": isPrompt,
- })
- return
- }
- //
- //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)
- //userId := "1212"
- if userId == "" {
- data := map[string]interface{}{
- "error_code": 1001,
- "myEntMenu": true,
- "entnicheMenu": true,
- }
- this.ServeJson(data)
- return
- }
- phone, _ := GetPhone(userId)
- //phone = "15136225931"
- myEntMenu := false
- entnicheMenu := false
- privatedata := false
- pcUsers := map[int]bool{}
- hideUsers := map[int]bool{}
- for _, v := range config.EntnichePcConf.EntnichePcUser {
- pcUsers[v] = true
- }
- for _, v := range config.EntnichePcConf.HideEntnicheMenu {
- hideUsers[v] = true
- }
- isNew := false
- if phone != "" {
- ent := public.Mysql.SelectBySql("select id,isNew,phone,createtime from entniche_info where phone=? and status=1 ", phone)
- if ent != nil && len(*ent) != 0 {
- for _, val := range *ent {
- if pcUsers[util.IntAll(val["id"])] {
- myEntMenu = true
- if hideUsers[util.IntAll(val["id"])] {
- entnicheMenu = false
- } else {
- if util.IntAll(val["isNew"]) == 1 {
- isNew = true
- }
- entnicheMenu = true
- }
- break
- }
- }
- }
- if !myEntMenu {
- user := public.Mysql.SelectBySql("select id,ent_id,power,export_power from entniche_user where phone=? ORDER BY power desc", phone)
- if user != nil && len(*user) > 0 {
- for _, v := range *user {
- if pcUsers[util.IntAll(v["ent_id"])] {
- ents := public.Mysql.SelectBySql("select status,id,createtime,isNew from entniche_info where id=? ", util.IntAll(v["ent_id"]))
- if ents != nil && len(*ents) != 0 {
- for _, vv := range *ents {
- if util.IntAll(vv["status"]) == 1 {
- myEntMenu = true
- }
- if util.IntAll(v["power"]) == 1 {
- if hideUsers[util.IntAll(vv["id"])] {
- entnicheMenu = false
- } else {
- if util.IntAll(vv["isNew"]) == 1 {
- isNew = true
- }
- entnicheMenu = true
- }
- }
- }
- }
- break
- }
- }
- }
- }
- userCount := public.Mysql.CountBySql("select count(1) from privatedata where phone=?", phone)
- if userCount > 0 {
- privatedata = true
- }
- }
- data := map[string]interface{}{
- "myEntMenu": true,
- "entnicheMenu": entnicheMenu,
- "isNew": isNew,
- "privatedata": privatedata,
- }
- 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": 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 := jyutil.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1}`)
- if u != nil {
- if s_phone, _ := (*u)["s_phone"].(string); s_phone != "" {
- return s_phone, "s_phone"
- } else if s_m_phone, _ := (*u)["s_m_phone"].(string); s_m_phone != "" {
- return s_m_phone, "s_m_phone"
- }
- }
- return "", ""
- }
- func (d *DataExport) MemberDetail() {
- d.Render("/pc/member_orderDetail.html")
- }
- func (d *DataExport) AiForecastPackDetail() {
- d.Render("/pc/aiPack_orderDetail.html")
- }
- func (d *DataExport) SubAccountDetail() {
- d.Render("/pc/subAccount_orderDetail.html")
- }
- func (d *DataExport) BidfileDetail() {
- d.Render("/order/pc/bidfile/bidfileDetail.html")
- }
- func (d *DataExport) IntegralDetail() {
- d.Render("/order/pc/integral/integralDetail.html")
- }
|