12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package logic
- import (
- "app.yhyue.com/moapp/jyInfo/rpc/model"
- es "app.yhyue.com/moapp/jyInfo/rpc/model/es"
- se "app.yhyue.com/moapp/jybase/encrypt"
- "context"
- "log"
- "regexp"
- "strconv"
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/consumerinfo"
- "app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
- mc "app.yhyue.com/moapp/jybase/common"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type SupplyInfoDetailLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewSupplyInfoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SupplyInfoDetailLogic {
- return &SupplyInfoDetailLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 供应信息详情
- func (l *SupplyInfoDetailLogic) SupplyInfoDetail(in *consumerinfo.StatusReq) (*consumerinfo.SupplyInfoDetailResp, error) {
- var resp consumerinfo.SupplyInfoDetailResp
- msgId := se.SE.DecodeString(in.MsgId) //信息id解密
- logx.Info(msgId, "-------msgid:", in.MsgId)
- if in.Type == 0 {
- data := model.Mysql.FindOne("supply_info", map[string]interface{}{"id": msgId}, "", "")
- if *data != nil {
- astr := mc.InterfaceToStr((*data)["attach"])
- regfid := regexp.MustCompile(`"fid":".*?",`)
- regoss := regexp.MustCompile(`"ossurl":".*?",`)
- astr = regfid.ReplaceAllString(astr, "")
- astr = regoss.ReplaceAllString(astr, "")
- var info consumerinfo.SupplyInfoDetailData
- info.Title = mc.InterfaceToStr((*data)["title"])
- info.Detail = mc.InterfaceToStr((*data)["detail"])
- info.PublishTime = mc.InterfaceToStr((*data)["publish_time"])
- info.ValidityTime = mc.InterfaceToStr((*data)["validity_time"])
- info.Province = mc.InterfaceToStr((*data)["province"])
- info.City = mc.InterfaceToStr((*data)["city"])
- var conctact consumerinfo.InfoDetailContact
- conctact.Phone = mc.If(mc.Int64All((*data)["contact_overt"]) == 1, mc.InterfaceToStr((*data)["contact_phone"]), "").(string)
- conctact.Name = mc.InterfaceToStr((*data)["contact_person"])
- conctact.Overt = mc.Int64All((*data)["contact_overt"])
- info.InfoDetailContact = &conctact
- info.Attach = astr
- info.EntId = mc.Int64All((*data)["ent_id"])
- info.Id = in.MsgId
- //其他供应信息
- otherData := es.GetSupplyOtherInfoByEntid(mc.InterfaceToStr(info.EntId), 5)
- if otherData != nil && len(*otherData) > 0 {
- for _, v := range *otherData {
- if info.Id == se.SE.EncodeString(mc.InterfaceToStr(v["_id"])) {
- continue
- }
- otherSupplyInfo := consumerinfo.OtherSupplyInfoByEnt{
- Title: mc.InterfaceToStr(v["title"]),
- Id: se.SE.EncodeString(mc.InterfaceToStr(v["_id"])),
- Province: mc.InterfaceToStr(v["province"]),
- City: mc.InterfaceToStr(v["city"]),
- PublishTime: strconv.FormatInt(mc.Int64All(v["publish_time"]), 10),
- CreateTime: strconv.FormatInt(mc.Int64All(v["create_time"]), 10),
- EntId: mc.Int64All(v["ent_id"]),
- }
- info.OtherSupplyInfo = append(info.OtherSupplyInfo, &otherSupplyInfo)
- }
- }
- log.Println(len(*otherData), "otherData:", info.OtherSupplyInfo)
- resp.Data = &info
- return &resp, nil
- }
- resp.ErrCode = -1
- resp.ErrMsg = "未查询到相关数据"
- resp.Data = nil
- return &resp, nil
- }
- return &consumerinfo.SupplyInfoDetailResp{}, nil
- }
|