supplyinfodetaillogic.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package logic
  2. import (
  3. se "app.yhyue.com/moapp/jybase/encrypt"
  4. "context"
  5. "app.yhyue.com/moapp/jyInfo/rpc/model"
  6. es "app.yhyue.com/moapp/jyInfo/rpc/model/es"
  7. "log"
  8. "strconv"
  9. "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumer"
  10. "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
  11. mc "app.yhyue.com/moapp/jybase/common"
  12. "github.com/zeromicro/go-zero/core/logx"
  13. )
  14. type SupplyInfoDetailLogic struct {
  15. ctx context.Context
  16. svcCtx *svc.ServiceContext
  17. logx.Logger
  18. }
  19. func NewSupplyInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SupplyInfoDetailLogic {
  20. return &SupplyInfoDetailLogic{
  21. ctx: ctx,
  22. svcCtx: svcCtx,
  23. Logger: logx.WithContext(ctx),
  24. }
  25. }
  26. // 供应信息详情
  27. func (l *SupplyInfoDetailLogic) SupplyInfoDetail(in *consumer.StatusReq) (*consumer.SupplyInfoDetailResp, error) {
  28. var resp consumer.SupplyInfoDetailResp
  29. msgId := se.SE.DecodeString(in.MsgId) //信息id解密
  30. if in.Type == 0 {
  31. data := model.Mysql.FindOne("supply_info", map[string]interface{}{"id": msgId}, "", "")
  32. if *data != nil {
  33. var info consumer.SupplyInfoDetailData
  34. info.Title = mc.InterfaceToStr((*data)["title"])
  35. info.Detail = mc.InterfaceToStr((*data)["detail"])
  36. info.PublishTime = mc.InterfaceToStr((*data)["publish_time"])
  37. info.ValidityTime = mc.InterfaceToStr((*data)["validity_time"])
  38. info.Province = mc.InterfaceToStr((*data)["province"])
  39. info.City = mc.InterfaceToStr((*data)["city"])
  40. var conctact consumer.InfoDetailContact
  41. conctact.Phone = mc.InterfaceToStr((*data)["contact_phone"])
  42. conctact.Name = mc.InterfaceToStr((*data)["contact_person"])
  43. conctact.Overt = mc.Int64All((*data)["contact_overt"])
  44. info.InfoDetailContact = &conctact
  45. info.Attach = mc.InterfaceToStr((*data)["attach"])
  46. info.EntId = mc.InterfaceToStr((*data)["ent_id"])
  47. info.Id = in.MsgId
  48. //其他供应信息
  49. otherData := es.GetSupplyOtherInfoByEntid(info.EntId, 5)
  50. if otherData != nil && len(*otherData) > 0 {
  51. for _, v := range *otherData {
  52. if info.Id == se.SE.EncodeString(mc.InterfaceToStr(v["_id"])) {
  53. continue
  54. }
  55. otherSupplyInfo := consumer.OtherSupplyInfoByEnt{
  56. Title: mc.InterfaceToStr(v["title"]),
  57. Id: se.SE.EncodeString(mc.InterfaceToStr(v["_id"])),
  58. Province: mc.InterfaceToStr(v["province"]),
  59. City: mc.InterfaceToStr(v["city"]),
  60. PublishTime: strconv.FormatInt(mc.Int64All(v["publish_time"]), 10),
  61. CreateTime: strconv.FormatInt(mc.Int64All(v["create_time"]), 10),
  62. EntId: se.SE.EncodeString(mc.InterfaceToStr(v["ent_id"])),
  63. }
  64. info.OtherSupplyInfo = append(info.OtherSupplyInfo, &otherSupplyInfo)
  65. }
  66. }
  67. log.Println(len(*otherData), "otherData:", info.OtherSupplyInfo)
  68. resp.Data = &info
  69. return &resp, nil
  70. }
  71. resp.ErrCode = -1
  72. resp.ErrMsg = "未查询到相关数据"
  73. resp.Data = nil
  74. return &resp, nil
  75. }
  76. return &consumer.SupplyInfoDetailResp{}, nil
  77. }