dataExport.go 37 KB

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