dataExport.go 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. package front
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "jy/src/jfw/config"
  7. "jy/src/jfw/jyutil"
  8. "log"
  9. "regexp"
  10. "strconv"
  11. "strings"
  12. "sync"
  13. "time"
  14. . "app.yhyue.com/moapp/jybase/date"
  15. "app.yhyue.com/moapp/jybase/encrypt"
  16. "app.yhyue.com/moapp/jypkg/common/src/qfw/util/dataexport"
  17. "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
  18. "app.yhyue.com/moapp/jypkg/public"
  19. util "app.yhyue.com/moapp/jybase/common"
  20. "app.yhyue.com/moapp/jybase/redis"
  21. "app.yhyue.com/moapp/jybase/go-xweb/xweb"
  22. )
  23. type DataExport struct {
  24. *xweb.Action
  25. toSieve xweb.Mapper `xweb:"/front/dataExport/toSieve"` //数据导出-条件筛选
  26. sieveData xweb.Mapper `xweb:"/front/dataExport/sieveData"` //筛选数据
  27. toOrderDetail xweb.Mapper `xweb:"/front/dataExport/toOrderDetail/(.*)"` //订单详情
  28. getOrderCode xweb.Mapper `xweb:"/front/dataExport/getOrderCode/(\\w+)"` //申请发票获取订单编号
  29. superSearchExport xweb.Mapper `xweb:"/front/dataExport/superSearchExport"` //数据导出-超级搜索
  30. toCreateOrderPage xweb.Mapper `xweb:"/front/dataExport/toCreateOrderPage/(.*)"` //数据导出-订单页面
  31. previewData xweb.Mapper `xweb:"/front/(.*)/previewData/(.*)"` //数据导出-数据预览
  32. sendMailVerify xweb.Mapper `xweb:"/front/dataExport/sendMailVerify"` //发送邮箱验证码
  33. checkMailVerify xweb.Mapper `xweb:"/front/dataExport/checkMailVerify"` //验证邮箱验证码
  34. paysuccess xweb.Mapper `xweb:"/front/dataExport/paysuccess"` //支付成功页面
  35. checkPhoneVerify xweb.Mapper `xweb:"/front/dataExport/checkPhoneVerify"` //验证手机号
  36. fontSet xweb.Mapper `xweb:"/front/dataExport/fontSet/(.*)"`
  37. setDontPromptAgain xweb.Mapper `xweb:"/front/dataExport/setDontPromptAgain"` //数据导出-超出2w条,不再提示
  38. getDontPromptAgain xweb.Mapper `xweb:"/front/dataExport/getDontPromptAgain"` //数据导出-超出2w条,不再提示
  39. cancelOrder xweb.Mapper `xweb:"/front/dataExport/cancelOrder"` //取消订单
  40. vipOrderDetail xweb.Mapper `xweb:"/front/vipOrder/vipOrderDetail"` //vip订单详情
  41. entOrderDetail xweb.Mapper `xweb:"/front/entniche/entnicheOrderDetail"` //商机管理订单详情
  42. invoice xweb.Mapper `xweb:"/front/order/invoice/(\\w+)"` //电子发票-开发票
  43. check_invoice xweb.Mapper `xweb:"/front/order/check_invoice/(\\w+)"` //电子发票-开发票-流程
  44. invoicetimeOut xweb.Mapper `xweb:"/front/order/invoicetimeOut"` //申请超时
  45. valuationList xweb.Mapper `xweb:"/front/order/valuationList/(\\w+)"` //计费清单
  46. memberDetail xweb.Mapper `xweb:"/front/member/memberDetail"` //大会员订单详情
  47. aiForecastPackDetail xweb.Mapper `xweb:"/front/aiForecastPack/aiForecastPackDetail"` //AI中标预测包订单详情
  48. subAccountDetail xweb.Mapper `xweb:"/front/subAccount/subAccountDetail"` //子账号订单详情
  49. bidfileDetail xweb.Mapper `xweb:"/front/bidfile/bidfileDetail"` //招标文件解读详情
  50. integralDetail xweb.Mapper `xweb:"/front/integral/integralDetail"` //剑鱼币订单详情
  51. getPcEntAuth xweb.Mapper `xweb:"/front/entExportAuth/getAuth"` //获取企业权限
  52. //gettest xweb.Mapper `xweb:"/front/order/gettest"` //模拟
  53. //entDataExport xweb.Mapper `xweb:"/front/entDataExport/(.*)"` //企业数据导出
  54. //isEntExportSuccess xweb.Mapper `xweb:"/front/entExportAuth/isEntExportSuccess"` //企业导出是否成功
  55. }
  56. var order_pageSize = 10
  57. type Filters struct {
  58. FilterId string
  59. }
  60. func init() {
  61. xweb.AddAction(&DataExport{})
  62. }
  63. var (
  64. layout_date = "2006.01.02"
  65. orderStatus_unPaid = "0" //订单状态-待支付
  66. orderStatus_paid = "1" //订单状态-已完成
  67. orderStatus_deleted = "-1" //订单状态-已删除
  68. orderStatus_cancel = "-2" //订单状态-已取消
  69. tableName_order = "dataexport_order" //订单表
  70. SEX = encrypt.SimpleEncrypt{Key: "topJYBX2019"}
  71. exportLock = sync.Mutex{}
  72. exportLockMap = map[int]sync.Mutex{}
  73. )
  74. func (d *DataExport) ToSieve() error {
  75. industrylist, sortArray = jy.Getindustrys(util.ObjToString(config.Sysconfig["industry"]), public.MQFW)
  76. d.T["industrylist"] = industrylist
  77. d.T["sortArray"] = sortArray
  78. d.T["logid"] = config.Seoconfig["dataexport"].(string)
  79. d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
  80. d.Render("/pc/dataExport_sieve.html", &d.T)
  81. return nil
  82. }
  83. func (d *DataExport) SieveData() {
  84. dataType := d.GetString("dataType")
  85. publishtime := d.GetString("publishtime")
  86. area := d.GetString("area")
  87. city := d.GetString("city")
  88. region := d.GetString("region")
  89. industry := d.GetString("industry")
  90. keyword := d.GetString("keyword")
  91. minPrice := d.GetString("minprice")
  92. maxPrice := d.GetString("maxprice")
  93. subType := d.GetString("subtype")
  94. buyer := d.GetString("buyer")
  95. buyerclass := d.GetString("buyerclass")
  96. winner := d.GetString("winner")
  97. selectType := d.GetString("selectType")
  98. var areaArr []string
  99. var cityArr []string
  100. var regionArr []string
  101. var industryArr []string
  102. var subTypeArr []string
  103. var buyerArr []string
  104. var buyerclassArr []string
  105. var winnerArr []string
  106. var keywordList []dataexport.KeyWord
  107. log.Println("price", minPrice, maxPrice)
  108. if publishtime != "" {
  109. log.Println("publishtime", publishtime)
  110. }
  111. if area != "" {
  112. areaArr = strings.Split(area, ",")
  113. log.Println("areaArr", areaArr)
  114. }
  115. if city != "" {
  116. cityArr = strings.Split(city, ",")
  117. log.Println("cityArr", cityArr)
  118. }
  119. if region != "" {
  120. regionArr = strings.Split(region, ",")
  121. log.Println("regionArr", regionArr)
  122. }
  123. if industry != "" {
  124. industryArr = strings.Split(industry, ",")
  125. log.Println("industryArr", industryArr)
  126. }
  127. if subType != "" {
  128. subTypeArr = strings.Split(subType, ",")
  129. log.Println("subTypeArr", subTypeArr)
  130. }
  131. log.Println("keywordParam", keyword)
  132. if keyword != "" {
  133. err := json.Unmarshal([]byte(keyword), &keywordList)
  134. if err != nil {
  135. log.Println("keyword param 反序列化异常,查看前后台字段是否对应")
  136. } else {
  137. log.Println("keywordList", len(keywordList), keywordList)
  138. }
  139. }
  140. log.Println("selectType", selectType)
  141. if buyer != "" {
  142. buyerArr = strings.Split(buyer, ",")
  143. log.Println("buyerArr", buyerArr)
  144. }
  145. if buyerclass != "" {
  146. buyerclassArr = strings.Split(buyerclass, ",")
  147. log.Println("buyerclassArr", buyerclassArr)
  148. }
  149. if winner != "" {
  150. winnerArr = strings.Split(winner, ",")
  151. log.Println("winnerArr", winnerArr)
  152. }
  153. var isTitle int
  154. if selectType != "" {
  155. if strings.Count(selectType, "title") > 1 {
  156. isTitle = 3 //包含标题及正文
  157. } else if strings.Contains(selectType, "detail") {
  158. isTitle = 2 //只包含正文
  159. } else if strings.Contains(selectType, "title") {
  160. isTitle = 1 //只包含标题
  161. }
  162. //去重 如果选取了标题及正文 引起的有2个title问题
  163. if strings.Count(selectType, "title") > 1 {
  164. var detail []string
  165. for _, v := range strings.Split(selectType, ",") {
  166. if v == "title" {
  167. continue
  168. }
  169. detail = append(detail, v)
  170. }
  171. //维持原逻辑 正文表示标题及正文
  172. selectType = strings.Replace(strings.Join(detail, ","), "detail", "title,detail", -1)
  173. }
  174. }
  175. if len(keywordList) > util.IntAllDef(config.Sysconfig["keywordRestrict"], 100) {
  176. keywordList = keywordList[:util.IntAllDef(config.Sysconfig["keywordRestrict"], 100)]
  177. }
  178. if len(buyerArr) > util.IntAllDef(config.Sysconfig["buyerRestrict"], 100) {
  179. buyerArr = buyerArr[:util.IntAllDef(config.Sysconfig["buyerRestrict"], 100)]
  180. }
  181. if len(winnerArr) > util.IntAllDef(config.Sysconfig["winnerRestrict"], 100) {
  182. winnerArr = winnerArr[:util.IntAllDef(config.Sysconfig["winnerRestrict"], 100)]
  183. }
  184. sieveCondition := map[string]interface{}{
  185. "publishtime": publishtime,
  186. "area": areaArr,
  187. "city": cityArr,
  188. "region": regionArr,
  189. "industry": industryArr,
  190. "keywords": keywordList,
  191. "selectType": selectType,
  192. "minprice": minPrice,
  193. "maxprice": maxPrice,
  194. "subtype": subType,
  195. "buyer": buyerArr,
  196. "buyerclass": buyerclassArr,
  197. "isTitle": isTitle,
  198. "winner": winnerArr,
  199. "comeintime": time.Now().Unix(),
  200. "comeinfrom": "exportPage",
  201. }
  202. if d.GetSession("s_m_openid") != nil {
  203. sieveCondition["s_openid"] = d.GetSession("s_m_openid").(string)
  204. }
  205. if d.GetSession("userId") != nil {
  206. sieveCondition["s_userid"] = d.GetSession("userId").(string)
  207. }
  208. _id := mongodb.Save(dataexport.ExportTable, sieveCondition)
  209. _res := map[string]interface{}{
  210. "error_code": 0,
  211. "error_msg": "",
  212. }
  213. if _id != "" {
  214. msgCount := dataexport.GetDataExportSearchCountByScdId(public.MQFW, public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, _id)
  215. //从500条数据中筛选字段最全五条
  216. scd := dataexport.GetSqlObjFromId(public.MQFW, _id)
  217. kws := scd.Keyword
  218. res, err := dataexport.GetDataExportSearchResult(public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, scd, dataType, -1)
  219. if res == nil || err != nil {
  220. _res["error_msg"] = "无数据"
  221. d.ServeJson(_res)
  222. return
  223. }
  224. //格式化字段
  225. res_screen := dataexport.ScreenData(res, dataType, 20, kws)
  226. var EntArr = []string{}
  227. if dataType == "2" {
  228. for _, v := range res_screen {
  229. //高级字段查询且winner不为空
  230. if v["s_winner"] != nil && v["s_winner"] != "" {
  231. EntArr = append(EntArr, v["s_winner"].(string))
  232. }
  233. }
  234. }
  235. list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
  236. /*if msgCount > 20000 {
  237. msgCount = 20000
  238. }*/
  239. _res["data"] = map[string]interface{}{
  240. "list": subUrl(list, dataType),
  241. "_id": encrypt.SE.Encode2Hex(_id),
  242. "total": msgCount,
  243. }
  244. d.ServeJson(_res)
  245. //_res["dataType"] = dataType
  246. //d.T["success"] = true
  247. //d.T["redirectUrl"] = "/front/dataExport/toCreateOrderPage/" + util.se.Encode2Hex(_id)
  248. } else {
  249. _res["error_code"] = -1
  250. _res["error_msg"] = "保存筛选条件失败"
  251. d.ServeJson(_res)
  252. }
  253. }
  254. /*
  255. *
  256. 根据 id+openid 取消订单
  257. */
  258. func (d *DataExport) CancelOrder() error {
  259. if userId := d.GetSession("userId"); userId != nil {
  260. // if openid := d.GetSession("s_m_openid"); openid != nil {
  261. queryMap := map[string]interface{}{
  262. "id": d.GetString("id"),
  263. "user_id": userId.(string),
  264. }
  265. boo := public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
  266. //取消订单
  267. d.ServeJson(map[string]interface{}{"success": boo})
  268. }
  269. return nil
  270. }
  271. /*
  272. *
  273. 根据 订单编号+userId 查询
  274. */
  275. func (d *DataExport) ToOrderDetail(orderCode string) error {
  276. myUserId := ""
  277. if userId := d.GetSession("userId"); userId != nil {
  278. // if openid := d.GetSession("s_m_openid"); openid != nil {
  279. myUserId = userId.(string)
  280. } else {
  281. return nil
  282. }
  283. orderDetail := map[string]interface{}{}
  284. filter := dataexport.SieveCondition{}
  285. queryMap := map[string]interface{}{
  286. "order_code": orderCode,
  287. "user_id": myUserId,
  288. }
  289. if orderCode != "" {
  290. orderDetail = *public.Mysql.FindOne(tableName_order, queryMap, "", "")
  291. }
  292. // log.Println("ToOrderDetail", orderCode, orderDetail)
  293. if orderDetail["pay_money"] != nil {
  294. orderDetail["pay_money"] = float64(orderDetail["pay_money"].(int64))
  295. }
  296. if orderDetail["order_money"] != nil {
  297. orderDetail["order_money"] = float64(orderDetail["order_money"].(int64))
  298. }
  299. if orderDetail["discount_price"] != nil {
  300. orderDetail["discount_price"] = float64(orderDetail["discount_price"].(int64))
  301. }
  302. //卡卷id加密
  303. if orderDetail["d_relation_id"] != "" {
  304. orderDetail["userLotteryId"] = encrypt.SE.Encode2Hex(util.ObjToString(orderDetail["d_relation_id"]))
  305. }
  306. delete(orderDetail, "d_relation_id")
  307. if orderDetail["filter"] != nil {
  308. err := json.Unmarshal([]byte(orderDetail["filter"].(string)), &filter)
  309. if err == nil {
  310. publishtime := filter.PublishTime
  311. if publishtime != "" {
  312. timeArr := strings.Split(publishtime, "_")
  313. if len(timeArr) == 2 {
  314. start, err := strconv.ParseInt(timeArr[0], 10, 64)
  315. end, erro := strconv.ParseInt(timeArr[1], 10, 64)
  316. if err == nil && erro == nil {
  317. filter.PublishTime = FormatDateByInt64(&start, layout_date) + "-" + FormatDateByInt64(&end, layout_date)
  318. } else if err == nil && erro != nil {
  319. filter.PublishTime = FormatDateByInt64(&start, layout_date) + "-"
  320. } else if err != nil && erro == nil {
  321. filter.PublishTime = "-" + FormatDateByInt64(&end, layout_date)
  322. }
  323. }
  324. }
  325. filter.MinPrice = public.GetPriceDes_SieveCondition(filter.MinPrice, filter.MaxPrice)
  326. orderDetail["filter"] = filter
  327. } else {
  328. log.Println("筛选条件-关键词-结构体反序列化-错误", err)
  329. }
  330. }
  331. if orderDetail["applybill_type"] != nil && orderDetail["applybill_type"].(int64) == 0 {
  332. orderDetail["applybill_type"] = "个人"
  333. } else if orderDetail["applybill_type"] != nil && orderDetail["applybill_type"].(int64) == 1 {
  334. orderDetail["applybill_type"] = "单位"
  335. } else {
  336. orderDetail["applybill_type"] = "-"
  337. }
  338. orderStatus := util.IntAll((orderDetail)["order_status"])
  339. if orderStatus == 1 {
  340. orderDetail["transaction_id"] = func() string {
  341. table := ""
  342. payway := util.ObjToString(orderDetail["pay_way"])
  343. if strings.Contains(payway, "wx") {
  344. payway = "微信"
  345. table = "weixin_pay"
  346. } else if strings.Contains(payway, "ali") {
  347. payway = "支付宝"
  348. table = "ali_pay"
  349. } else {
  350. return ""
  351. }
  352. orderDetail["pay_way"] = payway
  353. wxPayMap := map[string]interface{}{}
  354. wxPayMap["out_trade_no"] = orderDetail["out_trade_no"]
  355. payDetail := public.Mysql.FindOne(table, wxPayMap, "", "")
  356. if payDetail == nil || len(*payDetail) == 0 {
  357. return ""
  358. }
  359. return util.ObjToString((*payDetail)["transaction_id"])
  360. }()
  361. }
  362. d.T["o"] = orderDetail
  363. d.T["logid"] = config.Seoconfig["dataexport"].(string)
  364. return d.Render("/pc/orderDetail.html", &d.T)
  365. }
  366. // ------------------------------申请发票跳转页面-----------------------------
  367. func (d *DataExport) GetOrderCode(order_code string) error {
  368. var status, order_status int64
  369. queryMap := map[string]interface{}{
  370. "order_code": order_code,
  371. }
  372. oDate := public.Mysql.FindOne(tableName_order, queryMap, "", "")
  373. status = (*oDate)["applybill_status"].(int64)
  374. order_status = (*oDate)["order_status"].(int64)
  375. d.T["order_code"] = order_code
  376. d.T["logid"] = config.Seoconfig["dataexport"].(string)
  377. //是否申请发票 支付状态
  378. if status == 1 || order_status == 0 {
  379. d.Redirect("/front/dataExport/toOrderDetail/" + order_code)
  380. } else {
  381. d.Render("/pc/dataExport_invoice.html", &d.T)
  382. }
  383. return nil
  384. }
  385. // ---------------------------生成订单预览----------------------------------
  386. func (d *DataExport) SuperSearchExport() error {
  387. openid := util.ObjToString(d.GetSession("s_m_openid"))
  388. userId := util.ObjToString(d.GetSession("userId"))
  389. searchGroup, _ := d.GetInteger("searchGroup")
  390. searchMode, _ := d.GetInteger("searchMode")
  391. wordsMode, _ := d.GetInteger("wordsMode")
  392. if userId == "" {
  393. return errors.New("未登录")
  394. }
  395. //接收超级搜索页面参数
  396. reqData := public.BidSearchExport{
  397. Keywords: d.GetString("keywords"), //搜索词
  398. Publishtime: d.GetString("publishtime"), //发布时间
  399. Area: d.GetString("area"), //地区
  400. Subtype: d.GetString("subtype"), //信息类型
  401. Minprice: d.GetString("minprice"), //最低价格
  402. Maxprice: d.GetString("maxprice"), //最高价格
  403. Industry: strings.TrimSpace(d.GetString("industry")), //选中的行业
  404. SelectType: d.GetString("selectType"), //标题 or 全文
  405. Buyerclass: d.GetString("buyerclass"), //采购单位行业
  406. Hasbuyertel: d.GetString("buyertel"), //是否有采购电话
  407. Haswinnertel: d.GetString("winnertel"), //是否有中标电话
  408. SelectIds: strings.TrimSpace(d.GetString("selectIds")), //选择信息id
  409. Notkey: d.GetString("notkey"), //排除词
  410. FileExists: d.GetString("fileExists"), //是否有附件
  411. City: d.GetString("city"), //城市
  412. BidField: d.GetString("bid_field"), // 领域数据类型 0101- 医疗行业
  413. SearchGroup: searchGroup, //搜索分组:默认0:全部;1:招标采购公告;2:超前项目
  414. SearchMode: searchMode, //搜索模式:0:精准搜索;1:模糊搜索
  415. WordsMode: wordsMode, //搜索关键词模式;默认0:包含所有,1:包含任意
  416. AdditionalWords: d.GetString("additionalWords"), //关键词:附加关键词(副:五组,每组最多15个字符)
  417. }
  418. selectType := strings.Join(jy.GetVipState(d.Session(), *config.Middleground, userId).GetQueryItems(d.GetString("selectType"), util.Int64All(config.Sysconfig["bidSearchOldUserLimit"])), ",")
  419. //数据回显
  420. d.SetSession("Echo_timeslot", d.GetString("timeslot"))
  421. d.SetSession("Echo_keywords", reqData.Keywords)
  422. d.SetSession("Echo_publishtime", reqData.Publishtime)
  423. d.SetSession("Echo_area", reqData.Area)
  424. d.SetSession("Echo_subtype", reqData.Subtype)
  425. d.SetSession("Echo_minprice", reqData.Minprice)
  426. d.SetSession("Echo_maxprice", reqData.Maxprice)
  427. d.SetSession("Echo_industry", reqData.Industry)
  428. d.SetSession("Echo_selectType", reqData.SelectType)
  429. d.SetSession("Echo_buyerclass", reqData.Buyerclass)
  430. d.SetSession("Echo_hasBuyertel", reqData.Hasbuyertel)
  431. d.SetSession("Echo_hasWinnertel", reqData.Haswinnertel)
  432. d.SetSession("Echo_notkey", reqData.Notkey)
  433. d.SetSession("Echo_fileExists", reqData.FileExists)
  434. d.SetSession("Echo_city", reqData.City)
  435. d.SetSession("Echo_bid_field", reqData.BidField) // 领域类型 0101-医疗行业
  436. d.SetSession("Echo_searchGroup", reqData.SearchGroup)
  437. d.SetSession("Echo_searchMode", reqData.SearchMode)
  438. d.SetSession("Echo_wordsMode", reqData.WordsMode)
  439. d.SetSession("Echo_additionalWords", reqData.AdditionalWords)
  440. saveData := reqData.PassBidSearchExport(config.Sysconfig)
  441. saveData["selectType"] = selectType
  442. saveData["s_openid"] = openid
  443. saveData["s_userid"] = userId
  444. saveData["comeinfrom"] = "supersearchPage"
  445. //是否开启 正文 标题同时搜索只搜正文的开关
  446. saveData["searchTypeSwitch"], _ = config.Sysconfig["searchTypeSwitch"].(bool)
  447. region := util.If(reqData.Area == "全国", "", reqData.Area).(string)
  448. if region != "" && reqData.City != "" {
  449. region += "," + reqData.City
  450. } else {
  451. region = reqData.City
  452. }
  453. saveData["region"] = util.If(region != "", strings.Split(region, ","), []string{}).([]string)
  454. //存入数据库
  455. _id := mongodb.Save(dataexport.ExportTable, saveData)
  456. log.Println(_id, "saveData:", saveData)
  457. return d.Redirect("/front/dataExport/toCreateOrderPage/" + encrypt.SE.Encode2Hex(_id))
  458. }
  459. func (d *DataExport) ToCreateOrderPage(_id string) error {
  460. id := encrypt.SE.Decode4Hex(_id)
  461. openid := util.ObjToString(d.GetSession("s_m_openid"))
  462. userId := util.ObjToString(d.GetSession("userId"))
  463. if userId == "" {
  464. return errors.New("未登录")
  465. }
  466. // }
  467. // 企业数据导出结束
  468. //是否是从结构化数据推广页过来的
  469. if d.GetString("from") == "structed" {
  470. d.SetSession("Structed", true)
  471. } else {
  472. d.DelSession("Structed")
  473. }
  474. msgCount := dataexport.GetDataExportSearchCountByScdId(public.MQFW, public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, id)
  475. if msgCount > public.ExConf.MsgMaxCount || msgCount == -1 {
  476. msgCount = public.ExConf.MsgMaxCount
  477. }
  478. d.T["logid"] = config.Seoconfig["dataexport"].(string)
  479. if msgCount < 1 {
  480. d.Render("/pc/dataExport_noDataErr.html", &d.T)
  481. return nil
  482. }
  483. //订单数据存入session中
  484. d.SetSession("dataexport_waitcreateorder", map[string]interface{}{
  485. "id": id, //用户的筛选条件mongodb中的id string
  486. "data_count": msgCount, //匹配到的数据总数 int
  487. })
  488. resEmail, _ := d.GetSession("DataExportVerifyEmail_val").(string)
  489. resPhone, _ := d.GetSession("DataExportVerifyPhone_val").(string)
  490. if resEmail != "" {
  491. lastSendDEVerify := util.Int64All(d.GetSession("CreatEVerifyTime"))
  492. timeSpaceing := lastSendDEVerify - time.Now().Unix() + 60*5
  493. d.T["email"] = resEmail
  494. d.T["timeSpaceing"] = timeSpaceing
  495. }
  496. if resPhone != "" {
  497. d.T["phone"] = resPhone
  498. }
  499. if resEmail == "" || resPhone == "" {
  500. lastEmail, lastPhone := "", ""
  501. if lastPhone, lastEmail = dataexport.GetLastExportPhoneAndMail(public.Mysql, userId, util.ObjToString(d.GetSession("entUserId"))); lastPhone == "" || lastEmail == "" {
  502. userData := jyutil.Compatible.Select(userId, `{"s_myemail":1,"s_phone":1,"s_m_phone":1}`)
  503. if userData != nil && len(*userData) > 0 {
  504. if lastEmail == "" {
  505. lastEmail, _ = (*userData)["s_myemail"].(string)
  506. }
  507. if lastPhone == "" {
  508. lastPhone, _ = util.If((*userData)["s_phone"] != nil, (*userData)["s_phone"], (*userData)["s_m_phone"]).(string)
  509. }
  510. }
  511. }
  512. if resEmail == "" && lastEmail != "" {
  513. d.T["email"] = lastEmail
  514. d.SetSession("EMVerifySucess", true)
  515. d.SetSession("DataExportVerifyEmail_val", lastEmail)
  516. }
  517. if resPhone == "" {
  518. setPhone := lastPhone
  519. if isPhone(openid) { //剑鱼助手手机号登录
  520. setPhone = openid
  521. }
  522. if setPhone != "" {
  523. d.SetSession("DataExportVerifyPhone_val", lastPhone)
  524. }
  525. d.T["phone"] = lastPhone
  526. }
  527. }
  528. d.T["_id"] = _id
  529. d.T["msgCount"] = msgCount
  530. incurKey := fmt.Sprintf("PreviewData_%s_%d", d.GetSession("userId"), time.Now().Day())
  531. d.T["PreviewData"] = util.IntAll(redis.Get("other", incurKey))
  532. d.Render("/pc/createOrderPage.html", &d.T)
  533. return nil
  534. }
  535. func (d *DataExport) PreviewData(source, _id string) error {
  536. if !strings.Contains(source, "app") {
  537. userId := util.ObjToString(d.GetSession("userId"))
  538. // openid := util.ObjToString(d.GetSession("s_m_openid"))
  539. if userId == "" {
  540. return errors.New("未登录")
  541. }
  542. //数据预览每天限制50次
  543. incurKey := fmt.Sprintf("PreviewData_%s_%d", d.GetSession("userId"), time.Now().Day())
  544. times := util.IntAll(redis.Get("other", incurKey))
  545. if times >= 50 {
  546. return errors.New("超出预览次数")
  547. }
  548. if times == 0 {
  549. redis.Put("other", incurKey, 1, 24*60*60)
  550. } else {
  551. redis.Incr("other", incurKey)
  552. }
  553. }
  554. _id = encrypt.SE.Decode4Hex(_id)
  555. dataType := d.GetString("dataType")
  556. //从500条数据中筛选字段最全五条
  557. scd := dataexport.GetSqlObjFromId(public.MQFW, _id)
  558. kws := scd.Keyword
  559. res, err := dataexport.GetDataExportSearchResult(public.Mgo_Bidding, public.DbConf.Mongodb.Bidding.DbName, public.DbConf.Elasticsearch.Main.Address, scd, dataType, -1)
  560. if res == nil || err != nil {
  561. log.Println("PreviewData查询出错", res)
  562. return d.Render("/pc/dataExport_noDataErr.html", &d.T)
  563. }
  564. //格式化字段
  565. res_screen := dataexport.ScreenData(res, dataType, 20, kws)
  566. list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
  567. d.T["data"] = subUrl(list, dataType)
  568. d.T["dataType"] = dataType
  569. d.T["ttf"] = public.GetFontVersion() + "_" + public.PC
  570. d.Render("/pc/previewData.html", &d.T)
  571. return nil
  572. }
  573. /*
  574. *
  575. 设置ttf版本号
  576. */
  577. func (d *DataExport) FontSet(version string) {
  578. if public.ExConf.Font.Enabled {
  579. if version == "" {
  580. version = public.ExConf.Font.ConvertVersionDefault
  581. }
  582. b := redis.Put(public.ExConf.Font.RedisPool, public.ExConf.Font.RedisKey, version, -1)
  583. if b {
  584. d.RenderString("Congratulations , the font (version " + version + ") set successfully !")
  585. } else {
  586. d.RenderString("Sorry , there is an error , please view the logs !")
  587. }
  588. } else {
  589. d.RenderString("Sorry , permission denied , please contact the administrator !")
  590. }
  591. }
  592. func subUrl(list *[]map[string]interface{}, dataType string) *[]map[string]interface{} {
  593. for _, v := range *list {
  594. //加密截取url
  595. href := util.ObjToString(v["href"])
  596. url := util.ObjToString(v["url"])
  597. if len(url) > 40 { //截取剑鱼标讯地址
  598. v["url"] = url[:40] + "*****" + url[len(url)-10:]
  599. }
  600. if len(href) > 40 { //截取原文地址
  601. v["href"] = href[:40] + "*****" + href[len(href)-10:]
  602. } else if len(href) > 0 {
  603. v["href"] = href[:len(href)*8/10] + "*****"
  604. }
  605. }
  606. var result []map[string]interface{}
  607. bytes, marshalErr := json.Marshal(list)
  608. if marshalErr != nil {
  609. log.Println("数据导出字体混淆errMarshal", marshalErr)
  610. return list
  611. }
  612. //字体混淆
  613. hxb := public.GetFontConvertStr(public.ExConf.Font.ConvertVersionDefault, string(bytes), "pc")
  614. unmarshalErr := json.Unmarshal([]byte(hxb), &result)
  615. if unmarshalErr != nil {
  616. log.Println("数据导出字体混淆unmarshalErr", unmarshalErr)
  617. return list
  618. }
  619. return &result
  620. }
  621. // 发送邮件
  622. func (d *DataExport) SendMailVerify() {
  623. email := d.GetString("email")
  624. if isEmail(email) {
  625. var email_used = true
  626. if email != d.GetSession("DataExportVerifyEmail") {
  627. d.DelSession("CreatEVerifyTime")
  628. // openid := util.ObjToString(d.GetSession("s_m_openid"))
  629. userId := util.ObjToString(d.GetSession("userId"))
  630. emails := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
  631. "user_mail": email,
  632. "user_id": userId,
  633. }, "user_mail", "")
  634. if emails != nil && util.ObjToString((*emails)["user_mail"]) != "" {
  635. email_used = false
  636. d.T["success"] = true
  637. d.T["errCode"] = 4
  638. d.T["errMsg"] = "此邮箱已被验证"
  639. d.SetSession("DataExportVerifyEmail_val", email)
  640. d.SetSession("EMVerifySucess", true)
  641. }
  642. }
  643. if email_used {
  644. lastSendDEVerify := util.Int64All(d.GetSession("CreatEVerifyTime"))
  645. timeSpaceing := lastSendDEVerify - time.Now().Unix() + 60*5
  646. incurKey := fmt.Sprintf("SendEmail_%s_%d", d.GetSession("userId"), time.Now().Day())
  647. //log.Println(incurKey)
  648. if lastSendDEVerify == 0 || timeSpaceing < 0 {
  649. //每日限制10次
  650. times := util.IntAll(redis.Get("other", incurKey))
  651. if times < 10 {
  652. if times == 0 {
  653. redis.Put("other", incurKey, 1, 24*60*60)
  654. } else {
  655. redis.Incr("other", incurKey)
  656. }
  657. //生成随机数
  658. verifyStr := strings.ToUpper(util.GetComplexRandom(6, 3, 3))
  659. d.SetSession("EMVerifySucess", false)
  660. d.SetSession("DataExportVerifyEmail", email)
  661. d.SetSession("DataExportVerify", verifyStr)
  662. d.SetSession("CreatEVerifyTime", time.Now().Unix())
  663. log.Println("====================", verifyStr, "====================", d.GetSession("CreatEVerifyTime"), "====================")
  664. //发送邮箱验证码
  665. go public.SendMailIdentCode(email, verifyStr, config.GmailAuth)
  666. d.T["success"] = true
  667. } else {
  668. d.T["success"] = false
  669. d.T["errCode"] = 3
  670. d.T["time"] = timeSpaceing
  671. d.T["errMsg"] = "验证码发送次数已达到今日上限"
  672. }
  673. } else {
  674. d.T["success"] = false
  675. d.T["errCode"] = 2
  676. d.T["time"] = timeSpaceing
  677. d.T["errMsg"] = "已发送,5分钟后再尝试"
  678. }
  679. }
  680. } else {
  681. d.T["success"] = false
  682. d.T["errCode"] = 1
  683. d.T["errMsg"] = "邮箱格式不正确"
  684. }
  685. d.ServeJson(&d.T)
  686. }
  687. func isPhone(value string) bool {
  688. var phonePattern = regexp.MustCompile("^[1][3-9][0-9]{9}$")
  689. return phonePattern.MatchString(value)
  690. }
  691. // 验证手机号
  692. func (d *DataExport) CheckPhoneVerify() {
  693. phone := d.GetString("phone")
  694. verityResult := false
  695. if isPhone(phone) {
  696. verityResult = true
  697. d.SetSession("DataExportVerifyPhone", phone)
  698. }
  699. d.T["success"] = verityResult
  700. d.ServeJson(&d.T)
  701. }
  702. // 验证邮箱
  703. func (d *DataExport) CheckMailVerify() {
  704. email := d.GetString("email")
  705. emailVerity := d.GetString("emailVerity")
  706. DataExportEmail := d.GetSession("DataExportVerifyEmail")
  707. DataExportVerify := d.GetSession("DataExportVerify")
  708. verityResult := false
  709. if emailVerity != "" && emailVerity == DataExportVerify && email != "" && email == DataExportEmail {
  710. verityResult = true
  711. d.DelSession("DataExportVerify")
  712. d.DelSession("CreatEVerifyTime")
  713. d.SetSession("EMVerifySucess", true)
  714. d.SetSession("DataExportVerifyEmail_val", DataExportEmail)
  715. }
  716. d.T["success"] = verityResult
  717. d.ServeJson(&d.T)
  718. }
  719. func isEmail(value string) bool {
  720. 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})(\\]?)$")
  721. return emailPattern.MatchString(value)
  722. }
  723. func (d *DataExport) Paysuccess() error {
  724. code := d.GetString("code")
  725. // openid, _ := d.GetSession("s_m_openid").(string)
  726. userId, _ := d.GetSession("userId").(string)
  727. data := map[string]interface{}{}
  728. if code != "" && userId != "" {
  729. data_ := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
  730. "order_code": code,
  731. "user_id": userId,
  732. "order_status": 1,
  733. }, "pay_way,user_mail,pay_time,pay_money,order_money", "")
  734. if data_ != nil {
  735. data = *data_
  736. if data["pay_money"] != nil {
  737. data["pay_money"] = util.Float64All(data["pay_money"]) / 100
  738. } else {
  739. data["pay_money"] = util.Float64All(data["order_money"]) / 100
  740. }
  741. if data["pay_way"] != nil {
  742. pay_way := util.ObjToString(data["pay_way"])
  743. if strings.Contains(pay_way, "wx") {
  744. pay_way = "微信"
  745. } else if strings.Contains(pay_way, "ali") {
  746. pay_way = "支付宝"
  747. }
  748. data["pay_way"] = pay_way
  749. }
  750. }
  751. }
  752. d.T["data"] = data
  753. d.T["order_code"] = code
  754. return d.Render("/pc/paysuccess.html")
  755. }
  756. func (d *DataExport) VipOrderDetail() {
  757. d.Render("/pc/vip_orderDetail.html")
  758. }
  759. func (d *DataExport) EntOrderDetail() {
  760. d.Render("/pc/entniche_orderDetail.html")
  761. }
  762. func (d *DataExport) Invoice(order_code string) error {
  763. userid := d.GetSession("userId").(string)
  764. d.T["order_code"] = order_code
  765. res := public.Mysql.FindOne("dataexport_order", map[string]interface{}{
  766. "user_id": userid,
  767. "order_code": order_code,
  768. }, "user_mail,user_phone", "create_time desc")
  769. if *res != nil {
  770. d.T["mail"] = (*res)["user_mail"]
  771. d.T["phone"] = (*res)["user_phone"]
  772. }
  773. 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 {
  774. return d.Render("/pc/invoice.html", &d.T)
  775. }
  776. return d.Render("/_error.html")
  777. }
  778. func (d *DataExport) Check_invoice(order_code string) error {
  779. userid := d.GetSession("userId").(string)
  780. d.T["order_code"] = order_code
  781. 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 {
  782. return d.Render("/pc/check_invoice.html", &d.T)
  783. }
  784. return d.Render("/_error.html")
  785. }
  786. //func (d *DataExport) Gettest() {
  787. // order_code := d.GetString("order_code")
  788. // info := public.Mysql.FindOne("invoice", map[string]interface{}{"order_code": order_code}, "", "")
  789. // d.ServeJson(map[string]interface{}{
  790. // "data": info,
  791. // })
  792. // return
  793. //}
  794. func (d *DataExport) InvoicetimeOut() {
  795. d.Render("/pc/invoice_error.html")
  796. }
  797. func (d *DataExport) ValuationList(order_code string) error {
  798. userid := d.GetSession("userId").(string)
  799. d.T["order_code"] = order_code
  800. if public.Mysql.CountBySql("select count(1) as count from dataexport_order where user_id = ? and order_code = ?", userid, order_code) > 0 {
  801. return d.Render("/pc/billing_list.html")
  802. }
  803. return d.Render("/_error.html")
  804. }
  805. func (d *DataExport) SetDontPromptAgain() {
  806. status := d.GetString("status") //0 提示 1 不再提示
  807. userId := d.GetSession("mgoUserId").(string)
  808. boo := public.MQFW.UpdateById("user", userId, map[string]interface{}{
  809. "$set": map[string]interface{}{
  810. "i_export_promptAgain": status,
  811. },
  812. })
  813. d.ServeJson(map[string]interface{}{
  814. "error_code": 0,
  815. "error_msg": "",
  816. "success": boo,
  817. })
  818. return
  819. }
  820. func (d *DataExport) GetDontPromptAgain() {
  821. isPrompt := true
  822. userId := d.GetSession("mgoUserId").(string)
  823. user, ok := public.MQFW.FindById("user", userId, `{"i_export_promptAgain":1}`)
  824. if ok && user != nil && len(*user) > 0 {
  825. if util.IntAll((*user)["i_export_promptAgain"]) == 1 {
  826. isPrompt = false
  827. }
  828. }
  829. d.ServeJson(map[string]interface{}{
  830. "error_code": 0,
  831. "error_msg": "",
  832. "isPrompt": isPrompt,
  833. })
  834. return
  835. }
  836. //
  837. //func (d *DataExport) EntDataExport(_id string) error {
  838. // id := util.se.Decode4Hex(_id)
  839. // userId := util.ObjToString(d.GetSession("userId"))
  840. // entId := util.IntAll(d.GetSession("entId"))
  841. // entUserId := util.IntAll(d.GetSession("entUserId"))
  842. // isFirst, err := d.GetBool("isFirst")
  843. // if err != nil {
  844. // isFirst = true
  845. // }
  846. // if userId == "" {
  847. // return errors.New("未登录")
  848. // }
  849. // exportLock.Lock()
  850. // exportLockMap[entId] = sync.Mutex{}
  851. // entLock := exportLockMap[entId]
  852. // exportLock.Unlock()
  853. // entLock.Lock()
  854. // query := map[string]interface{}{"ent_id": entId, "user_id": entUserId}
  855. // data_limit, remain_nums, export_nums := 0, 0, 0
  856. // limit := public.Mysql.FindOne("entniche_export_limit", query, "data_limit,remain_nums,export_nums", "")
  857. // if limit != nil {
  858. // data_limit = util.IntAll((*limit)["data_limit"])
  859. // remain_nums = util.IntAll((*limit)["remain_nums"])
  860. // export_nums = util.IntAll((*limit)["export_nums"])
  861. // }
  862. // count := 0
  863. // newCount := 0
  864. // data := &[]map[string]interface{}{}
  865. // current := GetCurrentCount(entId)
  866. // log.Println("企业总条数", current)
  867. // url := config.Sysconfig["dedupUrl"].(string)
  868. // count, newCount, data = public.GetEntDataExportCount(id, entId, entUserId, remain_nums, current, isFirst, util.ObjToString(config.Sysconfig["webdomain"]), url)
  869. // isExport := true
  870. // isEntExport := true
  871. // if newCount > current {
  872. // isEntExport = false
  873. // }
  874. // if newCount > remain_nums {
  875. // isExport = false
  876. // }
  877. // //current 企业总条数 count 筛选条数 newCount 去重后条数 exportNum 今日已导出 limit 今日剩余 limitDay 今日限额
  878. // result := map[string]interface{}{
  879. // "newCount": newCount,
  880. // "count": count,
  881. // "limit": remain_nums,
  882. // "limitDay": data_limit,
  883. // "exportNum": export_nums,
  884. // "current": current,
  885. // "isExport": isExport,
  886. // "isEntExport": isEntExport,
  887. // }
  888. // if isFirst || !isExport || !isEntExport {
  889. // entLock.Unlock()
  890. // d.ServeJson(result)
  891. // } else {
  892. // go func() {
  893. // data = public.FormatExportDatas(data, config.Sysconfig["webdomain"].(string), "2", entId)
  894. // xlsxUrl := GetXlsx(*data, entId, entUserId)
  895. // if xlsxUrl != "" {
  896. // filter := Filters{
  897. // FilterId: id,
  898. // }
  899. // filterStr, _ := json.Marshal(filter)
  900. // SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums, xlsxUrl, "2", string(filterStr))
  901. // DeductNum(entId, newCount)
  902. // go func() {
  903. // for _, v := range *data {
  904. // mongodb.Save("entdataexport", v)
  905. // }
  906. // }()
  907. // redis.Put("other", "entexportdata_"+fmt.Sprintln(entId), xlsxUrl, 60)
  908. // entLock.Unlock()
  909. // }
  910. // }()
  911. // d.ServeJson(result)
  912. // }
  913. // return nil
  914. //}
  915. // 剑鱼pc判断登录用户是否有我的企业、商机管理菜单
  916. func (this *DataExport) GetPcEntAuth() {
  917. userId, _ := this.GetSession("userId").(string)
  918. //userId := "1212"
  919. if userId == "" {
  920. data := map[string]interface{}{
  921. "error_code": 1001,
  922. "myEntMenu": true,
  923. "entnicheMenu": true,
  924. }
  925. this.ServeJson(data)
  926. return
  927. }
  928. phone, _ := GetPhone(userId)
  929. //phone = "15136225931"
  930. myEntMenu := false
  931. entnicheMenu := false
  932. privatedata := false
  933. pcUsers := map[int]bool{}
  934. hideUsers := map[int]bool{}
  935. for _, v := range config.EntnichePcConf.EntnichePcUser {
  936. pcUsers[v] = true
  937. }
  938. for _, v := range config.EntnichePcConf.HideEntnicheMenu {
  939. hideUsers[v] = true
  940. }
  941. isNew := false
  942. if phone != "" {
  943. ent := public.Mysql.SelectBySql("select id,isNew,phone,createtime from entniche_info where phone=? and status=1 ", phone)
  944. if ent != nil && len(*ent) != 0 {
  945. for _, val := range *ent {
  946. if pcUsers[util.IntAll(val["id"])] {
  947. myEntMenu = true
  948. if hideUsers[util.IntAll(val["id"])] {
  949. entnicheMenu = false
  950. } else {
  951. if util.IntAll(val["isNew"]) == 1 {
  952. isNew = true
  953. }
  954. entnicheMenu = true
  955. }
  956. break
  957. }
  958. }
  959. }
  960. if !myEntMenu {
  961. user := public.Mysql.SelectBySql("select id,ent_id,power,export_power from entniche_user where phone=? ORDER BY power desc", phone)
  962. if user != nil && len(*user) > 0 {
  963. for _, v := range *user {
  964. if pcUsers[util.IntAll(v["ent_id"])] {
  965. ents := public.Mysql.SelectBySql("select status,id,createtime,isNew from entniche_info where id=? ", util.IntAll(v["ent_id"]))
  966. if ents != nil && len(*ents) != 0 {
  967. for _, vv := range *ents {
  968. if util.IntAll(vv["status"]) == 1 {
  969. myEntMenu = true
  970. }
  971. if util.IntAll(v["power"]) == 1 {
  972. if hideUsers[util.IntAll(vv["id"])] {
  973. entnicheMenu = false
  974. } else {
  975. if util.IntAll(vv["isNew"]) == 1 {
  976. isNew = true
  977. }
  978. entnicheMenu = true
  979. }
  980. }
  981. }
  982. }
  983. break
  984. }
  985. }
  986. }
  987. }
  988. userCount := public.Mysql.CountBySql("select count(1) from privatedata where phone=?", phone)
  989. if userCount > 0 {
  990. privatedata = true
  991. }
  992. }
  993. data := map[string]interface{}{
  994. "myEntMenu": true,
  995. "entnicheMenu": entnicheMenu,
  996. "isNew": isNew,
  997. "privatedata": privatedata,
  998. }
  999. this.ServeJson(data)
  1000. }
  1001. //
  1002. ////判断是否导出成功
  1003. //func (this *DataExport) IsEntExportSuccess() {
  1004. // entId := util.IntAll(this.GetSession("entId"))
  1005. // res := map[string]interface{}{
  1006. // "state": false,
  1007. // }
  1008. // if entId != 0 {
  1009. // key := "entexportdata_" + fmt.Sprintln(entId)
  1010. // log.Println(key)
  1011. // xlsxUrl := redis.Get("other", key)
  1012. // log.Println(xlsxUrl)
  1013. // if xlsxUrl != nil {
  1014. // res["state"] = true
  1015. // res["xlsxUrl"] = xlsxUrl
  1016. // redis.Del("other", key)
  1017. // }
  1018. // }
  1019. // this.ServeJson(res)
  1020. //}
  1021. //
  1022. ////生成xlsx
  1023. //func GetXlsx(mMap []map[string]interface{}, entId, entUserId int) string {
  1024. // xf, err := xlsx.OpenFile("./web/staticres/fields.xlsx")
  1025. // if err != nil {
  1026. // log.Println("fields file not foud", err.Error())
  1027. // }
  1028. // sh := xf.Sheets[1]
  1029. // for _, v := range mMap {
  1030. // row := sh.AddRow()
  1031. // row.AddCell().SetValue(v["area"])
  1032. // row.AddCell().SetValue(v["city"])
  1033. // row.AddCell().SetValue(v["title"])
  1034. // row.AddCell().SetValue(v["subtype"])
  1035. // row.AddCell().SetValue(v["detail"])
  1036. // if v["publishtime"] != nil {
  1037. // row.AddCell().SetValue(v["publishtime"])
  1038. // } else {
  1039. // row.AddCell()
  1040. // }
  1041. // row.AddCell().SetValue(v["href"])
  1042. // row.AddCell().SetValue(v["url"])
  1043. // row.AddCell().SetValue(v["projectname"])
  1044. // row.AddCell().SetValue(v["projectcode"])
  1045. // row.AddCell().SetValue(v["projectscope"])
  1046. // if v["budget"] != nil {
  1047. // row.AddCell().SetFloat(util.Float64All(v["budget"]))
  1048. // } else {
  1049. // row.AddCell()
  1050. // }
  1051. // if v["bidamount"] != nil {
  1052. // row.AddCell().SetFloat(util.Float64All(v["bidamount"]))
  1053. // } else {
  1054. // row.AddCell()
  1055. // }
  1056. // if v["bidopentime"] != nil {
  1057. // row.AddCell().SetValue(v["bidopentime"])
  1058. // } else {
  1059. // row.AddCell()
  1060. // }
  1061. // row.AddCell().SetValue(v["buyer"])
  1062. // row.AddCell().SetValue(v["buyerperson"])
  1063. // row.AddCell().SetValue(v["buyertel"])
  1064. // row.AddCell().SetValue(v["agency"])
  1065. // row.AddCell().SetValue(v["s_winner"])
  1066. // row.AddCell().SetValue(v["winnerperson"])
  1067. // row.AddCell().SetValue(v["winnertel"])
  1068. // row.AddCell().SetValue(v["legal_person"])
  1069. // row.AddCell().SetValue(v["company_phone"])
  1070. // row.AddCell().SetValue(v["company_email"])
  1071. // }
  1072. // xf.Sheets = xf.Sheets[1:2]
  1073. // xf.Sheets[0].Name = "数据导出"
  1074. // //生文件
  1075. // t := strconv.FormatInt(time.Now().Unix(), 10)
  1076. // entIds := strconv.Itoa(entId)
  1077. // entUserIds := strconv.Itoa(entUserId)
  1078. // dir := "./web/staticres/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/"
  1079. // if b, _ := PathExists(dir); !b {
  1080. // err1 := os.MkdirAll(dir, os.ModePerm)
  1081. // if err1 != nil {
  1082. // log.Println("mkdir err", dir)
  1083. // }
  1084. // }
  1085. // fname := entIds + "_" + entUserIds + "_" + "entdataexport.xlsx"
  1086. // xlsxUrl := dir + fname
  1087. // xlsxUrls := "/xlsx/entsearchexport/" + entIds + "_" + entUserIds + "_" + t + "/" + fname
  1088. // err = xf.Save(xlsxUrl)
  1089. // if err != nil {
  1090. // log.Println("xls error", fname)
  1091. // xlsxUrls = ""
  1092. // }
  1093. // return xlsxUrls
  1094. //}
  1095. //
  1096. //func PathExists(path string) (bool, error) {
  1097. // _, err := os.Stat(path)
  1098. // if err == nil {
  1099. // return true, nil
  1100. // }
  1101. // if os.IsNotExist(err) {
  1102. // return false, nil
  1103. // }
  1104. // return false, err
  1105. //}
  1106. //
  1107. //func SaveExportLog(entId, entUserId, count, newCount, remain_nums, export_nums int, xlsxUrl, types, filterStr string) {
  1108. // query := map[string]interface{}{
  1109. // "id": entUserId,
  1110. // "ent_id": entId,
  1111. // }
  1112. // set := map[string]interface{}{
  1113. // "remain_nums": remain_nums - newCount,
  1114. // "export_nums": export_nums + newCount,
  1115. // }
  1116. // ok := public.Mysql.Update("entniche_export_limit", map[string]interface{}{"ent_id": entId, "user_id": entUserId}, set)
  1117. // if !ok {
  1118. // log.Println("修改导出条数失败", query, remain_nums, newCount)
  1119. // }
  1120. // userData := public.Mysql.FindOne("entniche_user", query, "name,phone", "")
  1121. // if userData != nil {
  1122. // name := util.ObjToString((*userData)["name"])
  1123. // phone := util.ObjToString((*userData)["phone"])
  1124. // now := time.Now()
  1125. // public.Mysql.Insert("entniche_export_log", map[string]interface{}{
  1126. // "user_name": name,
  1127. // "export_time": FormatDate(&now, util.Date_Full_Layout),
  1128. // "data_source": "2",
  1129. // "export_num": count,
  1130. // "deduct_num": newCount,
  1131. // "download_url": xlsxUrl,
  1132. // "ent_id": entId,
  1133. // "phone": phone,
  1134. // "user_id": entUserId,
  1135. // "filter": filterStr,
  1136. // })
  1137. // }
  1138. //}
  1139. //
  1140. //func DeductNum(entId, newCount int) {
  1141. // query := map[string]interface{}{
  1142. // "id": entId,
  1143. // }
  1144. // userData := public.Mysql.FindOne("entniche_info", query, "name,phone", "")
  1145. // if userData != nil {
  1146. // name := util.ObjToString((*userData)["name"])
  1147. // phone := util.ObjToString((*userData)["phone"])
  1148. // public.Mgo_Qyfw.Update("user", map[string]interface{}{"phone": phone, "username": name}, map[string]interface{}{
  1149. // "$inc": map[string]interface{}{
  1150. // "plan.current": -newCount,
  1151. // },
  1152. // }, false, false)
  1153. // }
  1154. //}
  1155. //
  1156. //func GetCurrentCount(entId int) int {
  1157. // count := 0
  1158. // userData := public.Mysql.FindOne("entniche_info", map[string]interface{}{"id": entId}, "name,phone", "")
  1159. // if userData == nil {
  1160. // return count
  1161. // }
  1162. // current, ok := public.Mgo_Qyfw.FindOne("user", map[string]interface{}{"phone": util.ObjToString((*userData)["phone"]), "username": util.ObjToString((*userData)["name"])})
  1163. // if current == nil || !ok {
  1164. // return count
  1165. // }
  1166. // plan, _ := (*current)["plan"].(map[string]interface{})
  1167. // count = util.IntAll(plan["current"])
  1168. // return count
  1169. //}
  1170. // 获取当前登录用户的手机号
  1171. func GetPhone(userId string) (string, string) {
  1172. u := jyutil.Compatible.Select(userId, `{"s_phone":1,"s_m_phone":1}`)
  1173. if u != nil {
  1174. if s_phone, _ := (*u)["s_phone"].(string); s_phone != "" {
  1175. return s_phone, "s_phone"
  1176. } else if s_m_phone, _ := (*u)["s_m_phone"].(string); s_m_phone != "" {
  1177. return s_m_phone, "s_m_phone"
  1178. }
  1179. }
  1180. return "", ""
  1181. }
  1182. func (d *DataExport) MemberDetail() {
  1183. d.Render("/pc/member_orderDetail.html")
  1184. }
  1185. func (d *DataExport) AiForecastPackDetail() {
  1186. d.Render("/pc/aiPack_orderDetail.html")
  1187. }
  1188. func (d *DataExport) SubAccountDetail() {
  1189. d.Render("/pc/subAccount_orderDetail.html")
  1190. }
  1191. func (d *DataExport) BidfileDetail() {
  1192. d.Render("/order/pc/bidfile/bidfileDetail.html")
  1193. }
  1194. func (d *DataExport) IntegralDetail() {
  1195. d.Render("/order/pc/integral/integralDetail.html")
  1196. }