dataExport.go 40 KB

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