user_merchant_get_name.go 864 B

123456789101112131415161718192021222324252627282930
  1. package user_merchant
  2. import (
  3. "context"
  4. "gd_management/apis"
  5. "gd_management/common.in/utils"
  6. "gd_management/errors"
  7. "fmt"
  8. "github.com/astaxie/beego/orm"
  9. //"go.uber.org/zap"
  10. )
  11. func ManagementGetUserMerchantName(ctx context.Context, req *apis.ManagementGetUserMerchantNameReq, reply *apis.ManagementGetUserMerchantNameReply) (err error) {
  12. appKeys := ""
  13. for _, v := range req.AppKeys {
  14. if appKeys == "" {
  15. appKeys = fmt.Sprintf("\"%s\"", v)
  16. } else {
  17. appKeys = fmt.Sprintf("%s,\"%s\"", appKeys, v)
  18. }
  19. }
  20. sql := "select a.app_key, a.merchant_name, b.name as user_name from t_gd_merchants as a inner join t_gd_user as b on a.user_id = b.id where a.app_key in(" + appKeys + ")"
  21. o := orm.NewOrm()
  22. _, err = o.Raw(sql).QueryRows(&reply.Infos)
  23. if err != nil {
  24. return errors.DataBaseError
  25. }
  26. l.Debug(utils.MarshalJsonString(req, reply))
  27. return
  28. }