ent.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package service
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. MC "bp.jydev.jianyu360.cn/CRM/application/api/common"
  5. "errors"
  6. "log"
  7. "strings"
  8. "time"
  9. )
  10. type EntService struct {
  11. }
  12. const (
  13. Date_Full_Layout = "2006-01-02 15:04:05"
  14. Date_Short_Layout = "2006-01-02"
  15. )
  16. func (in *EntService) EntInfo(entName string) (map[string]interface{}, error) {
  17. entinfo, _ := MC.MgoEnt.FindOneByField("qyxy_std", map[string]interface{}{"company_name": entName}, map[string]interface{}{
  18. "company_type": 1, //公司类型
  19. //"issue_date": 1, //核准日期
  20. "operation_startdate": 1, //营业期限开始
  21. "operation_enddate": 1, //营业期限结束
  22. //"authority": 1, //登记机关
  23. "credit_no": 1, //统一社会信用代码
  24. "tax_code": 1, //纳税人识别码
  25. "capital": 1, //注册资本
  26. "establish_date": 1, //成立日期
  27. "company_status": 1, //经营状态
  28. "employee_no": 1, //员工规模
  29. "company_address": 1, //注册地
  30. "business_scope": 1, //经营范围
  31. "company_code": 1, //工商注册号
  32. "org_code": 1, //组织机构代码
  33. //"stock_realcapital": 1, //实缴资本
  34. "legal_person": 1, //法人姓名
  35. "company_phone": 1, //公司电话
  36. })
  37. if entinfo == nil || len(*entinfo) == 0 {
  38. log.Println()
  39. return nil, errors.New("未查询到企业相关信息")
  40. }
  41. rData := map[string]interface{}{
  42. "type": (*entinfo)["company_type"],
  43. "status": (*entinfo)["company_status"],
  44. "creditNo": (*entinfo)["credit_no"],
  45. "taxCode": (*entinfo)["tax_code"],
  46. "capital": (*entinfo)["capital"],
  47. "employeeNo": (*entinfo)["employee_no"],
  48. "address": (*entinfo)["company_address"],
  49. "scope": (*entinfo)["business_scope"],
  50. "company_code": (*entinfo)["company_code"],
  51. "org_code": (*entinfo)["org_code"],
  52. "operStart": paseDateToint64(common.ObjToString((*entinfo)["operation_startdate"])),
  53. "operEnd": paseDateToint64(common.ObjToString((*entinfo)["operation_enddate"])),
  54. "establish": paseDateToint64(common.ObjToString((*entinfo)["establish_date"])),
  55. "legal": (*entinfo)["legal_person"],
  56. "phone": (*entinfo)["company_phone"],
  57. "entName": (*entinfo)["company_name"],
  58. }
  59. return rData, nil
  60. }
  61. func paseDateToint64(dateStr string) (timeStamp int64) {
  62. timeStamp = -1
  63. if dateStr == "" {
  64. return
  65. }
  66. if thisTime, err := time.Parse(Date_Short_Layout, dateStr); err == nil {
  67. timeStamp = thisTime.Unix()
  68. }
  69. //企业变更部分信息时间格式2017-04-18 00:00:00.0
  70. if len(strings.Split(dateStr, " ")) == 2 {
  71. if thisTime, err := time.Parse(Date_Full_Layout, dateStr); err == nil {
  72. timeStamp = thisTime.Unix()
  73. }
  74. }
  75. return
  76. }